diff mbox series

[ovs-dev,09/20] netdev: Add netdev function: flow_stats_get()

Message ID 20191120152826.25074-10-elibr@mellanox.com
State Changes Requested
Delegated to: Ilya Maximets
Headers show
Series netdev datapath actions offload | expand

Commit Message

Eli Britstein Nov. 20, 2019, 3:28 p.m. UTC
From: Ophir Munk <ophirmu@mellanox.com>

Add flow_stats_get() function to netdev offload class, as a pre-step
towards implementation of statistics quering fully offloaded flows.

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
Signed-off-by: Eli Britstein <elibr@mellanox.com>
---
 lib/netdev-offload-provider.h |  7 +++++++
 lib/netdev-offload.c          | 12 ++++++++++++
 lib/netdev-offload.h          |  2 ++
 3 files changed, 21 insertions(+)

Comments

0-day Robot Nov. 20, 2019, 4:21 p.m. UTC | #1
Bleep bloop.  Greetings Eli Britstein, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Eli Britstein <elibr@mellanox.com>
Lines checked: 74, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Ilya Maximets Nov. 26, 2019, 4:52 p.m. UTC | #2
On 20.11.2019 16:28, Eli Britstein wrote:
> From: Ophir Munk <ophirmu@mellanox.com>
> 
> Add flow_stats_get() function to netdev offload class, as a pre-step
> towards implementation of statistics quering fully offloaded flows.

Please, do not introduce new API for each dpif provider.

You need to implement existing netdev_flow_dump_*() API for querying flows
from the device along with their stats and use it via netdev_ports_flow_dump_create().

You may extend 'struct netdev_flow_dump' for your purposes. Currently
it contains 'nl_dump' which is for tc offload provider.  You may add
a new field, but be sure to not use this field outside of the netdev-offload
provider implementation.
Please, keep in mind that flow dump should work the same way if we'll
use tc offload for netdevs in userspace datapath.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h
index 4e1c4251d..9d275e07a 100644
--- a/lib/netdev-offload-provider.h
+++ b/lib/netdev-offload-provider.h
@@ -82,6 +82,13 @@  struct netdev_flow_api {
     int (*flow_del)(struct netdev *, const ovs_u128 *ufid,
                     struct dpif_flow_stats *);
 
+    /* Get offloaded flow stats.
+     * Populate the 'stats' structure with the HW counters values for the
+     * specified ufid.
+     * Return 0 if successful, otherwise returns a positive errno value. */
+    int (*flow_stats_get)(struct netdev *netdev, const ovs_u128 *ufid,
+                          struct dpif_flow_stats *stats);
+
     /* Initializies the netdev flow api.
      * Return 0 if successful, otherwise returns a positive errno value. */
     int (*init_flow_api)(struct netdev *);
diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c
index ae01acda6..9726bb19a 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -267,6 +267,18 @@  netdev_flow_del(struct netdev *netdev, const ovs_u128 *ufid,
            : EOPNOTSUPP;
 }
 
+int
+netdev_flow_stats_get(struct netdev *netdev, const ovs_u128 *ufid,
+                      struct dpif_flow_stats *stats)
+{
+    const struct netdev_flow_api *flow_api =
+        ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api);
+
+    return (flow_api && flow_api->flow_stats_get
+            ? flow_api->flow_stats_get(netdev, ufid, stats)
+            : EOPNOTSUPP);
+}
+
 int
 netdev_init_flow_api(struct netdev *netdev)
 {
diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h
index e27b8782e..78909a416 100644
--- a/lib/netdev-offload.h
+++ b/lib/netdev-offload.h
@@ -89,6 +89,8 @@  int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions,
                     struct dpif_flow_attrs *, struct ofpbuf *wbuffer);
 int netdev_flow_del(struct netdev *, const ovs_u128 *,
                     struct dpif_flow_stats *);
+int netdev_flow_stats_get(struct netdev *, const ovs_u128 *,
+                          struct dpif_flow_stats *);
 int netdev_init_flow_api(struct netdev *);
 void netdev_uninit_flow_api(struct netdev *);
 uint32_t netdev_get_block_id(struct netdev *);