[U-Boot] [PATCHv2 06/21] net: core: print the source of the MAC address
Olliver Schinagl
oliver at schinagl.nl
Mon Apr 10 15:33:41 UTC 2017
With many potential places where a MAC address can be read from, the
user may not know where the MAC address originated from. Print the MAC
source after initializing the Ethernet device.
Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
---
include/net.h | 14 ++++++++++++++
net/eth-uclass.c | 18 +++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/include/net.h b/include/net.h
index 7c66f3f06d..3eb5f81ea5 100644
--- a/include/net.h
+++ b/include/net.h
@@ -87,18 +87,32 @@ enum eth_state_t {
ETH_STATE_ACTIVE
};
+enum enetaddr_source {
+ ENETADDR_SRC_UNKNOWN = 0,
+ ENETADDR_SRC_ROM,
+ ENETADDR_SRC_EEPROM,
+ ENETADDR_SRC_DRIVER,
+ ENETADDR_SRC_BOARD,
+ ENETADDR_SRC_ENV,
+ ENETADDR_SRC_FDT,
+ ENETADDR_SRC_RANDOM,
+ ENETADDR_SRC_NONE,
+};
+
#ifdef CONFIG_DM_ETH
/**
* struct eth_pdata - Platform data for Ethernet MAC controllers
*
* @iobase: The base address of the hardware registers
* @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env
+ * @enetaddr_source: Indicator where the Ethernet MAC adress came from
* @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_...
* @max_speed: Maximum speed of Ethernet connection supported by MAC
*/
struct eth_pdata {
phys_addr_t iobase;
unsigned char enetaddr[ARP_HLEN];
+ enum enetaddr_source enetaddr_src;
int phy_interface;
int max_speed;
};
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 02ee926f74..c88b032868 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -416,9 +416,21 @@ int eth_initialize(void)
putc('\n');
do {
struct eth_pdata *pdata = dev->platdata;
-
- printf("eth%d: %s [%pM]\n", dev->seq, dev->name,
- pdata->enetaddr);
+ const char *enetaddr_src[] = {
+ "unknown",
+ "ROM",
+ "EEPROM",
+ "driver",
+ "board",
+ "environment",
+ "flattened device tree",
+ "randomly generated",
+ "not set",
+ };
+
+ printf("eth%d: %s [%pM] (%s)\n", dev->seq, dev->name,
+ pdata->enetaddr,
+ enetaddr_src[pdata->enetaddr_src]);
if (ethprime && dev == prime_dev)
printf(" [PRIME]");
--
2.11.0
More information about the U-Boot
mailing list