On 1/17/2020 11:46 AM, Finn, Emma wrote:
Re-sending to patchwork

-----Original Message-----
From: Finn, Emma <emma.f...@intel.com>
Sent: Friday 17 January 2020 10:11
To: d...@openvswitch.com
Cc: i.maxim...@ovn.org; Stokes, Ian <ian.sto...@intel.com>; Finn, Emma
<emma.f...@intel.com>
Subject: [v5] dpif-netdev: Modified ovs-appctl dpctl/dump-flows command

Modified ovs-appctl dpctl/dump-flows command to output the miniflow bits
for a given flow when -m option is passed.

$ ovs-appctl dpctl/dump-flows -m

Signed-off-by: Emma Finn <emma.f...@intel.com>

Thanks Emma,

Applied to master.

BR Ian

---

RFC -> v1

* Changed revision from RFC to v1
* Reformatted based on comments
* Fixed same classifier being dumped multiple times
   flagged by Ilya
* Fixed print of subtables flagged by William
* Updated print count of bits as well as bits themselves

---

v1 -> v2

* Reformatted based on comments
* Refactored code to make output part of ovs-appctl
   dpctl/dump-flows -m command.

---

v2 -> v3

* Added attribute dp_extra_info to dpif_flow_attrs struct
   to store miniflow bits as a string

---

v3 -> v4

* Fixed string leak
* Refactored to code to make it  independent from the flowmap size

---

v4 -> v5

* Rebase on top of master branch
---
  NEWS              |  2 ++
  lib/dpctl.c       |  4 ++++
  lib/dpif-netdev.c | 15 +++++++++++++++
  lib/dpif.h        |  1 +
  4 files changed, 22 insertions(+)

diff --git a/NEWS b/NEWS
index 4d56eee..272650b 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Post-v2.12.0
       * Add option to enable, disable and query TCP sequence checking in
         conntrack.
       * Add support for conntrack zone limits.
+     * Command "ovs-appctl dpctl/dump-flows" refactored to show subtable
+       miniflow bits for userspace datapath.
     - AF_XDP:
       * New option 'use-need-wakeup' for netdev-afxdp to control enabling
         of corresponding 'need_wakeup' flag in AF_XDP rings.  Enabled by
default diff --git a/lib/dpctl.c b/lib/dpctl.c index 23c2682..4ebb004 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -829,6 +829,10 @@ format_dpif_flow(struct ds *ds, const struct
dpif_flow *f, struct hmap *ports,
      }
      ds_put_cstr(ds, ", actions:");
      format_odp_actions(ds, f->actions, f->actions_len, ports);
+    if (dpctl_p->verbosity && f->attrs.dp_extra_info) {
+        ds_put_format(ds, ", dp-extra-info:%s", f->attrs.dp_extra_info);
+    }
+    free(f->attrs.dp_extra_info);
  }

  struct dump_types {
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 909843e..3be4101
100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3158,6 +3158,21 @@ dp_netdev_flow_to_dpif_flow(const struct
dp_netdev *dp,
      flow->pmd_id = netdev_flow->pmd_id;

      get_dpif_flow_status(dp, netdev_flow, &flow->stats, &flow->attrs);
+
+    struct ds extra_info = DS_EMPTY_INITIALIZER;
+    size_t unit;
+
+    ds_put_cstr(&extra_info, "miniflow_bits(");
+    FLOWMAP_FOR_EACH_UNIT (unit) {
+        if (unit) {
+            ds_put_char(&extra_info, ',');
+        }
+        ds_put_format(&extra_info, "%d",
+                      count_1bits(netdev_flow->cr.mask->mf.map.bits[unit]));
+    }
+    ds_put_char(&extra_info, ')');
+    flow->attrs.dp_extra_info = ds_steal_cstr(&extra_info);
+    ds_destroy(&extra_info);
  }

  static int
diff --git a/lib/dpif.h b/lib/dpif.h
index c21e897..59d82dc 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -513,6 +513,7 @@ struct dpif_flow_detailed_stats {  struct
dpif_flow_attrs {
      bool offloaded;         /* True if flow is offloaded to HW. */
      const char *dp_layer;   /* DP layer the flow is handled in. */
+    char *dp_extra_info;    /* Extra information provided by DP. */
  };

  struct dpif_flow_dump_types {
--
2.7.4

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to