Subject: Re: [patch 03/14] e1000: omit stats for broken counter in 82543

From: Jeff Garzik <[email-masked]>
Date: Fri, 15 Dec 2006 10:37:39 -0500

Arjan van de Ven wrote:
> Subject: e1000: omit stats for broken counter in 82543
> From: Jesse Brandeburg <[email-masked]>
> 
> The 82543 chip does not count tx_carrier_errors properly in FD mode;
> report zeros instead of garbage.
> 
> Signed-off-by: Jesse Brandeburg <[email-masked]>
> Signed-off-by: Auke Kok <[email-masked]>
> Signed-off-by: Arjan van de Ven <[email-masked]>

I rewrote your patch #3 into the attached patch.  Man, that was hard. 
It was a MAJOR REVISION, trust me.

See attached.  (e1000 even ALREADY HAS some feature flags for this sort 
of thing)

	Jeff

diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 0201ca5..7376609 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -442,6 +442,9 @@ e1000_set_mac_type(struct e1000_hw *hw)
 		break;
 	}
 
+	if (hw->mac_type == e1000_82543)
+		hw->bad_tx_carr_stats_fd = TRUE;
+
 	return E1000_SUCCESS;
 }
 
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 28cdfe3..fef1f7b 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1460,6 +1460,7 @@ struct e1000_hw {
 	boolean_t		mng_reg_access_disabled;
 	boolean_t		leave_av_bit_off;
 	boolean_t		kmrn_lock_loss_workaround_disabled;
+	boolean_t		bad_tx_carr_stats_fd;
 };

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 62ef267..0816de2 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3581,6 +3581,11 @@ e1000_update_stats(struct e1000_adapter *adapter)
 	adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
 	adapter->net_stats.tx_window_errors = adapter->stats.latecol;
 	adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
+	if (adapter->hw.bad_tx_carr_stats_fd &&
+	    adapter->link_duplex == FULL_DUPLEX) {
+		adapter->net_stats.tx_carrier_errors = 0;
+		adapter->stats.tncrs = 0;
+	}
 
 	/* Tx Dropped needs to be maintained elsewhere */