From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com,
Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
stable@dpdk.org, Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [dpdk-dev] [PATCH v3 04/10] net/bnxt: fix enable/disable VLAN filtering
Date: Mon, 13 Jan 2020 21:14:29 -0800 [thread overview]
Message-ID: <20200114051435.46093-5-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200114051435.46093-1-ajit.khaparde@broadcom.com>
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
There is no condition check for the user requested operation
for VLAN filtering. As a result, VLAN filtering is getting disabled
when the user enables/disables VLAN stripping on same port.
The function bnxt_hwrm_clear_l2_filter() didn't actually free
L2 filter in HW if the reference count of filter is zero.
Fixed it by incrementing the reference count of filter in
bnxt_alloc_filter() routine.
Because of the recent changes in bnxt_hwrm_clear_l2_filter(),
change was needed in the routine bnxt_set_default_mac_addr_op()
to destroy and re-create the default filter when the user
changes the default MAC of the port.
Fixes: 5c1171c97216 ("net/bnxt: refactor filter/flow")
Fixes: 6118503d8071 ("net/bnxt: fix VLAN filtering")
Cc: stable@dpdk.org
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_ethdev.c | 66 ++++++++++++++++++----------------
drivers/net/bnxt/bnxt_filter.c | 5 +--
2 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a948c78cb..83f475d49 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1860,18 +1860,12 @@ static int bnxt_del_dflt_mac_filter(struct bnxt *bp,
}
static int
-bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask)
+bnxt_config_vlan_hw_filter(struct bnxt *bp, uint64_t rx_offloads)
{
- struct bnxt *bp = dev->data->dev_private;
- uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
struct bnxt_vnic_info *vnic;
unsigned int i;
int rc;
- rc = is_bnxt_in_error(bp);
- if (rc)
- return rc;
-
vnic = BNXT_GET_DEFAULT_VNIC(bp);
if (!(rx_offloads & DEV_RX_OFFLOAD_VLAN_FILTER)) {
/* Remove any VLAN filters programmed */
@@ -1895,6 +1889,28 @@ bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask)
PMD_DRV_LOG(DEBUG, "VLAN Filtering: %d\n",
!!(rx_offloads & DEV_RX_OFFLOAD_VLAN_FILTER));
+ return 0;
+}
+
+static int
+bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask)
+{
+ uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
+ struct bnxt *bp = dev->data->dev_private;
+ unsigned int i;
+ int rc;
+
+ rc = is_bnxt_in_error(bp);
+ if (rc)
+ return rc;
+
+ if (mask & ETH_VLAN_FILTER_MASK) {
+ /* Enable or disable VLAN filtering */
+ rc = bnxt_config_vlan_hw_filter(bp, rx_offloads);
+ if (rc)
+ return rc;
+ }
+
if (mask & ETH_VLAN_STRIP_MASK) {
/* Enable or disable VLAN stripping */
for (i = 0; i < bp->nr_vnics; i++) {
@@ -1984,7 +2000,6 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,
struct bnxt *bp = dev->data->dev_private;
/* Default Filter is tied to VNIC 0 */
struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp);
- struct bnxt_filter_info *filter;
int rc;
rc = is_bnxt_in_error(bp);
@@ -1997,32 +2012,23 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev,
if (rte_is_zero_ether_addr(addr))
return -EINVAL;
- STAILQ_FOREACH(filter, &vnic->filter, next) {
- /* Default Filter is at Index 0 */
- if (filter->mac_index != 0)
- continue;
-
- memcpy(filter->l2_addr, addr, RTE_ETHER_ADDR_LEN);
- memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
- filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX |
- HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_OUTERMOST;
- filter->enables |=
- HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
- HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK;
+ /* Check if the requested MAC is already added */
+ if (memcmp(addr, bp->mac_addr, RTE_ETHER_ADDR_LEN) == 0)
+ return 0;
- rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter);
- if (rc) {
- memcpy(filter->l2_addr, bp->mac_addr,
- RTE_ETHER_ADDR_LEN);
- return rc;
- }
+ /* Destroy filter and re-create it */
+ bnxt_del_dflt_mac_filter(bp, vnic);
- memcpy(bp->mac_addr, addr, RTE_ETHER_ADDR_LEN);
- PMD_DRV_LOG(DEBUG, "Set MAC addr\n");
- return 0;
+ memcpy(bp->mac_addr, addr, RTE_ETHER_ADDR_LEN);
+ if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_VLAN_FILTER) {
+ /* This filter will allow only untagged packets */
+ rc = bnxt_add_vlan_filter(bp, 0);
+ } else {
+ rc = bnxt_add_mac_filter(bp, vnic, addr, 0, 0);
}
- return 0;
+ PMD_DRV_LOG(DEBUG, "Set MAC addr\n");
+ return rc;
}
static int
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 0c410f8ba..b31f10479 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -39,9 +39,10 @@ struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp)
filter->flags = HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX;
filter->enables = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR |
HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK;
- memcpy(filter->l2_addr, bp->eth_dev->data->mac_addrs->addr_bytes,
- RTE_ETHER_ADDR_LEN);
+ memcpy(filter->l2_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
memset(filter->l2_addr_mask, 0xff, RTE_ETHER_ADDR_LEN);
+ /* bump up the reference count of filter */
+ filter->l2_ref_cnt++;
return filter;
}
--
2.21.0 (Apple Git-122.2)
next prev parent reply other threads:[~2020-01-14 5:17 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 5:01 [dpdk-dev] [PATCH V2 00/10] bnxt patchset with bug fixes Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 01/10] net/bnxt: handle flow create failure Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 02/10] net/bnxt: fix probe failure in FreeBSD Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 03/10] net/bnxt: fix to use correct IOVA mapping Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 04/10] net/bnxt: fix enable/disable VLAN filtering Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 05/10] net/bnxt: fix enable/disable vlan strip Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 06/10] net/bnxt: handle hw filter setting when port is stopped Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 07/10] net/bnxt: fix a memory leak in port stop Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 08/10] net/bnxt: use macro for PCI log format Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 09/10] net/bnxt: release port upon close Kalesh A P
2020-01-13 5:01 ` [dpdk-dev] [PATCH V2 10/10] net/bnxt: fix to cap max rings to minimum of compl rings and stat contexts Kalesh A P
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 00/10] bnxt patchset with bug fixes Ajit Khaparde
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 01/10] net/bnxt: handle flow create failure Ajit Khaparde
2020-01-14 12:59 ` Ferruh Yigit
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 02/10] net/bnxt: fix probe failure in FreeBSD Ajit Khaparde
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 03/10] net/bnxt: fix to use correct IOVA mapping Ajit Khaparde
2020-01-14 5:14 ` Ajit Khaparde [this message]
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 05/10] net/bnxt: fix VLAN strip support Ajit Khaparde
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 06/10] net/bnxt: handle HW filter setting when port is stopped Ajit Khaparde
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 07/10] net/bnxt: fix a memory leak in port stop Ajit Khaparde
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 08/10] net/bnxt: use macro for PCI log format Ajit Khaparde
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 09/10] net/bnxt: release port upon close Ajit Khaparde
2020-01-14 12:56 ` Ferruh Yigit
2020-01-14 14:49 ` Somnath Kotur
2020-01-16 11:20 ` Ferruh Yigit
2020-01-16 11:30 ` Somnath Kotur
2020-01-14 5:14 ` [dpdk-dev] [PATCH v3 10/10] net/bnxt: fix calculation of max rings Ajit Khaparde
2020-01-14 5:27 ` [dpdk-dev] [PATCH v3 00/10] bnxt patchset with bug fixes Ajit Khaparde
2020-01-14 13:02 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200114051435.46093-5-ajit.khaparde@broadcom.com \
--to=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=somnath.kotur@broadcom.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).