public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/3] net: Add a command to manipulate ethernet devices
@ 2014-10-14 16:26 Alban Bedel
  2014-10-14 16:26 ` [U-Boot] [PATCH v3 2/3] net: Add a command to access the EEPROM from " Alban Bedel
  2014-10-14 16:26 ` [U-Boot] [PATCH v3 3/3] usb: eth: smsc95xx: Add EEPROM access support for LAN9514 Alban Bedel
  0 siblings, 2 replies; 11+ messages in thread
From: Alban Bedel @ 2014-10-14 16:26 UTC (permalink / raw)
  To: u-boot

Add the 'eth' command for operations on ethernet devices.
This first version only contains a command to show a device
properties, currently only name, index and MAC address.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
---
v1: * Patch didn't exists
v2: * Patch didn't exists
v3: * Replace the dedicated 'eth_eeprom' command with a subcommand
      to the 'eth' command
---
 common/cmd_net.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 09489d4..9cc0bdf 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -445,3 +445,51 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
+
+static int do_eth_show(struct eth_device *dev,
+			int argc, char * const argv[])
+{
+	printf("Name : %s\n", dev->name);
+	printf("Index: %d\n", dev->index);
+	printf("MAC  : %pM\n", dev->enetaddr);
+	return 0;
+}
+
+static int do_eth(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	struct eth_device *dev;
+	char *endp = NULL;
+	int index;
+
+	if (argc < 3)
+		return CMD_RET_USAGE;
+
+	/* Get the ethernet device, by ID or by name */
+	index = (int) simple_strtoul(argv[1], &endp, 16);
+	if (endp > argv[1])
+		dev = eth_get_dev_by_index(index);
+	else
+		dev = eth_get_dev_by_name(argv[2]);
+
+	if (!dev) {
+		printf("Ethernet device not found\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (!strcmp(argv[2], "show"))
+		return do_eth_show(dev, argc - 2, argv + 2);
+
+	printf("Unknown eth sub command: %s\n", argv[2]);
+
+	return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+	eth,	7,	0,	do_eth,
+	"extended ops for ethernet devices",
+	"<dev> <command> [<args>...]\n"
+	"    - run command on a device, device may be a name or id.\n"
+	"\n"
+	"eth <dev> show\n"
+	"    - show basic information about the ethernet device\n"
+);
-- 
2.1.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-10-21 16:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-14 16:26 [U-Boot] [PATCH v3 1/3] net: Add a command to manipulate ethernet devices Alban Bedel
2014-10-14 16:26 ` [U-Boot] [PATCH v3 2/3] net: Add a command to access the EEPROM from " Alban Bedel
2014-10-14 17:21   ` Simon Glass
2014-10-14 19:14     ` Joe Hershberger
2014-10-14 19:18       ` Simon Glass
2014-10-15  9:42         ` Alban Bedel
2014-10-17 20:12           ` Simon Glass
2014-10-21 12:51             ` Alban Bedel
2014-10-21 16:19               ` Simon Glass
2014-10-14 20:59     ` Marek Vasut
2014-10-14 16:26 ` [U-Boot] [PATCH v3 3/3] usb: eth: smsc95xx: Add EEPROM access support for LAN9514 Alban Bedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox