From: Denis Kirjanov <dkirjanov@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH -next] sundance: Add initial ethtool stats support
Date: Sat, 9 Oct 2010 09:53:46 +0000 [thread overview]
Message-ID: <20101009095346.GA12951@hera.kernel.org> (raw)
Add initial ethtool statistics support
Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>
---
drivers/net/sundance.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 27d69aa..685845b 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -1564,6 +1564,18 @@ static int __set_mac_addr(struct net_device *dev)
return 0;
}
+static const struct {
+ const char name[ETH_GSTRING_LEN];
+} sundance_stats[] = {
+ { "tx_packets" },
+ { "tx_bytes" },
+ { "rx_packets" },
+ { "rx_bytes" },
+ { "tx_errors" },
+ { "tx_dropped" },
+ { "rx_errors" },
+};
+
static int check_if_running(struct net_device *dev)
{
if (!netif_running(dev))
@@ -1622,6 +1634,37 @@ static void set_msglevel(struct net_device *dev, u32 val)
np->msg_enable = val;
}
+static void get_strings(struct net_device *dev, u32 stringset,
+ u8 *data)
+{
+ memcpy(data, sundance_stats, sizeof(sundance_stats));
+}
+
+static int get_sset_count(struct net_device *dev, int sset)
+{
+ switch (sset) {
+ case ETH_SS_STATS:
+ return ARRAY_SIZE(sundance_stats);
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static void get_ethtool_stats(struct net_device *dev,
+ struct ethtool_stats *stats, u64 *data)
+{
+ struct net_device_stats *netdev_stats = get_stats(dev);
+ int i = 0;
+
+ data[i++] = netdev_stats->tx_packets;
+ data[i++] = netdev_stats->tx_bytes;
+ data[i++] = netdev_stats->rx_packets;
+ data[i++] = netdev_stats->rx_bytes;
+ data[i++] = netdev_stats->tx_errors;
+ data[i++] = netdev_stats->tx_dropped;
+ data[i++] = netdev_stats->rx_errors;
+}
+
static const struct ethtool_ops ethtool_ops = {
.begin = check_if_running,
.get_drvinfo = get_drvinfo,
@@ -1631,6 +1674,9 @@ static const struct ethtool_ops ethtool_ops = {
.get_link = get_link,
.get_msglevel = get_msglevel,
.set_msglevel = set_msglevel,
+ .get_strings = get_strings,
+ .get_sset_count = get_sset_count,
+ .get_ethtool_stats = get_ethtool_stats,
};
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
--
1.7.0
next reply other threads:[~2010-10-09 9:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-09 9:53 Denis Kirjanov [this message]
2010-10-09 12:17 ` [PATCH net-next] sundance: get_stats proper locking Eric Dumazet
2010-10-09 16:24 ` David Miller
2010-10-09 12:33 ` [PATCH -next] sundance: Add initial ethtool stats support Eric Dumazet
2010-10-09 13:27 ` Ben Hutchings
2010-10-09 14:40 ` Denis Kirjanov
2010-10-09 19:41 ` Denis Kirjanov
2010-10-09 21:48 ` Jeff Garzik
2010-10-12 18:51 ` David Miller
2010-10-12 20:36 ` Denis Kirjanov
2010-10-12 20:57 ` Joe Perches
2010-10-13 6:06 ` Denis Kirjanov
2010-10-13 6:33 ` Eric Dumazet
2010-10-13 7:02 ` Denis Kirjanov
2010-10-13 10:28 ` Denis Kirjanov
2010-10-13 10:36 ` Eric Dumazet
2010-10-13 10:56 ` Denis Kirjanov
2010-10-13 19:44 ` Eric Dumazet
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=20101009095346.GA12951@hera.kernel.org \
--to=dkirjanov@kernel.org \
--cc=davem@davemloft.net \
--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 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.