Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Oct 2002 01:44:09 -0500 (CDT)
From:      Mike Silbersack <silby@silby.com>
To:        freebsd-net@freebsd.org
Cc:        jlemon@freebsd.org, Harti Brandt <brandt@fokus.gmd.de>
Subject:   MII problem, need more eyes
Message-ID:  <20021022013605.D1194-100000@patrocles.silby.com>

next in thread | raw e-mail | index | archive | help
In trying to figure out why if_xl's mii_tick is such a pig, I think I've
stumbled upon a bug in -current's MII routines which I'd like confirmation
on before I go ahead and fix.

First, pull up

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/mii/nsphy.c?rev=1.2.2.5&content-type=text/x-cvsweb-markup

Which is nsphy.c from -stable.

Scroll down to "case MII_TICK" and examine closely.

Now look at the same thing in -current:

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/mii/nsphy.c?rev=1.16&content-type=text/x-cvsweb-markup

And look at mii_phy_tick in mii_physubr.c:

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/mii/nsphy.c?rev=1.16&content-type=text/x-cvsweb-markup

Now here's the problem:

In the original version (which is still present in -stable), the MII_TICK
case aborts out of the function due to a bunch of circumstances which
indicate that no autonegotiation is necessary.  mii_phy_tick does the
same.  HOWEVER, mii_phy_tick returns 0, which indicates to the new
MII_TICK logic that autonegotiation _is_ necessary, thereby
reautonegotiating _every second_.

I believe that the correct fix would be:

	if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
-		return (0);
+		return (EJUSTRETURN);

	/* Read the status register twice; BMSR_LINK is latch-low. */
	reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
	if (reg & BMSR_LINK) {
		/*
		 * See above.
		 */
-		return (0);
+		return (EJUSTRETURN);
	}

Doing this results in much quicker mii_ticks, dropping the time taken for
the normal case from 11ms to 3ms, without any of Harti Brandt's
optimizations.  Also, I believe that this change makes it operate more
correctly.

Could someone take a quick look over this to confirm that my patch makes
sense?

Thanks,

Mike "Silby" Silbersack



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021022013605.D1194-100000>