diff options
author | Sathya Perla <sathya.perla@emulex.com> | 2011-07-25 15:10:14 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-01 03:11:59 -0400 |
commit | ac124ff973e2780279774a30dd924affef758a51 (patch) | |
tree | 1df7efa8c135ee686860c3c296e30fbd2ce652e2 /drivers/net/benet/be_ethtool.c | |
parent | 1b4c8af8d2e9bfb474f233b010988ec008ae2ffa (diff) |
be2net: cleanup and refactor stats code
In preparation for 64-bit stats interface, the following cleanups help
streamline the code:
1) made some more rx/tx stats stored by driver 64 bit
2) made some HW stas (err/drop counters) stored in be_drv_stats 32 bit to
keep the code simple as BE provides 32-bit counters only.
3) removed duplication of netdev stats in ethtool
4) removed some un-necessary stats and fixed some names
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet/be_ethtool.c')
-rw-r--r-- | drivers/net/benet/be_ethtool.c | 65 |
1 files changed, 15 insertions, 50 deletions
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index 7fd8130d86ea..0300b9ddda06 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c | |||
@@ -26,33 +26,18 @@ struct be_ethtool_stat { | |||
26 | int offset; | 26 | int offset; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | enum {NETSTAT, DRVSTAT_TX, DRVSTAT_RX, ERXSTAT, | 29 | enum {DRVSTAT_TX, DRVSTAT_RX, DRVSTAT}; |
30 | DRVSTAT}; | ||
31 | #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ | 30 | #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ |
32 | offsetof(_struct, field) | 31 | offsetof(_struct, field) |
33 | #define NETSTAT_INFO(field) #field, NETSTAT,\ | ||
34 | FIELDINFO(struct net_device_stats,\ | ||
35 | field) | ||
36 | #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\ | 32 | #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\ |
37 | FIELDINFO(struct be_tx_stats, field) | 33 | FIELDINFO(struct be_tx_stats, field) |
38 | #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\ | 34 | #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\ |
39 | FIELDINFO(struct be_rx_stats, field) | 35 | FIELDINFO(struct be_rx_stats, field) |
40 | #define ERXSTAT_INFO(field) #field, ERXSTAT,\ | ||
41 | FIELDINFO(struct be_erx_stats_v1, field) | ||
42 | #define DRVSTAT_INFO(field) #field, DRVSTAT,\ | 36 | #define DRVSTAT_INFO(field) #field, DRVSTAT,\ |
43 | FIELDINFO(struct be_drv_stats, \ | 37 | FIELDINFO(struct be_drv_stats, field) |
44 | field) | ||
45 | 38 | ||
46 | static const struct be_ethtool_stat et_stats[] = { | 39 | static const struct be_ethtool_stat et_stats[] = { |
47 | {NETSTAT_INFO(rx_packets)}, | 40 | {DRVSTAT_INFO(tx_events)}, |
48 | {NETSTAT_INFO(tx_packets)}, | ||
49 | {NETSTAT_INFO(rx_bytes)}, | ||
50 | {NETSTAT_INFO(tx_bytes)}, | ||
51 | {NETSTAT_INFO(rx_errors)}, | ||
52 | {NETSTAT_INFO(tx_errors)}, | ||
53 | {NETSTAT_INFO(rx_dropped)}, | ||
54 | {NETSTAT_INFO(tx_dropped)}, | ||
55 | {DRVSTAT_INFO(be_tx_events)}, | ||
56 | {DRVSTAT_INFO(rx_crc_errors)}, | 41 | {DRVSTAT_INFO(rx_crc_errors)}, |
57 | {DRVSTAT_INFO(rx_alignment_symbol_errors)}, | 42 | {DRVSTAT_INFO(rx_alignment_symbol_errors)}, |
58 | {DRVSTAT_INFO(rx_pause_frames)}, | 43 | {DRVSTAT_INFO(rx_pause_frames)}, |
@@ -71,9 +56,6 @@ static const struct be_ethtool_stat et_stats[] = { | |||
71 | {DRVSTAT_INFO(rx_ip_checksum_errs)}, | 56 | {DRVSTAT_INFO(rx_ip_checksum_errs)}, |
72 | {DRVSTAT_INFO(rx_tcp_checksum_errs)}, | 57 | {DRVSTAT_INFO(rx_tcp_checksum_errs)}, |
73 | {DRVSTAT_INFO(rx_udp_checksum_errs)}, | 58 | {DRVSTAT_INFO(rx_udp_checksum_errs)}, |
74 | {DRVSTAT_INFO(rx_switched_unicast_packets)}, | ||
75 | {DRVSTAT_INFO(rx_switched_multicast_packets)}, | ||
76 | {DRVSTAT_INFO(rx_switched_broadcast_packets)}, | ||
77 | {DRVSTAT_INFO(tx_pauseframes)}, | 59 | {DRVSTAT_INFO(tx_pauseframes)}, |
78 | {DRVSTAT_INFO(tx_controlframes)}, | 60 | {DRVSTAT_INFO(tx_controlframes)}, |
79 | {DRVSTAT_INFO(rx_priority_pause_frames)}, | 61 | {DRVSTAT_INFO(rx_priority_pause_frames)}, |
@@ -96,24 +78,24 @@ static const struct be_ethtool_stat et_stats[] = { | |||
96 | static const struct be_ethtool_stat et_rx_stats[] = { | 78 | static const struct be_ethtool_stat et_rx_stats[] = { |
97 | {DRVSTAT_RX_INFO(rx_bytes)}, | 79 | {DRVSTAT_RX_INFO(rx_bytes)}, |
98 | {DRVSTAT_RX_INFO(rx_pkts)}, | 80 | {DRVSTAT_RX_INFO(rx_pkts)}, |
99 | {DRVSTAT_RX_INFO(rx_rate)}, | ||
100 | {DRVSTAT_RX_INFO(rx_polls)}, | 81 | {DRVSTAT_RX_INFO(rx_polls)}, |
101 | {DRVSTAT_RX_INFO(rx_events)}, | 82 | {DRVSTAT_RX_INFO(rx_events)}, |
102 | {DRVSTAT_RX_INFO(rx_compl)}, | 83 | {DRVSTAT_RX_INFO(rx_compl)}, |
103 | {DRVSTAT_RX_INFO(rx_mcast_pkts)}, | 84 | {DRVSTAT_RX_INFO(rx_mcast_pkts)}, |
104 | {DRVSTAT_RX_INFO(rx_post_fail)}, | 85 | {DRVSTAT_RX_INFO(rx_post_fail)}, |
105 | {DRVSTAT_RX_INFO(rx_dropped)}, | 86 | {DRVSTAT_RX_INFO(rx_drops_no_skbs)}, |
106 | {ERXSTAT_INFO(rx_drops_no_fragments)} | 87 | {DRVSTAT_RX_INFO(rx_drops_no_frags)} |
107 | }; | 88 | }; |
108 | #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) | 89 | #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) |
109 | 90 | ||
110 | /* Stats related to multi TX queues */ | 91 | /* Stats related to multi TX queues */ |
111 | static const struct be_ethtool_stat et_tx_stats[] = { | 92 | static const struct be_ethtool_stat et_tx_stats[] = { |
112 | {DRVSTAT_TX_INFO(be_tx_rate)}, | 93 | {DRVSTAT_TX_INFO(tx_bytes)}, |
113 | {DRVSTAT_TX_INFO(be_tx_reqs)}, | 94 | {DRVSTAT_TX_INFO(tx_pkts)}, |
114 | {DRVSTAT_TX_INFO(be_tx_wrbs)}, | 95 | {DRVSTAT_TX_INFO(tx_reqs)}, |
115 | {DRVSTAT_TX_INFO(be_tx_stops)}, | 96 | {DRVSTAT_TX_INFO(tx_wrbs)}, |
116 | {DRVSTAT_TX_INFO(be_tx_compl)} | 97 | {DRVSTAT_TX_INFO(tx_compl)}, |
98 | {DRVSTAT_TX_INFO(tx_stops)} | ||
117 | }; | 99 | }; |
118 | #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats)) | 100 | #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats)) |
119 | 101 | ||
@@ -260,20 +242,11 @@ be_get_ethtool_stats(struct net_device *netdev, | |||
260 | struct be_adapter *adapter = netdev_priv(netdev); | 242 | struct be_adapter *adapter = netdev_priv(netdev); |
261 | struct be_rx_obj *rxo; | 243 | struct be_rx_obj *rxo; |
262 | struct be_tx_obj *txo; | 244 | struct be_tx_obj *txo; |
263 | void *p = NULL; | 245 | void *p; |
264 | int i, j, base; | 246 | int i, j, base; |
265 | 247 | ||
266 | for (i = 0; i < ETHTOOL_STATS_NUM; i++) { | 248 | for (i = 0; i < ETHTOOL_STATS_NUM; i++) { |
267 | switch (et_stats[i].type) { | 249 | p = (u8 *)&adapter->drv_stats + et_stats[i].offset; |
268 | case NETSTAT: | ||
269 | p = &netdev->stats; | ||
270 | break; | ||
271 | case DRVSTAT: | ||
272 | p = &adapter->drv_stats; | ||
273 | break; | ||
274 | } | ||
275 | |||
276 | p = (u8 *)p + et_stats[i].offset; | ||
277 | data[i] = (et_stats[i].size == sizeof(u64)) ? | 250 | data[i] = (et_stats[i].size == sizeof(u64)) ? |
278 | *(u64 *)p: *(u32 *)p; | 251 | *(u64 *)p: *(u32 *)p; |
279 | } | 252 | } |
@@ -281,15 +254,7 @@ be_get_ethtool_stats(struct net_device *netdev, | |||
281 | base = ETHTOOL_STATS_NUM; | 254 | base = ETHTOOL_STATS_NUM; |
282 | for_all_rx_queues(adapter, rxo, j) { | 255 | for_all_rx_queues(adapter, rxo, j) { |
283 | for (i = 0; i < ETHTOOL_RXSTATS_NUM; i++) { | 256 | for (i = 0; i < ETHTOOL_RXSTATS_NUM; i++) { |
284 | switch (et_rx_stats[i].type) { | 257 | p = (u8 *)rx_stats(rxo) + et_rx_stats[i].offset; |
285 | case DRVSTAT_RX: | ||
286 | p = (u8 *)&rxo->stats + et_rx_stats[i].offset; | ||
287 | break; | ||
288 | case ERXSTAT: | ||
289 | p = (u32 *)be_erx_stats_from_cmd(adapter) + | ||
290 | rxo->q.id; | ||
291 | break; | ||
292 | } | ||
293 | data[base + j * ETHTOOL_RXSTATS_NUM + i] = | 258 | data[base + j * ETHTOOL_RXSTATS_NUM + i] = |
294 | (et_rx_stats[i].size == sizeof(u64)) ? | 259 | (et_rx_stats[i].size == sizeof(u64)) ? |
295 | *(u64 *)p: *(u32 *)p; | 260 | *(u64 *)p: *(u32 *)p; |
@@ -299,7 +264,7 @@ be_get_ethtool_stats(struct net_device *netdev, | |||
299 | base = ETHTOOL_STATS_NUM + adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM; | 264 | base = ETHTOOL_STATS_NUM + adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM; |
300 | for_all_tx_queues(adapter, txo, j) { | 265 | for_all_tx_queues(adapter, txo, j) { |
301 | for (i = 0; i < ETHTOOL_TXSTATS_NUM; i++) { | 266 | for (i = 0; i < ETHTOOL_TXSTATS_NUM; i++) { |
302 | p = (u8 *)&txo->stats + et_tx_stats[i].offset; | 267 | p = (u8 *)tx_stats(txo) + et_tx_stats[i].offset; |
303 | data[base + j * ETHTOOL_TXSTATS_NUM + i] = | 268 | data[base + j * ETHTOOL_TXSTATS_NUM + i] = |
304 | (et_tx_stats[i].size == sizeof(u64)) ? | 269 | (et_tx_stats[i].size == sizeof(u64)) ? |
305 | *(u64 *)p: *(u32 *)p; | 270 | *(u64 *)p: *(u32 *)p; |