From: "Émeric Vigier" <emeric.vigier@savoirfairelinux.com>
To: Steve Glendinning <steve@shawell.net>,
steve glendinning <steve.glendinning@smsc.com>
Cc: netdev@vger.kernel.org, Nancy Lin <nancy.lin@smsc.com>
Subject: [PATCH] smsc95xx: support ethtool get_regs
Date: Fri, 6 Jul 2012 14:15:31 -0400 (EDT) [thread overview]
Message-ID: <1847398984.224080.1341598531284.JavaMail.root@mail.savoirfairelinux.com> (raw)
In-Reply-To: <1291035348.223127.1341596173191.JavaMail.root@mail.savoirfairelinux.com>
From: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
Inspired by implementation in smsc911x.c and smsc9420.c
Tested on ARM/pandaboard rev A3
Signed-off-by: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
---
drivers/net/usb/smsc95xx.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index b1112e7..bce14f6 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -578,6 +578,41 @@ static int smsc95xx_ethtool_set_eeprom(struct net_device *netdev,
return smsc95xx_write_eeprom(dev, ee->offset, ee->len, data);
}
+
+static int smsc95xx_ethtool_getregslen(struct net_device *dev)
+{
+ /* all smsc95xx registers plus all phy registers */
+ return COE_CR - ID_REV + 1 + 32 * sizeof(u32);
+}
+
+static void
+smsc95xx_ethtool_getregs(struct net_device *netdev, struct ethtool_regs *regs,
+ void *buf)
+{
+ struct usbnet *dev = netdev_priv(netdev);
+ unsigned int i, j = 0, retval;
+ u32 *data = buf;
+
+ netif_dbg(dev, hw, dev->net, "ethtool_getregs\n");
+
+ retval = smsc95xx_read_reg(dev, ID_REV, ®s->version);
+ if (retval < 0) {
+ netdev_warn(dev->net, "REGS: cannot read ID_REV\n");
+ return;
+ }
+
+ for (i = 0; i <= COE_CR; i += (sizeof(u32))) {
+ retval = smsc95xx_read_reg(dev, i, &data[j++]);
+ if (retval < 0) {
+ netdev_warn(dev->net, "REGS: cannot read reg[%x]\n", i);
+ return;
+ }
+ }
+
+ for (i = 0; i <= PHY_SPECIAL; i++)
+ data[j++] = smsc95xx_mdio_read(netdev, dev->mii.phy_id, i);
+}
+
static const struct ethtool_ops smsc95xx_ethtool_ops = {
.get_link = usbnet_get_link,
.nway_reset = usbnet_nway_reset,
@@ -589,6 +624,8 @@ static const struct ethtool_ops smsc95xx_ethtool_ops = {
.get_eeprom_len = smsc95xx_ethtool_get_eeprom_len,
.get_eeprom = smsc95xx_ethtool_get_eeprom,
.set_eeprom = smsc95xx_ethtool_set_eeprom,
+ .get_regs_len = smsc95xx_ethtool_getregslen,
+ .get_regs = smsc95xx_ethtool_getregs,
};
static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
--
1.7.5.4
Emeric
next parent reply other threads:[~2012-07-06 18:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1291035348.223127.1341596173191.JavaMail.root@mail.savoirfairelinux.com>
2012-07-06 18:15 ` Émeric Vigier [this message]
2012-07-06 20:01 ` [PATCH] smsc95xx: support ethtool get_regs Francois Romieu
2012-07-06 21:26 ` Émeric Vigier
2012-07-06 22:11 ` Francois Romieu
2012-07-07 14:13 ` Émeric Vigier
2012-07-07 0:24 ` Ben Hutchings
2012-07-07 13:58 ` Émeric Vigier
2012-07-07 19:55 ` Ben Hutchings
2012-07-09 13:44 ` Émeric Vigier
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=1847398984.224080.1341598531284.JavaMail.root@mail.savoirfairelinux.com \
--to=emeric.vigier@savoirfairelinux.com \
--cc=nancy.lin@smsc.com \
--cc=netdev@vger.kernel.org \
--cc=steve.glendinning@smsc.com \
--cc=steve@shawell.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).