From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ABAEAA00C5; Tue, 4 Jan 2022 09:19:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED89341147; Tue, 4 Jan 2022 09:19:13 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id E65E141145 for ; Tue, 4 Jan 2022 09:19:12 +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-ext.broadcom.com (Postfix) with ESMTP id 412EAC0000F2; Tue, 4 Jan 2022 00:19:10 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 412EAC0000F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1641284351; bh=JPbnz156Dp2Z7zqTgirVBgBuE2+JfJH+6zrffiWmKD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGJAAT4lTXDlUlEPOW+4cX5gHC7nYXzPjuwINOKCo0WPxLajowLpV/vopJw399tpE jmIUjwq4eBHTfXwSwVRrZgDh+neYomzR4CncQJjt9ih4zEBH0UUTXpYxswWjVVjyVB G5DQ+yDMaxDTuHJHgryxb+q4fKus6XaIOpt9CfM4= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Subject: [dpdk-dev] [PATCH 01/18] net/bnxt: fix bnxt_dev_set_mc_addr_list_op Date: Tue, 4 Jan 2022 14:08:07 +0530 Message-Id: <20220104083824.23001-2-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20220104083824.23001-1-kalesh-anakkur.purayil@broadcom.com> References: <20220104083824.23001-1-kalesh-anakkur.purayil@broadcom.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kalesh AP Fix to cache the multicast mac addresses added to the port to the driver private structure memory. Use this cached mc list to program the FW. This fixes an issue where multicast packets reception is successful only if the multicast mac address of the packets is the first one in the multicast address list of the port. This is in preparation for another fix in the series. Fixes: d69851df12b2 ("net/bnxt: support multicast filter and set MAC addr") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt.h | 5 +++++ drivers/net/bnxt/bnxt_ethdev.c | 34 +++++++++++++++++++++++++--------- drivers/net/bnxt/bnxt_hwrm.c | 4 ++-- drivers/net/bnxt/bnxt_vnic.c | 7 +------ drivers/net/bnxt/bnxt_vnic.h | 4 ---- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 2341610..521fcb7 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -891,6 +891,11 @@ struct bnxt { uint16_t tx_cfa_action; struct bnxt_ring_stats *prev_rx_ring_stats; struct bnxt_ring_stats *prev_tx_ring_stats; + +#define BNXT_MAX_MC_ADDRS 16 + struct rte_ether_addr *mcast_addr_list; + rte_iova_t mc_list_dma_addr; + uint32_t nb_mc_addr; }; static diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index f79f33a..50ffa30 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -2831,9 +2831,8 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev, uint32_t nb_mc_addr) { struct bnxt *bp = eth_dev->data->dev_private; - char *mc_addr_list = (char *)mc_addr_set; struct bnxt_vnic_info *vnic; - uint32_t off = 0, i = 0; + uint32_t i = 0; int rc; rc = is_bnxt_in_error(bp); @@ -2842,6 +2841,8 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev, vnic = BNXT_GET_DEFAULT_VNIC(bp); + bp->nb_mc_addr = nb_mc_addr; + if (nb_mc_addr > BNXT_MAX_MC_ADDRS) { vnic->flags |= BNXT_VNIC_INFO_ALLMULTI; goto allmulti; @@ -2849,14 +2850,10 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev, /* TODO Check for Duplicate mcast addresses */ vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI; - for (i = 0; i < nb_mc_addr; i++) { - memcpy(vnic->mc_list + off, &mc_addr_list[i], - RTE_ETHER_ADDR_LEN); - off += RTE_ETHER_ADDR_LEN; - } + for (i = 0; i < nb_mc_addr; i++) + rte_ether_addr_copy(&mc_addr_set[i], &bp->mcast_addr_list[i]); - vnic->mc_addr_cnt = i; - if (vnic->mc_addr_cnt) + if (bp->nb_mc_addr) vnic->flags |= BNXT_VNIC_INFO_MCAST; else vnic->flags &= ~BNXT_VNIC_INFO_MCAST; @@ -5016,6 +5013,23 @@ static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev) /* Copy the permanent MAC from the FUNC_QCAPS response */ memcpy(ð_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN); + /* + * Allocate memory to hold multicast mac addresses added. + * Used to restore them during reset recovery + */ + bp->mcast_addr_list = rte_zmalloc("bnxt_mcast_addr_tbl", + sizeof(struct rte_ether_addr) * + BNXT_MAX_MC_ADDRS, 0); + if (bp->mcast_addr_list == NULL) { + PMD_DRV_LOG(ERR, "Failed to allocate multicast addr table\n"); + return -ENOMEM; + } + bp->mc_list_dma_addr = rte_malloc_virt2iova(bp->mcast_addr_list); + if (bp->mc_list_dma_addr == RTE_BAD_IOVA) { + PMD_DRV_LOG(ERR, "Fail to map mcast_addr_list to physical memory\n"); + return -ENOMEM; + } + return rc; } @@ -5916,6 +5930,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) if (!reconfig_dev) { bnxt_free_hwrm_resources(bp); bnxt_free_error_recovery_info(bp); + rte_free(bp->mcast_addr_list); + bp->mcast_addr_list = NULL; } bnxt_uninit_ctx_mem(bp); diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index f53f863..fdc274c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -506,8 +506,8 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST; } else if (vnic->flags & BNXT_VNIC_INFO_MCAST) { mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST; - req.num_mc_entries = rte_cpu_to_le_32(vnic->mc_addr_cnt); - req.mc_tbl_addr = rte_cpu_to_le_64(vnic->mc_list_dma_addr); + req.num_mc_entries = rte_cpu_to_le_32(bp->nb_mc_addr); + req.mc_tbl_addr = rte_cpu_to_le_64(bp->mc_list_dma_addr); } if (vlan_table) { if (!(mask & HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN)) diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index c63cf4b..e05dc24 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -126,8 +126,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) int i; rte_iova_t mz_phys_addr; - entry_length = HW_HASH_KEY_SIZE + - BNXT_MAX_MC_ADDRS * RTE_ETHER_ADDR_LEN; + entry_length = HW_HASH_KEY_SIZE; if (BNXT_CHIP_P5(bp)) rss_table_size = BNXT_RSS_TBL_SIZE_P5 * @@ -169,10 +168,6 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + rss_table_size; - vnic->mc_list = (void *)((char *)vnic->rss_hash_key + - HW_HASH_KEY_SIZE); - vnic->mc_list_dma_addr = vnic->rss_hash_key_dma_addr + - HW_HASH_KEY_SIZE; bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE); } diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h index 37b452f..af3a2dd 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -32,10 +32,6 @@ struct bnxt_vnic_info { uint16_t *rss_table; rte_iova_t rss_hash_key_dma_addr; void *rss_hash_key; - rte_iova_t mc_list_dma_addr; - char *mc_list; - uint32_t mc_addr_cnt; -#define BNXT_MAX_MC_ADDRS 16 uint32_t flags; #define BNXT_VNIC_INFO_PROMISC (1 << 0) #define BNXT_VNIC_INFO_ALLMULTI (1 << 1) -- 2.10.1