[v1 01/12] net/enetc: Add initial ENETC4 PMD driver support
Stephen Hemminger
stephen at networkplumber.org
Mon Oct 21 01:52:57 CEST 2024
On Fri, 18 Oct 2024 12:56:33 +0530
vanshika.shukla at nxp.com wrote:
> + /* Allocate memory for storing MAC addresses */
> + snprintf(eth_name, sizeof(eth_name), "enetc4_eth_%d", eth_dev->data->port_id);
> + eth_dev->data->mac_addrs = rte_zmalloc(eth_name,
> + RTE_ETHER_ADDR_LEN, 0);
> + if (!eth_dev->data->mac_addrs) {
The first argument of rte_malloc routines is hardly used. It does show up in
trace but that is about all. Ok to keep it this as is, but wasted effort.
> + if ((high_mac | low_mac) == 0) {
> + char *first_byte;
> +
> + ENETC_PMD_NOTICE("MAC is not available for this SI, "
> + "set random MAC");
> + mac = (uint32_t *)hw->mac.addr;
> + *mac = (uint32_t)rte_rand();
> + first_byte = (char *)mac;
> + *first_byte &= 0xfe; /* clear multicast bit */
> + *first_byte |= 0x02; /* set local assignment bit (IEEE802) */
> +
> + enetc4_port_wr(enetc_hw, ENETC4_PMAR0, *mac);
> + mac++;
> + *mac = (uint16_t)rte_rand();
> + enetc4_port_wr(enetc_hw, ENETC4_PMAR1, *mac);
> + print_ethaddr("New address: ",
> + (const struct rte_ether_addr *)hw->mac.addr);
Please use existing rte_eth_random_addr() for this.
More information about the dev
mailing list