ixgbe: refactor link setup code
Subsystems (2)
PATCH 1/3 ixgbe: refactor link setup code
From: Mallikarjuna R Chilakala <[email protected]>
Link code cleanup: a number of redundant functions and MAC variables are cleaned up, with some functions being consolidated into a single-purpose code path. Removed following deprecated link functions and mac variables
* ixgbe_setup_copper_link_speed_82598
* ixgbe_setup_mac_link_speed_multispeed_fiber
* ixgbe_setup_mac_link_speed_82599
* mac.autoneg, mac.autoneg_succeeded, phy.autoneg_wait_to_complete
---
drivers/net/ixgbe/ixgbe_82598.c | 49 +++---------- drivers/net/ixgbe/ixgbe_82599.c | 135 ++++++++++++------------------------- drivers/net/ixgbe/ixgbe_ethtool.c | 4 + drivers/net/ixgbe/ixgbe_main.c | 17 ++--- drivers/net/ixgbe/ixgbe_type.h | 7 -- 5 files changed, 67 insertions(+), 145 deletions(-)
drivers/net/ixgbe/ixgbe_82598.c +11 -38
@@ -41,8 +41,7 @@static s32 ixgbe_get_copper_link_capabilities_82598 (struct ixgbe_hw *hw,ixgbe_link_speed *speed,bool *autoneg); -static s32 ixgbe_setup_copper_link_82598 (struct ixgbe_hw *hw); -static s32 ixgbe_setup_copper_link_speed_82598 (struct ixgbe_hw *hw, +static s32 ixgbe_setup_copper_link_82598 (struct ixgbe_hw *hw,ixgbe_link_speed speed,bool autoneg,bool autoneg_wait_to_complete);
@@ -156,8 +155,6 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)/* Overwrite the link function pointers if copper PHY */ if (mac->ops.get_media_type (hw) == ixgbe_media_type_copper) { mac->ops.setup_link = &ixgbe_setup_copper_link_82598; - mac->ops.setup_link_speed = - &ixgbe_setup_copper_link_speed_82598; mac->ops.get_link_capabilities = &ixgbe_get_copper_link_capabilities_82598; }
@@ -465,13 +462,14 @@ out: }/** -* ixgbe_setup_mac_link_82598 - Configures MAC link settings +* ixgbe_start_mac_link_82598 - Configures MAC link settings * @hw: pointer to hardware structure * * Configures link settings based on values in the ixgbe_hw struct. * Restarts the link. Performs autonegotiation if needed. **/ -static s32 ixgbe_setup_mac_link_82598 (struct ixgbe_hw *hw) +static s32 ixgbe_start_mac_link_82598 (struct ixgbe_hw *hw, +bool autoneg_wait_to_complete) {u32 autoc_reg;u32 links_reg;
@@ -484,7 +482,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)IXGBE_WRITE_REG (hw,IXGBE_AUTOC , autoc_reg);/* Only poll for autoneg to complete if specified to do so */ - if (hw->phy.autoneg_wait_to_complete) { + if (autoneg_wait_to_complete) { if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) == IXGBE_AUTOC_LMS_KX4_AN || (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
@@ -600,7 +598,7 @@ out:/** -* ixgbe_setup_mac_link_speed_82598 - Set MAC link speed +* ixgbe_setup_mac_link_82598 - Set MAC link speed * @hw: pointer to hardware structure * @speed: new link speed * @autoneg: true if auto-negotiation enabled
@@ -608,7 +606,7 @@ out:* * Set the link speed in the AUTOC register and restarts link. **/ -static s32 ixgbe_setup_mac_link_speed_82598 (struct ixgbe_hw *hw, +static s32 ixgbe_setup_mac_link_82598 (struct ixgbe_hw *hw,ixgbe_link_speed speed,bool autoneg,bool autoneg_wait_to_complete) {
@@ -638,14 +636,12 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw, }if (status ==0 ) { - hw->phy.autoneg_wait_to_complete = autoneg_wait_to_complete; -/* * Setup and restart the link based on the new values in * ixgbe_hw This will write the AUTOC register based on the new * stored values */ - status =ixgbe_setup_mac_link_82598 (hw); + status =ixgbe_start_mac_link_82598 (hw, autoneg_wait_to_complete); }return status;
@@ -653,29 +649,7 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,/** -* ixgbe_setup_copper_link_82598 - Setup copper link settings -* @hw: pointer to hardware structure -* -* Configures link settings based on values in the ixgbe_hw struct. -* Restarts the link. Performs autonegotiation if needed. Restart -* phy and wait for autonegotiate to finish. Then synchronize the -* MAC and PHY. -**/ -static s32 ixgbe_setup_copper_link_82598 (struct ixgbe_hw *hw) -{ -s32 status; - -/* Restart autonegotiation on PHY */ - status = hw->phy.ops.setup_link (hw); - -/* Set up MAC */ -ixgbe_setup_mac_link_82598 (hw); - -return status; -} - -/** -* ixgbe_setup_copper_link_speed_82598 - Set the PHY autoneg advertised field +* ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field * @hw: pointer to hardware structure * @speed: new link speed * @autoneg: true if autonegotiation enabled
@@ -683,7 +657,7 @@ static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)* * Sets the link speed in the AUTOC register in the MAC and restarts link. **/ -static s32 ixgbe_setup_copper_link_speed_82598 (struct ixgbe_hw *hw, +static s32 ixgbe_setup_copper_link_82598 (struct ixgbe_hw *hw,ixgbe_link_speed speed,bool autoneg,bool autoneg_wait_to_complete)
@@ -695,7 +669,7 @@ static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, autoneg_wait_to_complete);/* Set up MAC */ -ixgbe_setup_mac_link_82598 (hw); +ixgbe_start_mac_link_82598 (hw, autoneg_wait_to_complete);return status; }
@@ -1163,7 +1137,6 @@ static struct ixgbe_mac_operations mac_ops_82598 = { .read_analog_reg8 = &ixgbe_read_analog_reg8_82598, .write_analog_reg8 = &ixgbe_write_analog_reg8_82598, .setup_link = &ixgbe_setup_mac_link_82598, - .setup_link_speed = &ixgbe_setup_mac_link_speed_82598, .check_link = &ixgbe_check_mac_link_82598, .get_link_capabilities = &ixgbe_get_link_capabilities_82598, .led_on = &ixgbe_led_on_generic,
drivers/net/ixgbe/ixgbe_82599.c +45 -90
240 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethtool.c +2 -2
@@ -233,11 +233,11 @@ static int ixgbe_set_settings(struct net_device *netdev,return err;/* this sets the link speed and restarts auto-neg */ hw->mac.autotry_restart = true; - err = hw->mac.ops.setup_link_speed (hw, advertised, true, true); + err = hw->mac.ops.setup_link (hw, advertised, true, true);if (err) {DPRINTK (PROBE ,INFO ,"setup link failed with code %d\n" , err); - hw->mac.ops.setup_link_speed (hw, old, true, true); + hw->mac.ops.setup_link (hw, old, true, true); } }else {/* in this case we currently only support 10Gb/FULL */
drivers/net/ixgbe/ixgbe_main.c +8 -9
@@ -2516,7 +2516,7 @@ static void ixgbe_sfp_link_config(struct ixgbe_adapter *adapter)static int ixgbe_non_sfp_link_config (struct ixgbe_hw *hw) {u32 autoneg; -bool link_up = false; +bool negotiation, link_up = false;u32 ret =IXGBE_ERR_LINK_SETUP ;if (hw->mac.ops.check_link)
@@ -2526,13 +2526,12 @@ static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw) goto link_cfg_out;if (hw->mac.ops.get_link_capabilities) - ret = hw->mac.ops.get_link_capabilities (hw, &autoneg, - &hw->mac.autoneg); + ret = hw->mac.ops.get_link_capabilities (hw, &autoneg, &negotiation);if (ret) goto link_cfg_out; -if (hw->mac.ops.setup_link_speed) - ret = hw->mac.ops.setup_link_speed (hw, autoneg, true, link_up); +if (hw->mac.ops.setup_link) + ret = hw->mac.ops.setup_link (hw, autoneg, negotiation, link_up); link_cfg_out:return ret; }
@@ -4517,14 +4516,14 @@ static void ixgbe_multispeed_fiber_task(struct work_struct *work) multispeed_fiber_task);struct ixgbe_hw *hw = &adapter->hw;u32 autoneg; +bool negotiation; adapter->flags |=IXGBE_FLAG_IN_SFP_LINK_TASK ; autoneg = hw->phy.autoneg_advertised;if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) - hw->mac.ops.get_link_capabilities (hw, &autoneg, - &hw->mac.autoneg); -if (hw->mac.ops.setup_link_speed) - hw->mac.ops.setup_link_speed (hw, autoneg, true, true); + hw->mac.ops.get_link_capabilities (hw, &autoneg, &negotiation); +if (hw->mac.ops.setup_link) + hw->mac.ops.setup_link (hw, autoneg, negotiation, true); adapter->flags |=IXGBE_FLAG_NEED_LINK_UPDATE ; adapter->flags &= ~IXGBE_FLAG_IN_SFP_LINK_TASK ; }
drivers/net/ixgbe/ixgbe_type.h +1 -6
@@ -2332,9 +2332,7 @@ struct ixgbe_mac_operations {s32 (*enable_rx_dma)(struct ixgbe_hw *,u32 );/* Link */ -s32 (*setup_link)(struct ixgbe_hw *); -s32 (*setup_link_speed)(struct ixgbe_hw *,ixgbe_link_speed ,bool , -bool ); +s32 (*setup_link)(struct ixgbe_hw *,ixgbe_link_speed ,bool ,bool );s32 (*check_link)(struct ixgbe_hw *,ixgbe_link_speed *,bool *,bool );s32 (*get_link_capabilities)(struct ixgbe_hw *,ixgbe_link_speed *,bool *);
@@ -2406,8 +2404,6 @@ struct ixgbe_mac_info {u32 orig_autoc;u32 orig_autoc2;bool orig_link_settings_stored; -bool autoneg; -bool autoneg_succeeded;bool autotry_restart; };
@@ -2422,7 +2418,6 @@ struct ixgbe_phy_info {enum ixgbe_media_type media_type;bool reset_disable;ixgbe_autoneg_advertised autoneg_advertised; -bool autoneg_wait_to_complete;bool multispeed_fiber; };
PATCH 2/3 ixgbe: Properly disable DCB arbiters prior to applying changes
From: Peter P Waskiewicz Jr <[email protected]>
When disabling the Rx and Tx data arbiters prior to configuration changes, the arbiters were not being shut down properly. This can create a race in the DCB hardware blocks, and potentially hang the arbiters. Also, the Tx descriptor arbiter shouldn't be disabled when applying configuration changes; disabling this arbiter can cause a Tx hang.
---
drivers/net/ixgbe/ixgbe_dcb_82599.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_dcb_82599.c +14 -7
@@ -145,8 +145,12 @@ s32 ixgbe_dcb_config_rx_arbiter_82599(struct ixgbe_hw *hw,u32 credit_max =0 ;u8 i =0 ; -/* Disable the arbiter before changing parameters */ -IXGBE_WRITE_REG (hw,IXGBE_RTRPCS ,IXGBE_RTRPCS_ARBDIS ); +/* +* Disable the arbiter before changing parameters +* (always enable recycle mode; WSP) +*/ + reg =IXGBE_RTRPCS_RRM |IXGBE_RTRPCS_RAC |IXGBE_RTRPCS_ARBDIS ; +IXGBE_WRITE_REG (hw,IXGBE_RTRPCS , reg);/* Map all traffic classes to their UP, 1 to 1 */ reg =0 ;
@@ -194,9 +198,6 @@ s32 ixgbe_dcb_config_tx_desc_arbiter_82599(struct ixgbe_hw *hw,u32 reg, max_credits;u8 i; -/* Disable the arbiter before changing parameters */ -IXGBE_WRITE_REG (hw,IXGBE_RTTDCS ,IXGBE_RTTDCS_ARBDIS ); -/* Clear the per-Tx queue credits; we use per-TC instead */ for (i =0 ; i <128 ; i++) {IXGBE_WRITE_REG (hw,IXGBE_RTTDQSEL , i);
@@ -244,8 +245,14 @@ s32 ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,u32 reg;u8 i; -/* Disable the arbiter before changing parameters */ -IXGBE_WRITE_REG (hw,IXGBE_RTTPCS ,IXGBE_RTTPCS_ARBDIS ); +/* +* Disable the arbiter before changing parameters +* (always enable recycle mode; SP; arb delay) +*/ + reg =IXGBE_RTTPCS_TPPAC |IXGBE_RTTPCS_TPRM | + (IXGBE_RTTPCS_ARBD_DCB <<IXGBE_RTTPCS_ARBD_SHIFT ) | +IXGBE_RTTPCS_ARBDIS ; +IXGBE_WRITE_REG (hw,IXGBE_RTTPCS , reg);/* Map all traffic classes to their UP, 1 to 1 */ reg =0 ;
PATCH 3/3 ixgbe: Patch to fix 82599 multispeed fiber link issues when driver is loaded without any cable and reconnecting it to 1G partner
In reply to Jeff KirsherFrom: Mallikarjuna R Chilakala <[email protected]>
In 82599 multi speed fiber case when driver is loaded without any cable and reconnecting the cable with a 1G partner does not bring up the link in 1Gb mode. When there is no link we first setup the link at 10G & 1G and then try to re-establish the link at highest speed 10G and thereby changing autoneg_advertised value to highest speed 10G. After connecting back the cable to a 1G link partner we never try 1G as autoneg advertised value is changed to link at 10G only. The following patch fixes the issue by properly initializing the autoneg_advertised value just before exiting from link setup routine.
---
drivers/net/ixgbe/ixgbe_82599.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/ixgbe/ixgbe_82599.c +11 -11
@@ -421,15 +421,6 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, hw->mac.ops.get_link_capabilities (hw, &phy_link_speed, &negotiation); speed &= phy_link_speed; -/* Set autoneg_advertised value based on input link speed */ - hw->phy.autoneg_advertised =0 ; - -if (speed &IXGBE_LINK_SPEED_10GB_FULL ) - hw->phy.autoneg_advertised |=IXGBE_LINK_SPEED_10GB_FULL ; - -if (speed &IXGBE_LINK_SPEED_1GB_FULL ) - hw->phy.autoneg_advertised |=IXGBE_LINK_SPEED_1GB_FULL ; -/* * When the driver changes the link speeds that it can support, * it sets autotry_restart to true to indicate that we need to
@@ -466,7 +457,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, autoneg, autoneg_wait_to_complete);if (status !=0 ) - goto out; +return status;/* Flap the tx laser if it has not already been done */ if (hw->mac.autotry_restart) {
@@ -520,7 +511,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, autoneg, autoneg_wait_to_complete);if (status !=0 ) - goto out; +return status;/* Flap the tx laser if it has not already been done */ if (hw->mac.autotry_restart) {
@@ -558,6 +549,15 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, autoneg_wait_to_complete); out: +/* Set autoneg_advertised value based on input link speed */ + hw->phy.autoneg_advertised =0 ; + +if (speed &IXGBE_LINK_SPEED_10GB_FULL ) + hw->phy.autoneg_advertised |=IXGBE_LINK_SPEED_10GB_FULL ; + +if (speed &IXGBE_LINK_SPEED_1GB_FULL ) + hw->phy.autoneg_advertised |=IXGBE_LINK_SPEED_1GB_FULL ; +return status; }
David Miller
maintainerAll 3 patches applied, thanks.