[PATCH 6/7] e1000e: fix spelling errors in comments

2008-02-21 Thread Auke Kok
Fix some spelling errors and inconsistencies in comment blocks.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/82571.c   |   10 +-
 drivers/net/e1000e/defines.h |   10 +-
 drivers/net/e1000e/hw.h  |4 ++--
 drivers/net/e1000e/ich8lan.c |   24 
 drivers/net/e1000e/lib.c |   16 
 drivers/net/e1000e/netdev.c  |   16 +---
 drivers/net/e1000e/phy.c |   10 +-
 7 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index f7ffd35..7fe2031 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -438,7 +438,7 @@ static void e1000_release_nvm_82571(struct e1000_hw *hw)
  *  For non-82573 silicon, write data to EEPROM at offset using SPI interface.
  *
  *  If e1000e_update_nvm_checksum is not called after this function, the
- *  EEPROM will most likley contain an invalid checksum.
+ *  EEPROM will most likely contain an invalid checksum.
  **/
 static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
 u16 *data)
@@ -547,7 +547,7 @@ static s32 e1000_validate_nvm_checksum_82571(struct 
e1000_hw *hw)
  *  poll for completion.
  *
  *  If e1000e_update_nvm_checksum is not called after this function, the
- *  EEPROM will most likley contain an invalid checksum.
+ *  EEPROM will most likely contain an invalid checksum.
  **/
 static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
  u16 words, u16 *data)
@@ -1053,7 +1053,7 @@ static s32 e1000_setup_fiber_serdes_link_82571(struct 
e1000_hw *hw)
/* If SerDes loopback mode is entered, there is no form
 * of reset to take the adapter out of that mode.  So we
 * have to explicitly take the adapter out of loopback
-* mode.  This prevents drivers from twidling their thumbs
+* mode.  This prevents drivers from twiddling their thumbs
 * if another tool failed to take it out of loopback mode.
 */
ew32(SCTL,
@@ -1098,7 +1098,7 @@ static s32 e1000_valid_led_default_82571(struct e1000_hw 
*hw, u16 *data)
  *  e1000e_get_laa_state_82571 - Get locally administered address state
  *  @hw: pointer to the HW structure
  *
- *  Retrieve and return the current locally administed address state.
+ *  Retrieve and return the current locally administered address state.
  **/
 bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
 {
@@ -1113,7 +1113,7 @@ bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
  *  @hw: pointer to the HW structure
  *  @state: enable/disable locally administered address
  *
- *  Enable/Disable the current locally administed address state.
+ *  Enable/Disable the current locally administers address state.
  **/
 void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
 {
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 6232c3e..a4f511f 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -66,7 +66,7 @@
 #define E1000_WUFC_ARP  0x0020 /* ARP Request Packet Wakeup Enable */
 
 /* Extended Device Control */
-#define E1000_CTRL_EXT_SDP7_DATA 0x0080 /* Value of SW Defineable Pin 7 */
+#define E1000_CTRL_EXT_SDP7_DATA 0x0080 /* Value of SW Definable Pin 7 */
 #define E1000_CTRL_EXT_EE_RST0x2000 /* Reinitialize from EEPROM */
 #define E1000_CTRL_EXT_RO_DIS0x0002 /* Relaxed Ordering disable */
 #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C0
@@ -75,12 +75,12 @@
 #define E1000_CTRL_EXT_IAME   0x0800 /* Interrupt acknowledge 
Auto-mask */
 #define E1000_CTRL_EXT_INT_TIMER_CLR  0x2000 /* Clear Interrupt timers 
after IMS clear */
 
-/* Receive Decriptor bit definitions */
+/* Receive Descriptor bit definitions */
 #define E1000_RXD_STAT_DD   0x01/* Descriptor Done */
 #define E1000_RXD_STAT_EOP  0x02/* End of Packet */
 #define E1000_RXD_STAT_IXSM 0x04/* Ignore checksum */
 #define E1000_RXD_STAT_VP   0x08/* IEEE VLAN Packet */
-#define E1000_RXD_STAT_UDPCS0x10/* UDP xsum caculated */
+#define E1000_RXD_STAT_UDPCS0x10/* UDP xsum calculated */
 #define E1000_RXD_STAT_TCPCS0x20/* TCP xsum calculated */
 #define E1000_RXD_ERR_CE0x01/* CRC Error */
 #define E1000_RXD_ERR_SE0x02/* Symbol Error */
@@ -223,7 +223,7 @@
 #define E1000_STATUS_LAN_INIT_DONE 0x0200   /* Lan Init Completion by NVM 
*/
 #define E1000_STATUS_GIO_MASTER_ENABLE 0x0008 /* Status of Master 
requests. */
 
-/* Constants used to intrepret the masked PCI-X bus speed. */
+/* Constants used to interpret the masked PCI-X bus speed. */
 
 #define HALF_DUPLEX 1
 #define FULL_DUPLEX 2
@@ -517,7 +517,7 @@
 /* PHY 1000 MII Register/Bit Definitions */
 /* PHY Registers defined by IEEE */
 #define PHY_C

[PATCH 2/7] e1000e: 82573 can use eerd method to read eeprom

2008-02-21 Thread Auke Kok
This simplifies the 82571/2/3 family initialization a bit
and removes an initialization table no longer needed.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
Signed-off-by: Jeff Kirsher <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/82571.c |   12 +---
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 3beace5..f7ffd35 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1281,16 +1281,6 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
 
 static struct e1000_nvm_operations e82571_nvm_ops = {
.acquire_nvm= e1000_acquire_nvm_82571,
-   .read_nvm   = e1000e_read_nvm_spi,
-   .release_nvm= e1000_release_nvm_82571,
-   .update_nvm = e1000_update_nvm_checksum_82571,
-   .valid_led_default  = e1000_valid_led_default_82571,
-   .validate_nvm   = e1000_validate_nvm_checksum_82571,
-   .write_nvm  = e1000_write_nvm_82571,
-};
-
-static struct e1000_nvm_operations e82573_nvm_ops = {
-   .acquire_nvm= e1000_acquire_nvm_82571,
.read_nvm   = e1000e_read_nvm_eerd,
.release_nvm= e1000_release_nvm_82571,
.update_nvm = e1000_update_nvm_checksum_82571,
@@ -1355,6 +1345,6 @@ struct e1000_info e1000_82573_info = {
.get_invariants = e1000_get_invariants_82571,
.mac_ops= &e82571_mac_ops,
.phy_ops= &e82_phy_ops_m88,
-   .nvm_ops= &e82573_nvm_ops,
+   .nvm_ops= &e82571_nvm_ops,
 };
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] ixgb: add RNBC counter - no buffer count - to ethtool stats

2008-02-21 Thread Auke Kok
This counter is valuable to determine if the system is unable
to timely return buffers to the hardware and this counter starts
to increase well before the hardware starts to drop packets. If
users experience rx_no_buffer_count increasing, they should increase
the amount of descriptors. That will provide more buffers for the
hardware and will decrease the chance of hard drops.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgb/ixgb_ethtool.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index 53a9fd0..75f3a68 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -67,6 +67,7 @@ static struct ixgb_stats ixgb_gstrings_stats[] = {
{"rx_over_errors", IXGB_STAT(net_stats.rx_over_errors)},
{"rx_crc_errors", IXGB_STAT(net_stats.rx_crc_errors)},
{"rx_frame_errors", IXGB_STAT(net_stats.rx_frame_errors)},
+   {"rx_no_buffer_count", IXGB_STAT(stats.rnbc)},
{"rx_fifo_errors", IXGB_STAT(net_stats.rx_fifo_errors)},
{"rx_missed_errors", IXGB_STAT(net_stats.rx_missed_errors)},
{"tx_aborted_errors", IXGB_STAT(net_stats.tx_aborted_errors)},

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/7] e1000e: fix flow control denial of service possibility

2008-02-21 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

this patch avoids a denial of service from an evildoer sending a
continuous stream of flow control at our adapter that is plugged
into a non-flow control enabled switch.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/lib.c |   31 +--
 1 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 0860b5f..341d74e 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -1104,34 +1104,13 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
mac->fc = e1000_fc_rx_pause;
hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n");
-   }
-   /* Per the IEEE spec, at this point flow control should be
-* disabled.  However, we want to consider that we could
-* be connected to a legacy switch that doesn't advertise
-* desired flow control, but can be forced on the link
-* partner.  So if we advertised no flow control, that is
-* what we will resolve to.  If we advertised some kind of
-* receive capability (Rx Pause Only or Full Flow Control)
-* and the link partner advertised none, we will configure
-* ourselves to enable Rx Flow Control only.  We can do
-* this safely for two reasons:  If the link partner really
-* didn't want flow control enabled, and we enable Rx, no
-* harm done since we won't be receiving any PAUSE frames
-* anyway.  If the intent on the link partner was to have
-* flow control enabled, then by us enabling RX only, we
-* can at least receive pause frames and process them.
-* This is a good idea because in most cases, since we are
-* predominantly a server NIC, more times than not we will
-* be asked to delay transmission of packets than asking
-* our link partner to pause transmission of frames.
-*/
-   else if ((mac->original_fc == e1000_fc_none) ||
-(mac->original_fc == e1000_fc_tx_pause)) {
+   } else {
+   /*
+* Per the IEEE spec, at this point flow control
+* should be disabled.
+*/
mac->fc = e1000_fc_none;
hw_dbg(hw, "Flow Control = NONE.\r\n");
-   } else {
-   mac->fc = e1000_fc_rx_pause;
-   hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n");
}
 
/* Now we need to do one last check...  If we auto-

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] e1000e: remove unused read value in ASPM disable code.

2008-02-21 Thread Auke Kok
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 7824bc2..fc5c63f 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3490,7 +3490,6 @@ static int e1000_suspend(struct pci_dev *pdev, 
pm_message_t state)
 static void e1000e_disable_l1aspm(struct pci_dev *pdev)
 {
int pos;
-   u32 cap;
u16 val;
 
/*
@@ -3505,7 +3504,6 @@ static void e1000e_disable_l1aspm(struct pci_dev *pdev)
 * active.
 */
pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-   pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &cap);
pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val);
if (val & 0x2) {
dev_warn(&pdev->dev, "Disabling L1 ASPM\n");

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] e1000e: fix flow control when using ethtool overrides

2008-02-21 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/lib.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 16f35fa..0860b5f 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -589,9 +589,6 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
s32 ret_val;
u16 nvm_data;
 
-   if (mac->fc != e1000_fc_default)
-   return 0;
-
/* Read and store word 0x0F of the EEPROM. This word contains bits
 * that determine the hardware's default PAUSE (flow control) mode,
 * a bit that determines whether the HW defaults to enabling or

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] e1000e: fix link up message to show ethX:

2008-02-21 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 8b88c22..327c062 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -42,8 +42,7 @@
 struct e1000_info;
 
 #define ndev_printk(level, netdev, format, arg...) \
-   printk(level "%s: %s: " format, (netdev)->dev.parent->bus_id, \
-  (netdev)->name, ## arg)
+   printk(level "%s: " format, (netdev)->name, ## arg)
 
 #ifdef DEBUG
 #define ndev_dbg(netdev, format, arg...) \

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] igb: Fix panic with NICs with 1000BASE-SX PHY

2008-02-19 Thread Auke Kok
From: Bill Hayes <[EMAIL PROTECTED]>

This patch eliminates a kernel panic with the igb driver in 2.6.25-rc2 when 
running on a Intel 82575 Ethernet controller with a 1000BASE-SX PHY.  The 
panic does not happen with the 1000BASE-T PHY, only with a SX connection.  

Signed-off-by: Bill Hayes <[EMAIL PROTECTED]>
Signed-off-by: Andy Gospodarek <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/igb/igb_main.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 3480cc7..6a1f230 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -816,7 +816,8 @@ void igb_reset(struct igb_adapter *adapter)
wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
 
igb_reset_adaptive(&adapter->hw);
-   adapter->hw.phy.ops.get_phy_info(&adapter->hw);
+   if (adapter->hw.phy.ops.get_phy_info)
+   adapter->hw.phy.ops.get_phy_info(&adapter->hw);
 }
 
 /**
@@ -2052,7 +2053,8 @@ static void igb_set_multi(struct net_device *netdev)
 static void igb_update_phy_info(unsigned long data)
 {
struct igb_adapter *adapter = (struct igb_adapter *) data;
-   adapter->hw.phy.ops.get_phy_info(&adapter->hw);
+   if (adapter->hw.phy.ops.get_phy_info)
+   adapter->hw.phy.ops.get_phy_info(&adapter->hw);
 }
 
 /**

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] igb: fix legacy mode irq issue

2008-02-15 Thread Auke Kok
From: Andy Gospodarek <[EMAIL PROTECTED]>

I booted an igb kernel with the option pci=nomsi and instantly noticed
that interrupts no longer worked on my igb device.  I took a look at the
interrupt initialization and quickly discovered a comment stating:

"DO NOT USE EIAME or IAME in legacy mode"

It seemed a bit odd that bits to enable IAM were being set in legacy
interrupt mode, so I dropped out the following parts and interrupts
began working fine again.

[Updated code flow and a nitpick spelling error --Auke]

Signed-off-by: Andy Gospodarek <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/igb/igb_main.c |9 ++---
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index bff280e..3480cc7 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -439,7 +439,7 @@ static int igb_request_irq(struct igb_adapter *adapter)
err = igb_request_msix(adapter);
if (!err) {
/* enable IAM, auto-mask,
-* DO NOT USE EIAME or IAME in legacy mode */
+* DO NOT USE EIAM or IAM in legacy mode */
wr32(E1000_IAM, IMS_ENABLE_MASK);
goto request_done;
}
@@ -465,14 +465,9 @@ static int igb_request_irq(struct igb_adapter *adapter)
err = request_irq(adapter->pdev->irq, &igb_intr, IRQF_SHARED,
  netdev->name, netdev);
 
-   if (err) {
+   if (err)
dev_err(&adapter->pdev->dev, "Error %d getting interrupt\n",
err);
-   goto request_done;
-   }
-
-   /* enable IAM, auto-mask */
-   wr32(E1000_IAM, IMS_ENABLE_MASK);
 
 request_done:
return err;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] igb: PCIe devices do not need to unset MANC_ARP_ENA

2008-02-14 Thread Auke Kok
From: David Graham <[EMAIL PROTECTED]>

Users reported that ARP's were lost with igb. The problem
is fixed by not enabling this manageability configuration
bit.

None of the release_manageability code is actually needed as the
normal device reset during a shutdown returns everthing to
the right condition automatically.

Signed-off-by: David Graham <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/igb/igb_main.c |   28 
 1 files changed, 0 insertions(+), 28 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index d4eb8e2..bff280e 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -606,9 +606,6 @@ static void igb_init_manageability(struct igb_adapter 
*adapter)
u32 manc2h = rd32(E1000_MANC2H);
u32 manc = rd32(E1000_MANC);
 
-   /* disable hardware interception of ARP */
-   manc &= ~(E1000_MANC_ARP_EN);
-
/* enable receiving management packets to the host */
/* this will probably generate destination unreachable messages
 * from the host OS, but the packets will be handled on SMBUS */
@@ -623,25 +620,6 @@ static void igb_init_manageability(struct igb_adapter 
*adapter)
}
 }
 
-static void igb_release_manageability(struct igb_adapter *adapter)
-{
-   struct e1000_hw *hw = &adapter->hw;
-
-   if (adapter->en_mng_pt) {
-   u32 manc = rd32(E1000_MANC);
-
-   /* re-enable hardware interception of ARP */
-   manc |= E1000_MANC_ARP_EN;
-   manc &= ~E1000_MANC_EN_MNG2HOST;
-
-   /* don't explicitly have to mess with MANC2H since
-* MANC has an enable disable that gates MANC2H */
-
-   /* XXX stop the hardware watchdog ? */
-   wr32(E1000_MANC, manc);
-   }
-}
-
 /**
  * igb_configure - configure the hardware for RX and TX
  * @adapter: private board structure
@@ -844,7 +822,6 @@ void igb_reset(struct igb_adapter *adapter)
 
igb_reset_adaptive(&adapter->hw);
adapter->hw.phy.ops.get_phy_info(&adapter->hw);
-   igb_release_manageability(adapter);
 }
 
 /**
@@ -1178,9 +1155,6 @@ static void __devexit igb_remove(struct pci_dev *pdev)
 
flush_scheduled_work();
 
-
-   igb_release_manageability(adapter);
-
/* Release control of h/w to f/w.  If f/w is AMT enabled, this
 * would have already happened in close and is redundant. */
igb_release_hw_control(adapter);
@@ -3955,8 +3929,6 @@ static int igb_suspend(struct pci_dev *pdev, pm_message_t 
state)
pci_enable_wake(pdev, PCI_D3cold, 0);
}
 
-   igb_release_manageability(adapter);
-
/* make sure adapter isn't asleep if manageability is enabled */
if (adapter->en_mng_pt) {
pci_enable_wake(pdev, PCI_D3hot, 1);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] e1000e: PCIe devices do not need to unset MANC_ARP_ENA

2008-02-14 Thread Auke Kok
From: David Graham <[EMAIL PROTECTED]>

Users reported that ARP's were lost with e1000e. The problem
is fixed by not enabling this manageability configuration
bit.

None of the release_manageability code is actually needed as the
normal device reset during a shutdown returns everthing to
the right condition automatically.

Signed-off-by: David Graham <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |   26 --
 1 files changed, 0 insertions(+), 26 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index ea4ecc3..3031d6d 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1055,23 +1055,6 @@ static void e1000_release_hw_control(struct 
e1000_adapter *adapter)
}
 }
 
-static void e1000_release_manageability(struct e1000_adapter *adapter)
-{
-   if (adapter->flags & FLAG_MNG_PT_ENABLED) {
-   struct e1000_hw *hw = &adapter->hw;
-
-   u32 manc = er32(MANC);
-
-   /* re-enable hardware interception of ARP */
-   manc |= E1000_MANC_ARP_EN;
-   manc &= ~E1000_MANC_EN_MNG2HOST;
-
-   /* don't explicitly have to mess with MANC2H since
-* MANC has an enable disable that gates MANC2H */
-   ew32(MANC, manc);
-   }
-}
-
 /**
  * @e1000_alloc_ring - allocate memory for a ring structure
  **/
@@ -1561,9 +1544,6 @@ static void e1000_init_manageability(struct e1000_adapter 
*adapter)
 
manc = er32(MANC);
 
-   /* disable hardware interception of ARP */
-   manc &= ~(E1000_MANC_ARP_EN);
-
/* enable receiving management packets to the host. this will probably
 * generate destination unreachable messages from the host OS, but
 * the packets will be handled on SMBUS */
@@ -2140,8 +2120,6 @@ void e1000e_reset(struct e1000_adapter *adapter)
phy_data &= ~IGP02E1000_PM_SPD;
e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
}
-
-   e1000_release_manageability(adapter);
 }
 
 int e1000e_up(struct e1000_adapter *adapter)
@@ -3487,8 +3465,6 @@ static int e1000_suspend(struct pci_dev *pdev, 
pm_message_t state)
pci_enable_wake(pdev, PCI_D3cold, 0);
}
 
-   e1000_release_manageability(adapter);
-
/* make sure adapter isn't asleep if manageability is enabled */
if (adapter->flags & FLAG_MNG_PT_ENABLED) {
pci_enable_wake(pdev, PCI_D3hot, 1);
@@ -4054,8 +4030,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
 
flush_scheduled_work();
 
-   e1000_release_manageability(adapter);
-
/* Release control of h/w to f/w.  If f/w is AMT enabled, this
 * would have already happened in close and is redundant. */
e1000_release_hw_control(adapter);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000e: Fix CRC stripping in hardware context bug

2008-02-12 Thread Auke Kok
CRC stripping was only correctly enabled for packet split recieves
which is used when receiving jumbo frames. Correctly enable SECRC
also for normal buffer packet receives.

Tested by Andy Gospodarek and Johan Andersson, see bugzilla #9940.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index b9b0d32..ea4ecc3 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1690,6 +1690,9 @@ static void e1000_setup_rctl(struct e1000_adapter 
*adapter)
else
rctl |= E1000_RCTL_LPE;
 
+   /* Enable hardware CRC frame stripping */
+   rctl |= E1000_RCTL_SECRC;
+
/* Setup buffer sizes */
rctl &= ~E1000_RCTL_SZ_4096;
rctl |= E1000_RCTL_BSEX;
@@ -1755,9 +1758,6 @@ static void e1000_setup_rctl(struct e1000_adapter 
*adapter)
 
/* Enable Packet split descriptors */
rctl |= E1000_RCTL_DTYP_PS;
-   
-   /* Enable hardware CRC frame stripping */
-   rctl |= E1000_RCTL_SECRC;
 
psrctl |= adapter->rx_ps_bsize0 >>
E1000_PSRCTL_BSIZE0_SHIFT;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ixgbe: Correctly obtain protocol information on transmit

2008-02-12 Thread Auke Kok
In reply to "RE: [Fwd: [PATCH 2.6.25] ixgbe/igb: correctly obtain protocol
information on transmit]" from Andy Gospodarek:

The driver was incorrectly looking at socket headers for
protocol information, needed for checksumming offload. Fix
this by not looking at the socket but frame headers instead.

This disregards extension headers but it's unclear that linux
generates those anyway.

Tested by Andy Gospodarek.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |   24 +---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 540b647..23d0a4a 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2277,11 +2277,29 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
IXGBE_ADVTXD_DTYP_CTXT);
 
if (skb->ip_summed == CHECKSUM_PARTIAL) {
-   if (skb->protocol == htons(ETH_P_IP))
+   switch (skb->protocol) {
+   case __constant_htons(ETH_P_IP):
type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4;
+   if (ip_hdr(skb)->protocol == IPPROTO_TCP)
+   type_tucmd_mlhl |=
+   IXGBE_ADVTXD_TUCMD_L4T_TCP;
+   break;
+
+   case __constant_htons(ETH_P_IPV6):
+   /* XXX what about other V6 headers?? */
+   if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
+   type_tucmd_mlhl |=
+   IXGBE_ADVTXD_TUCMD_L4T_TCP;
+   break;
 
-   if (skb->sk->sk_protocol == IPPROTO_TCP)
-   type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP;
+   default:
+   if (unlikely(net_ratelimit())) {
+   DPRINTK(PROBE, WARNING,
+"partial checksum but proto=%x!\n",
+skb->protocol);
+   }
+   break;
+   }
}
 
context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] ixgbe: warn when device is in a x4 or lower width slot

2008-02-11 Thread Auke Kok
It's easy to oversee this issue when working with this card
as evrything will work OK but performance is severely limited
(something like 1.5gbit on a x1 link) if the pci-express
slot does not offer more bandwidth.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index ead49e5..576fb51 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2778,6 +2778,14 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
 hw->mac.type, hw->phy.type,
 (part_num >> 8), (part_num & 0xff));
 
+   if (link_width <= IXGBE_PCI_LINK_WIDTH_4) {
+   dev_warn(&pdev->dev, "PCI-Express bandwidth available for "
+"this card is not sufficient for optimal "
+"performance.\n");
+   dev_warn(&pdev->dev, "For optimal performance a x8 "
+"PCI-Express slot is required.\n");
+   }
+
/* reset the hardware with the new settings */
ixgbe_start_hw(hw);
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] e1000: warn if this driver is used for e1000e devices

2008-02-11 Thread Auke Kok
We're already starting to see reports from users still
using e1000 where they should be using e1000e now that this is
actually possible. Just to prevent some of this thrash, add
a big warning on load on these devices that people should
switch to e1000e.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
Acked-by: Jesse Brandeburg <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7c5b05a..81db7fd 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1203,6 +1203,14 @@ e1000_probe(struct pci_dev *pdev,
 
printk("%s\n", print_mac(mac, netdev->dev_addr));
 
+   if (adapter->hw.bus_type == e1000_bus_type_pci_express) {
+   DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
+   "longer be supported by this driver in the future.\n",
+   pdev->vendor, pdev->device);
+   DPRINTK(PROBE, WARNING, "please use the \"e1000e\" "
+   "driver instead.\n");
+   }
+
/* reset the hardware with the new settings */
e1000_reset(adapter);
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] ixgbe: Disallow device reset during ethtool test

2008-02-11 Thread Auke Kok
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 576fb51..a4aeaec 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -1942,6 +1942,10 @@ static int ixgbe_open(struct net_device *netdev)
int err;
u32 num_rx_queues = adapter->num_rx_queues;
 
+   /* disallow open during test */
+   if (test_bit(__IXGBE_TESTING, &adapter->state))
+   return -EBUSY;
+
 try_intr_reinit:
/* allocate transmit descriptors */
err = ixgbe_setup_all_tx_resources(adapter);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] ixgbe: remove accidentally added #ifdef

2008-02-11 Thread Auke Kok
Let's not add these #ifdef NETIF_F_TSO's back.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index a4aeaec..540b647 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -220,7 +220,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter 
*adapter,
tx_ring->stats.bytes += tx_buffer_info->length;
if (cleaned) {
struct sk_buff *skb = tx_buffer_info->skb;
-#ifdef NETIF_F_TSO
unsigned int segs, bytecount;
segs = skb_shinfo(skb)->gso_segs ?: 1;
/* multiply data chunks by size of headers */
@@ -228,10 +227,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter 
*adapter,
skb->len;
total_tx_packets += segs;
total_tx_bytes += bytecount;
-#else
-   total_tx_packets++;
-   total_tx_bytes += skb->len;
-#endif
}
ixgbe_unmap_and_free_tx_resource(adapter,
 tx_buffer_info);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] [NET] replace code with FIELD_SIZEOF

2008-02-11 Thread Auke Kok
From: Julia Lawall <[EMAIL PROTECTED]>

Signed-off-by: Julia Lawall <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_ethtool.c |2 +-
 drivers/net/igb/igb_ethtool.c |2 +-
 drivers/net/ixgb/ixgb_ethtool.c   |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethtool.c 
b/drivers/net/e1000/e1000_ethtool.c
index d876787..85e66f4 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -50,7 +50,7 @@ struct e1000_stats {
int stat_offset;
 };
 
-#define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
+#define E1000_STAT(m) FIELD_SIZEOF(struct e1000_adapter, m), \
  offsetof(struct e1000_adapter, m)
 static const struct e1000_stats e1000_gstrings_stats[] = {
{ "rx_packets", E1000_STAT(stats.gprc) },
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index f69721e..0447f9b 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -43,7 +43,7 @@ struct igb_stats {
int stat_offset;
 };
 
-#define IGB_STAT(m) sizeof(((struct igb_adapter *)0)->m), \
+#define IGB_STAT(m) FIELD_SIZEOF(struct igb_adapter, m), \
  offsetof(struct igb_adapter, m)
 static const struct igb_stats igb_gstrings_stats[] = {
{ "rx_packets", IGB_STAT(stats.gprc) },
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index a267dd8..53a9fd0 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -49,7 +49,7 @@ struct ixgb_stats {
int stat_offset;
 };
 
-#define IXGB_STAT(m) sizeof(((struct ixgb_adapter *)0)->m), \
+#define IXGB_STAT(m) FIELD_SIZEOF(struct ixgb_adapter, m), \
  offsetof(struct ixgb_adapter, m)
 static struct ixgb_stats ixgb_gstrings_stats[] = {
{"rx_packets", IXGB_STAT(net_stats.rx_packets)},

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] e1000e: Fix logic reversal keeping link active

2008-02-11 Thread Auke Kok
A logic mishap caused the adapter to keep link while we can
disable it due to WoL not being active, and vice versa.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index f58f017..b9b0d32 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2008,7 +2008,7 @@ static void e1000_power_down_phy(struct e1000_adapter 
*adapter)
u16 mii_reg;
 
/* WoL is enabled */
-   if (!adapter->wol)
+   if (adapter->wol)
return;
 
/* non-copper PHY? */

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8] ixgbe: fix several counter register errata

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

Several counters behave differently on 82598 causing them to display
incorrect values. Adjust the accounting so the reported numbers
make sense and do not double count or represent the wrong item.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |   53 +++-
 1 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index ee5ee10..6e7d90e 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2026,22 +2026,26 @@ static int ixgbe_close(struct net_device *netdev)
 void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 {
struct ixgbe_hw *hw = &adapter->hw;
-   u64 good_rx, missed_rx, bprc;
+   u64 total_mpc = 0;
+   u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
 
adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
-   good_rx = IXGBE_READ_REG(hw, IXGBE_GPRC);
-   missed_rx = IXGBE_READ_REG(hw, IXGBE_MPC(0));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(1));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(2));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(3));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(4));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(5));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(6));
-   missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(7));
-   adapter->stats.gprc += (good_rx - missed_rx);
-
-   adapter->stats.mpc[0] += missed_rx;
+   for (i = 0; i < 8; i++) {
+   /* for packet buffers not used, the register should read 0 */
+   mpc = IXGBE_READ_REG(hw, IXGBE_MPC(i));
+   missed_rx += mpc;
+   adapter->stats.mpc[i] += mpc;
+   total_mpc += adapter->stats.mpc[i];
+   adapter->stats.rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i));
+   }
+   adapter->stats.gprc += IXGBE_READ_REG(hw, IXGBE_GPRC);
+   /* work around hardware counting issue */
+   adapter->stats.gprc -= missed_rx;
+
+   /* 82598 hardware only has a 32 bit counter in the high register */
adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
+   adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
+   adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORH);
bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
adapter->stats.bprc += bprc;
adapter->stats.mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
@@ -2053,28 +2057,34 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
adapter->stats.prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
adapter->stats.prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
adapter->stats.prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
-
adapter->stats.rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
-   adapter->stats.lxontxc += IXGBE_READ_REG(hw, IXGBE_LXONTXC);
adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
-   adapter->stats.lxofftxc += IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
+   lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
+   adapter->stats.lxontxc += lxon;
+   lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
+   adapter->stats.lxofftxc += lxoff;
adapter->stats.ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
adapter->stats.gptc += IXGBE_READ_REG(hw, IXGBE_GPTC);
-   adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
-   adapter->stats.rnbc[0] += IXGBE_READ_REG(hw, IXGBE_RNBC(0));
+   adapter->stats.mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
+   /*
+* 82598 errata - tx of flow control packets is included in tx counters
+*/
+   xon_off_tot = lxon + lxoff;
+   adapter->stats.gptc -= xon_off_tot;
+   adapter->stats.mptc -= xon_off_tot;
+   adapter->stats.gotc -= (xon_off_tot * (ETH_ZLEN + ETH_FCS_LEN));
adapter->stats.ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
adapter->stats.rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
adapter->stats.rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
-   adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORH);
adapter->stats.tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
adapter->stats.ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
+   adapter->stats.ptc64 -= xon_off_tot;
adapter->stats.ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
adapter->stats.ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
adapter->stats.ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
adapter->stats.ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
adapter->stats.ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
-   adapter->stats.mptc += IXGBE_READ_REG

[PATCH 8/8] ixgbe: add real-time traffic counters

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

Just like our other drivers before we can switch ixgbe to
provide real-time packet/byte counters to the stack easily.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |   15 +++
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 6e7d90e..ead49e5 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -275,6 +275,8 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter 
*adapter,
if (total_tx_packets >= tx_ring->work_limit)
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, tx_ring->eims_value);
 
+   adapter->net_stats.tx_bytes += total_tx_bytes;
+   adapter->net_stats.tx_packets += total_tx_packets;
cleaned = total_tx_packets ? true : false;
return cleaned;
 }
@@ -443,6 +445,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter 
*adapter,
u16 hdr_info, vlan_tag;
bool is_vlan, cleaned = false;
int cleaned_count = 0;
+   unsigned int total_rx_bytes = 0, total_rx_packets = 0;
 
i = rx_ring->next_to_clean;
upper_len = 0;
@@ -522,6 +525,11 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter 
*adapter,
}
 
ixgbe_rx_checksum(adapter, staterr, skb);
+
+   /* probably a little skewed due to removing CRC */
+   total_rx_bytes += skb->len;
+   total_rx_packets++;
+
skb->protocol = eth_type_trans(skb, netdev);
ixgbe_receive_skb(adapter, skb, is_vlan, vlan_tag);
netdev->last_rx = jiffies;
@@ -550,6 +558,9 @@ next_desc:
if (cleaned_count)
ixgbe_alloc_rx_buffers(adapter, rx_ring, cleaned_count);
 
+   adapter->net_stats.rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_packets += total_rx_packets;
+
return cleaned;
 }
 
@@ -2088,10 +2099,6 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
adapter->stats.bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
 
/* Fill out the OS statistics structure */
-   adapter->net_stats.rx_packets = adapter->stats.gprc;
-   adapter->net_stats.tx_packets = adapter->stats.gptc;
-   adapter->net_stats.rx_bytes = adapter->stats.gorc;
-   adapter->net_stats.tx_bytes = adapter->stats.gotc;
adapter->net_stats.multicast = adapter->stats.mprc;
 
/* Rx Errors */

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/8] ixbge: Make ethtool code account for media types

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

The i82598 can support various media types but this ethtool
code only was coded for fiber just yet.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_ethtool.c |   52 ++---
 1 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ixgbe/ixgbe_ethtool.c
index 9f3cdb8..b447dd7 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -103,21 +103,41 @@ static int ixgbe_get_settings(struct net_device *netdev,
  struct ethtool_cmd *ecmd)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
+   struct ixgbe_hw *hw = &adapter->hw;
+   u32 link_speed = 0;
+   bool link_up;
 
-   ecmd->supported = (SUPPORTED_1baseT_Full | SUPPORTED_FIBRE);
-   ecmd->advertising = (ADVERTISED_1baseT_Full | ADVERTISED_FIBRE);
-   ecmd->port = PORT_FIBRE;
+   ecmd->supported = SUPPORTED_1baseT_Full;
+   ecmd->autoneg = AUTONEG_ENABLE;
ecmd->transceiver = XCVR_EXTERNAL;
+   if (hw->phy.media_type == ixgbe_media_type_copper) {
+   ecmd->supported |= (SUPPORTED_1000baseT_Full |
+   SUPPORTED_TP | SUPPORTED_Autoneg);
+
+   ecmd->advertising = (ADVERTISED_TP | ADVERTISED_Autoneg);
+   if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
+   ecmd->advertising |= ADVERTISED_1baseT_Full;
+   if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
+   ecmd->advertising |= ADVERTISED_1000baseT_Full;
+
+   ecmd->port = PORT_TP;
+   } else {
+   ecmd->supported |= SUPPORTED_FIBRE;
+   ecmd->advertising = (ADVERTISED_1baseT_Full |
+ADVERTISED_FIBRE);
+   ecmd->port = PORT_FIBRE;
+   }
 
-   if (netif_carrier_ok(adapter->netdev)) {
-   ecmd->speed = SPEED_1;
+   adapter->hw.mac.ops.check_link(hw, &(link_speed), &link_up);
+   if (link_up) {
+   ecmd->speed = (link_speed == IXGBE_LINK_SPEED_10GB_FULL) ?
+   SPEED_1 : SPEED_1000;
ecmd->duplex = DUPLEX_FULL;
} else {
ecmd->speed = -1;
ecmd->duplex = -1;
}
 
-   ecmd->autoneg = AUTONEG_DISABLE;
return 0;
 }
 
@@ -125,17 +145,17 @@ static int ixgbe_set_settings(struct net_device *netdev,
  struct ethtool_cmd *ecmd)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
+   struct ixgbe_hw *hw = &adapter->hw;
 
-   if (ecmd->autoneg == AUTONEG_ENABLE ||
-   ecmd->speed + ecmd->duplex != SPEED_1 + DUPLEX_FULL)
-   return -EINVAL;
-
-   if (netif_running(adapter->netdev)) {
-   ixgbe_down(adapter);
-   ixgbe_reset(adapter);
-   ixgbe_up(adapter);
-   } else {
-   ixgbe_reset(adapter);
+   switch (hw->phy.media_type) {
+   case ixgbe_media_type_fiber:
+   if ((ecmd->autoneg == AUTONEG_ENABLE) ||
+   (ecmd->speed + ecmd->duplex != SPEED_1 + DUPLEX_FULL))
+   return -EINVAL;
+   /* in this case we currently only support 10Gb/FULL */
+   break;
+   default:
+   break;
}
 
return 0;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] ixgbe: properly return CHECKSUM_NONE, cleanup csum code

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

We were not returning CHECKSUM_NONE in a lot of cases which is
wrong. Move common exit points in this function and error code
up before the actual work in this function.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |   29 ++---
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index c814d9b..ee5ee10 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -304,25 +304,40 @@ static void ixgbe_receive_skb(struct ixgbe_adapter 
*adapter,
}
 }
 
+/**
+ * ixgbe_rx_checksum - indicate in skb if hw indicated a good cksum
+ * @adapter: address of board private structure
+ * @status_err: hardware indication of status of receive
+ * @skb: skb currently being received and modified
+ **/
 static inline void ixgbe_rx_checksum(struct ixgbe_adapter *adapter,
 u32 status_err,
 struct sk_buff *skb)
 {
skb->ip_summed = CHECKSUM_NONE;
 
-   /* Ignore Checksum bit is set */
+   /* Ignore Checksum bit is set, or rx csum disabled */
if ((status_err & IXGBE_RXD_STAT_IXSM) ||
-!(adapter->flags & IXGBE_FLAG_RX_CSUM_ENABLED))
+   !(adapter->flags & IXGBE_FLAG_RX_CSUM_ENABLED))
return;
-   /* TCP/UDP checksum error bit is set */
-   if (status_err & (IXGBE_RXDADV_ERR_TCPE | IXGBE_RXDADV_ERR_IPE)) {
-   /* let the stack verify checksum errors */
+
+   /* if IP and error */
+   if ((status_err & IXGBE_RXD_STAT_IPCS) &&
+   (status_err & IXGBE_RXDADV_ERR_IPE)) {
adapter->hw_csum_rx_error++;
return;
}
+
+   if (!(status_err & IXGBE_RXD_STAT_L4CS))
+   return;
+
+   if (status_err & IXGBE_RXDADV_ERR_TCPE) {
+   adapter->hw_csum_rx_error++;
+   return;
+   }
+
/* It must be a TCP or UDP packet with a valid checksum */
-   if (status_err & (IXGBE_RXD_STAT_L4CS | IXGBE_RXD_STAT_UDPCS))
-   skb->ip_summed = CHECKSUM_UNNECESSARY;
+   skb->ip_summed = CHECKSUM_UNNECESSARY;
adapter->hw_csum_rx_good++;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/8] ixgbe: Fix FW init/release, make this code a function

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

A gap was left in the FW release/grab code in up/down path. Fix
it by making the release/grab code a function and calling it in
appropriate locations.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_main.c |   38 --
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index b4c9c77..c814d9b 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -87,6 +87,25 @@ MODULE_VERSION(DRV_VERSION);
 
 #define DEFAULT_DEBUG_LEVEL_SHIFT 3
 
+static void ixgbe_release_hw_control(struct ixgbe_adapter *adapter)
+{
+   u32 ctrl_ext;
+
+   /* Let firmware take over control of h/w */
+   ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
+   IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT,
+   ctrl_ext & ~IXGBE_CTRL_EXT_DRV_LOAD);
+}
+
+static void ixgbe_get_hw_control(struct ixgbe_adapter *adapter)
+{
+   u32 ctrl_ext;
+
+   /* Let firmware know the driver has taken over */
+   ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
+   IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT,
+   ctrl_ext | IXGBE_CTRL_EXT_DRV_LOAD);
+}
 
 #ifdef DEBUG
 /**
@@ -1204,6 +1223,8 @@ static int ixgbe_up_complete(struct ixgbe_adapter 
*adapter)
u32 txdctl, rxdctl, mhadd;
int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
 
+   ixgbe_get_hw_control(adapter);
+
if (adapter->flags & (IXGBE_FLAG_MSIX_ENABLED |
  IXGBE_FLAG_MSI_ENABLED)) {
if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
@@ -1490,6 +1511,8 @@ static int ixgbe_suspend(struct pci_dev *pdev, 
pm_message_t state)
pci_enable_wake(pdev, PCI_D3hot, 0);
pci_enable_wake(pdev, PCI_D3cold, 0);
 
+   ixgbe_release_hw_control(adapter);
+
pci_disable_device(pdev);
 
pci_set_power_state(pdev, pci_choose_state(pdev, state));
@@ -1891,14 +1914,8 @@ static int ixgbe_open(struct net_device *netdev)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
int err;
-   u32 ctrl_ext;
u32 num_rx_queues = adapter->num_rx_queues;
 
-   /* Let firmware know the driver has taken over */
-   ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
-   IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT,
-   ctrl_ext | IXGBE_CTRL_EXT_DRV_LOAD);
-
 try_intr_reinit:
/* allocate transmit descriptors */
err = ixgbe_setup_all_tx_resources(adapter);
@@ -1949,6 +1966,7 @@ try_intr_reinit:
return 0;
 
 err_up:
+   ixgbe_release_hw_control(adapter);
ixgbe_free_irq(adapter);
 err_req_irq:
ixgbe_free_all_rx_resources(adapter);
@@ -1974,7 +1992,6 @@ err_setup_tx:
 static int ixgbe_close(struct net_device *netdev)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
-   u32 ctrl_ext;
 
ixgbe_down(adapter);
ixgbe_free_irq(adapter);
@@ -1982,9 +1999,7 @@ static int ixgbe_close(struct net_device *netdev)
ixgbe_free_all_tx_resources(adapter);
ixgbe_free_all_rx_resources(adapter);
 
-   ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
-   IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT,
-   ctrl_ext & ~IXGBE_CTRL_EXT_DRV_LOAD);
+   ixgbe_release_hw_control(adapter);
 
return 0;
 }
@@ -2749,6 +2764,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
return 0;
 
 err_register:
+   ixgbe_release_hw_control(adapter);
 err_hw_init:
 err_sw_init:
 err_eeprom:
@@ -2784,6 +2800,8 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
 
unregister_netdev(netdev);
 
+   ixgbe_release_hw_control(adapter);
+
kfree(adapter->tx_ring);
kfree(adapter->rx_ring);
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/8] ixgbe: Fix pause code for ethtool

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe_ethtool.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ixgbe/ixgbe_ethtool.c
index b447dd7..a119cbd 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -167,7 +167,7 @@ static void ixgbe_get_pauseparam(struct net_device *netdev,
struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw;
 
-   pause->autoneg = AUTONEG_DISABLE;
+   pause->autoneg = (hw->fc.type == ixgbe_fc_full ? 1 : 0);
 
if (hw->fc.type == ixgbe_fc_rx_pause) {
pause->rx_pause = 1;
@@ -185,10 +185,8 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw;
 
-   if (pause->autoneg == AUTONEG_ENABLE)
-   return -EINVAL;
-
-   if (pause->rx_pause && pause->tx_pause)
+   if ((pause->autoneg == AUTONEG_ENABLE) ||
+   (pause->rx_pause && pause->tx_pause))
hw->fc.type = ixgbe_fc_full;
else if (pause->rx_pause && !pause->tx_pause)
hw->fc.type = ixgbe_fc_rx_pause;
@@ -196,6 +194,8 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
hw->fc.type = ixgbe_fc_tx_pause;
else if (!pause->rx_pause && !pause->tx_pause)
hw->fc.type = ixgbe_fc_none;
+   else
+   return -EINVAL;
 
hw->fc.original_type = hw->fc.type;
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] ixbge: remove TX lock and redo TX accounting.

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

This ports Herbert Xu's "maybe_stop_tx" code and removes the tx_lock
which is not needed.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe.h  |2 -
 drivers/net/ixgbe/ixgbe_main.c |  110 
 2 files changed, 76 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index 7dd9a03..d0bf206 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -136,8 +136,6 @@ struct ixgbe_ring {
u16 head;
u16 tail;
 
-   /* To protect race between sender and clean_tx_irq */
-   spinlock_t tx_lock;
 
struct ixgbe_queue_stats stats;
 
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 28bb203..b4c9c77 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -165,6 +165,15 @@ static inline bool ixgbe_check_tx_hang(struct 
ixgbe_adapter *adapter,
return false;
 }
 
+#define IXGBE_MAX_TXD_PWR  14
+#define IXGBE_MAX_DATA_PER_TXD (1 << IXGBE_MAX_TXD_PWR)
+
+/* Tx Descriptors needed, worst case */
+#define TXD_USE_COUNT(S) (((S) >> IXGBE_MAX_TXD_PWR) + \
+(((S) & (IXGBE_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
+#define DESC_NEEDED (TXD_USE_COUNT(IXGBE_MAX_DATA_PER_TXD) /* skb->data */ + \
+   MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1)   /* for context */
+
 /**
  * ixgbe_clean_tx_irq - Reclaim resources after transmit completes
  * @adapter: board private structure
@@ -177,18 +186,34 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter 
*adapter,
struct ixgbe_tx_buffer *tx_buffer_info;
unsigned int i, eop;
bool cleaned = false;
-   int count = 0;
+   unsigned int total_tx_bytes = 0, total_tx_packets = 0;
 
i = tx_ring->next_to_clean;
eop = tx_ring->tx_buffer_info[i].next_to_watch;
eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop);
while (eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) {
-   for (cleaned = false; !cleaned;) {
+   cleaned = false;
+   while (!cleaned) {
tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i);
tx_buffer_info = &tx_ring->tx_buffer_info[i];
cleaned = (i == eop);
 
tx_ring->stats.bytes += tx_buffer_info->length;
+   if (cleaned) {
+   struct sk_buff *skb = tx_buffer_info->skb;
+#ifdef NETIF_F_TSO
+   unsigned int segs, bytecount;
+   segs = skb_shinfo(skb)->gso_segs ?: 1;
+   /* multiply data chunks by size of headers */
+   bytecount = ((segs - 1) * skb_headlen(skb)) +
+   skb->len;
+   total_tx_packets += segs;
+   total_tx_bytes += bytecount;
+#else
+   total_tx_packets++;
+   total_tx_bytes += skb->len;
+#endif
+   }
ixgbe_unmap_and_free_tx_resource(adapter,
 tx_buffer_info);
tx_desc->wb.status = 0;
@@ -204,29 +229,34 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter 
*adapter,
eop_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop);
 
/* weight of a sort for tx, avoid endless transmit cleanup */
-   if (count++ >= tx_ring->work_limit)
+   if (total_tx_packets >= tx_ring->work_limit)
break;
}
 
tx_ring->next_to_clean = i;
 
-#define TX_WAKE_THRESHOLD 32
-   spin_lock(&tx_ring->tx_lock);
-
-   if (cleaned && netif_carrier_ok(netdev) &&
-   (IXGBE_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD) &&
-   !test_bit(__IXGBE_DOWN, &adapter->state))
-   netif_wake_queue(netdev);
-
-   spin_unlock(&tx_ring->tx_lock);
+#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2)
+   if (total_tx_packets && netif_carrier_ok(netdev) &&
+   (IXGBE_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
+   /* Make sure that anybody stopping the queue after this
+* sees the new next_to_clean.
+*/
+   smp_mb();
+   if (netif_queue_stopped(netdev) &&
+   !test_bit(__IXGBE_DOWN, &adapter->state)) {
+   netif_wake_queue(netdev);
+   adapter->restart_queue++;
+   }
+   }
 
if (adapter->detect_tx_hung)
   

[PATCH 1/8] ixgbe: remove obsolete irq_sem, add driver state checking code

2008-02-01 Thread Auke Kok
From: Ayyappan Veeraiyan <[EMAIL PROTECTED]>

After testing we confirmed that the irq_sem can safely be
removed from ixgbe.

Add strict state checking code to various ethtool parts to
properly protect against races between various driver reset
paths.

Signed-off-by: Ayyappan Veeraiyan <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe.h |2 +
 drivers/net/ixgbe/ixgbe_ethtool.c |   29 --
 drivers/net/ixgbe/ixgbe_main.c|   60 ++---
 3 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index a021a6e..7dd9a03 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -174,7 +174,6 @@ struct ixgbe_adapter {
struct vlan_group *vlgrp;
u16 bd_number;
u16 rx_buf_len;
-   atomic_t irq_sem;
struct work_struct reset_task;
 
/* TX */
@@ -244,6 +243,7 @@ extern const char ixgbe_driver_version[];
 
 extern int ixgbe_up(struct ixgbe_adapter *adapter);
 extern void ixgbe_down(struct ixgbe_adapter *adapter);
+extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
 extern void ixgbe_reset(struct ixgbe_adapter *adapter);
 extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);
 extern void ixgbe_set_ethtool_ops(struct net_device *netdev);
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ixgbe/ixgbe_ethtool.c
index 3635344..9f3cdb8 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -179,12 +179,10 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
 
hw->fc.original_type = hw->fc.type;
 
-   if (netif_running(adapter->netdev)) {
-   ixgbe_down(adapter);
-   ixgbe_up(adapter);
-   } else {
+   if (netif_running(netdev))
+   ixgbe_reinit_locked(adapter);
+   else
ixgbe_reset(adapter);
-   }
 
return 0;
 }
@@ -203,12 +201,10 @@ static int ixgbe_set_rx_csum(struct net_device *netdev, 
u32 data)
else
adapter->flags &= ~IXGBE_FLAG_RX_CSUM_ENABLED;
 
-   if (netif_running(netdev)) {
-   ixgbe_down(adapter);
-   ixgbe_up(adapter);
-   } else {
+   if (netif_running(netdev))
+   ixgbe_reinit_locked(adapter);
+   else
ixgbe_reset(adapter);
-   }
 
return 0;
 }
@@ -662,7 +658,10 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
return 0;
}
 
-   if (netif_running(adapter->netdev))
+   while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
+   msleep(1);
+
+   if (netif_running(netdev))
ixgbe_down(adapter);
 
/*
@@ -733,6 +732,7 @@ err_setup:
if (netif_running(adapter->netdev))
ixgbe_up(adapter);
 
+   clear_bit(__IXGBE_RESETTING, &adapter->state);
return err;
 }
 
@@ -820,11 +820,8 @@ static int ixgbe_nway_reset(struct net_device *netdev)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
 
-   if (netif_running(netdev)) {
-   ixgbe_down(adapter);
-   ixgbe_reset(adapter);
-   ixgbe_up(adapter);
-   }
+   if (netif_running(netdev))
+   ixgbe_reinit_locked(adapter);
 
return 0;
 }
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 3732dd6..28bb203 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -535,7 +535,9 @@ static irqreturn_t ixgbe_msix_lsc(int irq, void *data)
if (!test_bit(__IXGBE_DOWN, &adapter->state))
mod_timer(&adapter->watchdog_timer, jiffies);
}
-   IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
+
+   if (!test_bit(__IXGBE_DOWN, &adapter->state))
+   IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
 
return IRQ_HANDLED;
 }
@@ -713,7 +715,6 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
/* Disable interrupts and register for poll. The flush of the
 * posted write is intentionally left out. */
-   atomic_inc(&adapter->irq_sem);
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
__netif_rx_schedule(netdev, &adapter->napi);
}
@@ -801,7 +802,6 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
  **/
 static inline void ixgbe_irq_disable(struct ixgbe_adapter *adapter)
 {
-   atomic_inc(&adapter->irq_sem);
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
IXGBE_WRITE_FLUSH(&adapter->hw);
synchronize_irq(adapter->pdev->irq);
@@ -813,15 +813,13 @@ static inline void 

[PATCH 1/6] e1000e: make a function static

2008-02-01 Thread Auke Kok
From: Adrian Bunk <[EMAIL PROTECTED]>

This patch makes the needlessly global reg_pattern_test_array() static.

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 6d9c27f..a2034cf 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -690,8 +690,8 @@ err_setup:
return err;
 }
 
-bool reg_pattern_test_array(struct e1000_adapter *adapter, u64 *data,
-   int reg, int offset, u32 mask, u32 write)
+static bool reg_pattern_test_array(struct e1000_adapter *adapter, u64 *data,
+  int reg, int offset, u32 mask, u32 write)
 {
int i;
u32 read;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] e100: fix spelling errors

2008-02-01 Thread Auke Kok
From: Andreas Mohr <[EMAIL PROTECTED]>

Signed-off-by: Andreas Mohr <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e100.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 9d42dd8..36ba6dc 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -94,7 +94,7 @@
  * enabled.  82557 pads with 7Eh, while the later controllers pad
  * with 00h.
  *
- * IV.  Recieve
+ * IV.  Receive
  *
  * The Receive Frame Area (RFA) comprises a ring of Receive Frame
  * Descriptors (RFD) + data buffer, thus forming the simplified mode
@@ -120,7 +120,7 @@
  * and Rx indication and re-allocation happen in the same context,
  * therefore no locking is required.  A software-generated interrupt
  * is generated from the watchdog to recover from a failed allocation
- * senario where all Rx resources have been indicated and none re-
+ * scenario where all Rx resources have been indicated and none re-
  * placed.
  *
  * V.   Miscellaneous
@@ -954,7 +954,7 @@ static void e100_get_defaults(struct nic *nic)
/* Quadwords to DMA into FIFO before starting frame transmit */
nic->tx_threshold = 0xE0;
 
-   /* no interrupt for every tx completion, delay = 256us if not 557*/
+   /* no interrupt for every tx completion, delay = 256us if not 557 */
nic->tx_command = cpu_to_le16(cb_tx | cb_tx_sf |
((nic->mac >= mac_82558_D101_A4) ? cb_cid : cb_i));
 
@@ -1497,7 +1497,7 @@ static void e100_update_stats(struct nic *nic)
&s->complete;
 
/* Device's stats reporting may take several microseconds to
-* complete, so where always waiting for results of the
+* complete, so we're always waiting for results of the
 * previous command. */
 
if(*complete == cpu_to_le32(cuc_dump_reset_complete)) {
@@ -2858,17 +2858,17 @@ static void e100_shutdown(struct pci_dev *pdev)
 /**
  * e100_io_error_detected - called when PCI error is detected.
  * @pdev: Pointer to PCI device
- * @state: The current pci conneection state
+ * @state: The current pci connection state
  */
 static pci_ers_result_t e100_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state)
 {
struct net_device *netdev = pci_get_drvdata(pdev);
struct nic *nic = netdev_priv(netdev);
 
-   /* Similar to calling e100_down(), but avoids adpater I/O. */
+   /* Similar to calling e100_down(), but avoids adapter I/O. */
netdev->stop(netdev);
 
-   /* Detach; put netif into state similar to hotplug unplug. */
+   /* Detach; put netif into a state similar to hotplug unplug. */
napi_enable(&nic->napi);
netif_device_detach(netdev);
pci_disable_device(pdev);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] igb: remove unneeded declaration shadowing earlier one

2008-02-01 Thread Auke Kok
This removes a sparse warning.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/igb/igb_main.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index f3c144d..d4eb8e2 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -438,7 +438,6 @@ static int igb_request_irq(struct igb_adapter *adapter)
if (adapter->msix_entries) {
err = igb_request_msix(adapter);
if (!err) {
-   struct e1000_hw *hw = &adapter->hw;
/* enable IAM, auto-mask,
 * DO NOT USE EIAME or IAME in legacy mode */
wr32(E1000_IAM, IMS_ENABLE_MASK);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] e1000e: tweak irq allocation messages

2008-02-01 Thread Auke Kok
From: Andy Gospodarek <[EMAIL PROTECTED]>

There's too much noise on systems that don't support MSI.  Let's get rid
of a few and make the real error message more specific.

Signed-off-by: Andy Gospodarek <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |   12 +---
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 0a2cb79..f58f017 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -945,11 +945,7 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
int irq_flags = IRQF_SHARED;
int err;
 
-   err = pci_enable_msi(adapter->pdev);
-   if (err) {
-   ndev_warn(netdev,
-"Unable to allocate MSI interrupt Error: %d\n", err);
-   } else {
+   if (!pci_enable_msi(adapter->pdev)) {
adapter->flags |= FLAG_MSI_ENABLED;
handler = e1000_intr_msi;
irq_flags = 0;
@@ -958,10 +954,12 @@ static int e1000_request_irq(struct e1000_adapter 
*adapter)
err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
  netdev);
if (err) {
+   ndev_err(netdev,
+  "Unable to allocate %s interrupt (return: %d)\n",
+   adapter->flags & FLAG_MSI_ENABLED ? "MSI":"INTx",
+   err);
if (adapter->flags & FLAG_MSI_ENABLED)
pci_disable_msi(adapter->pdev);
-   ndev_err(netdev,
-  "Unable to allocate interrupt Error: %d\n", err);
}
 
return err;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] e100: Fix iomap mem accesses

2008-02-01 Thread Auke Kok
From: Jiri Slaby <[EMAIL PROTECTED]>

writeX functions are not permitted on iomap-ped space change to iowriteX,
also pci_unmap pci_map-ped space on exit (instead of iounmap).

Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e100.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 51cf577..9d42dd8 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1958,7 +1958,7 @@ static void e100_rx_clean(struct nic *nic, unsigned int 
*work_done,
 
if(restart_required) {
// ack the rnr?
-   writeb(stat_ack_rnr, &nic->csr->scb.stat_ack);
+   iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack);
e100_start_receiver(nic, nic->rx_to_clean);
if(work_done)
(*work_done)++;
@@ -2774,7 +2774,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
struct nic *nic = netdev_priv(netdev);
unregister_netdev(netdev);
e100_free(nic);
-   iounmap(nic->csr);
+   pci_iounmap(pdev, nic->csr);
free_netdev(netdev);
pci_release_regions(pdev);
pci_disable_device(pdev);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] e1000: make e1000_dump_eeprom() static

2008-02-01 Thread Auke Kok
From: Adrian Bunk <[EMAIL PROTECTED]>

This patch makes the needlessly global e1000_dump_eeprom() static.

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 8c87940..7c5b05a 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -853,7 +853,7 @@ e1000_reset(struct e1000_adapter *adapter)
 /**
  *  Dump the eeprom for users having checksum issues
  **/
-void e1000_dump_eeprom(struct e1000_adapter *adapter)
+static void e1000_dump_eeprom(struct e1000_adapter *adapter)
 {
struct net_device *netdev = adapter->netdev;
struct ethtool_eeprom eeprom;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] intel ethernet drivers: update MAINTAINERS

2008-01-07 Thread Auke Kok
Unfortunately Jeb decided to move away from our group. We wish
Jeb good luck with his new group!

Reordered people a bit so most active team members are on top.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 MAINTAINERS |   18 --
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index efdef65..087b871 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1982,29 +1982,27 @@ L:  netdev@vger.kernel.org
 S: Maintained
 
 INTEL PRO/100 ETHERNET SUPPORT
-P: John Ronciak
-M: [EMAIL PROTECTED]
+P:     Auke Kok
+M: [EMAIL PROTECTED]
 P: Jesse Brandeburg
 M: [EMAIL PROTECTED]
 P: Jeff Kirsher
 M: [EMAIL PROTECTED]
-P:     Auke Kok
-M: [EMAIL PROTECTED]
+P: John Ronciak
+M: [EMAIL PROTECTED]
 L: [EMAIL PROTECTED]
 W: http://sourceforge.net/projects/e1000/
 S: Supported
 
 INTEL PRO/1000 GIGABIT ETHERNET SUPPORT
-P: Jeb Cramer
-M: [EMAIL PROTECTED]
-P: John Ronciak
-M: [EMAIL PROTECTED]
+P:     Auke Kok
+M: [EMAIL PROTECTED]
 P: Jesse Brandeburg
 M: [EMAIL PROTECTED]
 P: Jeff Kirsher
 M: [EMAIL PROTECTED]
-P:     Auke Kok
-M: [EMAIL PROTECTED]
+P: John Ronciak
+M: [EMAIL PROTECTED]
 L: [EMAIL PROTECTED]
 W: http://sourceforge.net/projects/e1000/
 S: Supported

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] ethtool: fix typo on setting speed 10000

2008-01-07 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

fix the typo in speed 1 setting.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 3adf843..a668b49 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -524,7 +524,7 @@ static void parse_cmdline(int argc, char **argp)
speed_wanted = SPEED_1000;
else if (!strcmp(argp[i], "2500"))
speed_wanted = SPEED_2500;
-   else if (!strcmp(argp[1], "1"))
+   else if (!strcmp(argp[i], "1"))
speed_wanted = SPEED_1;
else
show_usage(1);

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] ethtool: update license field in specfile to be correctly defined

2008-01-07 Thread Auke Kok
RPM uses "License" as field and not "Copyright".

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.spec.in |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ethtool.spec.in b/ethtool.spec.in
index 1705d7f..4ff736a 100644
--- a/ethtool.spec.in
+++ b/ethtool.spec.in
@@ -5,7 +5,7 @@ Group   : Utilities
 
 Summary: A tool for setting ethernet parameters
 
-Copyright  : GPL
+License: GPL
 URL: http://sourceforge.net/projects/gkernel/
 
 Buildroot  : %{_tmppath}/%{name}-%{version}

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ethtool: correct man page for advertise mask value of 10gig

2008-01-07 Thread Auke Kok
10 gigabit is defined as 0x1000 in the advertise mask. The man
page mistakenly lists 0x800.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.8 |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ethtool.8 b/ethtool.8
index af51056..cc6a46e 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -362,7 +362,7 @@ a hexidecimal value using one or a combination of the 
following values:
 .TP 3
 .BR "0x8000" "   2500 Full" "(not supported by IEEE standards)"
 .TP 3
-.BR "0x800" "1 Full"
+.BR "0x1000" "   1 Full"
 .TP 3
 .BR "0x03F" "Auto"
 .PD

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] e1000e: Use deferrable timer for watchdog

2007-12-20 Thread Auke Kok
From: Parag Warudkar <[EMAIL PROTECTED]>

Reduce wakeups from idle per second.

Signed-off-by: Parag Warudkar <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 2422d16..59960d2 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3931,7 +3931,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
goto err_eeprom;
}
 
-   init_timer(&adapter->watchdog_timer);
+   init_timer_deferrable(&adapter->watchdog_timer);
adapter->watchdog_timer.function = &e1000_watchdog;
adapter->watchdog_timer.data = (unsigned long) adapter;
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] e1000: Use deferrable timer for watchdog

2007-12-20 Thread Auke Kok
From: Parag Warudkar <[EMAIL PROTECTED]>

Reduces wakeups from idle per second.

Signed-off-by: Parag Warudkar <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 599153d..6af86fa 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1066,7 +1066,7 @@ e1000_probe(struct pci_dev *pdev,
adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
 
-   init_timer(&adapter->watchdog_timer);
+   init_timer_deferrable(&adapter->watchdog_timer);
adapter->watchdog_timer.function = &e1000_watchdog;
adapter->watchdog_timer.data = (unsigned long) adapter;
 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000: Dump the eeprom when a user encounters a bad checksum

2007-12-17 Thread Auke Kok
To help supporting users with a bad eeprom checksum, dump the
eeprom info when such a situation is encountered by a user.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |   85 +++-
 1 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index efd8c2d..aac55be 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -817,6 +817,64 @@ e1000_reset(struct e1000_adapter *adapter)
 }
 
 /**
+ *  Dump the eeprom for users having checksum issues
+ **/
+void e1000_dump_eeprom(struct e1000_adapter *adapter)
+{
+   struct net_device *netdev = adapter->netdev;
+   struct ethtool_eeprom eeprom;
+   const struct ethtool_ops *ops = netdev->ethtool_ops;
+   u8 *data;
+   int i;
+   u16 csum_old, csum_new = 0;
+
+   eeprom.len = ops->get_eeprom_len(netdev);
+   eeprom.offset = 0;
+
+   data = kmalloc(eeprom.len, GFP_KERNEL);
+   if (!data) {
+   printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
+  " data\n");
+   return;
+   }
+
+   ops->get_eeprom(netdev, &eeprom, data);
+
+   csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
+  (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
+   for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
+   csum_new += data[i] + (data[i + 1] << 8);
+   csum_new = EEPROM_SUM - csum_new;
+
+   printk(KERN_ERR "/*/\n");
+   printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
+   printk(KERN_ERR "Calculated  : 0x%04x\n", csum_new);
+
+   printk(KERN_ERR "OffsetValues\n");
+   printk(KERN_ERR "  ==\n");
+   print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
+
+   printk(KERN_ERR "Include this output when contacting your support "
+  "provider.\n");
+   printk(KERN_ERR "This is not a software error! Something bad "
+  "happened to your hardware or\n");
+   printk(KERN_ERR "EEPROM image. Ignoring this "
+  "problem could result in further problems,\n");
+   printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
+   printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
+  "which is invalid\n");
+   printk(KERN_ERR "and requires you to set the proper MAC "
+  "address manually before continuing\n");
+   printk(KERN_ERR "to enable this network device.\n");
+   printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
+  "to your hardware vendor\n");
+   printk(KERN_ERR "or Intel Customer Support: [EMAIL PROTECTED]");
+   printk(KERN_ERR "/*/\n");
+
+   kfree(data);
+}
+
+/**
  * e1000_probe - Device Initialization Routine
  * @pdev: PCI device information struct
  * @ent: entry in e1000_pci_tbl
@@ -967,7 +1025,6 @@ e1000_probe(struct pci_dev *pdev,
adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
 
/* initialize eeprom parameters */
-
if (e1000_init_eeprom_params(&adapter->hw)) {
E1000_ERR("EEPROM initialization failed\n");
goto err_eeprom;
@@ -979,23 +1036,29 @@ e1000_probe(struct pci_dev *pdev,
e1000_reset_hw(&adapter->hw);
 
/* make sure the EEPROM is good */
-
if (e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
-   goto err_eeprom;
+   e1000_dump_eeprom(adapter);
+   /*
+* set MAC address to all zeroes to invalidate and temporary
+* disable this device for the user. This blocks regular
+* traffic while still permitting ethtool ioctls from reaching
+* the hardware as well as allowing the user to run the
+* interface after manually setting a hw addr using
+* `ip set address`
+*/
+   memset(adapter->hw.mac_addr, 0, netdev->addr_len);
+   } else {
+   /* copy the MAC address out of the EEPROM */
+   if (e1000_read_mac_addr(&adapter->hw))
+   DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
}
-
-   /* copy the MAC address out of the EEPROM */
-
-   if (e1000_read_mac_addr(&adapter->hw))
-   DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
+   /* don

[PATCH] e1000: Dump the eeprom when a user encounters a bad checksum

2007-12-14 Thread Auke Kok
To help supporting users with a bad eeprom checksum, dump the
eeprom info when such a situation is encountered by a user.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |   90 +++-
 1 files changed, 79 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index efd8c2d..2dab1a6 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -817,6 +817,69 @@ e1000_reset(struct e1000_adapter *adapter)
 }
 
 /**
+ *  Dump the eeprom for users having checksum issues
+ **/
+void e1000_dump_eeprom(struct e1000_adapter *adapter)
+{
+   struct net_device *netdev = adapter->netdev;
+   struct ethtool_eeprom eeprom;
+   const struct ethtool_ops *ops = netdev->ethtool_ops;
+   u8 *data;
+   int i;
+   u16 csum_old, csum_new = 0;
+
+   eeprom.len = ops->get_eeprom_len(netdev);
+   eeprom.offset = 0;
+
+   data = kmalloc(eeprom.len, GFP_KERNEL);
+   if (!data) {
+   printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
+  " data\n");
+   return;
+   }
+
+   ops->get_eeprom(netdev, &eeprom, data);
+
+   csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
+  (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
+   for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
+   csum_new += data[i] + (data[i + 1] << 8);
+   csum_new = EEPROM_SUM - csum_new;
+
+   printk(KERN_ERR "/*/\n");
+   printk(KERN_ERR "Current EEPROM: 0x%04x\nCalculated: 0x%04x\n",
+  csum_old, csum_new);
+
+   printk(KERN_ERR "Offset   Values\n");
+   printk(KERN_ERR "==   ==\n");
+   for (i = 0; i < eeprom.len; i += 16)
+   printk(KERN_ERR "0x%04x   "
+  "%02x %02x %02x %02x %02x %02x %02x %02x "
+  "%02x %02x %02x %02x %02x %02x %02x %02x\n",
+  i, data[i], data[i + 1], data[i + 2], data[i + 3],
+  data[i + 4], data[i + 5], data[i + 6], data[i + 7],
+  data[i + 8], data[i + 9], data[i + 10], data[i + 11],
+  data[i + 12], data[i + 13], data[i + 14], data[i + 15]);
+
+   printk(KERN_ERR "Include this output when contacting your support "
+  "provider.\n\nThis is not a software error! Something bad "
+  "happened to your hardware or\nEEPROM image. Ignoring this "
+  "problem could result in further problems,\npossibly loss "
+  "of data, corruption or system hangs!\n\n");
+   printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
+  "which is invalid\nand requires you to set the proper MAC "
+  "address manually before continuing\nto enable this network "
+  "device.\n\n");
+   printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
+  "to your hardware vendor\nor Intel Customer Support: "
+  "[EMAIL PROTECTED]");
+
+   printk(KERN_ERR "/*/\n");
+
+   kfree(data);
+}
+
+/**
  * e1000_probe - Device Initialization Routine
  * @pdev: PCI device information struct
  * @ent: entry in e1000_pci_tbl
@@ -967,7 +1030,6 @@ e1000_probe(struct pci_dev *pdev,
adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
 
/* initialize eeprom parameters */
-
if (e1000_init_eeprom_params(&adapter->hw)) {
E1000_ERR("EEPROM initialization failed\n");
goto err_eeprom;
@@ -979,23 +1041,29 @@ e1000_probe(struct pci_dev *pdev,
e1000_reset_hw(&adapter->hw);
 
/* make sure the EEPROM is good */
-
if (e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
-   goto err_eeprom;
+   e1000_dump_eeprom(adapter);
+   /*
+* set MAC address to all zeroes to invalidate and temporary
+* disable this device for the user. This blocks regular
+* traffic while still permitting ethtool ioctls from reaching
+* the hardware as well as allowing the user to run the
+* interface after manually setting a hw addr using
+* `ip set address`
+*/
+   memset(adapter->hw.mac_addr, 0, netdev->addr_len);
+   } else {
+   /* copy the MAC address out of the EEPROM */
+   if (e1000_read_mac_addr(&adapter->hw))
+ 

[PATCH 1/2] ixgb: make sure jumbos stay enabled after reset

2007-12-14 Thread Auke Kok
From: Matheos Worku <[EMAIL PROTECTED]>

Currently a device reset (ethtool -r ethX) would cause the
adapter to fall back to regular MTU sizes.

Signed-off-by: Matheos Worku <[EMAIL PROTECTED]>
Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgb/ixgb_main.c |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 3021234..bf9085f 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -320,10 +320,22 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t 
kill_watchdog)
 void
 ixgb_reset(struct ixgb_adapter *adapter)
 {
+   struct ixgb_hw *hw = &adapter->hw;
 
-   ixgb_adapter_stop(&adapter->hw);
-   if(!ixgb_init_hw(&adapter->hw))
+   ixgb_adapter_stop(hw);
+   if (!ixgb_init_hw(hw))
DPRINTK(PROBE, ERR, "ixgb_init_hw failed.\n");
+
+   /* restore frame size information */
+   IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
+   if (hw->max_frame_size >
+   IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
+   u32 ctrl0 = IXGB_READ_REG(hw, CTRL0);
+   if (!(ctrl0 & IXGB_CTRL0_JFE)) {
+   ctrl0 |= IXGB_CTRL0_JFE;
+   IXGB_WRITE_REG(hw, CTRL0, ctrl0);
+   }
+   }
 }
 
 /**

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ixgb: enable sun hardware support for broadcom phy

2007-12-14 Thread Auke Kok
From: Matheos Worku <[EMAIL PROTECTED]>

Implement support for a SUN-specific PHY.

SUN provides a modified 82597-based board with their own
PHY that works with very little modification to the code. This
patch implements this new PHY which is identified by the
subvendor device ID. The device ID of the adapter remains
the same.

Signed-off-by: Matheos Worku <[EMAIL PROTECTED]>
Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgb/ixgb_hw.c   |   82 +-
 drivers/net/ixgb/ixgb_hw.h   |3 +-
 drivers/net/ixgb/ixgb_ids.h  |4 ++
 drivers/net/ixgb/ixgb_main.c |   10 +++--
 4 files changed, 91 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
index 2c6367a..80a8b98 100644
--- a/drivers/net/ixgb/ixgb_hw.c
+++ b/drivers/net/ixgb/ixgb_hw.c
@@ -45,6 +45,8 @@ static boolean_t ixgb_link_reset(struct ixgb_hw *hw);
 
 static void ixgb_optics_reset(struct ixgb_hw *hw);
 
+static void ixgb_optics_reset_bcm(struct ixgb_hw *hw);
+
 static ixgb_phy_type ixgb_identify_phy(struct ixgb_hw *hw);
 
 static void ixgb_clear_hw_cntrs(struct ixgb_hw *hw);
@@ -90,10 +92,20 @@ static uint32_t ixgb_mac_reset(struct ixgb_hw *hw)
ASSERT(!(ctrl_reg & IXGB_CTRL0_RST));
 #endif
 
-   if (hw->phy_type == ixgb_phy_type_txn17401) {
-   ixgb_optics_reset(hw);
+   if (hw->subsystem_vendor_id == SUN_SUBVENDOR_ID) {
+   ctrl_reg =  /* Enable interrupt from XFP and SerDes */
+  IXGB_CTRL1_GPI0_EN |
+  IXGB_CTRL1_SDP6_DIR |
+  IXGB_CTRL1_SDP7_DIR |
+  IXGB_CTRL1_SDP6 |
+  IXGB_CTRL1_SDP7;
+   IXGB_WRITE_REG(hw, CTRL1, ctrl_reg);
+   ixgb_optics_reset_bcm(hw);
}
 
+   if (hw->phy_type == ixgb_phy_type_txn17401)
+   ixgb_optics_reset(hw);
+
return ctrl_reg;
 }
 
@@ -253,6 +265,10 @@ ixgb_identify_phy(struct ixgb_hw *hw)
break;
}
 
+   /* update phy type for sun specific board */
+   if (hw->subsystem_vendor_id == SUN_SUBVENDOR_ID)
+   phy_type = ixgb_phy_type_bcm;
+
return (phy_type);
 }
 
@@ -1225,3 +1241,65 @@ ixgb_optics_reset(struct ixgb_hw *hw)
 
return;
 }
+
+/**
+ * Resets the 10GbE optics module for Sun variant NIC.
+ *
+ * hw - Struct containing variables accessed by shared code
+ */
+
+#define   IXGB_BCM8704_USER_PMD_TX_CTRL_REG 0xC803
+#define   IXGB_BCM8704_USER_PMD_TX_CTRL_REG_VAL 0x0164
+#define   IXGB_BCM8704_USER_CTRL_REG0xC800
+#define   IXGB_BCM8704_USER_CTRL_REG_VAL0x7FBF
+#define   IXGB_BCM8704_USER_DEV3_ADDR   0x0003
+#define   IXGB_SUN_PHY_ADDRESS  0x
+#define   IXGB_SUN_PHY_RESET_DELAY 305
+
+static void
+ixgb_optics_reset_bcm(struct ixgb_hw *hw)
+{
+   u32 ctrl = IXGB_READ_REG(hw, CTRL0);
+   ctrl &= ~IXGB_CTRL0_SDP2;
+   ctrl |= IXGB_CTRL0_SDP3;
+   IXGB_WRITE_REG(hw, CTRL0, ctrl);
+
+   /* SerDes needs extra delay */
+   msleep(IXGB_SUN_PHY_RESET_DELAY);
+
+   /* Broadcom 7408L configuration */
+   /* Reference clock config */
+   ixgb_write_phy_reg(hw,
+  IXGB_BCM8704_USER_PMD_TX_CTRL_REG,
+  IXGB_SUN_PHY_ADDRESS,
+  IXGB_BCM8704_USER_DEV3_ADDR,
+  IXGB_BCM8704_USER_PMD_TX_CTRL_REG_VAL);
+   /*  we must read the registers twice */
+   ixgb_read_phy_reg(hw,
+ IXGB_BCM8704_USER_PMD_TX_CTRL_REG,
+ IXGB_SUN_PHY_ADDRESS,
+ IXGB_BCM8704_USER_DEV3_ADDR);
+   ixgb_read_phy_reg(hw,
+ IXGB_BCM8704_USER_PMD_TX_CTRL_REG,
+ IXGB_SUN_PHY_ADDRESS,
+ IXGB_BCM8704_USER_DEV3_ADDR);
+
+   ixgb_write_phy_reg(hw,
+  IXGB_BCM8704_USER_CTRL_REG,
+  IXGB_SUN_PHY_ADDRESS,
+  IXGB_BCM8704_USER_DEV3_ADDR,
+  IXGB_BCM8704_USER_CTRL_REG_VAL);
+   ixgb_read_phy_reg(hw,
+ IXGB_BCM8704_USER_CTRL_REG,
+ IXGB_SUN_PHY_ADDRESS,
+ IXGB_BCM8704_USER_DEV3_ADDR);
+   ixgb_read_phy_reg(hw,
+ IXGB_BCM8704_USER_CTRL_REG,
+ IXGB_SUN_PHY_ADDRESS,
+ IXGB_BCM8704_USER_DEV3_ADDR);
+
+   /* SerDes needs extra delay */
+   msleep(IXGB_SUN_PHY_RESET_DELAY);
+
+   return;
+}
diff --git a/drivers/net/ixgb/ixgb_hw.h b/drive

[PATCH] e1000: remove no longer used code for pci read/write cfg

2007-12-13 Thread Auke Kok
From: Adrian Bunk <[EMAIL PROTECTED]>

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_hw.h   |2 --
 drivers/net/e1000/e1000_main.c |   16 
 2 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index a2a86c5..930554b 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -421,8 +421,6 @@ void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct 
e1000_hw_stats *stats, u
 void e1000_get_bus_info(struct e1000_hw *hw);
 void e1000_pci_set_mwi(struct e1000_hw *hw);
 void e1000_pci_clear_mwi(struct e1000_hw *hw);
-void e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
-void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
 int32_t e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t 
*value);
 void e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc);
 int e1000_pcix_get_mmrbc(struct e1000_hw *hw);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 724f067..efd8c2d 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -4866,22 +4866,6 @@ e1000_pci_clear_mwi(struct e1000_hw *hw)
pci_clear_mwi(adapter->pdev);
 }
 
-void
-e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
-{
-   struct e1000_adapter *adapter = hw->back;
-
-   pci_read_config_word(adapter->pdev, reg, value);
-}
-
-void
-e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
-{
-   struct e1000_adapter *adapter = hw->back;
-
-   pci_write_config_word(adapter->pdev, reg, *value);
-}
-
 int
 e1000_pcix_get_mmrbc(struct e1000_hw *hw)
 {

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ethtool: update license field in specfile to be correctly defined

2007-12-12 Thread Auke Kok
RPM uses "License" as field and not "Copyright".

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.spec.in |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ethtool.spec.in b/ethtool.spec.in
index 1705d7f..4ff736a 100644
--- a/ethtool.spec.in
+++ b/ethtool.spec.in
@@ -5,7 +5,7 @@ Group   : Utilities
 
 Summary: A tool for setting ethernet parameters
 
-Copyright  : GPL
+License: GPL
 URL: http://sourceforge.net/projects/gkernel/
 
 Buildroot  : %{_tmppath}/%{name}-%{version}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e100: free IRQ to remove warningwhenrebooting

2007-12-12 Thread Auke Kok
Adapted from Ian Wienand <[EMAIL PROTECTED]>

Explicitly free the IRQ before removing the device to remove a
warning "Destroying IRQ without calling free_irq"

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
Cc: Ian Wienand <[EMAIL PROTECTED]>
---

 drivers/net/e100.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 27f4d4a..f630ea9 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2807,8 +2807,9 @@ static int e100_suspend(struct pci_dev *pdev, 
pm_message_t state)
pci_enable_wake(pdev, PCI_D3cold, 0);
}
 
-   pci_disable_device(pdev);
free_irq(pdev->irq, netdev);
+
+   pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);
 
return 0;
@@ -2850,6 +2851,8 @@ static void e100_shutdown(struct pci_dev *pdev)
pci_enable_wake(pdev, PCI_D3cold, 0);
}
 
+   free_irq(pdev->irq, netdev);
+
pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);
 }
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] e100: cleanup unneeded math

2007-12-05 Thread Auke Kok
No need to convert to bytes and back - cleanup unneeded code.

Adapted from fix from 'Roel Kluin <[EMAIL PROTECTED]>'

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e100.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 9189aff..27f4d4a 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2284,13 +2284,11 @@ static void e100_get_drvinfo(struct net_device *netdev,
strcpy(info->bus_info, pci_name(nic->pdev));
 }
 
+#define E100_PHY_REGS 0x1C
 static int e100_get_regs_len(struct net_device *netdev)
 {
struct nic *nic = netdev_priv(netdev);
-#define E100_PHY_REGS  0x1C
-#define E100_REGS_LEN  1 + E100_PHY_REGS + \
-   sizeof(nic->mem->dump_buf) / sizeof(u32)
-   return E100_REGS_LEN * sizeof(u32);
+   return 1 + E100_PHY_REGS + sizeof(nic->mem->dump_buf);
 }
 
 static void e100_get_regs(struct net_device *netdev,
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] e1000: fix memcpy in e1000_get_strings

2007-12-05 Thread Auke Kok
From: Roel Kluin <[EMAIL PROTECTED]>

drivers/net/e1000/e1000_ethtool.c:113:
#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN

drivers/net/e1000e/ethtool.c:106:
#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN

E1000_TEST_LEN*ETH_GSTRING_LEN will expand to
sizeof(e1000_gstrings_test) / (ETH_GSTRING_LEN * ETH_GSTRING_LEN)

A lack of parentheses around defines causes unexpected results due to
operator precedences.

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_ethtool.c |2 +-
 drivers/net/e1000e/ethtool.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethtool.c 
b/drivers/net/e1000/e1000_ethtool.c
index 0542b10..d876787 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1949,7 +1949,7 @@ e1000_get_strings(struct net_device *netdev, uint32_t 
stringset, uint8_t *data)
switch (stringset) {
case ETH_SS_TEST:
memcpy(data, *e1000_gstrings_test,
-   E1000_TEST_LEN*ETH_GSTRING_LEN);
+   sizeof(e1000_gstrings_test));
break;
case ETH_SS_STATS:
for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index d824914..6d9c27f 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1760,7 +1760,7 @@ static void e1000_get_strings(struct net_device *netdev, 
u32 stringset,
switch (stringset) {
case ETH_SS_TEST:
memcpy(data, *e1000_gstrings_test,
-   E1000_TEST_LEN*ETH_GSTRING_LEN);
+   sizeof(e1000_gstrings_test));
break;
case ETH_SS_STATS:
for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000: Fix NAPI state bug when Rx complete

2007-11-27 Thread Auke Kok
Don't exit polling when we have not yet used our budget, this causes
the NAPI system to end up with a messed up poll list.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index b7c3070..724f067 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3926,7 +3926,7 @@ e1000_clean(struct napi_struct *napi, int budget)
  &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((!tx_cleaned && (work_done < budget)) ||
+   if ((!tx_cleaned && (work_done == 0)) ||
   !netif_running(poll_dev)) {
 quit_polling:
if (likely(adapter->itr_setting & 3))
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ethtool: fix typo on setting speed 10000

2007-11-26 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

fix the typo in speed 1 setting.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 3adf843..a668b49 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -524,7 +524,7 @@ static void parse_cmdline(int argc, char **argp)
speed_wanted = SPEED_1000;
else if (!strcmp(argp[i], "2500"))
speed_wanted = SPEED_2500;
-   else if (!strcmp(argp[1], "1"))
+   else if (!strcmp(argp[i], "1"))
speed_wanted = SPEED_1;
else
show_usage(1);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] e1000e: update netstats traffic counters realtime

2007-11-13 Thread Auke Kok
formerly e1000/e1000e only updated traffic counters once every
2 seconds with the register values of bytes/packets. With newer
code however in the interrupt and polling code we can real-time
fill in these values in the netstats struct for users to see.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index a271112..6c99703 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -458,6 +458,8 @@ next_desc:
 
adapter->total_rx_packets += total_rx_packets;
adapter->total_rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_packets += total_rx_packets;
+   adapter->net_stats.rx_bytes += total_rx_bytes;
return cleaned;
 }
 
@@ -593,6 +595,8 @@ static bool e1000_clean_tx_irq(struct e1000_adapter 
*adapter)
}
adapter->total_tx_bytes += total_tx_bytes;
adapter->total_tx_packets += total_tx_packets;
+   adapter->net_stats.tx_packets += total_tx_packets;
+   adapter->net_stats.tx_bytes += total_tx_bytes;
return cleaned;
 }
 
@@ -755,6 +759,8 @@ next_desc:
 
adapter->total_rx_packets += total_rx_packets;
adapter->total_rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_packets += total_rx_packets;
+   adapter->net_stats.rx_bytes += total_rx_bytes;
return cleaned;
 }
 
@@ -2537,10 +2543,6 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
}
 
/* Fill out the OS statistics structure */
-   adapter->net_stats.rx_packets = adapter->stats.gprc;
-   adapter->net_stats.tx_packets = adapter->stats.gptc;
-   adapter->net_stats.rx_bytes = adapter->stats.gorcl;
-   adapter->net_stats.tx_bytes = adapter->stats.gotcl;
adapter->net_stats.multicast = adapter->stats.mprc;
adapter->net_stats.collisions = adapter->stats.colc;
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] e1000: convert regtest macro's to functions

2007-11-13 Thread Auke Kok
Minimal macro to function conversion in e1000_ethtool.c

Adds functions reg_pattern_test and reg_set_and_check
Changes REG_PATTERN_TEST and REG_SET_AND_CHECK macros
to call these functions.

Saves ~2.5KB

Compiled x86, untested (no hardware)

old:

$ size drivers/net/e1000/e1000_ethtool.o
   textdata bss dec hex filename
  16778   0   0   16778418a drivers/net/e1000/e1000_ethtool.o

new:

$ size drivers/net/e1000/e1000_ethtool.o
   textdata bss dec hex filename
  14128   0   0   141283730 drivers/net/e1000/e1000_ethtool.o

Signed-off-by: Joe Perches <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_ethtool.c |   84 -
 1 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethtool.c 
b/drivers/net/e1000/e1000_ethtool.c
index 667f18b..ec67ea9 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -728,39 +728,65 @@ err_setup:
return err;
 }
 
-#define REG_PATTERN_TEST(R, M, W)  
\
-{  
\
-   uint32_t pat, val; \
-   const uint32_t test[] =\
-   {0x5A5A5A5A, 0xA5A5A5A5, 0x, 0x};  \
-   for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \
-   E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
-   val = E1000_READ_REG(&adapter->hw, R); \
-   if (val != (test[pat] & W & M)) {  \
-   DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \
-   "0x%08X expected 0x%08X\n",\
-   E1000_##R, val, (test[pat] & W & M));  \
-   *data = (adapter->hw.mac_type < e1000_82543) ? \
-   E1000_82542_##R : E1000_##R;   \
-   return 1;  \
-   }  \
-   }  \
+static bool reg_pattern_test(struct e1000_adapter *adapter, uint64_t *data,
+int reg, uint32_t mask, uint32_t write)
+{
+   static const uint32_t test[] =
+   {0x5A5A5A5A, 0xA5A5A5A5, 0x, 0x};
+   uint8_t __iomem *address = adapter->hw.hw_addr + reg;
+   uint32_t read;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(test); i++) {
+   writel(write & test[i], address);
+   read = readl(address);
+   if (read != (write & test[i] & mask)) {
+   DPRINTK(DRV, ERR, "pattern test reg %04X failed: "
+   "got 0x%08X expected 0x%08X\n",
+   reg, read, (write & test[i] & mask));
+   *data = reg;
+   return true;
+   }
+   }
+   return false;
 }
 
-#define REG_SET_AND_CHECK(R, M, W) 
\
-{  
\
-   uint32_t val;  \
-   E1000_WRITE_REG(&adapter->hw, R, W & M);   \
-   val = E1000_READ_REG(&adapter->hw, R); \
-   if ((W & M) != (val & M)) {\
-   DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\
-   "expected 0x%08X\n", E1000_##R, (val & M), (W & M));   \
-   *data = (adapter->hw.mac_type < e1000_82543) ? \
-   E1000_82542_##R : E1000_##R;   \
-   return 1;  \
-   }  \
+static bool reg_set_and_check(struct e1000_adapter *adapter, uint64_t *data,
+ int reg, uint32_t mask, uint32_t write)
+{
+   uint8_t __iomem *address = adapter->hw.hw_addr + reg;
+   uint32_t read;
+
+   writel(write & mask, address);
+   read = readl(address);
+   if ((read & mask) != (write & mask)) {
+   DPRINTK(DRV, ERR, "set/check reg %04X test failed: "
+   "got 0x%08X expecte

[PATCH 6/6] e1000: fix schedule while atomic when called from mii-tool

2007-11-13 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

mii-tool can cause the driver to call msleep during nway reset,
bugzilla.kernel.org bug 8430.  Fix by simply calling reinit_locked
outside of the spinlock, which is safe from ethtool, so it should be
safe from here.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |   13 +++--
 1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index dc4934d..b7c3070 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -4794,6 +4794,7 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq 
*ifr, int cmd)
spin_unlock_irqrestore(&adapter->stats_lock, flags);
return -EIO;
}
+   spin_unlock_irqrestore(&adapter->stats_lock, flags);
if (adapter->hw.media_type == e1000_media_type_copper) {
switch (data->reg_num) {
case PHY_CTRL:
@@ -4814,12 +4815,8 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq 
*ifr, int cmd)
   DUPLEX_HALF;
retval = e1000_set_spd_dplx(adapter,
spddplx);
-   if (retval) {
-   spin_unlock_irqrestore(
-   &adapter->stats_lock,
-   flags);
+   if (retval)
return retval;
-   }
}
if (netif_running(adapter->netdev))
e1000_reinit_locked(adapter);
@@ -4828,11 +4825,8 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq 
*ifr, int cmd)
break;
case M88E1000_PHY_SPEC_CTRL:
case M88E1000_EXT_PHY_SPEC_CTRL:
-   if (e1000_phy_reset(&adapter->hw)) {
-   spin_unlock_irqrestore(
-   &adapter->stats_lock, flags);
+   if (e1000_phy_reset(&adapter->hw))
return -EIO;
-   }
break;
}
} else {
@@ -4847,7 +4841,6 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq 
*ifr, int cmd)
break;
}
}
-   spin_unlock_irqrestore(&adapter->stats_lock, flags);
break;
default:
return -EOPNOTSUPP;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] e1000e: convert register test macros to functions

2007-11-13 Thread Auke Kok
From: Joe Perches <[EMAIL PROTECTED]>

Add functions for reg_pattern_test and reg_set_and check
Changed macros to use these functions

Compiled x86, untested

Size decreased ~2K

old:

$ size drivers/net/e1000e/ethtool.o
   textdata bss dec hex filename
  14461   0   0   14461387d drivers/net/e1000e/ethtool.o

new:

$ size drivers/net/e1000e/ethtool.o
   textdata bss dec hex filename
  12498   0   0   1249830d2 drivers/net/e1000e/ethtool.o


Signed-off-by: Joe Perches <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |   84 +++---
 1 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 6a39784..bc1115d 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -691,41 +691,63 @@ err_setup:
return err;
 }
 
-#define REG_PATTERN_TEST(R, M, W) REG_PATTERN_TEST_ARRAY(R, 0, M, W)
-#define REG_PATTERN_TEST_ARRAY(reg, offset, mask, writeable) \
-{\
-   u32 _pat; \
-   u32 _value;   \
-   u32 _test[] = {0x5A5A5A5A, 0xA5A5A5A5, 0x, 0x};   \
-   for (_pat = 0; _pat < ARRAY_SIZE(_test); _pat++) {\
-   E1000_WRITE_REG_ARRAY(hw, reg, offset,\
- (_test[_pat] & writeable)); \
-   _value = E1000_READ_REG_ARRAY(hw, reg, offset); \
-   if (_value != (_test[_pat] & writeable & mask)) { \
-   ndev_err(netdev, "pattern test reg %04X " \
-"failed: got 0x%08X expected 0x%08X\n",  \
-reg + offset,  \
-value, (_test[_pat] & writeable & mask));\
-   *data = reg;  \
-   return 1; \
-   } \
-   } \
+bool reg_pattern_test_array(struct e1000_adapter *adapter, u64 *data, 
+   int reg, int offset, u32 mask, u32 write)
+{
+   int i;
+   u32 read;
+   static const u32 test[] = 
+   {0x5A5A5A5A, 0xA5A5A5A5, 0x, 0x};
+   for (i = 0; i < ARRAY_SIZE(test); i++) {
+   E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
+ (test[i] & write));
+   read = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
+   if (read != (test[i] & write & mask)) {
+   ndev_err(adapter->netdev, "pattern test reg %04X "
+"failed: got 0x%08X expected 0x%08X\n",
+reg + offset,
+read, (test[i] & write & mask));
+   *data = reg;
+   return true;
+   }
+   }
+   return false;
 }
 
-#define REG_SET_AND_CHECK(R, M, W)   \
-{\
-   u32 _value;   \
-   __ew32(hw, R, W & M);   \
-   _value = __er32(hw, R); \
-   if ((W & M) != (_value & M)) {\
-   ndev_err(netdev, "set/check reg %04X test failed: "   \
-"got 0x%08X expected 0x%08X\n", R, (_value & M), \
-(W & M));\
-   *data = R;\
-   return 1; \
-   } \
+static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
+ int reg, u32 mask, u32 write)
+{
+   u32 read;
+   __ew32(&adapter->hw, reg, write & mask);
+   read = __er32(&adapter->hw, reg);
+   if ((write & mask) != (read & mask)) {
+   ndev_err(adapter->netdev, "set/check reg %04X test failed: "
+"got 0x%08X expected 0x%08X\n", reg, (read & 

[PATCH 5/6] e1000: Secondary unicast address support

2007-11-13 Thread Auke Kok
From: Patrick McHardy <[EMAIL PROTECTED]>

Add support for configuring secondary unicast addresses. Unicast
addresses take precendece over multicast addresses when filling
the exact address filters to avoid going to promiscous mode.
When more unicast addresses are present than filter slots,
unicast filtering is disabled and all slots can be used for
multicast addresses.

Signed-off-by: Patrick McHardy <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |   47 ++--
 1 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index e1ba705..dc4934d 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -126,7 +126,7 @@ static void e1000_clean_tx_ring(struct e1000_adapter 
*adapter,
 struct e1000_tx_ring *tx_ring);
 static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
 struct e1000_rx_ring *rx_ring);
-static void e1000_set_multi(struct net_device *netdev);
+static void e1000_set_rx_mode(struct net_device *netdev);
 static void e1000_update_phy_info(unsigned long data);
 static void e1000_watchdog(unsigned long data);
 static void e1000_82547_tx_fifo_stall(unsigned long data);
@@ -487,7 +487,7 @@ static void e1000_configure(struct e1000_adapter *adapter)
struct net_device *netdev = adapter->netdev;
int i;
 
-   e1000_set_multi(netdev);
+   e1000_set_rx_mode(netdev);
 
e1000_restore_vlan(adapter);
e1000_init_manageability(adapter);
@@ -899,7 +899,7 @@ e1000_probe(struct pci_dev *pdev,
netdev->stop = &e1000_close;
netdev->hard_start_xmit = &e1000_xmit_frame;
netdev->get_stats = &e1000_get_stats;
-   netdev->set_multicast_list = &e1000_set_multi;
+   netdev->set_rx_mode = &e1000_set_rx_mode;
netdev->set_mac_address = &e1000_set_mac;
netdev->change_mtu = &e1000_change_mtu;
netdev->do_ioctl = &e1000_ioctl;
@@ -2382,21 +2382,22 @@ e1000_set_mac(struct net_device *netdev, void *p)
 }
 
 /**
- * e1000_set_multi - Multicast and Promiscuous mode set
+ * e1000_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
  * @netdev: network interface device structure
  *
- * The set_multi entry point is called whenever the multicast address
- * list or the network interface flags are updated.  This routine is
- * responsible for configuring the hardware for proper multicast,
+ * The set_rx_mode entry point is called whenever the unicast or multicast
+ * address lists or the network interface flags are updated. This routine is
+ * responsible for configuring the hardware for proper unicast, multicast,
  * promiscuous mode, and all-multi behavior.
  **/
 
 static void
-e1000_set_multi(struct net_device *netdev)
+e1000_set_rx_mode(struct net_device *netdev)
 {
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
-   struct dev_mc_list *mc_ptr;
+   struct dev_addr_list *uc_ptr;
+   struct dev_addr_list *mc_ptr;
uint32_t rctl;
uint32_t hash_value;
int i, rar_entries = E1000_RAR_ENTRIES;
@@ -2419,9 +2420,16 @@ e1000_set_multi(struct net_device *netdev)
rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
} else if (netdev->flags & IFF_ALLMULTI) {
rctl |= E1000_RCTL_MPE;
-   rctl &= ~E1000_RCTL_UPE;
} else {
-   rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
+   rctl &= ~E1000_RCTL_MPE;
+   }
+
+   uc_ptr = NULL;
+   if (netdev->uc_count > rar_entries - 1) {
+   rctl |= E1000_RCTL_UPE;
+   } else if (!(netdev->flags & IFF_PROMISC)) {
+   rctl &= ~E1000_RCTL_UPE;
+   uc_ptr = netdev->uc_list;
}
 
E1000_WRITE_REG(hw, RCTL, rctl);
@@ -2431,7 +2439,10 @@ e1000_set_multi(struct net_device *netdev)
if (hw->mac_type == e1000_82542_rev2_0)
e1000_enter_82542_rst(adapter);
 
-   /* load the first 14 multicast address into the exact filters 1-14
+   /* load the first 14 addresses into the exact filters 1-14. Unicast
+* addresses take precedence to avoid disabling unicast filtering
+* when possible.
+*
 * RAR 0 is used for the station MAC adddress
 * if there are not 14 addresses, go ahead and clear the filters
 * -- with 82571 controllers only 0-13 entries are filled here
@@ -2439,8 +2450,11 @@ e1000_set_multi(struct net_device *netdev)
mc_ptr = netdev->mc_list;
 
for (i = 1; i < rar_entries; i++) {
-   if (mc_ptr) {
-   e1000_rar_set(hw, mc_ptr->dmi_addr, i);
+   if (uc_ptr) {
+   

[PATCH 2/6] e1000: update netstats traffic counters realtime

2007-11-13 Thread Auke Kok
formerly e1000/e1000e only updated traffic counters once every
2 seconds with the register values of bytes/packets. With newer
code however in the interrupt and polling code we can real-time
fill in these values in the netstats struct for users to see.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index d1b88e4..e1ba705 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3652,10 +3652,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
}
 
/* Fill out the OS statistics structure */
-   adapter->net_stats.rx_packets = adapter->stats.gprc;
-   adapter->net_stats.tx_packets = adapter->stats.gptc;
-   adapter->net_stats.rx_bytes = adapter->stats.gorcl;
-   adapter->net_stats.tx_bytes = adapter->stats.gotcl;
adapter->net_stats.multicast = adapter->stats.mprc;
adapter->net_stats.collisions = adapter->stats.colc;
 
@@ -4034,6 +4030,8 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
}
adapter->total_tx_bytes += total_tx_bytes;
adapter->total_tx_packets += total_tx_packets;
+   adapter->net_stats.tx_bytes += total_tx_bytes;
+   adapter->net_stats.tx_packets += total_tx_packets;
return cleaned;
 }
 
@@ -4256,6 +4254,8 @@ next_desc:
 
adapter->total_rx_packets += total_rx_packets;
adapter->total_rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_packets += total_rx_packets;
return cleaned;
 }
 
@@ -4443,6 +4443,8 @@ next_desc:
 
adapter->total_rx_packets += total_rx_packets;
adapter->total_rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_bytes += total_rx_bytes;
+   adapter->net_stats.rx_packets += total_rx_packets;
return cleaned;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ethtool: Fix coalesce settings copy+paste typo

2007-11-12 Thread Auke Kok
Coalesce setting errors use the same error messages as the
descriptor ring errors.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 6c7a2e3..bb9dd59 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1470,7 +1470,7 @@ static int do_scoalesce(int fd, struct ifreq *ifr)
   &changed);
 
if (!changed) {
-   fprintf(stderr, "no ring parameters changed, aborting\n");
+   fprintf(stderr, "no coalesce parameters changed, aborting\n");
return 80;
}
 
@@ -1478,7 +1478,7 @@ static int do_scoalesce(int fd, struct ifreq *ifr)
ifr->ifr_data = (caddr_t)&ecoal;
err = ioctl(fd, SIOCETHTOOL, ifr);
if (err) {
-   perror("Cannot set device ring parameters");
+   perror("Cannot set device coalesce parameters");
return 81;
}
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Fix e100 on systems that have cache incoherent DMA

2007-11-08 Thread Auke Kok
From: David Acker <[EMAIL PROTECTED]>

On the systems that have cache incoherent DMA, including ARM, there
is a race condition between software allocating a new receive buffer
and hardware writing into a buffer.  The two race on touching the last
Receive Frame Descriptor (RFD).  It has its el-bit set and its next
link equal to 0.  When hardware encounters this buffer it attempts to
write data to it and then update Status Word bits and Actual Count in
the RFD.  At the same time software may try to clear the el-bit and
set the link address to a new buffer.

Since the entire RFD is once cache-line, the two write operations can
collide.  This can lead to the receive unit stalling or interpreting
random memory as its receive area.

The fix is to set the el-bit on and the size to 0 on the next to last
buffer in the chain.  When the hardware encounters this buffer it stops
and does not write to it at all.  The hardware issues an RNR interrupt
with the receive unit in the No Resources state.  Software can write
to the tail of the list because it knows hardware will stop on the
previous descriptor that was marked as the end of list.

Once it has a new next to last buffer prepared, it can clear the el-bit
and set the size on the previous one.  The race on this buffer is safe
since the link already points to a valid next buffer and the software
can handle the race setting the size (assuming aligned 16 bit writes
are atomic with respect to the DMA read). If the hardware sees the
el-bit cleared without the size set, it will move on to the next buffer
and skip this one.  If it sees the size set but the el-bit still set,
it will complete that buffer and then RNR interrupt and wait.

Signed-off-by: David Acker <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e100.c |  128 
 1 files changed, 99 insertions(+), 29 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 3dbaec6..2153058 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -106,6 +106,13 @@
  * the RFD, the RFD must be dma_sync'ed to maintain a consistent
  * view from software and hardware.
  *
+ * In order to keep updates to the RFD link field from colliding with
+ * hardware writes to mark packets complete, we use the feature that
+ * hardware will not write to a size 0 descriptor and mark the previous
+ * packet as end-of-list (EL).   After updating the link, we remove EL
+ * and only then restore the size such that hardware may use the
+ * previous-to-end RFD.
+ *
  * Under typical operation, the  receive unit (RU) is start once,
  * and the controller happily fills RFDs as frames arrive.  If
  * replacement RFDs cannot be allocated, or the RU goes non-active,
@@ -281,6 +288,7 @@ struct csr {
 };
 
 enum scb_status {
+   rus_no_res   = 0x08,
rus_ready= 0x10,
rus_mask = 0x3C,
 };
@@ -952,7 +960,7 @@ static void e100_get_defaults(struct nic *nic)
((nic->mac >= mac_82558_D101_A4) ? cb_cid : cb_i));
 
/* Template for a freshly allocated RFD */
-   nic->blank_rfd.command = cpu_to_le16(cb_el);
+   nic->blank_rfd.command = 0;
nic->blank_rfd.rbd = 0x;
nic->blank_rfd.size = cpu_to_le16(VLAN_ETH_FRAME_LEN);
 
@@ -1791,15 +1799,12 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx 
*rx)
}
 
/* Link the RFD to end of RFA by linking previous RFD to
-* this one, and clearing EL bit of previous.  */
+* this one.  We are safe to touch the previous RFD because
+* it is protected by the before last buffer's el bit being set */
if(rx->prev->skb) {
struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data;
put_unaligned(cpu_to_le32(rx->dma_addr),
(u32 *)&prev_rfd->link);
-   wmb();
-   prev_rfd->command &= ~cpu_to_le16(cb_el);
-   pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr,
-   sizeof(struct rfd), PCI_DMA_TODEVICE);
}
 
return 0;
@@ -1824,8 +1829,19 @@ static int e100_rx_indicate(struct nic *nic, struct rx 
*rx,
DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status);
 
/* If data isn't ready, nothing to indicate */
-   if(unlikely(!(rfd_status & cb_complete)))
+   if (unlikely(!(rfd_status & cb_complete))) {
+   /* If the next buffer has the el bit, but we think the receiver
+* is still running, check to see if it really stopped while
+* we had interrupts off.
+* This allows for a fast restart without re-enabling
+* interrupts */
+   if ((le16_to_cpu(rfd->command) & cb_el) &&

[PATCH] ethtool: add support for supporting 10000baseT

2007-11-07 Thread Auke Kok
From: Jesse Brandeburg <[EMAIL PROTECTED]>

there is missing support in ethtool for reporting 1baseT
as SUPPORTED_1baseT_Full.  The code seems to be half
implemented because the "advertising" field has the implementation.

this patch just adds it for supported reporting.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 6c7a2e3..888be57 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -725,6 +725,13 @@ static void dump_supported(struct ethtool_cmd *ep)
if (mask & SUPPORTED_2500baseX_Full) {
did1++; fprintf(stdout, "2500baseX/Full ");
}
+   if (did1 && (mask & SUPPORTED_1baseT_Full)) {
+   fprintf(stdout, "\n");
+   fprintf(stdout, "   ");
+   }
+   if (mask & SUPPORTED_1baseT_Full) {
+   did1++; fprintf(stdout, "1baseT/Full ");
+   }
fprintf(stdout, "\n");
 
fprintf(stdout, "   Supports auto-negotiation: ");
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] ixgbe: Fix copper PHY initialization code

2007-10-31 Thread Auke Kok
While cleaning up the internal API focussing on Fiber and CX4 code
we found that I had broken the copper PHY initialization code. This
patch restores the PHY-specific code. This is mostly uninteresting
since no copper PHY boards are yet available. The changes have been
tested against Fiber only as I do not even have copper PHY versions
of 82598 macs.

This change actually cleans up the API code a bit more and we
lose some initialization code. A few PHY link detection helper
lines of code have been snuck into this patch, as well as a
read flush where it was suspected that this might cause issues.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe.h|8 --
 drivers/net/ixgbe/ixgbe_82598.c  |  156 +++---
 drivers/net/ixgbe/ixgbe_common.c |   10 ++
 drivers/net/ixgbe/ixgbe_main.c   |   19 ++---
 drivers/net/ixgbe/ixgbe_phy.h|1 
 drivers/net/ixgbe/ixgbe_type.h   |   13 ++-
 6 files changed, 71 insertions(+), 136 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index bc51432..a021a6e 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -234,14 +234,10 @@ enum ixbge_state_t {
 };
 
 enum ixgbe_boards {
-   board_82598AF,
-   board_82598EB,
-   board_82598AT,
+   board_82598,
 };
 
-extern struct ixgbe_info ixgbe_82598AF_info;
-extern struct ixgbe_info ixgbe_82598EB_info;
-extern struct ixgbe_info ixgbe_82598AT_info;
+extern struct ixgbe_info ixgbe_82598_info;
 
 extern char ixgbe_driver_name[];
 extern const char ixgbe_driver_version[];
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 4d64673..6321b05 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -50,8 +50,6 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw 
*hw, u32 speed,
bool autoneg,
bool autoneg_wait_to_complete);
 static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw);
-static s32 ixgbe_check_copper_link_82598(struct ixgbe_hw *hw, u32 *speed,
-bool *link_up);
 static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, u32 speed,
   bool autoneg,
   bool autoneg_wait_to_complete);
@@ -64,6 +62,28 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
hw->mac.num_tx_queues = IXGBE_82598_MAX_RX_QUEUES;
hw->mac.num_rx_addrs = IXGBE_82598_RAR_ENTRIES;
 
+   /* PHY ops are filled in by default properly for Fiber only */
+   if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
+   hw->mac.ops.setup_link = &ixgbe_setup_copper_link_82598;
+   hw->mac.ops.setup_link_speed = 
&ixgbe_setup_copper_link_speed_82598;
+   hw->mac.ops.get_link_settings =
+   &ixgbe_get_copper_link_settings_82598;
+
+   /* Call PHY identify routine to get the phy type */
+   ixgbe_identify_phy(hw);
+
+   switch (hw->phy.type) {
+   case ixgbe_phy_tn:
+   hw->phy.ops.setup_link = &ixgbe_setup_tnx_phy_link;
+   hw->phy.ops.check_link = &ixgbe_check_tnx_phy_link;
+   hw->phy.ops.setup_link_speed =
+   &ixgbe_setup_tnx_phy_link_speed;
+   break;
+   default:
+   break;
+   }
+   }
+
return 0;
 }
 
@@ -206,6 +226,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
autoc_reg |= hw->mac.link_mode_select;
 
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
+   IXGBE_WRITE_FLUSH(hw);
msleep(50);
}
 
@@ -314,7 +335,7 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw 
*hw,
 * ixgbe_hw This will write the AUTOC register based on the new
 * stored values
 */
-   hw->phy.ops.setup(hw);
+   hw->mac.ops.setup_link(hw);
}
 
return status;
@@ -332,72 +353,18 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct 
ixgbe_hw *hw,
  **/
 static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)
 {
-   s32 status;
-   u32 speed = 0;
-   bool link_up = false;
-
-   /* Set up MAC */
-   hw->phy.ops.setup(hw);
+   s32 status = 0;
 
/* Restart autonegotiation on PHY */
-   status = hw->phy.ops.setup(hw);
-
-   /* Synchronize MAC to PHY speed */
-   if (status == 0)
-   status = hw->phy.ops.check(hw, &speed, &link_up);
-
-   return status;
-}
+   if (hw->phy.ops.setup_link)
+   status = hw->phy.o

[PATCH 3/4] e1000/e1000e: Move PCI-Express device IDs over to e1000e

2007-10-31 Thread Auke Kok
e1000e will from now on support the PCI-Express adapters that
previously were supported by e1000. This support means better
performance and easier debugging from now on for both the old
PCI-X/PCI hardware and PCI-Express adapters.

This patch also moves 3 recently merged device IDs over to e1000e
that are identical to quad-port versions of already existing
dual port versions. With this last bit every former e1000 pci-e
device should work now with e1000e.

Here is a brief list of which gigabit driver to use with which
adapter:

  e1000:
82540 -> 82547

  e1000e:
82571 -> 82573
ich8, ich9   (82562 or 82566)
es2lan   (80003eslan)

  igb: (not yet merged, only available from e1000.sf.net)
82575

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |   27 ---
 drivers/net/e1000e/82571.c |6 ++
 drivers/net/e1000e/hw.h|3 +++
 drivers/net/e1000e/netdev.c|9 +++--
 4 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 72deff0..d1b88e4 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -73,14 +73,6 @@ static struct pci_device_id e1000_pci_tbl[] = {
INTEL_E1000_ETHERNET_DEVICE(0x1026),
INTEL_E1000_ETHERNET_DEVICE(0x1027),
INTEL_E1000_ETHERNET_DEVICE(0x1028),
-   INTEL_E1000_ETHERNET_DEVICE(0x1049),
-   INTEL_E1000_ETHERNET_DEVICE(0x104A),
-   INTEL_E1000_ETHERNET_DEVICE(0x104B),
-   INTEL_E1000_ETHERNET_DEVICE(0x104C),
-   INTEL_E1000_ETHERNET_DEVICE(0x104D),
-   INTEL_E1000_ETHERNET_DEVICE(0x105E),
-   INTEL_E1000_ETHERNET_DEVICE(0x105F),
-   INTEL_E1000_ETHERNET_DEVICE(0x1060),
INTEL_E1000_ETHERNET_DEVICE(0x1075),
INTEL_E1000_ETHERNET_DEVICE(0x1076),
INTEL_E1000_ETHERNET_DEVICE(0x1077),
@@ -89,28 +81,9 @@ static struct pci_device_id e1000_pci_tbl[] = {
INTEL_E1000_ETHERNET_DEVICE(0x107A),
INTEL_E1000_ETHERNET_DEVICE(0x107B),
INTEL_E1000_ETHERNET_DEVICE(0x107C),
-   INTEL_E1000_ETHERNET_DEVICE(0x107D),
-   INTEL_E1000_ETHERNET_DEVICE(0x107E),
-   INTEL_E1000_ETHERNET_DEVICE(0x107F),
INTEL_E1000_ETHERNET_DEVICE(0x108A),
-   INTEL_E1000_ETHERNET_DEVICE(0x108B),
-   INTEL_E1000_ETHERNET_DEVICE(0x108C),
-   INTEL_E1000_ETHERNET_DEVICE(0x1096),
-   INTEL_E1000_ETHERNET_DEVICE(0x1098),
INTEL_E1000_ETHERNET_DEVICE(0x1099),
-   INTEL_E1000_ETHERNET_DEVICE(0x109A),
-   INTEL_E1000_ETHERNET_DEVICE(0x10A4),
-   INTEL_E1000_ETHERNET_DEVICE(0x10A5),
INTEL_E1000_ETHERNET_DEVICE(0x10B5),
-   INTEL_E1000_ETHERNET_DEVICE(0x10B9),
-   INTEL_E1000_ETHERNET_DEVICE(0x10BA),
-   INTEL_E1000_ETHERNET_DEVICE(0x10BB),
-   INTEL_E1000_ETHERNET_DEVICE(0x10BC),
-   INTEL_E1000_ETHERNET_DEVICE(0x10C4),
-   INTEL_E1000_ETHERNET_DEVICE(0x10C5),
-   INTEL_E1000_ETHERNET_DEVICE(0x10D5),
-   INTEL_E1000_ETHERNET_DEVICE(0x10D9),
-   INTEL_E1000_ETHERNET_DEVICE(0x10DA),
/* required last entry */
{0,}
 };
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 45f5ee2..3beace5 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -194,6 +194,8 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter 
*adapter)
break;
case E1000_DEV_ID_82571EB_SERDES:
case E1000_DEV_ID_82572EI_SERDES:
+   case E1000_DEV_ID_82571EB_SERDES_DUAL:
+   case E1000_DEV_ID_82571EB_SERDES_QUAD:
hw->media_type = e1000_media_type_internal_serdes;
break;
default:
@@ -260,6 +262,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter 
*adapter)
case E1000_DEV_ID_82571EB_QUAD_COPPER:
case E1000_DEV_ID_82571EB_QUAD_FIBER:
case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
+   case E1000_DEV_ID_82571PT_QUAD_COPPER:
adapter->flags |= FLAG_IS_QUAD_PORT;
/* mark the first port */
if (global_quad_port_a == 0)
@@ -285,6 +288,9 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter 
*adapter)
if (adapter->flags & FLAG_IS_QUAD_PORT &&
(!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
adapter->flags &= ~FLAG_HAS_WOL;
+   /* Does not support WoL on any port */
+   if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
+   adapter->flags &= ~FLAG_HAS_WOL;
break;
 
case e1000_82573:
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 1bb2052..71f93ce 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -303,8 +303,11 @@ enum e1e_registers {
 #define E1000_DEV_ID_82571EB_FIBER 0x105F
 #defi

[PATCH 1/4] e1000e: alternate MAC address support

2007-10-31 Thread Auke Kok
From: Bill Hayes <[EMAIL PROTECTED]>

Port alternate MAC address support from the sourceforge
e1000 driver to the upstream e1000e driver.

Signed-off-by: Bill Hayes <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/82571.c   |4 
 drivers/net/e1000e/defines.h |1 +
 drivers/net/e1000e/hw.h  |1 +
 drivers/net/e1000e/lib.c |   39 +--
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 14141a5..b6401ab 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -752,6 +752,10 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
ew32(IMC, 0x);
icr = er32(ICR);
 
+   if (hw->mac.type == e1000_82571 &&
+   hw->dev_spec.e82571.alt_mac_addr_is_present)
+   e1000e_set_laa_state_82571(hw, true);
+
return 0;
 }
 
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index b32ed45..f2175ea 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -557,6 +557,7 @@
 #define NVM_INIT_3GIO_30x001A
 #define NVM_INIT_CONTROL3_PORT_A   0x0024
 #define NVM_CFG0x0012
+#define NVM_ALT_MAC_ADDR_PTR   0x0037
 #define NVM_CHECKSUM_REG   0x003F
 
 #define E1000_NVM_CFG_DONE_PORT_0  0x4 /* MNG config cycle done */
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 6451578..1bb2052 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -816,6 +816,7 @@ struct e1000_bus_info {
 
 struct e1000_dev_spec_82571 {
bool laa_is_present;
+   bool alt_mac_addr_is_present;
 };
 
 struct e1000_shadow_ram {
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 0bdeca3..16f35fa 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -2059,9 +2059,44 @@ s32 e1000e_read_mac_addr(struct e1000_hw *hw)
 {
s32 ret_val;
u16 offset, nvm_data, i;
+   u16 mac_addr_offset = 0;
+
+   if (hw->mac.type == e1000_82571) {
+   /* Check for an alternate MAC address.  An alternate MAC
+* address can be setup by pre-boot software and must be
+* treated like a permanent address and must override the
+* actual permanent MAC address. */
+   ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
+   &mac_addr_offset);
+   if (ret_val) {
+   hw_dbg(hw, "NVM Read Error\n");
+   return ret_val;
+   }
+   if (mac_addr_offset == 0x)
+   mac_addr_offset = 0;
+
+   if (mac_addr_offset) {
+   if (hw->bus.func == E1000_FUNC_1)
+   mac_addr_offset += ETH_ALEN/sizeof(u16);
+
+   /* make sure we have a valid mac address here
+* before using it */
+   ret_val = e1000_read_nvm(hw, mac_addr_offset, 1,
+&nvm_data);
+   if (ret_val) {
+   hw_dbg(hw, "NVM Read Error\n");
+   return ret_val;
+   }
+   if (nvm_data & 0x0001)
+   mac_addr_offset = 0;
+   }
+
+   if (mac_addr_offset)
+   hw->dev_spec.e82571.alt_mac_addr_is_present = 1;
+   }
 
for (i = 0; i < ETH_ALEN; i += 2) {
-   offset = i >> 1;
+   offset = mac_addr_offset + (i >> 1);
ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data);
if (ret_val) {
hw_dbg(hw, "NVM Read Error\n");
@@ -2072,7 +2107,7 @@ s32 e1000e_read_mac_addr(struct e1000_hw *hw)
}
 
/* Flip last bit of mac address if we're on second port */
-   if (hw->bus.func == E1000_FUNC_1)
+   if (!mac_addr_offset && hw->bus.func == E1000_FUNC_1)
hw->mac.perm_addr[5] ^= 1;
 
for (i = 0; i < ETH_ALEN; i++)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] e1000e: Disable L1 ASPM power savings for 82573 mobile variants

2007-10-31 Thread Auke Kok
L1 ASPM link (pci-e link power savings) has significant benefits
(~1W savings when link is active) but unfortunately does not work
correctly on any of the chipsets that have 82573 on mobile platforms
which causes various nuisances:
 - eeprom reads return garbage information leading to bad eeprom
   checksums
 - long ping times (up to 2 seconds)
 - complete system hangs (freeze/lockup)

A lot of T60 owners have been plagued by this, but other mobile
solutions also suffer from these symptoms.

Disabling L1 ASPM before we activate the PCI-E link fixes all of
these issues at the cost of some power consumption.

Remove a workaround RDTR adjustment that is no longer needed with
this new one.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/82571.c  |1 -
 drivers/net/e1000e/e1000.h  |1 -
 drivers/net/e1000e/netdev.c |   30 ++
 drivers/net/e1000e/param.c  |7 ---
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index b6401ab..45f5ee2 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -1343,7 +1343,6 @@ struct e1000_info e1000_82573_info = {
  | FLAG_HAS_STATS_ICR_ICT
  | FLAG_HAS_SMART_POWER_DOWN
  | FLAG_HAS_AMT
- | FLAG_HAS_ASPM
  | FLAG_HAS_ERT
  | FLAG_HAS_SWSM_ON_LOAD,
.pba= 20,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 473f78d..8b88c22 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -288,7 +288,6 @@ struct e1000_info {
 #define FLAG_HAS_CTRLEXT_ON_LOAD  (1 << 5)
 #define FLAG_HAS_SWSM_ON_LOAD (1 << 6)
 #define FLAG_HAS_JUMBO_FRAMES (1 << 7)
-#define FLAG_HAS_ASPM (1 << 8)
 #define FLAG_HAS_STATS_ICR_ICT(1 << 9)
 #define FLAG_HAS_STATS_PTC_PRC(1 << 10)
 #define FLAG_HAS_SMART_POWER_DOWN (1 << 11)
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 4fd2e23..ec427e2 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3511,6 +3511,33 @@ static int e1000_suspend(struct pci_dev *pdev, 
pm_message_t state)
return 0;
 }
 
+static void e1000e_disable_l1aspm(struct pci_dev *pdev)
+{
+   int pos;
+   u32 cap;
+   u16 val;
+
+   /*
+* 82573 workaround - disable L1 ASPM on mobile chipsets
+*
+* L1 ASPM on various mobile (ich7) chipsets do not behave properly
+* resulting in lost data or garbage information on the pci-e link
+* level. This could result in (false) bad EEPROM checksum errors,
+* long ping times (up to 2s) or even a system freeze/hang.
+*
+* Unfortunately this feature saves about 1W power consumption when
+* active.
+*/
+   pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+   pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &cap);
+   pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val);
+   if (val & 0x2) {
+   dev_warn(&pdev->dev, "Disabling L1 ASPM\n");
+   val &= ~0x2;
+   pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val);
+   }
+}
+
 #ifdef CONFIG_PM
 static int e1000_resume(struct pci_dev *pdev)
 {
@@ -3521,6 +3548,7 @@ static int e1000_resume(struct pci_dev *pdev)
 
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
+   e1000e_disable_l1aspm(pdev);
err = pci_enable_device(pdev);
if (err) {
dev_err(&pdev->dev,
@@ -3621,6 +3649,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct 
pci_dev *pdev)
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
 
+   e1000e_disable_l1aspm(pdev);
if (pci_enable_device(pdev)) {
dev_err(&pdev->dev,
"Cannot re-enable PCI device after reset.\n");
@@ -3722,6 +3751,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
u16 eeprom_data = 0;
u16 eeprom_apme_mask = E1000_EEPROM_APME;
 
+   e1000e_disable_l1aspm(pdev);
err = pci_enable_device(pdev);
if (err)
return err;
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
index 3327892..df266c3 100644
--- a/drivers/net/e1000e/param.c
+++ b/drivers/net/e1000e/param.c
@@ -262,13 +262,6 @@ void __devinit e1000e_check_options(struct e1000_adapter 
*adapter)
 .max = MAX_RXDELAY } }
};
 
-   /* modify min and default if 82573 for slow ping w/a,
-* a value greater than 8 n

[PATCH] ixgb: fix TX hangs under heavy load

2007-10-30 Thread Auke Kok
A merge error occurred where we merged the wrong block here
in version 1.0.120. The right condition for frags is slightly
different then for the skb, so account for the difference properly
and trim the TSO based size right.

Originally part of a fix reported by IBM to fix TSO hangs on
pSeries hardware.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
Cc: Andy Gospodarek <[EMAIL PROTECTED]>
---

 drivers/net/ixgb/ixgb_main.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index e564335..3021234 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1321,8 +1321,8 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff 
*skb,
 
/* Workaround for premature desc write-backs
 * in TSO mode.  Append 4-byte sentinel desc */
-   if (unlikely(mss && !nr_frags && size == len
-&& size > 8))
+   if (unlikely(mss && (f == (nr_frags - 1))
+&& size == len && size > 8))
size -= 4;
 
buffer_info->length = size;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] ixgbe: minor sparse fixes

2007-10-29 Thread Auke Kok
From: Stephen Hemminger <[EMAIL PROTECTED]>

Make strings const if possible, and fix includes so forward definitions
are seen.

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe.h   |2 +-
 drivers/net/ixgbe/ixgbe_82598.c |3 +--
 drivers/net/ixgbe/ixgbe_main.c  |9 +
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index c160a7d..bc51432 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -244,7 +244,7 @@ extern struct ixgbe_info ixgbe_82598EB_info;
 extern struct ixgbe_info ixgbe_82598AT_info;
 
 extern char ixgbe_driver_name[];
-extern char ixgbe_driver_version[];
+extern const char ixgbe_driver_version[];
 
 extern int ixgbe_up(struct ixgbe_adapter *adapter);
 extern void ixgbe_down(struct ixgbe_adapter *adapter);
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 00ee201..4d64673 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -30,8 +30,7 @@
 #include 
 #include 
 
-#include "ixgbe_type.h"
-#include "ixgbe_common.h"
+#include "ixgbe.h"
 #include "ixgbe_phy.h"
 
 #define IXGBE_82598_MAX_TX_QUEUES 32
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index b75f1c6..00bc525 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -45,12 +45,13 @@
 #include "ixgbe_common.h"
 
 char ixgbe_driver_name[] = "ixgbe";
-static char ixgbe_driver_string[] =
-   "Intel(R) 10 Gigabit PCI Express Network Driver";
+static const char ixgbe_driver_string[] =
+   "Intel(R) 10 Gigabit PCI Express Network Driver";
 
 #define DRV_VERSION "1.1.18"
-char ixgbe_driver_version[] = DRV_VERSION;
-static char ixgbe_copyright[] = "Copyright (c) 1999-2007 Intel Corporation.";
+const char ixgbe_driver_version[] = DRV_VERSION;
+static const char ixgbe_copyright[] =
+"Copyright (c) 1999-2007 Intel Corporation.";
 
 static const struct ixgbe_info *ixgbe_info_tbl[] = {
[board_82598AF] = &ixgbe_82598AF_info,
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] e1000e: fix sparse warnings

2007-10-29 Thread Auke Kok
From: Stephen Hemminger <[EMAIL PROTECTED]>

Fix sparse warnings from e1000e driver in net-2.6.24.

Added a sparse fix for module param arrays which can have int values
but only the array index needs to be unsigned. --Auke

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |4 ++--
 drivers/net/e1000e/param.c   |   35 ++-
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 0666e62..6a39784 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1680,8 +1680,8 @@ static int e1000_phys_id(struct net_device *netdev, u32 
data)
 {
struct e1000_adapter *adapter = netdev_priv(netdev);
 
-   if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
-   data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
+   if (!data)
+   data = INT_MAX;
 
if (adapter->hw.phy.type == e1000_phy_ife) {
if (!adapter->blink_timer.function) {
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
index e4e655e..3327892 100644
--- a/drivers/net/e1000e/param.c
+++ b/drivers/net/e1000e/param.c
@@ -52,10 +52,11 @@ MODULE_PARM_DESC(copybreak,
  */
 
 #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
-#define E1000_PARAM(X, desc) \
-   static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
-   static int num_##X; \
-   module_param_array_named(X, X, int, &num_##X, 0); \
+#define E1000_PARAM(X, desc)   \
+   static int __devinitdata X[E1000_MAX_NIC+1] \
+   = E1000_PARAM_INIT; \
+   static unsigned int num_##X;\
+   module_param_array_named(X, X, int, &num_##X, 0);   \
MODULE_PARM_DESC(X, desc);
 
 
@@ -124,9 +125,9 @@ E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss 
workaround");
 
 struct e1000_option {
enum { enable_option, range_option, list_option } type;
-   char *name;
-   char *err;
-   int  def;
+   const char *name;
+   const char *err;
+   int def;
union {
struct { /* range_option info */
int min;
@@ -139,8 +140,8 @@ struct e1000_option {
} arg;
 };
 
-static int __devinit e1000_validate_option(int *value,
-  struct e1000_option *opt,
+static int __devinit e1000_validate_option(unsigned int *value,
+  const struct e1000_option *opt,
   struct e1000_adapter *adapter)
 {
if (*value == OPTION_UNSET) {
@@ -213,7 +214,7 @@ void __devinit e1000e_check_options(struct e1000_adapter 
*adapter)
}
 
{ /* Transmit Interrupt Delay */
-   struct e1000_option opt = {
+   const struct e1000_option opt = {
.type = range_option,
.name = "Transmit Interrupt Delay",
.err  = "using default of "
@@ -232,7 +233,7 @@ void __devinit e1000e_check_options(struct e1000_adapter 
*adapter)
}
}
{ /* Transmit Absolute Interrupt Delay */
-   struct e1000_option opt = {
+   const struct e1000_option opt = {
.type = range_option,
.name = "Transmit Absolute Interrupt Delay",
.err  = "using default of "
@@ -277,7 +278,7 @@ void __devinit e1000e_check_options(struct e1000_adapter 
*adapter)
}
}
{ /* Receive Absolute Interrupt Delay */
-   struct e1000_option opt = {
+   const struct e1000_option opt = {
.type = range_option,
.name = "Receive Absolute Interrupt Delay",
.err  = "using default of "
@@ -296,7 +297,7 @@ void __devinit e1000e_check_options(struct e1000_adapter 
*adapter)
}
}
{ /* Interrupt Throttling Rate */
-   struct e1000_option opt = {
+   const struct e1000_option opt = {
.type = range_option,
.name = "Interrupt Throttling Rate (ints/sec)",
.err  = "using default of "
@@ -344,7 +345,7 @@ void __devinit e1000e_check_options(struct e1000_adapter 
*adapter)
}
}
{ /* Smart Power Down */
-   struct e1000_option opt = {
+   const struct e1000_option opt = {
.type = enable_option,
.name = "PHY Smart Power Down",
.err  = "defaulting t

netdev@vger.kernel.org

2007-10-29 Thread Auke Kok
From: Roel Kluin <[EMAIL PROTECTED]>

Signed-off-by: Roel Kluin <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/82571.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index cf70522..14141a5 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -283,7 +283,7 @@ static s32 e1000_get_invariants_82571(struct e1000_adapter 
*adapter)
adapter->flags &= ~FLAG_HAS_WOL;
/* quad ports only support WoL on port A */
if (adapter->flags & FLAG_IS_QUAD_PORT &&
-   (!adapter->flags & FLAG_IS_QUAD_PORT_A))
+   (!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
adapter->flags &= ~FLAG_HAS_WOL;
break;
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] e1000: sparse warnings fixes

2007-10-29 Thread Auke Kok
From: Stephen Hemminger <[EMAIL PROTECTED]>

Fix sparse warnings and problems from e1000 driver.

Added a sparse fix for the module param array index
-- Auke

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000.h |8 
 drivers/net/e1000/e1000_ethtool.c |   29 -
 drivers/net/e1000/e1000_hw.c  |4 ++--
 drivers/net/e1000/e1000_main.c|7 ++-
 drivers/net/e1000/e1000_param.c   |   23 ---
 5 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 781ed99..3b84028 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -351,4 +351,12 @@ enum e1000_state_t {
__E1000_DOWN
 };
 
+extern char e1000_driver_name[];
+extern const char e1000_driver_version[];
+
+extern void e1000_power_up_phy(struct e1000_adapter *);
+extern void e1000_set_ethtool_ops(struct net_device *netdev);
+extern void e1000_check_options(struct e1000_adapter *adapter);
+
+
 #endif /* _E1000_H_ */
diff --git a/drivers/net/e1000/e1000_ethtool.c 
b/drivers/net/e1000/e1000_ethtool.c
index 6c9a643..667f18b 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -32,9 +32,6 @@
 
 #include 
 
-extern char e1000_driver_name[];
-extern char e1000_driver_version[];
-
 extern int e1000_up(struct e1000_adapter *adapter);
 extern void e1000_down(struct e1000_adapter *adapter);
 extern void e1000_reinit_locked(struct e1000_adapter *adapter);
@@ -733,16 +730,16 @@ err_setup:
 
 #define REG_PATTERN_TEST(R, M, W)  
\
 {  
\
-   uint32_t pat, value;   \
-   uint32_t test[] =  \
+   uint32_t pat, val; \
+   const uint32_t test[] =\
{0x5A5A5A5A, 0xA5A5A5A5, 0x, 0x};  \
-   for (pat = 0; pat < ARRAY_SIZE(test); pat++) {  \
+   for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \
E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
-   value = E1000_READ_REG(&adapter->hw, R);   \
-   if (value != (test[pat] & W & M)) { 
\
+   val = E1000_READ_REG(&adapter->hw, R); \
+   if (val != (test[pat] & W & M)) {  \
DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \
"0x%08X expected 0x%08X\n",\
-   E1000_##R, value, (test[pat] & W & M));\
+   E1000_##R, val, (test[pat] & W & M));  \
*data = (adapter->hw.mac_type < e1000_82543) ? \
E1000_82542_##R : E1000_##R;   \
return 1;  \
@@ -752,12 +749,12 @@ err_setup:
 
 #define REG_SET_AND_CHECK(R, M, W) 
\
 {  
\
-   uint32_t value;\
+   uint32_t val;  \
E1000_WRITE_REG(&adapter->hw, R, W & M);   \
-   value = E1000_READ_REG(&adapter->hw, R);   \
-   if ((W & M) != (value & M)) {  \
+   val = E1000_READ_REG(&adapter->hw, R); \
+   if ((W & M) != (val & M)) {\
DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\
-   "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \
+   "expected 0x%08X\n", E1000_##R, (val & M), (W & M));   \
*data = (adapter->hw.mac_type < e1000_82543) ? \
E1000_82542_##R : E1000_##R;   \
return 1;  \
@@ -1621,8 +1618,6 @@ e1000_get_sset_count(struct net_device *netdev, int sset)
}
 }
 
-extern void e1000_power_up_phy(struct e1000_adapter *);
-
 static void
 e1000_diag_test(struct net_device *netdev,
 

[PATCH 2/4] ixgb: fix sparse warnings

2007-10-29 Thread Auke Kok
From: Stephen Hemminger <[EMAIL PROTECTED]>

Fix sparse warnings in ixgb driver for net-2.6.24.

Added a sparse fix for invalid declaration using non-constant value
in ixgb_set_multi. Added a fix for the module param array index
and allows int params in the array. --Auke

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgb/ixgb.h |7 ++
 drivers/net/ixgb/ixgb_ethtool.c |7 ++
 drivers/net/ixgb/ixgb_hw.c  |4 ++--
 drivers/net/ixgb/ixgb_main.c|   11 --
 drivers/net/ixgb/ixgb_param.c   |   43 ---
 5 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
index 1eee889..3d2e721 100644
--- a/drivers/net/ixgb/ixgb.h
+++ b/drivers/net/ixgb/ixgb.h
@@ -196,4 +196,11 @@ struct ixgb_adapter {
uint32_t alloc_rx_buff_failed;
boolean_t have_msi;
 };
+
+/* Exported from other modules */
+extern void ixgb_check_options(struct ixgb_adapter *adapter);
+extern void ixgb_set_ethtool_ops(struct net_device *netdev);
+extern char ixgb_driver_name[];
+extern const char ixgb_driver_version[];
+
 #endif /* _IXGB_H_ */
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index fddd584..a267dd8 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -32,9 +32,6 @@
 
 #include 
 
-extern char ixgb_driver_name[];
-extern char ixgb_driver_version[];
-
 extern int ixgb_up(struct ixgb_adapter *adapter);
 extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
 extern void ixgb_reset(struct ixgb_adapter *adapter);
@@ -639,8 +636,8 @@ ixgb_phys_id(struct net_device *netdev, uint32_t data)
 {
struct ixgb_adapter *adapter = netdev_priv(netdev);
 
-   if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
-   data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
+   if (!data)
+   data = INT_MAX;
 
if(!adapter->blink_timer.function) {
init_timer(&adapter->blink_timer);
diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
index ecbf458..2c6367a 100644
--- a/drivers/net/ixgb/ixgb_hw.c
+++ b/drivers/net/ixgb/ixgb_hw.c
@@ -1174,7 +1174,7 @@ mac_addr_valid(uint8_t *mac_addr)
  *
  * hw - Struct containing variables accessed by shared code
  */
-boolean_t
+static boolean_t
 ixgb_link_reset(struct ixgb_hw *hw)
 {
boolean_t link_status = FALSE;
@@ -1205,7 +1205,7 @@ ixgb_link_reset(struct ixgb_hw *hw)
  *
  * hw - Struct containing variables accessed by shared code
  */
-void
+static void
 ixgb_optics_reset(struct ixgb_hw *hw)
 {
if (hw->phy_type == ixgb_phy_type_txn17401) {
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index d444de5..e564335 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -37,8 +37,8 @@ static char ixgb_driver_string[] = "Intel(R) PRO/10GbE 
Network Driver";
 #define DRIVERNAPI "-NAPI"
 #endif
 #define DRV_VERSION"1.0.126-k2"DRIVERNAPI
-char ixgb_driver_version[] = DRV_VERSION;
-static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
+const char ixgb_driver_version[] = DRV_VERSION;
+static const char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel 
Corporation.";
 
 /* ixgb_pci_tbl - PCI Device ID Table
  *
@@ -104,7 +104,6 @@ static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter 
*adapter,
 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
 #endif
 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
-void ixgb_set_ethtool_ops(struct net_device *netdev);
 static void ixgb_tx_timeout(struct net_device *dev);
 static void ixgb_tx_timeout_task(struct work_struct *work);
 static void ixgb_vlan_rx_register(struct net_device *netdev,
@@ -123,9 +122,6 @@ static pci_ers_result_t ixgb_io_error_detected (struct 
pci_dev *pdev,
 static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
 static void ixgb_io_resume (struct pci_dev *pdev);
 
-/* Exported from other modules */
-extern void ixgb_check_options(struct ixgb_adapter *adapter);
-
 static struct pci_error_handlers ixgb_err_handler = {
.error_detected = ixgb_io_error_detected,
.slot_reset = ixgb_io_slot_reset,
@@ -1085,7 +1081,8 @@ ixgb_set_multi(struct net_device *netdev)
rctl |= IXGB_RCTL_MPE;
IXGB_WRITE_REG(hw, RCTL, rctl);
} else {
-   uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
+   uint8_t mta[IXGB_MAX_NUM_MULTICAST_ADDRESSES *
+   IXGB_ETH_LENGTH_OF_ADDRESS];
 
IXGB_WRITE_REG(hw, RCTL, rctl);
 
d

[PATCH] pcnet: fix sparse triviality

2007-10-26 Thread Auke Kok
Since data can never exceed u32, it can't even be larger than LONG_MAX/HZ.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
---

 drivers/net/pcnet32.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index ff92aca..3573e77 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1101,9 +1101,8 @@ static int pcnet32_phys_id(struct net_device *dev, u32 
data)
mod_timer(&lp->blink_timer, jiffies);
set_current_state(TASK_INTERRUPTIBLE);
 
-   /* AV: the limit here makes no sense whatsoever */
-   if ((!data) || (data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ)))
-   data = (u32) (MAX_SCHEDULE_TIMEOUT / HZ);
+   if (!data)
+   data = INT_MAX;
 
msleep_interruptible(data * 1000);
del_timer_sync(&lp->blink_timer);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] skye/skge: sparse fix - data can't ever be bigger than LONG_MAX / HZ

2007-10-26 Thread Auke Kok
Trivial replacement - use INT_MAX instead here.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
---

 drivers/net/sk98lin/skethtool.c |4 ++--
 drivers/net/skge.c  |8 
 drivers/net/sky2.c  |8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index 5a6da89..4549b97 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -430,8 +430,8 @@ static int locateDevice(struct net_device *dev, u32 data)
DEV_NET *pNet = netdev_priv(dev);
SK_AC *pAC = pNet->pAC;
 
-   if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
-   data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
+   if (!data)
+   data = INT_MAX;
 
/* start blinking */
pAC->LedsOn = 0;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index b9961dc..696a79e 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -783,10 +783,10 @@ static int skge_phys_id(struct net_device *dev, u32 data)
unsigned long ms;
enum led_mode mode = LED_MODE_TST;
 
-   if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
-   ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000;
-   else
-   ms = data * 1000;
+   if (!data)
+   data = INT_MAX;
+
+   ms = data * HZ;
 
while (ms > 0) {
skge_led(skge, mode);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index c27c7d6..1381d04 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -3336,10 +3336,10 @@ static int sky2_phys_id(struct net_device *dev, u32 
data)
int interrupted;
int onoff = 1;
 
-   if (!data || data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ))
-   ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT);
-   else
-   ms = data * 1000;
+   if (!data)
+   data = INT_MAX:
+
+   ms = data * HZ;
 
/* save initial values */
spin_lock_bh(&sky2->phy_lock);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] e1000e: Re-enable SECRC - crc stripping

2007-10-25 Thread Auke Kok
This workaround code performed software stripping instead of the
hardware which can do it much faster. None of the e1000e target
hardware has issues with this feature and should work fine. This
gives us some performance back on receive, and removes some
kludging stripping the 4 bytes.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |   19 ++-
 1 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index e87ed31..03fcc70 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -494,10 +494,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter 
*adapter,
goto next_desc;
}
 
-   /* adjust length to remove Ethernet CRC */
-   length -= 4;
-
-   /* probably a little skewed due to removing CRC */
total_rx_bytes += length;
total_rx_packets++;
 
@@ -964,8 +960,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter 
*adapter,
kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
pci_dma_sync_single_for_device(pdev, ps_page->dma,
PAGE_SIZE, PCI_DMA_FROMDEVICE);
-   /* remove the CRC */
-   l1 -= 4;
+
skb_put(skb, l1);
goto copydone;
} /* if */
@@ -987,10 +982,6 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter 
*adapter,
skb->truesize += length;
}
 
-   /* strip the ethernet crc, problem is we're using pages now so
-* this whole operation can get a little cpu intensive */
-   pskb_trim(skb, skb->len - 4);
-
 copydone:
total_rx_bytes += skb->len;
total_rx_packets++;
@@ -2034,9 +2025,11 @@ static void e1000_setup_rctl(struct e1000_adapter 
*adapter)
 
ew32(RFCTL, rfctl);
 
-   /* disable the stripping of CRC because it breaks
-* BMC firmware connected over SMBUS */
-   rctl |= E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */;
+   /* Enable Packet split descriptors */
+   rctl |= E1000_RCTL_DTYP_PS;
+   
+   /* Enable hardware CRC frame stripping */
+   rctl |= E1000_RCTL_SECRC;
 
psrctl |= adapter->rx_ps_bsize0 >>
E1000_PSRCTL_BSIZE0_SHIFT;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] e1000e: Fix PBA calculation for jumbo frame packets

2007-10-25 Thread Auke Kok
Upon inspection the rx FIFO size calculation code was found to have
2 significant flaws: A superfluous minus sign resulting in the
wrong size to be used for jumbo frames on 82573 and ich9, as well
as that this code rewrote the read-only adapter->pba variable
resulting in different values at each run.

Without this patch jumbo's will work but performance will be
awkward since the TX size is not adequate for two whole frames.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |   22 +-
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 46c5ac6..e87ed31 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2328,8 +2328,11 @@ void e1000e_reset(struct e1000_adapter *adapter)
struct e1000_mac_info *mac = &adapter->hw.mac;
struct e1000_hw *hw = &adapter->hw;
u32 tx_space, min_tx_space, min_rx_space;
+   u32 pba;
u16 hwm;
 
+   ew32(PBA, adapter->pba);
+
if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) {
/* To maintain wire speed transmits, the Tx FIFO should be
 * large enough to accommodate two full transmit packets,
@@ -2337,11 +2340,11 @@ void e1000e_reset(struct e1000_adapter *adapter)
 * the Rx FIFO should be large enough to accommodate at least
 * one full receive packet and is similarly rounded up and
 * expressed in KB. */
-   adapter->pba = er32(PBA);
+   pba = er32(PBA);
/* upper 16 bits has Tx packet buffer allocation size in KB */
-   tx_space = adapter->pba >> 16;
+   tx_space = pba >> 16;
/* lower 16 bits has Rx packet buffer allocation size in KB */
-   adapter->pba &= 0x;
+   pba &= 0x;
/* the tx fifo also stores 16 bytes of information about the tx
 * but don't include ethernet FCS because hardware appends it */
min_tx_space = (mac->max_frame_size +
@@ -2357,20 +2360,21 @@ void e1000e_reset(struct e1000_adapter *adapter)
/* If current Tx allocation is less than the min Tx FIFO size,
 * and the min Tx FIFO size is less than the current Rx FIFO
 * allocation, take space away from current Rx allocation */
-   if (tx_space < min_tx_space &&
-   ((min_tx_space - tx_space) < adapter->pba)) {
-   adapter->pba -= - (min_tx_space - tx_space);
+   if ((tx_space < min_tx_space) &&
+   ((min_tx_space - tx_space) < pba)) {
+   pba -= min_tx_space - tx_space;
 
/* if short on rx space, rx wins and must trump tx
 * adjustment or use Early Receive if available */
-   if ((adapter->pba < min_rx_space) &&
+   if ((pba < min_rx_space) &&
(!(adapter->flags & FLAG_HAS_ERT)))
/* ERT enabled in e1000_configure_rx */
-   adapter->pba = min_rx_space;
+   pba = min_rx_space;
}
+
+   ew32(PBA, pba);
}
 
-   ew32(PBA, adapter->pba);
 
/* flow control settings */
/* The high water mark must be low enough to fit one full frame
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] e1000e: Remove legacy jumbo frame receive code

2007-10-25 Thread Auke Kok
The legacy jumbo frame receive code is no longer needed since all
hardware can do packet split and we're no longer offering a bypass
kernel config option to disable packet split. Remove the unused code.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |1 
 drivers/net/e1000e/netdev.c |  282 ---
 2 files changed, 1 insertions(+), 282 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 811eada..473f78d 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -122,7 +122,6 @@ struct e1000_buffer {
u16 next_to_watch;
};
/* RX */
-   struct page *page;
/* arrays of page information for packet split */
struct e1000_ps_page *ps_pages;
};
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 03fcc70..4fd2e23 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -333,94 +333,6 @@ no_buffers:
 }
 
 /**
- * e1000_alloc_rx_buffers_jumbo - Replace used jumbo receive buffers
- *
- * @adapter: address of board private structure
- * @cleaned_count: number of buffers to allocate this pass
- **/
-static void e1000_alloc_rx_buffers_jumbo(struct e1000_adapter *adapter,
-int cleaned_count)
-{
-   struct net_device *netdev = adapter->netdev;
-   struct pci_dev *pdev = adapter->pdev;
-   struct e1000_ring *rx_ring = adapter->rx_ring;
-   struct e1000_rx_desc *rx_desc;
-   struct e1000_buffer *buffer_info;
-   struct sk_buff *skb;
-   unsigned int i;
-   unsigned int bufsz = 256 -
-16 /*for skb_reserve */ -
-NET_IP_ALIGN;
-
-   i = rx_ring->next_to_use;
-   buffer_info = &rx_ring->buffer_info[i];
-
-   while (cleaned_count--) {
-   skb = buffer_info->skb;
-   if (skb) {
-   skb_trim(skb, 0);
-   goto check_page;
-   }
-
-   skb = netdev_alloc_skb(netdev, bufsz);
-   if (!skb) {
-   /* Better luck next round */
-   adapter->alloc_rx_buff_failed++;
-   break;
-   }
-
-   /* Make buffer alignment 2 beyond a 16 byte boundary
-* this will result in a 16 byte aligned IP header after
-* the 14 byte MAC header is removed
-*/
-   skb_reserve(skb, NET_IP_ALIGN);
-
-   buffer_info->skb = skb;
-check_page:
-   /* allocate a new page if necessary */
-   if (!buffer_info->page) {
-   buffer_info->page = alloc_page(GFP_ATOMIC);
-   if (!buffer_info->page) {
-   adapter->alloc_rx_buff_failed++;
-   break;
-   }
-   }
-
-   if (!buffer_info->dma)
-   buffer_info->dma = pci_map_page(pdev,
-   buffer_info->page, 0,
-   PAGE_SIZE,
-   PCI_DMA_FROMDEVICE);
-   if (pci_dma_mapping_error(buffer_info->dma)) {
-   dev_err(&adapter->pdev->dev, "RX DMA page map 
failed\n");
-   adapter->rx_dma_failed++;
-   break;
-   }
-
-   rx_desc = E1000_RX_DESC(*rx_ring, i);
-   rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
-
-   i++;
-   if (i == rx_ring->count)
-   i = 0;
-   buffer_info = &rx_ring->buffer_info[i];
-   }
-
-   if (rx_ring->next_to_use != i) {
-   rx_ring->next_to_use = i;
-   if (i-- == 0)
-   i = (rx_ring->count - 1);
-
-   /* Force memory writes to complete before letting h/w
-* know there are new descriptors to fetch.  (Only
-* applicable for weak-ordered memory model archs,
-* such as IA-64). */
-   wmb();
-   writel(i, adapter->hw.hw_addr + rx_ring->tail);
-   }
-}
-
-/**
  * e1000_clean_rx_irq - Send received data up the network stack; legacy
  * @adapter: board private structure
  *
@@ -549,15 +461,6 @@ next_desc:
return cleaned;
 }
 
-static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
-  u16 length)
-{
-   bi->page = NULL;
-   skb->len += length;
-   skb->data_len += length;
-   skb->truesize += length;
-}
-
 static void e1

[PATCH 1/4] e1000e: Fix jumbo frame receive code.

2007-10-25 Thread Auke Kok
Fix allocation and freeing of jumbo frames where several bugs
were recently introduced by cleanups after we forked this code
from e1000. This moves ps_pages to buffer_info where it really
belongs and makes it a dynamically allocated array. The penalty
is not that high since it's allocated outside of the buffer_info
struct anyway.

Without this patch all jumbo frames are completely broken and the
driver panics.

Signed-off-by: Jesse Brandeburg <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |4 +-
 drivers/net/e1000e/netdev.c |  102 ++-
 2 files changed, 54 insertions(+), 52 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index d2499bb..811eada 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -123,6 +123,8 @@ struct e1000_buffer {
};
/* RX */
struct page *page;
+   /* arrays of page information for packet split */
+   struct e1000_ps_page *ps_pages;
};
 
 };
@@ -142,8 +144,6 @@ struct e1000_ring {
/* array of buffer information structs */
struct e1000_buffer *buffer_info;
 
-   /* arrays of page information for packet split */
-   struct e1000_ps_page *ps_pages;
struct sk_buff *rx_skb_top;
 
struct e1000_queue_stats stats;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 033e124..46c5ac6 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -245,37 +245,36 @@ static void e1000_alloc_rx_buffers_ps(struct 
e1000_adapter *adapter,
rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
 
for (j = 0; j < PS_PAGE_BUFFERS; j++) {
-   ps_page = &rx_ring->ps_pages[(i * PS_PAGE_BUFFERS)
-+ j];
-   if (j < adapter->rx_ps_pages) {
+   ps_page = &buffer_info->ps_pages[j];
+   if (j >= adapter->rx_ps_pages) {
+   /* all unused desc entries get hw null ptr */
+   rx_desc->read.buffer_addr[j+1] = ~0;
+   continue;
+   }
+   if (!ps_page->page) {
+   ps_page->page = alloc_page(GFP_ATOMIC);
if (!ps_page->page) {
-   ps_page->page = alloc_page(GFP_ATOMIC);
-   if (!ps_page->page) {
-   adapter->alloc_rx_buff_failed++;
-   goto no_buffers;
-   }
-   ps_page->dma = pci_map_page(pdev,
-  ps_page->page,
-  0, PAGE_SIZE,
-  PCI_DMA_FROMDEVICE);
-   if (pci_dma_mapping_error(
-   ps_page->dma)) {
-   dev_err(&adapter->pdev->dev,
- "RX DMA page map failed\n");
-   adapter->rx_dma_failed++;
-   goto no_buffers;
-   }
+   adapter->alloc_rx_buff_failed++;
+   goto no_buffers;
+   }
+   ps_page->dma = pci_map_page(pdev,
+  ps_page->page,
+  0, PAGE_SIZE,
+  PCI_DMA_FROMDEVICE);
+   if (pci_dma_mapping_error(ps_page->dma)) {
+   dev_err(&adapter->pdev->dev,
+ "RX DMA page map failed\n");
+   adapter->rx_dma_failed++;
+   goto no_buffers;
}
-   /*
-* Refresh the desc even if buffer_addrs
-* didn't change because each write-back
-* erases this info.
-*/
-   rx_desc->read.buffer_addr[j+1] =
-cpu_to_le64(ps_page->dma);
-   } else {
-   

[PATCH] e1000e: don't poke PHY registers to retreive link status

2007-10-15 Thread Auke Kok
Apparently poking the link status registers when autonegotiation
is running on the PHY might botch the PHY link on 80003es2lan
devices. While this is a very rare condition we can completely
avoid it alltogether by just using the MAC link bits to provide
the proper information to ethtool.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |   31 +--
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index b7a7e2a..983b031 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -110,6 +110,7 @@ static int e1000_get_settings(struct net_device *netdev,
 {
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
+   u32 status;
 
if (hw->media_type == e1000_media_type_copper) {
 
@@ -147,16 +148,16 @@ static int e1000_get_settings(struct net_device *netdev,
ecmd->transceiver = XCVR_EXTERNAL;
}
 
-   if (er32(STATUS) & E1000_STATUS_LU) {
-
-   adapter->hw.mac.ops.get_link_up_info(hw, &adapter->link_speed,
- &adapter->link_duplex);
-   ecmd->speed = adapter->link_speed;
-
-   /* unfortunately FULL_DUPLEX != DUPLEX_FULL
-*and HALF_DUPLEX != DUPLEX_HALF */
+   status = er32(STATUS);
+   if (status & E1000_STATUS_LU) {
+   if (status & E1000_STATUS_SPEED_1000)
+   ecmd->speed = 1000;
+   else if (status & E1000_STATUS_SPEED_100)
+   ecmd->speed = 100;
+   else
+   ecmd->speed = 10;
 
-   if (adapter->link_duplex == FULL_DUPLEX)
+   if (status & E1000_STATUS_FD)
ecmd->duplex = DUPLEX_FULL;
else
ecmd->duplex = DUPLEX_HALF;
@@ -170,6 +171,16 @@ static int e1000_get_settings(struct net_device *netdev,
return 0;
 }
 
+static u32 e1000_get_link(struct net_device *netdev)
+{
+   struct e1000_adapter *adapter = netdev_priv(netdev);
+   struct e1000_hw *hw = &adapter->hw;
+   u32 status;
+   
+   status = er32(STATUS);
+   return (status & E1000_STATUS_LU);
+}
+
 static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
 {
struct e1000_mac_info *mac = &adapter->hw.mac;
@@ -1751,7 +1762,7 @@ static const struct ethtool_ops e1000_ethtool_ops = {
.get_msglevel   = e1000_get_msglevel,
.set_msglevel   = e1000_set_msglevel,
.nway_reset = e1000_nway_reset,
-   .get_link   = ethtool_op_get_link,
+   .get_link   = e1000_get_link,
.get_eeprom_len = e1000_get_eeprom_len,
.get_eeprom = e1000_get_eeprom,
.set_eeprom = e1000_set_eeprom,
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] e1000e: Fix debug printk macro

2007-10-15 Thread Auke Kok
Spotted by Joe Perches.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/hw.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index aa82f1a..6451578 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -852,7 +852,7 @@ struct e1000_hw {
 
 #ifdef DEBUG
 #define hw_dbg(hw, format, arg...) \
-   printk(KERN_DEBUG, "%s: " format, e1000e_get_hw_dev_name(hw), ##arg);
+   printk(KERN_DEBUG "%s: " format, e1000e_get_hw_dev_name(hw), ##arg)
 #else
 static inline int __attribute__ ((format (printf, 2, 3)))
 hw_dbg(struct e1000_hw *hw, const char *format, ...)
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] e1000e: fix error checks

2007-10-15 Thread Auke Kok
From: Adrian Bunk <[EMAIL PROTECTED]>

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index b7a7e2a..ca06c35 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1451,11 +1451,11 @@ static int e1000_loopback_test(struct e1000_adapter 
*adapter, u64 *data)
}
 
*data = e1000_setup_desc_rings(adapter);
-   if (data)
+   if (*data)
goto out;
 
*data = e1000_setup_loopback_test(adapter);
-   if (data)
+   if (*data)
goto err_loopback;
 
*data = e1000_run_loopback_test(adapter);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000e: restore flow control settings properly

2007-10-05 Thread Auke Kok
After a cable unplug the forced flow control settings were lost
accidentally and the flow control settings fell back to the default
EEPROM determined values. This breaks for people who want to
run without fc enabled - after a cable reset the driver would
refuse to run with fc disabled.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |1 +
 drivers/net/e1000e/lib.c |   12 +---
 drivers/net/e1000e/netdev.c  |1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 2e8218f..b7a7e2a 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -301,6 +301,7 @@ static int e1000_set_pauseparam(struct net_device *netdev,
hw->mac.original_fc = hw->mac.fc;
 
if (adapter->fc_autoneg == AUTONEG_ENABLE) {
+   hw->mac.fc = e1000_fc_default;
if (netif_running(adapter->netdev)) {
e1000e_down(adapter);
e1000e_up(adapter);
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 3bbfe60..0bdeca3 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -639,9 +639,15 @@ s32 e1000e_setup_link(struct e1000_hw *hw)
if (e1000_check_reset_block(hw))
return 0;
 
-   ret_val = e1000_set_default_fc_generic(hw);
-   if (ret_val)
-   return ret_val;
+   /*
+* If flow control is set to default, set flow control based on
+* the EEPROM flow control settings.
+*/
+   if (mac->fc == e1000_fc_default) {
+   ret_val = e1000_set_default_fc_generic(hw);
+   if (ret_val)
+   return ret_val;
+   }
 
/* We want to save off the original Flow Control configuration just
 * in case we get disconnected and then reconnected into a different
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 3a0bb2a..71c9fed 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4196,6 +4196,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 
/* Initialize link parameters. User can change them with ethtool */
adapter->hw.mac.autoneg = 1;
+   adapter->fc_autoneg = 1;
adapter->hw.mac.original_fc = e1000_fc_default;
adapter->hw.mac.fc = e1000_fc_default;
adapter->hw.phy.autoneg_advertised = 0x2f;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] e1000: Simple optimizations in e1000_xmit_frame

2007-10-05 Thread Auke Kok
From: Krishna Kumar <[EMAIL PROTECTED]>

Some simple optimizations in e1000_xmit_frame.

Signed-off-by: Krishna Kumar <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_main.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 10505de..0472638 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3261,14 +3261,13 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device 
*netdev)
unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
unsigned int tx_flags = 0;
-   unsigned int len = skb->len;
+   unsigned int len = skb->len - skb->data_len;
unsigned long flags;
-   unsigned int nr_frags = 0;
-   unsigned int mss = 0;
+   unsigned int nr_frags;
+   unsigned int mss;
int count = 0;
int tso;
unsigned int f;
-   len -= skb->data_len;
 
/* This goes back to the question of how to logically map a tx queue
 * to a flow.  Right now, performance is impacted slightly negatively
@@ -3302,7 +3301,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device 
*netdev)
* points to just header, pull a few bytes of payload from
* frags into skb->data */
hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-   if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
+   if (skb->data_len && hdr_len == len) {
switch (adapter->hw.mac_type) {
unsigned int pull_size;
case e1000_82544:
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] e1000e: Simple optimizations in e1000_xmit_frame

2007-10-05 Thread Auke Kok
After an e1000 patch from Krishna Kumar <[EMAIL PROTECTED]>.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 71c9fed..033e124 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3424,14 +3424,13 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct 
net_device *netdev)
unsigned int max_per_txd = E1000_MAX_PER_TXD;
unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
unsigned int tx_flags = 0;
-   unsigned int len = skb->len;
+   unsigned int len = skb->len - skb->data_len;
unsigned long irq_flags;
-   unsigned int nr_frags = 0;
-   unsigned int mss = 0;
+   unsigned int nr_frags;
+   unsigned int mss;
int count = 0;
int tso;
unsigned int f;
-   len -= skb->data_len;
 
if (test_bit(__E1000_DOWN, &adapter->state)) {
dev_kfree_skb_any(skb);
@@ -3459,7 +3458,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct 
net_device *netdev)
* points to just header, pull a few bytes of payload from
* frags into skb->data */
hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-   if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
+   if (skb->data_len && (hdr_len == len)) {
unsigned int pull_size;
 
pull_size = min((unsigned int)4, skb->data_len);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000e: Fix ethtool register test code

2007-10-04 Thread Auke Kok
A merge/cleanup code accidentally dropped 8254x code in and removed
8257x code here. Undo this mistake and use the pci-e relevant register
test similar as to what is in e1000.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 3423f33..2e8218f 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -784,10 +784,16 @@ static int e1000_reg_test(struct e1000_adapter *adapter, 
u64 *data)
REG_SET_AND_CHECK(E1000_RCTL, before, 0x003B);
REG_SET_AND_CHECK(E1000_TCTL, 0x, 0x);
 
-   REG_SET_AND_CHECK(E1000_RCTL, 0x, 0x01FF);
-   REG_PATTERN_TEST(E1000_RDBAL, 0xF000, 0x);
-   REG_PATTERN_TEST(E1000_TXCW, 0x, 0x);
-   REG_PATTERN_TEST(E1000_TDBAL, 0xF000, 0x);
+   REG_SET_AND_CHECK(E1000_RCTL, before, 0x);
+   REG_PATTERN_TEST(E1000_RDBAL, 0xFFF0, 0x);
+   if ((mac->type != e1000_ich8lan) &&
+   (mac->type != e1000_ich9lan))
+   REG_PATTERN_TEST(E1000_TXCW, 0xC000, 0x);
+   REG_PATTERN_TEST(E1000_TDBAL, 0xFFF0, 0x);
+   REG_PATTERN_TEST(E1000_TIDV, 0x, 0x);
+   for (i = 0; i < mac->rar_entry_count; i++)
+   REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1),
+  0x8003, 0x);
 
for (i = 0; i < mac->mta_reg_count; i++)
REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0x, 0x);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000e: fix debugging printout code

2007-10-04 Thread Auke Kok
A small bug crawled in the -DDEBUG enabled code. Fix this to
properly call the backreference device name.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/hw.h |2 +-
 drivers/net/e1000e/netdev.c |4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 848217a..aa82f1a 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -852,7 +852,7 @@ struct e1000_hw {
 
 #ifdef DEBUG
 #define hw_dbg(hw, format, arg...) \
-   printk(KERN_DEBUG, "%s: " format, e1000_get_hw_dev_name(hw), ##arg);
+   printk(KERN_DEBUG, "%s: " format, e1000e_get_hw_dev_name(hw), ##arg);
 #else
 static inline int __attribute__ ((format (printf, 2, 3)))
 hw_dbg(struct e1000_hw *hw, const char *format, ...)
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 4a21d7d..3a0bb2a 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -66,9 +66,7 @@ static const struct e1000_info *e1000_info_tbl[] = {
  **/
 char *e1000e_get_hw_dev_name(struct e1000_hw *hw)
 {
-   struct e1000_adapter *adapter = hw->back;
-   struct net_device *netdev = adapter->netdev;
-   return netdev->name;
+   return hw->adapter->netdev->name;
 }
 #endif
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ethtool: Add e1000e reg dump support (using e1000 decode function)

2007-10-04 Thread Auke Kok
The e1000 register dump code can print out e1000e register dump
information as well, so enable it for e1000e devices.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 ethtool.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 651529e..6c7a2e3 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1003,6 +1003,7 @@ static struct {
{ "r8169", realtek_dump_regs },
{ "de2104x", de2104x_dump_regs },
{ "e1000", e1000_dump_regs },
+   { "e1000e", e1000_dump_regs },
{ "igb", igb_dump_regs },
{ "ixgb", ixgb_dump_regs },
{ "ixgbe", ixgbe_dump_regs },
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000e: Do not allow requeue of freed skb

2007-09-21 Thread Auke Kok
From: Krishna Kumar <[EMAIL PROTECTED]>

Returning BUSY will make qdisc_restart enqueue the skb which was already
freed. The bad skb was correctly freed and we should return NETDEV_TX_OK.

First spotted by Jeff Garzik on 08/13/07.

Signed-off-by: Krishna Kumar <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 372da46..03f7472 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3537,7 +3537,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct 
net_device *netdev)
/* handle pci_map_single() error in e1000_tx_map */
dev_kfree_skb_any(skb);
spin_unlock_irqrestore(&adapter->tx_queue_lock, irq_flags);
-   return NETDEV_TX_BUSY;
+   return NETDEV_TX_OK;
}
 
e1000_tx_queue(adapter, tx_flags, count);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [-MM, FIX] ixgbe: incorporate napi_struct changes from net-2.6.24.git

2007-09-12 Thread Auke Kok
This incorporates the new napi_struct changes into ixgbe.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/ixgbe/ixgbe.h  |1 +
 drivers/net/ixgbe/ixgbe_main.c |   62 +---
 2 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index b24803f..c160a7d 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -179,6 +179,7 @@ struct ixgbe_adapter {
 
/* TX */
struct ixgbe_ring *tx_ring; /* One per active queue */
+   struct napi_struct napi;
u64 restart_queue;
u64 lsc_int;
u64 hw_tso_ctxt;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 23fb1ed..a08a462 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -557,14 +557,15 @@ static irqreturn_t ixgbe_msix_clean_rx(int irq, void 
*data)
struct ixgbe_adapter *adapter = rxr->adapter;
 
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, rxr->eims_value);
-   netif_rx_schedule(adapter->netdev);
+   netif_rx_schedule(adapter->netdev, &adapter->napi);
return IRQ_HANDLED;
 }
 
-static int ixgbe_clean_rxonly(struct net_device *netdev, int *budget)
+static int ixgbe_clean_rxonly(struct napi_struct *napi, int budget)
 {
-   struct ixgbe_adapter *adapter = netdev_priv(netdev);
-   int work_to_do = min(*budget, netdev->quota);
+   struct ixgbe_adapter *adapter = container_of(napi,
+   struct ixgbe_adapter, napi);
+   struct net_device *netdev = adapter->netdev;
int work_done = 0;
struct ixgbe_ring *rxr = adapter->rx_ring;
 
@@ -572,22 +573,18 @@ static int ixgbe_clean_rxonly(struct net_device *netdev, 
int *budget)
if (!netif_carrier_ok(netdev))
goto quit_polling;
 
-   ixgbe_clean_rx_irq(adapter, rxr, &work_done, work_to_do);
-
-   *budget -= work_done;
-   netdev->quota -= work_done;
+   ixgbe_clean_rx_irq(adapter, rxr, &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((work_done == 0) || !netif_running(netdev)) {
+   if ((work_done < budget) || !netif_running(netdev)) {
 quit_polling:
-   netif_rx_complete(netdev);
+   netif_rx_complete(netdev, napi);
if (!test_bit(__IXGBE_DOWN, &adapter->state))
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS,
rxr->eims_value);
-   return 0;
}
 
-   return 1;
+   return work_done;
 }
 
 /**
@@ -669,7 +666,8 @@ static int ixgbe_setup_msix(struct ixgbe_adapter *adapter)
goto release_irqs;
}
 
-   adapter->netdev->poll = ixgbe_clean_rxonly;
+   /* FIXME: implement netif_napi_remove() instead */
+   adapter->napi.poll = ixgbe_clean_rxonly;
adapter->flags |= IXGBE_FLAG_MSIX_ENABLED;
return 0;
 
@@ -713,12 +711,12 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
if (!test_bit(__IXGBE_DOWN, &adapter->state))
mod_timer(&adapter->watchdog_timer, jiffies);
}
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
/* Disable interrupts and register for poll. The flush of the
 * posted write is intentionally left out. */
atomic_inc(&adapter->irq_sem);
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0);
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
}
 
return IRQ_HANDLED;
@@ -1218,7 +1216,7 @@ static int ixgbe_up_complete(struct ixgbe_adapter 
*adapter)
ixgbe_configure_msi_and_legacy(adapter);
 
clear_bit(__IXGBE_DOWN, &adapter->state);
-   netif_poll_enable(netdev);
+   napi_enable(&adapter->napi);
ixgbe_irq_enable(adapter);
 
/* bring the link up in the watchdog, this could race with our first
@@ -1412,7 +1410,7 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
 
ixgbe_irq_disable(adapter);
 
-   netif_poll_disable(netdev);
+   napi_disable(&adapter->napi);
del_timer_sync(&adapter->watchdog_timer);
 
netif_carrier_off(netdev);
@@ -1464,11 +1462,12 @@ static void ixgbe_shutdown(struct pci_dev *pdev)
  * ixgbe_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int ixgbe_clean(struct net_device *netdev, int *budget)
+static int ixgbe_clean(struct napi_struct *napi, int budget)
 {
-   struct ixgbe_adapter *adapter = netdev_priv(netdev);
-   int work_to_do = min(*budget, netdev->quota);
-   int tx_cleaned, work_done = 0;
+   

[PATCH] [-MM, FIX V4] e1000e: incorporate napi_struct changes from net-2.6.24.git

2007-09-10 Thread Auke Kok
This incorporates the new napi_struct changes into e1000e. Included
bugfix for ifdown hang from Krishna Kumar for e1000.

Disabling polling is no longer needed at init time, so remove
napi_disable() call from _probe().

This also fixes an endless polling loop where the driver signalled
"polling done" improperly back to the stack.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |2 ++
 drivers/net/e1000e/netdev.c |   40 
 2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index c57e35a..d2499bb 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -187,6 +187,8 @@ struct e1000_adapter {
struct e1000_ring *tx_ring /* One per active queue */
cacheline_aligned_in_smp;
 
+   struct napi_struct napi;
+
unsigned long tx_queue_len;
unsigned int restart_queue;
u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 372da46..eeb40cc 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1662,10 +1662,10 @@ set_itr_now:
  * e1000_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
 {
-   struct e1000_adapter *adapter;
-   int work_to_do = min(*budget, poll_dev->quota);
+   struct e1000_adapter *adapter = container_of(napi, struct 
e1000_adapter, napi);
+   struct net_device *poll_dev = adapter->netdev;
int tx_cleaned = 0, work_done = 0;
 
/* Must NOT use netdev_priv macro here. */
@@ -1684,25 +1684,19 @@ static int e1000_clean(struct net_device *poll_dev, int 
*budget)
spin_unlock(&adapter->tx_queue_lock);
}
 
-   adapter->clean_rx(adapter, &work_done, work_to_do);
-   *budget -= work_done;
-   poll_dev->quota -= work_done;
+   adapter->clean_rx(adapter, &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((!tx_cleaned && (work_done == 0)) ||
+   if ((!tx_cleaned && (work_done < budget)) ||
   !netif_running(poll_dev)) {
 quit_polling:
if (adapter->itr_setting & 3)
e1000_set_itr(adapter);
-   netif_rx_complete(poll_dev);
-   if (test_bit(__E1000_DOWN, &adapter->state))
-   atomic_dec(&adapter->irq_sem);
-   else
-   e1000_irq_enable(adapter);
-   return 0;
+   netif_rx_complete(poll_dev, napi);
+   e1000_irq_enable(adapter);
}
 
-   return 1;
+   return work_done;
 }
 
 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2439,7 +2433,7 @@ int e1000e_up(struct e1000_adapter *adapter)
 
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(adapter->netdev);
+   napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
 
/* fire a link change interrupt to start the watchdog */
@@ -2472,7 +2466,7 @@ void e1000e_down(struct e1000_adapter *adapter)
e1e_flush();
msleep(10);
 
-   netif_poll_disable(netdev);
+   napi_disable(&adapter->napi);
e1000_irq_disable(adapter);
 
del_timer_sync(&adapter->w

[PATCH] [-MM, FIX V3] e1000e: incorporate napi_struct changes from net-2.6.24.git

2007-09-07 Thread Auke Kok
This incorporates the new napi_struct changes into e1000e. Included
bugfix for ifdown hang from Krishna Kumar for e1000.

Disabling polling is no longer needed at init time, so remove
napi_disable() call from _probe().

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |2 ++
 drivers/net/e1000e/netdev.c |   39 ---
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index c57e35a..d2499bb 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -187,6 +187,8 @@ struct e1000_adapter {
struct e1000_ring *tx_ring /* One per active queue */
cacheline_aligned_in_smp;
 
+   struct napi_struct napi;
+
unsigned long tx_queue_len;
unsigned int restart_queue;
u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 372da46..f8ec537 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1662,10 +1662,10 @@ set_itr_now:
  * e1000_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
 {
-   struct e1000_adapter *adapter;
-   int work_to_do = min(*budget, poll_dev->quota);
+   struct e1000_adapter *adapter = container_of(napi, struct 
e1000_adapter, napi);
+   struct net_device *poll_dev = adapter->netdev;
int tx_cleaned = 0, work_done = 0;
 
/* Must NOT use netdev_priv macro here. */
@@ -1684,25 +1684,20 @@ static int e1000_clean(struct net_device *poll_dev, int 
*budget)
spin_unlock(&adapter->tx_queue_lock);
}
 
-   adapter->clean_rx(adapter, &work_done, work_to_do);
-   *budget -= work_done;
-   poll_dev->quota -= work_done;
+   adapter->clean_rx(adapter, &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((!tx_cleaned && (work_done == 0)) ||
+   if ((tx_cleaned && (work_done < budget)) ||
   !netif_running(poll_dev)) {
 quit_polling:
if (adapter->itr_setting & 3)
e1000_set_itr(adapter);
-   netif_rx_complete(poll_dev);
-   if (test_bit(__E1000_DOWN, &adapter->state))
-   atomic_dec(&adapter->irq_sem);
-   else
-   e1000_irq_enable(adapter);
+   netif_rx_complete(poll_dev, napi);
+   e1000_irq_enable(adapter);
return 0;
}
 
-   return 1;
+   return work_done;
 }
 
 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2439,7 +2434,7 @@ int e1000e_up(struct e1000_adapter *adapter)
 
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(adapter->netdev);
+   napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
 
/* fire a link change interrupt to start the watchdog */
@@ -2472,7 +2467,7 @@ void e1000e_down(struct e1000_adapter *adapter)
e1e_flush();
msleep(10);
 
-   netif_poll_disable(netdev);
+   napi_disable(&adapter->napi);
e1000_irq_disable(adapter);
 
del_timer_sync(&adapter->watchdog_timer);
@@ -2605,7 +2600,7 @@ static int e1000_open(struct net_device *netdev)
/* From here on the code is the same as e1000e_up() */

[PATCH] e100: timer power saving

2007-09-06 Thread Auke Kok
From: Stephen Hemminger <[EMAIL PROTECTED]>

Since E100 timer is 2HZ, use rounding to make timer occur on the
correct boundary.

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e100.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 280313b..d7b9437 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1604,7 +1604,8 @@ static void e100_watchdog(unsigned long data)
else
nic->flags &= ~ich_10h_workaround;
 
-   mod_timer(&nic->watchdog, jiffies + E100_WATCHDOG_PERIOD);
+   mod_timer(&nic->watchdog,
+ round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
 }
 
 static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] e1000: Add device IDs of blade version of the 82571 quad port

2007-08-30 Thread Auke Kok
This blade-specific board form factor is identical to the 82571EB
board.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000/e1000_ethtool.c |1 +
 drivers/net/e1000/e1000_hw.c  |1 +
 drivers/net/e1000/e1000_hw.h  |1 +
 drivers/net/e1000/e1000_main.c|2 ++
 4 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethtool.c 
b/drivers/net/e1000/e1000_ethtool.c
index 4c3785c..9ecc3ad 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1726,6 +1726,7 @@ static int e1000_wol_exclusion(struct e1000_adapter 
*adapter, struct ethtool_wol
case E1000_DEV_ID_82571EB_QUAD_COPPER:
case E1000_DEV_ID_82571EB_QUAD_FIBER:
case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
+   case E1000_DEV_ID_82571PT_QUAD_COPPER:
case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
/* quad port adapters only support WoL on port A */
if (!adapter->quad_port_a) {
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index ba120f7..8604adb 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -387,6 +387,7 @@ e1000_set_mac_type(struct e1000_hw *hw)
case E1000_DEV_ID_82571EB_SERDES_DUAL:
case E1000_DEV_ID_82571EB_SERDES_QUAD:
case E1000_DEV_ID_82571EB_QUAD_COPPER:
+   case E1000_DEV_ID_82571PT_QUAD_COPPER:
case E1000_DEV_ID_82571EB_QUAD_FIBER:
case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
hw->mac_type = e1000_82571;
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index fe87146..07f0ea7 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -475,6 +475,7 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
 #define E1000_DEV_ID_82571EB_FIBER   0x105F
 #define E1000_DEV_ID_82571EB_SERDES  0x1060
 #define E1000_DEV_ID_82571EB_QUAD_COPPER 0x10A4
+#define E1000_DEV_ID_82571PT_QUAD_COPPER 0x10D5
 #define E1000_DEV_ID_82571EB_QUAD_FIBER  0x10A5
 #define E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE  0x10BC
 #define E1000_DEV_ID_82571EB_SERDES_DUAL 0x10D9
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 4a22595..e7c8951 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -108,6 +108,7 @@ static struct pci_device_id e1000_pci_tbl[] = {
INTEL_E1000_ETHERNET_DEVICE(0x10BC),
INTEL_E1000_ETHERNET_DEVICE(0x10C4),
INTEL_E1000_ETHERNET_DEVICE(0x10C5),
+   INTEL_E1000_ETHERNET_DEVICE(0x10D5),
INTEL_E1000_ETHERNET_DEVICE(0x10D9),
INTEL_E1000_ETHERNET_DEVICE(0x10DA),
/* required last entry */
@@ -1101,6 +1102,7 @@ e1000_probe(struct pci_dev *pdev,
case E1000_DEV_ID_82571EB_QUAD_COPPER:
case E1000_DEV_ID_82571EB_QUAD_FIBER:
case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
+   case E1000_DEV_ID_82571PT_QUAD_COPPER:
/* if quad port adapter, disable WoL on all but port A */
if (global_quad_port_a != 0)
adapter->eeprom_wol = 0;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [-MM, FIX] e1000e: incorporate napi_struct changes from net-2.6.24.git

2007-08-23 Thread Auke Kok
This incorporates the new napi_struct changes into e1000e. Included
bugfix for ifdown hang from Krishna Kumar for e1000.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |2 ++
 drivers/net/e1000e/netdev.c |   35 ---
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index e3cd877..ea6a9fe 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -196,6 +196,8 @@ struct e1000_adapter {
struct e1000_ring *tx_ring /* One per active queue */
cacheline_aligned_in_smp;
 
+   struct napi_struct napi;
+
unsigned long tx_queue_len;
unsigned int restart_queue;
u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 8ebe238..0e35d0a 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1663,10 +1663,10 @@ set_itr_now:
  * e1000_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
 {
-   struct e1000_adapter *adapter;
-   int work_to_do = min(*budget, poll_dev->quota);
+   struct e1000_adapter *adapter = container_of(napi, struct 
e1000_adapter, napi);
+   struct net_device *poll_dev = adapter->netdev;
int tx_cleaned = 0, work_done = 0;
 
/* Must NOT use netdev_priv macro here. */
@@ -1685,17 +1685,15 @@ static int e1000_clean(struct net_device *poll_dev, int 
*budget)
spin_unlock(&adapter->tx_queue_lock);
}
 
-   adapter->clean_rx(adapter, &work_done, work_to_do);
-   *budget -= work_done;
-   poll_dev->quota -= work_done;
+   adapter->clean_rx(adapter, &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((!tx_cleaned && (work_done == 0)) ||
+   if ((tx_cleaned && (work_done < budget)) ||
   !netif_running(poll_dev)) {
 quit_polling:
if (adapter->itr_setting & 3)
e1000_set_itr(adapter);
-   netif_rx_complete(poll_dev);
+   netif_rx_complete(poll_dev, napi);
if (test_bit(__E1000_DOWN, &adapter->state))
atomic_dec(&adapter->irq_sem);
else
@@ -1703,7 +1701,7 @@ quit_polling:
return 0;
}
 
-   return 1;
+   return work_done;
 }
 
 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2441,7 +2439,7 @@ int e1000e_up(struct e1000_adapter *adapter)
 
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(adapter->netdev);
+   napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
 
/* fire a link change interrupt to start the watchdog */
@@ -2474,7 +2472,7 @@ void e1000e_down(struct e1000_adapter *adapter)
e1e_flush();
msleep(10);
 
-   netif_poll_disable(netdev);
+   napi_disable(&adapter->napi);
e1000_irq_disable(adapter);
 
del_timer_sync(&adapter->watchdog_timer);
@@ -2607,7 +2605,7 @@ static int e1000_open(struct net_device *netdev)
/* From here on the code is the same as e1000e_up() */
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(netdev);
+   napi_enable(&adapter->napi);
 
e100

[PATCH] [-MM] e1000e: incorporate napi_struct changes from net-2.6.24.git

2007-08-22 Thread Auke Kok
This incorporates the new napi_struct changes into e1000e.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |2 ++
 drivers/net/e1000e/netdev.c |   37 ++---
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index e3cd877..ea6a9fe 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -196,6 +196,8 @@ struct e1000_adapter {
struct e1000_ring *tx_ring /* One per active queue */
cacheline_aligned_in_smp;
 
+   struct napi_struct napi;
+
unsigned long tx_queue_len;
unsigned int restart_queue;
u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 8ebe238..e30eae2 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1663,10 +1663,10 @@ set_itr_now:
  * e1000_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
 {
-   struct e1000_adapter *adapter;
-   int work_to_do = min(*budget, poll_dev->quota);
+   struct e1000_adapter *adapter = container_of(napi, struct 
e1000_adapter, napi);
+   struct net_device *poll_dev = adapter->netdev;
int tx_cleaned = 0, work_done = 0;
 
/* Must NOT use netdev_priv macro here. */
@@ -1685,17 +1685,15 @@ static int e1000_clean(struct net_device *poll_dev, int 
*budget)
spin_unlock(&adapter->tx_queue_lock);
}
 
-   adapter->clean_rx(adapter, &work_done, work_to_do);
-   *budget -= work_done;
-   poll_dev->quota -= work_done;
+   adapter->clean_rx(adapter, &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((!tx_cleaned && (work_done == 0)) ||
+   if ((tx_cleaned && (work_done < budget)) ||
   !netif_running(poll_dev)) {
 quit_polling:
if (adapter->itr_setting & 3)
e1000_set_itr(adapter);
-   netif_rx_complete(poll_dev);
+   netif_rx_complete(poll_dev, napi);
if (test_bit(__E1000_DOWN, &adapter->state))
atomic_dec(&adapter->irq_sem);
else
@@ -1703,7 +1701,7 @@ quit_polling:
return 0;
}
 
-   return 1;
+   return work_done;
 }
 
 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2441,7 +2439,7 @@ int e1000e_up(struct e1000_adapter *adapter)
 
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(adapter->netdev);
+   napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
 
/* fire a link change interrupt to start the watchdog */
@@ -2474,7 +2472,7 @@ void e1000e_down(struct e1000_adapter *adapter)
e1e_flush();
msleep(10);
 
-   netif_poll_disable(netdev);
+   napi_disable(&adapter->napi);
e1000_irq_disable(adapter);
 
del_timer_sync(&adapter->watchdog_timer);
@@ -2607,7 +2605,7 @@ static int e1000_open(struct net_device *netdev)
/* From here on the code is the same as e1000e_up() */
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(netdev);
+   napi_enable(&adapter->napi);
 
e1000_irq_enable(adapter);
 
@@ -2643,6 +2641,8 @@ static int e10

[PATCH 3/3] e1000e: Remove conditional packet split disable flag

2007-08-22 Thread Auke Kok
This flag conflicts with e1000's Kconfig symbol and we'll leave
the feature enabled by default for now.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/netdev.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 420e111..372da46 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2009,7 +2009,6 @@ static void e1000_setup_rctl(struct e1000_adapter 
*adapter)
break;
}
 
-#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
/*
 * 82571 and greater support packet-split where the protocol
 * header is placed in skb->data and the packet data is
@@ -2029,7 +2028,7 @@ static void e1000_setup_rctl(struct e1000_adapter 
*adapter)
pages = PAGE_USE_COUNT(adapter->netdev->mtu);
if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
adapter->rx_ps_pages = pages;
-#endif
+
if (adapter->rx_ps_pages) {
/* Configure extra packet-split registers */
rfctl = er32(RFCTL);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] e1000e: retire last_tx_tso workaround

2007-08-22 Thread Auke Kok
This TSO-related workaround is no longer needed since it's only
applicable for 8254x silicon.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |   15 +++
 drivers/net/e1000e/netdev.c |   20 ++--
 2 files changed, 5 insertions(+), 30 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index e3cd877..bbe5faf 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -142,18 +142,9 @@ struct e1000_ring {
/* array of buffer information structs */
struct e1000_buffer *buffer_info;
 
-   union {
-   /* for TX */
-   struct {
-   bool last_tx_tso; /* used to mark tso desc.  */
-   };
-   /* for RX */
-   struct {
-   /* arrays of page information for packet split */
-   struct e1000_ps_page *ps_pages;
-   struct sk_buff *rx_skb_top;
-   };
-   };
+   /* arrays of page information for packet split */
+   struct e1000_ps_page *ps_pages;
+   struct sk_buff *rx_skb_top;
 
struct e1000_queue_stats stats;
 };
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 8ebe238..4916f7c 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1483,7 +1483,6 @@ static void e1000_clean_tx_ring(struct e1000_adapter 
*adapter)
 
tx_ring->next_to_use = 0;
tx_ring->next_to_clean = 0;
-   tx_ring->last_tx_tso = 0;
 
writel(0, adapter->hw.hw_addr + tx_ring->head);
writel(0, adapter->hw.hw_addr + tx_ring->tail);
@@ -3216,15 +3215,6 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
while (len) {
buffer_info = &tx_ring->buffer_info[i];
size = min(len, max_per_txd);
-   /* Workaround for Controller erratum --
-* descriptor for non-tso packet in a linear SKB that follows a
-* tso gets written back prematurely before the data is fully
-* DMA'd to the controller */
-   if (tx_ring->last_tx_tso && !skb_is_gso(skb)) {
-   tx_ring->last_tx_tso = 0;
-   if (!skb->data_len)
-   size -= 4;
-   }
 
/* Workaround for premature desc write-backs
 * in TSO mode.  Append 4-byte sentinel desc */
@@ -3497,10 +3487,6 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct 
net_device *netdev)
count++;
count++;
 
-   /* Controller Erratum workaround */
-   if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
-   count++;
-
count += TXD_USE_COUNT(len, max_txd_pwr);
 
nr_frags = skb_shinfo(skb)->nr_frags;
@@ -3536,12 +3522,10 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct 
net_device *netdev)
return NETDEV_TX_OK;
}
 
-   if (tso) {
-   tx_ring->last_tx_tso = 1;
+   if (tso)
tx_flags |= E1000_TX_FLAGS_TSO;
-   } else if (e1000_tx_csum(adapter, skb)) {
+   else if (e1000_tx_csum(adapter, skb))
tx_flags |= E1000_TX_FLAGS_CSUM;
-   }
 
/* Old method was to assume IPv4 packet by default if TSO was enabled.
 * 82571 hardware supports TSO capabilities for IPv6 as well...
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] e1000e: Add read code and printout of PBA number (board identifier)

2007-08-22 Thread Auke Kok
The PBA number allows customers and support to directly identify
the type of board and characteristics such as different skews.

Slightly enhance loading messages by adding module name to printout.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/defines.h |6 --
 drivers/net/e1000e/e1000.h   |2 ++
 drivers/net/e1000e/lib.c |   21 +
 drivers/net/e1000e/netdev.c  |   12 +---
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index ca80fde..b32ed45 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -573,9 +573,11 @@
 /* For checksumming, the sum of all words in the NVM should equal 0xBABA. */
 #define NVM_SUM0xBABA
 
-#define NVM_WORD_SIZE_BASE_SHIFT   6
+/* PBA (printed board assembly) number words */
+#define NVM_PBA_OFFSET_0   8
+#define NVM_PBA_OFFSET_1   9
 
-/* NVM Commands - Microwire */
+#define NVM_WORD_SIZE_BASE_SHIFT   6
 
 /* NVM Commands - SPI */
 #define NVM_MAX_RETRY_SPI  5000 /* Max wait of 5ms, for RDY signal */
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index bbe5faf..c57e35a 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -358,6 +358,8 @@ extern struct e1000_info e1000_ich8_info;
 extern struct e1000_info e1000_ich9_info;
 extern struct e1000_info e1000_es2_info;
 
+extern s32 e1000e_read_part_num(struct e1000_hw *hw, u32 *part_num);
+
 extern s32  e1000e_commit_phy(struct e1000_hw *hw);
 
 extern bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw);
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 6645c21..3bbfe60 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -2464,3 +2464,24 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
return ret_val;
 }
 
+s32 e1000e_read_part_num(struct e1000_hw *hw, u32 *part_num)
+{
+   s32 ret_val;
+   u16 nvm_data;
+
+   ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
+   if (ret_val) {
+   hw_dbg(hw, "NVM Read Error\n");
+   return ret_val;
+   }
+   *part_num = (u32)(nvm_data << 16);
+
+   ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
+   if (ret_val) {
+   hw_dbg(hw, "NVM Read Error\n");
+   return ret_val;
+   }
+   *part_num |= nvm_data;
+
+   return 0;
+}
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 4916f7c..420e111 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3966,6 +3966,7 @@ static void e1000_print_device_info(struct e1000_adapter 
*adapter)
 {
struct e1000_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
+   u32 part_num;
 
/* print bus type/speed/width info */
ndev_info(netdev, "(PCI Express:2.5GB/s:%s) "
@@ -3980,6 +3981,10 @@ static void e1000_print_device_info(struct e1000_adapter 
*adapter)
ndev_info(netdev, "Intel(R) PRO/%s Network Connection\n",
  (hw->phy.type == e1000_phy_ife)
   ? "10/100" : "1000");
+   e1000e_read_part_num(hw, &part_num);
+   ndev_info(netdev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n",
+ hw->mac.type, hw->phy.type,
+ (part_num >> 8), (part_num & 0xff));
 }
 
 /**
@@ -4414,9 +4419,10 @@ static struct pci_driver e1000_driver = {
 static int __init e1000_init_module(void)
 {
int ret;
-   printk(KERN_INFO "Intel(R) PRO/1000 Network Driver - %s\n",
-  e1000e_driver_version);
-   printk(KERN_INFO "Copyright (c) 1999-2007 Intel Corporation.\n");
+   printk(KERN_INFO "%s: Intel(R) PRO/1000 Network Driver - %s\n",
+  e1000e_driver_name, e1000e_driver_version);
+   printk(KERN_INFO "%s: Copyright (c) 1999-2007 Intel Corporation.\n",
+  e1000e_driver_name);
ret = pci_register_driver(&e1000_driver);
 
return ret;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ethtool: add register dump support for intel 82598 chipsets (ixgbe driver)

2007-08-15 Thread Auke Kok
From: Nicholas Nunley <[EMAIL PROTECTED]>

Signed-off-by: Nicholas Nunley <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 Makefile.am|2 
 ethtool-util.h |2 
 ethtool.c  |1 
 ixgbe.c| 1017 
 4 files changed, 1021 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 7bb58d8..43d1236 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,7 @@ EXTRA_DIST = ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog 
autogen.sh
 sbin_PROGRAMS = ethtool
 ethtool_SOURCES = ethtool.c ethtool-copy.h ethtool-util.h  \
  amd8111e.c de2104x.c e100.c e1000.c igb.c \
- fec_8xx.c ibm_emac.c ixgb.c natsemi.c \
+ fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c \
  pcnet32.c realtek.c tg3.c marvell.c vioc.c\
  smsc911x.c
 
diff --git a/ethtool-util.h b/ethtool-util.h
index 1621dfe..5572771 100644
--- a/ethtool-util.h
+++ b/ethtool-util.h
@@ -56,6 +56,8 @@ int ibm_emac_dump_regs(struct ethtool_drvinfo *info, struct 
ethtool_regs *regs);
 /* Intel(R) PRO/10GBe Gigabit Adapter Family */
 int ixgb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
 
+int ixgbe_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
+
 /* Broadcom Tigon3 Ethernet controller */
 int tg3_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
 
diff --git a/ethtool.c b/ethtool.c
index 29562a7..651529e 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1005,6 +1005,7 @@ static struct {
{ "e1000", e1000_dump_regs },
{ "igb", igb_dump_regs },
{ "ixgb", ixgb_dump_regs },
+   { "ixgbe", ixgbe_dump_regs },
{ "natsemi", natsemi_dump_regs },
{ "e100", e100_dump_regs },
{ "amd8111e", amd8111e_dump_regs },
diff --git a/ixgbe.c b/ixgbe.c
new file mode 100644
index 000..03eba6a
--- /dev/null
+++ b/ixgbe.c
@@ -0,0 +1,1017 @@
+/* Copyright (c) 2007 Intel Corporation */
+#include 
+#include "ethtool-util.h"
+
+/* Register Bit Masks */
+#define IXGBE_FCTRL_SBP0x0002
+#define IXGBE_FCTRL_MPE0x0100
+#define IXGBE_FCTRL_UPE0x0200
+#define IXGBE_FCTRL_BAM0x0400
+#define IXGBE_FCTRL_PMCF   0x1000
+#define IXGBE_FCTRL_DPF0x2000
+#define IXGBE_FCTRL_RPFCE  0x4000
+#define IXGBE_FCTRL_RFCE   0x8000
+#define IXGBE_VLNCTRL_VET  0x
+#define IXGBE_VLNCTRL_CFI  0x1000
+#define IXGBE_VLNCTRL_CFIEN0x2000
+#define IXGBE_VLNCTRL_VFE  0x4000
+#define IXGBE_VLNCTRL_VME  0x8000
+#define IXGBE_LINKS_UP 0x4000
+#define IXGBE_LINKS_SPEED  0x2000
+#define IXGBE_SRRCTL_BSIZEPKT_MASK 0x007F
+#define IXGBE_HLREG0_TXCRCEN   0x0001
+#define IXGBE_HLREG0_RXCRCSTRP 0x0002
+#define IXGBE_HLREG0_JUMBOEN   0x0004
+#define IXGBE_HLREG0_TXPADEN   0x0400
+#define IXGBE_HLREG0_LPBK  0x8000
+#define IXGBE_RMCS_TFCE_802_3X 0x0008
+#define IXGBE_RMCS_TFCE_PRIORITY   0x0010
+
+int
+ixgbe_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
+{
+   u32 *regs_buff = (u32 *)regs->data;
+   u32 reg;
+   u8 i;
+   u8 version = (u8)(regs->version >> 24);
+
+   if (version != 1)
+   return -1;
+
+   reg = regs_buff[1065];
+   fprintf(stdout,
+   "0x042A4: LINKS (Link Status register) 0x%08X\n"
+   "   Link Status:   %s\n"
+   "   Link Speed:%s\n",
+   reg,
+   reg & IXGBE_LINKS_UP  ? "up"   : "down",
+   reg & IXGBE_LINKS_SPEED   ? "10G"  : "1G");
+   
+   reg = regs_buff[515];
+   fprintf(stdout,
+   "0x05080: FCTRL (Filter Control register)  0x%08X\n"
+   "   Receive Flow Control Packets:  %s\n"
+   "   Receive Priority Flow Control Packets: %s\n"
+   "   Discard Pause Frames:  %s\n"
+   "   Pass MAC Control Frames:   %s\n"
+   "   Broadcast Accept:  %s\n"
+   "   Unicast Promiscuous:   %s\n"
+   "   Multicast Promiscuous: %s\n"
+   "   Store Bad Packets: %s\n",
+   reg,
+   reg & IXGBE_FCTRL_RFCE? "enabled"  : "disabled",
+   reg & IXGBE_FCTRL_RPFCE   ? "enabled"  : "disabl

[PATCH 1/2] ethtool: add register dump support for intel 82575 chipsets (igb driver)

2007-08-15 Thread Auke Kok
From: Nicholas Nunley <[EMAIL PROTECTED]>

Signed-off-by: Nicholas Nunley <[EMAIL PROTECTED]>
Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 Makefile.am|2 
 ethtool-util.h |2 
 ethtool.c  |1 
 igb.c  |  864 
 4 files changed, 868 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 9f4bbd3..7bb58d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ EXTRA_DIST = ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog 
autogen.sh
 
 sbin_PROGRAMS = ethtool
 ethtool_SOURCES = ethtool.c ethtool-copy.h ethtool-util.h  \
- amd8111e.c de2104x.c e100.c e1000.c   \
+ amd8111e.c de2104x.c e100.c e1000.c igb.c \
  fec_8xx.c ibm_emac.c ixgb.c natsemi.c \
  pcnet32.c realtek.c tg3.c marvell.c vioc.c\
  smsc911x.c
diff --git a/ethtool-util.h b/ethtool-util.h
index f429555..1621dfe 100644
--- a/ethtool-util.h
+++ b/ethtool-util.h
@@ -30,6 +30,8 @@ int de2104x_dump_regs(struct ethtool_drvinfo *info, struct 
ethtool_regs *regs);
 /* Intel(R) PRO/1000 Gigabit Adapter Family */
 int e1000_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
 
+int igb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
+
 /* RealTek PCI */
 int realtek_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
 
diff --git a/ethtool.c b/ethtool.c
index b04f747..29562a7 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1003,6 +1003,7 @@ static struct {
{ "r8169", realtek_dump_regs },
{ "de2104x", de2104x_dump_regs },
{ "e1000", e1000_dump_regs },
+   { "igb", igb_dump_regs },
{ "ixgb", ixgb_dump_regs },
{ "natsemi", natsemi_dump_regs },
{ "e100", e100_dump_regs },
diff --git a/igb.c b/igb.c
new file mode 100644
index 000..fadc22e
--- /dev/null
+++ b/igb.c
@@ -0,0 +1,864 @@
+/* Copyright (c) 2007 Intel Corporation */
+#include 
+#include "ethtool-util.h"
+
+/* Register Bit Masks */
+/* Device Control */
+#define E1000_CTRL_FD 0x0001  /* Full duplex.0=half; 1=full */
+#define E1000_CTRL_PRIOR  0x0004  /* Priority on PCI. 0=rx,1=fair */
+#define E1000_CTRL_GIOMASTERD 0x0008  /* GIO Master Disable*/
+#define E1000_CTRL_TME0x0010  /* Test mode. 0=normal,1=test */
+#define E1000_CTRL_SLE0x0020  /* Serial Link on 0=dis,1=en */
+#define E1000_CTRL_ASDE   0x0020  /* Auto-speed detect enable */
+#define E1000_CTRL_SLU0x0040  /* Set link up (Force Link) */
+#define E1000_CTRL_ILOS   0x0080  /* Invert Loss-Of Signal */
+#define E1000_CTRL_SPD_SEL0x0300  /* Speed Select Mask */
+#define E1000_CTRL_SPD_10 0x  /* Force 10Mb */
+#define E1000_CTRL_SPD_1000x0100  /* Force 100Mb */
+#define E1000_CTRL_SPD_1000   0x0200  /* Force 1Gb */
+#define E1000_CTRL_FRCSPD 0x0800  /* Force Speed */
+#define E1000_CTRL_FRCDPX 0x1000  /* Force Duplex */
+#define E1000_CTRL_SDP0_GPIEN 0x0001  /* General Purpose Interrupt 
Detection Enable for SDP0 */
+#define E1000_CTRL_SDP1_GPIEN 0x0002  /* General Purpose Interrupt 
Detection Enable for SDP1 */
+#define E1000_CTRL_SDP0_DATA  0x0004  /* SDP0 Data */
+#define E1000_CTRL_SDP1_DATA  0x0008  /* SDP1 Data */
+#define E1000_CTRL_ADVD3WUC   0x0010  /* D3Cold WakeUp Capability 
Advertisement Enable */
+#define E1000_CTRL_SDP0_WDE   0x0020  /* Watchdog Indication for SDP0 */
+#define E1000_CTRL_SDP1_IODIR 0x0040  /* SDP1 Directionality */
+#define E1000_CTRL_RST0x0400  /* Global reset */
+#define E1000_CTRL_RFCE   0x0800  /* Receive Flow Control enable */
+#define E1000_CTRL_TFCE   0x1000  /* Transmit flow control enable */
+#define E1000_CTRL_VME0x4000  /* IEEE VLAN mode enable */
+#define E1000_CTRL_PHY_RST0x8000  /* PHY Reset */
+
+/* Device Status */
+#define E1000_STATUS_FD  0x0001  /* Full duplex.0=half,1=full 
*/
+#define E1000_STATUS_LU  0x0002  /* Link up.0=no,1=link */
+#define E1000_STATUS_LANID   0x0008  /* LAN ID */
+#define E1000_STATUS_TXOFF   0x0010  /* transmission paused */
+#define E1000_STATUS_TBIMODE 0x0020  /* TBI mode */
+#define E1000_STATUS_SPEED_MASK  0x00C0  /* Speed Mask */
+#define E1000_STATUS_SPEED_100x  /* Speed 10Mb/s */
+#define E1000_STATUS_SPEED_100   0x0040  /* Speed 100Mb/s */
+#define E1000_STATUS_SPEED_1000  0x0080  /* Speed 1000Mb/s */
+#define E1000_STATUS_ASDV0x0300  /* Auto speed detect value */
+#define E1000_STATUS_PHYRA   0x0400  /* PHY Reset Asserted */
+#define E1000_STATUS_GIOMASTEREN 0x0008  /* GIO Master Enable Status */
+#define E1000_

[PATCH 6/6] e1000e: Remove two compile warnings

2007-08-10 Thread Auke Kok
CC [M]  drivers/net/e1000e/lib.o
drivers/net/e1000e/lib.c: In function 'e1000e_read_nvm_eerd':
drivers/net/e1000e/lib.c:1941: warning: 'ret_val' may be used uninitialized
in this function
  CC [M]  drivers/net/e1000e/phy.o
drivers/net/e1000e/phy.c: In function 'e1000e_phy_has_link_generic':
drivers/net/e1000e/phy.c:1324: warning: 'ret_val' may be used
uninitialized in this function

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/lib.c |2 +-
 drivers/net/e1000e/phy.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index a04c1e4..6645c21 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -1938,7 +1938,7 @@ s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, 
u16 words, u16 *data)
 {
struct e1000_nvm_info *nvm = &hw->nvm;
u32 i, eerd = 0;
-   s32 ret_val;
+   s32 ret_val = 0;
 
/* A check for invalid values:  offset too large, too many words,
 * and not enough words. */
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
index 1efb47a..7932318 100644
--- a/drivers/net/e1000e/phy.c
+++ b/drivers/net/e1000e/phy.c
@@ -1321,7 +1321,7 @@ static s32 e1000_wait_autoneg(struct e1000_hw *hw)
 s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
   u32 usec_interval, bool *success)
 {
-   s32 ret_val;
+   s32 ret_val = 0;
u16 i, phy_status;
 
for (i = 0; i < iterations; i++) {
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] e1000e: error handling for pci_map_single calls.

2007-08-10 Thread Auke Kok
Add proper error handling for various callers of pci_map_single.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h   |2 ++
 drivers/net/e1000e/ethtool.c |   16 +++---
 drivers/net/e1000e/netdev.c  |   49 +++---
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 3475e48..e3cd877 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -220,6 +220,7 @@ struct e1000_adapter {
u32 tx_fifo_head;
u32 tx_head_addr;
u32 tx_fifo_size;
+   u32 tx_dma_failed;
 
/*
 * RX
@@ -241,6 +242,7 @@ struct e1000_adapter {
u64 gorcl_old;
u32 gorcl;
u32 alloc_rx_buff_failed;
+   u32 rx_dma_failed;
 
unsigned int rx_ps_pages;
u16 rx_ps_bsize0;
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index d14cc4b..0e80406 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -91,6 +91,8 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
{ "tx_smbus", E1000_STAT(stats.mgptc) },
{ "rx_smbus", E1000_STAT(stats.mgprc) },
{ "dropped_smbus", E1000_STAT(stats.mgpdc) },
+   { "rx_dma_failed", E1000_STAT(rx_dma_failed) },
+   { "tx_dma_failed", E1000_STAT(tx_dma_failed) },
 };
 
 #define E1000_GLOBAL_STATS_LEN \
@@ -1042,6 +1044,10 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
tx_ring->buffer_info[i].dma =
pci_map_single(pdev, skb->data, skb->len,
   PCI_DMA_TODEVICE);
+   if (pci_dma_mapping_error(tx_ring->buffer_info[i].dma)) {
+   ret_val = 4;
+   goto err_nomem;
+   }
tx_desc->buffer_addr = cpu_to_le64(
 tx_ring->buffer_info[i].dma);
tx_desc->lower.data = cpu_to_le32(skb->len);
@@ -1059,7 +1065,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
size = rx_ring->count * sizeof(struct e1000_buffer);
rx_ring->buffer_info = kmalloc(size, GFP_KERNEL);
if (!rx_ring->buffer_info) {
-   ret_val = 4;
+   ret_val = 5;
goto err_nomem;
}
memset(rx_ring->buffer_info, 0, size);
@@ -1068,7 +1074,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
   &rx_ring->dma, GFP_KERNEL);
if (!rx_ring->desc) {
-   ret_val = 5;
+   ret_val = 6;
goto err_nomem;
}
memset(rx_ring->desc, 0, rx_ring->size);
@@ -1093,7 +1099,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
 
skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL);
if (!skb) {
-   ret_val = 6;
+   ret_val = 7;
goto err_nomem;
}
skb_reserve(skb, NET_IP_ALIGN);
@@ -1101,6 +1107,10 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
rx_ring->buffer_info[i].dma =
pci_map_single(pdev, skb->data, 2048,
   PCI_DMA_FROMDEVICE);
+   if (pci_dma_mapping_error(rx_ring->buffer_info[i].dma)) {
+   ret_val = 8;
+   goto err_nomem;
+   }
rx_desc->buffer_addr =
cpu_to_le64(rx_ring->buffer_info[i].dma);
memset(skb->data, 0x00, skb->len);
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 51c9024..8ebe238 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -195,6 +195,11 @@ map_skb:
buffer_info->dma = pci_map_single(pdev, skb->data,
  adapter->rx_buffer_len,
  PCI_DMA_FROMDEVICE);
+   if (pci_dma_mapping_error(buffer_info->dma)) {
+   dev_err(&pdev->dev, "RX DMA map failed\n");
+   adapter->rx_dma_failed++;
+   break;
+   }
 
rx_desc = E1000_RX_DESC(*rx_ring, i);
rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
@@ -255,6 +260,13 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter 
*adapter,
   ps_page->page,
   

[PATCH 3/6] e1000e: Use dma_alloc_coherent where possible

2007-08-10 Thread Auke Kok
Instead of using pci_alloc_consistent at GFP_ATOMIC we can be
more reliable at startup and use dma_alloc_coherent instead with
GFP_KERNEL.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/ethtool.c |   16 
 drivers/net/e1000e/netdev.c  |9 ++---
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index c9d74a8..d184116 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -962,13 +962,13 @@ static void e1000_free_desc_rings(struct e1000_adapter 
*adapter)
}
 
if (tx_ring->desc) {
-   pci_free_consistent(pdev, tx_ring->size, tx_ring->desc,
-   tx_ring->dma);
+   dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
+ tx_ring->dma);
tx_ring->desc = NULL;
}
if (rx_ring->desc) {
-   pci_free_consistent(pdev, rx_ring->size, rx_ring->desc,
-   rx_ring->dma);
+   dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
+ rx_ring->dma);
rx_ring->desc = NULL;
}
 
@@ -1004,8 +1004,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
 
tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
tx_ring->size = ALIGN(tx_ring->size, 4096);
-   tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size,
-   &tx_ring->dma);
+   tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
+  &tx_ring->dma, GFP_KERNEL);
if (!tx_ring->desc) {
ret_val = 2;
goto err_nomem;
@@ -1065,8 +1065,8 @@ static int e1000_setup_desc_rings(struct e1000_adapter 
*adapter)
memset(rx_ring->buffer_info, 0, size);
 
rx_ring->size = rx_ring->count * sizeof(struct e1000_rx_desc);
-   rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size,
-&rx_ring->dma);
+   rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
+  &rx_ring->dma, GFP_KERNEL);
if (!rx_ring->desc) {
ret_val = 5;
goto err_nomem;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index d711e14..51c9024 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1344,7 +1344,8 @@ static int e1000_alloc_ring_dma(struct e1000_adapter 
*adapter,
 {
struct pci_dev *pdev = adapter->pdev;
 
-   ring->desc = pci_alloc_consistent(pdev, ring->size, &ring->dma);
+   ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
+   GFP_KERNEL);
if (!ring->desc)
return -ENOMEM;
 
@@ -1479,7 +1480,8 @@ void e1000e_free_tx_resources(struct e1000_adapter 
*adapter)
vfree(tx_ring->buffer_info);
tx_ring->buffer_info = NULL;
 
-   pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
+   dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
+ tx_ring->dma);
tx_ring->desc = NULL;
 }
 
@@ -1503,7 +1505,8 @@ void e1000e_free_rx_resources(struct e1000_adapter 
*adapter)
kfree(rx_ring->ps_pages);
rx_ring->ps_pages = NULL;
 
-   pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
+   dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
+ rx_ring->dma);
rx_ring->desc = NULL;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   3   4   >