From e8ab24b4e0a8c137a5376bb75ca823fdcce92ab5 Mon Sep 17 00:00:00 2001 From: Kalesh AP Date: Thu, 18 Jul 2019 09:05:59 +0530 Subject: [PATCH] net/bnxt: fix setting primary MAC address [ upstream commit 68f589f2c728e7d893b2eacd86aca09b5546d690 ] 1. Default filter is tied to VNIC 0 at index 0. After finding the filter with mac_index 0 and set the new MAC address, looping through remaining filters is unnecessary. 2. Added a check for NULL MAC address. 3. bnxt_hwrm_set_l2_filter() clears the existing filter configuration first before applying new filter settings. Hence there is no need to invoke bnxt_hwrm_clear_l2_filter() explicitly in bnxt_set_default_mac_addr_op(). Fixes: d69851df12b2 ("net/bnxt: support multicast filter and set MAC addr") Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 20bca23c76..286f7cb8b9 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1541,26 +1541,28 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev, struct ether_addr *addr) if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) return -EPERM; - memcpy(bp->mac_addr, addr, sizeof(bp->mac_addr)); + if (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; - rc = bnxt_hwrm_clear_l2_filter(bp, filter); - if (rc) - return rc; + memcpy(filter->l2_addr, bp->mac_addr, ETHER_ADDR_LEN); memset(filter->l2_addr_mask, 0xff, ETHER_ADDR_LEN); 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; + rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter); if (rc) return rc; - filter->mac_index = 0; + + memcpy(bp->mac_addr, addr, ETHER_ADDR_LEN); PMD_DRV_LOG(DEBUG, "Set MAC addr\n"); + return 0; } return 0;