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 74C72A051C for ; Tue, 11 Feb 2020 12:27:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 665B22B9C; Tue, 11 Feb 2020 12:27:47 +0100 (CET) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id E7D9E2B9C for ; Tue, 11 Feb 2020 12:27:45 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id p9so3034618wmc.2 for ; Tue, 11 Feb 2020 03:27:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zl2SfH/IBfuj9eZYfwS0143N363lsbOA+D719PPUFVE=; b=S0IQ8WjjBJ4WndIqBY/dc3VHl4xaVNV736NIgkYa15keSm55kzGPNYyStpcloo3plu H+JyIlz436QeaEzONq7Qy+c5LF8W9f2zJhwNshfrY4yQE2+zX57Gkd5aLokM3NmtBbbv tWqPT8gKwPAxq1bVAOrJLilrHkYj3Rskn1gAEb0iAvSMq6RqxHbeHh/ggiUga5aM0ouQ T4FUcn5bdUz1TOZL7FZtvQCDNi3Rl8d3CtEqP5MMoSGA8osNiPXDdj0cetLpuPMJtjCA vDQetamy1MrXE5t5I/g3u1LCFEI15a3yDk3HDDShdz1ngbuwQTrjWbOFd5WRR8I53BLr QwOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zl2SfH/IBfuj9eZYfwS0143N363lsbOA+D719PPUFVE=; b=kUIM9qvnnLLCF91OBkK3P/9N4kc5WxO/gYZazCdzNEfewHWpGOBy6YDwNqmz2KQ2zD FRl3GMD/5NA+vdGJkdNd8jIIlkGugJzYHD0NkY0+bep2jLoU9xVSkqgGZj7W+coo5zX+ WIXQTI/knr8Vy/l2CkLFHaFa0LN3mPIxPjOEdREKr8WhLV4VqX9fljcawbjZFw5QhIIR 8WLNeJYrjwy9u6dUiX9aYfGDAmDvtktjD64ivu9h9Rgdb87Y31oCnPRXw627P+6QDTZi 4oLgbwn9tYSzptRvVtE4YBBKAN2WvNvPOhSStauTdT9Say+QB18spmVTXjjMCVVQfONa Sx+w== X-Gm-Message-State: APjAAAWgzOvunahXwdjylmoY30g4Jhgunn2jMwPKivSPkNiAKa5/PNaL K/vwCHLl5accfDLWEGKba14= X-Google-Smtp-Source: APXvYqzZDoNXQxrZC5UB6bJDuP5/RpvFEWHtXQvDBuZ75CobuFyAk2yv+sloRgC/dEi0tn6p6N7m2w== X-Received: by 2002:a05:600c:2207:: with SMTP id z7mr4937983wml.167.1581420465601; Tue, 11 Feb 2020 03:27:45 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id x21sm3265320wmi.30.2020.02.11.03.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 03:27:45 -0800 (PST) From: luca.boccassi@gmail.com To: Somnath Kotur Cc: Ajit Khaparde , dpdk stable Date: Tue, 11 Feb 2020 11:20:02 +0000 Message-Id: <20200211112216.3929-56-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200211112216.3929-1-luca.boccassi@gmail.com> References: <20200211112216.3929-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: fix reusing L2 filter' has been queued to stable release 19.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/13/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 00a5ed015b201325ba6f124da0052784fe7a0151 Mon Sep 17 00:00:00 2001 From: Somnath Kotur Date: Fri, 20 Dec 2019 18:29:41 -0800 Subject: [PATCH] net/bnxt: fix reusing L2 filter [ upstream commit f0f6b5e6cf94e75cd419bb1bc37463bbc7884110 ] The software L2 filter was being released back to the free pool, though 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. Now that L2 filters can be re-used for an n-tuple filter(s), delete L2 filter as well so the reference count of an L2 filter (if reused) can be decremented appropriately. Fixes: 5c1171c97216 ("net/bnxt: refactor filter/flow") Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_filter.h | 4 ++++ drivers/net/bnxt/bnxt_flow.c | 20 +++++++++----------- drivers/net/bnxt/bnxt_hwrm.c | 20 +++++++++++++++----- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h index 9db3e74877..fc40f112ba 100644 --- a/drivers/net/bnxt/bnxt_filter.h +++ b/drivers/net/bnxt/bnxt_filter.h @@ -77,6 +77,10 @@ struct bnxt_filter_info { uint16_t ip_addr_type; uint16_t ethertype; uint32_t priority; + /* 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 98b1f27bbd..2293de2c37 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -746,10 +746,9 @@ bnxt_find_matching_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf) { 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 @@ bnxt_find_matching_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf) 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 @@ bnxt_create_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf, 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 @@ bnxt_get_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf, 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; } @@ -1429,11 +1432,6 @@ vnic_found: 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); if (act->type != RTE_FLOW_ACTION_TYPE_END) { diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 7628ae9402..3319dee6a1 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; } @@ -2489,8 +2501,7 @@ int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) 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); - else - rc = bnxt_hwrm_clear_l2_filter(bp, filter); + rc = bnxt_hwrm_clear_l2_filter(bp, filter); STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next); bnxt_free_filter(bp, filter); } @@ -2512,8 +2523,7 @@ bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic) 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); - else - rc = bnxt_hwrm_clear_l2_filter(bp, filter); + rc = bnxt_hwrm_clear_l2_filter(bp, filter); STAILQ_REMOVE(&vnic->flow_list, flow, rte_flow, next); rte_free(flow); -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-11 11:17:41.011259089 +0000 +++ 0056-net-bnxt-fix-reusing-L2-filter.patch 2020-02-11 11:17:38.432001945 +0000 @@ -1,8 +1,10 @@ -From f0f6b5e6cf94e75cd419bb1bc37463bbc7884110 Mon Sep 17 00:00:00 2001 +From 00a5ed015b201325ba6f124da0052784fe7a0151 Mon Sep 17 00:00:00 2001 From: Somnath Kotur Date: Fri, 20 Dec 2019 18:29:41 -0800 Subject: [PATCH] net/bnxt: fix reusing L2 filter +[ upstream commit f0f6b5e6cf94e75cd419bb1bc37463bbc7884110 ] + The software L2 filter was being released back to the free pool, though it was created in HW and the filter corresponding to an actual 'flow' would have reference to the HW L2 filter. @@ -17,7 +19,6 @@ can be decremented appropriately. Fixes: 5c1171c97216 ("net/bnxt: refactor filter/flow") -Cc: stable@dpdk.org Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde @@ -43,7 +44,7 @@ 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 855994a6b0..2bd492ea33 100644 +index 98b1f27bbd..2293de2c37 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -746,10 +746,9 @@ bnxt_find_matching_l2_filter(struct bnxt *bp, struct bnxt_filter_info *nf) @@ -107,7 +108,7 @@ act = bnxt_flow_non_void_action(++act); if (act->type != RTE_FLOW_ACTION_TYPE_END) { diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c -index bee4c154fd..8178213e5a 100644 +index 7628ae9402..3319dee6a1 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, @@ -148,7 +149,7 @@ return 0; } -@@ -2483,8 +2495,7 @@ int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) +@@ -2489,8 +2501,7 @@ int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) 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); @@ -158,7 +159,7 @@ STAILQ_REMOVE(&vnic->filter, filter, bnxt_filter_info, next); bnxt_free_filter(bp, filter); } -@@ -2506,8 +2517,7 @@ bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic) +@@ -2512,8 +2523,7 @@ bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic) 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);