Subject: Re: [patch 13/14] e1000: 3 new driver stats for managability testing

From: Jeff Garzik <[email-masked]>
Date: Fri, 15 Dec 2006 11:17:23 -0500

Arjan van de Ven wrote:
> Subject: e1000: 3 new driver stats for managability testing
> From: Jesse Brandeburg <[email-masked]>
> 
> Add 3 extra packet redirect counters for tracking purposes to make sure we
> can test that all packets arrive properly.
> 
> Signed-off-by: Jesse Brandeburg <[email-masked]>
> Signed-off-by: Auke Kok <[email-masked]>
> Signed-off-by: Arjan van de Ven <[email-masked]>

as revised...

commit 979b575f7666d12157d8b975f022bf8fb6d23c64
Author: Jeff Garzik <[email-masked]>
Date:   Fri Dec 15 11:16:33 2006 -0500

    e1000: 3 new driver stats for managability testing
    
    Add 3 extra packet redirect counters for tracking purposes to make sure
    we can test that all packets arrive properly.
    
    Originally from Jesse Brandeburg <[email-masked]>,
    rewritten to use feature flags by me.
    
    Signed-off-by: Jeff Garzik <[email-masked]>

979b575f7666d12157d8b975f022bf8fb6d23c64
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index da459f7..fb96c87 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -100,6 +100,9 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
 	{ "rx_csum_offload_errors", E1000_STAT(hw_csum_err) },
 	{ "rx_header_split", E1000_STAT(rx_hdr_split) },
 	{ "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) },
+	{ "tx_smbus", E1000_STAT(stats.mgptc) },
+	{ "rx_smbus", E1000_STAT(stats.mgprc) },
+	{ "dropped_smbus", E1000_STAT(stats.mgpdc) },
 };
 
 #define E1000_QUEUE_STATS_LEN 0
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 5a6a61e..9be4469 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -458,6 +458,9 @@ e1000_set_mac_type(struct e1000_hw *hw)
 	if (hw->mac_type == e1000_80003es2lan)
 		hw->rx_needs_kicking = TRUE;
 
+	if (hw->mac_type > e1000_82544)
+		hw->has_smbus = TRUE;
+
 	return E1000_SUCCESS;
 }
 
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 15b8625..d671058 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1464,6 +1464,7 @@ struct e1000_hw {
 	boolean_t		bad_tx_carr_stats_fd;
 	boolean_t		has_manc2h;
 	boolean_t		rx_needs_kicking;
+	boolean_t		has_smbus;
 };

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 3f40a90..b06b51a 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3743,6 +3743,13 @@ e1000_update_stats(struct e1000_adapter *adapter)
 			adapter->phy_stats.receive_errors += phy_tmp;
 	}
 
+	/* Management Stats */
+	if (adapter->hw.has_smbus) {
+		adapter->stats.mgptc += E1000_READ_REG(hw, MGTPTC);
+		adapter->stats.mgprc += E1000_READ_REG(hw, MGTPRC);
+		adapter->stats.mgpdc += E1000_READ_REG(hw, MGTPDC);
+	}
+
 	spin_unlock_irqrestore(&adapter->stats_lock, flags);
 }
 #ifdef CONFIG_PCI_MSI