[ovs-dev] [PATCH 16/25] netdev-offload-dpdk: Refactor disassociate ufid function

Eli Britstein elibr at mellanox.com
Mon Jan 20 15:08:21 UTC 2020


Find the entry of UFID mappings and use it in the disassociate function,
as a pre-step towards more release operations to be done with properties
in the entry.

Signed-off-by: Eli Britstein <elibr at mellanox.com>
Reviewed-by: Roni Bar Yanai <roniba at mellanox.com>
---
 lib/netdev-offload-dpdk.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index c4d77c115..9fd95d775 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -109,22 +109,14 @@ ufid_to_rte_flow_associate(const ovs_u128 *ufid,
 }
 
 static inline void
-ufid_to_rte_flow_disassociate(const ovs_u128 *ufid)
+ufid_to_rte_flow_disassociate(struct ufid_to_rte_flow_data *data)
 {
-    size_t hash = hash_bytes(ufid, sizeof *ufid, 0);
-    struct ufid_to_rte_flow_data *data;
-
-    CMAP_FOR_EACH_WITH_HASH (data, node, hash, &ufid_to_rte_flow) {
-        if (ovs_u128_equals(*ufid, data->ufid)) {
-            cmap_remove(&ufid_to_rte_flow,
-                        CONST_CAST(struct cmap_node *, &data->node), hash);
-            ovsrcu_postpone(free, data);
-            return;
-        }
-    }
+    size_t hash;
 
-    VLOG_WARN("ufid "UUID_FMT" is not associated with an rte flow\n",
-              UUID_ARGS((struct uuid *) ufid));
+    hash = hash_bytes(&data->ufid, sizeof data->ufid, 0);
+    cmap_remove(&ufid_to_rte_flow,
+                CONST_CAST(struct cmap_node *, &data->node), hash);
+    ovsrcu_postpone(free, data);
 }
 
 /* A generic data structure used for mapping data to id and id to data. The
@@ -1647,11 +1639,18 @@ netdev_offload_dpdk_destroy_flow(struct netdev *netdev,
                                  const ovs_u128 *ufid,
                                  struct rte_flow *rte_flow)
 {
+    struct ufid_to_rte_flow_data *data;
     struct rte_flow_error error;
     int ret = netdev_dpdk_rte_flow_destroy(netdev, rte_flow, &error);
 
     if (ret == 0) {
-        ufid_to_rte_flow_disassociate(ufid);
+        data = ufid_to_rte_flow_data_find(ufid);
+        if (!data) {
+            VLOG_WARN("ufid "UUID_FMT" is not associated with an rte flow\n",
+                      UUID_ARGS((struct uuid *) ufid));
+            return -1;
+        }
+        ufid_to_rte_flow_disassociate(data);
         VLOG_DBG("%s: removed rte flow %p associated with ufid " UUID_FMT "\n",
                  netdev_get_name(netdev), rte_flow,
                  UUID_ARGS((struct uuid *)ufid));
-- 
2.14.5



More information about the dev mailing list