diff mbox series

[01/18] net/bnxt: fix bnxt_dev_set_mc_addr_list_op

Message ID 20220104083824.23001-2-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers show
Series bnxt PMD fixes | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kalesh A P Jan. 4, 2022, 8:38 a.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

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 <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 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 mbox series

Patch

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(&eth_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)