netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] sundance: Add initial ethtool stats support
@ 2010-10-09  9:53 Denis Kirjanov
  2010-10-09 12:17 ` [PATCH net-next] sundance: get_stats proper locking Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Denis Kirjanov @ 2010-10-09  9:53 UTC (permalink / raw)
  To: davem; +Cc: netdev

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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-10-13 19:45 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-09  9:53 [PATCH -next] sundance: Add initial ethtool stats support Denis Kirjanov
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

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).