From owner-freebsd-net@FreeBSD.ORG Wed Mar 18 00:39:44 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FD6A1065695 for ; Wed, 18 Mar 2009 00:39:44 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.240]) by mx1.freebsd.org (Postfix) with ESMTP id C5F768FC14 for ; Wed, 18 Mar 2009 00:39:43 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by an-out-0708.google.com with SMTP id d11so214401and.13 for ; Tue, 17 Mar 2009 17:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:date:to:cc :subject:message-id:reply-to:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=3lReCweNE40BgyTImt6kh7xLR/v5H9+nUgj/S0qWB+w=; b=BmzC/WvJlpJkUOC6ylNsII6X7msHxv3kCiH8g5aNhOtp0HiPtA7BrnBnZd0UC7S+Cz +ONcSnr3kaab+ZpQwiIo0ikzMLVgNKW8YF3y4MhXp9QxIkih/mhW0cVpc6a0GnUnZTk1 c2EnMoo5hU/qIBfujAwa+03HiAoXjO4IecSdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=hfVvAHO7jhNj7doqYJl5/Gougf2273MoCEA0OfIjR4AlQ/seHSrs9xcTxdyhDF0Lwu 6YvXIkxSH7gRYiULodP4vCNQWn4drTQNFrPofqbCRcXojHA9SHz72PKBX1ZcEFDEN18J SNT15ur96w4UTdFRQnTDM3lfOqaMRHvpkzEn4= Received: by 10.100.142.4 with SMTP id p4mr947922and.23.1237336783070; Tue, 17 Mar 2009 17:39:43 -0700 (PDT) Received: from michelle.cdnetworks.co.kr ([114.111.62.249]) by mx.google.com with ESMTPS id d12sm3356008and.24.2009.03.17.17.39.39 (version=SSLv3 cipher=RC4-MD5); Tue, 17 Mar 2009 17:39:41 -0700 (PDT) Received: by michelle.cdnetworks.co.kr (sSMTP sendmail emulation); Wed, 18 Mar 2009 09:39:44 +0900 From: Pyun YongHyeon Date: Wed, 18 Mar 2009 09:39:44 +0900 To: Bruce Simpson Message-ID: <20090318003944.GA41410@michelle.cdnetworks.co.kr> References: <49BF54EB.3070800@incunabulum.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline In-Reply-To: <49BF54EB.3070800@incunabulum.net> User-Agent: Mutt/1.4.2.3i Cc: stas@FreeBSD.org, FreeBSD Net , imp@freebsd.org Subject: Re: ae(4) Wake-on-Lan MFC X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2009 00:39:44 -0000 --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --k+w/mQv8wyuph6w0 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ae.wol.diff" 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); } --k+w/mQv8wyuph6w0--