From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 16E6CA04F0; Tue, 17 Dec 2019 05:19:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 453151BF75; Tue, 17 Dec 2019 05:18:41 +0100 (CET) Received: from relay.smtp.broadcom.com (unknown [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id 167522C52 for ; Tue, 17 Dec 2019 05:18:34 +0100 (CET) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (bgccx-dev-host-lnx35.bec.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id C5DA11BE6CA; Mon, 16 Dec 2019 20:18:32 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com C5DA11BE6CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1576556313; bh=922oDffj0VTmsD5bbKBG3BpkbvTOsTvKTlJ5iHz0g9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uokjdvBnvhh+LW4arRSdD5CjccSM1qvj2Sc2ft5fm1C7ZSO1XvnOiEcbKs+EDivrc 4Oh3NfzRjcB4FWMO4p2Hffr9Iv6u/KCVS09152fcKdwLuhZaoHc1LT0/GdVAA+Gpst jOsC3be7Cc7nlNVZ7+/Vwpx2/idxhFhYu7VyltRY= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 17 Dec 2019 09:47:54 +0530 Message-Id: <20191217041755.29232-6-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20191217041755.29232-1-somnath.kotur@broadcom.com> References: <20191217041755.29232-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 5/6] net/bnxt: fix to keep the L2 filter intact so it can be reused X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The software L2 filter was being released back to the free pool, after it was created in HW and the filter corresponding to an actual 'flow' would have reference to the HW L2 filter. But if this 'flow were to be deleted, then this HW L2 filter also would be gone. Fix this by storing the L2 filter created originally either for an n-tuple flow or otherwise as part of the vnic's filter list. This would require the filter_info struct to have a backptr to the vnic which it came from. Fixes: 0ba82dee ("net/bnxt: fix to check for L2 filters that doesn't have any references") Signed-off-by: Somnath Kotur Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/bnxt_filter.h | 4 ++++ drivers/net/bnxt/bnxt_flow.c | 20 +++++++++----------- drivers/net/bnxt/bnxt_hwrm.c | 14 +++++++++++++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h index 8cafa8f..5c96b34 100644 --- a/drivers/net/bnxt/bnxt_filter.h +++ b/drivers/net/bnxt/bnxt_filter.h @@ -80,6 +80,10 @@ struct bnxt_filter_info { uint16_t ethertype; uint32_t priority; uint32_t mark; + /* Backptr to vnic. As of now, used only by an L2 filter + * to remember which vnic it was created on + */ + struct bnxt_vnic_info *vnic; }; struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp); diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c index f926f9b..660760c 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -746,10 +746,9 @@ { struct bnxt_filter_info *mf, *f0; struct bnxt_vnic_info *vnic0; - struct rte_flow *flow; int i; - vnic0 = &bp->vnic_info[0]; + vnic0 = BNXT_GET_DEFAULT_VNIC(bp); f0 = STAILQ_FIRST(&vnic0->filter); /* This flow has same DST MAC as the port/l2 filter. */ @@ -762,8 +761,7 @@ if (vnic->fw_vnic_id == INVALID_VNIC_ID) continue; - STAILQ_FOREACH(flow, &vnic->flow_list, next) { - mf = flow->filter; + STAILQ_FOREACH(mf, &vnic->filter, next) { if (mf->matching_l2_fltr_ptr) continue; @@ -798,6 +796,8 @@ if (filter1 == NULL) return NULL; + memcpy(filter1, nf, sizeof(*filter1)); + filter1->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_XDP_DISABLE; filter1->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX; if (nf->valid_flags & BNXT_FLOW_L2_SRC_VALID_FLAG || @@ -880,11 +880,14 @@ struct bnxt_filter_info * l2_filter = bnxt_find_matching_l2_filter(bp, nf); if (l2_filter) { l2_filter->l2_ref_cnt++; - nf->matching_l2_fltr_ptr = l2_filter; } else { l2_filter = bnxt_create_l2_filter(bp, nf, vnic); - nf->matching_l2_fltr_ptr = NULL; + if (l2_filter) { + STAILQ_INSERT_TAIL(&vnic->filter, l2_filter, next); + l2_filter->vnic = vnic; + } } + nf->matching_l2_fltr_ptr = l2_filter; return l2_filter; } @@ -1437,11 +1440,6 @@ static int match_vnic_rss_cfg(struct bnxt *bp, goto ret; } - if (filter1 && !filter->matching_l2_fltr_ptr) { - bnxt_free_filter(bp, filter1); - filter1->fw_l2_filter_id = -1; - } - done: act = bnxt_flow_non_void_action(++act); while (act->type != RTE_FLOW_ACTION_TYPE_END) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 694d2d0..1b19fba 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -363,10 +363,11 @@ int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid, } int bnxt_hwrm_clear_l2_filter(struct bnxt *bp, - struct bnxt_filter_info *filter) + struct bnxt_filter_info *filter) { int rc = 0; struct bnxt_filter_info *l2_filter = filter; + struct bnxt_vnic_info *vnic = NULL; struct hwrm_cfa_l2_filter_free_input req = {.req_type = 0 }; struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr; @@ -379,6 +380,9 @@ int bnxt_hwrm_clear_l2_filter(struct bnxt *bp, PMD_DRV_LOG(DEBUG, "filter: %p l2_filter: %p ref_cnt: %d\n", filter, l2_filter, l2_filter->l2_ref_cnt); + if (l2_filter->l2_ref_cnt == 0) + return 0; + if (l2_filter->l2_ref_cnt > 0) l2_filter->l2_ref_cnt--; @@ -395,6 +399,14 @@ int bnxt_hwrm_clear_l2_filter(struct bnxt *bp, HWRM_UNLOCK(); filter->fw_l2_filter_id = UINT64_MAX; + if (l2_filter->l2_ref_cnt == 0) { + vnic = l2_filter->vnic; + if (vnic) { + STAILQ_REMOVE(&vnic->filter, l2_filter, + bnxt_filter_info, next); + bnxt_free_filter(bp, l2_filter); + } + } return 0; } -- 1.8.3.1