Commit 5c48ef3e authored by Bruce Allan's avatar Bruce Allan Committed by David S. Miller

e1000e: sync change flow control variables with ixgbe

Sync flow control variables and usage model with that found in the ixgbe
driver.
Signed-off-by: default avatarBruce Allan <bruce.w.allan@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8f12fe86
...@@ -1118,8 +1118,8 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw) ...@@ -1118,8 +1118,8 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw)
* set it to full. * set it to full.
*/ */
if ((hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) && if ((hw->mac.type == e1000_82573 || hw->mac.type == e1000_82574) &&
hw->fc.type == e1000_fc_default) hw->fc.requested_mode == e1000_fc_default)
hw->fc.type = e1000_fc_full; hw->fc.requested_mode = e1000_fc_full;
return e1000e_setup_link(hw); return e1000e_setup_link(hw);
} }
......
...@@ -249,7 +249,7 @@ static int e1000_set_settings(struct net_device *netdev, ...@@ -249,7 +249,7 @@ static int e1000_set_settings(struct net_device *netdev,
ADVERTISED_Autoneg; ADVERTISED_Autoneg;
ecmd->advertising = hw->phy.autoneg_advertised; ecmd->advertising = hw->phy.autoneg_advertised;
if (adapter->fc_autoneg) if (adapter->fc_autoneg)
hw->fc.original_type = e1000_fc_default; hw->fc.requested_mode = e1000_fc_default;
} else { } else {
if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
clear_bit(__E1000_RESETTING, &adapter->state); clear_bit(__E1000_RESETTING, &adapter->state);
...@@ -279,11 +279,11 @@ static void e1000_get_pauseparam(struct net_device *netdev, ...@@ -279,11 +279,11 @@ static void e1000_get_pauseparam(struct net_device *netdev,
pause->autoneg = pause->autoneg =
(adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
if (hw->fc.type == e1000_fc_rx_pause) { if (hw->fc.current_mode == e1000_fc_rx_pause) {
pause->rx_pause = 1; pause->rx_pause = 1;
} else if (hw->fc.type == e1000_fc_tx_pause) { } else if (hw->fc.current_mode == e1000_fc_tx_pause) {
pause->tx_pause = 1; pause->tx_pause = 1;
} else if (hw->fc.type == e1000_fc_full) { } else if (hw->fc.current_mode == e1000_fc_full) {
pause->rx_pause = 1; pause->rx_pause = 1;
pause->tx_pause = 1; pause->tx_pause = 1;
} }
...@@ -301,19 +301,8 @@ static int e1000_set_pauseparam(struct net_device *netdev, ...@@ -301,19 +301,8 @@ static int e1000_set_pauseparam(struct net_device *netdev,
while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
msleep(1); msleep(1);
if (pause->rx_pause && pause->tx_pause)
hw->fc.type = e1000_fc_full;
else if (pause->rx_pause && !pause->tx_pause)
hw->fc.type = e1000_fc_rx_pause;
else if (!pause->rx_pause && pause->tx_pause)
hw->fc.type = e1000_fc_tx_pause;
else if (!pause->rx_pause && !pause->tx_pause)
hw->fc.type = e1000_fc_none;
hw->fc.original_type = hw->fc.type;
if (adapter->fc_autoneg == AUTONEG_ENABLE) { if (adapter->fc_autoneg == AUTONEG_ENABLE) {
hw->fc.type = e1000_fc_default; hw->fc.requested_mode = e1000_fc_default;
if (netif_running(adapter->netdev)) { if (netif_running(adapter->netdev)) {
e1000e_down(adapter); e1000e_down(adapter);
e1000e_up(adapter); e1000e_up(adapter);
...@@ -321,6 +310,17 @@ static int e1000_set_pauseparam(struct net_device *netdev, ...@@ -321,6 +310,17 @@ static int e1000_set_pauseparam(struct net_device *netdev,
e1000e_reset(adapter); e1000e_reset(adapter);
} }
} else { } else {
if (pause->rx_pause && pause->tx_pause)
hw->fc.requested_mode = e1000_fc_full;
else if (pause->rx_pause && !pause->tx_pause)
hw->fc.requested_mode = e1000_fc_rx_pause;
else if (!pause->rx_pause && pause->tx_pause)
hw->fc.requested_mode = e1000_fc_tx_pause;
else if (!pause->rx_pause && !pause->tx_pause)
hw->fc.requested_mode = e1000_fc_none;
hw->fc.current_mode = hw->fc.requested_mode;
retval = ((hw->phy.media_type == e1000_media_type_fiber) ? retval = ((hw->phy.media_type == e1000_media_type_fiber) ?
hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw)); hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw));
} }
......
...@@ -437,7 +437,7 @@ enum e1000_rev_polarity{ ...@@ -437,7 +437,7 @@ enum e1000_rev_polarity{
e1000_rev_polarity_undefined = 0xFF e1000_rev_polarity_undefined = 0xFF
}; };
enum e1000_fc_type { enum e1000_fc_mode {
e1000_fc_none = 0, e1000_fc_none = 0,
e1000_fc_rx_pause, e1000_fc_rx_pause,
e1000_fc_tx_pause, e1000_fc_tx_pause,
...@@ -850,8 +850,8 @@ struct e1000_fc_info { ...@@ -850,8 +850,8 @@ struct e1000_fc_info {
u16 pause_time; /* Flow control pause timer */ u16 pause_time; /* Flow control pause timer */
bool send_xon; /* Flow control send XON */ bool send_xon; /* Flow control send XON */
bool strict_ieee; /* Strict IEEE mode */ bool strict_ieee; /* Strict IEEE mode */
enum e1000_fc_type type; /* Type of flow control */ enum e1000_fc_mode current_mode; /* FC mode in effect */
enum e1000_fc_type original_type; enum e1000_fc_mode requested_mode; /* FC mode requested by caller */
}; };
struct e1000_dev_spec_82571 { struct e1000_dev_spec_82571 {
......
...@@ -2071,12 +2071,17 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) ...@@ -2071,12 +2071,17 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
* the default flow control setting, so we explicitly * the default flow control setting, so we explicitly
* set it to full. * set it to full.
*/ */
if (hw->fc.type == e1000_fc_default) if (hw->fc.requested_mode == e1000_fc_default)
hw->fc.type = e1000_fc_full; hw->fc.requested_mode = e1000_fc_full;
hw->fc.original_type = hw->fc.type; /*
* Save off the requested flow control mode for use later. Depending
* on the link partner's capabilities, we may or may not use this mode.
*/
hw->fc.current_mode = hw->fc.requested_mode;
hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", hw->fc.type); hw_dbg(hw, "After fix-ups FlowControl is now = %x\n",
hw->fc.current_mode);
/* Continue to configure the copper link. */ /* Continue to configure the copper link. */
ret_val = e1000_setup_copper_link_ich8lan(hw); ret_val = e1000_setup_copper_link_ich8lan(hw);
......
...@@ -645,12 +645,12 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) ...@@ -645,12 +645,12 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
} }
if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0)
hw->fc.type = e1000_fc_none; hw->fc.requested_mode = e1000_fc_none;
else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) ==
NVM_WORD0F_ASM_DIR) NVM_WORD0F_ASM_DIR)
hw->fc.type = e1000_fc_tx_pause; hw->fc.requested_mode = e1000_fc_tx_pause;
else else
hw->fc.type = e1000_fc_full; hw->fc.requested_mode = e1000_fc_full;
return 0; return 0;
} }
...@@ -678,23 +678,23 @@ s32 e1000e_setup_link(struct e1000_hw *hw) ...@@ -678,23 +678,23 @@ s32 e1000e_setup_link(struct e1000_hw *hw)
return 0; return 0;
/* /*
* If flow control is set to default, set flow control based on * If requested flow control is set to default, set flow control
* the EEPROM flow control settings. * based on the EEPROM flow control settings.
*/ */
if (hw->fc.type == e1000_fc_default) { if (hw->fc.requested_mode == e1000_fc_default) {
ret_val = e1000_set_default_fc_generic(hw); ret_val = e1000_set_default_fc_generic(hw);
if (ret_val) if (ret_val)
return ret_val; return ret_val;
} }
/* /*
* We want to save off the original Flow Control configuration just * Save off the requested flow control mode for use later. Depending
* in case we get disconnected and then reconnected into a different * on the link partner's capabilities, we may or may not use this mode.
* hub or switch with different Flow Control capabilities.
*/ */
hw->fc.original_type = hw->fc.type; hw->fc.current_mode = hw->fc.requested_mode;
hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", hw->fc.type); hw_dbg(hw, "After fix-ups FlowControl is now = %x\n",
hw->fc.current_mode);
/* Call the necessary media_type subroutine to configure the link. */ /* Call the necessary media_type subroutine to configure the link. */
ret_val = mac->ops.setup_physical_interface(hw); ret_val = mac->ops.setup_physical_interface(hw);
...@@ -746,7 +746,7 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw) ...@@ -746,7 +746,7 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
* do not support receiving pause frames). * do not support receiving pause frames).
* 3: Both Rx and Tx flow control (symmetric) are enabled. * 3: Both Rx and Tx flow control (symmetric) are enabled.
*/ */
switch (hw->fc.type) { switch (hw->fc.current_mode) {
case e1000_fc_none: case e1000_fc_none:
/* Flow control completely disabled by a software over-ride. */ /* Flow control completely disabled by a software over-ride. */
txcw = (E1000_TXCW_ANE | E1000_TXCW_FD); txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
...@@ -928,7 +928,7 @@ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) ...@@ -928,7 +928,7 @@ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw)
* ability to transmit pause frames is not enabled, then these * ability to transmit pause frames is not enabled, then these
* registers will be set to 0. * registers will be set to 0.
*/ */
if (hw->fc.type & e1000_fc_tx_pause) { if (hw->fc.current_mode & e1000_fc_tx_pause) {
/* /*
* We need to set up the Receive Threshold high and low water * We need to set up the Receive Threshold high and low water
* marks as well as (optionally) enabling the transmission of * marks as well as (optionally) enabling the transmission of
...@@ -967,7 +967,7 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw) ...@@ -967,7 +967,7 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw)
* receive flow control. * receive flow control.
* *
* The "Case" statement below enables/disable flow control * The "Case" statement below enables/disable flow control
* according to the "hw->fc.type" parameter. * according to the "hw->fc.current_mode" parameter.
* *
* The possible values of the "fc" parameter are: * The possible values of the "fc" parameter are:
* 0: Flow control is completely disabled * 0: Flow control is completely disabled
...@@ -978,9 +978,9 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw) ...@@ -978,9 +978,9 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw)
* 3: Both Rx and Tx flow control (symmetric) is enabled. * 3: Both Rx and Tx flow control (symmetric) is enabled.
* other: No other values should be possible at this point. * other: No other values should be possible at this point.
*/ */
hw_dbg(hw, "hw->fc.type = %u\n", hw->fc.type); hw_dbg(hw, "hw->fc.current_mode = %u\n", hw->fc.current_mode);
switch (hw->fc.type) { switch (hw->fc.current_mode) {
case e1000_fc_none: case e1000_fc_none:
ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE)); ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
break; break;
...@@ -1124,11 +1124,11 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) ...@@ -1124,11 +1124,11 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
* ONLY. Hence, we must now check to see if we need to * ONLY. Hence, we must now check to see if we need to
* turn OFF the TRANSMISSION of PAUSE frames. * turn OFF the TRANSMISSION of PAUSE frames.
*/ */
if (hw->fc.original_type == e1000_fc_full) { if (hw->fc.requested_mode == e1000_fc_full) {
hw->fc.type = e1000_fc_full; hw->fc.current_mode = e1000_fc_full;
hw_dbg(hw, "Flow Control = FULL.\r\n"); hw_dbg(hw, "Flow Control = FULL.\r\n");
} else { } else {
hw->fc.type = e1000_fc_rx_pause; hw->fc.current_mode = e1000_fc_rx_pause;
hw_dbg(hw, "Flow Control = " hw_dbg(hw, "Flow Control = "
"RX PAUSE frames only.\r\n"); "RX PAUSE frames only.\r\n");
} }
...@@ -1146,7 +1146,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) ...@@ -1146,7 +1146,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
(mii_nway_adv_reg & NWAY_AR_ASM_DIR) && (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
(mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
hw->fc.type = e1000_fc_tx_pause; hw->fc.current_mode = e1000_fc_tx_pause;
hw_dbg(hw, "Flow Control = Tx PAUSE frames only.\r\n"); hw_dbg(hw, "Flow Control = Tx PAUSE frames only.\r\n");
} }
/* /*
...@@ -1162,14 +1162,14 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) ...@@ -1162,14 +1162,14 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
(mii_nway_adv_reg & NWAY_AR_ASM_DIR) && (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
!(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
(mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
hw->fc.type = e1000_fc_rx_pause; hw->fc.current_mode = e1000_fc_rx_pause;
hw_dbg(hw, "Flow Control = Rx PAUSE frames only.\r\n"); hw_dbg(hw, "Flow Control = Rx PAUSE frames only.\r\n");
} else { } else {
/* /*
* Per the IEEE spec, at this point flow control * Per the IEEE spec, at this point flow control
* should be disabled. * should be disabled.
*/ */
hw->fc.type = e1000_fc_none; hw->fc.current_mode = e1000_fc_none;
hw_dbg(hw, "Flow Control = NONE.\r\n"); hw_dbg(hw, "Flow Control = NONE.\r\n");
} }
...@@ -1185,7 +1185,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) ...@@ -1185,7 +1185,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
} }
if (duplex == HALF_DUPLEX) if (duplex == HALF_DUPLEX)
hw->fc.type = e1000_fc_none; hw->fc.current_mode = e1000_fc_none;
/* /*
* Now we call a subroutine to actually force the MAC * Now we call a subroutine to actually force the MAC
......
...@@ -2785,7 +2785,7 @@ void e1000e_reset(struct e1000_adapter *adapter) ...@@ -2785,7 +2785,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
else else
fc->pause_time = E1000_FC_PAUSE_TIME; fc->pause_time = E1000_FC_PAUSE_TIME;
fc->send_xon = 1; fc->send_xon = 1;
fc->type = fc->original_type; fc->current_mode = fc->requested_mode;
/* Allow time for pending master requests to run */ /* Allow time for pending master requests to run */
mac->ops.reset_hw(hw); mac->ops.reset_hw(hw);
...@@ -4983,8 +4983,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -4983,8 +4983,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
/* Initialize link parameters. User can change them with ethtool */ /* Initialize link parameters. User can change them with ethtool */
adapter->hw.mac.autoneg = 1; adapter->hw.mac.autoneg = 1;
adapter->fc_autoneg = 1; adapter->fc_autoneg = 1;
adapter->hw.fc.original_type = e1000_fc_default; adapter->hw.fc.requested_mode = e1000_fc_default;
adapter->hw.fc.type = e1000_fc_default; adapter->hw.fc.current_mode = e1000_fc_default;
adapter->hw.phy.autoneg_advertised = 0x2f; adapter->hw.phy.autoneg_advertised = 0x2f;
/* ring size defaults */ /* ring size defaults */
......
...@@ -744,7 +744,7 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw) ...@@ -744,7 +744,7 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)
* other: No software override. The flow control configuration * other: No software override. The flow control configuration
* in the EEPROM is used. * in the EEPROM is used.
*/ */
switch (hw->fc.type) { switch (hw->fc.current_mode) {
case e1000_fc_none: case e1000_fc_none:
/* /*
* Flow control (Rx & Tx) is completely disabled by a * Flow control (Rx & Tx) is completely disabled by a
...@@ -1114,7 +1114,7 @@ void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) ...@@ -1114,7 +1114,7 @@ void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl)
u32 ctrl; u32 ctrl;
/* Turn off flow control when forcing speed/duplex */ /* Turn off flow control when forcing speed/duplex */
hw->fc.type = e1000_fc_none; hw->fc.current_mode = e1000_fc_none;
/* Force speed/duplex on the mac */ /* Force speed/duplex on the mac */
ctrl = er32(CTRL); ctrl = er32(CTRL);
......
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