aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/spider_net_ethtool.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/spider_net_ethtool.c')
-rw-r--r--drivers/net/spider_net_ethtool.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/net/spider_net_ethtool.c b/drivers/net/spider_net_ethtool.c
index b0e65d0e0645..589e43658dee 100644
--- a/drivers/net/spider_net_ethtool.c
+++ b/drivers/net/spider_net_ethtool.c
@@ -27,6 +27,27 @@
27 27
28#include "spider_net.h" 28#include "spider_net.h"
29 29
30
31#define SPIDER_NET_NUM_STATS 13
32
33static struct {
34 const char str[ETH_GSTRING_LEN];
35} ethtool_stats_keys[] = {
36 { "tx_packets" },
37 { "tx_bytes" },
38 { "rx_packets" },
39 { "rx_bytes" },
40 { "tx_errors" },
41 { "tx_dropped" },
42 { "rx_dropped" },
43 { "rx_descriptor_error" },
44 { "tx_timeouts" },
45 { "alloc_rx_skb_error" },
46 { "rx_iommu_map_error" },
47 { "tx_iommu_map_error" },
48 { "rx_desc_unk_state" },
49};
50
30static int 51static int
31spider_net_ethtool_get_settings(struct net_device *netdev, 52spider_net_ethtool_get_settings(struct net_device *netdev,
32 struct ethtool_cmd *cmd) 53 struct ethtool_cmd *cmd)
@@ -142,6 +163,37 @@ spider_net_ethtool_get_ringparam(struct net_device *netdev,
142 ering->rx_pending = card->rx_desc; 163 ering->rx_pending = card->rx_desc;
143} 164}
144 165
166static int spider_net_get_stats_count(struct net_device *netdev)
167{
168 return SPIDER_NET_NUM_STATS;
169}
170
171static void spider_net_get_ethtool_stats(struct net_device *netdev,
172 struct ethtool_stats *stats, u64 *data)
173{
174 struct spider_net_card *card = netdev->priv;
175
176 data[0] = card->netdev_stats.tx_packets;
177 data[1] = card->netdev_stats.tx_bytes;
178 data[2] = card->netdev_stats.rx_packets;
179 data[3] = card->netdev_stats.rx_bytes;
180 data[4] = card->netdev_stats.tx_errors;
181 data[5] = card->netdev_stats.tx_dropped;
182 data[6] = card->netdev_stats.rx_dropped;
183 data[7] = card->spider_stats.rx_desc_error;
184 data[8] = card->spider_stats.tx_timeouts;
185 data[9] = card->spider_stats.alloc_rx_skb_error;
186 data[10] = card->spider_stats.rx_iommu_map_error;
187 data[11] = card->spider_stats.tx_iommu_map_error;
188 data[12] = card->spider_stats.rx_desc_unk_state;
189}
190
191static void spider_net_get_strings(struct net_device *netdev, u32 stringset,
192 u8 *data)
193{
194 memcpy(data, ethtool_stats_keys, sizeof(ethtool_stats_keys));
195}
196
145const struct ethtool_ops spider_net_ethtool_ops = { 197const struct ethtool_ops spider_net_ethtool_ops = {
146 .get_settings = spider_net_ethtool_get_settings, 198 .get_settings = spider_net_ethtool_get_settings,
147 .get_drvinfo = spider_net_ethtool_get_drvinfo, 199 .get_drvinfo = spider_net_ethtool_get_drvinfo,
@@ -154,5 +206,8 @@ const struct ethtool_ops spider_net_ethtool_ops = {
154 .get_tx_csum = spider_net_ethtool_get_tx_csum, 206 .get_tx_csum = spider_net_ethtool_get_tx_csum,
155 .set_tx_csum = spider_net_ethtool_set_tx_csum, 207 .set_tx_csum = spider_net_ethtool_set_tx_csum,
156 .get_ringparam = spider_net_ethtool_get_ringparam, 208 .get_ringparam = spider_net_ethtool_get_ringparam,
209 .get_strings = spider_net_get_strings,
210 .get_stats_count = spider_net_get_stats_count,
211 .get_ethtool_stats = spider_net_get_ethtool_stats,
157}; 212};
158 213