-
Notifications
You must be signed in to change notification settings - Fork 2
/
if_bge.c.patch
64 lines (61 loc) · 1.72 KB
/
if_bge.c.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- if_bge.c.orig 2017-07-15 19:41:51.714981200 +1000
+++ if_bge.c 2017-07-15 19:42:06.499867000 +1000
@@ -489,6 +489,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 *);
@@ -3748,7 +3749,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);
@@ -6081,6 +6082,7 @@
sc = device_get_softc(dev);
BGE_LOCK(sc);
bge_stop(sc);
+ bge_setwol(sc);
BGE_UNLOCK(sc);
return (0);
@@ -6773,6 +6775,36 @@
return (*func == NULL ? ENXIO : 0);
}
+static void
+bge_setwol(struct bge_softc *sc)
+{
+ struct ifnet *ifp;
+ uint16_t pmstat;
+ int pmc;
+
+ ifp = sc->bge_ifp;
+
+ if ((ifp->if_capenable & IFCAP_WOL_MAGIC) == 0)
+ return;
+
+ if (pci_find_cap(sc->bge_dev, PCIY_PMG, &pmc) != 0)
+ return;
+
+ 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);
+
+ /* Request PME. */
+ pmstat = pci_read_config(sc->bge_dev,
+ pmc + PCIR_POWER_STATUS, 2);
+ pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
+ pci_write_config(sc->bge_dev,
+ pmc + PCIR_POWER_STATUS, pmstat, 2);
+}
+
static uint64_t
bge_get_counter(if_t ifp, ift_counter cnt)
{