Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2009 13:37:51 +0900
From:      Hiroharu Tamaru <tamaru@myn.rcast.u-tokyo.ac.jp>
To:        pyunyh@gmail.com
Cc:        thompsa@freebsd.org, freebsd-usb@freebsd.org
Subject:   Re: USB2: [was: umass not detected correctly, axe not transmitting] AXE problems
Message-ID:  <sa6r624jmn4.wl%tamaru@myn.rcast.u-tokyo.ac.jp>
In-Reply-To: <20090212043033.GC6313@michelle.cdnetworks.co.kr>
References:  <sa64oz1lacr.wl%tamaru@myn.rcast.u-tokyo.ac.jp> <200902110954.37659.hselasky@c2i.net> <sa6y6wdjbts.wl%tamaru@myn.rcast.u-tokyo.ac.jp> <200902111657.38129.hselasky@c2i.net> <sa6vdrgkjbw.wl%tamaru@myn.rcast.u-tokyo.ac.jp> <20090212023723.GA6313@michelle.cdnetworks.co.kr> <20090212034251.GB6313@michelle.cdnetworks.co.kr> <sa6skmkjofi.wl%tamaru@myn.rcast.u-tokyo.ac.jp> <20090212043033.GC6313@michelle.cdnetworks.co.kr>

next in thread | previous in thread | raw e-mail | index | archive | help
At Thu, 12 Feb 2009 13:30:33 +0900, Pyun YongHyeon wrote:
> [1  <text/plain; us-ascii (7bit)>]
> 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: <ASIX Electronics> at usbus3
> > > > > > > > > axe0: <ASIX Electronics AX88178, rev 2.00/0.01, addr 3> on usbus3
> > > > > > > > > axe0: PHYADDR 0xe0:0x18
> > > > > > > > > miibus0: <MII bus> on axe0
> > > > > > > > > ciphy0: <Cicada VSC8211 10/100/1000TX PHY> PHY 24 on miibus0
> > > > > > > > > ciphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT,
> > > > > > > > > 1000baseT-FDX, auto ue0: <USB Ethernet> 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: <ASIX Electronics> at usbus3 (disconnected)
> > > > > > > pid 3244 (dhclient), uid 65: exited on signal 11
> > > > > > > ugen3.3: <ASIX Electronics> at usbus3
> > > > > > > axe0: <ASIX Electronics AX88178, rev 2.00/0.01, addr 3> on usbus3
> > > > > > > axe0: PHYADDR 0xe0:0x18
> > > > > > > miibus0: <MII bus> on axe0
> > > > > > > ciphy0: <Cicada VSC8211 10/100/1000TX PHY> PHY 24 on miibus0
> > > > > > > ciphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT,
> > > > > > > 1000baseT-FDX, auto ue0: <USB Ethernet> 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: <ASIX Electronics AX88178, rev 2.00/0.01, addr 4> on usbus1
> > > > axe0: PHYADDR 0xe0:0x18
> > > > miibus2: <MII bus> on axe0
> > > > ciphy0: <Cicada VSC8211 10/100/1000TX PHY> PHY 24 on miibus2
> > > > ciphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
> > > > ue0: <USB Ethernet> 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.

Thanks, will do.  Could take half a day or so building the world and
all on this host, though.
I'll be back with the results.

> > Hiroharu
> [2 usb2_ethernet.patch2 <text/plain; us-ascii (7bit)>]
> 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);
>  	}
>  }
>  

Hiroharu



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?sa6r624jmn4.wl%tamaru>