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 1448DA04F0 for ; Wed, 18 Dec 2019 07:24:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6D6561BF82; Wed, 18 Dec 2019 07:24:49 +0100 (CET) Received: from relay.smtp.broadcom.com (unknown [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id EFDE51BC25 for ; Wed, 18 Dec 2019 07:24:46 +0100 (CET) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 847BB28FA66; Tue, 17 Dec 2019 22:24:46 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 847BB28FA66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1576650286; bh=IYVsKy0QzG7GxaSqCbol64meXukSPQvJbQIFQ2V2aDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fa9rK6uOGV2LGfxvHTmVyEhyteZIq87Z1spKDJBZR86rn9wwFKXqfgT66SRsQ50Om mkRpFvQcL7jzbLWW/Y/xLLKPq5cyfaW2inUOHs4wNLGoT+rhtaeBmjss4VszYEx1Fe GhZdyfBEJnCOM+PHDV7nFAGTOqPCIhOKqZxlsOD8= From: Somnath Kotur To: stable@dpdk.org Cc: ktraynor@redhat.com Date: Wed, 18 Dec 2019 11:54:06 +0530 Message-Id: <20191218062411.13079-15-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20191218062411.13079-1-somnath.kotur@broadcom.com> References: <20191218062411.13079-1-somnath.kotur@broadcom.com> Subject: [dpdk-stable] [PATCH 18.11 14/19] net/bnxt: fix MAC/VLAN filter allocation 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" From: Santoshkumar Karanappa Rastapur We were adding the VLAN filters to all the VNICs of the function. Also, we were adding these VLANs to all the existing MAC only filters. This was resulting in fewer VLANs getting added. By default we should allocate MAC+VLAN filter only to the default VNIC of the function using the default mac address. Similar logic was followed in the VLAN deletion code. This patch fixes it. Use inner VLAN fields instead of outer VLAN during filter deletion to be in sync with VLAN addition code. Fixes: 246c5cc5f05e ("net/bnxt: use correct flags during VLAN configuration") Signed-off-by: Santoshkumar Karanappa Rastapur Signed-off-by: Ajit Khaparde Signed-off-by: root --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 192 ++++++++++++++++------------------------- 2 files changed, 75 insertions(+), 118 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 20eacc7..909651e 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -348,6 +348,7 @@ struct bnxt { unsigned int nr_vnics; +#define BNXT_GET_DEFAULT_VNIC(bp) (&(bp)->vnic_info[0]) struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 5a62695..e6a9ad2 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1305,141 +1305,97 @@ bnxt_udp_tunnel_port_del_op(struct rte_eth_dev *eth_dev, static int bnxt_del_vlan_filter(struct bnxt *bp, uint16_t vlan_id) { - struct bnxt_filter_info *filter, *temp_filter, *new_filter; + struct bnxt_filter_info *filter; struct bnxt_vnic_info *vnic; - unsigned int i; int rc = 0; - uint32_t chk = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_OVLAN; - - /* Cycle through all VNICs */ - for (i = 0; i < bp->nr_vnics; i++) { - /* - * For each VNIC and each associated filter(s) - * if VLAN exists && VLAN matches vlan_id - * remove the MAC+VLAN filter - * add a new MAC only filter - * else - * VLAN filter doesn't exist, just skip and continue - */ - vnic = &bp->vnic_info[i]; - filter = STAILQ_FIRST(&vnic->filter); - while (filter) { - temp_filter = STAILQ_NEXT(filter, next); - - if (filter->enables & chk && - filter->l2_ovlan == vlan_id) { - /* Must delete the filter */ - STAILQ_REMOVE(&vnic->filter, filter, - bnxt_filter_info, next); - bnxt_hwrm_clear_l2_filter(bp, filter); - STAILQ_INSERT_TAIL(&bp->free_filter_list, - filter, next); + uint32_t chk = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN; - /* - * Need to examine to see if the MAC - * filter already existed or not before - * allocating a new one - */ - - new_filter = bnxt_alloc_filter(bp); - if (!new_filter) { - PMD_DRV_LOG(ERR, - "MAC/VLAN filter alloc failed\n"); - rc = -ENOMEM; - goto exit; - } - STAILQ_INSERT_TAIL(&vnic->filter, - new_filter, next); - /* Inherit MAC from previous filter */ - new_filter->mac_index = - filter->mac_index; - memcpy(new_filter->l2_addr, filter->l2_addr, - ETHER_ADDR_LEN); - /* MAC only filter */ - rc = bnxt_hwrm_set_l2_filter(bp, - vnic->fw_vnic_id, - new_filter); - if (rc) - goto exit; - PMD_DRV_LOG(INFO, - "Del Vlan filter for %d\n", - vlan_id); - } - filter = temp_filter; + /* if VLAN exists && VLAN matches vlan_id + * remove the MAC+VLAN filter + * add a new MAC only filter + * else + * VLAN filter doesn't exist, just skip and continue + */ + vnic = BNXT_GET_DEFAULT_VNIC(bp); + filter = STAILQ_FIRST(&vnic->filter); + while (filter) { + /* Search for this matching MAC+VLAN filter */ + if (filter->enables & chk && filter->l2_ivlan == vlan_id && + !memcmp(filter->l2_addr, + bp->mac_addr, + ETHER_ADDR_LEN)) { + /* Delete the filter */ + rc = bnxt_hwrm_clear_l2_filter(bp, filter); + if (rc) + return rc; + STAILQ_REMOVE(&vnic->filter, filter, + bnxt_filter_info, next); + STAILQ_INSERT_TAIL(&bp->free_filter_list, filter, next); + PMD_DRV_LOG(INFO, + "Del vlan filter for %d\n", + vlan_id); + return rc; } + filter = STAILQ_NEXT(filter, next); } -exit: - return rc; + return -ENOENT; } static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id) { - struct bnxt_filter_info *filter, *temp_filter, *new_filter; + struct bnxt_filter_info *filter; struct bnxt_vnic_info *vnic; - unsigned int i; int rc = 0; uint32_t en = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN_MASK; uint32_t chk = HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_IVLAN; - /* Cycle through all VNICs */ - for (i = 0; i < bp->nr_vnics; i++) { - /* - * For each VNIC and each associated filter(s) - * if VLAN exists: - * if VLAN matches vlan_id - * VLAN filter already exists, just skip and continue - * else - * add a new MAC+VLAN filter - * else - * Remove the old MAC only filter - * Add a new MAC+VLAN filter - */ - vnic = &bp->vnic_info[i]; - filter = STAILQ_FIRST(&vnic->filter); - while (filter) { - temp_filter = STAILQ_NEXT(filter, next); + /* Implementation notes on the use of VNIC in this command: + * + * By default, these filters belong to default vnic for the function. + * Once these filters are set up, only destination VNIC can be modified. + * If the destination VNIC is not specified in this command, + * then the HWRM shall only create an l2 context id. + */ - if (filter->enables & chk) { - if (filter->l2_ivlan == vlan_id) - goto cont; - } else { - /* Must delete the MAC filter */ - STAILQ_REMOVE(&vnic->filter, filter, - bnxt_filter_info, next); - bnxt_hwrm_clear_l2_filter(bp, filter); - filter->l2_ovlan = 0; - STAILQ_INSERT_TAIL(&bp->free_filter_list, - filter, next); - } - new_filter = bnxt_alloc_filter(bp); - if (!new_filter) { - PMD_DRV_LOG(ERR, - "MAC/VLAN filter alloc failed\n"); - rc = -ENOMEM; - goto exit; - } - STAILQ_INSERT_TAIL(&vnic->filter, new_filter, next); - /* Inherit MAC from the previous filter */ - new_filter->mac_index = filter->mac_index; - memcpy(new_filter->l2_addr, filter->l2_addr, - ETHER_ADDR_LEN); - /* MAC + VLAN ID filter */ - new_filter->l2_ivlan = vlan_id; - new_filter->l2_ivlan_mask = 0xF000; - new_filter->enables |= en; - rc = bnxt_hwrm_set_l2_filter(bp, - vnic->fw_vnic_id, - new_filter); - if (rc) - goto exit; - PMD_DRV_LOG(INFO, - "Added Vlan filter for %d\n", vlan_id); -cont: - filter = temp_filter; - } + vnic = BNXT_GET_DEFAULT_VNIC(bp); + filter = STAILQ_FIRST(&vnic->filter); + /* Check if the VLAN has already been added */ + while (filter) { + if (filter->enables & chk && filter->l2_ivlan == vlan_id && + !memcmp(filter->l2_addr, bp->mac_addr, ETHER_ADDR_LEN)) + return -EEXIST; + + filter = STAILQ_NEXT(filter, next); } -exit: + + /* No match found. Alloc a fresh filter and issue the L2_FILTER_ALLOC + * command to create MAC+VLAN filter with the right flags, enables set. + */ + filter = bnxt_alloc_filter(bp); + if (!filter) { + PMD_DRV_LOG(ERR, + "MAC/VLAN filter alloc failed\n"); + return -ENOMEM; + } + /* MAC + VLAN ID filter */ + filter->l2_ivlan = vlan_id; + filter->l2_ivlan_mask = 0x0FFF; + filter->enables |= en; + rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter); + if (rc) { + /* Free the newly allocated filter as we were + * not able to create the filter in hardware. + */ + filter->fw_l2_filter_id = UINT64_MAX; + STAILQ_INSERT_TAIL(&bp->free_filter_list, filter, next); + return rc; + } + + /* Add this new filter to the list */ + STAILQ_INSERT_TAIL(&vnic->filter, filter, next); + PMD_DRV_LOG(INFO, + "Added Vlan filter for %d\n", vlan_id); return rc; } -- 2.10.1