net/bnxt: fix setting primary MAC address
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Thu, 18 Jul 2019 03:35:59 +0000 (09:05 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 23 Jul 2019 12:31:35 +0000 (14:31 +0200)
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 <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c

index 55b030a..70d2449 100644 (file)
@@ -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;