All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghuram Chary J <raghuramchary.jallipalli@microchip.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <unglinuxdriver@microchip.com>,
	<woojung.huh@microchip.com>,
	<raghuramchary.jallipalli@microchip.com>
Subject: [PATCH ethtool] ethtool: Add register dump support for MICROCHIP LAN78xx
Date: Thu, 5 Apr 2018 11:41:28 +0530	[thread overview]
Message-ID: <20180405061128.5479-1-raghuramchary.jallipalli@microchip.com> (raw)

This patch adds support for Microchip's lan78xx families
of USB Ethernet controllers to ethtool's dump registers
command.

This patch is for use with the lan78xx driver.

Signed-off-by: Raghuram Chary J <raghuramchary.jallipalli@microchip.com>
---
 Makefile.am |  2 +-
 ethtool.c   |  1 +
 internal.h  |  4 +++
 lan78xx.c   | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100644 lan78xx.c

diff --git a/Makefile.am b/Makefile.am
index edbda57..14f79b6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@ ethtool_SOURCES += \
 		  pcnet32.c realtek.c tg3.c marvell.c vioc.c	\
 		  smsc911x.c at76c50x-usb.c sfc.c stmmac.c	\
 		  sff-common.c sff-common.h sfpid.c sfpdiag.c	\
-		  ixgbevf.c tse.c vmxnet3.c qsfp.c qsfp.h fjes.c
+		  ixgbevf.c tse.c vmxnet3.c qsfp.c qsfp.h fjes.c lan78xx.c
 endif
 
 TESTS = test-cmdline test-features
diff --git a/ethtool.c b/ethtool.c
index da7421c..3494402 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1160,6 +1160,7 @@ static const struct {
 	{ "altera_tse", altera_tse_dump_regs },
 	{ "vmxnet3", vmxnet3_dump_regs },
 	{ "fjes", fjes_dump_regs },
+	{ "lan78xx", lan78xx_dump_regs },
 #endif
 };
 
diff --git a/internal.h b/internal.h
index 913f4eb..b239dc7 100644
--- a/internal.h
+++ b/internal.h
@@ -350,4 +350,8 @@ void sff8636_show_all(const __u8 *id, __u32 eeprom_len);
 
 /* FUJITSU Extended Socket network device */
 int fjes_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
+
+/* MICROCHIP LAN78XX USB ETHERNET Controller */
+int lan78xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
+
 #endif /* ETHTOOL_INTERNAL_H__ */
diff --git a/lan78xx.c b/lan78xx.c
new file mode 100644
index 0000000..bb64e80
--- /dev/null
+++ b/lan78xx.c
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <string.h>
+#include "internal.h"
+
+int lan78xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
+{
+	unsigned int *lan78xx_reg = (unsigned int *)regs->data;
+
+	fprintf(stdout, "LAN78xx Registers:\n");
+	fprintf(stdout, "------------------\n");
+	fprintf(stdout, "ID_REV       = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "INT_STS      = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "HW_CFG       = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "PMT_CTRL     = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "E2P_CMD      = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "E2P_DATA     = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "USB_STATUS   = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "VLAN_TYPE    = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "\n");
+
+	fprintf(stdout, "MAC Registers:\n");
+	fprintf(stdout, "--------------\n");
+	fprintf(stdout, "MAC_CR             = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "MAC_RX             = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "MAC_TX             = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "FLOW               = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "ERR_STS            = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "MII_ACC            = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "MII_DATA           = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "EEE_TX_LPI_REQ_DLY = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "EEE_TW_TX_SYS      = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "EEE_TX_LPI_REM_DLY = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "WUCSR              = 0x%08X\n", *lan78xx_reg++);
+	fprintf(stdout, "\n");
+
+	fprintf(stdout, "PHY Registers:\n");
+	fprintf(stdout, "--------------\n");
+	fprintf(stdout, "Mode Control = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Mode Status  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Device identifier1   = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Device identifier2   = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Auto-Neg Advertisement         = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "Auto-Neg Link Partner Ability  = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "Auto-Neg Expansion      = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Auto-Neg Next Page TX   = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Auto-Neg Link Partner Next Page RX  = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "1000BASE-T Control  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "1000BASE-T Status   = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Reserved  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Reserved  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "MMD Access Control       = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "MMD Access Address/Data  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "1000BASE-T Status Extension1  = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "1000BASE-TX Status Extension  = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "1000BASE-T Status Extension2  = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "Bypass Control  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout,
+		"100BASE-TX/1000BASE-T Rx Error Counter    = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout,
+		"100BASE-TX/1000BASE-T FC Err Counter      = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout,
+		"10BASE-T/100BASE-TX/1000BASE-T LD Counter = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "Extended 10BASE-T Control and Status      = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "Extended PHY Control1  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Extended PHY Control2  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Interrupt Mask    = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Interrupt Status  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Reserved  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Auxiliary Control and Status  = 0x%04X\n",
+		*lan78xx_reg++);
+	fprintf(stdout, "LED Mode Select  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "LED Behavior     = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "Extended Page Access  = 0x%04X\n", *lan78xx_reg++);
+	fprintf(stdout, "\n");
+
+	return 0;
+}
-- 
2.16.2

             reply	other threads:[~2018-04-05  6:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  6:11 Raghuram Chary J [this message]
2018-04-05 12:37 ` [PATCH ethtool] ethtool: Add register dump support for MICROCHIP LAN78xx Andrew Lunn
2018-04-16 17:57 ` [ethtool] " John W. Linville

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=20180405061128.5479-1-raghuramchary.jallipalli@microchip.com \
    --to=raghuramchary.jallipalli@microchip.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=unglinuxdriver@microchip.com \
    --cc=woojung.huh@microchip.com \
    /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.