Subject: Re: kern/34109 vr(4) is painfully slow with the new rlphy(4)
To: None <jmmv@NetBSD.org, gnats-bugs@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: netbsd-bugs
Date: 03/18/2007 14:31:25
- Could you please show "ifconfig vr0" output during slowness?
- Does it work if you set "ifconfig vr0 media 10baseT" manually?
- If it works, what happens once after "ifconfig vr0 media auto" again?

With some quick tests on my 8139 cards, rlphy on RTK8139
doesn't set BMCR_AUTOEN after reset but some of them set BMCR_FDX.
If that is the problem, could you try the attached patch?
---
Izumi Tsutsui


Index: rlphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/rlphy.c,v
retrieving revision 1.12
diff -u -r1.12 rlphy.c
--- rlphy.c	16 Nov 2006 01:33:06 -0000	1.12
+++ rlphy.c	18 Mar 2007 05:15:57 -0000
@@ -65,8 +65,10 @@
 int	rlphy_service(struct mii_softc *, struct mii_data *, int);
 void	rlphy_status(struct mii_softc *);
 
+static void rlphy_reset(struct mii_softc *);
+
 const struct mii_phy_funcs rlphy_funcs = {
-	rlphy_service, rlphy_status, mii_phy_reset,
+	rlphy_service, rlphy_status, rlphy_reset,
 };
 
 static const struct mii_phydesc rlphys[] = {
@@ -331,3 +333,16 @@
 	} else
 		mii->mii_media_active = ife->ifm_media;
 }
+
+static void
+rlphy_reset(struct mii_softc *sc)
+{
+
+	mii_phy_reset(sc);
+
+	/*
+	 * XXX RealTek PHY doesn't set the BMCR properly after
+	 * XXX reset, which breaks autonegotiation.
+	 */
+	PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN);
+}