Commit 0c6bdb30 authored by Bruce Allan's avatar Bruce Allan Committed by David S. Miller

e1000e: avoid polling h/w registers during link negotiation

Avoid touching hardware registers when possible, otherwise link negotiation
can get messed up when user-level scripts are rapidly polling the driver to
see if/when link is up.  Use the saved link state information instead when
possible.
Signed-off-by: default avatarBruce Allan <bruce.w.allan@intel.com>
Tested-by: default avatarJeff Pieper <jeffrey.e.pieper@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 69ad7820
...@@ -461,7 +461,6 @@ extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter); ...@@ -461,7 +461,6 @@ extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter);
extern void e1000e_free_rx_resources(struct e1000_adapter *adapter); extern void e1000e_free_rx_resources(struct e1000_adapter *adapter);
extern void e1000e_free_tx_resources(struct e1000_adapter *adapter); extern void e1000e_free_tx_resources(struct e1000_adapter *adapter);
extern void e1000e_update_stats(struct e1000_adapter *adapter); extern void e1000e_update_stats(struct e1000_adapter *adapter);
extern bool e1000e_has_link(struct e1000_adapter *adapter);
extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state); extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
......
...@@ -118,7 +118,6 @@ static int e1000_get_settings(struct net_device *netdev, ...@@ -118,7 +118,6 @@ static int e1000_get_settings(struct net_device *netdev,
{ {
struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
u32 status;
if (hw->phy.media_type == e1000_media_type_copper) { if (hw->phy.media_type == e1000_media_type_copper) {
...@@ -156,7 +155,16 @@ static int e1000_get_settings(struct net_device *netdev, ...@@ -156,7 +155,16 @@ static int e1000_get_settings(struct net_device *netdev,
ecmd->transceiver = XCVR_EXTERNAL; ecmd->transceiver = XCVR_EXTERNAL;
} }
status = er32(STATUS); ecmd->speed = -1;
ecmd->duplex = -1;
if (netif_running(netdev)) {
if (netif_carrier_ok(netdev)) {
ecmd->speed = adapter->link_speed;
ecmd->duplex = adapter->link_duplex - 1;
}
} else {
u32 status = er32(STATUS);
if (status & E1000_STATUS_LU) { if (status & E1000_STATUS_LU) {
if (status & E1000_STATUS_SPEED_1000) if (status & E1000_STATUS_SPEED_1000)
ecmd->speed = 1000; ecmd->speed = 1000;
...@@ -169,9 +177,7 @@ static int e1000_get_settings(struct net_device *netdev, ...@@ -169,9 +177,7 @@ static int e1000_get_settings(struct net_device *netdev,
ecmd->duplex = DUPLEX_FULL; ecmd->duplex = DUPLEX_FULL;
else else
ecmd->duplex = DUPLEX_HALF; ecmd->duplex = DUPLEX_HALF;
} else { }
ecmd->speed = -1;
ecmd->duplex = -1;
} }
ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) || ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
...@@ -179,7 +185,7 @@ static int e1000_get_settings(struct net_device *netdev, ...@@ -179,7 +185,7 @@ static int e1000_get_settings(struct net_device *netdev,
/* MDI-X => 2; MDI =>1; Invalid =>0 */ /* MDI-X => 2; MDI =>1; Invalid =>0 */
if ((hw->phy.media_type == e1000_media_type_copper) && if ((hw->phy.media_type == e1000_media_type_copper) &&
!hw->mac.get_link_status) netif_carrier_ok(netdev))
ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X : ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X :
ETH_TP_MDI; ETH_TP_MDI;
else else
...@@ -191,19 +197,15 @@ static int e1000_get_settings(struct net_device *netdev, ...@@ -191,19 +197,15 @@ static int e1000_get_settings(struct net_device *netdev,
static u32 e1000_get_link(struct net_device *netdev) static u32 e1000_get_link(struct net_device *netdev)
{ {
struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_mac_info *mac = &adapter->hw.mac; struct e1000_hw *hw = &adapter->hw;
/* /*
* If the link is not reported up to netdev, interrupts are disabled, * Avoid touching hardware registers when possible, otherwise
* and so the physical link state may have changed since we last * link negotiation can get messed up when user-level scripts
* looked. Set get_link_status to make sure that the true link * are rapidly polling the driver to see if link is up.
* state is interrogated, rather than pulling a cached and possibly
* stale link state from the driver.
*/ */
if (!netif_carrier_ok(netdev)) return netif_running(netdev) ? netif_carrier_ok(netdev) :
mac->get_link_status = 1; !!(er32(STATUS) & E1000_STATUS_LU);
return e1000e_has_link(adapter);
} }
static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
......
...@@ -3964,7 +3964,7 @@ static void e1000_print_link_info(struct e1000_adapter *adapter) ...@@ -3964,7 +3964,7 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)
((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" ))); ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" )));
} }
bool e1000e_has_link(struct e1000_adapter *adapter) static bool e1000e_has_link(struct e1000_adapter *adapter)
{ {
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
bool link_active = 0; bool link_active = 0;
......
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