diff options
author | Sabrina Dubroca <sd@queasysnail.net> | 2014-01-09 04:09:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-11 23:52:58 -0500 |
commit | f1b6b1062a546279e3e340524c25029b8c6da385 (patch) | |
tree | b34853c8f214abc201f196224296bad5db5349a6 | |
parent | 5665dc6488902606b2d80ed640bb1e189aabddfe (diff) |
alx: add alx_get_stats64 operation
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/atheros/alx/alx.h | 3 | ||||
-rw-r--r-- | drivers/net/ethernet/atheros/alx/main.c | 50 |
2 files changed, 53 insertions, 0 deletions
diff --git a/drivers/net/ethernet/atheros/alx/alx.h b/drivers/net/ethernet/atheros/alx/alx.h index d71103dbf2cd..8fc93c5f6abc 100644 --- a/drivers/net/ethernet/atheros/alx/alx.h +++ b/drivers/net/ethernet/atheros/alx/alx.h | |||
@@ -106,6 +106,9 @@ struct alx_priv { | |||
106 | u16 msg_enable; | 106 | u16 msg_enable; |
107 | 107 | ||
108 | bool msi; | 108 | bool msi; |
109 | |||
110 | /* protects hw.stats */ | ||
111 | spinlock_t stats_lock; | ||
109 | }; | 112 | }; |
110 | 113 | ||
111 | extern const struct ethtool_ops alx_ethtool_ops; | 114 | extern const struct ethtool_ops alx_ethtool_ops; |
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c index c3c4c266b846..e92ffd6e1c15 100644 --- a/drivers/net/ethernet/atheros/alx/main.c +++ b/drivers/net/ethernet/atheros/alx/main.c | |||
@@ -1166,10 +1166,60 @@ static void alx_poll_controller(struct net_device *netdev) | |||
1166 | } | 1166 | } |
1167 | #endif | 1167 | #endif |
1168 | 1168 | ||
1169 | static struct rtnl_link_stats64 *alx_get_stats64(struct net_device *dev, | ||
1170 | struct rtnl_link_stats64 *net_stats) | ||
1171 | { | ||
1172 | struct alx_priv *alx = netdev_priv(dev); | ||
1173 | struct alx_hw_stats *hw_stats = &alx->hw.stats; | ||
1174 | |||
1175 | spin_lock(&alx->stats_lock); | ||
1176 | |||
1177 | alx_update_hw_stats(&alx->hw); | ||
1178 | |||
1179 | net_stats->tx_bytes = hw_stats->tx_byte_cnt; | ||
1180 | net_stats->rx_bytes = hw_stats->rx_byte_cnt; | ||
1181 | net_stats->multicast = hw_stats->rx_mcast; | ||
1182 | net_stats->collisions = hw_stats->tx_single_col + | ||
1183 | hw_stats->tx_multi_col + | ||
1184 | hw_stats->tx_late_col + | ||
1185 | hw_stats->tx_abort_col; | ||
1186 | |||
1187 | net_stats->rx_errors = hw_stats->rx_frag + | ||
1188 | hw_stats->rx_fcs_err + | ||
1189 | hw_stats->rx_len_err + | ||
1190 | hw_stats->rx_ov_sz + | ||
1191 | hw_stats->rx_ov_rrd + | ||
1192 | hw_stats->rx_align_err + | ||
1193 | hw_stats->rx_ov_rxf; | ||
1194 | |||
1195 | net_stats->rx_fifo_errors = hw_stats->rx_ov_rxf; | ||
1196 | net_stats->rx_length_errors = hw_stats->rx_len_err; | ||
1197 | net_stats->rx_crc_errors = hw_stats->rx_fcs_err; | ||
1198 | net_stats->rx_frame_errors = hw_stats->rx_align_err; | ||
1199 | net_stats->rx_dropped = hw_stats->rx_ov_rrd; | ||
1200 | |||
1201 | net_stats->tx_errors = hw_stats->tx_late_col + | ||
1202 | hw_stats->tx_abort_col + | ||
1203 | hw_stats->tx_underrun + | ||
1204 | hw_stats->tx_trunc; | ||
1205 | |||
1206 | net_stats->tx_aborted_errors = hw_stats->tx_abort_col; | ||
1207 | net_stats->tx_fifo_errors = hw_stats->tx_underrun; | ||
1208 | net_stats->tx_window_errors = hw_stats->tx_late_col; | ||
1209 | |||
1210 | net_stats->tx_packets = hw_stats->tx_ok + net_stats->tx_errors; | ||
1211 | net_stats->rx_packets = hw_stats->rx_ok + net_stats->rx_errors; | ||
1212 | |||
1213 | spin_unlock(&alx->stats_lock); | ||
1214 | |||
1215 | return net_stats; | ||
1216 | } | ||
1217 | |||
1169 | static const struct net_device_ops alx_netdev_ops = { | 1218 | static const struct net_device_ops alx_netdev_ops = { |
1170 | .ndo_open = alx_open, | 1219 | .ndo_open = alx_open, |
1171 | .ndo_stop = alx_stop, | 1220 | .ndo_stop = alx_stop, |
1172 | .ndo_start_xmit = alx_start_xmit, | 1221 | .ndo_start_xmit = alx_start_xmit, |
1222 | .ndo_get_stats64 = alx_get_stats64, | ||
1173 | .ndo_set_rx_mode = alx_set_rx_mode, | 1223 | .ndo_set_rx_mode = alx_set_rx_mode, |
1174 | .ndo_validate_addr = eth_validate_addr, | 1224 | .ndo_validate_addr = eth_validate_addr, |
1175 | .ndo_set_mac_address = alx_set_mac_address, | 1225 | .ndo_set_mac_address = alx_set_mac_address, |