[ovs-dev] [PATCH 1/4] netdev-offload-dpdk: Refactor get_vport_netdev()

Nir Anteby nanteby at nvidia.com
Tue Sep 14 08:05:10 UTC 2021


Refactor the function as a pre-step towards supporting more tunnel
types.

Signed-off-by: Nir Anteby <nanteby at nvidia.com>
---
 lib/netdev-offload-dpdk.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index b87a50b..c831471 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -2085,17 +2085,18 @@ struct get_vport_netdev_aux {
     struct rte_flow_tunnel *tunnel;
     odp_port_t *odp_port;
     struct netdev *vport;
+    const char *type;
 };
 
 static bool
-get_vxlan_netdev_cb(struct netdev *netdev,
+get_vport_netdev_cb(struct netdev *netdev,
                     odp_port_t odp_port,
                     void *aux_)
 {
     const struct netdev_tunnel_config *tnl_cfg;
     struct get_vport_netdev_aux *aux = aux_;
 
-    if (strcmp(netdev_get_type(netdev), "vxlan")) {
+    if (!aux->type || strcmp(netdev_get_type(netdev), aux->type)) {
         return false;
     }
 
@@ -2117,7 +2118,7 @@ get_vxlan_netdev_cb(struct netdev *netdev,
 }
 
 static struct netdev *
-get_vxlan_netdev(const char *dpif_type,
+get_vport_netdev(const char *dpif_type,
                  struct rte_flow_tunnel *tunnel,
                  odp_port_t *odp_port)
 {
@@ -2125,22 +2126,15 @@ get_vxlan_netdev(const char *dpif_type,
         .tunnel = tunnel,
         .odp_port = odp_port,
         .vport = NULL,
+        .type = NULL,
     };
 
-    netdev_ports_traverse(dpif_type, get_vxlan_netdev_cb, &aux);
-    return aux.vport;
-}
-
-static struct netdev *
-get_vport_netdev(const char *dpif_type,
-                 struct rte_flow_tunnel *tunnel,
-                 odp_port_t *odp_port)
-{
     if (tunnel->type == RTE_FLOW_ITEM_TYPE_VXLAN) {
-        return get_vxlan_netdev(dpif_type, tunnel, odp_port);
+        aux.type = "vxlan";
     }
+    netdev_ports_traverse(dpif_type, get_vport_netdev_cb, &aux);
 
-    OVS_NOT_REACHED();
+    return aux.vport;
 }
 
 static int
-- 
1.8.3.1



More information about the dev mailing list