diff mbox series

[06/18] net/bnxt: fix to cap max number of unicast MACs

Message ID 20220104083824.23001-7-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>

The Maximum number of receive mac addr is hard coded to 128
in the ethdev library(RTE_ETH_NUM_RECEIVE_MAC_ADDR).
But the bnxt devices support more than 128 unicast MAC filters
which could result in a segfault while user tries to add more
than 128 unicast MAC addresses to the port.

Fixes: a2033fda22ab ("net/bnxt: fix number of MAC addresses for VMDq")
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_ethdev.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 99a7d35..82350a5 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -954,7 +954,7 @@  static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 		return rc;
 
 	/* MAC Specifics */
-	dev_info->max_mac_addrs = bp->max_l2_ctx;
+	dev_info->max_mac_addrs = RTE_MIN(bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
 	dev_info->max_hash_mac_addrs = 0;
 
 	/* PF/VF specifics */
@@ -5016,11 +5016,15 @@  static int bnxt_alloc_stats_mem(struct bnxt *bp)
 static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
+	size_t max_mac_addr = RTE_MIN(bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
 	int rc = 0;
 
+	if (bp->max_l2_ctx > RTE_ETH_NUM_RECEIVE_MAC_ADDR)
+		PMD_DRV_LOG(INFO, "Max number of MAC addrs supported is %d, but will be limited to %d\n",
+			    bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
+
 	eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
-					       RTE_ETHER_ADDR_LEN *
-					       bp->max_l2_ctx,
+					       RTE_ETHER_ADDR_LEN * max_mac_addr,
 					       0);
 	if (eth_dev->data->mac_addrs == NULL) {
 		PMD_DRV_LOG(ERR, "Failed to alloc MAC addr tbl\n");