diff mbox

[ovs-dev,V10,28/33] dpctl: Indicate if flow is offloaded when dumping flows of all types

Message ID 1496922410-36853-29-git-send-email-roid@mellanox.com
State Superseded
Headers show

Commit Message

Roi Dayan June 8, 2017, 11:46 a.m. UTC
From: Paul Blakey <paulb@mellanox.com>

When verbosity is requested on dump-flows (-m) indicate which flows
are offloaded.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
---
 lib/dpctl.c        | 11 ++++++++---
 lib/dpif-netlink.c |  4 ++++
 lib/dpif.h         |  1 +
 3 files changed, 13 insertions(+), 3 deletions(-)

Comments

Flavio Leitner June 10, 2017, 1:23 p.m. UTC | #1
On Thu, Jun 08, 2017 at 02:46:45PM +0300, Roi Dayan wrote:
> From: Paul Blakey <paulb@mellanox.com>
> 
> When verbosity is requested on dump-flows (-m) indicate which flows
> are offloaded.
> 
> Signed-off-by: Paul Blakey <paulb@mellanox.com>
> Reviewed-by: Roi Dayan <roid@mellanox.com>
> ---

I'd suggest to either say offloaded: yes or no, and not to just
add the field if offloaded. It makes harder to parse on a script.

I can propose an improvement if this gets merged, so it's not a
problem for me.

Acked-by: Flavio Leitner <fbl@sysclose.org>
Simon Horman June 15, 2017, 10:14 a.m. UTC | #2
On Sat, Jun 10, 2017 at 10:23:11AM -0300, Flavio Leitner wrote:
> On Thu, Jun 08, 2017 at 02:46:45PM +0300, Roi Dayan wrote:
> > From: Paul Blakey <paulb@mellanox.com>
> > 
> > When verbosity is requested on dump-flows (-m) indicate which flows
> > are offloaded.
> > 
> > Signed-off-by: Paul Blakey <paulb@mellanox.com>
> > Reviewed-by: Roi Dayan <roid@mellanox.com>
> > ---
> 
> I'd suggest to either say offloaded: yes or no, and not to just
> add the field if offloaded. It makes harder to parse on a script.
> 
> I can propose an improvement if this gets merged, so it's not a
> problem for me.
> 
> Acked-by: Flavio Leitner <fbl@sysclose.org>

I have applied v11 to master.

I for one am in favour of seeing your proposed improvement.
diff mbox

Patch

diff --git a/lib/dpctl.c b/lib/dpctl.c
index a2ee8a2..7f44d02 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -739,7 +739,7 @@  dpctl_dump_dps(int argc OVS_UNUSED, const char *argv[] OVS_UNUSED,
 
 static void
 format_dpif_flow(struct ds *ds, const struct dpif_flow *f, struct hmap *ports,
-                 struct dpctl_params *dpctl_p)
+                 char *type, struct dpctl_params *dpctl_p)
 {
     if (dpctl_p->verbosity && f->ufid_present) {
         odp_format_ufid(&f->ufid, ds);
@@ -750,6 +750,9 @@  format_dpif_flow(struct ds *ds, const struct dpif_flow *f, struct hmap *ports,
     ds_put_cstr(ds, ", ");
 
     dpif_flow_stats_format(&f->stats, ds);
+    if (dpctl_p->verbosity && !type && f->offloaded) {
+        ds_put_cstr(ds, ", offloaded:yes");
+    }
     ds_put_cstr(ds, ", actions:");
     format_odp_actions(ds, f->actions, f->actions_len);
 }
@@ -850,6 +853,7 @@  dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
     BUILD_ASSERT(PMD_ID_NULL != NON_PMD_CORE_ID);
 
     ds_init(&ds);
+    memset(&f, 0, sizeof f);
     flow_dump = dpif_flow_dump_create(dpif, false, (type ? type : "dpctl"));
     flow_dump_thread = dpif_flow_dump_thread_create(flow_dump);
     while (dpif_flow_dump_next(flow_dump_thread, &f, 1)) {
@@ -886,7 +890,8 @@  dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p)
             }
             pmd_id = f.pmd_id;
         }
-        format_dpif_flow(&ds, &f, &portno_names, dpctl_p);
+        format_dpif_flow(&ds, &f, &portno_names, type, dpctl_p);
+
         dpctl_print(dpctl_p, "%s\n", ds_cstr(&ds));
     }
     dpif_flow_dump_thread_destroy(flow_dump_thread);
@@ -1069,7 +1074,7 @@  dpctl_get_flow(int argc, const char *argv[], struct dpctl_params *dpctl_p)
     }
 
     ds_init(&ds);
-    format_dpif_flow(&ds, &flow, &portno_names, dpctl_p);
+    format_dpif_flow(&ds, &flow, &portno_names, NULL, dpctl_p);
     dpctl_print(dpctl_p, "%s\n", ds_cstr(&ds));
     ds_destroy(&ds);
 
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index f10c638..75cd228 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -1639,6 +1639,7 @@  dpif_netlink_flow_to_dpif_flow(struct dpif *dpif, struct dpif_flow *dpif_flow,
                        &dpif_flow->ufid);
     }
     dpif_netlink_flow_get_stats(datapath_flow, &dpif_flow->stats);
+    dpif_flow->offloaded = false;
 }
 
 /* The design is such that all threads are working together on the first dump
@@ -1718,6 +1719,9 @@  dpif_netlink_netdev_match_to_dpif_flow(struct match *match,
     flow->ufid = *ufid;
 
     flow->pmd_id = PMD_ID_NULL;
+
+    flow->offloaded = true;
+
     return 0;
 }
 
diff --git a/lib/dpif.h b/lib/dpif.h
index b1f516e..38efd29 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -591,6 +591,7 @@  struct dpif_flow {
     bool ufid_present;            /* True if 'ufid' was provided by datapath.*/
     unsigned pmd_id;              /* Datapath poll mode driver id. */
     struct dpif_flow_stats stats; /* Flow statistics. */
+    bool offloaded;               /* True if flow is offloaded */
 };
 int dpif_flow_dump_next(struct dpif_flow_dump_thread *,
                         struct dpif_flow *flows, int max_flows);