Where is "initial" MAC address extracted? [IPQ40xx Ethernet]

I'm trying to track down where the initial MAC address is set during early boot when not explicitly set in the device tree, probably at driver-probe time.

The context is that compatible = "qcom,ipq4019-ess-edma" is picking up a MAC address from the U-Boot environment if it is present, and assigning a seemingly random, locally administered MAC when not. In the case of the EA8300, the value in the U-Boot environment is "always" 00:03:7f:ba:db:ad which can lead to MAC conflicts if multiples are present. (The "real" MAC address is in a different partition, strings /dev/mtdblock9).

Working on transitioning to DSA, I'd like to clear this up at the same time.

I'd prefer not to alter the U-Boot environment on everybody's devices, especially silently. To be able to accomplish this, finding out where in the code the decision to read the U-Boot environment would be very helpful.

drivers/net/ethernet/qualcomm/ipqess/ipqess.c has led me down a few rabbit holes.

static int __init ipqess_init(struct net_device *netdev)
{
        struct ipqess *ess = netdev_priv(netdev);
        struct device_node *of_node = ess->pdev->dev.of_node;
        return phylink_of_phy_connect(ess->phylink, of_node, 0);
}

suggests to me that the MAC address is somehow merged into the run-time device tree. (I've confirmed that changing the U-Boot environment variable changes the MAC, as well as removing it results in a locally administered value).

Pointers would be greatly appreciated. TIA

1 Like

IPQESS driver will call of_get_mac_address() as part of the probe which will attempt to get the MAC from the DT node, and if that fails from the NVMEM cell if it's defined, and if everything fails use a random MAC.

It's not picking the MAC from the U-boot env, but rather its U-boot which uses the ethernet0 alias to patch the MAC into the DT node.

So, you can either delete the ethernet0 alias in device DTS, then set the MAC using NVMEM cell in DTS or use 02_network to override it during runtime

1 Like

Thanks, having options is always a good thing.

I'll think through the use cases.There's always the chance that someone other than a half-dozen of us would notice and change it in the U-Boot env and then wonder why it was "broken".

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.