From 87520e59fb84c3ba5dbeee10d57a534fa3a70ad2 Mon Sep 17 00:00:00 2001 From: Kalesh AP Date: Thu, 9 Jul 2020 15:08:32 +0530 Subject: [PATCH] net/bnxt: fix freeing filters on flow creation failure 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 Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_flow.c | 15 +++++++-------- drivers/net/bnxt/bnxt_hwrm.c | 31 +++++++++++++++++++++---------- drivers/net/bnxt/bnxt_hwrm.h | 2 ++ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c index 499dcdf6b8..320b53d944 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -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) { diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index f9c7461097..7ea13a8b29 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -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); diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 1704eddba8..01201a7a47 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -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 -- 2.20.1