[ovs-dev] [PATCH 06/62] netdev-offload: Add vport offload flow api

Tao YunXiang taoyunxiang at cmss.chinamobile.com
Mon Dec 28 09:24:24 UTC 2020


From: Liuchang <liuchang at cmss.chinamobile.com>

Code Source From: Self Code
Description:

    'linux_tc' flow API suitable only for tunneling vports with backing
linux interfaces. DPDK flow API is not suitable for such ports.

With this change we could drop vport restriction from dpif-netdev.

This is a prerequisite for enabling vport offloading in DPDK.

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/dpif-netdev.c         | 3 +--
 lib/netdev-offload-dpdk.c | 8 ++++++++
 lib/netdev-offload-tc.c   | 8 ++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 12ee8bd..492b2c1 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2441,8 +2441,7 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload)
     info.dpif_class = dpif_class;
 
     port = netdev_ports_get(in_port, dpif_type_str);
-    if (!port || netdev_vport_is_vport_class(port->netdev_class)) {
-        netdev_close(port);
+    if (!port) {
         goto err_free;
     }
     /* Taking a global 'port_mutex' to fulfill thread safety restrictions for
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index d7184c0..5ce25e3 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -24,6 +24,7 @@
 #include "dpif-netdev.h"
 #include "netdev-offload-provider.h"
 #include "netdev-provider.h"
+#include "netdev-vport.h"
 #include "openvswitch/match.h"
 #include "openvswitch/vlog.h"
 #include "packets.h"
@@ -1374,6 +1375,13 @@ netdev_offload_dpdk_flow_del(struct netdev *netdev, const ovs_u128 *ufid,
 static int
 netdev_offload_dpdk_init_flow_api(struct netdev *netdev)
 {
+    if (netdev_vport_is_vport_class(netdev->netdev_class)
+        && !strcmp(netdev_get_dpif_type(netdev), "system")) {
+        VLOG_DBG("%s: vport belongs to the system datapath. Skipping.",
+                 netdev_get_name(netdev));
+        return EOPNOTSUPP;
+    }
+
     return netdev_dpdk_flow_api_supported(netdev) ? 0 : EOPNOTSUPP;
 }
 
diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c
index 51f5fd5..6c76f69 100644
--- a/lib/netdev-offload-tc.c
+++ b/lib/netdev-offload-tc.c
@@ -31,6 +31,7 @@
 #include "netdev-linux.h"
 #include "netdev-offload-provider.h"
 #include "netdev-provider.h"
+#include "netdev-vport.h"
 #include "netlink.h"
 #include "netlink-socket.h"
 #include "odp-netlink.h"
@@ -1912,6 +1913,13 @@ netdev_tc_init_flow_api(struct netdev *netdev)
     int ifindex;
     int error;
 
+    if (netdev_vport_is_vport_class(netdev->netdev_class)
+        && strcmp(netdev_get_dpif_type(netdev), "system")) {
+        VLOG_DBG("%s: vport doesn't belong to the system datapath. Skipping.",
+                 netdev_get_name(netdev));
+        return EOPNOTSUPP;
+    }
+
     ifindex = netdev_get_ifindex(netdev);
     if (ifindex < 0) {
         VLOG_INFO("init: failed to get ifindex for %s: %s",
-- 
1.8.3.1





More information about the dev mailing list