diff mbox series

[ovs-dev,30/62] dpif-netdev: free mark value if the offloaded fail flow deleted

Message ID 20201228092520.11807-31-taoyunxiang@cmss.chinamobile.com
State Not Applicable
Headers show
Series DPDK Offload API to test | expand

Commit Message

Tao YunXiang Dec. 28, 2020, 9:24 a.m. UTC
From: Rongyin <rongyin@cmss.chinamobile.com>

Code Source From: Self Code

Description:

     free mark value if the offloaded fail flow deleted

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/dpif-netdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index db28b88..73367ab 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2444,6 +2444,13 @@  dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload)
         if (megaflow_to_offload_st_find(&flow->ufid) == true) {
             return -1;
         }
+        /* There are two possibilities when runs here:
+         * 1. This flow is new, has never been offloaded before
+         * 2. This flow has been offload before and succeed
+         *    means hw flow is ageout,ovs should offload it again
+         * So for 1. we should alloc new mark value from pool
+         *    for 2. we should assert flow->mark == mark
+         */
         if (mark != INVALID_FLOW_MARK) {
             VLOG_DBG("Flow has already been offloaded with mark %u\n", mark);
             if (flow->mark != INVALID_FLOW_MARK) {
@@ -2611,11 +2618,21 @@  dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread *pmd,
     struct cmap_node *node = CONST_CAST(struct cmap_node *, &flow->node);
     struct dpcls *cls;
     odp_port_t in_port = flow->flow.in_port.odp_port;
+    uint32_t mark ;
 
     cls = dp_netdev_pmd_lookup_dpcls(pmd, in_port);
     ovs_assert(cls != NULL);
     dpcls_remove(cls, &flow->cr);
     cmap_remove(&pmd->flow_table, node, dp_netdev_flow_hash(&flow->ufid));
+    /* There is one condition that offloaded failed flows should also
+     * free mark value
+     */
+    if (megaflow_to_offload_st_find(&flow->ufid) == true ){
+        mark = megaflow_to_mark_find(&flow->ufid);
+        if (mark != INVALID_FLOW_MARK) {
+            flow_mark_free(mark);
+        }
+    }
     if (flow->mark != INVALID_FLOW_MARK) {
         queue_netdev_flow_del(pmd, flow);
     }