diff mbox series

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

Message ID 1634807897-98819-2-git-send-email-nanteby@nvidia.com
State Accepted
Commit 8279041460c6ec47ecc39a136b2fed327e9e3456
Headers show
Series netdev datapath hardware offload support for GRE flows | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Nir Anteby Oct. 21, 2021, 9:18 a.m. UTC
Refactor the function as a pre-step towards supporting more tunnel
types.

Signed-off-by: Nir Anteby <nanteby@nvidia.com>
---
 lib/netdev-offload-dpdk.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

Comments

Maxime Coquelin Oct. 21, 2021, 2:13 p.m. UTC | #1
On 10/21/21 11:18, Nir Anteby via dev wrote:
> Refactor the function as a pre-step towards supporting more tunnel
> types.
> 
> Signed-off-by: Nir Anteby <nanteby@nvidia.com>
> ---
>   lib/netdev-offload-dpdk.c | 35 +++++++++++++++--------------------
>   1 file changed, 15 insertions(+), 20 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
diff mbox series

Patch

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 9fee757..af56491 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -2222,17 +2222,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;
     }
 
@@ -2243,18 +2244,19 @@  get_vxlan_netdev_cb(struct netdev *netdev,
         return false;
     }
 
-    if (tnl_cfg->dst_port == aux->tunnel->tp_dst) {
-        /* Found the netdev. Store the results and stop the traversing. */
-        aux->vport = netdev_ref(netdev);
-        *aux->odp_port = odp_port;
-        return true;
+    if (tnl_cfg->dst_port != aux->tunnel->tp_dst) {
+        return false;
     }
 
-    return false;
+    /* Found the netdev. Store the results and stop the traversing. */
+    aux->vport = netdev_ref(netdev);
+    *aux->odp_port = odp_port;
+
+    return true;
 }
 
 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)
 {
@@ -2262,22 +2264,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