On Tue, Mar 17, 2009 at 07:44:43AM +0000, Bruce Simpson wrote:
> Hi,
> 
> I noticed that ae(4) got MFC'ed to RELENG_7 before Wake-on-Lan support did.
> 

I think WOL MFC was done before ae(4) MFC.

> However, WOL support is now there, and it looks like the change can just 
> go in:
>    
> http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/ae/if_ae.c.diff?r1=1.1.2%3ARELENG_7&tr1=1.1&r2=1.3%3AHEAD&tr2=1.3
> 
> I am tied up looking at other stuff at the moment, it would be nice to 
> merge the change, but low priority for me right now.
> 

Do you have ae(4) hardware? I'm not sure why stas@ removed WOL part
in the MFC but it could be lack of testing(CCed to stas@). I've
attached diff that includes WOL support from HEAD.

> BTW, it still seems easier to use cvsweb to pull a diff between FreeBSD 
> branches since the SVN change,
> does anyone know an easier way?
> 
> thanks
> BMS
Index: sys/dev/ae/if_ae.c
===================================================================
--- sys/dev/ae/if_ae.c	(revision 189940)
+++ sys/dev/ae/if_ae.c	(working copy)
@@ -380,8 +380,10 @@
 	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
 	IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
 	IFQ_SET_READY(&ifp->if_snd);
-	if (pci_find_extcap(dev, PCIY_PMG, &pmc) == 0)
+	if (pci_find_extcap(dev, PCIY_PMG, &pmc) == 0) {
+		ifp->if_capabilities |= IFCAP_WOL_MAGIC;
 		sc->flags |= AE_FLAG_PMG;
+	}
 	ifp->if_capenable = ifp->if_capabilities;
 
 	/*
@@ -1329,6 +1331,7 @@
 	struct ifnet *ifp;
 	uint32_t val;
 	uint16_t pmstat;
+	struct mii_data *mii;
 	int pmc;
 
 	AE_LOCK_ASSERT(sc);
@@ -1340,8 +1343,41 @@
 		return;
 	}
 
-	ae_powersave_enable(sc);
+	/*
+	 * Configure WOL if enabled.
+	 */
+	if ((ifp->if_capenable & IFCAP_WOL) != 0) {
+		mii = device_get_softc(sc->miibus);
+		mii_pollstat(mii);
+		if ((mii->mii_media_status & IFM_AVALID) != 0 &&
+		    (mii->mii_media_status & IFM_ACTIVE) != 0) {
+			AE_WRITE_4(sc, AE_WOL_REG, AE_WOL_MAGIC | \
+			    AE_WOL_MAGIC_PME);
 
+			/*
+			 * Configure MAC.
+			 */
+			val = AE_MAC_RX_EN | AE_MAC_CLK_PHY | \
+			    AE_MAC_TX_CRC_EN | AE_MAC_TX_AUTOPAD | \
+			    ((AE_HALFBUF_DEFAULT << AE_HALFBUF_SHIFT) & \
+			    AE_HALFBUF_MASK) | \
+			    ((AE_MAC_PREAMBLE_DEFAULT << \
+			    AE_MAC_PREAMBLE_SHIFT) & AE_MAC_PREAMBLE_MASK) | \
+			    AE_MAC_BCAST_EN | AE_MAC_MCAST_EN;
+			if ((IFM_OPTIONS(mii->mii_media_active) & \
+			    IFM_FDX) != 0)
+				val |= AE_MAC_FULL_DUPLEX;
+			AE_WRITE_4(sc, AE_MAC_REG, val);
+			    
+		} else {	/* No link. */
+			AE_WRITE_4(sc, AE_WOL_REG, AE_WOL_LNKCHG | \
+			    AE_WOL_LNKCHG_PME);
+			AE_WRITE_4(sc, AE_MAC_REG, 0);
+		}
+	} else {
+		ae_powersave_enable(sc);
+	}
+
 	/*
 	 * PCIE hacks. Magic numbers.
 	 */
@@ -1358,6 +1394,8 @@
 	pci_find_extcap(sc->dev, PCIY_PMG, &pmc);
 	pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2);
 	pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
+	if ((ifp->if_capenable & IFCAP_WOL) != 0)
+		pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
 	pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
 }
 
_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to