igb: remove unused temp variable from stats clearing path
Subsystems (2)
PATCH 1/15 igb: remove unused temp variable from stats clearing path
From: Alexander Duyck <[email protected]>
There is a temp variable in the stats clearing path that isn't needed since the results from the stats read can be immediately discared. Since it isn't needed we might as well just drop it from the function call.
---
drivers/net/igb/e1000_82575.c | 96 ++++++++++++++++++++--------------------- drivers/net/igb/e1000_mac.c | 76 ++++++++++++++++---------------- 2 files changed, 84 insertions(+), 88 deletions(-)
drivers/net/igb/e1000_82575.c +47 -49
@@ -1181,61 +1181,59 @@ static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)**/ static void igb_clear_hw_cntrs_82575 (struct e1000_hw *hw) { -u32 temp; -igb_clear_hw_cntrs_base (hw); - temp =rd32 (E1000_PRC64 ); - temp =rd32 (E1000_PRC127 ); - temp =rd32 (E1000_PRC255 ); - temp =rd32 (E1000_PRC511 ); - temp =rd32 (E1000_PRC1023 ); - temp =rd32 (E1000_PRC1522 ); - temp =rd32 (E1000_PTC64 ); - temp =rd32 (E1000_PTC127 ); - temp =rd32 (E1000_PTC255 ); - temp =rd32 (E1000_PTC511 ); - temp =rd32 (E1000_PTC1023 ); - temp =rd32 (E1000_PTC1522 ); - - temp =rd32 (E1000_ALGNERRC ); - temp =rd32 (E1000_RXERRC ); - temp =rd32 (E1000_TNCRS ); - temp =rd32 (E1000_CEXTERR ); - temp =rd32 (E1000_TSCTC ); - temp =rd32 (E1000_TSCTFC ); - - temp =rd32 (E1000_MGTPRC ); - temp =rd32 (E1000_MGTPDC ); - temp =rd32 (E1000_MGTPTC ); - - temp =rd32 (E1000_IAC ); - temp =rd32 (E1000_ICRXOC ); - - temp =rd32 (E1000_ICRXPTC ); - temp =rd32 (E1000_ICRXATC ); - temp =rd32 (E1000_ICTXPTC ); - temp =rd32 (E1000_ICTXATC ); - temp =rd32 (E1000_ICTXQEC ); - temp =rd32 (E1000_ICTXQMTC ); - temp =rd32 (E1000_ICRXDMTC ); - - temp =rd32 (E1000_CBTMPC ); - temp =rd32 (E1000_HTDPMC ); - temp =rd32 (E1000_CBRMPC ); - temp =rd32 (E1000_RPTHC ); - temp =rd32 (E1000_HGPTC ); - temp =rd32 (E1000_HTCBDPC ); - temp =rd32 (E1000_HGORCL ); - temp =rd32 (E1000_HGORCH ); - temp =rd32 (E1000_HGOTCL ); - temp =rd32 (E1000_HGOTCH ); - temp =rd32 (E1000_LENERRS ); +rd32 (E1000_PRC64 ); +rd32 (E1000_PRC127 ); +rd32 (E1000_PRC255 ); +rd32 (E1000_PRC511 ); +rd32 (E1000_PRC1023 ); +rd32 (E1000_PRC1522 ); +rd32 (E1000_PTC64 ); +rd32 (E1000_PTC127 ); +rd32 (E1000_PTC255 ); +rd32 (E1000_PTC511 ); +rd32 (E1000_PTC1023 ); +rd32 (E1000_PTC1522 ); + +rd32 (E1000_ALGNERRC ); +rd32 (E1000_RXERRC ); +rd32 (E1000_TNCRS ); +rd32 (E1000_CEXTERR ); +rd32 (E1000_TSCTC ); +rd32 (E1000_TSCTFC ); + +rd32 (E1000_MGTPRC ); +rd32 (E1000_MGTPDC ); +rd32 (E1000_MGTPTC ); + +rd32 (E1000_IAC ); +rd32 (E1000_ICRXOC ); + +rd32 (E1000_ICRXPTC ); +rd32 (E1000_ICRXATC ); +rd32 (E1000_ICTXPTC ); +rd32 (E1000_ICTXATC ); +rd32 (E1000_ICTXQEC ); +rd32 (E1000_ICTXQMTC ); +rd32 (E1000_ICRXDMTC ); + +rd32 (E1000_CBTMPC ); +rd32 (E1000_HTDPMC ); +rd32 (E1000_CBRMPC ); +rd32 (E1000_RPTHC ); +rd32 (E1000_HGPTC ); +rd32 (E1000_HTCBDPC ); +rd32 (E1000_HGORCL ); +rd32 (E1000_HGORCH ); +rd32 (E1000_HGOTCL ); +rd32 (E1000_HGOTCH ); +rd32 (E1000_LENERRS );/* This register should not be read in copper configurations */ if (hw->phy.media_type == e1000_media_type_internal_serdes ||igb_sgmii_active_82575 (hw)) - temp =rd32 (E1000_SCVPC ); +rd32 (E1000_SCVPC ); }/**
drivers/net/igb/e1000_mac.c +37 -39
82 lines not on this page · raw message
PATCH 2/15 igb: update comments for serdes config and update to handle duplex
From: Alexander Duyck <[email protected]>
This update corrects the driver so that it handles duplex for serdes links correctly instead of just forcing full duplex always.
---
drivers/net/igb/e1000_82575.c | 55 ++++++++++++++++++++++++++++------------- drivers/net/igb/e1000_82575.h | 1 + drivers/net/igb/e1000_hw.h | 1 + 3 files changed, 40 insertions(+), 17 deletions(-)
drivers/net/igb/e1000_82575.c +38 -17
@@ -706,9 +706,7 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)s32 ret_val;u16 speed, duplex; -/* SGMII link check is done through the PCS register. */ -if ((hw->phy.media_type != e1000_media_type_copper) || - (igb_sgmii_active_82575 (hw))) { +if (hw->phy.media_type != e1000_media_type_copper) { ret_val =igb_get_pcs_speed_and_duplex_82575 (hw, &speed, &duplex);/*
@@ -723,6 +721,7 @@ static s32 igb_check_for_link_82575(struct e1000_hw *hw)return ret_val; } +/** * igb_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex * @hw: pointer to the HW structure
@@ -788,13 +787,23 @@ static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed,void igb_shutdown_serdes_link_82575 (struct e1000_hw *hw) {u32 reg; +u16 eeprom_data =0 ;if (hw->phy.media_type != e1000_media_type_internal_serdes ||igb_sgmii_active_82575 (hw))return ; -/* if the management interface is not enabled, then power down */ -if (!igb_enable_mng_pass_thru (hw)) { +if (hw->bus.func ==E1000_FUNC_0 ) + hw->nvm.ops.read (hw,NVM_INIT_CONTROL3_PORT_A ,1 , &eeprom_data); +else if (hw->bus.func ==E1000_FUNC_1 ) + hw->nvm.ops.read (hw,NVM_INIT_CONTROL3_PORT_B ,1 , &eeprom_data); + +/* +* If APM is not enabled in the EEPROM and management interface is +* not enabled, then power down. +*/ +if (!(eeprom_data &E1000_NVM_APME_82575 ) && + !igb_enable_mng_pass_thru (hw)) {/* Disable PCS to turn off link */ reg =rd32 (E1000_PCS_CFG0 ); reg &= ~E1000_PCS_CFG_PCS_EN ;
@@ -1010,10 +1019,13 @@ out: }/** -* igb_setup_serdes_link_82575 - Setup link for fiber/serdes +* igb_setup_serdes_link_82575 - Setup link for serdes * @hw: pointer to the HW structure * -* Configures speed and duplex for fiber and serdes links. +* Configure the physical coding sub-layer (PCS) link. The PCS link is +* used on copper connections where the serialized gigabit media independent +* interface (sgmii), or serdes fiber is being used. Configures the link +* for auto-negotiation or forces speed/duplex. **/ static s32 igb_setup_serdes_link_82575 (struct e1000_hw *hw) {
@@ -1086,18 +1098,27 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)*/ if (hw->mac.autoneg ||igb_sgmii_active_82575 (hw)) {/* Set PCS register for autoneg */ - reg |=E1000_PCS_LCTL_FSV_1000 |/* Force 1000 */ -E1000_PCS_LCTL_FDV_FULL |/* SerDes Full duplex */ -E1000_PCS_LCTL_AN_ENABLE |/* Enable Autoneg */ -E1000_PCS_LCTL_AN_RESTART ;/* Restart autoneg */ + reg |=E1000_PCS_LCTL_FSV_1000 |/* Force 1000 */ +E1000_PCS_LCTL_FDV_FULL |/* SerDes Full dplx */ +E1000_PCS_LCTL_AN_ENABLE |/* Enable Autoneg */ +E1000_PCS_LCTL_AN_RESTART ;/* Restart autoneg */ hw_dbg ("Configuring Autoneg; PCS_LCTL = 0x%08X\n" , reg); }else { -/* Set PCS register for forced speed */ - reg |=E1000_PCS_LCTL_FLV_LINK_UP |/* Force link up */ -E1000_PCS_LCTL_FSV_1000 |/* Force 1000 */ -E1000_PCS_LCTL_FDV_FULL |/* SerDes Full duplex */ -E1000_PCS_LCTL_FSD |/* Force Speed */ -E1000_PCS_LCTL_FORCE_LINK ;/* Force Link */ +/* Check for duplex first */ +if (hw->mac.forced_speed_duplex &E1000_ALL_FULL_DUPLEX ) + reg |=E1000_PCS_LCTL_FDV_FULL ; + +/* No need to check for 1000/full since the spec states that +* it requires autoneg to be enabled */ +/* Now set speed */ +if (hw->mac.forced_speed_duplex &E1000_ALL_100_SPEED ) + reg |=E1000_PCS_LCTL_FSV_100 ; + +/* Force speed and force link */ + reg |=E1000_PCS_LCTL_FSD | +E1000_PCS_LCTL_FORCE_LINK | +E1000_PCS_LCTL_FLV_LINK_UP ; +hw_dbg ("Configuring Forced Link; PCS_LCTL = 0x%08X\n" , reg); }
drivers/net/igb/e1000_82575.h +1 -0
@@ -167,6 +167,7 @@ struct e1000_adv_tx_context_desc {#define E1000_DCA_TXCTRL_CPUID_SHIFT 24/* Tx CPUID now in the last byte */ #define E1000_DCA_RXCTRL_CPUID_SHIFT 24/* Rx CPUID now in the last byte */ +#define E1000_NVM_APME_82575 0x0400#define MAX_NUM_VFS 8#define E1000_DTXSWC_VMDQ_LOOPBACK_EN (1 << 31)/* global VF LB enable */
drivers/net/igb/e1000_hw.h +1 -0
@@ -50,6 +50,7 @@ struct e1000_hw;#define E1000_REVISION_2 2#define E1000_REVISION_4 4 +#define E1000_FUNC_0 0#define E1000_FUNC_1 1enum e1000_mac_type {
Re: [net-next-2.6 PATCH 02/15] igb: update comments for serdes config and update to handle duplex
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:31:47 -0700
Quoted 7 lines
From: Alexander Duyck <[email protected]>
This update corrects the driver so that it handles duplex for serdes links correctly instead of just forcing full duplex always.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 3/15 igb: update the approach taken to acquiring and releasing the phy lock
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
The current approach is just using a ?: type mechanism to set the phy locking bit. This if fine for now but limits us to only 2. Switch to a nested if statement for future compatiblity with more than 2 phys.
---
drivers/net/igb/e1000_82575.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/igb/e1000_82575.c +7 -4
@@ -240,9 +240,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)**/ static s32 igb_acquire_phy_82575 (struct e1000_hw *hw) { -u16 mask; +u16 mask =E1000_SWFW_PHY0_SM ; - mask = hw->bus.func ?E1000_SWFW_PHY1_SM :E1000_SWFW_PHY0_SM ; +if (hw->bus.func ==E1000_FUNC_1 ) + mask =E1000_SWFW_PHY1_SM ;return igb_acquire_swfw_sync_82575 (hw, mask); }
@@ -256,9 +257,11 @@ static s32 igb_acquire_phy_82575(struct e1000_hw *hw)**/ static void igb_release_phy_82575 (struct e1000_hw *hw) { -u16 mask; +u16 mask =E1000_SWFW_PHY0_SM ; + +if (hw->bus.func ==E1000_FUNC_1 ) + mask =E1000_SWFW_PHY1_SM ; - mask = hw->bus.func ?E1000_SWFW_PHY1_SM :E1000_SWFW_PHY0_SM ;igb_release_swfw_sync_82575 (hw, mask); }
Re: [net-next-2.6 PATCH 03/15] igb: update the approach taken to acquiring and releasing the phy lock
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:32:07 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
The current approach is just using a ?: type mechanism to set the phy locking bit. This if fine for now but limits us to only 2. Switch to a nested if statement for future compatiblity with more than 2 phys.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 4/15 igb: add locking to reads of the i2c interface
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
The current implementation of sgmii support isn't correctly locking the interfaces for reads/writes. This change pulls the read/write functionality out of 82575.c and moves it to phy.c. In addition it replaces the implementation in 82575.c with one that uses locking around the relocated i2c interface calls.
---
drivers/net/igb/e1000_82575.c | 85 ++++++++---------------------------- drivers/net/igb/e1000_phy.c | 97 +++++++++++++++++++++++++++++++++++++++++ drivers/net/igb/e1000_phy.h | 2 + 3 files changed, 119 insertions(+), 65 deletions(-)
drivers/net/igb/e1000_82575.c +20 -65
@@ -277,45 +277,23 @@ static void igb_release_phy_82575(struct e1000_hw *hw)static s32 igb_read_phy_reg_sgmii_82575 (struct e1000_hw *hw,u32 offset,u16 *data) { -struct e1000_phy_info *phy = &hw->phy; -u32 i, i2ccmd =0 ; +s32 ret_val = -E1000_ERR_PARAM ;if (offset >E1000_MAX_SGMII_PHY_REG_ADDR ) {hw_dbg ("PHY Address %u is out of range\n" , offset); -return -E1000_ERR_PARAM ; + goto out; } -/* -* Set up Op-code, Phy Address, and register address in the I2CCMD -* register. The MAC will take care of interfacing with the -* PHY to retrieve the desired data. -*/ - i2ccmd = ((offset <<E1000_I2CCMD_REG_ADDR_SHIFT ) | - (phy->addr <<E1000_I2CCMD_PHY_ADDR_SHIFT ) | - (E1000_I2CCMD_OPCODE_READ )); + ret_val = hw->phy.ops.acquire (hw); +if (ret_val) + goto out; -wr32 (E1000_I2CCMD , i2ccmd); + ret_val =igb_read_phy_reg_i2c (hw, offset, data); -/* Poll the ready bit to see if the I2C read completed */ -for (i =0 ; i <E1000_I2CCMD_PHY_TIMEOUT ; i++) { -udelay (50 ); - i2ccmd =rd32 (E1000_I2CCMD ); -if (i2ccmd &E1000_I2CCMD_READY ) -break ; - } -if (!(i2ccmd &E1000_I2CCMD_READY )) { -hw_dbg ("I2CCMD Read did not complete\n" ); -return -E1000_ERR_PHY ; - } -if (i2ccmd &E1000_I2CCMD_ERROR ) { -hw_dbg ("I2CCMD Error bit set\n" ); -return -E1000_ERR_PHY ; - } - -/* Need to byte-swap the 16-bit value. */ - *data = ((i2ccmd >>8 ) &0x00FF ) | ((i2ccmd <<8 ) &0xFF00 ); + hw->phy.ops.release (hw); -return 0 ; +out: +return ret_val; }/**
@@ -330,47 +308,24 @@ static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,static s32 igb_write_phy_reg_sgmii_82575 (struct e1000_hw *hw,u32 offset,u16 data) { -struct e1000_phy_info *phy = &hw->phy; -u32 i, i2ccmd =0 ; -u16 phy_data_swapped; +s32 ret_val = -E1000_ERR_PARAM ; +if (offset >E1000_MAX_SGMII_PHY_REG_ADDR ) {hw_dbg ("PHY Address %d is out of range\n" , offset); -return -E1000_ERR_PARAM ; + goto out; } -/* Swap the data bytes for the I2C interface */ - phy_data_swapped = ((data >>8 ) &0x00FF ) | ((data <<8 ) &0xFF00 ); + ret_val = hw->phy.ops.acquire (hw); +if (ret_val) + goto out; -/* -* Set up Op-code, Phy Address, and register address in the I2CCMD -* register. The MAC will take care of interfacing with the -* PHY to retrieve the desired data. -*/ - i2ccmd = ((offset <<E1000_I2CCMD_REG_ADDR_SHIFT ) | - (phy->addr <<E1000_I2CCMD_PHY_ADDR_SHIFT ) | -E1000_I2CCMD_OPCODE_WRITE | - phy_data_swapped); - -wr32 (E1000_I2CCMD , i2ccmd); - -/* Poll the ready bit to see if the I2C read completed */ -for (i =0 ; i <E1000_I2CCMD_PHY_TIMEOUT ; i++) { -udelay (50 ); - i2ccmd =rd32 (E1000_I2CCMD ); -if (i2ccmd &E1000_I2CCMD_READY ) -break ; - } -if (!(i2ccmd &E1000_I2CCMD_READY )) { -hw_dbg ("I2CCMD Write did not complete\n" ); -return -E1000_ERR_PHY ; - } -if (i2ccmd &E1000_I2CCMD_ERROR ) { -hw_dbg ("I2CCMD Error bit set\n" ); -return -E1000_ERR_PHY ; - } + ret_val =igb_write_phy_reg_i2c (hw, offset, data); -return 0 ; + hw->phy.ops.release (hw); + +out: +return ret_val; }/**
drivers/net/igb/e1000_phy.c +97 -0
103 lines not on this page · raw message
drivers/net/igb/e1000_phy.h +2 -0
@@ -61,6 +61,8 @@ s32 igb_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);s32 igb_phy_has_link (struct e1000_hw *hw,u32 iterations,u32 usec_interval,bool *success);s32 igb_phy_init_script_igp3 (struct e1000_hw *hw); +s32 igb_read_phy_reg_i2c (struct e1000_hw *hw,u32 offset,u16 *data); +s32 igb_write_phy_reg_i2c (struct e1000_hw *hw,u32 offset,u16 data);/* IGP01E1000 Specific Registers */ #define IGP01E1000_PHY_PORT_CONFIG 0x10/* Port Config */
Re: [net-next-2.6 PATCH 04/15] igb: add locking to reads of the i2c interface
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:32:27 -0700
Quoted 10 lines
From: Alexander Duyck <[email protected]>
The current implementation of sgmii support isn't correctly locking the interfaces for reads/writes. This change pulls the read/write functionality out of 82575.c and moves it to
phy.c. In addition it replaces the implementation in 82575.c with one that uses locking around the relocated i2c interface calls.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 5/15 igb: add combined function for setting rar and pool bits
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This patch adds igb_rar_qsel which sets the mac address and pool bits for a given mac address in the receive address register table.
---
drivers/net/igb/igb_main.c | 63 ++++++++++++++++++++++++++++---------------- 1 files changed, 40 insertions(+), 23 deletions(-)
drivers/net/igb/igb_main.c +40 -23
@@ -127,10 +127,10 @@ static void igb_vlan_rx_register(struct net_device *, struct vlan_group *);static void igb_vlan_rx_add_vid (struct net_device *,u16 );static void igb_vlan_rx_kill_vid (struct net_device *,u16 );static void igb_restore_vlan (struct igb_adapter *); +static void igb_rar_set_qsel (struct igb_adapter *,u8 *,u32 ,u8 );static void igb_ping_all_vfs (struct igb_adapter *);static void igb_msg_task (struct igb_adapter *);static int igb_rcv_msg_from_vf (struct igb_adapter *,u32 ); -static inline void igb_set_rah_pool (struct e1000_hw *,int ,int );static void igb_vmm_control (struct igb_adapter *);static int igb_set_vf_mac (struct igb_adapter *adapter,int ,unsigned char *);static void igb_restore_vf_multicasts (struct igb_adapter *adapter);
@@ -168,16 +168,6 @@ static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size,return 0 ; } -static inline void igb_set_rah_pool (struct e1000_hw *hw,int pool,int entry) -{ -u32 reg_data; - - reg_data =rd32 (E1000_RAH (entry)); - reg_data &= ~E1000_RAH_POOL_MASK ; - reg_data |=E1000_RAH_POOL_1 << pool;; -wr32 (E1000_RAH (entry), reg_data); -} -#ifdef CONFIG_PM static int igb_suspend (struct pci_dev *,pm_message_t );static int igb_resume (struct pci_dev *);
@@ -982,7 +972,6 @@ int igb_up(struct igb_adapter *adapter)igb_configure_msix (adapter);igb_vmm_control (adapter); -igb_set_rah_pool (hw, adapter->vfs_allocated_count,0 );igb_set_vmolr (hw, adapter->vfs_allocated_count);/* Clear any pending interrupts. */
@@ -1769,7 +1758,6 @@ static int igb_open(struct net_device *netdev)igb_configure (adapter);igb_vmm_control (adapter); -igb_set_rah_pool (hw, adapter->vfs_allocated_count,0 );igb_set_vmolr (hw, adapter->vfs_allocated_count); err =igb_request_irq (adapter);
@@ -2298,6 +2286,10 @@ static void igb_configure_rx(struct igb_adapter *adapter)/* Set the default pool for the PF's first queue */ igb_configure_vt_default_pool (adapter); +/* set the correct pool for the PF default MAC address in entry 0 */ +igb_rar_set_qsel (adapter, adapter->hw.mac.addr,0 , + adapter->vfs_allocated_count); +igb_rlpml_set (adapter);/* Enable Receives */
@@ -2521,8 +2513,9 @@ static int igb_set_mac(struct net_device *netdev, void *p)memcpy (netdev->dev_addr, addr->sa_data, netdev->addr_len);memcpy (hw->mac.addr, addr->sa_data, netdev->addr_len); -igb_rar_set (hw, hw->mac.addr,0 ); -igb_set_rah_pool (hw, adapter->vfs_allocated_count,0 ); +/* set the correct pool for the new PF MAC address in entry 0 */ +igb_rar_set_qsel (adapter, hw->mac.addr,0 , + adapter->vfs_allocated_count);return 0 ; }
@@ -2572,10 +2565,9 @@ static void igb_set_rx_mode(struct net_device *netdev)list_for_each_entry (ha, &netdev->uc.list, list) {if (!rar_entries)break ; -igb_rar_set (hw, ha->addr, rar_entries); -igb_set_rah_pool (hw, adapter->vfs_allocated_count, - rar_entries); - rar_entries--; +igb_rar_set_qsel (adapter, ha->addr, + rar_entries--, + adapter->vfs_allocated_count); } }/* write the addresses in reverse order to avoid write combining */
@@ -4142,8 +4134,7 @@ static inline void igb_vf_reset_msg(struct igb_adapter *adapter, u32 vf)igb_vf_reset_event (adapter, vf);/* set vf mac address */ -igb_rar_set (hw, vf_mac, rar_entry); -igb_set_rah_pool (hw, vf, rar_entry); +igb_rar_set_qsel (adapter, vf_mac, rar_entry, vf);/* enable transmit and receive for vf */ reg =rd32 (E1000_VFTE );
@@ -5532,6 +5523,33 @@ static void igb_io_resume(struct pci_dev *pdev)igb_get_hw_control (adapter); } +static void igb_rar_set_qsel (struct igb_adapter *adapter,u8 *addr,u32 index, +u8 qsel) +{ +u32 rar_low, rar_high; +struct e1000_hw *hw = &adapter->hw; + +/* HW expects these in little endian so we reverse the byte order +* from network order (big endian) to little endian +*/ + rar_low = ((u32 ) addr[0 ] | ((u32 ) addr[1 ] <<8 ) | + ((u32 ) addr[2 ] <<16 ) | ((u32 ) addr[3 ] <<24 )); + rar_high = ((u32 ) addr[4 ] | ((u32 ) addr[5 ] <<8 )); + +/* Indicate to hardware the Address is Valid. */ + rar_high |=E1000_RAH_AV ; + +if (hw->mac.type == e1000_82575) + rar_high |=E1000_RAH_POOL_1 * qsel; +else + rar_high |=E1000_RAH_POOL_1 << qsel; + +wr32 (E1000_RAL (index), rar_low); +wrfl (); +wr32 (E1000_RAH (index), rar_high); +wrfl (); +} +static int igb_set_vf_mac (struct igb_adapter *adapter,int vf,unsigned char *mac_addr) {
@@ -5542,8 +5560,7 @@ static int igb_set_vf_mac(struct igb_adapter *adapter,memcpy (adapter->vf_data[vf].vf_mac_addresses, mac_addr,ETH_ALEN ); -igb_rar_set (hw, mac_addr, rar_entry); -igb_set_rah_pool (hw, vf, rar_entry); +igb_rar_set_qsel (adapter, mac_addr, rar_entry, vf);return 0 ; }
Re: [net-next-2.6 PATCH 05/15] igb: add combined function for setting rar and pool bits
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:32:49 -0700
Quoted 7 lines
From: Alexander Duyck <[email protected]>
This patch adds
igb_rar_qselwhich sets the mac address and pool bits for a given mac address in the receive address register table.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 6/15 igb: make use of the uta to allow for promiscous mode filter
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
In order to support functions such as vlan tag stripping when SR-IOV is enabled any given packet must match at least one filter. However in the case of promiscous mode being enabled on the PF the traffic routed to it may not match any filters and is just sent to the PF by default. In order to make certain that this traffic is processed we can set all bits in the UTA registers to create a pseudo promiscous mode filter that accepts all packets.
---
drivers/net/igb/e1000_82575.c | 5 + drivers/net/igb/e1000_hw.h | 1 drivers/net/igb/e1000_regs.h | 1 drivers/net/igb/igb_main.c | 203 ++++++++++++++++++++++++++++++++--------- 4 files changed, 163 insertions(+), 47 deletions(-)
drivers/net/igb/e1000_82575.c +5 -0
@@ -875,6 +875,11 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw)for (i =0 ; i < mac->mta_reg_count; i++)array_wr32 (E1000_MTA , i,0 ); +/* Zero out the Unicast HASH table */ +hw_dbg ("Zeroing the UTA\n" ); +for (i =0 ; i < mac->uta_reg_count; i++) +array_wr32 (E1000_UTA , i,0 ); +/* Setup link and flow control */ ret_val =igb_setup_link (hw);
drivers/net/igb/e1000_hw.h +1 -0
@@ -340,6 +340,7 @@ struct e1000_mac_info {u16 ifs_ratio;u16 ifs_step_size;u16 mta_reg_count; +u16 uta_reg_count;/* Maximum size of the MTA register table in all supported adapters */ #define MAX_MTA_REG 128
drivers/net/igb/e1000_regs.h +1 -0
@@ -331,6 +331,7 @@ enum {#define E1000_QDE 0x02408/* Queue Drop Enable - RW */ #define E1000_DTXSWC 0x03500/* DMA Tx Switch Control - RW */ #define E1000_RPLOLR 0x05AF0/* Replication Offload - RW */ +#define E1000_UTA 0x0A000/* Unicast Table Array - RW */ #define E1000_IOVTCL 0x05BBC/* IOV Control Register */ /* These act per VF so an array friendly macro is used */ #define E1000_P2VMAILBOX (_n) (0x00C00 + (4 * (_n)))
drivers/net/igb/igb_main.c +156 -47
261 lines not on this page · raw message
Re: [net-next-2.6 PATCH 06/15] igb: make use of the uta to allow for promiscous mode filter
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:33:08 -0700
Quoted 10 lines
From: Alexander Duyck <[email protected]>
In order to support functions such as vlan tag stripping when SR-IOV is enabled any given packet must match at least one filter. However in the case of promiscous mode being enabled on the PF the traffic routed to it may not match any filters and is just sent to the PF by default. In order to make certain that this traffic is processed we can set all bits in the UTA registers to create a pseudo promiscous mode filter that accepts all packets.
Quoted 2 lines
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 7/15 igb: add support for 82576NS SerDes adapter
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This patch adds the device ID necessary to support the 82576NS SerDes adapter.
---
drivers/net/igb/e1000_82575.c | 1 + drivers/net/igb/e1000_hw.h | 1 + drivers/net/igb/igb_main.c | 1 + 3 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/igb/e1000_82575.c +1 -0
@@ -81,6 +81,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)break ;case E1000_DEV_ID_82576 :case E1000_DEV_ID_82576_NS : +case E1000_DEV_ID_82576_NS_SERDES :case E1000_DEV_ID_82576_FIBER :case E1000_DEV_ID_82576_SERDES :case E1000_DEV_ID_82576_QUAD_COPPER :
drivers/net/igb/e1000_hw.h +1 -0
@@ -42,6 +42,7 @@ struct e1000_hw;#define E1000_DEV_ID_82576_SERDES 0x10E7#define E1000_DEV_ID_82576_QUAD_COPPER 0x10E8#define E1000_DEV_ID_82576_NS 0x150A +#define E1000_DEV_ID_82576_NS_SERDES 0x1518#define E1000_DEV_ID_82576_SERDES_QUAD 0x150D#define E1000_DEV_ID_82575EB_COPPER 0x10A7#define E1000_DEV_ID_82575EB_FIBER_SERDES 0x10A9
drivers/net/igb/igb_main.c +1 -0
@@ -63,6 +63,7 @@ static const struct e1000_info *igb_info_tbl[] = {static struct pci_device_id igb_pci_tbl[] = { {PCI_VDEVICE (INTEL ,E1000_DEV_ID_82576 ), board_82575 }, {PCI_VDEVICE (INTEL ,E1000_DEV_ID_82576_NS ), board_82575 }, + {PCI_VDEVICE (INTEL ,E1000_DEV_ID_82576_NS_SERDES ), board_82575 }, {PCI_VDEVICE (INTEL ,E1000_DEV_ID_82576_FIBER ), board_82575 }, {PCI_VDEVICE (INTEL ,E1000_DEV_ID_82576_SERDES ), board_82575 }, {PCI_VDEVICE (INTEL ,E1000_DEV_ID_82576_SERDES_QUAD ), board_82575 },
Re: [net-next-2.6 PATCH 07/15] igb: add support for 82576NS SerDes adapter
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:33:27 -0700
Quoted 7 lines
From: Alexander Duyck <[email protected]>
This patch adds the device ID necessary to support the 82576NS SerDes adapter.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 8/15 igb: add function to handle mailbox lock
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
Both the read and write mailbox functions need to acquire the mailbox lock. Since that is the case we might as well combine both of the procedures into one function so it is easier to maintain.
---
drivers/net/igb/e1000_mbx.c | 63 +++++++++++++++++++++++-------------------- 1 files changed, 34 insertions(+), 29 deletions(-)
drivers/net/igb/e1000_mbx.c +34 -29
@@ -305,6 +305,30 @@ static s32 igb_check_for_rst_pf(struct e1000_hw *hw, u16 vf_number) }/** +* igb_obtain_mbx_lock_pf - obtain mailbox lock +* @hw: pointer to the HW structure +* @vf_number: the VF index +* +* return SUCCESS if we obtained the mailbox lock +**/ +static s32 igb_obtain_mbx_lock_pf (struct e1000_hw *hw,u16 vf_number) +{ +s32 ret_val = -E1000_ERR_MBX ; +u32 p2v_mailbox; + + +/* Take ownership of the buffer */ +wr32 (E1000_P2VMAILBOX (vf_number),E1000_P2VMAILBOX_PFU ); + +/* reserve mailbox for vf use */ + p2v_mailbox =rd32 (E1000_P2VMAILBOX (vf_number)); +if (p2v_mailbox &E1000_P2VMAILBOX_PFU ) + ret_val =0 ; + +return ret_val; +} + +/** * igb_write_mbx_pf - Places a message in the mailbox * @hw: pointer to the HW structure * @msg: The message buffer
@@ -316,27 +340,17 @@ static s32 igb_check_for_rst_pf(struct e1000_hw *hw, u16 vf_number)static s32 igb_write_mbx_pf (struct e1000_hw *hw,u32 *msg,u16 size,u16 vf_number) { -u32 p2v_mailbox; -s32 ret_val =0 ; +s32 ret_val;u16 i; -/* Take ownership of the buffer */ -wr32 (E1000_P2VMAILBOX (vf_number),E1000_P2VMAILBOX_PFU ); - -/* Make sure we have ownership now... */ - p2v_mailbox =rd32 (E1000_P2VMAILBOX (vf_number)); -if (!(p2v_mailbox &E1000_P2VMAILBOX_PFU )) { -/* failed to grab ownership */ - ret_val = -E1000_ERR_MBX ; +/* lock the mailbox to prevent pf/vf race condition */ + ret_val =igb_obtain_mbx_lock_pf (hw, vf_number); +if (ret_val) goto out_no_write; - } -/* -* flush any ack or msg which may already be in the queue -* as they are likely the result of an error -*/ -igb_check_for_ack_pf (hw, vf_number); +/* flush msg and acks as we are overwriting the message buffer */ igb_check_for_msg_pf (hw, vf_number); +igb_check_for_ack_pf (hw, vf_number);/* copy the caller specified message to the mailbox memory buffer */ for (i =0 ; i < size; i++)
@@ -367,20 +381,13 @@ out_no_write:static s32 igb_read_mbx_pf (struct e1000_hw *hw,u32 *msg,u16 size,u16 vf_number) { -u32 p2v_mailbox; -s32 ret_val =0 ; +s32 ret_val;u16 i; -/* Take ownership of the buffer */ -wr32 (E1000_P2VMAILBOX (vf_number),E1000_P2VMAILBOX_PFU ); - -/* Make sure we have ownership now... */ - p2v_mailbox =rd32 (E1000_P2VMAILBOX (vf_number)); -if (!(p2v_mailbox &E1000_P2VMAILBOX_PFU )) { -/* failed to grab ownership */ - ret_val = -E1000_ERR_MBX ; +/* lock the mailbox to prevent pf/vf race condition */ + ret_val =igb_obtain_mbx_lock_pf (hw, vf_number); +if (ret_val) goto out_no_read; - }/* copy the message to the mailbox memory buffer */ for (i =0 ; i < size; i++)
@@ -392,8 +399,6 @@ static s32 igb_read_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,/* update stats */ hw->mbx.stats.msgs_rx++; - ret_val =0 ; - out_no_read:return ret_val; }
Re: [net-next-2.6 PATCH 08/15] igb: add function to handle mailbox lock
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:33:46 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
Both the read and write mailbox functions need to acquire the mailbox lock. Since that is the case we might as well combine both of the procedures into one function so it is easier to maintain.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 9/15 igb: fix a few items where weren't correctly setup for mbx timeout
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
The mailbox timeout routines need to be updated as they were not correctly handling the case of a mailbox timeout and could cause issues with long delays when used.
---
drivers/net/igb/e1000_mbx.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/net/igb/e1000_mbx.c +14 -5
@@ -143,12 +143,16 @@ static s32 igb_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)if (!countdown || !mbx->ops.check_for_msg) goto out; -while (mbx->ops.check_for_msg (hw, mbx_id)) { +while (countdown && mbx->ops.check_for_msg (hw, mbx_id)) { countdown--;if (!countdown)break ;udelay (mbx->usec_delay); } + +/* if we failed, all future posted messages fail until reset */ +if (!countdown) + mbx->timeout =0 ; out:return countdown ?0 : -E1000_ERR_MBX ; }
@@ -168,12 +172,16 @@ static s32 igb_poll_for_ack(struct e1000_hw *hw, u16 mbx_id)if (!countdown || !mbx->ops.check_for_ack) goto out; -while (mbx->ops.check_for_ack (hw, mbx_id)) { +while (countdown && mbx->ops.check_for_ack (hw, mbx_id)) { countdown--;if (!countdown)break ;udelay (mbx->usec_delay); } + +/* if we failed, all future posted messages fail until reset */ +if (!countdown) + mbx->timeout =0 ; out:return countdown ?0 : -E1000_ERR_MBX ; }
@@ -217,12 +225,13 @@ out:static s32 igb_write_posted_mbx (struct e1000_hw *hw,u32 *msg,u16 size,u16 mbx_id) {struct e1000_mbx_info *mbx = &hw->mbx; -s32 ret_val =0 ; +s32 ret_val = -E1000_ERR_MBX ; -if (!mbx->ops.write) +/* exit if either we can't write or there isn't a defined timeout */ +if (!mbx->ops.write || !mbx->timeout) goto out; -/* send msg*/ +/* send msg */ ret_val = mbx->ops.write (hw, msg, size, mbx_id);/* if msg sent wait until we receive an ack */
Re: [net-next-2.6 PATCH 09/15] igb: fix a few items where weren't correctly setup for mbx timeout
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:34:05 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
The mailbox timeout routines need to be updated as they were not correctly handling the case of a mailbox timeout and could cause issues with long delays when used.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 10/15 igb: change how we handle alternate mac addresses
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This patch allows us to treat the alternate mac address as though it is the physical address on the adapter. This is accomplished by letting the alt_mac_address function to only fail on an NVM error. If no errors occur and the alternate mac address is not present then RAR0 is read as the default mac address.
---
drivers/net/igb/e1000_82575.c | 13 +++++++++++-- drivers/net/igb/e1000_hw.h | 2 ++ drivers/net/igb/e1000_mac.c | 17 +++++++++-------- 3 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/igb/e1000_82575.c +11 -2
@@ -1152,9 +1152,18 @@ static s32 igb_read_mac_addr_82575(struct e1000_hw *hw) {s32 ret_val =0 ; -if (igb_check_alt_mac_addr (hw)) - ret_val =igb_read_mac_addr (hw); +/* +* If there's an alternate MAC address place it in RAR0 +* so that it will override the Si installed default perm +* address. +*/ + ret_val =igb_check_alt_mac_addr (hw); +if (ret_val) + goto out; + + ret_val =igb_read_mac_addr (hw); +out:return ret_val; }
drivers/net/igb/e1000_hw.h +2 -0
@@ -54,6 +54,8 @@ struct e1000_hw;#define E1000_FUNC_0 0#define E1000_FUNC_1 1 +#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 3 +enum e1000_mac_type { e1000_undefined =0 , e1000_82575,
drivers/net/igb/e1000_mac.c +9 -8
@@ -185,13 +185,12 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw) }if (nvm_alt_mac_addr_offset ==0xFFFF ) { - ret_val = -(E1000_NOT_IMPLEMENTED ); +/* There is no Alternate MAC Address */ goto out; }if (hw->bus.func ==E1000_FUNC_1 ) - nvm_alt_mac_addr_offset +=ETH_ALEN /sizeof (u16); - + nvm_alt_mac_addr_offset +=E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 ;for (i =0 ; i <ETH_ALEN ; i +=2 ) { offset = nvm_alt_mac_addr_offset + (i >>1 ); ret_val = hw->nvm.ops.read (hw, offset,1 , &nvm_data);
@@ -206,14 +205,16 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw)/* if multicast bit is set, the alternate address will not be used */ if (alt_mac_addr[0 ] &0x01 ) { - ret_val = -(E1000_NOT_IMPLEMENTED ); +hw_dbg ("Ignoring Alternate Mac Address with MC bit set\n" ); goto out; } -for (i =0 ; i <ETH_ALEN ; i++) - hw->mac.addr[i] = hw->mac.perm_addr[i] = alt_mac_addr[i]; - - hw->mac.ops.rar_set (hw, hw->mac.perm_addr,0 ); +/* +* We have a valid alternate MAC address, and we want to treat it the +* same as the normal permanent MAC address stored by the HW into the +* RAR. Do this by mapping this address into RAR0. +*/ + hw->mac.ops.rar_set (hw, alt_mac_addr,0 ); out:return ret_val;
Re: [net-next-2.6 PATCH 10/15] igb: change how we handle alternate mac addresses
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:34:25 -0700
Quoted 10 lines
From: Alexander Duyck <[email protected]>
This patch allows us to treat the alternate mac address as though it is the physical address on the adapter. This is accomplished by letting the
alt_mac_addressfunction to only fail on an NVM error. If no errors occur and the alternate mac address is not present then RAR0 is read as the default mac address.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 11/15 igb: remove microwire support from igb
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
igb doesn't have any devices that use a microwire interface for NVM. As such the code related to this can be removed.
---
drivers/net/igb/e1000_hw.h | 3 --- drivers/net/igb/e1000_nvm.c | 36 +++--------------------------------- 2 files changed, 3 insertions(+), 36 deletions(-)
drivers/net/igb/e1000_hw.h +0 -3
@@ -74,7 +74,6 @@ enum e1000_nvm_type { e1000_nvm_unknown =0 , e1000_nvm_none, e1000_nvm_eeprom_spi, - e1000_nvm_eeprom_microwire, e1000_nvm_flash_hw, e1000_nvm_flash_sw };
@@ -83,8 +82,6 @@ enum e1000_nvm_override { e1000_nvm_override_none =0 , e1000_nvm_override_spi_small, e1000_nvm_override_spi_large, - e1000_nvm_override_microwire_small, - e1000_nvm_override_microwire_large }; enum e1000_phy_type {
drivers/net/igb/e1000_nvm.c +3 -33
@@ -78,9 +78,7 @@ static void igb_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)u32 mask; mask =0x01 << (count -1 ); -if (nvm->type == e1000_nvm_eeprom_microwire) - eecd &= ~E1000_EECD_DO ; -else if (nvm->type == e1000_nvm_eeprom_spi) +if (nvm->type == e1000_nvm_eeprom_spi) eecd |=E1000_EECD_DO ; do {
@@ -220,22 +218,7 @@ static void igb_standby_nvm(struct e1000_hw *hw)struct e1000_nvm_info *nvm = &hw->nvm;u32 eecd =rd32 (E1000_EECD ); -if (nvm->type == e1000_nvm_eeprom_microwire) { - eecd &= ~(E1000_EECD_CS |E1000_EECD_SK ); -wr32 (E1000_EECD , eecd); -wrfl (); -udelay (nvm->delay_usec); - -igb_raise_eec_clk (hw, &eecd); - -/* Select EEPROM */ - eecd |=E1000_EECD_CS ; -wr32 (E1000_EECD , eecd); -wrfl (); -udelay (nvm->delay_usec); - -igb_lower_eec_clk (hw, &eecd); - }else if (nvm->type == e1000_nvm_eeprom_spi) { +if (nvm->type == e1000_nvm_eeprom_spi) {/* Toggle CS to flush commands */ eecd |=E1000_EECD_CS ;wr32 (E1000_EECD , eecd);
@@ -263,12 +246,6 @@ static void e1000_stop_nvm(struct e1000_hw *hw)/* Pull CS high */ eecd |=E1000_EECD_CS ;igb_lower_eec_clk (hw, &eecd); - }else if (hw->nvm.type == e1000_nvm_eeprom_microwire) { -/* CS on Microcwire is active-high */ - eecd &= ~(E1000_EECD_CS |E1000_EECD_DI ); -wr32 (E1000_EECD , eecd); -igb_raise_eec_clk (hw, &eecd); -igb_lower_eec_clk (hw, &eecd); } }
@@ -304,14 +281,7 @@ static s32 igb_ready_nvm_eeprom(struct e1000_hw *hw)u8 spi_stat_reg; -if (nvm->type == e1000_nvm_eeprom_microwire) { -/* Clear SK and DI */ - eecd &= ~(E1000_EECD_DI |E1000_EECD_SK ); -wr32 (E1000_EECD , eecd); -/* Set CS */ - eecd |=E1000_EECD_CS ; -wr32 (E1000_EECD , eecd); - }else if (nvm->type == e1000_nvm_eeprom_spi) { +if (nvm->type == e1000_nvm_eeprom_spi) {/* Clear SK and CS */ eecd &= ~(E1000_EECD_CS |E1000_EECD_SK );wr32 (E1000_EECD , eecd);
Re: [net-next-2.6 PATCH 11/15] igb: remove microwire support from igb
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:34:44 -0700
Quoted 7 lines
From: Alexander Duyck <[email protected]>
igb doesn't have any devices that use a microwire interface for NVM. As such the code related to this can be removed.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 12/15 igb: move the generic copper link setup code into e1000_phy.c
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This patch moves the generic portion of the copper link setup into a seperate function in e1000_phy.c. This helps to reduce the size of copper_link_setup_82575 and make it a bit more readable.
---
drivers/net/igb/e1000_82575.c | 40 +-------------------------- drivers/net/igb/e1000_phy.c | 61 ++++++++++++++++++++++++++++++++++++++++- drivers/net/igb/e1000_phy.h | 2 + 3 files changed, 62 insertions(+), 41 deletions(-)
drivers/net/igb/e1000_82575.c +1 -39
@@ -907,7 +907,6 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw) {u32 ctrl;s32 ret_val; -bool link; ctrl =rd32 (E1000_CTRL ); ctrl |=E1000_CTRL_SLU ;
@@ -940,44 +939,7 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw)if (ret_val) goto out; -if (hw->mac.autoneg) { -/* -* Setup autoneg and flow control advertisement -* and perform autonegotiation. -*/ - ret_val =igb_copper_link_autoneg (hw); -if (ret_val) - goto out; - }else { -/* -* PHY will be set to 10H, 10F, 100H or 100F -* depending on user settings. -*/ -hw_dbg ("Forcing Speed and Duplex\n" ); - ret_val = hw->phy.ops.force_speed_duplex (hw); -if (ret_val) { -hw_dbg ("Error Forcing Speed and Duplex\n" ); - goto out; - } - } - -/* -* Check link status. Wait up to 100 microseconds for link to become -* valid. -*/ - ret_val =igb_phy_has_link (hw,COPPER_LINK_UP_LIMIT ,10 , &link); -if (ret_val) - goto out; - -if (link) { -hw_dbg ("Valid link established!!!\n" ); -/* Config the MAC and PHY after link is up */ -igb_config_collision_dist (hw); - ret_val =igb_config_fc_after_link_up (hw); - }else { -hw_dbg ("Unable to establish link!!!\n" ); - } - + ret_val =igb_setup_copper_link (hw); out:return ret_val; }
drivers/net/igb/e1000_phy.c +60 -1
73 lines not on this page · raw message
drivers/net/igb/e1000_phy.h +1 -1
@@ -43,7 +43,6 @@ enum e1000_smart_speed {s32 igb_check_downshift (struct e1000_hw *hw);s32 igb_check_reset_block (struct e1000_hw *hw); -s32 igb_copper_link_autoneg (struct e1000_hw *hw);s32 igb_copper_link_setup_igp (struct e1000_hw *hw);s32 igb_copper_link_setup_m88 (struct e1000_hw *hw);s32 igb_phy_force_speed_duplex_igp (struct e1000_hw *hw);
@@ -57,6 +56,7 @@ s32 igb_phy_sw_reset(struct e1000_hw *hw);s32 igb_phy_hw_reset (struct e1000_hw *hw);s32 igb_read_phy_reg_igp (struct e1000_hw *hw,u32 offset,u16 *data);s32 igb_set_d3_lplu_state (struct e1000_hw *hw,bool active); +s32 igb_setup_copper_link (struct e1000_hw *hw);s32 igb_write_phy_reg_igp (struct e1000_hw *hw,u32 offset,u16 data);s32 igb_phy_has_link (struct e1000_hw *hw,u32 iterations,u32 usec_interval,bool *success);
Re: [net-next-2.6 PATCH 12/15] igb: move the generic copper link setup code into e1000_phy.c
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:35:03 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
This patch moves the generic portion of the copper link setup into a seperate function in
e1000_phy.c. This helps to reduce the size ofcopper_link_setup_82575and make it a bit more readable.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 13/15 igb: add code to retry a phy read in the event of failure on link check
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This patch adds a retry to phy reads in the event of failure. The original code broke out of the loop on failure and this is a mistake as we should be trying to do the read twice.
---
drivers/net/igb/e1000_phy.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/igb/e1000_phy.c +8 -2
@@ -1444,8 +1444,14 @@ s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations,* it across the board. */ ret_val = hw->phy.ops.read_reg (hw,PHY_STATUS , &phy_status); -if (ret_val) -break ; +if (ret_val) { +/* +* If the first read fails, another entity may have +* ownership of the resources, wait and try again to +* see if they have relinquished the resources yet. +*/ +udelay (usec_interval); + } ret_val = hw->phy.ops.read_reg (hw,PHY_STATUS , &phy_status);if (ret_val)break ;
Re: [net-next-2.6 PATCH 13/15] igb: add code to retry a phy read in the event of failure on link check
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:35:23 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
This patch adds a retry to phy reads in the event of failure. The original code broke out of the loop on failure and this is a mistake as we should be trying to do the read twice.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 14/15 igb: add additional error handling to the phy code
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
This update adds additional exception handling to the phy code to handle situations where it may be called incorrectly. In addition it adds some bounds checking to the cable length checks to prevent an array overrun in the event that the hardware returned a different value than expected.
---
drivers/net/igb/e1000_phy.c | 39 +++++++++++++++++++++++++-------------- 1 files changed, 25 insertions(+), 14 deletions(-)
drivers/net/igb/e1000_phy.c +25 -14
@@ -39,6 +39,9 @@ static s32 igb_wait_autoneg(struct e1000_hw *hw);/* Cable length tables */ static const u16 e1000_m88_cable_length_table[] = {0 ,50 ,80 ,110 ,140 ,140 ,E1000_CABLE_LENGTH_UNDEFINED }; +#define M88E1000_CABLE_LENGTH_TABLE_SIZE \ + (sizeof(e1000_m88_cable_length_table) / \ + sizeof(e1000_m88_cable_length_table[0]))static const u16 e1000_igp_2_cable_length_table[] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,3 ,5 ,8 ,11 ,13 ,16 ,18 ,21 ,
@@ -109,7 +112,10 @@ out:**/ static s32 igb_phy_reset_dsp (struct e1000_hw *hw) { -s32 ret_val; +s32 ret_val =0 ; + +if (!(hw->phy.ops.write_reg)) + goto out; ret_val = hw->phy.ops.write_reg (hw,M88E1000_PHY_GEN_CONTROL ,0xC1 );if (ret_val)
@@ -1059,22 +1065,19 @@ s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)igb_phy_force_speed_duplex_setup (hw, &phy_data); -/* Reset the phy to commit changes. */ - phy_data |=MII_CR_RESET ; - ret_val = phy->ops.write_reg (hw,PHY_CONTROL , phy_data);if (ret_val) goto out; -udelay (1 ); +/* Reset the phy to commit changes. */ + ret_val =igb_phy_sw_reset (hw); +if (ret_val) + goto out;if (phy->autoneg_wait_to_complete) {hw_dbg ("Waiting for forced speed/duplex link on M88 phy.\n" ); - ret_val =igb_phy_has_link (hw, -PHY_FORCE_LIMIT , -100000 , - &link); + ret_val =igb_phy_has_link (hw,PHY_FORCE_LIMIT ,100000 , &link);if (ret_val) goto out;
@@ -1084,8 +1087,8 @@ s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)* Reset the DSP and cross our fingers. */ ret_val = phy->ops.write_reg (hw, -M88E1000_PHY_PAGE_SELECT , -0x001d ); +M88E1000_PHY_PAGE_SELECT , +0x001d );if (ret_val) goto out; ret_val =igb_phy_reset_dsp (hw);
@@ -1095,7 +1098,7 @@ s32 igb_phy_force_speed_duplex_m88(struct e1000_hw *hw)/* Try once more */ ret_val =igb_phy_has_link (hw,PHY_FORCE_LIMIT , -100000 , &link); +100000 , &link);if (ret_val) goto out; }
@@ -1207,9 +1210,12 @@ static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw,s32 igb_set_d3_lplu_state (struct e1000_hw *hw,bool active) {struct e1000_phy_info *phy = &hw->phy; -s32 ret_val; +s32 ret_val =0 ;u16 data; +if (!(hw->phy.ops.read_reg)) + goto out; + ret_val = phy->ops.read_reg (hw,IGP02E1000_PHY_POWER_MGMT , &data);if (ret_val) goto out;
@@ -1495,8 +1501,13 @@ s32 igb_get_cable_length_m88(struct e1000_hw *hw) index = (phy_data &M88E1000_PSSR_CABLE_LENGTH ) >>M88E1000_PSSR_CABLE_LENGTH_SHIFT ; +if (index >=M88E1000_CABLE_LENGTH_TABLE_SIZE -1 ) { + ret_val = -E1000_ERR_PHY ; + goto out; + } + phy->min_cable_length = e1000_m88_cable_length_table[index]; - phy->max_cable_length = e1000_m88_cable_length_table[index+1 ]; + phy->max_cable_length = e1000_m88_cable_length_table[index +1 ]; phy->cable_length = (phy->min_cable_length + phy->max_cable_length) /2 ;
Re: [net-next-2.6 PATCH 14/15] igb: add additional error handling to the phy code
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:35:42 -0700
Quoted 9 lines
From: Alexander Duyck <[email protected]>
This update adds additional exception handling to the phy code to handle situations where it may be called incorrectly. In addition it adds some bounds checking to the cable length checks to prevent an array overrun in the event that the hardware returned a different value than expected.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
PATCH 15/15 igb: add flushes between RAR writes when setting mac address
In reply to Jeff KirsherFrom: Alexander Duyck <[email protected]>
There are some switches that will do write combining when they see two sequential regions written. In order to avoid any possible write combining issues it is necessary to add a flush after writing each piece of a rar register.
---
drivers/net/igb/e1000_mac.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/igb/e1000_mac.c +7 -0
@@ -247,8 +247,15 @@ void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)if (rar_low || rar_high) rar_high |=E1000_RAH_AV ; +/* +* Some bridges will combine consecutive 32-bit writes into +* a single burst write, which will malfunction on some parts. +* The flushes avoid this. +*/ wr32 (E1000_RAL (index), rar_low); +wrfl ();wr32 (E1000_RAH (index), rar_high); +wrfl (); }/**
Re: [net-next-2.6 PATCH 15/15] igb: add flushes between RAR writes when setting mac address
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:36:01 -0700
Quoted 9 lines
From: Alexander Duyck <[email protected]>
There are some switches that will do write combining when they see two sequential regions written. In order to avoid any possible write combining issues it is necessary to add a flush after writing each piece of a rar register.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:31:25 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
There is a temp variable in the stats clearing path that isn't needed since the results from the stats read can be immediately discared. Since it isn't needed we might as well just drop it from the function call.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
From: Jeff Kirsher <[email protected]>
Date: Mon, 05 Oct 2009 09:31:25 -0700
Quoted 8 lines
From: Alexander Duyck <[email protected]>
There is a temp variable in the stats clearing path that isn't needed since the results from the stats read can be immediately discared. Since it isn't needed we might as well just drop it from the function call.
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.