[ovs-dev] [PATCH v12 05/11] netdev-offload: Introduce register sFlow upcall callback API
Chris Mi
cmi at nvidia.com
Wed Jan 27 06:23:38 UTC 2021
Introduce register sFlow upcall callback API as a pre-step towards
saving the upcall callback.
Signed-off-by: Chris Mi <cmi at nvidia.com>
Reviewed-by: Eli Britstein <elibr at nvidia.com>
---
lib/dpif-netlink.h | 4 ++++
lib/netdev-offload-provider.h | 3 +++
lib/netdev-offload.c | 12 ++++++++++++
lib/netdev-offload.h | 3 +++
4 files changed, 22 insertions(+)
diff --git a/lib/dpif-netlink.h b/lib/dpif-netlink.h
index 24294bc42..318a4c71f 100644
--- a/lib/dpif-netlink.h
+++ b/lib/dpif-netlink.h
@@ -21,6 +21,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "dpif.h"
#include "flow.h"
struct ofpbuf;
@@ -60,4 +61,7 @@ bool dpif_netlink_is_internal_device(const char *name);
enum ovs_vport_type netdev_to_ovs_vport_type(const char *type);
+typedef int dpif_netlink_sflow_upcall_callback(struct dpif_upcall_sflow
+ *dupcall);
+
#endif /* dpif-netlink.h */
diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h
index cf859d1b4..feeb3b458 100644
--- a/lib/netdev-offload-provider.h
+++ b/lib/netdev-offload-provider.h
@@ -87,6 +87,9 @@ struct netdev_flow_api {
* Return 0 if successful, otherwise returns a positive errno value. */
int (*flow_get_n_flows)(struct netdev *, uint64_t *n_flows);
+ /* Registers an upcall callback to process sFlow packet */
+ void (*register_nl_sflow_upcall_cb)(dpif_netlink_sflow_upcall_callback *);
+
/* 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 6237667c3..99b2704f6 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -693,3 +693,15 @@ netdev_set_flow_api_enabled(const struct smap *ovs_other_config)
}
}
}
+
+void
+netdev_regsiter_nl_sflow_upcall_cb(struct netdev *netdev,
+ dpif_netlink_sflow_upcall_callback *cb)
+{
+ const struct netdev_flow_api *flow_api =
+ ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api);
+
+ if (flow_api && flow_api->register_nl_sflow_upcall_cb) {
+ flow_api->register_nl_sflow_upcall_cb(cb);
+ }
+}
diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h
index 18b48790f..5ad5463ff 100644
--- a/lib/netdev-offload.h
+++ b/lib/netdev-offload.h
@@ -22,6 +22,7 @@
#include "openvswitch/types.h"
#include "packets.h"
#include "flow.h"
+#include "dpif-netlink.h"
#ifdef __cplusplus
extern "C" {
@@ -127,6 +128,8 @@ int netdev_ports_flow_get(const char *dpif_type, struct match *match,
struct ofpbuf *buf);
int netdev_ports_get_n_flows(const char *dpif_type,
odp_port_t port_no, uint64_t *n_flows);
+void netdev_regsiter_nl_sflow_upcall_cb(struct netdev *netdev,
+ dpif_netlink_sflow_upcall_callback *cb);
#ifdef __cplusplus
}
--
2.26.2
More information about the dev
mailing list