aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2008-06-01 05:40:29 -0400
committerLennert Buytenhek <buytenh@wantstofly.org>2008-06-12 02:40:33 -0400
commit16820054773027a9be2e2b5e33eb2015d32deeaf (patch)
tree7313ee5d54b1db5b33f57e9b50746f7d3481080b
parent03ae1aac4af54b52ac501e507d75d8f37634b32e (diff)
mv643xx_eth: kill private unused instance of struct net_device_stats
The per-port mv643xx_eth_private struct had a private instance of struct net_device_stats that was never ever written to, only read (via the ethtool statistics interface). This patch gets rid of the private instance, and tweaks the ethtool statistics code in mv643xx_eth to use the statistics in struct net_device instead. Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Acked-by: Dale Farnsworth <dale@farnsworth.org>
-rw-r--r--drivers/net/mv643xx_eth.c120
1 files changed, 66 insertions, 54 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index ddd3e1148662..cc93af002013 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -325,7 +325,6 @@ struct mv643xx_eth_private {
325 325
326 struct net_device *dev; 326 struct net_device *dev;
327 struct napi_struct napi; 327 struct napi_struct napi;
328 struct net_device_stats stats;
329 struct mib_counters mib_counters; 328 struct mib_counters mib_counters;
330 spinlock_t lock; 329 spinlock_t lock;
331 /* Size of Tx Ring per queue */ 330 /* Size of Tx Ring per queue */
@@ -885,55 +884,59 @@ static void update_mib_counters(struct mv643xx_eth_private *mp)
885struct mv643xx_eth_stats { 884struct mv643xx_eth_stats {
886 char stat_string[ETH_GSTRING_LEN]; 885 char stat_string[ETH_GSTRING_LEN];
887 int sizeof_stat; 886 int sizeof_stat;
888 int stat_offset; 887 int netdev_off;
888 int mp_off;
889}; 889};
890 890
891#define MV643XX_ETH_STAT(m) FIELD_SIZEOF(struct mv643xx_eth_private, m), \ 891#define SSTAT(m) \
892 offsetof(struct mv643xx_eth_private, m) 892 { #m, FIELD_SIZEOF(struct net_device_stats, m), \
893 893 offsetof(struct net_device, stats.m), -1 }
894static const struct mv643xx_eth_stats mv643xx_eth_gstrings_stats[] = { 894
895 { "rx_packets", MV643XX_ETH_STAT(stats.rx_packets) }, 895#define MIBSTAT(m) \
896 { "tx_packets", MV643XX_ETH_STAT(stats.tx_packets) }, 896 { #m, FIELD_SIZEOF(struct mib_counters, m), \
897 { "rx_bytes", MV643XX_ETH_STAT(stats.rx_bytes) }, 897 -1, offsetof(struct mv643xx_eth_private, mib_counters.m) }
898 { "tx_bytes", MV643XX_ETH_STAT(stats.tx_bytes) }, 898
899 { "rx_errors", MV643XX_ETH_STAT(stats.rx_errors) }, 899static const struct mv643xx_eth_stats mv643xx_eth_stats[] = {
900 { "tx_errors", MV643XX_ETH_STAT(stats.tx_errors) }, 900 SSTAT(rx_packets),
901 { "rx_dropped", MV643XX_ETH_STAT(stats.rx_dropped) }, 901 SSTAT(tx_packets),
902 { "tx_dropped", MV643XX_ETH_STAT(stats.tx_dropped) }, 902 SSTAT(rx_bytes),
903 { "good_octets_received", MV643XX_ETH_STAT(mib_counters.good_octets_received) }, 903 SSTAT(tx_bytes),
904 { "bad_octets_received", MV643XX_ETH_STAT(mib_counters.bad_octets_received) }, 904 SSTAT(rx_errors),
905 { "internal_mac_transmit_err", MV643XX_ETH_STAT(mib_counters.internal_mac_transmit_err) }, 905 SSTAT(tx_errors),
906 { "good_frames_received", MV643XX_ETH_STAT(mib_counters.good_frames_received) }, 906 SSTAT(rx_dropped),
907 { "bad_frames_received", MV643XX_ETH_STAT(mib_counters.bad_frames_received) }, 907 SSTAT(tx_dropped),
908 { "broadcast_frames_received", MV643XX_ETH_STAT(mib_counters.broadcast_frames_received) }, 908 MIBSTAT(good_octets_received),
909 { "multicast_frames_received", MV643XX_ETH_STAT(mib_counters.multicast_frames_received) }, 909 MIBSTAT(bad_octets_received),
910 { "frames_64_octets", MV643XX_ETH_STAT(mib_counters.frames_64_octets) }, 910 MIBSTAT(internal_mac_transmit_err),
911 { "frames_65_to_127_octets", MV643XX_ETH_STAT(mib_counters.frames_65_to_127_octets) }, 911 MIBSTAT(good_frames_received),
912 { "frames_128_to_255_octets", MV643XX_ETH_STAT(mib_counters.frames_128_to_255_octets) }, 912 MIBSTAT(bad_frames_received),
913 { "frames_256_to_511_octets", MV643XX_ETH_STAT(mib_counters.frames_256_to_511_octets) }, 913 MIBSTAT(broadcast_frames_received),
914 { "frames_512_to_1023_octets", MV643XX_ETH_STAT(mib_counters.frames_512_to_1023_octets) }, 914 MIBSTAT(multicast_frames_received),
915 { "frames_1024_to_max_octets", MV643XX_ETH_STAT(mib_counters.frames_1024_to_max_octets) }, 915 MIBSTAT(frames_64_octets),
916 { "good_octets_sent", MV643XX_ETH_STAT(mib_counters.good_octets_sent) }, 916 MIBSTAT(frames_65_to_127_octets),
917 { "good_frames_sent", MV643XX_ETH_STAT(mib_counters.good_frames_sent) }, 917 MIBSTAT(frames_128_to_255_octets),
918 { "excessive_collision", MV643XX_ETH_STAT(mib_counters.excessive_collision) }, 918 MIBSTAT(frames_256_to_511_octets),
919 { "multicast_frames_sent", MV643XX_ETH_STAT(mib_counters.multicast_frames_sent) }, 919 MIBSTAT(frames_512_to_1023_octets),
920 { "broadcast_frames_sent", MV643XX_ETH_STAT(mib_counters.broadcast_frames_sent) }, 920 MIBSTAT(frames_1024_to_max_octets),
921 { "unrec_mac_control_received", MV643XX_ETH_STAT(mib_counters.unrec_mac_control_received) }, 921 MIBSTAT(good_octets_sent),
922 { "fc_sent", MV643XX_ETH_STAT(mib_counters.fc_sent) }, 922 MIBSTAT(good_frames_sent),
923 { "good_fc_received", MV643XX_ETH_STAT(mib_counters.good_fc_received) }, 923 MIBSTAT(excessive_collision),
924 { "bad_fc_received", MV643XX_ETH_STAT(mib_counters.bad_fc_received) }, 924 MIBSTAT(multicast_frames_sent),
925 { "undersize_received", MV643XX_ETH_STAT(mib_counters.undersize_received) }, 925 MIBSTAT(broadcast_frames_sent),
926 { "fragments_received", MV643XX_ETH_STAT(mib_counters.fragments_received) }, 926 MIBSTAT(unrec_mac_control_received),
927 { "oversize_received", MV643XX_ETH_STAT(mib_counters.oversize_received) }, 927 MIBSTAT(fc_sent),
928 { "jabber_received", MV643XX_ETH_STAT(mib_counters.jabber_received) }, 928 MIBSTAT(good_fc_received),
929 { "mac_receive_error", MV643XX_ETH_STAT(mib_counters.mac_receive_error) }, 929 MIBSTAT(bad_fc_received),
930 { "bad_crc_event", MV643XX_ETH_STAT(mib_counters.bad_crc_event) }, 930 MIBSTAT(undersize_received),
931 { "collision", MV643XX_ETH_STAT(mib_counters.collision) }, 931 MIBSTAT(fragments_received),
932 { "late_collision", MV643XX_ETH_STAT(mib_counters.late_collision) }, 932 MIBSTAT(oversize_received),
933 MIBSTAT(jabber_received),
934 MIBSTAT(mac_receive_error),
935 MIBSTAT(bad_crc_event),
936 MIBSTAT(collision),
937 MIBSTAT(late_collision),
933}; 938};
934 939
935#define MV643XX_ETH_STATS_LEN ARRAY_SIZE(mv643xx_eth_gstrings_stats)
936
937static int mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 940static int mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
938{ 941{
939 struct mv643xx_eth_private *mp = netdev_priv(dev); 942 struct mv643xx_eth_private *mp = netdev_priv(dev);
@@ -969,7 +972,7 @@ static void mv643xx_eth_get_drvinfo(struct net_device *netdev,
969 strncpy(drvinfo->version, mv643xx_eth_driver_version, 32); 972 strncpy(drvinfo->version, mv643xx_eth_driver_version, 32);
970 strncpy(drvinfo->fw_version, "N/A", 32); 973 strncpy(drvinfo->fw_version, "N/A", 32);
971 strncpy(drvinfo->bus_info, "mv643xx", 32); 974 strncpy(drvinfo->bus_info, "mv643xx", 32);
972 drvinfo->n_stats = MV643XX_ETH_STATS_LEN; 975 drvinfo->n_stats = ARRAY_SIZE(mv643xx_eth_stats);
973} 976}
974 977
975static int mv643xx_eth_nway_restart(struct net_device *dev) 978static int mv643xx_eth_nway_restart(struct net_device *dev)
@@ -993,9 +996,9 @@ static void mv643xx_eth_get_strings(struct net_device *netdev, uint32_t stringse
993 996
994 switch(stringset) { 997 switch(stringset) {
995 case ETH_SS_STATS: 998 case ETH_SS_STATS:
996 for (i=0; i < MV643XX_ETH_STATS_LEN; i++) { 999 for (i=0; i < ARRAY_SIZE(mv643xx_eth_stats); i++) {
997 memcpy(data + i * ETH_GSTRING_LEN, 1000 memcpy(data + i * ETH_GSTRING_LEN,
998 mv643xx_eth_gstrings_stats[i].stat_string, 1001 mv643xx_eth_stats[i].stat_string,
999 ETH_GSTRING_LEN); 1002 ETH_GSTRING_LEN);
1000 } 1003 }
1001 break; 1004 break;
@@ -1010,10 +1013,19 @@ static void mv643xx_eth_get_ethtool_stats(struct net_device *netdev,
1010 1013
1011 update_mib_counters(mp); 1014 update_mib_counters(mp);
1012 1015
1013 for (i = 0; i < MV643XX_ETH_STATS_LEN; i++) { 1016 for (i = 0; i < ARRAY_SIZE(mv643xx_eth_stats); i++) {
1014 char *p = (char *)mp+mv643xx_eth_gstrings_stats[i].stat_offset; 1017 const struct mv643xx_eth_stats *stat;
1015 data[i] = (mv643xx_eth_gstrings_stats[i].sizeof_stat == 1018 void *p;
1016 sizeof(uint64_t)) ? *(uint64_t *)p : *(uint32_t *)p; 1019
1020 stat = mv643xx_eth_stats + i;
1021
1022 if (stat->netdev_off >= 0)
1023 p = ((void *)mp->dev) + stat->netdev_off;
1024 else
1025 p = ((void *)mp) + stat->mp_off;
1026
1027 data[i] = (stat->sizeof_stat == 8) ?
1028 *(uint64_t *)p : *(uint32_t *)p;
1017 } 1029 }
1018} 1030}
1019 1031
@@ -1021,7 +1033,7 @@ static int mv643xx_eth_get_sset_count(struct net_device *netdev, int sset)
1021{ 1033{
1022 switch (sset) { 1034 switch (sset) {
1023 case ETH_SS_STATS: 1035 case ETH_SS_STATS:
1024 return MV643XX_ETH_STATS_LEN; 1036 return ARRAY_SIZE(mv643xx_eth_stats);
1025 default: 1037 default:
1026 return -EOPNOTSUPP; 1038 return -EOPNOTSUPP;
1027 } 1039 }