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 68F1FA04F0; Mon, 13 Jan 2020 05:44:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CB18A1C225; Mon, 13 Jan 2020 05:44:19 +0100 (CET) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id 5382D1D57D for ; Mon, 13 Jan 2020 05:44:10 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 77C4928F8C6; Sun, 12 Jan 2020 20:44:09 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 77C4928F8C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1578890649; bh=12qQC0drNN1AeEe5DRtPOVT+QIkz5ztAl1nd5e8Hk18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWkJECnwPGiI8+KwkwR7Ky0DgEPWzazAWXAw1vWEGu2LSue/YE1RoInBrlaRHv9H5 TmZ1NuZwp0amnMcsYSb4gF6w+Jo/sn2WkTulPEyum3gfuaonFd+riiZZl+mMM9tyEP 6gTmfoe4JMtdxQVmiZ660MIf8oUOD44SdpB8qhP8= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Date: Mon, 13 Jan 2020 10:31:12 +0530 Message-Id: <20200113050118.28719-5-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20200113050118.28719-1-kalesh-anakkur.purayil@broadcom.com> References: <20200113050118.28719-1-kalesh-anakkur.purayil@broadcom.com> Subject: [dpdk-dev] [PATCH V2 04/10] net/bnxt: fix enable/disable VLAN filtering 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" From: Kalesh AP 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: 51fda51e7b70 ("net/bnxt: fix to keep the L2 filter intact so it can be reused") Fixes: 6118503d8071 ("net/bnxt: fix VLAN filtering") Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Kumar Khaparde --- 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 a948c78..83f475d 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 0c410f8..b31f104 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.10.1