Skip to content

Commit e3d21ea

Browse files
qsndavem330
authored andcommitted
atl1: update statistics code
As Ben Hutchings pointed out for the stats in alx, some hardware-specific stats aren't matched to the right net_device_stats field. Also fix the collision field and include errors in the total number of RX/TX packets. Add a rx_dropped field and use it where netdev->stats was modified directly out of the stats update function. Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fb3a42f commit e3d21ea

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

drivers/net/ethernet/atheros/atlx/atl1.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,33 +1678,42 @@ static void atl1_inc_smb(struct atl1_adapter *adapter)
16781678
struct net_device *netdev = adapter->netdev;
16791679
struct stats_msg_block *smb = adapter->smb.smb;
16801680

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+
16811693
/* Fill out the OS statistics structure */
1682-
adapter->soft_stats.rx_packets += smb->rx_ok;
1683-
adapter->soft_stats.tx_packets += smb->tx_ok;
1694+
adapter->soft_stats.rx_packets += smb->rx_ok + new_rx_errors;
1695+
adapter->soft_stats.tx_packets += smb->tx_ok + new_tx_errors;
16841696
adapter->soft_stats.rx_bytes += smb->rx_byte_cnt;
16851697
adapter->soft_stats.tx_bytes += smb->tx_byte_cnt;
16861698
adapter->soft_stats.multicast += smb->rx_mcast;
1687-
adapter->soft_stats.collisions += (smb->tx_1_col + smb->tx_2_col * 2 +
1688-
smb->tx_late_col + smb->tx_abort_col * adapter->hw.max_retry);
1699+
adapter->soft_stats.collisions += smb->tx_1_col +
1700+
smb->tx_2_col +
1701+
smb->tx_late_col +
1702+
smb->tx_abort_col;
16891703

16901704
/* Rx Errors */
1691-
adapter->soft_stats.rx_errors += (smb->rx_frag + smb->rx_fcs_err +
1692-
smb->rx_len_err + smb->rx_sz_ov + smb->rx_rxf_ov +
1693-
smb->rx_rrd_ov + smb->rx_align_err);
1705+
adapter->soft_stats.rx_errors += new_rx_errors;
16941706
adapter->soft_stats.rx_fifo_errors += smb->rx_rxf_ov;
16951707
adapter->soft_stats.rx_length_errors += smb->rx_len_err;
16961708
adapter->soft_stats.rx_crc_errors += smb->rx_fcs_err;
16971709
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);
17001710

17011711
adapter->soft_stats.rx_pause += smb->rx_pause;
17021712
adapter->soft_stats.rx_rrd_ov += smb->rx_rrd_ov;
17031713
adapter->soft_stats.rx_trunc += smb->rx_sz_ov;
17041714

17051715
/* Tx Errors */
1706-
adapter->soft_stats.tx_errors += (smb->tx_late_col +
1707-
smb->tx_abort_col + smb->tx_underrun + smb->tx_trunc);
1716+
adapter->soft_stats.tx_errors += new_tx_errors;
17081717
adapter->soft_stats.tx_fifo_errors += smb->tx_underrun;
17091718
adapter->soft_stats.tx_aborted_errors += smb->tx_abort_col;
17101719
adapter->soft_stats.tx_window_errors += smb->tx_late_col;
@@ -1718,23 +1727,18 @@ static void atl1_inc_smb(struct atl1_adapter *adapter)
17181727
adapter->soft_stats.tx_trunc += smb->tx_trunc;
17191728
adapter->soft_stats.tx_pause += smb->tx_pause;
17201729

1721-
netdev->stats.rx_packets = adapter->soft_stats.rx_packets;
1722-
netdev->stats.tx_packets = adapter->soft_stats.tx_packets;
17231730
netdev->stats.rx_bytes = adapter->soft_stats.rx_bytes;
17241731
netdev->stats.tx_bytes = adapter->soft_stats.tx_bytes;
17251732
netdev->stats.multicast = adapter->soft_stats.multicast;
17261733
netdev->stats.collisions = adapter->soft_stats.collisions;
17271734
netdev->stats.rx_errors = adapter->soft_stats.rx_errors;
1728-
netdev->stats.rx_over_errors =
1729-
adapter->soft_stats.rx_missed_errors;
17301735
netdev->stats.rx_length_errors =
17311736
adapter->soft_stats.rx_length_errors;
17321737
netdev->stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors;
17331738
netdev->stats.rx_frame_errors =
17341739
adapter->soft_stats.rx_frame_errors;
17351740
netdev->stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors;
1736-
netdev->stats.rx_missed_errors =
1737-
adapter->soft_stats.rx_missed_errors;
1741+
netdev->stats.rx_dropped = adapter->soft_stats.rx_rrd_ov;
17381742
netdev->stats.tx_errors = adapter->soft_stats.tx_errors;
17391743
netdev->stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors;
17401744
netdev->stats.tx_aborted_errors =
@@ -1743,6 +1747,9 @@ static void atl1_inc_smb(struct atl1_adapter *adapter)
17431747
adapter->soft_stats.tx_window_errors;
17441748
netdev->stats.tx_carrier_errors =
17451749
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;
17461753
}
17471754

17481755
static void atl1_update_mailbox(struct atl1_adapter *adapter)
@@ -1872,7 +1879,7 @@ static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter)
18721879
adapter->rx_buffer_len);
18731880
if (unlikely(!skb)) {
18741881
/* Better luck next round */
1875-
adapter->netdev->stats.rx_dropped++;
1882+
adapter->soft_stats.rx_dropped++;
18761883
break;
18771884
}
18781885

drivers/net/ethernet/atheros/atlx/atl1.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ struct atl1_sft_stats {
666666
u64 rx_errors;
667667
u64 rx_length_errors;
668668
u64 rx_crc_errors;
669+
u64 rx_dropped;
669670
u64 rx_frame_errors;
670671
u64 rx_fifo_errors;
671672
u64 rx_missed_errors;

0 commit comments

Comments
 (0)