diff mbox series

[ovs-dev,v5,05/12] netdev-offload: Introduce register sFlow upcall callback API

Message ID 20201029112340.14167-6-cmi@nvidia.com
State New
Headers show
Series Add offload support for sFlow | expand

Commit Message

Chris Mi Oct. 29, 2020, 11:23 a.m. UTC
Introduce register sFlow upcall callback API as a pre-step towards
saving the upcall callback.

Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Eli Britstein <elibr@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(+)

Comments

0-day Robot Oct. 29, 2020, 12:10 p.m. UTC | #1
Bleep bloop.  Greetings Chris Mi, 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: Line is 80 characters long (recommended limit is 79)
#89 FILE: lib/netdev-offload.h:129:
                                        dpif_netlink_sflow_upcall_callback *cb);

Lines checked: 95, 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
diff mbox series

Patch

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 0bed7bf61..a199c9de1 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 *);
 
+    /* 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 2da3bc701..f8d397d08 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -666,3 +666,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 4c0ed2ae8..f74419dee 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" {
@@ -124,6 +125,8 @@  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);
+void netdev_regsiter_nl_sflow_upcall_cb(struct netdev *netdev,
+                                        dpif_netlink_sflow_upcall_callback *cb);
 
 #ifdef  __cplusplus
 }