net/bnxt: fix freeing filters on flow creation failure
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Thu, 9 Jul 2020 09:38:32 +0000 (15:08 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:54 +0000 (06:18 +0200)
This patch does following things:
1. Added a wrapper function bnxt_clear_one_vnic_filter()
   for destroying the filters in hw. This will avoid duplicate
   code in many places.
2. When flow create fails due to an already existing mark id
   for the new flow id created, fixed to destroy the hw
   filter created.
3. Re-arranged code to move a log and list update to right place.

Fixes: 9db66782bd06 ("net/bnxt: fix supporting zero mark ID with RSS action")
Fixes: 5ef3b79fdfe6 ("net/bnxt: support flow filter ops")
Cc: stable@dpdk.org
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_flow.c
drivers/net/bnxt/bnxt_hwrm.c
drivers/net/bnxt/bnxt_hwrm.h

index 499dcdf..320b53d 100644 (file)
@@ -1816,9 +1816,6 @@ done:
                        goto free_flow;
                }
 
-               STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
-               PMD_DRV_LOG(DEBUG, "Successfully created flow.\n");
-               STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
                if (filter->valid_flags & BNXT_FLOW_MARK_FLAG) {
                        PMD_DRV_LOG(DEBUG,
                                    "Mark action: mark id 0x%x, flow id 0x%x\n",
@@ -1833,15 +1830,21 @@ done:
                                                   RTE_FLOW_ERROR_TYPE_HANDLE,
                                                   NULL,
                                                   "Flow with mark id exists");
+                               bnxt_clear_one_vnic_filter(bp, filter);
                                goto free_filter;
                        }
                        bp->mark_table[flow_id].valid = true;
                        bp->mark_table[flow_id].mark_id = filter->mark;
                }
+
+               STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
+               STAILQ_INSERT_TAIL(&vnic->flow_list, flow, next);
+
                if (BNXT_FLOW_XSTATS_EN(bp))
                        bp->flow_stat->flow_count++;
                bnxt_release_flow_lock(bp);
                bnxt_setup_flow_counter(bp);
+               PMD_DRV_LOG(DEBUG, "Successfully created flow.\n");
                return flow;
        }
 
@@ -1940,11 +1943,7 @@ _bnxt_flow_destroy(struct bnxt *bp,
                filter->flow_id = 0;
        }
 
-       if (filter->filter_type == HWRM_CFA_EM_FILTER)
-               ret = bnxt_hwrm_clear_em_filter(bp, filter);
-       if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
-               ret = bnxt_hwrm_clear_ntuple_filter(bp, filter);
-       ret = bnxt_hwrm_clear_l2_filter(bp, filter);
+       ret = bnxt_clear_one_vnic_filter(bp, filter);
 
 done:
        if (!ret) {
index f9c7461..7ea13a8 100644 (file)
@@ -2613,6 +2613,25 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
        return 0;
 }
 
+int
+bnxt_clear_one_vnic_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
+{
+       int rc = 0;
+
+       if (filter->filter_type == HWRM_CFA_EM_FILTER) {
+               rc = bnxt_hwrm_clear_em_filter(bp, filter);
+               if (rc)
+                       return rc;
+       } else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
+               rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
+               if (rc)
+                       return rc;
+       }
+
+       rc = bnxt_hwrm_clear_l2_filter(bp, filter);
+       return rc;
+}
+
 static int
 bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
@@ -2620,11 +2639,7 @@ bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic)
        int rc = 0;
 
        STAILQ_FOREACH(filter, &vnic->filter, next) {
-               if (filter->filter_type == HWRM_CFA_EM_FILTER)
-                       rc = bnxt_hwrm_clear_em_filter(bp, filter);
-               else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
-                       rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
-               rc = bnxt_hwrm_clear_l2_filter(bp, filter);
+               rc = bnxt_clear_one_vnic_filter(bp, filter);
                STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next);
                bnxt_free_filter(bp, filter);
        }
@@ -2642,11 +2657,7 @@ bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic)
                flow = STAILQ_FIRST(&vnic->flow_list);
                filter = flow->filter;
                PMD_DRV_LOG(DEBUG, "filter type %d\n", filter->filter_type);
-               if (filter->filter_type == HWRM_CFA_EM_FILTER)
-                       rc = bnxt_hwrm_clear_em_filter(bp, filter);
-               else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
-                       rc = bnxt_hwrm_clear_ntuple_filter(bp, filter);
-               rc = bnxt_hwrm_clear_l2_filter(bp, filter);
+               rc = bnxt_clear_one_vnic_filter(bp, filter);
 
                STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next);
                rte_free(flow);
index 1704edd..01201a7 100644 (file)
@@ -276,4 +276,6 @@ int bnxt_hwrm_get_dflt_vnic_svif(struct bnxt *bp, uint16_t fid,
 int bnxt_hwrm_parent_pf_qcfg(struct bnxt *bp);
 int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp);
 int bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num);
+int bnxt_clear_one_vnic_filter(struct bnxt *bp,
+                              struct bnxt_filter_info *filter);
 #endif