diff mbox series

[ovs-dev,v4,4/9] netdev-offload: Introduce sFlow attributes query by group ID API

Message ID 20200924102415.23528-5-cmi@nvidia.com
State Changes Requested
Headers show
Series Add offload support for sFlow | expand

Commit Message

Chris Mi Sept. 24, 2020, 10:24 a.m. UTC
OVS maintains a group ID to sFlow attribute mapping when offloading
sFlow action to TC. Introduce sFlow attributes query by group ID API.

Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Eli Britstein <elibr@nvidia.com>
---
 lib/netdev-offload-provider.h |  5 +++++
 lib/netdev-offload.c          | 11 +++++++++++
 lib/netdev-offload.h          |  1 +
 3 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h
index 0bed7bf61..8edffcbbd 100644
--- a/lib/netdev-offload-provider.h
+++ b/lib/netdev-offload-provider.h
@@ -86,6 +86,11 @@  struct netdev_flow_api {
     /* Initializies the netdev flow api.
      * Return 0 if successful, otherwise returns a positive errno value. */
     int (*init_flow_api)(struct netdev *);
+
+    /* Query sFlow attribute by group ID.
+     *
+     * On success returns a const pointer, on failure returns NULL */
+    const struct dpif_sflow_attr *(*sflow_attr_get)(uint32_t gid);
 };
 
 int netdev_register_flow_api_provider(const struct netdev_flow_api *);
diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c
index 2da3bc701..084ce25a9 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -666,3 +666,14 @@  netdev_set_flow_api_enabled(const struct smap *ovs_other_config)
         }
     }
 }
+
+const struct dpif_sflow_attr *
+netdev_sflow_attr_get(struct netdev *netdev, uint32_t gid)
+{
+    const struct netdev_flow_api *flow_api =
+        ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api);
+
+    return (flow_api && flow_api->sflow_attr_get)
+           ? flow_api->sflow_attr_get(gid)
+           : NULL;
+}
diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h
index 4c0ed2ae8..9f167e1a5 100644
--- a/lib/netdev-offload.h
+++ b/lib/netdev-offload.h
@@ -124,6 +124,7 @@  int netdev_ports_flow_get(const char *dpif_type, struct match *match,
                           struct dpif_flow_stats *stats,
                           struct dpif_flow_attrs *attrs,
                           struct ofpbuf *buf);
+const struct dpif_sflow_attr *netdev_sflow_attr_get(struct netdev *, uint32_t);
 
 #ifdef  __cplusplus
 }