Format output of "ethtool -d" for tg3 devices to make it more
readable. Each register is displayed as a 32-bit value and the
undefined regions in the register space are skipped.

Signed-off-by: Michael Chan <[EMAIL PROTECTED]>


diff -rup ethtool-3.a/ethtool.c ethtool-3.b/ethtool.c
--- ethtool-3.a/ethtool.c       2005-11-08 11:58:21.000000000 -0800
+++ ethtool-3.b/ethtool.c       2005-11-08 12:03:08.000000000 -0800
@@ -936,6 +936,7 @@ static struct {
        { "pcnet32", pcnet32_dump_regs },
        { "fec_8xx", fec_8xx_dump_regs },
        { "ibm_emac", ibm_emac_dump_regs },
+       { "tg3", tg3_dump_regs },
 };
 
 static int dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
diff -rup ethtool-3.a/ethtool-util.h ethtool-3.b/ethtool-util.h
--- ethtool-3.a/ethtool-util.h  2005-11-08 11:58:31.000000000 -0800
+++ ethtool-3.b/ethtool-util.h  2005-11-08 12:00:32.000000000 -0800
@@ -42,4 +42,7 @@ int fec_8xx_dump_regs(struct ethtool_drv
 /* PowerPC 4xx on-chip Ethernet controller */
 int ibm_emac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs 
*regs);
 
+/* Broadcom Tigon3 Ethernet controller */
+int tg3_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
+
 #endif
diff -rup ethtool-3.a/tg3.c ethtool-3.b/tg3.c
--- ethtool-3.a/tg3.c   2005-11-08 11:58:40.000000000 -0800
+++ ethtool-3.b/tg3.c   2005-11-08 12:06:11.000000000 -0800
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <string.h>
 #include "ethtool-util.h"
 
 #define TG3_MAGIC 0x669955aa
@@ -21,3 +22,37 @@ tg3_dump_eeprom(struct ethtool_drvinfo *
 
        return 0;
 }
+
+int
+tg3_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
+{
+       int i, j;
+       int reg_boundaries[] = { 0x015c, 0x0200, 0x0400, 0x0400, 0x08f0, 0x0c00,
+                                0x0ce0, 0x1000, 0x1004, 0x1400, 0x1480, 0x1800,
+                                0x1848, 0x1c00, 0x1c04, 0x2000, 0x225c, 0x2400,
+                                0x24c4, 0x2800, 0x2804, 0x2c00, 0x2c20, 0x3000,
+                                0x3014, 0x3400, 0x3408, 0x3800, 0x3808, 0x3c00,
+                                0x3d00, 0x4000, 0x4010, 0x4400, 0x4458, 0x4800,
+                                0x4808, 0x4c00, 0x4c08, 0x5000, 0x5280, 0x5400,
+                                0x5680, 0x5800, 0x5a10, 0x5c00, 0x5d20, 0x6000,
+                                0x600c, 0x6800, 0x6848, 0x7000, 0x7034, 0x7c00,
+                                0x7e40, 0x8000 };
+
+       fprintf(stdout, "Offset\tValue\n");
+       fprintf(stdout, "------\t----------\n");
+       for (i = 0, j = 0; i < regs->len; ) {
+               u32 reg;
+
+               memcpy(&reg, &regs->data[i], 4);
+               fprintf(stdout, "0x%04x\t0x%08x\n", i, reg);
+
+               i += 4;
+               if (i == reg_boundaries[j]) {
+                       i = reg_boundaries[j + 1];
+                       j += 2;
+                       fprintf(stdout, "\n");
+               }
+       }
+       fprintf(stdout, "\n");
+       return 0;
+}


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to