Subject: [PATCH 1/7] ethtool: dsa: add pretty dump

From: Vivien Didelot <[email-masked]>
Date: Fri, 14 Dec 2018 21:50:29 -0500

This patch adds the preliminary bits for pretty dumping the registers
of the "dsa" kernel drivers.

Following patches will add support for the "mv88e6xxx" DSA driver.

Signed-off-by: Vivien Didelot <[email-masked]>
---
 Makefile.am |  2 +-
 dsa.c       | 12 ++++++++++++
 ethtool.c   |  1 +
 internal.h  |  3 +++
 4 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 dsa.c

diff --git a/Makefile.am b/Makefile.am
index 14f79b6..468eed1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,7 +9,7 @@ ethtool_SOURCES = ethtool.c ethtool-copy.h internal.h net_tstamp-copy.h \
 		  rxclass.c
 if ETHTOOL_ENABLE_PRETTY_DUMP
 ethtool_SOURCES += \
-		  amd8111e.c de2104x.c e100.c e1000.c et131x.c igb.c	\
+		  amd8111e.c de2104x.c dsa.c e100.c e1000.c et131x.c igb.c	\
 		  fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c	\
 		  pcnet32.c realtek.c tg3.c marvell.c vioc.c	\
 		  smsc911x.c at76c50x-usb.c sfc.c stmmac.c	\
diff --git a/dsa.c b/dsa.c
new file mode 100644
index 0000000..83396b5
--- /dev/null
+++ b/dsa.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "internal.h"
+
+int dsa_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
+{
+	/* DSA per-driver register dump */
+
+	/* Fallback to hexdump */
+	return 1;
+}
diff --git a/ethtool.c b/ethtool.c
index 2f7e96b..f1f1ec2 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1166,6 +1166,7 @@ static const struct {
 	{ "vmxnet3", vmxnet3_dump_regs },
 	{ "fjes", fjes_dump_regs },
 	{ "lan78xx", lan78xx_dump_regs },
+	{ "dsa", dsa_dump_regs },
 #endif
 };
 
diff --git a/internal.h b/internal.h
index b239dc7..84b0f9c 100644
--- a/internal.h
+++ b/internal.h
@@ -354,4 +354,7 @@ 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);
 
+/* Distributed Switch Architecture */
+int dsa_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
+
 #endif /* ETHTOOL_INTERNAL_H__ */
-- 
2.19.2