From: Paul Blakey <pa...@mellanox.com>

netdev vports are backed by actualy netdev at the kernel
level, so they can use the common netdev-tc offloads interface
for flow offloading (if enabled).

Signed-off-by: Paul Blakey <pa...@mellanox.com>
Reviewed-by: Roi Dayan <r...@mellanox.com>
---
 lib/netdev-vport.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index befa4e4..4cc086e 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -45,6 +45,7 @@
 #include "unaligned.h"
 #include "unixctl.h"
 #include "openvswitch/vlog.h"
+#include "netdev-tc-offloads.h"
 #include "netdev-linux.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_vport);
@@ -780,7 +781,23 @@ get_stats(const struct netdev *netdev, struct netdev_stats 
*stats)
     return 0;
 }
 
-
+#ifdef __linux__
+static int
+netdev_vport_get_ifindex(const struct netdev *netdev_)
+{
+    char buf[NETDEV_VPORT_NAME_BUFSIZE];
+    const char *name = netdev_vport_get_dpif_port(netdev_, buf, sizeof(buf));
+
+    return linux_get_ifindex(name);
+}
+
+#define NETDEV_VPORT_GET_IFINDEX netdev_vport_get_ifindex
+#define NETDEV_FLOW_OFFLOAD_API LINUX_FLOW_OFFLOAD_API
+#else /* !__linux__ */
+#define NETDEV_VPORT_GET_IFINDEX NULL
+#define NETDEV_FLOW_OFFLOAD_API NO_OFFLOAD_API
+#endif /* __linux__ */
+
 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG,             \
                         GET_TUNNEL_CONFIG, GET_STATUS,      \
                         BUILD_HEADER,                       \
@@ -851,14 +868,7 @@ get_stats(const struct netdev *netdev, struct netdev_stats 
*stats)
     NULL,                   /* rx_wait */                   \
     NULL,                   /* rx_drain */                  \
                                                             \
-    NULL,                   /* flow_flush */                \
-    NULL,                   /* flow_dump_create */          \
-    NULL,                   /* flow_dump_destroy */         \
-    NULL,                   /* flow_dump_next */            \
-    NULL,                   /* flow_put */                  \
-    NULL,                   /* flow_get */                  \
-    NULL,                   /* flow_del */                  \
-    NULL,                   /* init_flow_api */
+    NETDEV_FLOW_OFFLOAD_API
 
 
 #define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER,   
\
-- 
2.7.4

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to