Patchwork [1/3] atl1c: update statistics code

login
register
mail settings
Submitter Sabrina Dubroca
Date Jan. 10, 2014, 4:08 p.m.
Message ID <1389370103-3009-2-git-send-email-sd@queasysnail.net>
Download mbox | patch
Permalink /patch/309321/
State Superseded
Delegated to: David Miller
Headers show

Comments

Sabrina Dubroca - Jan. 10, 2014, 4:08 p.m.
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.

Minor whitespace fixes to match the style in alx.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 31 ++++++++++++++++---------
 1 file changed, 20 insertions(+), 11 deletions(-)
Ben Hutchings - Jan. 10, 2014, 6:19 p.m.
On Fri, 2014-01-10 at 17:08 +0100, Sabrina Dubroca wrote:
> 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.
> 
> Minor whitespace fixes to match the style in alx.
> 
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

Again I don't know the hardware, but this seems to make sense.

Reviewed-by: Ben Hutchings <bhutchings@solarflare.com>

> ---
>  drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 31 ++++++++++++++++---------
>  1 file changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index 2980175..4d3258d 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)
>  	struct net_device_stats *net_stats = &netdev->stats;
>  
>  	atl1c_update_hw_stats(adapter);
> -	net_stats->rx_packets = hw_stats->rx_ok;
> -	net_stats->tx_packets = hw_stats->tx_ok;
>  	net_stats->rx_bytes   = hw_stats->rx_byte_cnt;
>  	net_stats->tx_bytes   = hw_stats->tx_byte_cnt;
>  	net_stats->multicast  = hw_stats->rx_mcast;
>  	net_stats->collisions = hw_stats->tx_1_col +
> -				hw_stats->tx_2_col * 2 +
> -				hw_stats->tx_late_col + hw_stats->tx_abort_col;
> -	net_stats->rx_errors  = hw_stats->rx_frag + hw_stats->rx_fcs_err +
> -				hw_stats->rx_len_err + hw_stats->rx_sz_ov +
> -				hw_stats->rx_rrd_ov + hw_stats->rx_align_err;
> +				hw_stats->tx_2_col +
> +				hw_stats->tx_late_col +
> +				hw_stats->tx_abort_col;
> +
> +	net_stats->rx_errors  = hw_stats->rx_frag +
> +				hw_stats->rx_fcs_err +
> +				hw_stats->rx_len_err +
> +				hw_stats->rx_sz_ov +
> +				hw_stats->rx_rrd_ov +
> +				hw_stats->rx_align_err +
> +				hw_stats->rx_rxf_ov;
> +
>  	net_stats->rx_fifo_errors   = hw_stats->rx_rxf_ov;
>  	net_stats->rx_length_errors = hw_stats->rx_len_err;
>  	net_stats->rx_crc_errors    = hw_stats->rx_fcs_err;
>  	net_stats->rx_frame_errors  = hw_stats->rx_align_err;
> -	net_stats->rx_over_errors   = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov;
> +	net_stats->rx_dropped       = hw_stats->rx_rrd_ov;
>  
> -	net_stats->rx_missed_errors = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov;
> +	net_stats->tx_errors = hw_stats->tx_late_col +
> +			       hw_stats->tx_abort_col +
> +			       hw_stats->tx_underrun +
> +			       hw_stats->tx_trunc;
>  
> -	net_stats->tx_errors = hw_stats->tx_late_col + hw_stats->tx_abort_col +
> -				hw_stats->tx_underrun + hw_stats->tx_trunc;
>  	net_stats->tx_fifo_errors    = hw_stats->tx_underrun;
>  	net_stats->tx_aborted_errors = hw_stats->tx_abort_col;
>  	net_stats->tx_window_errors  = hw_stats->tx_late_col;
>  
> +	net_stats->rx_packets = hw_stats->rx_ok + net_stats->rx_errors;
> +	net_stats->tx_packets = hw_stats->tx_ok + net_stats->tx_errors;
> +
>  	return net_stats;
>  }
>

Patch

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index 2980175..4d3258d 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)
 	struct net_device_stats *net_stats = &netdev->stats;
 
 	atl1c_update_hw_stats(adapter);
-	net_stats->rx_packets = hw_stats->rx_ok;
-	net_stats->tx_packets = hw_stats->tx_ok;
 	net_stats->rx_bytes   = hw_stats->rx_byte_cnt;
 	net_stats->tx_bytes   = hw_stats->tx_byte_cnt;
 	net_stats->multicast  = hw_stats->rx_mcast;
 	net_stats->collisions = hw_stats->tx_1_col +
-				hw_stats->tx_2_col * 2 +
-				hw_stats->tx_late_col + hw_stats->tx_abort_col;
-	net_stats->rx_errors  = hw_stats->rx_frag + hw_stats->rx_fcs_err +
-				hw_stats->rx_len_err + hw_stats->rx_sz_ov +
-				hw_stats->rx_rrd_ov + hw_stats->rx_align_err;
+				hw_stats->tx_2_col +
+				hw_stats->tx_late_col +
+				hw_stats->tx_abort_col;
+
+	net_stats->rx_errors  = hw_stats->rx_frag +
+				hw_stats->rx_fcs_err +
+				hw_stats->rx_len_err +
+				hw_stats->rx_sz_ov +
+				hw_stats->rx_rrd_ov +
+				hw_stats->rx_align_err +
+				hw_stats->rx_rxf_ov;
+
 	net_stats->rx_fifo_errors   = hw_stats->rx_rxf_ov;
 	net_stats->rx_length_errors = hw_stats->rx_len_err;
 	net_stats->rx_crc_errors    = hw_stats->rx_fcs_err;
 	net_stats->rx_frame_errors  = hw_stats->rx_align_err;
-	net_stats->rx_over_errors   = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov;
+	net_stats->rx_dropped       = hw_stats->rx_rrd_ov;
 
-	net_stats->rx_missed_errors = hw_stats->rx_rrd_ov + hw_stats->rx_rxf_ov;
+	net_stats->tx_errors = hw_stats->tx_late_col +
+			       hw_stats->tx_abort_col +
+			       hw_stats->tx_underrun +
+			       hw_stats->tx_trunc;
 
-	net_stats->tx_errors = hw_stats->tx_late_col + hw_stats->tx_abort_col +
-				hw_stats->tx_underrun + hw_stats->tx_trunc;
 	net_stats->tx_fifo_errors    = hw_stats->tx_underrun;
 	net_stats->tx_aborted_errors = hw_stats->tx_abort_col;
 	net_stats->tx_window_errors  = hw_stats->tx_late_col;
 
+	net_stats->rx_packets = hw_stats->rx_ok + net_stats->rx_errors;
+	net_stats->tx_packets = hw_stats->tx_ok + net_stats->tx_errors;
+
 	return net_stats;
 }