From owner-freebsd-usb@FreeBSD.ORG Thu Feb 12 04:28:00 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A3541065673; Thu, 12 Feb 2009 04:28:00 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-gx0-f176.google.com (mail-gx0-f176.google.com [209.85.217.176]) by mx1.freebsd.org (Postfix) with ESMTP id 8374E8FC1D; Thu, 12 Feb 2009 04:27:59 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by gxk24 with SMTP id 24so64325gxk.19 for ; Wed, 11 Feb 2009 20:27:58 -0800 (PST) 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=anQbrMg8XXG3cuQvNMA+wbKw92lCdM7/Zv0a3akJKq4=; b=NqE6Fne+NQD0rA+SuhiYN700N1jjwqVk5xbYKQ2ltPcU43+vUzMWh9YXXz48c6V/SQ bcf9s2dKxeTP0Ck1OpfTUPxIv/idjPbzsTHQ/sh0LXhKEftsBq+yNxgXKzA0AiMW3uFf 9az9dc0HHGSLB8hoJwIFWgGkgfN9bGHCiYP/k= 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=SJQA0RyWJMxKKTsomWwmiZghc4peChru59eeNNVdapizt8OHNxnJHZShnX6F7An3Rr gb/FDUxN5EB3dFAk0mbDHAtdD5+Fq5ZAQ6hD7vi3JzQ+k+uhGJF5ByvLsRE3cqby+G9U MR0IJRUJADonOTSwdwlPEDc6fXs85MUraxKi0= Received: by 10.151.111.15 with SMTP id o15mr563225ybm.214.1234412878794; Wed, 11 Feb 2009 20:27:58 -0800 (PST) Received: from michelle.cdnetworks.co.kr ([114.111.62.249]) by mx.google.com with ESMTPS id o29sm1541916elf.9.2009.02.11.20.27.55 (version=SSLv3 cipher=RC4-MD5); Wed, 11 Feb 2009 20:27:57 -0800 (PST) Received: by michelle.cdnetworks.co.kr (sSMTP sendmail emulation); Thu, 12 Feb 2009 13:30:33 +0900 From: Pyun YongHyeon Date: Thu, 12 Feb 2009 13:30:33 +0900 To: Hiroharu Tamaru Message-ID: <20090212043033.GC6313@michelle.cdnetworks.co.kr> References: <200902110954.37659.hselasky@c2i.net> <200902111657.38129.hselasky@c2i.net> <20090212023723.GA6313@michelle.cdnetworks.co.kr> <20090212034251.GB6313@michelle.cdnetworks.co.kr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="uZ3hkaAS1mZxFaxD" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: thompsa@freebsd.org, freebsd-usb@freebsd.org Subject: Re: USB2: [was: umass not detected correctly, axe not transmitting] AXE problems X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 04:28:00 -0000 --uZ3hkaAS1mZxFaxD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 12, 2009 at 12:59:13PM +0900, Hiroharu Tamaru wrote: > I've just sent another message before reading this. > > At Thu, 12 Feb 2009 12:42:51 +0900, Pyun YongHyeon wrote: > > On Thu, Feb 12, 2009 at 11:37:23AM +0900, Pyun YongHyeon wrote: > > > On Thu, Feb 12, 2009 at 01:51:47AM +0900, Hiroharu Tamaru wrote: > > > > > > > > At Wed, 11 Feb 2009 16:57:36 +0100, Hans Petter Selasky wrote: > > > > > > > > ugen3.3: at usbus3 > > > > > > > > axe0: on usbus3 > > > > > > > > axe0: PHYADDR 0xe0:0x18 > > > > > > > > miibus0: on axe0 > > > > > > > > ciphy0: PHY 24 on miibus0 > > > > > > > > ciphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, > > > > > > > > 1000baseT-FDX, auto ue0: on axe0 > > > > > > > > ue0: Ethernet address: 00:90:cc:xx:xx:xx > > > > > > > > ue0: link state changed to DOWN > > > > > > > > ue0: link state changed to UP > > > > > > > > > > > > > > > > > > > > > > > > > > > Turn on debugging: > > > > > > > > > > > > > > sysctl hw.usb2.axe.debug=15 > > > > > > > > > > > > > > And repeat test. > > > > > > > > > > > > with hw.usb2.axe.debug=15, I have: > > > > > > > > > > > > ugen3.3: at usbus3 (disconnected) > > > > > > pid 3244 (dhclient), uid 65: exited on signal 11 > > > > > > ugen3.3: at usbus3 > > > > > > axe0: on usbus3 > > > > > > axe0: PHYADDR 0xe0:0x18 > > > > > > miibus0: on axe0 > > > > > > ciphy0: PHY 24 on miibus0 > > > > > > ciphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, > > > > > > 1000baseT-FDX, auto ue0: on axe0 > > > > > > ue0: Ethernet address: 00:90:cc:f7:bc:2e > > > > > > ue0: link state changed to DOWN > > > > > > ue0: link state changed to UP > > > > > > > > > > > > > > > > > The hardware is a PLANEX GU-1000T ethernet adapter. > > > > > > > > > > > > > > > I have the same USB controller and latest CURRENT works. > > > > > > axe0: on usbus1 > > > axe0: PHYADDR 0xe0:0x18 > > > miibus2: on axe0 > > > ciphy0: PHY 24 on miibus2 > > > ciphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto > > > ue0: on axe0 > > > ue0: Ethernet address: 00:90:cc:ef:b9:f6 > > > ue0: link state changed to DOWN > > > > > > I manually loaded necessary kernel modules as my kernel does not > > > have any USB device entries. The only regression since I tried USB2 > > > axe(4) was failure of symbol resolving of link_elf in > > > usb2_ethernet.ko module. Attached simple patch seems to fix that. > > > > > > To Hans, > > > I think MODULE_DEPEND should come first before any reference to > > > the module in usb2_ethernet.c. Since mii_phy_probe live in > > > miibus(4) I added it too. > > > > > > > Hans, I managed to track down Hiroharu's issue in axe(4). It seems > > Andrew removed link handling code that ensures correct state of > > established link in r188412. > > I believe we have to revert changes made in axe_cfg_mii_statchg() > > and axe_tick(). I have no idea what was happend in P4, you > > checked in the link handling code I submitted. > > Thanks for looking into this. > > So, can I just be waiting for a patch to test, or a CVS > revision of files to revert to? > > Meanwhile, I'll bring the userland to the latest current, as > I mentioned on the other mail. > Ok, try this one after installword. Attached one restores previous link handle code. Note, it was just compile tested. > Hiroharu --uZ3hkaAS1mZxFaxD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="usb2_ethernet.patch2" Index: sys/dev/usb2/ethernet/usb2_ethernet.c =================================================================== --- sys/dev/usb2/ethernet/usb2_ethernet.c (revision 188507) +++ sys/dev/usb2/ethernet/usb2_ethernet.c (working copy) @@ -43,6 +43,9 @@ #define UE_UNLOCK(_ue) mtx_unlock((_ue)->ue_mtx) #define UE_LOCK_ASSERT(_ue, t) mtx_assert((_ue)->ue_mtx, t) +MODULE_DEPEND(usb2_ethernet, usb2_core, 1, 1, 1); +MODULE_DEPEND(usb2_ethernet, miibus, 1, 1, 1); + static struct unrhdr *ueunit; static usb2_proc_callback_t ue_attach_post_task; @@ -582,4 +585,3 @@ DECLARE_MODULE(usb2_ethernet, usb2_ether_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); MODULE_VERSION(usb2_ethernet, 1); -MODULE_DEPEND(usb2_ethernet, usb2_core, 1, 1, 1); Index: sys/dev/usb2/ethernet/if_axe2.c =================================================================== --- sys/dev/usb2/ethernet/if_axe2.c (revision 188507) +++ sys/dev/usb2/ethernet/if_axe2.c (working copy) @@ -341,6 +341,7 @@ { struct axe_softc *sc = device_get_softc(dev); struct mii_data *mii = GET_MII(sc); + struct ifnet *ifp; uint16_t val; int err, locked; @@ -348,11 +349,40 @@ if (!locked) AXE_LOCK(sc); - val = (mii->mii_media_active & IFM_GMASK) == IFM_FDX ? - AXE_MEDIA_FULL_DUPLEX : 0; + ifp = usb2_ether_getifp(&sc->sc_ue); + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + goto done; + + sc->sc_flags &= ~AXE_FLAG_LINK; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->sc_flags |= AXE_FLAG_LINK; + break; + case IFM_1000_T: + if ((sc->sc_flags & AXE_FLAG_178) == 0) + break; + sc->sc_flags |= AXE_FLAG_LINK; + break; + default: + break; + } + } + + /* Lost link, do nothing. */ + if ((sc->sc_flags & AXE_FLAG_LINK) == 0) + goto done; + + val = 0; + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) + val |= AXE_MEDIA_FULL_DUPLEX; if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) { val |= AXE_178_MEDIA_RX_EN | AXE_178_MEDIA_MAGIC; - + if ((sc->sc_flags & AXE_FLAG_178) != 0) + val |= AXE_178_MEDIA_ENCK; switch (IFM_SUBTYPE(mii->mii_media_active)) { case IFM_1000_T: val |= AXE_178_MEDIA_GMII | AXE_178_MEDIA_ENCK; @@ -368,7 +398,7 @@ err = axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, val, NULL); if (err) device_printf(dev, "media change failed, error %d\n", err); - +done: if (!locked) AXE_UNLOCK(sc); } @@ -381,18 +411,18 @@ { struct axe_softc *sc = ifp->if_softc; struct mii_data *mii = GET_MII(sc); + int error; AXE_LOCK_ASSERT(sc, MA_OWNED); - sc->sc_flags &= ~AXE_FLAG_LINK; if (mii->mii_instance) { struct mii_softc *miisc; LIST_FOREACH(miisc, &mii->mii_phys, mii_list) mii_phy_reset(miisc); } - mii_mediachg(mii); - return (0); + error = mii_mediachg(mii); + return (error); } /* @@ -915,11 +945,10 @@ AXE_LOCK_ASSERT(sc, MA_OWNED); mii_tick(mii); - if ((sc->sc_flags & AXE_FLAG_LINK) == 0 - && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->sc_flags |= AXE_FLAG_LINK; - axe_start(ue); + if ((sc->sc_flags & AXE_FLAG_LINK) == 0) { + axe_miibus_statchg(ue->ue_dev); + if ((sc->sc_flags & AXE_FLAG_LINK) != 0) + axe_start(ue); } } --uZ3hkaAS1mZxFaxD--