net/bnxt: fix flow error on filter creation
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Thu, 9 Jul 2020 09:38:31 +0000 (15:08 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:54 +0000 (06:18 +0200)
If set_em_filter/set_ntuple_filter cmds fails for some reason,
driver is not filling the "rte_flow_error" string buffer.
Same is the case when flow create fails due to an already
existing mark id for the new flow id created.
This leads to a crash in testpmd while trying to print the
error message.

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

index 19bc66a..499dcdf 100644 (file)
@@ -1786,12 +1786,24 @@ bnxt_flow_create(struct rte_eth_dev *dev,
                filter->enables |=
                        HWRM_CFA_EM_FLOW_ALLOC_INPUT_ENABLES_L2_FILTER_ID;
                ret = bnxt_hwrm_set_em_filter(bp, filter->dst_id, filter);
+               if (ret != 0) {
+                       rte_flow_error_set(error, -ret,
+                                          RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+                                          "Failed to create EM filter");
+                       goto free_filter;
+               }
        }
 
        if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER) {
                filter->enables |=
                        HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_L2_FILTER_ID;
                ret = bnxt_hwrm_set_ntuple_filter(bp, filter->dst_id, filter);
+               if (ret != 0) {
+                       rte_flow_error_set(error, -ret,
+                                          RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+                                          "Failed to create ntuple filter");
+                       goto free_filter;
+               }
        }
 
        vnic = find_matching_vnic(bp, filter);
@@ -1817,10 +1829,10 @@ done:
                         */
                        flow_id = filter->flow_id & BNXT_FLOW_ID_MASK;
                        if (bp->mark_table[flow_id].valid) {
-                               PMD_DRV_LOG(ERR,
-                                           "Entry for Mark id 0x%x occupied"
-                                           " flow id 0x%x\n",
-                                           filter->mark, filter->flow_id);
+                               rte_flow_error_set(error, EEXIST,
+                                                  RTE_FLOW_ERROR_TYPE_HANDLE,
+                                                  NULL,
+                                                  "Flow with mark id exists");
                                goto free_filter;
                        }
                        bp->mark_table[flow_id].valid = true;