Skip to contentSkip to conversation

ethtool: sky2 GMAC decode

PATCH In review Stephen Hemminger 4 participants 12 messages Oct 18, 2006 – Feb 9, 2007

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 2/3 ethtool: sky2 more decode

In reply to Stephen Hemminger

Dump even more GMAC/GPHY state

---
 marvell.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
marvell.c +12 -4
index 244bb69..e867521 100644
@@ -113,7 +113,7 @@ static void dump_fifo(const char *name, 
 	dump_timer("LED", p + 0x20);
 }
 
-static void dump_gmac_fifo(const void *p)
+static void dump_gmac_fifo(const char *name, const void *p)
 {
 	const u32 *r = p;
 	int i;
@@ -133,6 +133,7 @@ static void dump_gmac_fifo(const void *p
 		"FIFO Read Level",
 	};
 
+	printf("\n%s\n", name);
 	for (i = 0; i < sizeof(regs)/sizeof(regs[0]); ++i)
 		printf("%-32s 0x%08X\n", regs[i], r[i]);
 
@@ -319,8 +320,6 @@ int sky2_dump_regs(struct ethtool_drvinf
 	}
 
 	dump_mac(regs->data);
-	dump_gmac("GMAC 1", regs->data + 0x2800);
-	dump_gmac_fifo(regs->data + 0xc40);
 
 	printf("\nStatus BMU:\n-----------\n");
 	printf("Control                                0x%08X\n",
@@ -350,6 +349,14 @@ int sky2_dump_regs(struct ethtool_drvinf
 	dump_timer("TX status", regs->data + 0xec0);
 	dump_timer("ISR", regs->data + 0xed0);
 
+	printf("\nGMAC control             0x%04X\n", *(u32 *)(regs->data + 0xf00));
+	printf("GPHY control             0x%04X\n", *(u32 *)(regs->data + 0xf04));
+	printf("LINK control             0x%02hX\n", *(u16 *)(regs->data + 0xf10));
+
+	dump_gmac("GMAC 1", regs->data + 0x2800);
+	dump_gmac_fifo("Rx GMAC 1", regs->data + 0xc40);
+	dump_gmac_fifo("Tx GMAC 1", regs->data + 0xd40);
+
 	dump_queue2("Receive Queue 1", regs->data +0x400, 1);
 	dump_queue("Sync Transmit Queue 1", regs->data +0x600, 0);
 	dump_queue2("Async Transmit Queue 1", regs->data +0x680, 0);
@@ -364,7 +371,8 @@ int sky2_dump_regs(struct ethtool_drvinf
 		dump_ram("Sync Transmit RAMbuffer 2", regs->data+0xb00);
 		dump_ram("Async Transmit RAMbuffer 21", regs->data+0xb80);
 		dump_gmac("GMAC 2", regs->data + 0x3800);
-		dump_gmac_fifo(regs->data + 0xc40 + 128);
+		dump_gmac_fifo("Rx GMAC 2", regs->data + 0xc40 + 128);
+		dump_gmac_fifo("Tx GMAC 2", regs->data + 0xd40 + 128);
 	}
 
 	return 0;
Signature · 1 line
1.4.1
#2 lore raw

PATCH 3/3 ethtool: dump_registers post mortem

In reply to Stephen Hemminger

This patch allows:
ethtool -d eth0 raw on >saved_regs
and later
ethtool -d eth0 file saved_regs

Selfish motive is to be able to take register dumps from users and and decode later, possibly adding more output as needed.

---
 ethtool.c |   39 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 34 insertions(+), 5 deletions(-)
ethtool.c +34 -5
index b783248..7861990 100644
@@ -29,7 +29,9 @@ #endif
 #include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <sys/ioctl.h>
+#include <sys/stat.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
@@ -251,6 +253,7 @@ static int msglvl_wanted = -1;
 static int phys_id_time = 0;
 static int gregs_changed = 0;
 static int gregs_dump_raw = 0;
+static char *gregs_dump_file = NULL;
 static int geeprom_changed = 0;
 static int geeprom_dump_raw = 0;
 static int geeprom_offset = 0;
@@ -268,6 +271,7 @@ typedef enum {
 	CMDL_NONE,
 	CMDL_BOOL,
 	CMDL_INT,
+	CMDL_STR,
 } cmdline_type_t;
 
 struct cmdline_info {
@@ -279,6 +283,7 @@ struct cmdline_info {
 
 static struct cmdline_info cmdline_gregs[] = {
 	{ "raw", CMDL_BOOL, &gregs_dump_raw, NULL },
+	{ "file", CMDL_STR, &gregs_dump_file, NULL },
 };
 
 static struct cmdline_info cmdline_geeprom[] = {
@@ -355,20 +360,28 @@ static void parse_generic_cmdline(int ar
 				if (i >= argc)
 					show_usage(1);
 				p = info[idx].wanted_val;
-				if (info[idx].type == CMDL_BOOL) {
+				switch (info[idx].type) {
+				case CMDL_BOOL:
 					if (!strcmp(argp[i], "on"))
 						*p = 1;
 					else if (!strcmp(argp[i], "off"))
 						*p = 0;
 					else
 						show_usage(1);
-				} else if (info[idx].type == CMDL_INT) {
-					long v;
-					v = strtol(argp[i], NULL, 0);
+					break;
+				case CMDL_INT: {
+					long v = strtol(argp[i], NULL, 0);
 					if (v < 0)
 						show_usage(1);
 					*p = (int) v;
-				} else {
+					break;
+				}
+				case CMDL_STR: {
+					char **s = info[idx].wanted_val;
+					*s = strdup(argp[i]);
+					break;
+				}
+				default:
 					show_usage(1);
 				}
 			}
@@ -969,6 +982,22 @@ static int dump_regs(struct ethtool_drvi
 		return 0;
 	}
 
+	if (gregs_dump_file) {
+		FILE *f = fopen(gregs_dump_file, "r");
+		struct stat st;
+
+		if (!f || fstat(fileno(f), &st) < 0) {
+			fprintf(stderr, "Can't open '%s': %s\n",
+				gregs_dump_file, strerror(errno));
+			return -1;
+		}
+		
+		regs = realloc(regs, sizeof(*regs) + st.st_size);
+		regs->len = st.st_size;
+		fread(regs->data, regs->len, 1, f);
+		fclose(f);
+	}
+
 	for (i = 0; i < ARRAY_SIZE(driver_list); i++)
 		if (!strncmp(driver_list[i].name, info->driver,
 			     ETHTOOL_BUSINFO_LEN))
Signature · 1 line
1.4.1
#0 lore raw

PATCH 1/3 ethtool: sky2 GMAC decode

Add decoding of GMAC bits.

---
 marvell.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
marvell.c +28 -0
index 16147a9..244bb69 100644
@@ -113,6 +113,31 @@ static void dump_fifo(const char *name, 
 	dump_timer("LED", p + 0x20);
 }
 
+static void dump_gmac_fifo(const void *p)
+{
+	const u32 *r = p;
+	int i;
+	static const char *regs[] = {
+		"End Address",
+		"Almost Full Thresh",
+		"Control/Test",
+		"FIFO Flush Mask",
+		"FIFO Flush Threshold",
+		"Truncation Threshold",
+		"Upper Pause Threshold",
+		"Lower Pause Threshold",
+		"VLAN Tag",
+		"FIFO Write Pointer",
+		"FIFO Write Level",
+		"FIFO Read Pointer",
+		"FIFO Read Level",
+	};
+
+	for (i = 0; i < sizeof(regs)/sizeof(regs[0]); ++i)
+		printf("%-32s 0x%08X\n", regs[i], r[i]);
+
+}
+
 static void dump_mac(const u8 *r)
 {
 	printf("\nMAC Addresses\n");
@@ -143,6 +168,7 @@ static void dump_gma(const char *name, c
 static void dump_gmac(const char *name, const u8 *data)
 {
 	printf("\n%s\n", name);
+
 	printf("Status                       0x%04X\n", *(u16 *) data);
 	printf("Control                      0x%04X\n", *(u16 *) (data + 4));
 	printf("Transmit                     0x%04X\n", *(u16 *) (data + 8));
@@ -294,6 +320,7 @@ int sky2_dump_regs(struct ethtool_drvinf
 
 	dump_mac(regs->data);
 	dump_gmac("GMAC 1", regs->data + 0x2800);
+	dump_gmac_fifo(regs->data + 0xc40);
 
 	printf("\nStatus BMU:\n-----------\n");
 	printf("Control                                0x%08X\n",
@@ -337,6 +364,7 @@ int sky2_dump_regs(struct ethtool_drvinf
 		dump_ram("Sync Transmit RAMbuffer 2", regs->data+0xb00);
 		dump_ram("Async Transmit RAMbuffer 21", regs->data+0xb80);
 		dump_gmac("GMAC 2", regs->data + 0x3800);
+		dump_gmac_fifo(regs->data + 0xc40 + 128);
 	}
 
 	return 0;
Signature · 1 line
1.4.1
#3 lore raw

PATCH 1/1 ethtool: more sky2 decode

In reply to Stephen Hemminger

More marvell register decode. Add chip table, pci config info and other bits useful for debug.

---
 marvell.c |   80 +++++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 59 insertions(+), 21 deletions(-)
marvell.c +59 -21
index e867521..9a14dd2 100644
@@ -141,6 +141,8 @@ static void dump_gmac_fifo(const char *n
 
 static void dump_mac(const u8 *r)
 {
+	u8 id;
+
 	printf("\nMAC Addresses\n");
 	printf("---------------\n");
 	dump_addr(1, r + 0x100);
@@ -148,10 +150,30 @@ static void dump_mac(const u8 *r)
 	dump_addr(3, r + 0x110);
 	printf("\n");
 
-	printf("Connector type               0x%02X\n", r[0x118]);
-	printf("PMD type                     0x%02X\n", r[0x119]);
-	printf("Configuration                0x%02X\n", r[0x11a]);
-	printf("Chip Revision                0x%02X\n", r[0x11b]);
+	printf("Connector type               0x%02X (%c)\n", 
+	       r[0x118], (char)r[0x118]);
+	printf("PMD type                     0x%02X (%c)\n",
+	       r[0x119], (char)r[0x119]);
+	printf("PHY type                     0x%02X\n", r[0x11d]);
+
+	id = r[0x11b];
+	printf("Chip Id                      0x%02X ", id);
+	switch (id) {
+	case 0x0a:	puts("Genesis");	break;
+	case 0xb0:	puts("Yukon");	break;
+	case 0xb1:	puts("Yukon-Lite");	break;
+	case 0xb2:	puts("Yukon-LP");	break;
+	case 0xb3:	puts("Yukon-2 XL");	break;
+	case 0xb4:	puts("Yukon-2 EC Ultra");	break;
+	case 0xb6:	puts("Yukon-2 EC");	break;
+ 	case 0xb7:	puts("Yukon-2 FE");	break;
+	default:	puts("Unknown");
+	}
+
+	printf(" (rev %d)\n", r[0x11a] & 0xf);
+
+	printf("Ram Buffer                   0x%02X\n", r[0x11c]);
+	       
 }
 	
 static void dump_gma(const char *name, const u8 *r)
@@ -182,21 +204,43 @@ static void dump_gmac(const char *name, 
 	dump_gma("Physical", data + 0x28);
 }
 
+static void dump_pci(const u8 *cfg)
+{
+	int i;
+
+	printf("\nPCI config\n----------\n");
+	for(i = 0; i < 0x80; i++) {
+		if (!(i & 15))
+			printf("%02x:", i);
+		printf(" %02x", cfg[i]);
+		if ((i & 15) == 15)
+			putchar('\n');
+	}
+	putchar('\n');
+}
+
+static void dump_control(u8 *r)
+{
+	printf("Control Registers\n");
+	printf("-----------------\n");
+
+	printf("Register Access Port             0x%02X\n", *r);
+	printf("LED Control/Status               0x%08X\n", *(u32 *) (r + 4));
+
+	printf("Interrupt Source                 0x%08X\n", *(u32 *) (r + 8));
+	printf("Interrupt Mask                   0x%08X\n", *(u32 *) (r + 0xc));
+	printf("Interrupt Hardware Error Source  0x%08X\n", *(u32 *) (r + 0x10));
+	printf("Interrupt Hardware Error Mask    0x%08X\n", *(u32 *) (r + 0x14));
+}
+
 int skge_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
 {
 	const u32 *r = (const u32 *) regs->data;
 	int dual = !(regs->data[0x11a] & 1);
 
-	printf("Control Registers\n");
-	printf("-----------------\n");
+	dump_pci(regs->data + 0x380);
 
-	printf("Register Access Port             0x%08X\n", r[0]);
-	printf("LED Control/Status               0x%08X\n", r[1]);
-	printf("Interrupt Source                 0x%08X\n", r[2]);
-	printf("Interrupt Mask                   0x%08X\n", r[3]);
-	printf("Interrupt Hardware Error Source  0x%08X\n", r[4]);
-	printf("Interrupt Hardware Error Mask    0x%08X\n", r[5]);
-	printf("Special Interrupt Source         0x%08X\n", r[6]);
+	dump_control(regs->data);
 
 	printf("\nBus Management Unit\n");
 	printf("-------------------\n");
@@ -296,15 +340,9 @@ int sky2_dump_regs(struct ethtool_drvinf
 	const u32 *r = (const u32 *) regs->data;
 	int dual;
 
-	printf("Control Registers\n");
-	printf("-----------------\n");
+	dump_pci(regs->data + 0x1c00);
 
-	printf("Control/Status                   0x%08X\n", r[1]);
-	printf("Interrupt Source                 0x%08X\n", r[2]);
-	printf("Interrupt Mask                   0x%08X\n", r[3]);
-	printf("Interrupt Hardware Error Source  0x%08X\n", r[4]);
-	printf("Interrupt Hardware Error Mask    0x%08X\n", r[5]);
-	printf("Special Interrupt Source         0x%08X\n", r[6]);
+	dump_control(regs->data);
 
 	printf("\nBus Management Unit\n");
 	printf("-------------------\n");
Signature · 1 line
1.4.1
#4 lore raw

Re: [PATCH 3/3] ethtool: dump_registers post mortem

In reply to Stephen Hemminger
Quoted 9 lines · Stephen Hemminger

This patch allows:
ethtool -d eth0 raw on >saved_regs
and later
ethtool -d eth0 file saved_regs

Selfish motive is to be able to take register dumps from users and and decode later, possibly adding more output as needed.

Would you be kind enough to roll your ethtool patches into two patches:
this patch, and 'more sky2 decode' patch. I now have three sky2
decode patches, two from 10/18 and one from 10/19.

Also, please update the man page, and possibly the -h help info, to indicate this enhancement.

Jeff

#5 lore raw

PATCH 1/3 ethtool: marvell register dump

This is a consolidation of earlier marvell register decode patches to ethtool.

---
 marvell.c |  106 ++++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 77 insertions(+), 29 deletions(-)
marvell.c +77 -29
index 244bb69..b73addc 100644
@@ -88,10 +88,12 @@ static void dump_ram(const char *name, c
 	printf("End Address                      0x%08X\n", r[1]);
 	printf("Write Pointer                    0x%08X\n", r[2]);
 	printf("Read Pointer                     0x%08X\n", r[3]);
-	printf("Upper Threshold/Pause Packets    0x%08X\n", r[4]);
-	printf("Lower Threshold/Pause Packets    0x%08X\n", r[5]);
-	printf("Upper Threshold/High Priority    0x%08X\n", r[6]);
-	printf("Lower Threshold/High Priority    0x%08X\n", r[7]);
+	if (*name == 'R') {
+		printf("Upper Threshold/Pause Packets    0x%08X\n", r[4]);
+		printf("Lower Threshold/Pause Packets    0x%08X\n", r[5]);
+		printf("Upper Threshold/High Priority    0x%08X\n", r[6]);
+		printf("Lower Threshold/High Priority    0x%08X\n", r[7]);
+	}
 	printf("Packet Counter                   0x%08X\n", r[8]);
 	printf("Level                            0x%08X\n", r[9]);
 	printf("Test                             0x%08X\n", r[10]);
@@ -113,7 +115,7 @@ static void dump_fifo(const char *name, 
 	dump_timer("LED", p + 0x20);
 }
 
-static void dump_gmac_fifo(const void *p)
+static void dump_gmac_fifo(const char *name, const void *p)
 {
 	const u32 *r = p;
 	int i;
@@ -133,6 +135,7 @@ static void dump_gmac_fifo(const void *p
 		"FIFO Read Level",
 	};
 
+	printf("\n%s\n", name);
 	for (i = 0; i < sizeof(regs)/sizeof(regs[0]); ++i)
 		printf("%-32s 0x%08X\n", regs[i], r[i]);
 
@@ -140,6 +143,8 @@ static void dump_gmac_fifo(const void *p
 
 static void dump_mac(const u8 *r)
 {
+	u8 id;
+
 	printf("\nMAC Addresses\n");
 	printf("---------------\n");
 	dump_addr(1, r + 0x100);
@@ -147,10 +152,30 @@ static void dump_mac(const u8 *r)
 	dump_addr(3, r + 0x110);
 	printf("\n");
 
-	printf("Connector type               0x%02X\n", r[0x118]);
-	printf("PMD type                     0x%02X\n", r[0x119]);
-	printf("Configuration                0x%02X\n", r[0x11a]);
-	printf("Chip Revision                0x%02X\n", r[0x11b]);
+	printf("Connector type               0x%02X (%c)\n", 
+	       r[0x118], (char)r[0x118]);
+	printf("PMD type                     0x%02X (%c)\n",
+	       r[0x119], (char)r[0x119]);
+	printf("PHY type                     0x%02X\n", r[0x11d]);
+
+	id = r[0x11b];
+	printf("Chip Id                      0x%02X ", id);
+	switch (id) {
+	case 0x0a:	puts("Genesis");	break;
+	case 0xb0:	puts("Yukon");	break;
+	case 0xb1:	puts("Yukon-Lite");	break;
+	case 0xb2:	puts("Yukon-LP");	break;
+	case 0xb3:	puts("Yukon-2 XL");	break;
+	case 0xb4:	puts("Yukon-2 EC Ultra");	break;
+	case 0xb6:	puts("Yukon-2 EC");	break;
+ 	case 0xb7:	puts("Yukon-2 FE");	break;
+	default:	puts("Unknown");
+	}
+
+	printf(" (rev %d)\n", r[0x11a] & 0xf);
+
+	printf("Ram Buffer                   0x%02X\n", r[0x11c]);
+	       
 }
 	
 static void dump_gma(const char *name, const u8 *r)
@@ -181,21 +206,43 @@ static void dump_gmac(const char *name, 
 	dump_gma("Physical", data + 0x28);
 }
 
+static void dump_pci(const u8 *cfg)
+{
+	int i;
+
+	printf("\nPCI config\n----------\n");
+	for(i = 0; i < 0x80; i++) {
+		if (!(i & 15))
+			printf("%02x:", i);
+		printf(" %02x", cfg[i]);
+		if ((i & 15) == 15)
+			putchar('\n');
+	}
+	putchar('\n');
+}
+
+static void dump_control(u8 *r)
+{
+	printf("Control Registers\n");
+	printf("-----------------\n");
+
+	printf("Register Access Port             0x%02X\n", *r);
+	printf("LED Control/Status               0x%08X\n", *(u32 *) (r + 4));
+
+	printf("Interrupt Source                 0x%08X\n", *(u32 *) (r + 8));
+	printf("Interrupt Mask                   0x%08X\n", *(u32 *) (r + 0xc));
+	printf("Interrupt Hardware Error Source  0x%08X\n", *(u32 *) (r + 0x10));
+	printf("Interrupt Hardware Error Mask    0x%08X\n", *(u32 *) (r + 0x14));
+}
+
 int skge_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
 {
 	const u32 *r = (const u32 *) regs->data;
 	int dual = !(regs->data[0x11a] & 1);
 
-	printf("Control Registers\n");
-	printf("-----------------\n");
+	dump_pci(regs->data + 0x380);
 
-	printf("Register Access Port             0x%08X\n", r[0]);
-	printf("LED Control/Status               0x%08X\n", r[1]);
-	printf("Interrupt Source                 0x%08X\n", r[2]);
-	printf("Interrupt Mask                   0x%08X\n", r[3]);
-	printf("Interrupt Hardware Error Source  0x%08X\n", r[4]);
-	printf("Interrupt Hardware Error Mask    0x%08X\n", r[5]);
-	printf("Special Interrupt Source         0x%08X\n", r[6]);
+	dump_control(regs->data);
 
 	printf("\nBus Management Unit\n");
 	printf("-------------------\n");
@@ -295,15 +342,9 @@ int sky2_dump_regs(struct ethtool_drvinf
 	const u32 *r = (const u32 *) regs->data;
 	int dual;
 
-	printf("Control Registers\n");
-	printf("-----------------\n");
+	dump_pci(regs->data + 0x1c00);
 
-	printf("Control/Status                   0x%08X\n", r[1]);
-	printf("Interrupt Source                 0x%08X\n", r[2]);
-	printf("Interrupt Mask                   0x%08X\n", r[3]);
-	printf("Interrupt Hardware Error Source  0x%08X\n", r[4]);
-	printf("Interrupt Hardware Error Mask    0x%08X\n", r[5]);
-	printf("Special Interrupt Source         0x%08X\n", r[6]);
+	dump_control(regs->data);
 
 	printf("\nBus Management Unit\n");
 	printf("-------------------\n");
@@ -319,8 +360,6 @@ int sky2_dump_regs(struct ethtool_drvinf
 	}
 
 	dump_mac(regs->data);
-	dump_gmac("GMAC 1", regs->data + 0x2800);
-	dump_gmac_fifo(regs->data + 0xc40);
 
 	printf("\nStatus BMU:\n-----------\n");
 	printf("Control                                0x%08X\n",
@@ -350,6 +389,14 @@ int sky2_dump_regs(struct ethtool_drvinf
 	dump_timer("TX status", regs->data + 0xec0);
 	dump_timer("ISR", regs->data + 0xed0);
 
+	printf("\nGMAC control             0x%04X\n", *(u32 *)(regs->data + 0xf00));
+	printf("GPHY control             0x%04X\n", *(u32 *)(regs->data + 0xf04));
+	printf("LINK control             0x%02hX\n", *(u16 *)(regs->data + 0xf10));
+
+	dump_gmac("GMAC 1", regs->data + 0x2800);
+	dump_gmac_fifo("Rx GMAC 1", regs->data + 0xc40);
+	dump_gmac_fifo("Tx GMAC 1", regs->data + 0xd40);
+
 	dump_queue2("Receive Queue 1", regs->data +0x400, 1);
 	dump_queue("Sync Transmit Queue 1", regs->data +0x600, 0);
 	dump_queue2("Async Transmit Queue 1", regs->data +0x680, 0);
@@ -364,7 +411,8 @@ int sky2_dump_regs(struct ethtool_drvinf
 		dump_ram("Sync Transmit RAMbuffer 2", regs->data+0xb00);
 		dump_ram("Async Transmit RAMbuffer 21", regs->data+0xb80);
 		dump_gmac("GMAC 2", regs->data + 0x3800);
-		dump_gmac_fifo(regs->data + 0xc40 + 128);
+		dump_gmac_fifo("Rx GMAC 2", regs->data + 0xc40 + 128);
+		dump_gmac_fifo("Tx GMAC 2", regs->data + 0xd40 + 128);
 	}
 
 	return 0;
Signature · 1 line
1.4.2.3
#6 lore raw

PATCH 2/3 ethtool: flie option to register dump

Add ability to take old raw dumps from a file and decode them. It is kind of limited because you still need to have same device as the raw file, but useful for maintainers to decode raw dumps.

---
 ethtool.8 |   13 ++++++++++++-
 ethtool.c |   43 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 7 deletions(-)
ethtool.8 +12 -1
index 679f6bc..bffde30 100644
@@ -126,6 +126,8 @@ ethtool \- Display or change ethernet ca
 .B ethtool \-d|\-\-register\-dump
 .I ethX
 .B2 raw on off
+.RB [ file 
+.IR name ]
 
 .B ethtool \-e|\-\-eeprom\-dump
 .I ethX
@@ -244,7 +246,16 @@ queries the specified ethernet device fo
 .TP
 .B \-d \-\-register\-dump
 retrieves and prints a register dump for the specified ethernet device.
-When raw is enabled, then it dumps the raw register data to stdout.
+The register format for some devices is known and decoded others
+are printed in hex.
+When 
+.I raw 
+is enabled, then it dumps the raw register data to stdout.
+If
+.I file
+is specified, then use contents of previous raw register dump, rather
+than reading from the device.
+
 .TP
 .B \-e \-\-eeprom\-dump
 retrieves and prints an EEPROM dump for the specified ethernet device.
ethtool.c +37 -6

95 lines not on this page · raw message

Signature · 1 line
1.4.2.3
#10 lore raw

PATCH 3/3 ethtool: allow force hex in register dump

In reply to Stephen Hemminger

Sometimes the device decode logic just gets in the way so add a "force hex" option to register dump.

---
 ethtool.8 |    1 +
 ethtool.c |   11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)
ethtool.8 +1 -0
index bffde30..d247d51 100644
@@ -126,6 +126,7 @@ ethtool \- Display or change ethernet ca
 .B ethtool \-d|\-\-register\-dump
 .I ethX
 .B2 raw on off
+.B2 hex on off
 .RB [ file 
 .IR name ]
 
ethtool.c +7 -4
index f004d54..06e3675 100644
@@ -255,6 +255,7 @@ static int msglvl_wanted = -1;
 static int phys_id_time = 0;
 static int gregs_changed = 0;
 static int gregs_dump_raw = 0;
+static int gregs_dump_hex = 0;
 static char *gregs_dump_file = NULL;
 static int geeprom_changed = 0;
 static int geeprom_dump_raw = 0;
@@ -285,6 +286,7 @@ struct cmdline_info {
 
 static struct cmdline_info cmdline_gregs[] = {
 	{ "raw", CMDL_BOOL, &gregs_dump_raw, NULL },
+	{ "hex", CMDL_BOOL, &gregs_dump_hex, NULL },
 	{ "file", CMDL_STR, &gregs_dump_file, NULL },
 };
 
@@ -1000,10 +1002,11 @@ static int dump_regs(struct ethtool_drvi
 		fclose(f);
 	}
 
-	for (i = 0; i < ARRAY_SIZE(driver_list); i++)
-		if (!strncmp(driver_list[i].name, info->driver,
-			     ETHTOOL_BUSINFO_LEN))
-			return driver_list[i].func(info, regs);
+	if (!gregs_dump_hex)
+		for (i = 0; i < ARRAY_SIZE(driver_list); i++)
+			if (!strncmp(driver_list[i].name, info->driver,
+				     ETHTOOL_BUSINFO_LEN))
+				return driver_list[i].func(info, regs);
 
 	fprintf(stdout, "Offset\tValues\n");
 	fprintf(stdout, "--------\t-----");
Signature · 1 line
1.4.2.3
#7 lore raw

Re: [PATCH 2/3] ethtool: flie option to register dump

In reply to Stephen Hemminger

Hi Stephen,

Quoted 3 lines · Stephen Hemminger

Add ability to take old raw dumps from a file and decode them. It is kind of limited because you still need to have same device as the raw file, but useful for maintainers to decode raw dumps.

What about putting the (Permanent) MAC into the first 4-6 octets of the hexdump and decode+check+warn using this info first to avoid mixing up files?

Maybe only the first 4 octets to enhance privacy and still being able to detect known "bad" series.

This might prevent user errors when sending such files to developers.

Regards

Ingo Oeser

#8 lore raw

Re: [PATCH 2/3] ethtool: flie option to register dump

Quoted 14 lines · On Tue, 24 Oct 2006 11:50:19 +0200 Ingo Oeser <[email protected]> wrote:

Hi Stephen,

Quoted 3 lines · Stephen Hemminger

Add ability to take old raw dumps from a file and decode them. It is kind of limited because you still need to have same device as the raw file, but useful for maintainers to decode raw dumps.

What about putting the (Permanent) MAC into the first 4-6 octets of the hexdump and decode+check+warn using this info first to avoid mixing up files?

Maybe only the first 4 octets to enhance privacy and still being able to detect known "bad" series.

Quoted 6 lines

This might prevent user errors when sending such files to developers.

Regards

Ingo Oeser

The existing output format for raw is fine for piping into utilities like hexdump

Signature · 1 line
Stephen Hemminger <[email protected]>
#9 lore raw

Re: [PATCH 2/3] ethtool: flie option to register dump

In reply to Stephen Hemminger
Quoted 10 lines · Stephen Hemminger

Add ability to take old raw dumps from a file and decode them. It is kind of limited because you still need to have same device as the raw file, but useful for maintainers to decode raw dumps.

---
 ethtool.8 |   13 ++++++++++++-
 ethtool.c |   43 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 7 deletions(-)

applied 2-3