FreeBSD Bugzilla – Attachment 156970 Details for
Bug 177184
[bge] Enable wake on lan (WoL)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Almost working patch
bge.diff (text/plain), 2.74 KB, created by
Cy Schubert
on 2015-05-20 03:20:02 UTC
(
hide
)
Description:
Almost working patch
Filename:
MIME Type:
Creator:
Cy Schubert
Created:
2015-05-20 03:20:02 UTC
Size:
2.74 KB
patch
obsolete
>Index: if_bge.c >=================================================================== >--- if_bge.c (revision 283015) >+++ if_bge.c (working copy) >@@ -487,6 +487,7 @@ > static void bge_stop_fw(struct bge_softc *); > static int bge_reset(struct bge_softc *); > static void bge_link_upd(struct bge_softc *); >+static void bge_setwol(struct bge_softc *); > > static void bge_ape_lock_init(struct bge_softc *); > static void bge_ape_read_fw_ver(struct bge_softc *); >@@ -3742,7 +3743,7 @@ > if_setsendqready(ifp); > if_sethwassist(ifp, sc->bge_csum_features); > if_setcapabilities(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING | >- IFCAP_VLAN_MTU); >+ IFCAP_VLAN_MTU | IFCAP_WOL_MAGIC); > if ((sc->bge_flags & (BGE_FLAG_TSO | BGE_FLAG_TSO3)) != 0) { > if_sethwassistbits(ifp, CSUM_TSO, 0); > if_setcapabilitiesbit(ifp, IFCAP_TSO4 | IFCAP_VLAN_HWTSO, 0); >@@ -3750,6 +3751,8 @@ > #ifdef IFCAP_VLAN_HWCSUM > if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWCSUM, 0); > #endif >+ if (pci_find_cap(dev, PCIY_PMG, ®) == 0) >+ if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC, 0); > if_setcapenable(ifp, if_getcapabilities(ifp)); > #ifdef DEVICE_POLLING > if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0); >@@ -5847,6 +5850,9 @@ > } > } > #endif >+ if ((mask & IFCAP_WOL_MAGIC) != 0 && >+ (if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) != 0) >+ if_togglecapenable(ifp, IFCAP_WOL_MAGIC); > if ((mask & IFCAP_TXCSUM) != 0 && > (if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) { > if_togglecapenable(ifp, IFCAP_TXCSUM); >@@ -6075,6 +6081,7 @@ > sc = device_get_softc(dev); > BGE_LOCK(sc); > bge_stop(sc); >+ bge_setwol(sc); > BGE_UNLOCK(sc); > > return (0); >@@ -6088,6 +6095,7 @@ > sc = device_get_softc(dev); > BGE_LOCK(sc); > bge_stop(sc); >+ bge_setwol(sc); > BGE_UNLOCK(sc); > > return (0); >@@ -6788,3 +6796,36 @@ > return (if_get_counter_default(ifp, cnt)); > } > } >+ >+static void >+bge_setwol(struct bge_softc *sc) >+{ >+ struct ifnet *ifp; >+ uint16_t pmstat; >+ int pmc; >+ >+ BGE_LOCK_ASSERT(sc); >+ >+ if (pci_find_cap(sc->bge_dev, PCIY_PMG, &pmc) != 0) >+ return; >+ ifp = sc->bge_ifp; >+ if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0) >+ return; >+ if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0) { >+ BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_MAGIC_PKT_ENB); >+ BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE); >+ BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII); >+ BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); >+ } >+ else { >+ BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_MAGIC_PKT_ENB); >+ } >+ >+ /* Request PME if WOL is requested. */ >+ pmstat = pci_read_config(sc->bge_dev, pmc + PCIR_POWER_STATUS, 2); >+ pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); >+ if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) >+ pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; >+ pci_write_config(sc->bge_dev, pmc + PCIR_POWER_STATUS, pmstat, 2); >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 177184
:
132818
| 156970