From: Guenter Roeck <linux@roeck-us.net>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH v2 12/15] net: dsa: Add support for reading switch registers with ethtool
Date: Sun, 26 Oct 2014 09:52:42 -0700 [thread overview]
Message-ID: <1414342365-27191-13-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1414342365-27191-1-git-send-email-linux@roeck-us.net>
Add support for reading switch registers with 'ethtool -d'.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2:
- Do not compare new function pointers against NULL
- Check if get_regs is set before calling it
include/net/dsa.h | 7 +++++++
net/dsa/slave.c | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 37856a2..ed3c34b 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -268,6 +268,13 @@ struct dsa_switch_driver {
struct ethtool_eeprom *eeprom, u8 *data);
int (*set_eeprom)(struct dsa_switch *ds,
struct ethtool_eeprom *eeprom, u8 *data);
+
+ /*
+ * Register access.
+ */
+ int (*get_regs_len)(struct dsa_switch *ds, int port);
+ void (*get_regs)(struct dsa_switch *ds, int port,
+ struct ethtool_regs *regs, void *p);
};
void register_switch_driver(struct dsa_switch_driver *type);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index ff2fbe7..474f296 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -249,6 +249,27 @@ static void dsa_slave_get_drvinfo(struct net_device *dev,
strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));
}
+static int dsa_slave_get_regs_len(struct net_device *dev)
+{
+ struct dsa_slave_priv *p = netdev_priv(dev);
+ struct dsa_switch *ds = p->parent;
+
+ if (ds->drv->get_regs_len)
+ return ds->drv->get_regs_len(ds, p->port);
+
+ return -EOPNOTSUPP;
+}
+
+static void
+dsa_slave_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *_p)
+{
+ struct dsa_slave_priv *p = netdev_priv(dev);
+ struct dsa_switch *ds = p->parent;
+
+ if (ds->drv->get_regs)
+ ds->drv->get_regs(ds, p->port, regs, _p);
+}
+
static int dsa_slave_nway_reset(struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);
@@ -423,6 +444,8 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
.get_settings = dsa_slave_get_settings,
.set_settings = dsa_slave_set_settings,
.get_drvinfo = dsa_slave_get_drvinfo,
+ .get_regs_len = dsa_slave_get_regs_len,
+ .get_regs = dsa_slave_get_regs,
.nway_reset = dsa_slave_nway_reset,
.get_link = dsa_slave_get_link,
.get_eeprom_len = dsa_slave_get_eeprom_len,
--
1.9.1
next prev parent reply other threads:[~2014-10-26 16:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-26 16:52 [PATCH v2 00/15] net: dsa: Fixes and enhancements Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 01/15] net: dsa: Don't set skb->protocol on outgoing tagged packets Guenter Roeck
2014-10-28 19:19 ` Florian Fainelli
2014-10-28 19:23 ` Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 02/15] net: dsa: Report known silicon revisions for Marvell 88E6060 Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 03/15] net: dsa: Report known silicon revisions for Marvell 88E6131 Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 04/15] net: dsa: Add support for Marvell 88E6352 Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 05/15] net: dsa/mv88e6352: Add support for MV88E6176 Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 06/15] net: dsa: Add support for reporting switch chip temperatures Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 07/15] net: dsa/mv88e6352: Report chip temperature Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 08/15] net: dsa/mv88e6123_61_65: " Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 09/15] net: dsa: Add support for switch EEPROM access Guenter Roeck
2014-10-27 2:41 ` Andrew Lunn
2014-10-27 3:56 ` Guenter Roeck
2014-10-27 8:50 ` Richard Cochran
2014-10-27 13:22 ` Guenter Roeck
2014-10-27 13:59 ` Andrew Lunn
2014-10-27 15:42 ` Guenter Roeck
2014-10-28 13:31 ` Guenter Roeck
2014-10-28 16:49 ` [PATCH v3 " Guenter Roeck
2014-10-28 18:19 ` David Miller
2014-10-28 19:21 ` Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 10/15] dsa: Add new optional devicetree property to describe EEPROM size Guenter Roeck
2014-10-28 16:50 ` [PATCH v3 " Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 11/15] net: dsa/mv88e6352: Implement EEPROM access functions Guenter Roeck
2014-10-26 16:52 ` Guenter Roeck [this message]
2014-10-26 16:52 ` [PATCH v2 13/15] net: dsa/mv88e6123_61_65: Add support for reading switch registers Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 14/15] net: dsa/mv88e6352: " Guenter Roeck
2014-10-26 16:52 ` [PATCH v2 15/15] net: dsa: Provide additional RMON statistics Guenter Roeck
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=1414342365-27191-13-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).