Commit 8620a103 authored by Mallikarjuna R Chilakala's avatar Mallikarjuna R Chilakala Committed by David S. Miller

ixgbe: refactor link setup code

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
Signed-off-by: default avatarMallikarjuna R Chilakala <mallikarjuna.chilakala@intel.com>
Acked-by: default avatarPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fd38d7a0
...@@ -41,8 +41,7 @@ ...@@ -41,8 +41,7 @@
static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw, static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
ixgbe_link_speed *speed, ixgbe_link_speed *speed,
bool *autoneg); bool *autoneg);
static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw); static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
ixgbe_link_speed speed, ixgbe_link_speed speed,
bool autoneg, bool autoneg,
bool autoneg_wait_to_complete); bool autoneg_wait_to_complete);
...@@ -156,8 +155,6 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw) ...@@ -156,8 +155,6 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
/* Overwrite the link function pointers if copper PHY */ /* Overwrite the link function pointers if copper PHY */
if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) { if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
mac->ops.setup_link = &ixgbe_setup_copper_link_82598; 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 = mac->ops.get_link_capabilities =
&ixgbe_get_copper_link_capabilities_82598; &ixgbe_get_copper_link_capabilities_82598;
} }
...@@ -465,13 +462,14 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num) ...@@ -465,13 +462,14 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
} }
/** /**
* ixgbe_setup_mac_link_82598 - Configures MAC link settings * ixgbe_start_mac_link_82598 - Configures MAC link settings
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
* *
* Configures link settings based on values in the ixgbe_hw struct. * Configures link settings based on values in the ixgbe_hw struct.
* Restarts the link. Performs autonegotiation if needed. * 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 autoc_reg;
u32 links_reg; u32 links_reg;
...@@ -484,7 +482,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw) ...@@ -484,7 +482,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);
/* Only poll for autoneg to complete if specified to do so */ /* 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) == if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
IXGBE_AUTOC_LMS_KX4_AN || IXGBE_AUTOC_LMS_KX4_AN ||
(autoc_reg & IXGBE_AUTOC_LMS_MASK) == (autoc_reg & IXGBE_AUTOC_LMS_MASK) ==
...@@ -600,7 +598,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, ...@@ -600,7 +598,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
/** /**
* ixgbe_setup_mac_link_speed_82598 - Set MAC link speed * ixgbe_setup_mac_link_82598 - Set MAC link speed
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
* @speed: new link speed * @speed: new link speed
* @autoneg: true if auto-negotiation enabled * @autoneg: true if auto-negotiation enabled
...@@ -608,7 +606,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, ...@@ -608,7 +606,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
* *
* Set the link speed in the AUTOC register and restarts link. * 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, ixgbe_link_speed speed, bool autoneg,
bool autoneg_wait_to_complete) bool autoneg_wait_to_complete)
{ {
...@@ -638,14 +636,12 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw, ...@@ -638,14 +636,12 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,
} }
if (status == 0) { if (status == 0) {
hw->phy.autoneg_wait_to_complete = autoneg_wait_to_complete;
/* /*
* Setup and restart the link based on the new values in * Setup and restart the link based on the new values in
* ixgbe_hw This will write the AUTOC register based on the new * ixgbe_hw This will write the AUTOC register based on the new
* stored values * stored values
*/ */
status = ixgbe_setup_mac_link_82598(hw); status = ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
} }
return status; return status;
...@@ -653,29 +649,7 @@ static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw, ...@@ -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 * ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field
* @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
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
* @speed: new link speed * @speed: new link speed
* @autoneg: true if autonegotiation enabled * @autoneg: true if autonegotiation enabled
...@@ -683,7 +657,7 @@ static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw) ...@@ -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. * 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, ixgbe_link_speed speed,
bool autoneg, bool autoneg,
bool autoneg_wait_to_complete) bool autoneg_wait_to_complete)
...@@ -695,7 +669,7 @@ static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, ...@@ -695,7 +669,7 @@ static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
autoneg_wait_to_complete); autoneg_wait_to_complete);
/* Set up MAC */ /* Set up MAC */
ixgbe_setup_mac_link_82598(hw); ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
return status; return status;
} }
...@@ -1163,7 +1137,6 @@ static struct ixgbe_mac_operations mac_ops_82598 = { ...@@ -1163,7 +1137,6 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
.read_analog_reg8 = &ixgbe_read_analog_reg8_82598, .read_analog_reg8 = &ixgbe_read_analog_reg8_82598,
.write_analog_reg8 = &ixgbe_write_analog_reg8_82598, .write_analog_reg8 = &ixgbe_write_analog_reg8_82598,
.setup_link = &ixgbe_setup_mac_link_82598, .setup_link = &ixgbe_setup_mac_link_82598,
.setup_link_speed = &ixgbe_setup_mac_link_speed_82598,
.check_link = &ixgbe_check_mac_link_82598, .check_link = &ixgbe_check_mac_link_82598,
.get_link_capabilities = &ixgbe_get_link_capabilities_82598, .get_link_capabilities = &ixgbe_get_link_capabilities_82598,
.led_on = &ixgbe_led_on_generic, .led_on = &ixgbe_led_on_generic,
......
This diff is collapsed.
...@@ -233,11 +233,11 @@ static int ixgbe_set_settings(struct net_device *netdev, ...@@ -233,11 +233,11 @@ static int ixgbe_set_settings(struct net_device *netdev,
return err; return err;
/* this sets the link speed and restarts auto-neg */ /* this sets the link speed and restarts auto-neg */
hw->mac.autotry_restart = true; 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) { if (err) {
DPRINTK(PROBE, INFO, DPRINTK(PROBE, INFO,
"setup link failed with code %d\n", err); "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 { } else {
/* in this case we currently only support 10Gb/FULL */ /* in this case we currently only support 10Gb/FULL */
......
...@@ -2516,7 +2516,7 @@ static void ixgbe_sfp_link_config(struct ixgbe_adapter *adapter) ...@@ -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) static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw)
{ {
u32 autoneg; u32 autoneg;
bool link_up = false; bool negotiation, link_up = false;
u32 ret = IXGBE_ERR_LINK_SETUP; u32 ret = IXGBE_ERR_LINK_SETUP;
if (hw->mac.ops.check_link) if (hw->mac.ops.check_link)
...@@ -2526,13 +2526,12 @@ static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw) ...@@ -2526,13 +2526,12 @@ static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw)
goto link_cfg_out; goto link_cfg_out;
if (hw->mac.ops.get_link_capabilities) if (hw->mac.ops.get_link_capabilities)
ret = hw->mac.ops.get_link_capabilities(hw, &autoneg, ret = hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation);
&hw->mac.autoneg);
if (ret) if (ret)
goto link_cfg_out; goto link_cfg_out;
if (hw->mac.ops.setup_link_speed) if (hw->mac.ops.setup_link)
ret = hw->mac.ops.setup_link_speed(hw, autoneg, true, link_up); ret = hw->mac.ops.setup_link(hw, autoneg, negotiation, link_up);
link_cfg_out: link_cfg_out:
return ret; return ret;
} }
...@@ -4517,14 +4516,14 @@ static void ixgbe_multispeed_fiber_task(struct work_struct *work) ...@@ -4517,14 +4516,14 @@ static void ixgbe_multispeed_fiber_task(struct work_struct *work)
multispeed_fiber_task); multispeed_fiber_task);
struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_hw *hw = &adapter->hw;
u32 autoneg; u32 autoneg;
bool negotiation;
adapter->flags |= IXGBE_FLAG_IN_SFP_LINK_TASK; adapter->flags |= IXGBE_FLAG_IN_SFP_LINK_TASK;
autoneg = hw->phy.autoneg_advertised; autoneg = hw->phy.autoneg_advertised;
if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
hw->mac.ops.get_link_capabilities(hw, &autoneg, hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation);
&hw->mac.autoneg); if (hw->mac.ops.setup_link)
if (hw->mac.ops.setup_link_speed) hw->mac.ops.setup_link(hw, autoneg, negotiation, true);
hw->mac.ops.setup_link_speed(hw, autoneg, true, true);
adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
adapter->flags &= ~IXGBE_FLAG_IN_SFP_LINK_TASK; adapter->flags &= ~IXGBE_FLAG_IN_SFP_LINK_TASK;
} }
......
...@@ -2332,9 +2332,7 @@ struct ixgbe_mac_operations { ...@@ -2332,9 +2332,7 @@ struct ixgbe_mac_operations {
s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
/* Link */ /* Link */
s32 (*setup_link)(struct ixgbe_hw *); s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool,
bool);
s32 (*check_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 *, s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
bool *); bool *);
...@@ -2406,8 +2404,6 @@ struct ixgbe_mac_info { ...@@ -2406,8 +2404,6 @@ struct ixgbe_mac_info {
u32 orig_autoc; u32 orig_autoc;
u32 orig_autoc2; u32 orig_autoc2;
bool orig_link_settings_stored; bool orig_link_settings_stored;
bool autoneg;
bool autoneg_succeeded;
bool autotry_restart; bool autotry_restart;
}; };
...@@ -2422,7 +2418,6 @@ struct ixgbe_phy_info { ...@@ -2422,7 +2418,6 @@ struct ixgbe_phy_info {
enum ixgbe_media_type media_type; enum ixgbe_media_type media_type;
bool reset_disable; bool reset_disable;
ixgbe_autoneg_advertised autoneg_advertised; ixgbe_autoneg_advertised autoneg_advertised;
bool autoneg_wait_to_complete;
bool multispeed_fiber; bool multispeed_fiber;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment