diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2015-05-04 14:55:13 -0500 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2015-05-19 13:33:21 -0500 |
commit | bef1014b31c5b33052bcaa865ba3618d73e906f0 (patch) | |
tree | b56bfdcf1466f142f2aeb4ed87cb6e6a87d73f24 /net | |
parent | abbfcbe58eefc1accda5dd120fcfe58d244b63dd (diff) | |
download | u-boot-imx-bef1014b31c5b33052bcaa865ba3618d73e906f0.zip u-boot-imx-bef1014b31c5b33052bcaa865ba3618d73e906f0.tar.gz u-boot-imx-bef1014b31c5b33052bcaa865ba3618d73e906f0.tar.bz2 |
net: Implement random ethaddr fallback in eth.c
Implement the random ethaddr fallback in eth.c so it is in a common
place and not reimplemented in each board or driver that wants this
behavior.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/Kconfig | 8 | ||||
-rw-r--r-- | net/eth.c | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/net/Kconfig b/net/Kconfig index 22b9eaa..a2bd4fe 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -7,4 +7,12 @@ menuconfig NET if NET +config NET_RANDOM_ETHADDR + bool "Random ethaddr if unset" + help + Selecting this will allow the Ethernet interface to function + even when the ethaddr variable for that interface is unset. + A new MAC address will be generated on every boot and it will + not be added to the environment. + endif # if NET @@ -538,9 +538,15 @@ static int eth_post_probe(struct udevice *dev) printf("\nWarning: %s using MAC address from ROM\n", dev->name); } else if (is_zero_ethaddr(pdata->enetaddr)) { +#ifdef CONFIG_NET_RANDOM_ETHADDR + net_random_ethaddr(pdata->enetaddr); + printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", + dev->name, dev->seq, pdata->enetaddr); +#else printf("\nError: %s address not set.\n", dev->name); return -EINVAL; +#endif } return 0; @@ -666,9 +672,15 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, printf("\nWarning: %s using MAC address from net device\n", dev->name); } else if (is_zero_ethaddr(dev->enetaddr)) { +#ifdef CONFIG_NET_RANDOM_ETHADDR + net_random_ethaddr(dev->enetaddr); + printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", + dev->name, eth_number, dev->enetaddr); +#else printf("\nError: %s address not set.\n", dev->name); return -EINVAL; +#endif } if (dev->write_hwaddr && !eth_mac_skip(eth_number)) { |