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: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Jeff Pieper <jeffrey.e.pieper@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
69ad78208e
commit
0c6bdb3084
|
@ -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_tx_resources(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_reset_interrupt_capability(struct e1000_adapter *adapter);
|
||||
extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
|
||||
|
|
|
@ -118,7 +118,6 @@ static int e1000_get_settings(struct net_device *netdev,
|
|||
{
|
||||
struct e1000_adapter *adapter = netdev_priv(netdev);
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
u32 status;
|
||||
|
||||
if (hw->phy.media_type == e1000_media_type_copper) {
|
||||
|
||||
|
@ -156,22 +155,29 @@ static int e1000_get_settings(struct net_device *netdev,
|
|||
ecmd->transceiver = XCVR_EXTERNAL;
|
||||
}
|
||||
|
||||
status = er32(STATUS);
|
||||
if (status & E1000_STATUS_LU) {
|
||||
if (status & E1000_STATUS_SPEED_1000)
|
||||
ecmd->speed = 1000;
|
||||
else if (status & E1000_STATUS_SPEED_100)
|
||||
ecmd->speed = 100;
|
||||
else
|
||||
ecmd->speed = 10;
|
||||
ecmd->speed = -1;
|
||||
ecmd->duplex = -1;
|
||||
|
||||
if (status & E1000_STATUS_FD)
|
||||
ecmd->duplex = DUPLEX_FULL;
|
||||
else
|
||||
ecmd->duplex = DUPLEX_HALF;
|
||||
if (netif_running(netdev)) {
|
||||
if (netif_carrier_ok(netdev)) {
|
||||
ecmd->speed = adapter->link_speed;
|
||||
ecmd->duplex = adapter->link_duplex - 1;
|
||||
}
|
||||
} else {
|
||||
ecmd->speed = -1;
|
||||
ecmd->duplex = -1;
|
||||
u32 status = er32(STATUS);
|
||||
if (status & E1000_STATUS_LU) {
|
||||
if (status & E1000_STATUS_SPEED_1000)
|
||||
ecmd->speed = 1000;
|
||||
else if (status & E1000_STATUS_SPEED_100)
|
||||
ecmd->speed = 100;
|
||||
else
|
||||
ecmd->speed = 10;
|
||||
|
||||
if (status & E1000_STATUS_FD)
|
||||
ecmd->duplex = DUPLEX_FULL;
|
||||
else
|
||||
ecmd->duplex = DUPLEX_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
|
||||
|
@ -179,7 +185,7 @@ static int e1000_get_settings(struct net_device *netdev,
|
|||
|
||||
/* MDI-X => 2; MDI =>1; Invalid =>0 */
|
||||
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 :
|
||||
ETH_TP_MDI;
|
||||
else
|
||||
|
@ -191,19 +197,15 @@ static int e1000_get_settings(struct net_device *netdev,
|
|||
static u32 e1000_get_link(struct net_device *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,
|
||||
* and so the physical link state may have changed since we last
|
||||
* looked. Set get_link_status to make sure that the true link
|
||||
* state is interrogated, rather than pulling a cached and possibly
|
||||
* stale link state from the driver.
|
||||
* 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 link is up.
|
||||
*/
|
||||
if (!netif_carrier_ok(netdev))
|
||||
mac->get_link_status = 1;
|
||||
|
||||
return e1000e_has_link(adapter);
|
||||
return netif_running(netdev) ? netif_carrier_ok(netdev) :
|
||||
!!(er32(STATUS) & E1000_STATUS_LU);
|
||||
}
|
||||
|
||||
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)
|
|||
((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;
|
||||
bool link_active = 0;
|
||||
|
|
Loading…
Reference in New Issue