net/mlx5: workaround drop action with old kernel
[dpdk.git] / drivers / net / bnxt / bnxt_flow.c
index d23f8cf..59489b5 100644 (file)
@@ -919,6 +919,19 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf,
        return l2_filter;
 }
 
+static void bnxt_vnic_cleanup(struct bnxt *bp, struct bnxt_vnic_info *vnic)
+{
+       if (vnic->rx_queue_cnt > 1)
+               bnxt_hwrm_vnic_ctx_free(bp, vnic);
+
+       bnxt_hwrm_vnic_free(bp, vnic);
+
+       rte_free(vnic->fw_grp_ids);
+       vnic->fw_grp_ids = NULL;
+
+       vnic->rx_queue_cnt = 0;
+}
+
 static int bnxt_vnic_prep(struct bnxt *bp, struct bnxt_vnic_info *vnic,
                          const struct rte_flow_action *act,
                          struct rte_flow_error *error)
@@ -949,8 +962,6 @@ static int bnxt_vnic_prep(struct bnxt *bp, struct bnxt_vnic_info *vnic,
                goto ret;
        }
 
-       bp->nr_vnics++;
-
        /* RSS context is required only when there is more than one RSS ring */
        if (vnic->rx_queue_cnt > 1) {
                rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic, 0);
@@ -986,9 +997,12 @@ static int bnxt_vnic_prep(struct bnxt *bp, struct bnxt_vnic_info *vnic,
                goto ret;
        }
 
+       bp->nr_vnics++;
+
        return 0;
 
 ret:
+       bnxt_vnic_cleanup(bp, vnic);
        return rc;
 }
 
@@ -1563,10 +1577,7 @@ bnxt_flow_validate(struct rte_eth_dev *dev,
        vnic = find_matching_vnic(bp, filter);
        if (vnic) {
                if (STAILQ_EMPTY(&vnic->filter)) {
-                       rte_free(vnic->fw_grp_ids);
-                       bnxt_hwrm_vnic_ctx_free(bp, vnic);
-                       bnxt_hwrm_vnic_free(bp, vnic);
-                       vnic->rx_queue_cnt = 0;
+                       bnxt_vnic_cleanup(bp, vnic);
                        bp->nr_vnics--;
                        PMD_DRV_LOG(DEBUG, "Free VNIC\n");
                }
@@ -1955,12 +1966,20 @@ static int bnxt_handle_tunnel_redirect_destroy(struct bnxt *bp,
                /* Tunnel doesn't belong to this VF, so don't send HWRM
                 * cmd, just delete the flow from driver
                 */
-               if (bp->fw_fid != (tun_dst_fid + bp->first_vf_id))
+               if (bp->fw_fid != (tun_dst_fid + bp->first_vf_id)) {
                        PMD_DRV_LOG(ERR,
                                    "Tunnel does not belong to this VF, skip hwrm_tunnel_redirect_free\n");
-               else
+               } else {
                        ret = bnxt_hwrm_tunnel_redirect_free(bp,
                                                        filter->tunnel_type);
+                       if (ret) {
+                               rte_flow_error_set(error, -ret,
+                                                  RTE_FLOW_ERROR_TYPE_HANDLE,
+                                                  NULL,
+                                                  "Unable to free tunnel redirection");
+                               return ret;
+                       }
+               }
        }
        return ret;
 }
@@ -2023,12 +2042,7 @@ done:
                 */
                if (vnic && !vnic->func_default &&
                    STAILQ_EMPTY(&vnic->flow_list)) {
-                       rte_free(vnic->fw_grp_ids);
-                       if (vnic->rx_queue_cnt > 1)
-                               bnxt_hwrm_vnic_ctx_free(bp, vnic);
-
-                       bnxt_hwrm_vnic_free(bp, vnic);
-                       vnic->rx_queue_cnt = 0;
+                       bnxt_vnic_cleanup(bp, vnic);
                        bp->nr_vnics--;
                }
        } else {