From: Kalesh AP Date: Fri, 15 May 2020 05:04:36 +0000 (-0700) Subject: net/bnxt: fix storing MAC address twice X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=86421846cc20e963e5b6878724727abd427cd1b6;p=dpdk.git net/bnxt: fix storing MAC address twice 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 Signed-off-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 4093a2f01e..403b23f356 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -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; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4d64a98351..77492f89c7 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -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(ð_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 */ diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index a41d77669b..c1798b59d1 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -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;