e1000: driver update to 7.1.9-k2
Subsystems (2)
cover e1000: driver update to 7.1.9-k2
Hi,
A large number of e1000 patches this update, including the release of the integrated NIC in the ICH8 motherboard chipset, which has been officially released into the public. Also known as i965, the lan chipset on this motherboard is fully supported by this driver.
The motherboard actually comes with two different PHY's, one that supports gigabit speeds and one that only does 10/100. This driver supports both of them.
All of these changes correspond with the 7.1.9 release on SF this week, and have been tested and validated by our team, who did and an excellent job ;^).
Furthermore, the patches included also fixes included in the 7.0.38 and 7.0.41 releases, which were not yet merged into the kernel. This patch series brings the kernel driver up to current.
---
Summary of patches:
[01]: fix loopback ethtool test
[02]: rework driver hardware reset locking
[03]: Make PHY powerup/down a function
[04]: fix CONFIG_PM blocks
[05]: small performance tweak by removing double code [06]: add smart power down code
[07]: change printk into DPRINTK
[08]: recycle skb
[09]: rework module param code with uninitialized values [10]: force register write flushes to circumvent broken platforms [11]: disable CRC stripping workaround
[12]: fix adapter led blinking inconsistency
[13]: add E1000_BIG_ENDIAN symbol
[14]: M88 PHY workaround
[15]: check return value of _get_speed_and_duplex
[16]: disable ERT
[17]: add ich8lan core functions
[18]: integrate ich8 support into driver
[19]: allow user to disable ich8 lock loss workaround [20]: add ich8lan device ID's
[21]: increase version to 7.1.9-k2
---
Since these patches are rather large together, they are also available over http here:
http://foo-projects.org/~sofar/e1000-7.1.9-k2/ And in a tarball: http://foo-projects.org/~sofar/e1000-7.1.9-k2/e1000-patches-7.1.9-k2.tar.bz2
---
Jeff, please pull from our git repository:
git://lost.foo-projects.org/~ahkok/git/netdev-2.6 upstream
These patches are against
netdev-2.6#upstream 612eff0e3715a6faff5ba1b74873b99e036c59fe
(Brian Haley <[email protected]> / [PATCH] s2io: netpoll support)
Cheers,
Auke
--- drivers/net/e1000/e1000.h | 10 drivers/net/e1000/e1000_ethtool.c | 143 +-- drivers/net/e1000/e1000_hw.c | 1770 +++++++++++++++++++++++++++++++++++--- drivers/net/e1000/e1000_hw.h | 400 ++++++++ drivers/net/e1000/e1000_main.c | 386 +++++--- drivers/net/e1000/e1000_osdep.h | 16 drivers/net/e1000/e1000_param.c | 213 ++-- 7 files changed, 2539 insertions(+), 399 deletions(-)
--
Auke Kok <[email protected]>
PATCH 1/21 e1000: fix loopback ethtool test
Ethtool was reporting that loopback failed randomly on esb2 systems. Upon study it was found that the phy manual was changed with respect to the loopback mode bits. The new value fixes it.
---
drivers/net/e1000/e1000_ethtool.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_ethtool.c +1 -1
@@ -1246,7 +1246,7 @@ e1000_integrated_phy_loopback(struct e10 }else if (adapter->hw.phy_type == e1000_phy_gg82563) {e1000_write_phy_reg (&adapter->hw,GG82563_PHY_KMRN_MODE_CTRL , -0x1CE ); +0x1CC ); }/* force 1000, set loopback */ e1000_write_phy_reg (&adapter->hw,PHY_CTRL ,0x4140 );
--
Auke Kok <[email protected]>
PATCH 2/21 e1000: rework driver hardware reset locking
In reply to Kok, AukeAfter studying the driver mac reset code it was found that there were multiple race conditions possible to reset the unit twice or bring it e1000_up() double. This fixes all occurences where the driver needs to reset the mac.
We also remove irq requesting/releasing into _open and _close so that while the device is _up we will never touch the irq's. This fixes the double free irq bug that people saw.
To make sure that the watchdog task doesn't cause another race we let it run as a non-scheduled task.
---
drivers/net/e1000/e1000.h | 8 ++ drivers/net/e1000/e1000_ethtool.c | 46 ++++++++------ drivers/net/e1000/e1000_main.c | 126 +++++++++++++++++++++---------------- 3 files changed, 105 insertions(+), 75 deletions(-)
drivers/net/e1000/e1000.h +6 -2
@@ -69,7 +69,6 @@#ifdef NETIF_F_TSO #include <net/checksum.h> #endif -#include <linux/workqueue.h> #include <linux/mii.h> #include <linux/ethtool.h> #include <linux/if_vlan.h>
@@ -255,7 +254,6 @@ struct e1000_adapter {spinlock_t tx_queue_lock;#endif atomic_t irq_sem; -struct work_struct watchdog_task;struct work_struct reset_task;uint8_t fc_autoneg;
@@ -340,8 +338,13 @@ struct e1000_adapter {#ifdef NETIF_F_TSO boolean_t tso_force;#endif +unsigned long flags; }; +enum e1000_state_t { + __E1000_DRIVER_TESTING, + __E1000_RESETTING, +};/* e1000_main.c */ extern char e1000_driver_name[];
@@ -349,6 +352,7 @@ extern char e1000_driver_version[];int e1000_up (struct e1000_adapter *adapter);void e1000_down (struct e1000_adapter *adapter);void e1000_reset (struct e1000_adapter *adapter); +void e1000_reinit_locked (struct e1000_adapter *adapter);int e1000_setup_all_tx_resources (struct e1000_adapter *adapter);void e1000_free_all_tx_resources (struct e1000_adapter *adapter);int e1000_setup_all_rx_resources (struct e1000_adapter *adapter);
drivers/net/e1000/e1000_ethtool.c +26 -20
115 lines not on this page · raw message
drivers/net/e1000/e1000_main.c +73 -53
227 lines not on this page · raw message
--
Auke Kok <[email protected]>
Re: [PATCH 02/21] e1000: rework driver hardware reset locking
drivers/net/e1000/e1000_ethtool.c e1000_set_ringparam(struct net_device *n · line 631
Quoted 6 lines · Auke
drivers/net/e1000/e1000_ethtool.c +2
-0@@ -631,6 +627,9 @@ e1000_set_ringparam(struct net_device *n tx_ring_size =sizeof (struct e1000_tx_ring ) * adapter->num_tx_queues; rx_ring_size =sizeof (struct e1000_rx_ring ) * adapter->num_rx_queues; +while (test_and_set_bit (__E1000_RESETTING, &adapter->flags)) +msleep (1 );
This is a bit worrying, but no outright objection. We don't want to see these accumulate.
Re: [PATCH 02/21] e1000: rework driver hardware reset locking
Quoted 11 lines · Jeff Garzik
Review e1000_set_ringparam(struct net_device *n · line 633
Quoted 8 lines · Auke
(quoted diff) +2
-0@@ -631,6 +627,9 @@ e1000_set_ringparam(struct net_device *n tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues; rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues; + while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) + msleep(1);This is a bit worrying, but no outright objection. We don't want to see these accumulate.
Agreed but at least we removed the opportunity to panic the driver as easy as with 2 commandline commands (in several ways) - we're still looking into improving this - any comments would be appreciated.
Cheers,
Auke
PATCH 3/21 e1000: Make PHY powerup/down a function
In reply to Kok, AukeIn relation to the irq work done earlier we also move the PHY powerup and powerdown functions into separate functions and move the calls to _close and _open, making the PHY stay in it's power state as long as the device is _up.
---
drivers/net/e1000/e1000_main.c | 76 ++++++++++++++++++++++++++-------------- 1 files changed, 49 insertions(+), 27 deletions(-)
drivers/net/e1000/e1000_main.c +49 -27
@@ -428,14 +428,6 @@ e1000_up(struct e1000_adapter *adapter)/* hardware has been reset, we need to reload some things */ -/* Reset the PHY if it was previously powered down */ -if (adapter->hw.media_type == e1000_media_type_copper) { -uint16_t mii_reg; -e1000_read_phy_reg (&adapter->hw,PHY_CTRL , &mii_reg); -if (mii_reg &MII_CR_POWER_DOWN ) -e1000_phy_hw_reset (&adapter->hw); - } -e1000_set_multi (netdev);e1000_restore_vlan (adapter);
@@ -464,12 +456,56 @@ e1000_up(struct e1000_adapter *adapter)return 0 ; } +/** +* e1000_power_up_phy - restore link in case the phy was powered down +* @adapter: address of board private structure +* +* The phy may be powered down to save power and turn off link when the +* driver is unloaded and wake on lan is not enabled (among others) +* *** this routine MUST be followed by a call to e1000_reset *** +* +**/ + +static void e1000_power_up_phy (struct e1000_adapter *adapter) +{ +uint16_t mii_reg =0 ; + +/* Just clear the power down bit to wake the phy back up */ +if (adapter->hw.media_type == e1000_media_type_copper) { +/* according to the manual, the phy will retain its +* settings across a power-down/up cycle */ +e1000_read_phy_reg (&adapter->hw,PHY_CTRL , &mii_reg); + mii_reg &= ~MII_CR_POWER_DOWN ; +e1000_write_phy_reg (&adapter->hw,PHY_CTRL , mii_reg); + } +} + +static void e1000_power_down_phy (struct e1000_adapter *adapter) +{ +boolean_t mng_mode_enabled = (adapter->hw.mac_type >= e1000_82571) && +e1000_check_mng_mode (&adapter->hw); +/* Power down the PHY so no link is implied when interface is down +* The PHY cannot be powered down if any of the following is TRUE +* (a) WoL is enabled +* (b) AMT is active +* (c) SoL/IDER session is active */ +if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 && + adapter->hw.media_type == e1000_media_type_copper && + !(E1000_READ_REG (&adapter->hw,MANC ) &E1000_MANC_SMBUS_EN ) && + !mng_mode_enabled && + !e1000_check_phy_reset_block (&adapter->hw)) { +uint16_t mii_reg =0 ; +e1000_read_phy_reg (&adapter->hw,PHY_CTRL , &mii_reg); + mii_reg |=MII_CR_POWER_DOWN ; +e1000_write_phy_reg (&adapter->hw,PHY_CTRL , mii_reg); +mdelay (1 ); + } +} +void e1000_down (struct e1000_adapter *adapter) {struct net_device *netdev = adapter->netdev; -boolean_t mng_mode_enabled = (adapter->hw.mac_type >= e1000_82571) && -e1000_check_mng_mode (&adapter->hw);e1000_irq_disable (adapter);
@@ -489,23 +525,6 @@ e1000_down(struct e1000_adapter *adaptere1000_reset (adapter);e1000_clean_all_tx_rings (adapter);e1000_clean_all_rx_rings (adapter); - -/* Power down the PHY so no link is implied when interface is down * -* The PHY cannot be powered down if any of the following is TRUE * -* (a) WoL is enabled -* (b) AMT is active -* (c) SoL/IDER session is active */ -if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 && - adapter->hw.media_type == e1000_media_type_copper && - !(E1000_READ_REG (&adapter->hw,MANC ) &E1000_MANC_SMBUS_EN ) && - !mng_mode_enabled && - !e1000_check_phy_reset_block (&adapter->hw)) { -uint16_t mii_reg; -e1000_read_phy_reg (&adapter->hw,PHY_CTRL , &mii_reg); - mii_reg |=MII_CR_POWER_DOWN ; -e1000_write_phy_reg (&adapter->hw,PHY_CTRL , mii_reg); -mdelay (1 ); - } }void
@@ -1117,6 +1136,8 @@ e1000_open(struct net_device *netdev)if (err) goto err_up; +e1000_power_up_phy (adapter); +if ((err =e1000_up (adapter))) goto err_up; adapter->mng_vlan_id =E1000_MNG_VLAN_NONE ;
@@ -1162,6 +1183,7 @@ e1000_close(struct net_device *netdev)WARN_ON (test_bit (__E1000_RESETTING, &adapter->flags));e1000_down (adapter); +e1000_power_down_phy (adapter);e1000_free_irq (adapter);e1000_free_all_tx_resources (adapter);
--
Auke Kok <[email protected]>
PATCH 4/21 e1000: fix CONFIG_PM blocks
In reply to Kok, Aukee1000_suspend is called even when !CONFIG_PM. The non-PM code inside of it is properly #ifdef'd. This fixes the compiler warnings when !CONFIG_PM.
---
drivers/net/e1000/e1000_main.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/e1000/e1000_main.c +4 -2
@@ -177,8 +177,8 @@ static void e1000_vlan_rx_add_vid(structstatic void e1000_vlan_rx_kill_vid (struct net_device *netdev,uint16_t vid);static void e1000_restore_vlan (struct e1000_adapter *adapter); -#ifdef CONFIG_PM static int e1000_suspend (struct pci_dev *pdev,pm_message_t state); +#ifdef CONFIG_PM static int e1000_resume (struct pci_dev *pdev);#endif static void e1000_shutdown (struct pci_dev *pdev);
@@ -205,8 +205,8 @@ static struct pci_driver e1000_driver = .probe = e1000_probe, .remove = __devexit_p(e1000_remove),/* Power Managment Hooks */ -#ifdef CONFIG_PM .suspend = e1000_suspend, +#ifdef CONFIG_PM .resume = e1000_resume, #endif .shutdown = e1000_shutdown,
@@ -4498,7 +4498,9 @@ e1000_suspend(struct pci_dev *pdev, pm_mstruct e1000_adapter *adapter =netdev_priv (netdev);uint32_t ctrl, ctrl_ext, rctl, manc, status;uint32_t wufc = adapter->wol; +#ifdef CONFIG_PM int retval =0 ; +#endif netif_device_detach (netdev);
--
Auke Kok <[email protected]>
PATCH 5/21 e1000: small performance tweak by removing double code
In reply to Kok, Aukebuffer_info is already filled at the end of this while() loop.
---
drivers/net/e1000/e1000_main.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_main.c +0 -1
@@ -3717,7 +3717,6 @@ e1000_clean_rx_irq_ps(struct e1000_adapt buffer_info = &rx_ring->buffer_info[i];while (staterr &E1000_RXD_STAT_DD ) { - buffer_info = &rx_ring->buffer_info[i]; ps_page = &rx_ring->ps_page[i]; ps_page_dma = &rx_ring->ps_page_dma[i];#ifdef CONFIG_E1000_NAPI
--
Auke Kok <[email protected]>
PATCH 6/21 e1000: add smart power down code
In reply to Kok, AukeSmart Power Down is a power saving feature in newer e1000 hardware. We disable it because it causes time to link to be long, but make it a user choice.
---
drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/e1000_main.c | 15 +++++++++++++++ drivers/net/e1000/e1000_param.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 0 deletions(-)
drivers/net/e1000/e1000.h +1 -0
@@ -338,6 +338,7 @@ struct e1000_adapter {#ifdef NETIF_F_TSO boolean_t tso_force;#endif +boolean_t smart_power_down;/* phy smart power down */ unsigned long flags; };
drivers/net/e1000/e1000_main.c +15 -0
@@ -607,6 +607,21 @@ e1000_reset(struct e1000_adapter *adaptee1000_reset_adaptive (&adapter->hw);e1000_phy_get_info (&adapter->hw, &adapter->phy_info); + +if (!adapter->smart_power_down && + (adapter->hw.mac_type == e1000_82571 || + adapter->hw.mac_type == e1000_82572)) { +uint16_t phy_data =0 ; +/* speed up time to link by disabling smart power down, ignore +* the return value of this function because there is nothing +* different we would do if it failed */ +e1000_read_phy_reg (&adapter->hw,IGP02E1000_PHY_POWER_MGMT , + &phy_data); + phy_data &= ~IGP02E1000_PM_SPD ; +e1000_write_phy_reg (&adapter->hw,IGP02E1000_PHY_POWER_MGMT , + phy_data); + } +if (adapter->en_mng_pt) { manc =E1000_READ_REG (&adapter->hw,MANC ); manc |= (E1000_MANC_ARP_EN |E1000_MANC_EN_MNG2HOST );
drivers/net/e1000/e1000_param.c +25 -0
@@ -183,6 +183,15 @@ E1000_PARAM(RxAbsIntDelay, "Receive AbsoE1000_PARAM (InterruptThrottleRate,"Interrupt Throttling Rate" ); +/* Enable Smart Power Down of the PHY +* +* Valid Range: 0, 1 +* +* Default Value: 0 (disabled) +*/ + +E1000_PARAM (SmartPowerDownEnable,"Enable PHY smart power down" ); +#define AUTONEG_ADV_DEFAULT 0x2F#define AUTONEG_ADV_MASK 0x2F#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
@@ -494,6 +503,22 @@ e1000_check_options(struct e1000_adapter adapter->itr = opt.def; } } + {/* Smart Power Down */ +struct e1000_option opt = { + .type = enable_option, + .name ="PHY Smart Power Down" , + .err ="defaulting to Disabled" , + .def =OPTION_DISABLED + }; + +if (num_SmartPowerDownEnable > bd) { +int spd = SmartPowerDownEnable[bd]; +e1000_validate_option (&spd, &opt, adapter); + adapter->smart_power_down = spd; + }else { + adapter->smart_power_down = opt.def; + } + }switch (adapter->hw.media_type) {case e1000_media_type_fiber:
--
Auke Kok <[email protected]>
Re: [PATCH 06/21] e1000: add smart power down code
Quoted 4 lines · Auke
Smart Power Down is a power saving feature in newer e1000 hardware. We disable it because it causes time to link to be long, but make it a user choice.
Quoted 8 lines
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/e1000_main.c | 15 +++++++++++++++ drivers/net/e1000/e1000_param.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 0 deletions(-)
Since it's not default, who will actually use this? Particularly since it is only a module option, and not supported through ethtool (frown).
Jeff
Re: [PATCH 06/21] e1000: add smart power down code
Quoted 9 lines · Jeff Garzik
Quoted 8 lines · Auke
Smart Power Down is a power saving feature in newer e1000 hardware. We disable it because it causes time to link to be long, but make it a user choice.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
Quoted 7 lines
Quoted 4 lines
drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/e1000_main.c | 15 +++++++++++++++ drivers/net/e1000/e1000_param.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 0 deletions(-)Since it's not default, who will actually use this? Particularly since it is only a module option, and not supported through ethtool (frown).
i would use it, i always wanted the feature on my laptop (ibm thinkpad)
Signature · 1 line
Florian Reitmeir
Re: [PATCH 06/21] e1000: add smart power down code
In reply to Jeff GarzikQuoted 9 lines · Jeff Garzik
Quoted 8 lines · Auke
Smart Power Down is a power saving feature in newer e1000 hardware. We disable it because it causes time to link to be long, but make it a user choice.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
Quoted 6 lines
Quoted 4 lines
drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/e1000_main.c | 15 +++++++++++++++ drivers/net/e1000/e1000_param.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 0 deletions(-)Since it's not default, who will actually use this? Particularly since it is only a module option, and not supported through ethtool (frown).
laptop users that frequently re-connect their cables might enable this function since it saves battery life.
Auke
PATCH 7/21 e1000: change printk into DPRINTK
In reply to Kok, AukeChanging a printk message to make clear that this message is originating from e1000.
---
drivers/net/e1000/e1000_main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_main.c +1 -1
@@ -2841,7 +2841,7 @@ e1000_xmit_frame(struct sk_buff *skb, stcase e1000_82573: pull_size =min ((unsigned int )4 , skb->data_len);if (!__pskb_pull_tail (skb, pull_size)) { -printk (KERN_ERR +DPRINTK (DRV ,ERR ,"__pskb_pull_tail failed.\n" );dev_kfree_skb_any (skb);return NETDEV_TX_OK ;
--
Auke Kok <[email protected]>
PATCH 8/21 e1000: recycle skb
In reply to Kok, AukeRecycle an skb to improve performance a bit.
---
drivers/net/e1000/e1000_main.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_main.c +2 -1
@@ -3604,7 +3604,8 @@ e1000_clean_rx_irq(struct e1000_adapter/* All receives must fit into a single buffer */ E1000_DBG ("%s: Receive packet consumed multiple" " buffers\n" , netdev->name); -dev_kfree_skb_irq (skb); +/* recycle */ + buffer_info-> skb = skb; goto next_desc; }
--
Auke Kok <[email protected]>
PATCH 9/21 e1000: rework module param code with uninitialized values
In reply to Kok, AukeWe can take uninitialized values into account which minimizes code and allows us to simplify the parameter checking code greatly.
---
drivers/net/e1000/e1000_param.c | 167 ++++++++++++++------------------------- 1 files changed, 61 insertions(+), 106 deletions(-)
drivers/net/e1000/e1000_param.c +61 -106
@@ -45,6 +45,16 @@*/ #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } +/* Module Parameters are always initialized to -1, so that the driver +* can tell the difference between no user specified value or the +* user asking for the default value. +* The true default values are loaded in when e1000_check_options is called. +* +* This is a GCC extension to ANSI C. +* See the item "Labeled Elements in Initializers" in the section +* "Extensions to the C Language Family" of the GCC documentation. +*/ +#define E1000_PARAM (X , desc) \ static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ static int num_##X = 0; \
@@ -305,6 +315,7 @@ e1000_check_options(struct e1000_adapterDPRINTK (PROBE ,NOTICE ,"Warning: no configuration for board #%i\n" , bd);DPRINTK (PROBE ,NOTICE ,"Using defaults for all values\n" ); + bd =E1000_MAX_NIC ; } {/* Transmit Descriptor Count */
@@ -322,14 +333,9 @@ e1000_check_options(struct e1000_adapter opt.arg.r.max = mac_type < e1000_82544 ?E1000_MAX_TXD :E1000_MAX_82544_TXD ; -if (num_TxDescriptors > bd) { - tx_ring->count = TxDescriptors[bd]; -e1000_validate_option (&tx_ring->count, &opt, adapter); -E1000_ROUNDUP (tx_ring->count, -REQ_TX_DESCRIPTOR_MULTIPLE ); - }else { - tx_ring->count = opt.def; - } + tx_ring->count = TxDescriptors[bd]; +e1000_validate_option (&tx_ring->count, &opt, adapter); +E1000_ROUNDUP (tx_ring->count,REQ_TX_DESCRIPTOR_MULTIPLE );for (i =0 ; i < adapter->num_tx_queues; i++) tx_ring[i].count = tx_ring->count; }
@@ -348,14 +354,9 @@ e1000_check_options(struct e1000_adapter opt.arg.r.max = mac_type < e1000_82544 ?E1000_MAX_RXD :E1000_MAX_82544_RXD ; -if (num_RxDescriptors > bd) { - rx_ring->count = RxDescriptors[bd]; -e1000_validate_option (&rx_ring->count, &opt, adapter); -E1000_ROUNDUP (rx_ring->count, -REQ_RX_DESCRIPTOR_MULTIPLE ); - }else { - rx_ring->count = opt.def; - } + rx_ring->count = RxDescriptors[bd]; +e1000_validate_option (&rx_ring->count, &opt, adapter); +E1000_ROUNDUP (rx_ring->count,REQ_RX_DESCRIPTOR_MULTIPLE );for (i =0 ; i < adapter->num_rx_queues; i++) rx_ring[i].count = rx_ring->count; }
@@ -367,13 +368,9 @@ e1000_check_options(struct e1000_adapter .def = OPTION_ENABLED }; -if (num_XsumRX > bd) { -int rx_csum = XsumRX[bd]; -e1000_validate_option (&rx_csum, &opt, adapter); - adapter->rx_csum = rx_csum; - }else { - adapter->rx_csum = opt.def; - } +int rx_csum = XsumRX[bd]; +e1000_validate_option (&rx_csum, &opt, adapter); + adapter->rx_csum = rx_csum; } {/* Flow Control */
@@ -393,13 +390,9 @@ e1000_check_options(struct e1000_adapter .p = fc_list }} }; -if (num_FlowControl > bd) { -int fc = FlowControl[bd]; -e1000_validate_option (&fc, &opt, adapter); - adapter->hw.fc = adapter->hw.original_fc = fc; - }else { - adapter->hw.fc = adapter->hw.original_fc = opt.def; - } +int fc = FlowControl[bd]; +e1000_validate_option (&fc, &opt, adapter); + adapter->hw.fc = adapter->hw.original_fc = fc; } {/* Transmit Interrupt Delay */ struct e1000_option opt = {
@@ -411,13 +404,8 @@ e1000_check_options(struct e1000_adapter .max = MAX_TXDELAY }} }; -if (num_TxIntDelay > bd) { - adapter->tx_int_delay = TxIntDelay[bd]; -e1000_validate_option (&adapter->tx_int_delay, &opt, - adapter); - }else { - adapter->tx_int_delay = opt.def; - } + adapter->tx_int_delay = TxIntDelay[bd]; +e1000_validate_option (&adapter->tx_int_delay, &opt, adapter); } {/* Transmit Absolute Interrupt Delay */ struct e1000_option opt = {
@@ -429,13 +417,9 @@ e1000_check_options(struct e1000_adapter .max = MAX_TXABSDELAY }} }; -if (num_TxAbsIntDelay > bd) { - adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; -e1000_validate_option (&adapter->tx_abs_int_delay, &opt, - adapter); - }else { - adapter->tx_abs_int_delay = opt.def; - } + adapter->tx_abs_int_delay = TxAbsIntDelay[bd]; +e1000_validate_option (&adapter->tx_abs_int_delay, &opt, + adapter); } {/* Receive Interrupt Delay */ struct e1000_option opt = {
@@ -447,13 +431,8 @@ e1000_check_options(struct e1000_adapter .max = MAX_RXDELAY }} }; -if (num_RxIntDelay > bd) { - adapter->rx_int_delay = RxIntDelay[bd]; -e1000_validate_option (&adapter->rx_int_delay, &opt, - adapter); - }else { - adapter->rx_int_delay = opt.def; - } + adapter->rx_int_delay = RxIntDelay[bd]; +e1000_validate_option (&adapter->rx_int_delay, &opt, adapter); } {/* Receive Absolute Interrupt Delay */ struct e1000_option opt = {
@@ -465,13 +444,9 @@ e1000_check_options(struct e1000_adapter .max = MAX_RXABSDELAY }} }; -if (num_RxAbsIntDelay > bd) { - adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; -e1000_validate_option (&adapter->rx_abs_int_delay, &opt, - adapter); - }else { - adapter->rx_abs_int_delay = opt.def; - } + adapter->rx_abs_int_delay = RxAbsIntDelay[bd]; +e1000_validate_option (&adapter->rx_abs_int_delay, &opt, + adapter); } {/* Interrupt Throttling Rate */ struct e1000_option opt = {
@@ -483,24 +458,18 @@ e1000_check_options(struct e1000_adapter .max = MAX_ITR }} }; -if (num_InterruptThrottleRate > bd) { - adapter->itr = InterruptThrottleRate[bd]; -switch (adapter->itr) { -case 0 : -DPRINTK (PROBE ,INFO ,"%s turned off\n" , - opt.name); -break ; -case 1 : -DPRINTK (PROBE ,INFO ,"%s set to dynamic mode\n" , - opt.name); -break ; -default : -e1000_validate_option (&adapter->itr, &opt, - adapter); -break ; - } - }else { - adapter->itr = opt.def; + adapter->itr = InterruptThrottleRate[bd]; +switch (adapter->itr) { +case 0 : +DPRINTK (PROBE ,INFO ,"%s turned off\n" , opt.name); +break ; +case 1 : +DPRINTK (PROBE ,INFO ,"%s set to dynamic mode\n" , + opt.name); +break ; +default : +e1000_validate_option (&adapter->itr, &opt, adapter); +break ; } } {/* Smart Power Down */
@@ -511,13 +480,9 @@ e1000_check_options(struct e1000_adapter .def = OPTION_DISABLED }; -if (num_SmartPowerDownEnable > bd) { -int spd = SmartPowerDownEnable[bd]; -e1000_validate_option (&spd, &opt, adapter); - adapter->smart_power_down = spd; - }else { - adapter->smart_power_down = opt.def; - } +int spd = SmartPowerDownEnable[bd]; +e1000_validate_option (&spd, &opt, adapter); + adapter->smart_power_down = spd; }switch (adapter->hw.media_type) {
@@ -544,17 +509,18 @@ static void __devinit e1000_check_fiber_options(struct e1000_adapter *adapter) {int bd = adapter->bd_number; -if (num_Speed > bd) { + bd = bd >E1000_MAX_NIC ?E1000_MAX_NIC : bd; +if ((Speed[bd] !=OPTION_UNSET )) {DPRINTK (PROBE ,INFO ,"Speed not valid for fiber adapters, " "parameter ignored\n" ); } -if (num_Duplex > bd) { +if ((Duplex[bd] !=OPTION_UNSET )) {DPRINTK (PROBE ,INFO ,"Duplex not valid for fiber adapters, " "parameter ignored\n" ); } -if ((num_AutoNeg > bd) && (AutoNeg[bd] !=0x20 )) { +if ((AutoNeg[bd] !=OPTION_UNSET ) && (AutoNeg[bd] !=0x20 )) {DPRINTK (PROBE ,INFO ,"AutoNeg other than 1000/Full is " "not valid for fiber adapters, " "parameter ignored\n" );
@@ -573,6 +539,7 @@ e1000_check_copper_options(struct e1000_ {int speed, dplx, an;int bd = adapter->bd_number; + bd = bd >E1000_MAX_NIC ?E1000_MAX_NIC : bd; {/* Speed */ struct e1000_opt_list speed_list[] = {{ 0, "" },
@@ -589,12 +556,8 @@ e1000_check_copper_options(struct e1000_ .p = speed_list }} }; -if (num_Speed > bd) { - speed = Speed[bd]; -e1000_validate_option (&speed, &opt, adapter); - }else { - speed = opt.def; - } + speed = Speed[bd]; +e1000_validate_option (&speed, &opt, adapter); } {/* Duplex */ struct e1000_opt_list dplx_list[] = {{0 ,"" },
@@ -616,15 +579,11 @@ e1000_check_copper_options(struct e1000_ "Speed/Duplex/AutoNeg parameter ignored.\n");return ; } -if (num_Duplex > bd) { - dplx = Duplex[bd]; -e1000_validate_option (&dplx, &opt, adapter); - }else { - dplx = opt.def; - } + dplx = Duplex[bd]; +e1000_validate_option (&dplx, &opt, adapter); } -if ((num_AutoNeg > bd) && (speed !=0 || dplx !=0 )) { +if (AutoNeg[bd] !=OPTION_UNSET && (speed !=0 || dplx !=0 )) {DPRINTK (PROBE ,INFO ,"AutoNeg specified along with Speed or Duplex, " "parameter ignored\n" );
@@ -673,19 +632,15 @@ e1000_check_copper_options(struct e1000_ .p = an_list }} }; -if (num_AutoNeg > bd) { - an = AutoNeg[bd]; -e1000_validate_option (&an, &opt, adapter); - }else { - an = opt.def; - } + an = AutoNeg[bd]; +e1000_validate_option (&an, &opt, adapter); adapter->hw.autoneg_advertised = an; }switch (speed + dplx) {case 0 : adapter->hw.autoneg = adapter->fc_autoneg =1 ; -if ((num_Speed > bd) && (speed !=0 || dplx !=0 )) +if (Speed[bd] !=OPTION_UNSET || Duplex[bd] !=OPTION_UNSET )DPRINTK (PROBE ,INFO ,"Speed and duplex autonegotiation enabled\n" );break ;
--
Auke Kok <[email protected]>
PATCH 10/21 e1000: force register write flushes to circumvent broken platforms
In reply to Kok, AukeA certain AMD64 bridge (8132) has an option to turn on write combining which breaks our adapter. To circumvent this we need to flush every write.
---
drivers/net/e1000/e1000_hw.c | 24 ++++++++++++++++++++++-- drivers/net/e1000/e1000_main.c | 18 +++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-)
drivers/net/e1000/e1000_hw.c +22 -2
@@ -705,8 +705,12 @@ e1000_init_hw(struct e1000_hw *hw)/* Zero out the Multicast HASH table */ DEBUGOUT ("Zeroing the MTA\n" ); mta_size =E1000_MC_TBL_SIZE ; -for (i =0 ; i < mta_size; i++) +for (i =0 ; i < mta_size; i++) {E1000_WRITE_REG_ARRAY (hw,MTA , i,0 ); +/* use write flush to prevent Memory Write Block (MWB) from +* occuring when accessing our register space */ +E1000_WRITE_FLUSH (hw); + }/* Set the PCI priority bit correctly in the CTRL register. This * determines if the adapter gives priority to receives, or if it
@@ -5106,7 +5110,9 @@ e1000_init_rx_addrs(struct e1000_hw *hw)DEBUGOUT ("Clearing RAR[1-15]\n" );for (i =1 ; i < rar_num; i++) {E1000_WRITE_REG_ARRAY (hw,RA , (i <<1 ),0 ); +E1000_WRITE_FLUSH (hw);E1000_WRITE_REG_ARRAY (hw,RA , ((i <<1 ) +1 ),0 ); +E1000_WRITE_FLUSH (hw); } }
@@ -5153,7 +5159,9 @@ e1000_mc_addr_list_update(struct e1000_hfor (i = rar_used_count; i < num_rar_entry; i++) {E1000_WRITE_REG_ARRAY (hw,RA , (i <<1 ),0 ); +E1000_WRITE_FLUSH (hw);E1000_WRITE_REG_ARRAY (hw,RA , ((i <<1 ) +1 ),0 ); +E1000_WRITE_FLUSH (hw); }/* Clear the MTA */
@@ -5161,6 +5169,7 @@ e1000_mc_addr_list_update(struct e1000_h num_mta_entry =E1000_NUM_MTA_REGISTERS ;for (i =0 ; i < num_mta_entry; i++) {E1000_WRITE_REG_ARRAY (hw,MTA , i,0 ); +E1000_WRITE_FLUSH (hw); }/* Add the new addresses */
@@ -5275,9 +5284,12 @@ e1000_mta_set(struct e1000_hw *hw,if ((hw->mac_type == e1000_82544) && ((hash_reg &0x1 ) ==1 )) { temp =E1000_READ_REG_ARRAY (hw,MTA , (hash_reg -1 ));E1000_WRITE_REG_ARRAY (hw,MTA , hash_reg, mta); +E1000_WRITE_FLUSH (hw);E1000_WRITE_REG_ARRAY (hw,MTA , (hash_reg -1 ), temp); +E1000_WRITE_FLUSH (hw); }else {E1000_WRITE_REG_ARRAY (hw,MTA , hash_reg, mta); +E1000_WRITE_FLUSH (hw); } }
@@ -5334,7 +5346,9 @@ e1000_rar_set(struct e1000_hw *hw, }E1000_WRITE_REG_ARRAY (hw,RA , (index <<1 ), rar_low); +E1000_WRITE_FLUSH (hw);E1000_WRITE_REG_ARRAY (hw,RA , ((index <<1 ) +1 ), rar_high); +E1000_WRITE_FLUSH (hw); }/******************************************************************************
@@ -5354,9 +5368,12 @@ e1000_write_vfta(struct e1000_hw *hw,if ((hw->mac_type == e1000_82544) && ((offset &0x1 ) ==1 )) { temp =E1000_READ_REG_ARRAY (hw,VFTA , (offset -1 ));E1000_WRITE_REG_ARRAY (hw,VFTA , offset, value); +E1000_WRITE_FLUSH (hw);E1000_WRITE_REG_ARRAY (hw,VFTA , (offset -1 ), temp); +E1000_WRITE_FLUSH (hw); }else {E1000_WRITE_REG_ARRAY (hw,VFTA , offset, value); +E1000_WRITE_FLUSH (hw); } }
@@ -5392,6 +5409,7 @@ e1000_clear_vfta(struct e1000_hw *hw)* manageability unit */ vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg :0 ;E1000_WRITE_REG_ARRAY (hw,VFTA , offset, vfta_value); +E1000_WRITE_FLUSH (hw); } }
@@ -6928,8 +6946,10 @@ e1000_mng_write_cmd_header(struct e1000_ length >>=2 ;/* The device driver writes the relevant command block into the ram area. */ -for (i =0 ; i < length; i++) +for (i =0 ; i < length; i++) {E1000_WRITE_REG_ARRAY_DWORD (hw,HOST_IF , i, *((uint32_t *) hdr + i)); +E1000_WRITE_FLUSH (hw); + }return E1000_SUCCESS ; }
drivers/net/e1000/e1000_main.c +11 -7
@@ -1370,11 +1370,11 @@ e1000_configure_tx(struct e1000_adapter tdba = adapter->tx_ring[0 ].dma; tdlen = adapter->tx_ring[0 ].count *sizeof (struct e1000_tx_desc ); -E1000_WRITE_REG (hw,TDBAL , (tdba &0x00000000ffffffffULL )); -E1000_WRITE_REG (hw,TDBAH , (tdba >>32 ));E1000_WRITE_REG (hw,TDLEN , tdlen); -E1000_WRITE_REG (hw,TDH ,0 ); +E1000_WRITE_REG (hw,TDBAH , (tdba >>32 )); +E1000_WRITE_REG (hw,TDBAL , (tdba &0x00000000ffffffffULL ));E1000_WRITE_REG (hw,TDT ,0 ); +E1000_WRITE_REG (hw,TDH ,0 ); adapter->tx_ring[0 ].tdh =E1000_TDH ; adapter->tx_ring[0 ].tdt =E1000_TDT ;break ;
@@ -1780,11 +1780,11 @@ e1000_configure_rx(struct e1000_adaptercase 1 :default : rdba = adapter->rx_ring[0 ].dma; -E1000_WRITE_REG (hw,RDBAL , (rdba &0x00000000ffffffffULL )); -E1000_WRITE_REG (hw,RDBAH , (rdba >>32 ));E1000_WRITE_REG (hw,RDLEN , rdlen); -E1000_WRITE_REG (hw,RDH ,0 ); +E1000_WRITE_REG (hw,RDBAH , (rdba >>32 )); +E1000_WRITE_REG (hw,RDBAL , (rdba &0x00000000ffffffffULL ));E1000_WRITE_REG (hw,RDT ,0 ); +E1000_WRITE_REG (hw,RDH ,0 ); adapter->rx_ring[0 ].rdh =E1000_RDH ; adapter->rx_ring[0 ].rdt =E1000_RDT ;break ;
@@ -2189,14 +2189,18 @@ e1000_set_multi(struct net_device *netde mc_ptr = mc_ptr->next; }else {E1000_WRITE_REG_ARRAY (hw,RA , i <<1 ,0 ); +E1000_WRITE_FLUSH (hw);E1000_WRITE_REG_ARRAY (hw,RA , (i <<1 ) +1 ,0 ); +E1000_WRITE_FLUSH (hw); } }/* clear the old settings from the multicast hash table */ -for (i =0 ; i <E1000_NUM_MTA_REGISTERS ; i++) +for (i =0 ; i <E1000_NUM_MTA_REGISTERS ; i++) {E1000_WRITE_REG_ARRAY (hw,MTA , i,0 ); +E1000_WRITE_FLUSH (hw); + }/* load any remaining addresses into the hash table */
--
Auke Kok <[email protected]>
Re: [PATCH 10/21] e1000: force register write flushes to circumvent broken platforms
Quoted 16 lines · Auke
A certain AMD64 bridge (8132) has an option to turn on write combining which breaks our adapter. To circumvent this we need to flush every write.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_hw.c | 24 ++++++++++++++++++++++-- drivers/net/e1000/e1000_main.c | 18 +++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-)drivers/net/e1000/e1000_hw.c +0
-0
drivers/net/e1000/e1000_hw.c e1000_init_hw(struct e1000_hw *hw) · line 713
Quoted 10 lines
drivers/net/e1000/e1000_hw.c +5
-1@@ -705,8 +705,12 @@ e1000_init_hw(struct e1000_hw *hw)/* Zero out the Multicast HASH table */ DEBUGOUT ("Zeroing the MTA\n" ); mta_size =E1000_MC_TBL_SIZE ; -for (i =0 ; i < mta_size; i++) +for (i =0 ; i < mta_size; i++) {E1000_WRITE_REG_ARRAY (hw,MTA , i,0 ); +/* use write flush to prevent Memory Write Block (MWB) from +* occuring when accessing our register space */ +E1000_WRITE_FLUSH (hw); + }
NAK. We can't crap up every driver just for one weird piece of hardware.
If this problem falls outside the grounds of mmiowb() [see Documentation/memory-barriers.txt], then other solutions need to be looked into... ioremap_nocache() ? Tweaking the MTRR for this region? Chipset quirk? ...
Jeff
Re: [PATCH 10/21] e1000: force register write flushes to circumvent broken platforms
Quoted 30 lines · Jeff Garzik
Quoted 16 lines · Auke
A certain AMD64 bridge (8132) has an option to turn on write combining which breaks our adapter. To circumvent this we need to flush every write.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_hw.c | 24 ++++++++++++++++++++++-- drivers/net/e1000/e1000_main.c | 18 +++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-)drivers/net/e1000/e1000_hw.c +0
-0drivers/net/e1000/e1000_hw.c e1000_init_hw(struct e1000_hw *hw) · line 713
Quoted 10 lines
drivers/net/e1000/e1000_hw.c +5
-1@@ -705,8 +705,12 @@ e1000_init_hw(struct e1000_hw *hw)/* Zero out the Multicast HASH table */ DEBUGOUT ("Zeroing the MTA\n" ); mta_size =E1000_MC_TBL_SIZE ; -for (i =0 ; i < mta_size; i++) +for (i =0 ; i < mta_size; i++) {E1000_WRITE_REG_ARRAY (hw,MTA , i,0 ); +/* use write flush to prevent Memory Write Block (MWB) from +* occuring when accessing our register space */ +E1000_WRITE_FLUSH (hw); + }NAK. We can't crap up every driver just for one weird piece of hardware.
Quoted 1 line
If this problem falls outside the grounds of
mmiowb()[seeDocumentation/memory-barriers.txt], then other solutions need to be looked into...ioremap_nocache()? Tweaking the MTRR for this region? Chipset quirk? ...
If there is an in-kernel fix for this that would make these flushes obsolete I would certainly prefer it too, unfortunately we can't fix already released kernels and our driver still needs to work there too, so that's why I queued it. It can be dropped from this series if that's preferred.
Cheers,
Auke
Re: [PATCH 10/21] e1000: force register write flushes to circumvent broken platforms
Quoted 1 line · Auke Kok
If there is an in-kernel fix for this that would make these flushes obsolete I would certainly prefer it too, unfortunately we can't fix already released kernels and our driver still needs to work there too, so that's why I queued it. It can be dropped from this series if that's preferred.
Yes, definitely drop it from the series...
Jeff
Re: [PATCH 10/21] e1000: force register write flushes to circumvent broken platforms
In reply to Auke KokQuoted 31 lines · Auke Kok
Quoted 30 lines · Jeff Garzik
Quoted 16 lines · Auke
A certain AMD64 bridge (8132) has an option to turn on write combining which breaks our adapter. To circumvent this we need to flush every write.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_hw.c | 24 ++++++++++++++++++++++-- drivers/net/e1000/e1000_main.c | 18 +++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-)drivers/net/e1000/e1000_hw.c +0
-0drivers/net/e1000/e1000_hw.c e1000_init_hw(struct e1000_hw *hw) · line 713
Quoted 10 lines
drivers/net/e1000/e1000_hw.c +5
-1@@ -705,8 +705,12 @@ e1000_init_hw(struct e1000_hw *hw)/* Zero out the Multicast HASH table */ DEBUGOUT ("Zeroing the MTA\n" ); mta_size =E1000_MC_TBL_SIZE ; -for (i =0 ; i < mta_size; i++) +for (i =0 ; i < mta_size; i++) {E1000_WRITE_REG_ARRAY (hw,MTA , i,0 ); +/* use write flush to prevent Memory Write Block (MWB) from +* occuring when accessing our register space */ +E1000_WRITE_FLUSH (hw); + }NAK. We can't crap up every driver just for one weird piece of hardware.
Quoted 3 lines
Quoted 1 line
If this problem falls outside the grounds of
mmiowb()[seeDocumentation/memory-barriers.txt], then other solutions need to be looked into...ioremap_nocache()? Tweaking the MTRR for this region? Chipset quirk? ...If there is an in-kernel fix for this that would make these flushes obsolete I would certainly prefer it too, unfortunately we can't fix already released kernels and our driver still needs to work there too, so that's why I queued it. It can be dropped from this series if that's preferred.
I have to get back on that - it's not as simple as "the platform is broken". e1000's don't support write-combining in hardware but the problem only shows itself during initialization. This patch makes it work on AMD platforms with write-combining enabled, the platform itself isn't broken - technically the NIC is (ixgb doesn't have this problem for instance).
The added write flushes are at initialization only, and fix the problem for any other case. I don't see much harm in that.
Auke
PATCH 11/21 e1000: disable CRC stripping workaround
In reply to Kok, AukeCRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
---
drivers/net/e1000/e1000_main.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_main.c +6 -1
@@ -1628,8 +1628,11 @@ e1000_setup_rctl(struct e1000_adapter *aE1000_RCTL_LBM_NO |E1000_RCTL_RDMTS_HALF | (adapter->hw.mc_filter_type <<E1000_RCTL_MO_SHIFT ); +/* disable hardware stripping of CRC because it breaks +* BMC firmware connected over SMBUS if (adapter->hw.mac_type > e1000_82543) rctl |= E1000_RCTL_SECRC; +*/ if (adapter->hw.tbi_compatibility_on ==1 ) rctl |=E1000_RCTL_SBP ;
@@ -1696,7 +1699,9 @@ e1000_setup_rctl(struct e1000_adapter *a rfctl |=E1000_RFCTL_IPV6_DIS ;E1000_WRITE_REG (&adapter->hw,RFCTL , rfctl); - rctl |=E1000_RCTL_DTYP_PS |E1000_RCTL_SECRC ; +/* disable the stripping of CRC because it breaks +* BMC firmware connected over SMBUS */ + rctl |=E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */ ; psrctl |= adapter->rx_ps_bsize0 >>E1000_PSRCTL_BSIZE0_SHIFT ;
--
Auke Kok <[email protected]>
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
Quoted 2 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Shouldn't you also have to subtract 4 bytes when setting the skb len in the receive logic? Perhaps when setting the rx-bytes counter as well?
Ben
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
Quoted 6 lines · Ben Greear
Quoted 2 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Shouldn't you also have to subtract 4 bytes when setting the skb len in the receive logic? Perhaps when setting the rx-bytes counter as well?
the hardware corrects for the size properly when we disable CRC stripping. The end result is the same.
Cheers,
Auke
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
In reply to Ben GreearQuoted 6 lines · Ben Greear
Quoted 2 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Shouldn't you also have to subtract 4 bytes when setting the skb len in the receive logic? Perhaps when setting the rx-bytes counter as well?
we thought about this, but most drivers don't strip the CRC, and we couldn't find any tests including bridging that cared if the CRC was there in the indicated packet.
If you can find me a failing case I'll fix it. It was much simpler to leave it out, especially when we add back in the multiple descriptor receive code in the future (think about the case when subtracting the CRC makes the last descriptor disappear)
Once again, let me know if you have info I don't :-)
Thanks for the review,
Jesse
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
Quoted 14 lines · Jesse Brandeburg
Quoted 6 lines · Ben Greear
Quoted 2 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Shouldn't you also have to subtract 4 bytes when setting the skb len in the receive logic? Perhaps when setting the rx-bytes counter as well?
we thought about this, but most drivers don't strip the CRC, and we couldn't find any tests including bridging that cared if the CRC was there in the indicated packet.
Quoted 6 lines
If you can find me a failing case I'll fix it. It was much simpler to leave it out, especially when we add back in the multiple descriptor receive code in the future (think about the case when subtracting the CRC makes the last descriptor disappear)
Once again, let me know if you have info I don't :-)
It should only be a problem if skb->len includes the extra 4 bytes for the crc. Then, if I transmit that skb to another interface, I am afraid that the crc will be seen as data in the packet. In the 2.6.13 days, the e1000 did not strip the CRC, but it subtracted 4 before it did the skb_put. So, the crc was correctly stripped/ignored. The e100 functioned similarly I believe.
If you skb_put the extra 4 bytes, I believe this will break my (proprietary) app because on transmit it will append the extra 4 crc bytes, but that isn't your problem..and I can work around it. If the receiving NIC can handle pkts 4 bytes bigger than normal, it will probably still receive the packet w/out problem, but in truth, the frame will not be exactly correct.
When you did your bridging tests, did you sniff the packets on the far side of the bridge to see if they were the right size?
Thanks,
Ben
Quoted 4 lines
Thanks for the review,
Jesse
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
Quoted 20 lines · Ben Greear
Quoted 19 lines · Jesse Brandeburg
Quoted 6 lines · Ben Greear
Quoted 2 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Shouldn't you also have to subtract 4 bytes when setting the skb len in the receive logic? Perhaps when setting the rx-bytes counter as well?
we thought about this, but most drivers don't strip the CRC, and we couldn't find any tests including bridging that cared if the CRC was there in the indicated packet.
If you can find me a failing case I'll fix it. It was much simpler to leave it out, especially when we add back in the multiple descriptor receive code in the future (think about the case when subtracting the CRC makes the last descriptor disappear)
Quoted 8 lines
Quoted 1 line
Once again, let me know if you have info I don't :-)
It should only be a problem if
skb->lenincludes the extra 4 bytes for the crc. Then, if I transmit that skb to another interface, I am afraid that the crc will be seen as data in the packet. In the 2.6.13 days, the e1000 did not strip the CRC, but it subtracted 4 before it did theskb_put. So, the crc was correctly stripped/ignored. The e100 functioned similarly I believe.
currently the e100 driver in 2.6.X strips the CRC in hardware.
Quoted 9 lines
If you
skb_putthe extra 4 bytes, I believe this will break my (proprietary) app because on transmit it will append the extra 4 crc bytes, but that isn't your problem..and I can work around it. If the receiving NIC can handle pkts 4 bytes bigger than normal, it will probably still receive the packet w/out problem, but in truth, the frame will not be exactly correct.When you did your bridging tests, did you sniff the packets on the far side of the bridge to see if they were the right size?
hm, probably not, we touch tested bridging (probably with TCP), and have completed several internal testing passes, to make sure it worked
but I don't think we went so far as to sniff the traffic at the
other end of the bridge. I'll look into it.
Jesse
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
In reply to Jesse BrandeburgQuoted 7 lines · Jesse Brandeburg
Quoted 5 lines
Quoted 2 lines
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Shouldn't you also have to subtract 4 bytes when setting the skb len in the receive logic? Perhaps when setting the rx-bytes counter as well?
we thought about this, but most drivers don't strip the CRC,
Really?
Quoted 2 lines
and we couldn't find any tests including bridging that cared if the CRC was there in the indicated packet.
Bridging definitely cares -- some years ago there was a case where 8139too NICs would pass packets up the stack with 4 bytes of FCS, and that causes frames received on 8139too interfaces not to be forwarded to other interfaces because on TX, the frame would be too long.
Maybe e1000 is okay with sending oversized frames, but other NIC drivers might not be.
(Did you test without bridge-netfilter enabled? bridge-nf might trim incoming IP packets even in the bridging case.)
cheers,
Lennert
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
In reply to Kok, AukeQuoted 27 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_main.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)drivers/net/e1000/e1000_main.c +3
-0@@ -1628,8 +1628,11 @@ e1000_setup_rctl(struct e1000_adapter *aE1000_RCTL_LBM_NO |E1000_RCTL_RDMTS_HALF | (adapter->hw.mc_filter_type <<E1000_RCTL_MO_SHIFT ); +/* disable hardware stripping of CRC because it breaks +* BMC firmware connected over SMBUS if (adapter->hw.mac_type > e1000_82543) rctl |= E1000_RCTL_SECRC; +*/ if (adapter->hw.tbi_compatibility_on ==1 ) rctl |=E1000_RCTL_SBP ;
drivers/net/e1000/e1000_main.c e1000_setup_rctl(struct e1000_adapter *a · line 1704
Quoted 7 lines
drivers/net/e1000/e1000_main.c +3
-1@@ -1696,7 +1699,9 @@ e1000_setup_rctl(struct e1000_adapter *a rfctl |=E1000_RFCTL_IPV6_DIS ;E1000_WRITE_REG (&adapter->hw,RFCTL , rfctl); - rctl |=E1000_RCTL_DTYP_PS |E1000_RCTL_SECRC ; +/* disable the stripping of CRC because it breaks +* BMC firmware connected over SMBUS */ + rctl |=E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */ ;
This is quite ugly. You are basically bloating the code with historic, dead code, no different than filling the e1000/*.c with '#if 0' regions.
Just delete it, and explain why in the patch description.
Jeff
Re: [PATCH 11/21] e1000: disable CRC stripping workaround
Quoted 31 lines · Jeff Garzik
Quoted 30 lines · Auke
CRC stripping is breaking SMBUS-connected BMC's. We disable this feature to make it work. This fixes related bugs regarding SOL.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_main.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)drivers/net/e1000/e1000_main.c +3
-0@@ -1628,8 +1628,11 @@ e1000_setup_rctl(struct e1000_adapter *aE1000_RCTL_LBM_NO |E1000_RCTL_RDMTS_HALF | (adapter->hw.mc_filter_type <<E1000_RCTL_MO_SHIFT ); +/* disable hardware stripping of CRC because it breaks +* BMC firmware connected over SMBUS if (adapter->hw.mac_type > e1000_82543) rctl |= E1000_RCTL_SECRC; +*/ if (adapter->hw.tbi_compatibility_on ==1 ) rctl |=E1000_RCTL_SBP ;@@ -1696,7 +1699,9 @@ e1000_setup_rctl(struct e1000_adapter *a rfctl |=E1000_RFCTL_IPV6_DIS ;E1000_WRITE_REG (&adapter->hw,RFCTL , rfctl);
Quoted 8 lines
drivers/net/e1000/e1000_main.c e1000_setup_rctl(struct e1000_adapter *a · line 1704
Quoted 4 lines
drivers/net/e1000/e1000_main.c +3
-1- rctl |=E1000_RCTL_DTYP_PS |E1000_RCTL_SECRC ; +/* disable the stripping of CRC because it breaks +* BMC firmware connected over SMBUS */ + rctl |=E1000_RCTL_DTYP_PS /* | E1000_RCTL_SECRC */ ;This is quite ugly. You are basically bloating the code with historic, dead code, no different than filling the e1000/*.c with '#if 0' regions.
Just delete it, and explain why in the patch description.
Adjusted the patch on our git server to this:
drivers/net/e1000/e1000_main.c +1 -4
@@ -1628,9 +1628,6 @@ e1000_setup_rctl(struct e1000_adapter *aE1000_RCTL_LBM_NO |E1000_RCTL_RDMTS_HALF | (adapter->hw.mc_filter_type <<E1000_RCTL_MO_SHIFT ); -if (adapter->hw.mac_type > e1000_82543) - rctl |=E1000_RCTL_SECRC ; -if (adapter->hw.tbi_compatibility_on ==1 ) rctl |=E1000_RCTL_SBP ;else
@@ -1696,7 +1693,7 @@ e1000_setup_rctl(struct e1000_adapter *a rfctl |=E1000_RFCTL_IPV6_DIS ;E1000_WRITE_REG (&adapter->hw,RFCTL , rfctl); - rctl |=E1000_RCTL_DTYP_PS |E1000_RCTL_SECRC ; + rctl |=E1000_RCTL_DTYP_PS ; psrctl |= adapter->rx_ps_bsize0 >>E1000_PSRCTL_BSIZE0_SHIFT ;
Cheers,
Auke
PATCH 12/21 e1000: fix adapter led blinking inconsistency
In reply to Kok, AukeSeveral e1000 adapters were not blinking correctly or inconsistently. This patch cleans this up and makes them all behave the same as far as possible.
---
drivers/net/e1000/e1000_ethtool.c | 15 +-------------- drivers/net/e1000/e1000_hw.c | 38 +++++++++++++++++++++++++++++++++++++ drivers/net/e1000/e1000_hw.h | 1 + 3 files changed, 40 insertions(+), 14 deletions(-)
drivers/net/e1000/e1000_ethtool.c +1 -14
@@ -1786,21 +1786,8 @@ e1000_phys_id(struct net_device *netdev,mod_timer (&adapter->blink_timer, jiffies);msleep_interruptible (data *1000 );del_timer_sync (&adapter->blink_timer); - }else if (adapter->hw.mac_type < e1000_82573) { -E1000_WRITE_REG (&adapter->hw,LEDCTL , - (E1000_LEDCTL_LED2_BLINK_RATE | -E1000_LEDCTL_LED0_BLINK |E1000_LEDCTL_LED2_BLINK | - (E1000_LEDCTL_MODE_LED_ON <<E1000_LEDCTL_LED2_MODE_SHIFT ) | - (E1000_LEDCTL_MODE_LINK_ACTIVITY <<E1000_LEDCTL_LED0_MODE_SHIFT ) | - (E1000_LEDCTL_MODE_LED_OFF <<E1000_LEDCTL_LED1_MODE_SHIFT ))); -msleep_interruptible (data *1000 ); }else { -E1000_WRITE_REG (&adapter->hw,LEDCTL , - (E1000_LEDCTL_LED2_BLINK_RATE | -E1000_LEDCTL_LED1_BLINK |E1000_LEDCTL_LED2_BLINK | - (E1000_LEDCTL_MODE_LED_ON <<E1000_LEDCTL_LED2_MODE_SHIFT ) | - (E1000_LEDCTL_MODE_LINK_ACTIVITY <<E1000_LEDCTL_LED1_MODE_SHIFT ) | - (E1000_LEDCTL_MODE_LED_OFF <<E1000_LEDCTL_LED0_MODE_SHIFT ))); +e1000_blink_led_start (&adapter->hw);msleep_interruptible (data *1000 ); }
drivers/net/e1000/e1000_hw.c +38 -0
@@ -5537,6 +5537,44 @@ e1000_setup_led(struct e1000_hw *hw) }/****************************************************************************** +* Used on 82571 and later Si that has LED blink bits. +* Callers must use their own timer and should have already called +* e1000_id_led_init() +* Call e1000_cleanup led() to stop blinking +* +* hw - Struct containing variables accessed by shared code +*****************************************************************************/ +int32_t +e1000_blink_led_start (struct e1000_hw *hw) +{ +int16_t i; +uint32_t ledctl_blink =0 ; + +DEBUGFUNC ("e1000_id_led_blink_on" ); + +if (hw->mac_type < e1000_82571) { +/* Nothing to do */ +return E1000_SUCCESS ; + } +if (hw->media_type == e1000_media_type_fiber) { +/* always blink LED0 for PCI-E fiber */ + ledctl_blink =E1000_LEDCTL_LED0_BLINK | + (E1000_LEDCTL_MODE_LED_ON <<E1000_LEDCTL_LED0_MODE_SHIFT ); + }else { +/* set the blink bit for each LED that's "on" (0x0E) in ledctl_mode2 */ + ledctl_blink = hw->ledctl_mode2; +for (i=0 ; i <4 ; i++) +if (((hw->ledctl_mode2 >> (i *8 )) &0xFF ) == +E1000_LEDCTL_MODE_LED_ON ) + ledctl_blink |= (E1000_LEDCTL_LED0_BLINK << (i *8 )); + } + +E1000_WRITE_REG (hw,LEDCTL , ledctl_blink); + +return E1000_SUCCESS ; +} + +/****************************************************************************** * Restores the saved state of the SW controlable LED. * * hw - Struct containing variables accessed by shared code
drivers/net/e1000/e1000_hw.h +1 -0
@@ -401,6 +401,7 @@ int32_t e1000_setup_led(struct e1000_hwint32_t e1000_cleanup_led (struct e1000_hw *hw);int32_t e1000_led_on (struct e1000_hw *hw);int32_t e1000_led_off (struct e1000_hw *hw); +int32_t e1000_blink_led_start (struct e1000_hw *hw);/* Adaptive IFS Functions */
--
Auke Kok <[email protected]>
PATCH 13/21 e1000: add E1000_BIG_ENDIAN symbol
In reply to Kok, AukeThis adds a private symbol to signify endianess in our driver.
---
drivers/net/e1000/e1000_hw.h | 2 +- drivers/net/e1000/e1000_osdep.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_hw.h +1 -1
@@ -351,7 +351,7 @@ struct e1000_host_mng_command_info {struct e1000_host_mng_command_header command_header;/* Command Head/Command Result Head has 4 bytes */ uint8_t command_data[E1000_HI_MAX_MNG_DATA_LENGTH ];/* Command data can length 0..0x658*/ }; -#ifdef __BIG_ENDIAN +#ifdef E1000_BIG_ENDIAN struct e1000_host_mng_dhcp_cookie{ uint32_t signature; uint16_t vlan_id;
drivers/net/e1000/e1000_osdep.h +3 -0
@@ -83,6 +83,9 @@ typedef enum {#define DEBUGOUT3 DEBUGOUT2#define DEBUGOUT7 DEBUGOUT3 +#ifdef __BIG_ENDIAN +#define E1000_BIG_ENDIAN __BIG_ENDIAN +#endif #define E1000_WRITE_REG (a, reg, value) ( \ writel((value), ((a)->hw_addr + \
--
Auke Kok <[email protected]>
Re: [PATCH 13/21] e1000: add E1000_BIG_ENDIAN symbol
Quoted 28 lines · Auke
This adds a private symbol to signify endianess in our driver.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_hw.h | 2 +- drivers/net/e1000/e1000_osdep.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletions(-)drivers/net/e1000/e1000_hw.h +1
-1@@ -351,7 +351,7 @@ struct e1000_host_mng_command_info {struct e1000_host_mng_command_header command_header;/* Command Head/Command Result Head has 4 bytes */ uint8_t command_data[E1000_HI_MAX_MNG_DATA_LENGTH ];/* Command data can length 0..0x658*/ }; -#ifdef __BIG_ENDIAN +#ifdef E1000_BIG_ENDIAN struct e1000_host_mng_dhcp_cookie{ uint32_t signature; uint16_t vlan_id;drivers/net/e1000/e1000_osdep.h +0
-0
drivers/net/e1000/e1000_osdep.h typedef enum { · line 88
Quoted 6 lines
drivers/net/e1000/e1000_osdep.h +3
-0@@ -83,6 +83,9 @@ typedef enum {#define DEBUGOUT3 DEBUGOUT2#define DEBUGOUT7 DEBUGOUT3 +#ifdef __BIG_ENDIAN +#define E1000_BIG_ENDIAN __BIG_ENDIAN +#endif
NAK. This is backwards: We don't need wrappers for symbols that the kernel already provides.
Jeff
Re: [PATCH 13/21] e1000: add E1000_BIG_ENDIAN symbol
Quoted 34 lines · Jeff Garzik
Quoted 33 lines · Auke
This adds a private symbol to signify endianess in our driver.
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_hw.h | 2 +- drivers/net/e1000/e1000_osdep.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletions(-)drivers/net/e1000/e1000_hw.h +0
-0@@ -351,7 +351,7 @@ struct e1000_host_mng_command_info {struct e1000_host_mng_command_header command_header;/* Command Head/Command Result Head has 4 bytes */
uint8_t command_data[E1000_HI_MAX_MNG_DATA_LENGTH]; /* Commanddata can length 0..0x658*/
};drivers/net/e1000/e1000_hw.h +1
-1-#ifdef __BIG_ENDIAN +#ifdef E1000_BIG_ENDIAN struct e1000_host_mng_dhcp_cookie{ uint32_t signature; uint16_t vlan_id;drivers/net/e1000/e1000_osdep.h +0
-0@@ -83,6 +83,9 @@ typedef enum {#define DEBUGOUT3 DEBUGOUT2#define DEBUGOUT7 DEBUGOUT3
Quoted 5 lines
drivers/net/e1000/e1000_osdep.h typedef enum { · line 88
Quoted 3 lines
drivers/net/e1000/e1000_osdep.h +3
-0+#ifdef __BIG_ENDIAN +#define E1000_BIG_ENDIAN __BIG_ENDIAN +#endif NAK. This is backwards: We don't need wrappers for symbols that the kernel already provides.
Agreed, I deleted it from our git server.
Auke
PATCH 14/21 e1000: M88 PHY workaround
In reply to Kok, AukeM88 rev 2 PHY needs a longer downshift to function properly. This adds a much longer downshift counter for this specific device.
---
drivers/net/e1000/e1000_hw.c | 46 ++++++++++++++++++++++++++---------------- drivers/net/e1000/e1000_hw.h | 11 ++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-)
drivers/net/e1000/e1000_hw.c +29 -17
@@ -1565,28 +1565,40 @@ e1000_copper_link_mgp_setup(struct e1000 phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL ;if (hw->disable_polarity_correction ==1 ) phy_data |=M88E1000_PSCR_POLARITY_REVERSAL ; - ret_val =e1000_write_phy_reg (hw,M88E1000_PHY_SPEC_CTRL , phy_data); -if (ret_val) -return ret_val; - -/* Force TX_CLK in the Extended PHY Specific Control Register -* to 25MHz clock. -*/ - ret_val =e1000_read_phy_reg (hw,M88E1000_EXT_PHY_SPEC_CTRL , &phy_data); -if (ret_val) + ret_val =e1000_write_phy_reg (hw,M88E1000_PHY_SPEC_CTRL , phy_data); +if (ret_val)return ret_val; - phy_data |=M88E1000_EPSCR_TX_CLK_25 ; -if (hw->phy_revision <M88E1011_I_REV_4 ) { -/* Configure Master and Slave downshift values */ - phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK | +/* Force TX_CLK in the Extended PHY Specific Control Register +* to 25MHz clock. +*/ + ret_val =e1000_read_phy_reg (hw,M88E1000_EXT_PHY_SPEC_CTRL , &phy_data); +if (ret_val) +return ret_val; + + phy_data |=M88E1000_EPSCR_TX_CLK_25 ; + +if ((hw->phy_revision ==E1000_REVISION_2 ) && + (hw->phy_id ==M88E1111_I_PHY_ID )) { +/* Vidalia Phy, set the downshift counter to 5x */ + phy_data &= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK ); + phy_data |=M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X ; + ret_val =e1000_write_phy_reg (hw, +M88E1000_EXT_PHY_SPEC_CTRL , phy_data); +if (ret_val) +return ret_val; + }else { +/* Configure Master and Slave downshift values */ + phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK ); - phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X | + phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X ); - ret_val =e1000_write_phy_reg (hw,M88E1000_EXT_PHY_SPEC_CTRL , phy_data); -if (ret_val) -return ret_val; + ret_val =e1000_write_phy_reg (hw, +M88E1000_EXT_PHY_SPEC_CTRL , phy_data); +if (ret_val) +return ret_val; + } }/* SW Reset the PHY so all changes take effect */
drivers/net/e1000/e1000_hw.h +11 -0
@@ -2765,6 +2765,17 @@ struct e1000_host_command_info {#define M88E1000_EPSCR_TX_CLK_25 0x0070/* 25 MHz TX_CLK */ #define M88E1000_EPSCR_TX_CLK_0 0x0000/* NO TX_CLK */ +/* M88EC018 Rev 2 specific DownShift settings */ +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK 0x0E00 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_1X 0x0000 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_2X 0x0200 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_3X 0x0400 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_4X 0x0600 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X 0x0800 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_6X 0x0A00 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_7X 0x0C00 +#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_8X 0x0E00 +/* IGP01E1000 Specific Port Config Register - R/W */ #define IGP01E1000_PSCFR_AUTO_MDIX_PAR_DETECT 0x0010#define IGP01E1000_PSCFR_PRE_EN 0x0020
--
Auke Kok <[email protected]>
PATCH 15/21 e1000: check return value of _get_speed_and_duplex
In reply to Kok, AukeWe were not checking the return value of get_speed_and_duplex properly, whih may contain an error value.
---
drivers/net/e1000/e1000_hw.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/e1000/e1000_hw.c +6 -2
@@ -2737,8 +2737,12 @@ e1000_check_for_link(struct e1000_hw *hw*/ if (hw->tbi_compatibility_en) {uint16_t speed, duplex; -e1000_get_speed_and_duplex (hw, &speed, &duplex); -if (speed !=SPEED_1000 ) { + ret_val =e1000_get_speed_and_duplex (hw, &speed, &duplex); +if (ret_val) { +DEBUGOUT ("Error getting link speed and duplex\n" ); +return ret_val; + } +if (speed !=SPEED_1000 ) {/* If link speed is not set to gigabit speed, we do not need * to enable TBI compatibility. */
--
Auke Kok <[email protected]>
PATCH 16/21 e1000: disable ERT
In reply to Kok, AukeHardware is reported to have problems with ERT. We disable it for all hardware to make sure we are not seeing unexplainable user problems.
---
drivers/net/e1000/e1000_main.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/net/e1000/e1000_main.c +0 -3
@@ -1814,9 +1814,6 @@ e1000_configure_rx(struct e1000_adapterE1000_WRITE_REG (hw,RXCSUM , rxcsum); } -if (hw->mac_type == e1000_82573) -E1000_WRITE_REG (hw,ERT ,0x0100 ); -/* Enable Receives */ E1000_WRITE_REG (hw,RCTL , rctl); }
--
Auke Kok <[email protected]>
PATCH 17/21 e1000: add ich8lan core functions
In reply to Kok, AukeThis implements the core new functions needed for ich8's internal NIC. This includes:
* ich8 specific read/write code
* flash/nvm access code
* software semaphore flag functions
* 10/100 PHY (fe - no gigabit speed) support for low-end versions
* A workaround for a powerdown sequence problem discovered that affects a small number of motherboard.
---
drivers/net/e1000/e1000_hw.c | 1000 +++++++++++++++++++++++++++++++++++++++ drivers/net/e1000/e1000_hw.h | 386 +++++++++++++++ drivers/net/e1000/e1000_osdep.h | 13 + 3 files changed, 1392 insertions(+), 7 deletions(-)
drivers/net/e1000/e1000_hw.c +999 -1
@@ -3617,11 +3617,120 @@ e1000_phy_reset(struct e1000_hw *hw) }/****************************************************************************** +* Work-around for 82566 power-down: on D3 entry- +* 1) disable gigabit link +* 2) write VR power-down enable +* 3) read it back +* if successful continue, else issue LCD reset and repeat +* +* hw - struct containing variables accessed by shared code +******************************************************************************/ +void +e1000_phy_powerdown_workaround (struct e1000_hw *hw) +{ +int32_t reg; +uint16_t phy_data; +int32_t retry =0 ; + +DEBUGFUNC ("e1000_phy_powerdown_workaround" ); + +if (hw->phy_type != e1000_phy_igp_3) +return ; + +do { +/* Disable link */ + reg =E1000_READ_REG (hw,PHY_CTRL ); +E1000_WRITE_REG (hw,PHY_CTRL , reg |E1000_PHY_CTRL_GBE_DISABLE | +E1000_PHY_CTRL_NOND0A_GBE_DISABLE ); + +/* Write VR power-down enable */ +e1000_read_phy_reg (hw,IGP3_VR_CTRL , &phy_data); +e1000_write_phy_reg (hw,IGP3_VR_CTRL , phy_data | +IGP3_VR_CTRL_MODE_SHUT ); + +/* Read it back and test */ +e1000_read_phy_reg (hw,IGP3_VR_CTRL , &phy_data); +if ((phy_data &IGP3_VR_CTRL_MODE_SHUT ) || retry) +break ; + +/* Issue PHY reset and repeat at most one more time */ + reg =E1000_READ_REG (hw,CTRL ); +E1000_WRITE_REG (hw,CTRL , reg |E1000_CTRL_PHY_RST ); + retry++; + }while (retry); + +return ; + +} + +/****************************************************************************** +* Work-around for 82566 Kumeran PCS lock loss: +* On link status change (i.e. PCI reset, speed change) and link is up and +* speed is gigabit- +* 0) if workaround is optionally disabled do nothing +* 1) wait 1ms for Kumeran link to come up +* 2) check Kumeran Diagnostic register PCS lock loss bit +* 3) if not set the link is locked (all is good), otherwise... +* 4) reset the PHY +* 5) repeat up to 10 times +* Note: this is only called for IGP3 copper when speed is 1gb. +* +* hw - struct containing variables accessed by shared code +******************************************************************************/ +int32_t +e1000_kumeran_lock_loss_workaround (struct e1000_hw *hw) +{ +int32_t ret_val; +int32_t reg; +int32_t cnt; +uint16_t phy_data; + +if (hw->kmrn_lock_loss_workaround_disabled) +return E1000_SUCCESS ; + +/* Make sure link is up before proceeding. If not just return. +* Attempting this while link is negotiating fouls up link +* stability */ + ret_val =e1000_read_phy_reg (hw,PHY_STATUS , &phy_data); + ret_val =e1000_read_phy_reg (hw,PHY_STATUS , &phy_data); + +if (phy_data &MII_SR_LINK_STATUS ) { +for (cnt =0 ; cnt <10 ; cnt++) { +/* read once to clear */ + ret_val =e1000_read_phy_reg (hw,IGP3_KMRN_DIAG , &phy_data); +if (ret_val) +return ret_val; +/* and again to get new status */ + ret_val =e1000_read_phy_reg (hw,IGP3_KMRN_DIAG , &phy_data); +if (ret_val) +return ret_val; + +/* check for PCS lock */ +if (!(phy_data &IGP3_KMRN_DIAG_PCS_LOCK_LOSS )) +return E1000_SUCCESS ; + +/* Issue PHY reset */ +e1000_phy_hw_reset (hw); +msec_delay_irq (5 ); + } +/* Disable GigE link negotiation */ + reg =E1000_READ_REG (hw,PHY_CTRL ); +E1000_WRITE_REG (hw,PHY_CTRL , reg |E1000_PHY_CTRL_GBE_DISABLE | +E1000_PHY_CTRL_NOND0A_GBE_DISABLE ); + +/* unable to acquire PCS lock */ +return E1000_ERR_PHY ; + } + +return E1000_SUCCESS ; +} + +/****************************************************************************** * Probes the expected PHY address for known PHY IDs * * hw - Struct containing variables accessed by shared code ******************************************************************************/ -static int32_t +int32_t e1000_detect_gig_phy (struct e1000_hw *hw) {int32_t phy_init_status, ret_val;
@@ -3804,6 +3913,53 @@ e1000_phy_igp_get_info(struct e1000_hw * }/****************************************************************************** +* Get PHY information from various PHY registers for ife PHY only. +* +* hw - Struct containing variables accessed by shared code +* phy_info - PHY information structure +******************************************************************************/ +int32_t +e1000_phy_ife_get_info (struct e1000_hw *hw, +struct e1000_phy_info *phy_info) +{ +int32_t ret_val; +uint16_t phy_data, polarity; + +DEBUGFUNC ("e1000_phy_ife_get_info" ); + + phy_info->downshift = (e1000_downshift )hw->speed_downgraded; + phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal; + + ret_val =e1000_read_phy_reg (hw,IFE_PHY_SPECIAL_CONTROL , &phy_data); +if (ret_val) +return ret_val; + phy_info->polarity_correction = + (phy_data &IFE_PSC_AUTO_POLARITY_DISABLE ) >> +IFE_PSC_AUTO_POLARITY_DISABLE_SHIFT ; + +if (phy_info->polarity_correction == e1000_polarity_reversal_enabled) { + ret_val =e1000_check_polarity (hw, &polarity); +if (ret_val) +return ret_val; + }else { +/* Polarity is forced. */ + polarity = (phy_data &IFE_PSC_FORCE_POLARITY ) >> +IFE_PSC_FORCE_POLARITY_SHIFT ; + } + phy_info->cable_polarity = polarity; + + ret_val =e1000_read_phy_reg (hw,IFE_PHY_MDIX_CONTROL , &phy_data); +if (ret_val) +return ret_val; + + phy_info->mdix_mode = + (phy_data & (IFE_PMC_AUTO_MDIX |IFE_PMC_FORCE_MDIX )) >> +IFE_PMC_MDIX_MODE_SHIFT ; + +return E1000_SUCCESS ; +} + +/****************************************************************************** * Get PHY information from various PHY registers fot m88 PHY only. * * hw - Struct containing variables accessed by shared code
@@ -7630,4 +7786,846 @@ e1000_arc_subsystem_valid(struct e1000_h } +/****************************************************************************** +* Configure PCI-Ex no-snoop +* +* hw - Struct containing variables accessed by shared code. +* no_snoop - Bitmap of no-snoop events. +* +* returns: E1000_SUCCESS +* +*****************************************************************************/ +int32_t +e1000_set_pci_ex_no_snoop (struct e1000_hw *hw,uint32_t no_snoop) +{ +uint32_t gcr_reg =0 ; + +DEBUGFUNC ("e1000_set_pci_ex_no_snoop" ); + +if (hw->bus_type == e1000_bus_type_unknown) +e1000_get_bus_info (hw); + +if (hw->bus_type != e1000_bus_type_pci_express) +return E1000_SUCCESS ; + +if (no_snoop) { + gcr_reg =E1000_READ_REG (hw,GCR ); + gcr_reg &= ~(PCI_EX_NO_SNOOP_ALL ); + gcr_reg |= no_snoop; +E1000_WRITE_REG (hw,GCR , gcr_reg); + } +if (hw->mac_type == e1000_ich8lan) { +uint32_t ctrl_ext; + +E1000_WRITE_REG (hw,GCR ,PCI_EX_82566_SNOOP_ALL ); + + ctrl_ext =E1000_READ_REG (hw,CTRL_EXT ); + ctrl_ext |=E1000_CTRL_EXT_RO_DIS ; +E1000_WRITE_REG (hw,CTRL_EXT , ctrl_ext); + } + +return E1000_SUCCESS ; +} + +/*************************************************************************** +* +* Get software semaphore FLAG bit (SWFLAG). +* SWFLAG is used to synchronize the access to all shared resource between +* SW, FW and HW. +* +* hw: Struct containing variables accessed by shared code +* +***************************************************************************/ +int32_t +e1000_get_software_flag (struct e1000_hw *hw) +{ +int32_t timeout =PHY_CFG_TIMEOUT ; +uint32_t extcnf_ctrl; + +DEBUGFUNC ("e1000_get_software_flag" ); + +if (hw->mac_type == e1000_ich8lan) { +while (timeout) { + extcnf_ctrl =E1000_READ_REG (hw,EXTCNF_CTRL ); + extcnf_ctrl |=E1000_EXTCNF_CTRL_SWFLAG ; +E1000_WRITE_REG (hw,EXTCNF_CTRL , extcnf_ctrl); + + extcnf_ctrl =E1000_READ_REG (hw,EXTCNF_CTRL ); +if (extcnf_ctrl &E1000_EXTCNF_CTRL_SWFLAG ) +break ; +msec_delay_irq (1 ); + timeout--; + } + +if (!timeout) { +DEBUGOUT ("FW or HW locks the resource too long.\n" ); +return -E1000_ERR_CONFIG ; + } + } + +return E1000_SUCCESS ; +} + +/*************************************************************************** +* +* Release software semaphore FLAG bit (SWFLAG). +* SWFLAG is used to synchronize the access to all shared resource between +* SW, FW and HW. +* +* hw: Struct containing variables accessed by shared code +* +***************************************************************************/ +void +e1000_release_software_flag (struct e1000_hw *hw) +{ +uint32_t extcnf_ctrl; + +DEBUGFUNC ("e1000_release_software_flag" ); + +if (hw->mac_type == e1000_ich8lan) { + extcnf_ctrl=E1000_READ_REG (hw,EXTCNF_CTRL ); + extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG ; +E1000_WRITE_REG (hw,EXTCNF_CTRL , extcnf_ctrl); + } + +return ; +} + +/*************************************************************************** +* +* Disable dynamic power down mode in ife PHY. +* It can be used to workaround band-gap problem. +* +* hw: Struct containing variables accessed by shared code +* +***************************************************************************/ +int32_t +e1000_ife_disable_dynamic_power_down (struct e1000_hw *hw) +{ +uint16_t phy_data; +int32_t ret_val =E1000_SUCCESS ; + +DEBUGFUNC ("e1000_ife_disable_dynamic_power_down" ); + +if (hw->phy_type == e1000_phy_ife) { + ret_val =e1000_read_phy_reg (hw,IFE_PHY_SPECIAL_CONTROL , &phy_data); +if (ret_val) +return ret_val; + + phy_data |=IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN ; + ret_val =e1000_write_phy_reg (hw,IFE_PHY_SPECIAL_CONTROL , phy_data); + } + +return ret_val; +} + +/*************************************************************************** +* +* Enable dynamic power down mode in ife PHY. +* It can be used to workaround band-gap problem. +* +* hw: Struct containing variables accessed by shared code +* +***************************************************************************/ +int32_t +e1000_ife_enable_dynamic_power_down (struct e1000_hw *hw) +{ +uint16_t phy_data; +int32_t ret_val =E1000_SUCCESS ; + +DEBUGFUNC ("e1000_ife_enable_dynamic_power_down" ); + +if (hw->phy_type == e1000_phy_ife) { + ret_val =e1000_read_phy_reg (hw,IFE_PHY_SPECIAL_CONTROL , &phy_data); +if (ret_val) +return ret_val; + + phy_data &= ~IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN ; + ret_val =e1000_write_phy_reg (hw,IFE_PHY_SPECIAL_CONTROL , phy_data); + } + +return ret_val; +} + +/****************************************************************************** +* Reads a 16 bit word or words from the EEPROM using the ICH8's flash access +* register. +* +* hw - Struct containing variables accessed by shared code +* offset - offset of word in the EEPROM to read +* data - word read from the EEPROM +* words - number of words to read +*****************************************************************************/ +int32_t +e1000_read_eeprom_ich8 (struct e1000_hw *hw,uint16_t offset,uint16_t words, +uint16_t *data) +{ +int32_t error =E1000_SUCCESS ; +uint32_t flash_bank =0 ; +uint32_t act_offset =0 ; +uint32_t bank_offset =0 ; +uint16_t word =0 ; +uint16_t i =0 ; + +/* We need to know which is the valid flash bank. In the event +* that we didn't allocate eeprom_shadow_ram, we may not be +* managing flash_bank. So it cannot be trusted and needs +* to be updated with each read. +*/ +/* Value of bit 22 corresponds to the flash bank we're on. */ + flash_bank = (E1000_READ_REG (hw,EECD ) &E1000_EECD_SEC1VAL ) ?1 :0 ; + +/* Adjust offset appropriately if we're on bank 1 - adjust for word size */ + bank_offset = flash_bank * (hw->flash_bank_size *2 ); + + error =e1000_get_software_flag (hw); +if (error !=E1000_SUCCESS ) +return error; + +for (i =0 ; i < words; i++) { +if (hw->eeprom_shadow_ram !=NULL && + hw->eeprom_shadow_ram[offset+i].modified == TRUE) { + data[i] = hw->eeprom_shadow_ram[offset+i].eeprom_word; + }else { +/* The NVM part needs a byte offset, hence * 2 */ + act_offset = bank_offset + ((offset + i) *2 ); + error =e1000_read_ich8_word (hw, act_offset, &word); +if (error !=E1000_SUCCESS ) +break ; + data[i] = word; + } + } + +e1000_release_software_flag (hw); + +return error; +} + +/****************************************************************************** +* Writes a 16 bit word or words to the EEPROM using the ICH8's flash access +* register. Actually, writes are written to the shadow ram cache in the hw +* structure hw->e1000_shadow_ram. e1000_commit_shadow_ram flushes this to +* the NVM, which occurs when the NVM checksum is updated. +* +* hw - Struct containing variables accessed by shared code +* offset - offset of word in the EEPROM to write +* words - number of words to write +* data - words to write to the EEPROM +*****************************************************************************/ +int32_t +e1000_write_eeprom_ich8 (struct e1000_hw *hw,uint16_t offset,uint16_t words, +uint16_t *data) +{ +uint32_t i =0 ; +int32_t error =E1000_SUCCESS ; + + error =e1000_get_software_flag (hw); +if (error !=E1000_SUCCESS ) +return error; + +/* A driver can write to the NVM only if it has eeprom_shadow_ram +* allocated. Subsequent reads to the modified words are read from +* this cached structure as well. Writes will only go into this +* cached structure unless it's followed by a call to +* e1000_update_eeprom_checksum() where it will commit the changes +* and clear the "modified" field. +*/ +if (hw->eeprom_shadow_ram !=NULL ) { +for (i =0 ; i < words; i++) { +if ((offset + i) <E1000_SHADOW_RAM_WORDS ) { + hw->eeprom_shadow_ram[offset+i].modified = TRUE; + hw->eeprom_shadow_ram[offset+i].eeprom_word = data[i]; + }else { + error = -E1000_ERR_EEPROM ; +break ; + } + } + }else { +/* Drivers have the option to not allocate eeprom_shadow_ram as long +* as they don't perform any NVM writes. An attempt in doing so +* will result in this error. +*/ + error = -E1000_ERR_EEPROM ; + } + +e1000_release_software_flag (hw); + +return error; +} + +/****************************************************************************** +* This function does initial flash setup so that a new read/write/erase cycle +* can be started. +* +* hw - The pointer to the hw structure +****************************************************************************/ +int32_t +e1000_ich8_cycle_init (struct e1000_hw *hw) +{ +union ich8_hws_flash_status hsfsts; +int32_t error =E1000_ERR_EEPROM ; +int32_t i =0 ; + +DEBUGFUNC ("e1000_ich8_cycle_init" ); + + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); + +/* May be check the Flash Des Valid bit in Hw status */ +if (hsfsts.hsf_status.fldesvalid ==0 ) { +DEBUGOUT ("Flash descriptor invalid. SW Sequencing must be used." ); +return error; + } + +/* Clear FCERR in Hw status by writing 1 */ +/* Clear DAEL in Hw status by writing a 1 */ + hsfsts.hsf_status.flcerr =1 ; + hsfsts.hsf_status.dael =1 ; + +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS , hsfsts.regval); + +/* Either we should have a hardware SPI cycle in progress bit to check +* against, in order to start a new cycle or FDONE bit should be changed +* in the hardware so that it is 1 after harware reset, which can then be +* used as an indication whether a cycle is in progress or has been +* completed .. we should also have some software semaphore mechanism to +* guard FDONE or the cycle in progress bit so that two threads access to +* those bits can be sequentiallized or a way so that 2 threads dont +* start the cycle at the same time */ + +if (hsfsts.hsf_status.flcinprog ==0 ) { +/* There is no cycle running at present, so we can start a cycle */ +/* Begin by setting Flash Cycle Done. */ + hsfsts.hsf_status.flcdone =1 ; +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS , hsfsts.regval); + error =E1000_SUCCESS ; + }else { +/* otherwise poll for sometime so the current cycle has a chance +* to end before giving up. */ +for (i =0 ; i <ICH8_FLASH_COMMAND_TIMEOUT ; i++) { + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); +if (hsfsts.hsf_status.flcinprog ==0 ) { + error =E1000_SUCCESS ; +break ; + } +udelay (1 ); + } +if (error ==E1000_SUCCESS ) { +/* Successful in waiting for previous cycle to timeout, +* now set the Flash Cycle Done. */ + hsfsts.hsf_status.flcdone =1 ; +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS , hsfsts.regval); + }else { +DEBUGOUT ("Flash controller busy, cannot get access" ); + } + } +return error; +} + +/****************************************************************************** +* This function starts a flash cycle and waits for its completion +* +* hw - The pointer to the hw structure +****************************************************************************/ +int32_t +e1000_ich8_flash_cycle (struct e1000_hw *hw,uint32_t timeout) +{ +union ich8_hws_flash_ctrl hsflctl; +union ich8_hws_flash_status hsfsts; +int32_t error =E1000_ERR_EEPROM ; +uint32_t i =0 ; + +/* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ + hsflctl.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL ); + hsflctl.hsf_ctrl.flcgo =1 ; +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL , hsflctl.regval); + +/* wait till FDONE bit is set to 1 */ +do { + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); +if (hsfsts.hsf_status.flcdone ==1 ) +break ; +udelay (1 ); + i++; + }while (i < timeout); +if (hsfsts.hsf_status.flcdone ==1 && hsfsts.hsf_status.flcerr ==0 ) { + error =E1000_SUCCESS ; + } +return error; +} + +/****************************************************************************** +* Reads a byte or word from the NVM using the ICH8 flash access registers. +* +* hw - The pointer to the hw structure +* index - The index of the byte or word to read. +* size - Size of data to read, 1=byte 2=word +* data - Pointer to the word to store the value read. +*****************************************************************************/ +int32_t +e1000_read_ich8_data (struct e1000_hw *hw,uint32_t index, +uint32_t size,uint16_t * data) +{ +union ich8_hws_flash_status hsfsts; +union ich8_hws_flash_ctrl hsflctl; +uint32_t flash_linear_address; +uint32_t flash_data =0 ; +int32_t error = -E1000_ERR_EEPROM ; +int32_t count =0 ; + +DEBUGFUNC ("e1000_read_ich8_data" ); + +if (size <1 || size >2 || data ==0x0 || + index >ICH8_FLASH_LINEAR_ADDR_MASK ) +return error; + + flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + + hw->flash_base_addr; + +do { +udelay (1 ); +/* Steps */ + error =e1000_ich8_cycle_init (hw); +if (error !=E1000_SUCCESS ) +break ; + + hsflctl.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL ); +/* 0b/1b corresponds to 1 or 2 byte size, respectively. */ + hsflctl.hsf_ctrl.fldbcount = size -1 ; + hsflctl.hsf_ctrl.flcycle =ICH8_CYCLE_READ ; +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL , hsflctl.regval); + +/* Write the last 24 bits of index into Flash Linear address field in +* Flash Address */ +/* TODO: TBD maybe check the index against the size of flash */ + +E1000_WRITE_ICH8_REG (hw,ICH8_FLASH_FADDR , flash_linear_address); + + error =e1000_ich8_flash_cycle (hw,ICH8_FLASH_COMMAND_TIMEOUT ); + +/* Check if FCERR is set to 1, if set to 1, clear it and try the whole +* sequence a few more times, else read in (shift in) the Flash Data0, +* the order is least significant byte first msb to lsb */ +if (error ==E1000_SUCCESS ) { + flash_data =E1000_READ_ICH8_REG (hw,ICH8_FLASH_FDATA0 ); +if (size ==1 ) { + *data = (uint8_t )(flash_data &0x000000FF ); + }else if (size ==2 ) { + *data = (uint16_t )(flash_data &0x0000FFFF ); + } +break ; + }else { +/* If we've gotten here, then things are probably completely hosed, +* but if the error condition is detected, it won't hurt to give +* it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. +*/ + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); +if (hsfsts.hsf_status.flcerr ==1 ) { +/* Repeat for some time before giving up. */ +continue ; + }else if (hsfsts.hsf_status.flcdone ==0 ) { +DEBUGOUT ("Timeout error - flash cycle did not complete." ); +break ; + } + } + }while (count++ <ICH8_FLASH_CYCLE_REPEAT_COUNT ); + +return error; +} + +/****************************************************************************** +* Writes One /two bytes to the NVM using the ICH8 flash access registers. +* +* hw - The pointer to the hw structure +* index - The index of the byte/word to read. +* size - Size of data to read, 1=byte 2=word +* data - The byte(s) to write to the NVM. +*****************************************************************************/ +int32_t +e1000_write_ich8_data (struct e1000_hw *hw,uint32_t index,uint32_t size, +uint16_t data) +{ +union ich8_hws_flash_status hsfsts; +union ich8_hws_flash_ctrl hsflctl; +uint32_t flash_linear_address; +uint32_t flash_data =0 ; +int32_t error = -E1000_ERR_EEPROM ; +int32_t count =0 ; + +DEBUGFUNC ("e1000_write_ich8_data" ); + +if (size <1 || size >2 || data > size *0xff || + index >ICH8_FLASH_LINEAR_ADDR_MASK ) +return error; + + flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + + hw->flash_base_addr; + +do { +udelay (1 ); +/* Steps */ + error =e1000_ich8_cycle_init (hw); +if (error !=E1000_SUCCESS ) +break ; + + hsflctl.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL ); +/* 0b/1b corresponds to 1 or 2 byte size, respectively. */ + hsflctl.hsf_ctrl.fldbcount = size -1 ; + hsflctl.hsf_ctrl.flcycle =ICH8_CYCLE_WRITE ; +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL , hsflctl.regval); + +/* Write the last 24 bits of index into Flash Linear address field in +* Flash Address */ +E1000_WRITE_ICH8_REG (hw,ICH8_FLASH_FADDR , flash_linear_address); + +if (size ==1 ) + flash_data = (uint32_t )data &0x00FF ; +else + flash_data = (uint32_t )data; + +E1000_WRITE_ICH8_REG (hw,ICH8_FLASH_FDATA0 , flash_data); + +/* check if FCERR is set to 1 , if set to 1, clear it and try the whole +* sequence a few more times else done */ + error =e1000_ich8_flash_cycle (hw,ICH8_FLASH_COMMAND_TIMEOUT ); +if (error ==E1000_SUCCESS ) { +break ; + }else { +/* If we're here, then things are most likely completely hosed, +* but if the error condition is detected, it won't hurt to give +* it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. +*/ + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); +if (hsfsts.hsf_status.flcerr ==1 ) { +/* Repeat for some time before giving up. */ +continue ; + }else if (hsfsts.hsf_status.flcdone ==0 ) { +DEBUGOUT ("Timeout error - flash cycle did not complete." ); +break ; + } + } + }while (count++ <ICH8_FLASH_CYCLE_REPEAT_COUNT ); + +return error; +} + +/****************************************************************************** +* Reads a single byte from the NVM using the ICH8 flash access registers. +* +* hw - pointer to e1000_hw structure +* index - The index of the byte to read. +* data - Pointer to a byte to store the value read. +*****************************************************************************/ +int32_t +e1000_read_ich8_byte (struct e1000_hw *hw,uint32_t index,uint8_t * data) +{ +int32_t status =E1000_SUCCESS ; +uint16_t word =0 ; + + status =e1000_read_ich8_data (hw, index,1 , &word); +if (status ==E1000_SUCCESS ) { + *data = (uint8_t )word; + } + +return status; +} + +/****************************************************************************** +* Writes a single byte to the NVM using the ICH8 flash access registers. +* Performs verification by reading back the value and then going through +* a retry algorithm before giving up. +* +* hw - pointer to e1000_hw structure +* index - The index of the byte to write. +* byte - The byte to write to the NVM. +*****************************************************************************/ +int32_t +e1000_verify_write_ich8_byte (struct e1000_hw *hw,uint32_t index,uint8_t byte) +{ +int32_t error =E1000_SUCCESS ; +int32_t program_retries; +uint8_t temp_byte; + +e1000_write_ich8_byte (hw, index, byte); +udelay (100 ); + +for (program_retries =0 ; program_retries <100 ; program_retries++) { +e1000_read_ich8_byte (hw, index, &temp_byte); +if (temp_byte == byte) +break ; +udelay (10 ); +e1000_write_ich8_byte (hw, index, byte); +udelay (100 ); + } +if (program_retries ==100 ) + error =E1000_ERR_EEPROM ; + +return error; +} + +/****************************************************************************** +* Writes a single byte to the NVM using the ICH8 flash access registers. +* +* hw - pointer to e1000_hw structure +* index - The index of the byte to read. +* data - The byte to write to the NVM. +*****************************************************************************/ +int32_t +e1000_write_ich8_byte (struct e1000_hw *hw,uint32_t index,uint8_t data) +{ +int32_t status =E1000_SUCCESS ; +uint16_t word = (uint16_t )data; + + status =e1000_write_ich8_data (hw, index,1 , word); + +return status; +} + +/****************************************************************************** +* Reads a word from the NVM using the ICH8 flash access registers. +* +* hw - pointer to e1000_hw structure +* index - The starting byte index of the word to read. +* data - Pointer to a word to store the value read. +*****************************************************************************/ +int32_t +e1000_read_ich8_word (struct e1000_hw *hw,uint32_t index,uint16_t *data) +{ +int32_t status =E1000_SUCCESS ; + status =e1000_read_ich8_data (hw, index,2 , data); +return status; +} + +/****************************************************************************** +* Writes a word to the NVM using the ICH8 flash access registers. +* +* hw - pointer to e1000_hw structure +* index - The starting byte index of the word to read. +* data - The word to write to the NVM. +*****************************************************************************/ +int32_t +e1000_write_ich8_word (struct e1000_hw *hw,uint32_t index,uint16_t data) +{ +int32_t status =E1000_SUCCESS ; + status =e1000_write_ich8_data (hw, index,2 , data); +return status; +} + +/****************************************************************************** +* Erases the bank specified. Each bank is a 4k block. Segments are 0 based. +* segment N is 4096 * N + flash_reg_addr. +* +* hw - pointer to e1000_hw structure +* segment - 0 for first segment, 1 for second segment, etc. +*****************************************************************************/ +int32_t +e1000_erase_ich8_4k_segment (struct e1000_hw *hw,uint32_t segment) +{ +union ich8_hws_flash_status hsfsts; +union ich8_hws_flash_ctrl hsflctl; +uint32_t flash_linear_address; +int32_t count =0 ; +int32_t error =E1000_ERR_EEPROM ; +int32_t iteration, seg_size; +int32_t sector_size; +int32_t j =0 ; +int32_t error_flag =0 ; + + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); + +/* Determine HW Sector size: Read BERASE bits of Hw flash Status register */ +/* 00: The Hw sector is 256 bytes, hence we need to erase 16 +* consecutive sectors. The start index for the nth Hw sector can be +* calculated as = segment * 4096 + n * 256 +* 01: The Hw sector is 4K bytes, hence we need to erase 1 sector. +* The start index for the nth Hw sector can be calculated +* as = segment * 4096 +* 10: Error condition +* 11: The Hw sector size is much bigger than the size asked to +* erase...error condition */ +if (hsfsts.hsf_status.berasesz ==0x0 ) { +/* Hw sector size 256 */ + sector_size = seg_size =ICH8_FLASH_SEG_SIZE_256 ; + iteration =ICH8_FLASH_SECTOR_SIZE /ICH8_FLASH_SEG_SIZE_256 ; + }else if (hsfsts.hsf_status.berasesz ==0x1 ) { + sector_size = seg_size =ICH8_FLASH_SEG_SIZE_4K ; + iteration =1 ; + }else if (hsfsts.hsf_status.berasesz ==0x3 ) { + sector_size = seg_size =ICH8_FLASH_SEG_SIZE_64K ; + iteration =1 ; + }else { +return error; + } + +for (j =0 ; j < iteration ; j++) { +do { + count++; +/* Steps */ + error =e1000_ich8_cycle_init (hw); +if (error !=E1000_SUCCESS ) { + error_flag =1 ; +break ; + } + +/* Write a value 11 (block Erase) in Flash Cycle field in Hw flash +* Control */ + hsflctl.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL ); + hsflctl.hsf_ctrl.flcycle =ICH8_CYCLE_ERASE ; +E1000_WRITE_ICH8_REG16 (hw,ICH8_FLASH_HSFCTL , hsflctl.regval); + +/* Write the last 24 bits of an index within the block into Flash +* Linear address field in Flash Address. This probably needs to +* be calculated here based off the on-chip segment size and the +* software segment size assumed (4K) */ +/* TBD */ + flash_linear_address = segment * sector_size + j * seg_size; + flash_linear_address &=ICH8_FLASH_LINEAR_ADDR_MASK ; + flash_linear_address += hw->flash_base_addr; + +E1000_WRITE_ICH8_REG (hw,ICH8_FLASH_FADDR , flash_linear_address); + + error =e1000_ich8_flash_cycle (hw,1000000 ); +/* Check if FCERR is set to 1. If 1, clear it and try the whole +* sequence a few more times else Done */ +if (error ==E1000_SUCCESS ) { +break ; + }else { + hsfsts.regval =E1000_READ_ICH8_REG16 (hw,ICH8_FLASH_HSFSTS ); +if (hsfsts.hsf_status.flcerr ==1 ) { +/* repeat for some time before giving up */ +continue ; + }else if (hsfsts.hsf_status.flcdone ==0 ) { + error_flag =1 ; +break ; + } + } + }while ((count <ICH8_FLASH_CYCLE_REPEAT_COUNT ) && !error_flag); +if (error_flag ==1 ) +break ; + } +if (error_flag !=1 ) + error =E1000_SUCCESS ; +return error; +} + +/****************************************************************************** +* +* Reverse duplex setting without breaking the link. +* +* hw: Struct containing variables accessed by shared code +* +*****************************************************************************/ +int32_t +e1000_duplex_reversal (struct e1000_hw *hw) +{ +int32_t ret_val; +uint16_t phy_data; + +if (hw->phy_type != e1000_phy_igp_3) +return E1000_SUCCESS ; + + ret_val =e1000_read_phy_reg (hw,PHY_CTRL , &phy_data); +if (ret_val) +return ret_val; + + phy_data ^=MII_CR_FULL_DUPLEX ; + + ret_val =e1000_write_phy_reg (hw,PHY_CTRL , phy_data); +if (ret_val) +return ret_val; + + ret_val =e1000_read_phy_reg (hw,IGP3E1000_PHY_MISC_CTRL , &phy_data); +if (ret_val) +return ret_val; + + phy_data |=IGP3_PHY_MISC_DUPLEX_MANUAL_SET ; + ret_val =e1000_write_phy_reg (hw,IGP3E1000_PHY_MISC_CTRL , phy_data); + +return ret_val; +} + +int32_t +e1000_init_lcd_from_nvm_config_region (struct e1000_hw *hw, +uint32_t cnf_base_addr,uint32_t cnf_size) +{ +uint32_t ret_val =E1000_SUCCESS ; +uint16_t word_addr, reg_data, reg_addr; +uint16_t i; + +/* cnf_base_addr is in DWORD */ + word_addr = (uint16_t )(cnf_base_addr <<1 ); + +/* cnf_size is returned in size of dwords */ +for (i =0 ; i < cnf_size; i++) { + ret_val =e1000_read_eeprom (hw, (word_addr + i*2 ),1 , ®_data); +if (ret_val) +return ret_val; + + ret_val =e1000_read_eeprom (hw, (word_addr + i*2 +1 ),1 , ®_addr); +if (ret_val) +return ret_val; + + ret_val =e1000_get_software_flag (hw); +if (ret_val !=E1000_SUCCESS ) +return ret_val; + + ret_val =e1000_write_phy_reg_ex (hw, (uint32_t )reg_addr, reg_data); + +e1000_release_software_flag (hw); + } + +return ret_val; +} + + +int32_t +e1000_init_lcd_from_nvm (struct e1000_hw *hw) +{ +uint32_t reg_data, cnf_base_addr, cnf_size, ret_val, loop; + +if (hw->phy_type != e1000_phy_igp_3) +return E1000_SUCCESS ; + +/* Check if SW needs configure the PHY */ + reg_data =E1000_READ_REG (hw,FEXTNVM ); +if (!(reg_data &FEXTNVM_SW_CONFIG )) +return E1000_SUCCESS ; + +/* Wait for basic configuration completes before proceeding*/ + loop =0 ; +do { + reg_data =E1000_READ_REG (hw,STATUS ) &E1000_STATUS_LAN_INIT_DONE ; +udelay (100 ); + loop++; + }while ((!reg_data) && (loop <50 )); + +/* Clear the Init Done bit for the next init event */ + reg_data =E1000_READ_REG (hw,STATUS ); + reg_data &= ~E1000_STATUS_LAN_INIT_DONE ; +E1000_WRITE_REG (hw,STATUS , reg_data); + +/* Make sure HW does not configure LCD from PHY extended configuration +before SW configuration */ + reg_data =E1000_READ_REG (hw,EXTCNF_CTRL ); +if ((reg_data &E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE ) ==0x0000 ) { + reg_data =E1000_READ_REG (hw,EXTCNF_SIZE ); + cnf_size = reg_data &E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH ; + cnf_size >>=16 ; +if (cnf_size) { + reg_data =E1000_READ_REG (hw,EXTCNF_CTRL ); + cnf_base_addr = reg_data &E1000_EXTCNF_CTRL_EXT_CNF_POINTER ; +/* cnf_base_addr is in DWORD */ + cnf_base_addr >>=16 ; + +/* Configure LCD from extended configuration region. */ + ret_val =e1000_init_lcd_from_nvm_config_region (hw, cnf_base_addr, + cnf_size); +if (ret_val) +return ret_val; + } + } + +return E1000_SUCCESS ; +} + +
drivers/net/e1000/e1000_hw.h +380 -6
695 lines not on this page · raw message
drivers/net/e1000/e1000_osdep.h +13 -0
@@ -130,4 +130,17 @@ typedef enum {#define E1000_WRITE_FLUSH (a) E1000_READ_REG(a, STATUS) +#define E1000_WRITE_ICH8_REG (a, reg, value) ( \ + writel((value), ((a)->flash_address + reg))) + +#define E1000_READ_ICH8_REG (a, reg) ( \ + readl((a)->flash_address + reg)) + +#define E1000_WRITE_ICH8_REG16 (a, reg, value) ( \ + writew((value), ((a)->flash_address + reg))) + +#define E1000_READ_ICH8_REG16 (a, reg) ( \ + readw((a)->flash_address + reg)) + +#endif /* _E1000_OSDEP_H_ */
--
Auke Kok <[email protected]>
Re: [PATCH 17/21] e1000: add ich8lan core functions
Quoted 10 lines · Auke
This implements the core new functions needed for ich8's internal NIC. This includes:
* ich8 specific read/write code
* flash/nvm access code
* software semaphore flag functions
* 10/100 PHY (fe - no gigabit speed) support for low-end versions
* A workaround for a powerdown sequence problem discovered that affects a small number of motherboard.
Quoted 8 lines
Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
drivers/net/e1000/e1000_hw.c | 1000 +++++++++++++++++++++++++++++++++++++++ drivers/net/e1000/e1000_hw.h | 386 +++++++++++++++ drivers/net/e1000/e1000_osdep.h | 13 + 3 files changed, 1392 insertions(+), 7 deletions(-)
If it takes this much code to support ICH8, it seems like a e1000-ich8.c would be warranted...
Jeff
Re: [PATCH 17/21] e1000: add ich8lan core functions
Quoted 15 lines · Jeff Garzik
Quoted 14 lines · Auke
This implements the core new functions needed for ich8's internal NIC. This includes:
* ich8 specific read/write code
* flash/nvm access code
* software semaphore flag functions
* 10/100 PHY (fe - no gigabit speed) support for low-end versions
* A workaround for a powerdown sequence problem discovered that affects a small number of motherboard.Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Auke Kok <[email protected]>---
Quoted 7 lines
Quoted 5 lines
drivers/net/e1000/e1000_hw.c | 1000 +++++++++++++++++++++++++++++++++++++++ drivers/net/e1000/e1000_hw.h | 386 +++++++++++++++ drivers/net/e1000/e1000_osdep.h | 13 + 3 files changed, 1392 insertions(+), 7 deletions(-)If it takes this much code to support ICH8, it seems like a
e1000-ich8.cwould be warranted...
that's work in progress - Jeb Cramer has been working on this for a while now but unfortunately it's not ready, and getting ich8 supported in a way that we know that doesn't introduce new bugs is more important. This patch adds tested and validated support for these chipsets that has been hammered by our test team.
We are planning (working) on cleaning it all up (including whitespace!) - but getting the ich8 support out is more important - people can buy the hardware today.
Cheers,
Auke
PATCH 18/21 e1000: integrate ich8 support into driver
In reply to Kok, AukeThis hooks up the ich8 structure into the driver itself.
---
drivers/net/e1000/e1000.h | 1 drivers/net/e1000/e1000_ethtool.c | 80 +++-- drivers/net/e1000/e1000_hw.c | 654 ++++++++++++++++++++++++++++++++----- drivers/net/e1000/e1000_main.c | 118 ++++++- 4 files changed, 724 insertions(+), 129 deletions(-)
drivers/net/e1000/e1000.h +1 -0
@@ -143,6 +143,7 @@ struct e1000_adapter;#define AUTO_ALL_MODES 0#define E1000_EEPROM_82544_APM 0x0004 +#define E1000_EEPROM_ICH8_APME 0x0004#define E1000_EEPROM_APME 0x0400#ifndef E1000_MASTER_SLAVE
drivers/net/e1000/e1000_ethtool.c +58 -22
149 lines not on this page · raw message
drivers/net/e1000/e1000_hw.c +562 -92
1,325 lines not on this page · raw message
drivers/net/e1000/e1000_main.c +103 -15
355 lines not on this page · raw message
--
Auke Kok <[email protected]>
Re: [PATCH 18/21] e1000: integrate ich8 support into driver
Quoted 23 lines · Auke
drivers/net/e1000/e1000_hw.c +19
-0@@ -4225,6 +4396,35 @@ e1000_init_eeprom_params(struct e1000_hw eeprom->use_eerd = TRUE; eeprom->use_eewr = FALSE;break ; +case e1000_ich8lan: + { +int32_t i =0 ; +uint32_t flash_size =E1000_READ_ICH8_REG (hw,ICH8_FLASH_GFPREG ); + + eeprom->type = e1000_eeprom_ich8; + eeprom->use_eerd = FALSE; + eeprom->use_eewr = FALSE; + eeprom->word_size =E1000_SHADOW_RAM_WORDS ; + +/* Zero the shadow RAM structure. But don't load it from NVM +* so as to save time for driver init */ +if (hw->eeprom_shadow_ram !=NULL ) { +for (i =0 ; i <E1000_SHADOW_RAM_WORDS ; i++) { + hw->eeprom_shadow_ram[i].modified = FALSE; + hw->eeprom_shadow_ram[i].eeprom_word =0xFFFF ; + } + } +
drivers/net/e1000/e1000_hw.c e1000_init_eeprom_params(struct e1000_hw · line 4427
Quoted 10 lines
drivers/net/e1000/e1000_hw.c +10
-0+ hw->flash_base_addr = (flash_size &ICH8_GFPREG_BASE_MASK ) * +ICH8_FLASH_SECTOR_SIZE ; + + hw->flash_bank_size = ((flash_size >>16 ) &ICH8_GFPREG_BASE_MASK ) +1 ; + hw->flash_bank_size -= (flash_size &ICH8_GFPREG_BASE_MASK ); + hw->flash_bank_size *=ICH8_FLASH_SECTOR_SIZE ; + hw->flash_bank_size /=2 *sizeof (uint16_t ); + +break ; + }
seems to warrant a separate function, called from this callsite (perhaps stored in e1000-ich8.c?)
Quoted 197 lines
drivers/net/e1000/e1000_hw.c +135
-7@@ -4645,7 +4845,10 @@ e1000_read_eeprom(struct e1000_hw *hw,return ret_val; } -if (eeprom->type == e1000_eeprom_spi) { +if (eeprom->type == e1000_eeprom_ich8) +return e1000_read_eeprom_ich8 (hw, offset, words, data); + +if (eeprom->type == e1000_eeprom_spi) {uint16_t word_in;uint8_t read_opcode =EEPROM_READ_OPCODE_SPI ;@@ -4812,7 +5015,10 @@ e1000_is_onboard_nvm_eeprom(struct e1000DEBUGFUNC ("e1000_is_onboard_nvm_eeprom" ); -if (hw->mac_type == e1000_82573) { +if (hw->mac_type == e1000_ich8lan) +return FALSE; + +if (hw->mac_type == e1000_82573) { eecd =E1000_READ_REG (hw,EECD );/* Isolate bits 15 & 16 */ @@ -4862,8 +5068,22 @@ e1000_validate_eeprom_checksum(struct e1 } } -for (i =0 ; i < (EEPROM_CHECKSUM_REG +1 ); i++) { -if (e1000_read_eeprom (hw, i,1 , &eeprom_data) <0 ) { +if (hw->mac_type == e1000_ich8lan) { +/* Drivers must allocate the shadow ram structure for the +* EEPROM checksum to be updated. Otherwise, this bit as well +* as the checksum must both be set correctly for this +* validation to pass. +*/ +e1000_read_eeprom (hw,0x19 ,1 , &eeprom_data); +if ((eeprom_data &0x40 ) ==0 ) { + eeprom_data |=0x40 ; +e1000_write_eeprom (hw,0x19 ,1 , &eeprom_data); +e1000_update_eeprom_checksum (hw); + } + } + +for (i =0 ; i < (EEPROM_CHECKSUM_REG +1 ); i++) { +if (e1000_read_eeprom (hw, i,1 , &eeprom_data) <0 ) {DEBUGOUT ("EEPROM Read Error\n" );return -E1000_ERR_EEPROM ; }@@ -4889,6 +5109,7 @@ e1000_validate_eeprom_checksum(struct e1int32_t e1000_update_eeprom_checksum (struct e1000_hw *hw) { +uint32_t ctrl_ext;uint16_t checksum =0 ;uint16_t i, eeprom_data;@@ -4907,6 +5128,14 @@ e1000_update_eeprom_checksum(struct e100return -E1000_ERR_EEPROM ; }else if (hw->eeprom.type == e1000_eeprom_flash) {e1000_commit_shadow_ram (hw); + }else if (hw->eeprom.type == e1000_eeprom_ich8) { +e1000_commit_shadow_ram (hw); +/* Reload the EEPROM, or else modifications will not appear +* until after next adapter reset. */ + ctrl_ext =E1000_READ_REG (hw,CTRL_EXT ); + ctrl_ext |=E1000_CTRL_EXT_EE_RST ; +E1000_WRITE_REG (hw,CTRL_EXT , ctrl_ext); +msec_delay (10 ); }return E1000_SUCCESS ; }@@ -4946,6 +5175,9 @@ e1000_write_eeprom(struct e1000_hw *hw,if (eeprom->use_eewr == TRUE)return e1000_write_eeprom_eewr (hw, offset, words, data); +if (eeprom->type == e1000_eeprom_ich8) +return e1000_write_eeprom_ich8 (hw, offset, words, data); +/* Prepare the EEPROM for writing */ if (e1000_acquire_eeprom (hw) !=E1000_SUCCESS )return -E1000_ERR_EEPROM ;@@ -5133,11 +5365,17 @@ e1000_commit_shadow_ram(struct e1000_hwuint32_t flop =0 ;uint32_t i =0 ;int32_t error =E1000_SUCCESS ; - -/* The flop register will be used to determine if flash type is STM */ - flop =E1000_READ_REG (hw,FLOP ); +uint32_t old_bank_offset =0 ; +uint32_t new_bank_offset =0 ; +uint32_t sector_retries =0 ; +uint8_t low_byte =0 ; +uint8_t high_byte =0 ; +uint8_t temp_byte =0 ; +boolean_t sector_write_failed = FALSE;if (hw->mac_type == e1000_82573) { +/* The flop register will be used to determine if flash type is STM */ + flop =E1000_READ_REG (hw,FLOP );for (i=0 ; i < attempts; i++) { eecd =E1000_READ_REG (hw,EECD );if ((eecd &E1000_EECD_FLUPD ) ==0 ) {@@ -5171,6 +5409,106 @@ e1000_commit_shadow_ram(struct e1000_hw } } +if (hw->mac_type == e1000_ich8lan && hw->eeprom_shadow_ram !=NULL ) { +/* We're writing to the opposite bank so if we're on bank 1, +* write to bank 0 etc. We also need to erase the segment that +* is going to be written */ +if (!(E1000_READ_REG (hw,EECD ) &E1000_EECD_SEC1VAL )) { + new_bank_offset = hw->flash_bank_size *2 ; + old_bank_offset =0 ; +e1000_erase_ich8_4k_segment (hw,1 ); + }else { + old_bank_offset = hw->flash_bank_size *2 ; + new_bank_offset =0 ; +e1000_erase_ich8_4k_segment (hw,0 ); + } + + do { + sector_write_failed = FALSE; + /* Loop for every byte in the shadow RAM, + * which is in units of words. */ + for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) { + /* Determine whether to write the value stored + * in the other NVM bank or a modified value stored + * in the shadow RAM */ + if (hw->eeprom_shadow_ram[i].modified == TRUE) { + low_byte = (uint8_t)hw->eeprom_shadow_ram[i].eeprom_word; + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset, + &temp_byte); + udelay(100); + error = e1000_verify_write_ich8_byte(hw, + (i << 1) + new_bank_offset, + low_byte); + if (error != E1000_SUCCESS) + sector_write_failed = TRUE; + high_byte = + (uint8_t)(hw->eeprom_shadow_ram[i].eeprom_word >> 8); + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1, + &temp_byte); + udelay(100); + } else { + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset, + &low_byte); + udelay(100); + error = e1000_verify_write_ich8_byte(hw, + (i << 1) + new_bank_offset, low_byte); + if (error != E1000_SUCCESS) + sector_write_failed = TRUE; + e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1, + &high_byte); + } + + /* If the word is 0x13, then make sure the signature bits + * (15:14) are 11b until the commit has completed. + * This will allow us to write 10b which indicates the + * signature is valid. We want to do this after the write + * has completed so that we don't mark the segment valid + * while the write is still in progress */ + if (i == E1000_ICH8_NVM_SIG_WORD) + high_byte = E1000_ICH8_NVM_SIG_MASK | high_byte; + + error = e1000_verify_write_ich8_byte(hw, + (i << 1) + new_bank_offset + 1, high_byte); + if (error != E1000_SUCCESS) + sector_write_failed = TRUE; + + if (sector_write_failed == FALSE) { + /* Clear the now not used entry in the cache */ + hw->eeprom_shadow_ram[i].modified = FALSE; + hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF; + } + } + + /* Don't bother writing the segment valid bits if sector + * programming failed. */ + if (sector_write_failed == FALSE) { + /* Finally validate the new segment by setting bit 15:14 + * to 10b in word 0x13 , this can be done without an + * erase as well since these bits are 11 to start with + * and we need to change bit 14 to 0b */ + e1000_read_ich8_byte(hw, + E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, + &high_byte); + high_byte &= 0xBF; + error = e1000_verify_write_ich8_byte(hw, + E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, + high_byte); + if (error != E1000_SUCCESS) + sector_write_failed = TRUE; + + /* And invalidate the previously valid segment by setting + * its signature word (0x13) high_byte to 0b. This can be + * done without an erase because flash erase sets all bits
drivers/net/e1000/e1000_hw.c e1000_commit_shadow_ram(struct e1000_hw · line 5511
Quoted 10 lines
drivers/net/e1000/e1000_hw.c +10
-0+* to 1's. We can write 1's to 0's without an erase */ + error =e1000_verify_write_ich8_byte (hw, +E1000_ICH8_NVM_SIG_WORD *2 +1 + old_bank_offset, +0 ); +if (error !=E1000_SUCCESS ) + sector_write_failed = TRUE; + } + }while (++sector_retries <10 && sector_write_failed == TRUE); + } +
obviously warrants a separate function for new ich8 code...
PATCH 19/21 e1000: allow user to disable ich8 lock loss workaround
In reply to Kok, AukeThe workaround for the ich8 lock loss problem is only needed for a very small amount of systems. This adds an option for the user to disable the workaround.
---
drivers/net/e1000/e1000_param.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
drivers/net/e1000/e1000_param.c +21 -0
@@ -202,6 +202,15 @@ E1000_PARAM(InterruptThrottleRate, "InteE1000_PARAM (SmartPowerDownEnable,"Enable PHY smart power down" ); +/* Enable Kumeran Lock Loss workaround +* +* Valid Range: 0, 1 +* +* Default Value: 1 (enabled) +*/ + +E1000_PARAM (KumeranLockLoss,"Enable Kumeran lock loss workaround" ); +#define AUTONEG_ADV_DEFAULT 0x2F#define AUTONEG_ADV_MASK 0x2F#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
@@ -484,6 +493,18 @@ e1000_check_options(struct e1000_adaptere1000_validate_option (&spd, &opt, adapter); adapter->smart_power_down = spd; } + {/* Kumeran Lock Loss Workaround */ +struct e1000_option opt = { + .type = enable_option, + .name ="Kumeran Lock Loss Workaround" , + .err ="defaulting to Enabled" , + .def =OPTION_ENABLED + }; + +int kmrn_lock_loss = KumeranLockLoss[bd]; +e1000_validate_option (&kmrn_lock_loss, &opt, adapter); + adapter->hw.kmrn_lock_loss_workaround_disabled = !kmrn_lock_loss; + }switch (adapter->hw.media_type) {case e1000_media_type_fiber:
--
Auke Kok <[email protected]>
Re: [PATCH 19/21] e1000: allow user to disable ich8 lock loss workaround
Quoted 3 lines · Auke
The workaround for the ich8 lock loss problem is only needed for a very small amount of systems. This adds an option for the user to disable the workaround.
Does "very small amount" equate to "never in real production machines"?
Re: [PATCH 19/21] e1000: allow user to disable ich8 lock loss workaround
Quoted 6 lines · Jeff Garzik
Quoted 3 lines · Auke
The workaround for the ich8 lock loss problem is only needed for a very small amount of systems. This adds an option for the user to disable the workaround.
Does "very small amount" equate to "never in real production machines"?
Unfortunately not.
Cheers,
Auke
PATCH 20/21 e1000: add ich8lan device ID's
In reply to Kok, AukeAdd the device ID's of the supported ICH8 LAN devices.
---
drivers/net/e1000/e1000_main.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/e1000/e1000_main.c +7 -0
@@ -73,6 +73,11 @@ static struct pci_device_id e1000_pci_tbINTEL_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),
@@ -96,6 +101,8 @@ static struct pci_device_id e1000_pci_tbINTEL_E1000_ETHERNET_DEVICE (0x109A ),INTEL_E1000_ETHERNET_DEVICE (0x10B5 ),INTEL_E1000_ETHERNET_DEVICE (0x10B9 ), +INTEL_E1000_ETHERNET_DEVICE (0x10BA ), +INTEL_E1000_ETHERNET_DEVICE (0x10BB ),/* required last entry */ {0,} };
--
Auke Kok <[email protected]>
PATCH 21/21 e1000: increase version to 7.1.9-k2
In reply to Kok, AukeIncrement the version to 7.1.9-k2
---
drivers/net/e1000/e1000_main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/e1000/e1000_main.c +1 -1
@@ -36,7 +36,7 @@ static char e1000_driver_string[] = "Int#else #define DRIVERNAPI "-NAPI"#endif -#define DRV_VERSION "7.0.38-k4"DRIVERNAPI +#define DRV_VERSION "7.1.9-k2"DRIVERNAPIchar e1000_driver_version[] =DRV_VERSION ;static char e1000_copyright[] ="Copyright (c) 1999-2006 Intel Corporation." ;
--
Auke Kok <[email protected]>
Jeff,
after comments I've made some adjustments. I'll list them below against the old summary. The changes are available from our git-server:
Please pull from:
git://lost.foo-projects.org/~ahkok/git/netdev-2.6 upstream
These patches are against
netdev-2.6#upstream 612eff0e3715a6faff5ba1b74873b99e036c59fe
(Brian Haley <[email protected]> / [PATCH] s2io: netpoll support)
Quoted 12 lines
Summary of patches:
[01]: fix loopback ethtool test
[02]: rework driver hardware reset locking
[03]: Make PHY powerup/down a function
[04]: fixCONFIG_PMblocks
[05]: small performance tweak by removing double code [06]: add smart power down code
[07]: change printk into DPRINTK
[08]: recycle skb
[09]: rework module param code with uninitialized values [10]: force register write flushes to circumvent broken platforms
Unmodified. See comments here:
http://marc.theaimsgroup.com/?l=linux-netdev&m=115142459725123&w=2 [1]
Quoted 1 line
[11]: disable CRC stripping workaround
Removed all references to SECRC (crc stripping) instead of leaving it commented.
Quoted 2 lines
[12]: fix adapter led blinking inconsistency
[13]: addE1000_BIG_ENDIANsymbol
Dropped this patch entirely
Quoted 8 lines
[14]: M88 PHY workaround
[15]: check return value of_get_speed_and_duplex[16]: disable ERT
[17]: add ich8lan core functions
[18]: integrate ich8 support into driver [19]: allow user to disable ich8 lock loss workaround [20]: add ich8lan device ID's
[21]: increase version to 7.1.9-k2
[1] I can drop #11 in case someone throws a fit ;) - as everyone I'd really like to see patches 17->20 queued for 2.6.18 for obvious reasons - this is the most important section of these patches!
Cheers,
Auke
--- drivers/net/e1000/e1000.h | 10 drivers/net/e1000/e1000_ethtool.c | 143 +-- drivers/net/e1000/e1000_hw.c | 1770 +++++++++++++++++++++++++++++++++++--- drivers/net/e1000/e1000_hw.h | 398 ++++++++ drivers/net/e1000/e1000_main.c | 384 +++++--- drivers/net/e1000/e1000_osdep.h | 13 drivers/net/e1000/e1000_param.c | 213 ++-- 7 files changed, 2530 insertions(+), 401 deletions(-)