net: ibm: emac: generate random MAC if not found

On this Cisco MX60W, u-boot sets the local-mac-address property.
Unfortunately by default, the MAC is wrong and is actually located on a
UBI partition. Which means nvmem needs to be used to grab it.

In the case where that fails, EMAC fails to initialize instead of
generating a random MAC as many other drivers do.

Match behavior with other drivers to have a working ethernet interface.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Rosen Penev 2024-10-21 17:22:45 -07:00 committed by Paolo Abeni
parent af4698be49
commit 707f1c4b6a

View File

@ -2937,9 +2937,12 @@ static int emac_init_config(struct emac_instance *dev)
/* Read MAC-address */
err = of_get_ethdev_address(np, dev->ndev);
if (err)
return dev_err_probe(&dev->ofdev->dev, err,
"Can't get valid [local-]mac-address from OF !\n");
if (err == -EPROBE_DEFER)
return err;
if (err) {
dev_warn(&dev->ofdev->dev, "Can't get valid mac-address. Generating random.");
eth_hw_addr_random(dev->ndev);
}
/* IAHT and GAHT filter parameterization */
if (emac_has_feature(dev, EMAC_FTR_EMAC4SYNC)) {