Don't set any WOL enabling hardware bits if WOL isn't requested
according to the enabled interface capability bits. Also remove some dead code, which tried to preserve already set contents of E1000_WUC while that register is completely overwritten shortly after in all cases.
This commit is contained in:
parent
7023d9d4c6
commit
e023501c6a
@ -3639,34 +3639,13 @@ em_enable_wakeup(if_ctx_t ctx)
|
||||
struct adapter *adapter = iflib_get_softc(ctx);
|
||||
device_t dev = iflib_get_dev(ctx);
|
||||
if_t ifp = iflib_get_ifp(ctx);
|
||||
u32 pmc, ctrl, ctrl_ext, rctl, wuc;
|
||||
int error = 0;
|
||||
u32 pmc, ctrl, ctrl_ext, rctl;
|
||||
u16 status;
|
||||
|
||||
if ((pci_find_cap(dev, PCIY_PMG, &pmc) != 0))
|
||||
if (pci_find_cap(dev, PCIY_PMG, &pmc) != 0)
|
||||
return;
|
||||
|
||||
/* Advertise the wakeup capability */
|
||||
ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL);
|
||||
ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3);
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl);
|
||||
wuc = E1000_READ_REG(&adapter->hw, E1000_WUC);
|
||||
wuc |= (E1000_WUC_PME_EN | E1000_WUC_APME);
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_WUC, wuc);
|
||||
|
||||
if ((adapter->hw.mac.type == e1000_ich8lan) ||
|
||||
(adapter->hw.mac.type == e1000_pchlan) ||
|
||||
(adapter->hw.mac.type == e1000_ich9lan) ||
|
||||
(adapter->hw.mac.type == e1000_ich10lan))
|
||||
e1000_suspend_workarounds_ich8lan(&adapter->hw);
|
||||
|
||||
/* Keep the laser running on Fiber adapters */
|
||||
if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
|
||||
adapter->hw.phy.media_type == e1000_media_type_internal_serdes) {
|
||||
ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT);
|
||||
ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, ctrl_ext);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine type of Wakeup: note that wol
|
||||
* is set with all bits on by default.
|
||||
@ -3685,10 +3664,34 @@ em_enable_wakeup(if_ctx_t ctx)
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, rctl);
|
||||
}
|
||||
|
||||
if (!(adapter->wol & (E1000_WUFC_EX | E1000_WUFC_MAG | E1000_WUFC_MC)))
|
||||
goto pme;
|
||||
|
||||
/* Advertise the wakeup capability */
|
||||
ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL);
|
||||
ctrl |= (E1000_CTRL_SWDPIN2 | E1000_CTRL_SWDPIN3);
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl);
|
||||
|
||||
/* Keep the laser running on Fiber adapters */
|
||||
if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
|
||||
adapter->hw.phy.media_type == e1000_media_type_internal_serdes) {
|
||||
ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT);
|
||||
ctrl_ext |= E1000_CTRL_EXT_SDP3_DATA;
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, ctrl_ext);
|
||||
}
|
||||
|
||||
if ((adapter->hw.mac.type == e1000_ich8lan) ||
|
||||
(adapter->hw.mac.type == e1000_pchlan) ||
|
||||
(adapter->hw.mac.type == e1000_ich9lan) ||
|
||||
(adapter->hw.mac.type == e1000_ich10lan))
|
||||
e1000_suspend_workarounds_ich8lan(&adapter->hw);
|
||||
|
||||
if ( adapter->hw.mac.type >= e1000_pchlan) {
|
||||
if (em_enable_phy_wakeup(adapter))
|
||||
return;
|
||||
error = em_enable_phy_wakeup(adapter);
|
||||
if (error)
|
||||
goto pme;
|
||||
} else {
|
||||
/* Enable wakeup by the MAC */
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_WUC, E1000_WUC_PME_EN);
|
||||
E1000_WRITE_REG(&adapter->hw, E1000_WUFC, adapter->wol);
|
||||
}
|
||||
@ -3696,10 +3699,10 @@ em_enable_wakeup(if_ctx_t ctx)
|
||||
if (adapter->hw.phy.type == e1000_phy_igp_3)
|
||||
e1000_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
|
||||
|
||||
/* Request PME */
|
||||
pme:
|
||||
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2);
|
||||
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
||||
if (if_getcapenable(ifp) & IFCAP_WOL)
|
||||
if (!error && (if_getcapenable(ifp) & IFCAP_WOL))
|
||||
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
||||
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 2);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user