diff mbox

[U-Boot,PATCHv6,13/28] net: core: print the source of the MAC address

Message ID 20170515080244.21345-14-oliver@schinagl.nl
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Olliver Schinagl May 15, 2017, 8:02 a.m. UTC
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@schinagl.nl>
---
 include/net.h    | 14 ++++++++++++++
 net/eth-uclass.c | 18 +++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

Comments

Joe Hershberger May 30, 2017, 9:11 p.m. UTC | #1
On Mon, May 15, 2017 at 3:02 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
> 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@schinagl.nl>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

diff --git a/include/net.h b/include/net.h
index 392dc95fdc..762ff2b319 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]");