All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@netronome.com>
To: dev@openvswitch.org, netdev@vger.kernel.org
Cc: Pravin Shelar <pshelar@nicira.com>,
	Jesse Gross <jesse@nicira.com>, Thomas Graf <tgraf@suug.ch>,
	Simon Horman <simon.horman@netronome.com>
Subject: [PATCH/RFC repost 3/8] odp-util: formatting of datapath select group action
Date: Thu, 18 Sep 2014 10:55:06 +0900	[thread overview]
Message-ID: <1411005311-11752-4-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1411005311-11752-1-git-send-email-simon.horman@netronome.com>

Allow formatting of select group action. This is used
when pretty-printing datapath flows. Subsequent patches
will add support for the select group action to the datapath
and ovs-vswtichd.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 lib/odp-util.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 77b456f..4c8dd39 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -182,6 +182,71 @@ format_odp_sample_action(struct ds *ds, const struct nlattr *attr)
     ds_put_format(ds, "))");
 }
 
+static bool
+format_odp_bucket(struct ds *ds, const struct nlattr *attr)
+{
+    static const struct nl_policy ovs_sample_policy[] = {
+        [OVS_BUCKET_ATTR_WEIGHT] = { .type = NL_A_U16 },
+        [OVS_BUCKET_ATTR_ACTIONS] = { .type = NL_A_NESTED }
+    };
+    struct nlattr *a[ARRAY_SIZE(ovs_sample_policy)];
+    const struct nlattr *nla_acts;
+    int len;
+
+    ds_put_cstr(ds, "bucket");
+
+    if (!nl_parse_nested(attr, ovs_sample_policy, a, ARRAY_SIZE(a))) {
+        ds_put_cstr(ds, "(error)");
+        return false;
+    }
+
+    ds_put_format(ds, "(weight=%d,",
+                  nl_attr_get_u16(a[OVS_BUCKET_ATTR_WEIGHT]));
+
+    ds_put_cstr(ds, "actions(");
+    nla_acts = nl_attr_get(a[OVS_SAMPLE_ATTR_ACTIONS]);
+    len = nl_attr_get_size(a[OVS_SAMPLE_ATTR_ACTIONS]);
+    format_odp_actions(ds, nla_acts, len);
+    ds_put_format(ds, "))");
+
+    return true;
+}
+
+static void
+format_odp_select_group_action(struct ds *ds, const struct nlattr *attr)
+{
+    static const struct nl_policy ovs_sample_policy[] = {
+        [OVS_SELECT_GROUP_ATTR_BUCKET] = { .type = NL_A_NESTED,
+                                           .multiple = true }
+    };
+    struct nlattr *a[ARRAY_SIZE(ovs_sample_policy)];
+    struct nlattr *nla;
+    struct ofpbuf buf;
+    size_t left;
+
+    ds_put_cstr(ds, "select_group");
+
+    if (!nl_parse_nested(attr, ovs_sample_policy, a, ARRAY_SIZE(a))) {
+        ds_put_cstr(ds, "(error)");
+        return;
+    }
+
+    ds_put_cstr(ds, "(actions(");
+
+    nl_attr_get_nested(attr, &buf);
+    NL_ATTR_FOR_EACH (nla, left, ofpbuf_data(&buf), ofpbuf_size(&buf))
+    {
+        uint16_t type = nl_attr_type(nla);
+
+        ovs_assert(type == OVS_SELECT_GROUP_ATTR_BUCKET);
+        if (!format_odp_bucket(ds, nla)) {
+            break;
+        }
+    }
+
+    ds_put_format(ds, "))");
+}
+
 static const char *
 slow_path_reason_to_string(uint32_t reason)
 {
@@ -583,6 +648,8 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
         format_odp_sample_action(ds, a);
         break;
     case OVS_ACTION_ATTR_SELECT_GROUP:
+        format_odp_select_group_action(ds, a);
+        break;
     case OVS_ACTION_ATTR_UNSPEC:
     case __OVS_ACTION_ATTR_MAX:
     default:
-- 
2.0.1

  parent reply	other threads:[~2014-09-18  1:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18  1:55 [PATCH/RFC repost 0/8] Open vSwtich ODP Select Group Action Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 1/8] odp: select group action attributes Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 2/8] netlink: Allow suppression of warnings for duplicate attributes Simon Horman
     [not found]   ` <1411005311-11752-3-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-26 23:55     ` Ben Pfaff
2014-10-09  1:18       ` [ovs-dev] " Simon Horman
2014-10-10 15:31         ` Ben Pfaff
2014-09-18  1:55 ` Simon Horman [this message]
     [not found]   ` <1411005311-11752-4-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-19 13:44     ` [PATCH/RFC repost 3/8] odp-util: formatting of datapath select group action Thomas Graf
2014-09-24  4:55       ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 4/8] datapath: execution of " Simon Horman
     [not found]   ` <1411005311-11752-5-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-19 14:05     ` Thomas Graf
2014-09-24  6:01       ` Simon Horman
2014-09-24  8:19         ` Thomas Graf
2014-09-25  4:43           ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 5/8] datapath: Move last_action() helper to datapath.h Simon Horman
     [not found]   ` <1411005311-11752-6-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-19 14:06     ` Thomas Graf
2014-09-24  6:00       ` Simon Horman
     [not found]         ` <20140924060013.GB13314-IxS8c3vjKQDk1uMJSBkQmQ@public.gmane.org>
2014-09-24  8:20           ` Thomas Graf
2014-09-25  4:42             ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 6/8] datapath: validation of select group action Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 7/8] ofproto: translate datapath " Simon Horman
     [not found]   ` <1411005311-11752-8-git-send-email-simon.horman-wFxRvT7yatFl57MIdRCFDg@public.gmane.org>
2014-09-26 23:57     ` Ben Pfaff
2014-10-09  1:14       ` [ovs-dev] " Simon Horman
2014-10-13 20:46         ` Ben Pfaff
2014-10-14  4:54           ` Simon Horman
2014-09-18  1:55 ` [PATCH/RFC repost 8/8] hack: ofproto: enable odp select action Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411005311-11752-4-git-send-email-simon.horman@netronome.com \
    --to=simon.horman@netronome.com \
    --cc=dev@openvswitch.org \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.