diff mbox series

[ovs-dev,RFC,03/26] netdev-offload: Add function to read hardware offload stats

Message ID b8135d87cff8d24fe3d693bc2dc178b61b0cb8e7.1607177117.git.grive@u256.net
State RFC
Headers show
Series [ovs-dev,RFC,01/26] netdev: Add flow API de-init function | expand

Commit Message

Gaetan Rivet Dec. 5, 2020, 2:21 p.m. UTC
Add a function for an offload provider to report a device
hardware offload count.  It is not for reporting offload usage
statistics, i.e. in terms of packets or bytes matched by offloads,
but only to know how many offloads are currently programmed into the
device.

Because it is not related to any specific flow, this count is not
integrated with the more general flow statistics.

Signed-off-by: Gaetan Rivet <grive@u256.net>
---
 lib/netdev-offload-provider.h |  3 +++
 lib/netdev-offload.c          | 11 +++++++++++
 lib/netdev-offload.h          |  1 +
 3 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h
index f6e8b009c..fd38cea66 100644
--- a/lib/netdev-offload-provider.h
+++ b/lib/netdev-offload-provider.h
@@ -83,6 +83,9 @@  struct netdev_flow_api {
     int (*flow_del)(struct netdev *, const ovs_u128 *ufid,
                     struct dpif_flow_stats *);
 
+    /* Queries an offload provider hardware statistics. */
+    int (*hw_offload_stats_get)(struct netdev *netdev, uint64_t *counter);
+
     /* 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 f748fcf0d..4a8403ead 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -280,6 +280,17 @@  netdev_flow_del(struct netdev *netdev, const ovs_u128 *ufid,
            : EOPNOTSUPP;
 }
 
+int
+netdev_hw_offload_stats_get(struct netdev *netdev, uint64_t *counter)
+{
+    const struct netdev_flow_api *flow_api =
+        ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api);
+
+    return (flow_api && flow_api->hw_offload_stats_get)
+           ? flow_api->hw_offload_stats_get(netdev, counter)
+           : EOPNOTSUPP;
+}
+
 int
 netdev_init_flow_api(struct netdev *netdev)
 {
diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h
index 49b893190..5ed561d13 100644
--- a/lib/netdev-offload.h
+++ b/lib/netdev-offload.h
@@ -95,6 +95,7 @@  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_hw_offload_stats_get(struct netdev *, uint64_t *counter);
 int netdev_init_flow_api(struct netdev *);
 void netdev_uninit_flow_api(struct netdev *);
 uint32_t netdev_get_block_id(struct netdev *);