Subject: 100baseTX-FDX on HME and the generic MII code
To: None <tech-net@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-net
Date: 05/04/2002 20:21:24
--eheScQNz3K90DVRs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

So, after fixing a bug in hme_init() (it wasn't telling the MII code
to bring up the link), I needed to make one more hack to mii_set_media()
to make the HME negotiate 100baseTX-FDX.

Basically, the firmware on my CP1500 seems to disable full-duplex in
the ANAR, and then enables AUTONEG.  Thus, we get a 100baseTX link.

Now, as it stands now, mii_set_media() sees that AUTONEG is already set,
and thus skips starting the Nway cycle again.  This, however, isn't what
we want.  We want to make sure the ANAR gets the new media bits.

This is pretty easy to do -- just remove the test for AUTONEG from
mii_set_media().  Unfortunately, this means a busy-loop delay of
several milliseconds every time an MII-using Ethernet interface's
"init" routine is called (hackish patch attached).

However, it does work:

cp1500-1:thorpej 1$ ifconfig -a
hme0: flags=8a63<UP,BROADCAST,NOTRAILERS,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        address: 08:00:20:9f:1c:9a
        media: Ethernet autoselect (100baseTX full-duplex)
        status: active
        inet 192.168.2.3 netmask 0xffffff00 broadcast 192.168.2.255
        inet6 fe80::a00:20ff:fe9f:1c9a%hme0 prefixlen 64 scopeid 0x1
        inet6 3ffe:507:183:3::3 prefixlen 64
        inet6 3ffe:507:183:3:a00:20ff:fe9f:1c9a prefixlen 64
lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 33184
        inet 127.0.0.1 netmask 0xff000000
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet6 ::1 prefixlen 128
cp1500-1:thorpej 2$ 

So, should I go ahead and commit this (well, a cleaned up version,
anyway :-)?  Any discussion to be had here?

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

--eheScQNz3K90DVRs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=mii-patch

Index: mii_physubr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/mii/mii_physubr.c,v
retrieving revision 1.30
diff -u -r1.30 mii_physubr.c
--- mii_physubr.c	2001/11/13 07:41:37	1.30
+++ mii_physubr.c	2002/05/05 03:19:02
@@ -114,7 +114,7 @@
 	int bmcr, anar, gtcr;
 
 	if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
-		if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0)
+//		if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0)
 			(void) mii_phy_auto(sc, 1);
 		return;
 	}

--eheScQNz3K90DVRs--