diff options
| author | David S. Miller <davem@davemloft.net> | 2014-01-14 20:18:36 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-01-14 20:18:36 -0500 |
| commit | 86c72fdf386d81e0b77a4c40b8ba8215fbb1418b (patch) | |
| tree | a814cc5ea16154154aa421890759dd8567bab8bc | |
| parent | 88bfe6ea001d9915a3ad57f30a1b2826ef4e5890 (diff) | |
| parent | e3d21ea1a119ec31673d94f26c68d922bbd3d211 (diff) | |
Merge branch 'atl_stats'
Sabrina Dubroca says:
====================
atheros: modify statistics code
Following Ben Hutchings's advice on how to fill net_stats in alx [1],
this patch modifies the other atheros ethernet drivers
similarly. Minor whitespace/empty line changes in atl1c and atl1e to
make the code completely consistent between atl1c, atl1e, and alx.
I don't have this hardware, so these patches have only been
compile-tested.
v2 (changes only in atl1):
- don't set soft_stats.rx_missed_errors (Ben)
- add errors to soft_stats.{rx,tx}_packets (Ben)
- add soft_stats.rx_dropped field and update soft_stats.rx_dropped
instead of netdev->stats (overwritten) outside of the stats
update function
Detail of the changes (v1):
* atl1/atl1c/atl1e
- fix collisions computation
- rx_dropped = rx_rrd_ov
- rx_over_errors = 0
- rx_missed_errors = 0
- X_packets = X_ok + X_errors
* only atl1c/atl1e
- add rx_rxf_ov to rx_errors
[1] http://www.spinics.net/lists/netdev/msg264930.html
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 31 | ||||
| -rw-r--r-- | drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 30 | ||||
| -rw-r--r-- | drivers/net/ethernet/atheros/atlx/atl1.c | 43 | ||||
| -rw-r--r-- | drivers/net/ethernet/atheros/atlx/atl1.h | 1 |
4 files changed, 65 insertions, 40 deletions
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index 29801750f239..4d3258dd0a88 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c | |||
| @@ -1500,31 +1500,40 @@ static struct net_device_stats *atl1c_get_stats(struct net_device *netdev) | |||
| 1500 | struct net_device_stats *net_stats = &netdev->stats; | 1500 | struct net_device_stats *net_stats = &netdev->stats; |
| 1501 | 1501 | ||
| 1502 | atl1c_update_hw_stats(adapter); | 1502 | atl1c_update_hw_stats(adapter); |
| 1503 | net_stats->rx_packets = hw_stats->rx_ok; | ||
| 1504 | net_stats->tx_packets = hw_stats->tx_ok; | ||
| 1505 | net_stats->rx_bytes = hw_stats->rx_byte_cnt; | 1503 | net_stats->rx_bytes = hw_stats->rx_byte_cnt; |
| 1506 | net_stats->tx_bytes = hw_stats->tx_byte_cnt; | 1504 | net_stats->tx_bytes = hw_stats->tx_byte_cnt; |
| 1507 | net_stats->multicast = hw_stats->rx_mcast; | 1505 | net_stats->multicast = hw_stats->rx_mcast; |
| 1508 | net_stats->collisions = hw_stats->tx_1_col + | 1506 | net_stats->collisions = hw_stats->tx_1_col + |
| 1509 | hw_stats->tx_2_col * 2 + | 1507 | hw_stats->tx_2_col + |
| 1510 | hw_stats->tx_late_col + hw_stats->tx_abort_col; | 1508 | hw_stats->tx_late_col + |
| 1511 | net_stats->rx_errors = hw_stats->rx_frag + hw_stats->rx_fcs_err + | 1509 | hw_stats->tx_abort_col; |
| 1512 | hw_stats->rx_len_err + hw_stats->rx_sz_ov + | 1510 | |
| 1513 | hw_stats->rx_rrd_ov + hw_stats->rx_align_err; | 1511 | net_stats->rx_errors = hw_stats->rx_frag + |
| 1512 | hw_stats->rx_fcs_err + | ||
| 1513 | hw_stats->rx_len_err + | ||
| 1514 | hw_stats->rx_sz_ov + | ||
| 1515 | hw_stats->rx_rrd_ov + | ||
| 1516 | hw_stats->rx_align_err + | ||
| 1517 | hw_stats->rx_rxf_ov; | ||
| 1518 | |||
| 1514 | net_stats->rx_fifo_errors = hw_stats->rx_rxf_ov; | 1519 | net_stats->rx_fifo_errors = hw_stats->rx_rxf_ov; |
| 1515 | net_stats->rx_length_errors = hw_stats->rx_len_err; | 1520 | net_stats->rx_length_errors = hw_stats->rx_len_err; |
| 1516 | net_stats->rx_crc_errors = hw_stats->rx_fcs_err; | 1521 | net_stats->rx_crc_errors = hw_stats->rx_fcs_err; |
| 1517 | net_stats->rx_frame_errors = hw_stats->rx_align_err; | 1522 | net_stats->rx_frame_errors = hw_stats->rx_align_err; |
| 1518 | net_stats->rx_over_errors = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov; | 1523 | net_stats->rx_dropped = hw_stats->rx_rrd_ov; |
| 1519 | 1524 | ||
| 1520 | net_stats->rx_missed_errors = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov; | 1525 | net_stats->tx_errors = hw_stats->tx_late_col + |
| 1526 | hw_stats->tx_abort_col + | ||
| 1527 | hw_stats->tx_underrun + | ||
| 1528 | hw_stats->tx_trunc; | ||
| 1521 | 1529 | ||
| 1522 | net_stats->tx_errors = hw_stats->tx_late_col + hw_stats->tx_abort_col + | ||
| 1523 | hw_stats->tx_underrun + hw_stats->tx_trunc; | ||
| 1524 | net_stats->tx_fifo_errors = hw_stats->tx_underrun; | 1530 | net_stats->tx_fifo_errors = hw_stats->tx_underrun; |
| 1525 | net_stats->tx_aborted_errors = hw_stats->tx_abort_col; | 1531 | net_stats->tx_aborted_errors = hw_stats->tx_abort_col; |
| 1526 | net_stats->tx_window_errors = hw_stats->tx_late_col; | 1532 | net_stats->tx_window_errors = hw_stats->tx_late_col; |
| 1527 | 1533 | ||
| 1534 | net_stats->rx_packets = hw_stats->rx_ok + net_stats->rx_errors; | ||
| 1535 | net_stats->tx_packets = hw_stats->tx_ok + net_stats->tx_errors; | ||
| 1536 | |||
| 1528 | return net_stats; | 1537 | return net_stats; |
| 1529 | } | 1538 | } |
| 1530 | 1539 | ||
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 7a73f3a9fcb5..d5c2d3e912e5 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c | |||
| @@ -1177,32 +1177,40 @@ static struct net_device_stats *atl1e_get_stats(struct net_device *netdev) | |||
| 1177 | struct atl1e_hw_stats *hw_stats = &adapter->hw_stats; | 1177 | struct atl1e_hw_stats *hw_stats = &adapter->hw_stats; |
| 1178 | struct net_device_stats *net_stats = &netdev->stats; | 1178 | struct net_device_stats *net_stats = &netdev->stats; |
| 1179 | 1179 | ||
| 1180 | net_stats->rx_packets = hw_stats->rx_ok; | ||
| 1181 | net_stats->tx_packets = hw_stats->tx_ok; | ||
| 1182 | net_stats->rx_bytes = hw_stats->rx_byte_cnt; | 1180 | net_stats->rx_bytes = hw_stats->rx_byte_cnt; |
| 1183 | net_stats->tx_bytes = hw_stats->tx_byte_cnt; | 1181 | net_stats->tx_bytes = hw_stats->tx_byte_cnt; |
| 1184 | net_stats->multicast = hw_stats->rx_mcast; | 1182 | net_stats->multicast = hw_stats->rx_mcast; |
| 1185 | net_stats->collisions = hw_stats->tx_1_col + | 1183 | net_stats->collisions = hw_stats->tx_1_col + |
| 1186 | hw_stats->tx_2_col * 2 + | 1184 | hw_stats->tx_2_col + |
| 1187 | hw_stats->tx_late_col + hw_stats->tx_abort_col; | 1185 | hw_stats->tx_late_col + |
| 1186 | hw_stats->tx_abort_col; | ||
| 1187 | |||
| 1188 | net_stats->rx_errors = hw_stats->rx_frag + | ||
| 1189 | hw_stats->rx_fcs_err + | ||
| 1190 | hw_stats->rx_len_err + | ||
| 1191 | hw_stats->rx_sz_ov + | ||
| 1192 | hw_stats->rx_rrd_ov + | ||
| 1193 | hw_stats->rx_align_err + | ||
| 1194 | hw_stats->rx_rxf_ov; | ||
| 1188 | 1195 | ||
| 1189 | net_stats->rx_errors = hw_stats->rx_frag + hw_stats->rx_fcs_err + | ||
| 1190 | hw_stats->rx_len_err + hw_stats->rx_sz_ov + | ||
| 1191 | hw_stats->rx_rrd_ov + hw_stats->rx_align_err; | ||
| 1192 | net_stats->rx_fifo_errors = hw_stats->rx_rxf_ov; | 1196 | net_stats->rx_fifo_errors = hw_stats->rx_rxf_ov; |
| 1193 | net_stats->rx_length_errors = hw_stats->rx_len_err; | 1197 | net_stats->rx_length_errors = hw_stats->rx_len_err; |
| 1194 | net_stats->rx_crc_errors = hw_stats->rx_fcs_err; | 1198 | net_stats->rx_crc_errors = hw_stats->rx_fcs_err; |
| 1195 | net_stats->rx_frame_errors = hw_stats->rx_align_err; | 1199 | net_stats->rx_frame_errors = hw_stats->rx_align_err; |
| 1196 | net_stats->rx_over_errors = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov; | 1200 | net_stats->rx_dropped = hw_stats->rx_rrd_ov; |
| 1197 | 1201 | ||
| 1198 | net_stats->rx_missed_errors = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov; | 1202 | net_stats->tx_errors = hw_stats->tx_late_col + |
| 1203 | hw_stats->tx_abort_col + | ||
| 1204 | hw_stats->tx_underrun + | ||
| 1205 | hw_stats->tx_trunc; | ||
| 1199 | 1206 | ||
| 1200 | net_stats->tx_errors = hw_stats->tx_late_col + hw_stats->tx_abort_col + | ||
| 1201 | hw_stats->tx_underrun + hw_stats->tx_trunc; | ||
| 1202 | net_stats->tx_fifo_errors = hw_stats->tx_underrun; | 1207 | net_stats->tx_fifo_errors = hw_stats->tx_underrun; |
| 1203 | net_stats->tx_aborted_errors = hw_stats->tx_abort_col; | 1208 | net_stats->tx_aborted_errors = hw_stats->tx_abort_col; |
| 1204 | net_stats->tx_window_errors = hw_stats->tx_late_col; | 1209 | net_stats->tx_window_errors = hw_stats->tx_late_col; |
| 1205 | 1210 | ||
| 1211 | net_stats->rx_packets = hw_stats->rx_ok + net_stats->rx_errors; | ||
| 1212 | net_stats->tx_packets = hw_stats->tx_ok + net_stats->tx_errors; | ||
| 1213 | |||
| 1206 | return net_stats; | 1214 | return net_stats; |
| 1207 | } | 1215 | } |
| 1208 | 1216 | ||
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c index 55d86ecdacfe..287272dd69da 100644 --- a/drivers/net/ethernet/atheros/atlx/atl1.c +++ b/drivers/net/ethernet/atheros/atlx/atl1.c | |||
| @@ -1678,33 +1678,42 @@ static void atl1_inc_smb(struct atl1_adapter *adapter) | |||
| 1678 | struct net_device *netdev = adapter->netdev; | 1678 | struct net_device *netdev = adapter->netdev; |
| 1679 | struct stats_msg_block *smb = adapter->smb.smb; | 1679 | struct stats_msg_block *smb = adapter->smb.smb; |
| 1680 | 1680 | ||
| 1681 | u64 new_rx_errors = smb->rx_frag + | ||
| 1682 | smb->rx_fcs_err + | ||
| 1683 | smb->rx_len_err + | ||
| 1684 | smb->rx_sz_ov + | ||
| 1685 | smb->rx_rxf_ov + | ||
| 1686 | smb->rx_rrd_ov + | ||
| 1687 | smb->rx_align_err; | ||
| 1688 | u64 new_tx_errors = smb->tx_late_col + | ||
| 1689 | smb->tx_abort_col + | ||
| 1690 | smb->tx_underrun + | ||
| 1691 | smb->tx_trunc; | ||
| 1692 | |||
| 1681 | /* Fill out the OS statistics structure */ | 1693 | /* Fill out the OS statistics structure */ |
| 1682 | adapter->soft_stats.rx_packets += smb->rx_ok; | 1694 | adapter->soft_stats.rx_packets += smb->rx_ok + new_rx_errors; |
| 1683 | adapter->soft_stats.tx_packets += smb->tx_ok; | 1695 | adapter->soft_stats.tx_packets += smb->tx_ok + new_tx_errors; |
| 1684 | adapter->soft_stats.rx_bytes += smb->rx_byte_cnt; | 1696 | adapter->soft_stats.rx_bytes += smb->rx_byte_cnt; |
| 1685 | adapter->soft_stats.tx_bytes += smb->tx_byte_cnt; | 1697 | adapter->soft_stats.tx_bytes += smb->tx_byte_cnt; |
| 1686 | adapter->soft_stats.multicast += smb->rx_mcast; | 1698 | adapter->soft_stats.multicast += smb->rx_mcast; |
| 1687 | adapter->soft_stats.collisions += (smb->tx_1_col + smb->tx_2_col * 2 + | 1699 | adapter->soft_stats.collisions += smb->tx_1_col + |
| 1688 | smb->tx_late_col + smb->tx_abort_col * adapter->hw.max_retry); | 1700 | smb->tx_2_col + |
| 1701 | smb->tx_late_col + | ||
| 1702 | smb->tx_abort_col; | ||
| 1689 | 1703 | ||
| 1690 | /* Rx Errors */ | 1704 | /* Rx Errors */ |
| 1691 | adapter->soft_stats.rx_errors += (smb->rx_frag + smb->rx_fcs_err + | 1705 | adapter->soft_stats.rx_errors += new_rx_errors; |
| 1692 | smb->rx_len_err + smb->rx_sz_ov + smb->rx_rxf_ov + | ||
| 1693 | smb->rx_rrd_ov + smb->rx_align_err); | ||
| 1694 | adapter->soft_stats.rx_fifo_errors += smb->rx_rxf_ov; | 1706 | adapter->soft_stats.rx_fifo_errors += smb->rx_rxf_ov; |
| 1695 | adapter->soft_stats.rx_length_errors += smb->rx_len_err; | 1707 | adapter->soft_stats.rx_length_errors += smb->rx_len_err; |
| 1696 | adapter->soft_stats.rx_crc_errors += smb->rx_fcs_err; | 1708 | adapter->soft_stats.rx_crc_errors += smb->rx_fcs_err; |
| 1697 | adapter->soft_stats.rx_frame_errors += smb->rx_align_err; | 1709 | adapter->soft_stats.rx_frame_errors += smb->rx_align_err; |
| 1698 | adapter->soft_stats.rx_missed_errors += (smb->rx_rrd_ov + | ||
| 1699 | smb->rx_rxf_ov); | ||
| 1700 | 1710 | ||
| 1701 | adapter->soft_stats.rx_pause += smb->rx_pause; | 1711 | adapter->soft_stats.rx_pause += smb->rx_pause; |
| 1702 | adapter->soft_stats.rx_rrd_ov += smb->rx_rrd_ov; | 1712 | adapter->soft_stats.rx_rrd_ov += smb->rx_rrd_ov; |
| 1703 | adapter->soft_stats.rx_trunc += smb->rx_sz_ov; | 1713 | adapter->soft_stats.rx_trunc += smb->rx_sz_ov; |
| 1704 | 1714 | ||
| 1705 | /* Tx Errors */ | 1715 | /* Tx Errors */ |
| 1706 | adapter->soft_stats.tx_errors += (smb->tx_late_col + | 1716 | adapter->soft_stats.tx_errors += new_tx_errors; |
| 1707 | smb->tx_abort_col + smb->tx_underrun + smb->tx_trunc); | ||
| 1708 | adapter->soft_stats.tx_fifo_errors += smb->tx_underrun; | 1717 | adapter->soft_stats.tx_fifo_errors += smb->tx_underrun; |
| 1709 | adapter->soft_stats.tx_aborted_errors += smb->tx_abort_col; | 1718 | adapter->soft_stats.tx_aborted_errors += smb->tx_abort_col; |
| 1710 | adapter->soft_stats.tx_window_errors += smb->tx_late_col; | 1719 | adapter->soft_stats.tx_window_errors += smb->tx_late_col; |
| @@ -1718,23 +1727,18 @@ static void atl1_inc_smb(struct atl1_adapter *adapter) | |||
| 1718 | adapter->soft_stats.tx_trunc += smb->tx_trunc; | 1727 | adapter->soft_stats.tx_trunc += smb->tx_trunc; |
| 1719 | adapter->soft_stats.tx_pause += smb->tx_pause; | 1728 | adapter->soft_stats.tx_pause += smb->tx_pause; |
| 1720 | 1729 | ||
| 1721 | netdev->stats.rx_packets = adapter->soft_stats.rx_packets; | ||
| 1722 | netdev->stats.tx_packets = adapter->soft_stats.tx_packets; | ||
| 1723 | netdev->stats.rx_bytes = adapter->soft_stats.rx_bytes; | 1730 | netdev->stats.rx_bytes = adapter->soft_stats.rx_bytes; |
| 1724 | netdev->stats.tx_bytes = adapter->soft_stats.tx_bytes; | 1731 | netdev->stats.tx_bytes = adapter->soft_stats.tx_bytes; |
| 1725 | netdev->stats.multicast = adapter->soft_stats.multicast; | 1732 | netdev->stats.multicast = adapter->soft_stats.multicast; |
| 1726 | netdev->stats.collisions = adapter->soft_stats.collisions; | 1733 | netdev->stats.collisions = adapter->soft_stats.collisions; |
| 1727 | netdev->stats.rx_errors = adapter->soft_stats.rx_errors; | 1734 | netdev->stats.rx_errors = adapter->soft_stats.rx_errors; |
| 1728 | netdev->stats.rx_over_errors = | ||
| 1729 | adapter->soft_stats.rx_missed_errors; | ||
| 1730 | netdev->stats.rx_length_errors = | 1735 | netdev->stats.rx_length_errors = |
| 1731 | adapter->soft_stats.rx_length_errors; | 1736 | adapter->soft_stats.rx_length_errors; |
| 1732 | netdev->stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; | 1737 | netdev->stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; |
| 1733 | netdev->stats.rx_frame_errors = | 1738 | netdev->stats.rx_frame_errors = |
| 1734 | adapter->soft_stats.rx_frame_errors; | 1739 | adapter->soft_stats.rx_frame_errors; |
| 1735 | netdev->stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; | 1740 | netdev->stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; |
| 1736 | netdev->stats.rx_missed_errors = | 1741 | netdev->stats.rx_dropped = adapter->soft_stats.rx_rrd_ov; |
| 1737 | adapter->soft_stats.rx_missed_errors; | ||
| 1738 | netdev->stats.tx_errors = adapter->soft_stats.tx_errors; | 1742 | netdev->stats.tx_errors = adapter->soft_stats.tx_errors; |
| 1739 | netdev->stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; | 1743 | netdev->stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; |
| 1740 | netdev->stats.tx_aborted_errors = | 1744 | netdev->stats.tx_aborted_errors = |
| @@ -1743,6 +1747,9 @@ static void atl1_inc_smb(struct atl1_adapter *adapter) | |||
| 1743 | adapter->soft_stats.tx_window_errors; | 1747 | adapter->soft_stats.tx_window_errors; |
| 1744 | netdev->stats.tx_carrier_errors = | 1748 | netdev->stats.tx_carrier_errors = |
| 1745 | adapter->soft_stats.tx_carrier_errors; | 1749 | adapter->soft_stats.tx_carrier_errors; |
| 1750 | |||
| 1751 | netdev->stats.rx_packets = adapter->soft_stats.rx_packets; | ||
| 1752 | netdev->stats.tx_packets = adapter->soft_stats.tx_packets; | ||
| 1746 | } | 1753 | } |
| 1747 | 1754 | ||
| 1748 | static void atl1_update_mailbox(struct atl1_adapter *adapter) | 1755 | static void atl1_update_mailbox(struct atl1_adapter *adapter) |
| @@ -1872,7 +1879,7 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter) | |||
| 1872 | adapter->rx_buffer_len); | 1879 | adapter->rx_buffer_len); |
| 1873 | if (unlikely(!skb)) { | 1880 | if (unlikely(!skb)) { |
| 1874 | /* Better luck next round */ | 1881 | /* Better luck next round */ |
| 1875 | adapter->netdev->stats.rx_dropped++; | 1882 | adapter->soft_stats.rx_dropped++; |
| 1876 | break; | 1883 | break; |
| 1877 | } | 1884 | } |
| 1878 | 1885 | ||
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.h b/drivers/net/ethernet/atheros/atlx/atl1.h index 3bf79a56220d..34a58cd846a0 100644 --- a/drivers/net/ethernet/atheros/atlx/atl1.h +++ b/drivers/net/ethernet/atheros/atlx/atl1.h | |||
| @@ -666,6 +666,7 @@ struct atl1_sft_stats { | |||
| 666 | u64 rx_errors; | 666 | u64 rx_errors; |
| 667 | u64 rx_length_errors; | 667 | u64 rx_length_errors; |
| 668 | u64 rx_crc_errors; | 668 | u64 rx_crc_errors; |
| 669 | u64 rx_dropped; | ||
| 669 | u64 rx_frame_errors; | 670 | u64 rx_frame_errors; |
| 670 | u64 rx_fifo_errors; | 671 | u64 rx_fifo_errors; |
| 671 | u64 rx_missed_errors; | 672 | u64 rx_missed_errors; |
