diff options
-rw-r--r-- | drivers/net/igb/igb_ethtool.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index d46c3212757b..a6da32f25a83 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -37,16 +37,22 @@ | |||
37 | 37 | ||
38 | #include "igb.h" | 38 | #include "igb.h" |
39 | 39 | ||
40 | enum {NETDEV_STATS, IGB_STATS}; | ||
41 | |||
40 | struct igb_stats { | 42 | struct igb_stats { |
41 | char stat_string[ETH_GSTRING_LEN]; | 43 | char stat_string[ETH_GSTRING_LEN]; |
44 | int type; | ||
42 | int sizeof_stat; | 45 | int sizeof_stat; |
43 | int stat_offset; | 46 | int stat_offset; |
44 | }; | 47 | }; |
45 | 48 | ||
46 | #define IGB_STAT(m) FIELD_SIZEOF(struct igb_adapter, m), \ | 49 | #define IGB_STAT(m) IGB_STATS, \ |
47 | offsetof(struct igb_adapter, m) | 50 | FIELD_SIZEOF(struct igb_adapter, m), \ |
48 | #define IGB_NETDEV_STAT(m) FIELD_SIZEOF(struct net_device, m), \ | 51 | offsetof(struct igb_adapter, m) |
49 | offsetof(struct net_device, m) | 52 | #define IGB_NETDEV_STAT(m) NETDEV_STATS, \ |
53 | FIELD_SIZEOF(struct net_device, m), \ | ||
54 | offsetof(struct net_device, m) | ||
55 | |||
50 | static const struct igb_stats igb_gstrings_stats[] = { | 56 | static const struct igb_stats igb_gstrings_stats[] = { |
51 | { "rx_packets", IGB_STAT(stats.gprc) }, | 57 | { "rx_packets", IGB_STAT(stats.gprc) }, |
52 | { "tx_packets", IGB_STAT(stats.gptc) }, | 58 | { "tx_packets", IGB_STAT(stats.gptc) }, |
@@ -1959,10 +1965,21 @@ static void igb_get_ethtool_stats(struct net_device *netdev, | |||
1959 | int stat_count_rx = sizeof(struct igb_rx_queue_stats) / sizeof(u64); | 1965 | int stat_count_rx = sizeof(struct igb_rx_queue_stats) / sizeof(u64); |
1960 | int j; | 1966 | int j; |
1961 | int i; | 1967 | int i; |
1968 | char *p = NULL; | ||
1962 | 1969 | ||
1963 | igb_update_stats(adapter); | 1970 | igb_update_stats(adapter); |
1964 | for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) { | 1971 | for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) { |
1965 | char *p = (char *)adapter+igb_gstrings_stats[i].stat_offset; | 1972 | switch (igb_gstrings_stats[i].type) { |
1973 | case NETDEV_STATS: | ||
1974 | p = (char *) netdev + | ||
1975 | igb_gstrings_stats[i].stat_offset; | ||
1976 | break; | ||
1977 | case IGB_STATS: | ||
1978 | p = (char *) adapter + | ||
1979 | igb_gstrings_stats[i].stat_offset; | ||
1980 | break; | ||
1981 | } | ||
1982 | |||
1966 | data[i] = (igb_gstrings_stats[i].sizeof_stat == | 1983 | data[i] = (igb_gstrings_stats[i].sizeof_stat == |
1967 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; | 1984 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
1968 | } | 1985 | } |