All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olliver Schinagl <oliver@schinagl.nl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCHv2 06/21] net: core: print the source of the MAC address
Date: Mon, 10 Apr 2017 17:33:41 +0200	[thread overview]
Message-ID: <20170410153356.2664-7-oliver@schinagl.nl> (raw)
In-Reply-To: <20170410153356.2664-1-oliver@schinagl.nl>

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(-)

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

  parent reply	other threads:[~2017-04-10 15:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 15:33 [U-Boot] [PATCHv5 00/21] Retrieve MAC address from EEPROM Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 01/21] net: cosmetic: Do not use magic values for ARP_HLEN Olliver Schinagl
2017-04-13 21:16   ` Simon Glass
2017-05-30 20:32   ` Joe Hershberger
2017-04-10 15:33 ` [U-Boot] [PATCHv2 02/21] net: core: Sanitize get/set operations for enetaddr Olliver Schinagl
2017-04-13 21:16   ` Simon Glass
2017-04-10 15:33 ` [U-Boot] [PATCHv2 03/21] net: core: Inform the user of the device MAC address Olliver Schinagl
2017-04-15 23:39   ` Simon Glass
2017-04-10 15:33 ` [U-Boot] [PATCHv2 04/21] net: core: Add function to check/set MAC locality Olliver Schinagl
2017-04-11 13:49   ` Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 05/21] net: Add ability to set MAC address via EEPROM Olliver Schinagl
2017-04-10 15:33 ` Olliver Schinagl [this message]
2017-04-10 15:33 ` [U-Boot] [PATCHv2 07/21] net: cosmetic: A MAC address is not limited to SROM Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 08/21] fdt: fixup_eth: Remove code duplication with a function Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 09/21] fdt: fixup_eth: improve error catching/reduce identation Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 10/21] net: sunxi: Enable I2C bus set via NET_ETHADDR_EEPROM_I2C_BUS Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 11/21] net: sunxi_[eg]mac: Convert to Kconfig Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 12/21] arm: sunxi: Expose function to generate sunxi-specific a MAC address Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 13/21] net: sunxi_emac: Write HW address via net_ops hook Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 14/21] net: sunxi: Have sunxi common functions together Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 15/21] net: sunxi_emac: Add read_rom_hwaddr hook Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 16/21] net: sunxi_gmac: Make the sunxi variant of dw driver a subclass Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 17/21] net: dw: Expose designware_eth_start Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 18/21] net: sunxi_gmac: Add read_rom_hwaddr hook Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 19/21] net: sun8i_gmac: " Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 20/21] net: sun8i: fix whitespace Olliver Schinagl
2017-04-10 15:33 ` [U-Boot] [PATCHv2 21/21] net: core: Check return value of read_rom_hwaddr Olliver Schinagl
2017-04-10 15:52 ` [U-Boot] [PATCHv5 00/21] Retrieve MAC address from EEPROM York Sun
2017-04-10 15:57   ` Olliver Schinagl
2017-04-10 16:23     ` York Sun
2017-04-11 14:38       ` o.schinagl at ultimaker.com
2017-04-11 15:32         ` York Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170410153356.2664-7-oliver@schinagl.nl \
    --to=oliver@schinagl.nl \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.