From: Kalesh AP Date: Thu, 18 Jul 2019 03:35:59 +0000 (+0530) Subject: net/bnxt: fix setting primary MAC address X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=68f589f2c728e7d893b2eacd86aca09b5546d690;p=dpdk.git net/bnxt: fix setting primary MAC address 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") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 55b030a2b4..70d24494a1 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1699,26 +1699,28 @@ bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev, if (BNXT_VF(bp) && !BNXT_VF_IS_TRUSTED(bp)) return -EPERM; - memcpy(bp->mac_addr, addr, sizeof(bp->mac_addr)); + if (rte_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, RTE_ETHER_ADDR_LEN); memset(filter->l2_addr_mask, 0xff, RTE_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, RTE_ETHER_ADDR_LEN); PMD_DRV_LOG(DEBUG, "Set MAC addr\n"); + return 0; } return 0;