net/bnxt: fix storing MAC address twice
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Fri, 15 May 2020 05:04:36 +0000 (22:04 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 May 2020 18:35:57 +0000 (20:35 +0200)
We are maintaining MAC address twice which is unnecessary.
This patch removes the copy which helps reduce size of bnxt structure.

Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")
Cc: stable@dpdk.org
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_hwrm.c

index 4093a2f..403b23f 100644 (file)
@@ -560,6 +560,7 @@ struct bnxt {
 #define BNXT_FLAG_FC_THREAD                    BIT(23)
 #define BNXT_FLAG_RX_VECTOR_PKT_MODE           BIT(24)
 #define BNXT_FLAG_FLOW_XSTATS_EN               BIT(25)
+#define BNXT_FLAG_DFLT_MAC_SET                 BIT(26)
 #define BNXT_PF(bp)            (!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)            ((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)          ((bp)->flags & BNXT_FLAG_NPAR_PF)
@@ -573,6 +574,7 @@ struct bnxt {
 #define BNXT_HAS_NQ(bp)                BNXT_CHIP_THOR(bp)
 #define BNXT_HAS_RING_GRPS(bp) (!BNXT_CHIP_THOR(bp))
 #define BNXT_FLOW_XSTATS_EN(bp)        ((bp)->flags & BNXT_FLAG_FLOW_XSTATS_EN)
+#define BNXT_HAS_DFLT_MAC_SET(bp)      ((bp)->flags & BNXT_FLAG_DFLT_MAC_SET)
 
        uint32_t                fw_cap;
 #define BNXT_FW_CAP_HOT_RESET          BIT(0)
@@ -658,7 +660,6 @@ struct bnxt {
        uint8_t                 max_q;
 
        uint16_t                fw_fid;
-       uint8_t                 dflt_mac_addr[RTE_ETHER_ADDR_LEN];
        uint16_t                max_rsscos_ctx;
        uint16_t                max_cp_rings;
        uint16_t                max_tx_rings;
index 4d64a98..77492f8 100644 (file)
@@ -4980,7 +4980,7 @@ static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
                return -ENOMEM;
        }
 
-       if (bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN)) {
+       if (!BNXT_HAS_DFLT_MAC_SET(bp)) {
                if (BNXT_PF(bp))
                        return -EINVAL;
 
@@ -4993,14 +4993,11 @@ static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
                            bp->mac_addr[3], bp->mac_addr[4], bp->mac_addr[5]);
 
                rc = bnxt_hwrm_set_mac(bp);
-               if (!rc)
-                       memcpy(&bp->eth_dev->data->mac_addrs[0], bp->mac_addr,
-                              RTE_ETHER_ADDR_LEN);
-               return rc;
+               if (rc)
+                       return rc;
        }
 
        /* Copy the permanent MAC from the FUNC_QCAPS response */
-       memcpy(bp->mac_addr, bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN);
        memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
 
        return rc;
@@ -5011,7 +5008,7 @@ static int bnxt_restore_dflt_mac(struct bnxt *bp)
        int rc = 0;
 
        /* MAC is already configured in FW */
-       if (!bnxt_check_zero_bytes(bp->dflt_mac_addr, RTE_ETHER_ADDR_LEN))
+       if (BNXT_HAS_DFLT_MAC_SET(bp))
                return 0;
 
        /* Restore the old MAC configured */
index a41d776..c1798b5 100644 (file)
@@ -731,7 +731,12 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
        }
 
        bp->fw_fid = rte_le_to_cpu_32(resp->fid);
-       memcpy(bp->dflt_mac_addr, &resp->mac_address, RTE_ETHER_ADDR_LEN);
+       if (!bnxt_check_zero_bytes(resp->mac_address, RTE_ETHER_ADDR_LEN)) {
+               bp->flags |= BNXT_FLAG_DFLT_MAC_SET;
+               memcpy(bp->mac_addr, &resp->mac_address, RTE_ETHER_ADDR_LEN);
+       } else {
+               bp->flags &= ~BNXT_FLAG_DFLT_MAC_SET;
+       }
        bp->max_rsscos_ctx = rte_le_to_cpu_16(resp->max_rsscos_ctx);
        bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
        bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
@@ -5027,7 +5032,6 @@ int bnxt_hwrm_set_mac(struct bnxt *bp)
 
        HWRM_CHECK_RESULT();
 
-       memcpy(bp->dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
        HWRM_UNLOCK();
 
        return rc;