MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bnxt_setup_mac_addr

Function bnxt_setup_mac_addr

dpdk/drivers/net/bnxt/bnxt_ethdev.c:5098–5154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5096}
5097
5098static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
5099{
5100 struct bnxt *bp = eth_dev->data->dev_private;
5101 size_t max_mac_addr = RTE_MIN(bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
5102 int rc = 0;
5103
5104 if (bp->max_l2_ctx > RTE_ETH_NUM_RECEIVE_MAC_ADDR)
5105 PMD_DRV_LOG(INFO, "Max number of MAC addrs supported is %d, but will be limited to %d\n",
5106 bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
5107
5108 eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
5109 RTE_ETHER_ADDR_LEN * max_mac_addr,
5110 0);
5111 if (eth_dev->data->mac_addrs == NULL) {
5112 PMD_DRV_LOG(ERR, "Failed to alloc MAC addr tbl\n");
5113 return -ENOMEM;
5114 }
5115
5116 if (!BNXT_HAS_DFLT_MAC_SET(bp)) {
5117 if (BNXT_PF(bp))
5118 return -EINVAL;
5119
5120 /* Generate a random MAC address, if none was assigned by PF */
5121 PMD_DRV_LOG(INFO, "VF MAC address not assigned by Host PF\n");
5122 bnxt_eth_hw_addr_random(bp->mac_addr);
5123 PMD_DRV_LOG(INFO,
5124 "Assign random MAC:" RTE_ETHER_ADDR_PRT_FMT "\n",
5125 bp->mac_addr[0], bp->mac_addr[1], bp->mac_addr[2],
5126 bp->mac_addr[3], bp->mac_addr[4], bp->mac_addr[5]);
5127
5128 rc = bnxt_hwrm_set_mac(bp);
5129 if (rc)
5130 return rc;
5131 }
5132
5133 /* Copy the permanent MAC from the FUNC_QCAPS response */
5134 memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);
5135
5136 /*
5137 * Allocate memory to hold multicast mac addresses added.
5138 * Used to restore them during reset recovery
5139 */
5140 bp->mcast_addr_list = rte_zmalloc("bnxt_mcast_addr_tbl",
5141 sizeof(struct rte_ether_addr) *
5142 BNXT_MAX_MC_ADDRS, 0);
5143 if (bp->mcast_addr_list == NULL) {
5144 PMD_DRV_LOG(ERR, "Failed to allocate multicast addr table\n");
5145 return -ENOMEM;
5146 }
5147 bp->mc_list_dma_addr = rte_malloc_virt2iova(bp->mcast_addr_list);
5148 if (bp->mc_list_dma_addr == RTE_BAD_IOVA) {
5149 PMD_DRV_LOG(ERR, "Fail to map mcast_addr_list to physical memory\n");
5150 return -ENOMEM;
5151 }
5152
5153 return rc;
5154}
5155

Callers 1

bnxt_init_resourcesFunction · 0.85

Calls 5

rte_zmallocFunction · 0.85
bnxt_eth_hw_addr_randomFunction · 0.85
bnxt_hwrm_set_macFunction · 0.85
rte_malloc_virt2iovaFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected