diff options
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ixgb/ixgb_ethtool.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c index deeb25da0702..a4ed96caae69 100644 --- a/drivers/net/ixgb/ixgb_ethtool.c +++ b/drivers/net/ixgb/ixgb_ethtool.c | |||
@@ -34,16 +34,22 @@ | |||
34 | 34 | ||
35 | #define IXGB_ALL_RAR_ENTRIES 16 | 35 | #define IXGB_ALL_RAR_ENTRIES 16 |
36 | 36 | ||
37 | enum {NETDEV_STATS, IXGB_STATS}; | ||
38 | |||
37 | struct ixgb_stats { | 39 | struct ixgb_stats { |
38 | char stat_string[ETH_GSTRING_LEN]; | 40 | char stat_string[ETH_GSTRING_LEN]; |
41 | int type; | ||
39 | int sizeof_stat; | 42 | int sizeof_stat; |
40 | int stat_offset; | 43 | int stat_offset; |
41 | }; | 44 | }; |
42 | 45 | ||
43 | #define IXGB_STAT(m) FIELD_SIZEOF(struct ixgb_adapter, m), \ | 46 | #define IXGB_STAT(m) IXGB_STATS, \ |
44 | offsetof(struct ixgb_adapter, m) | 47 | FIELD_SIZEOF(struct ixgb_adapter, m), \ |
45 | #define IXGB_NETDEV_STAT(m) FIELD_SIZEOF(struct net_device, m), \ | 48 | offsetof(struct ixgb_adapter, m) |
46 | offsetof(struct net_device, m) | 49 | #define IXGB_NETDEV_STAT(m) NETDEV_STATS, \ |
50 | FIELD_SIZEOF(struct net_device, m), \ | ||
51 | offsetof(struct net_device, m) | ||
52 | |||
47 | static struct ixgb_stats ixgb_gstrings_stats[] = { | 53 | static struct ixgb_stats ixgb_gstrings_stats[] = { |
48 | {"rx_packets", IXGB_NETDEV_STAT(stats.rx_packets)}, | 54 | {"rx_packets", IXGB_NETDEV_STAT(stats.rx_packets)}, |
49 | {"tx_packets", IXGB_NETDEV_STAT(stats.tx_packets)}, | 55 | {"tx_packets", IXGB_NETDEV_STAT(stats.tx_packets)}, |
@@ -664,10 +670,21 @@ ixgb_get_ethtool_stats(struct net_device *netdev, | |||
664 | { | 670 | { |
665 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 671 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
666 | int i; | 672 | int i; |
673 | char *p = NULL; | ||
667 | 674 | ||
668 | ixgb_update_stats(adapter); | 675 | ixgb_update_stats(adapter); |
669 | for (i = 0; i < IXGB_STATS_LEN; i++) { | 676 | for (i = 0; i < IXGB_STATS_LEN; i++) { |
670 | char *p = (char *)adapter+ixgb_gstrings_stats[i].stat_offset; | 677 | switch (ixgb_gstrings_stats[i].type) { |
678 | case NETDEV_STATS: | ||
679 | p = (char *) netdev + | ||
680 | ixgb_gstrings_stats[i].stat_offset; | ||
681 | break; | ||
682 | case IXGB_STATS: | ||
683 | p = (char *) adapter + | ||
684 | ixgb_gstrings_stats[i].stat_offset; | ||
685 | break; | ||
686 | } | ||
687 | |||
671 | data[i] = (ixgb_gstrings_stats[i].sizeof_stat == | 688 | data[i] = (ixgb_gstrings_stats[i].sizeof_stat == |
672 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; | 689 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
673 | } | 690 | } |