From owner-freebsd-net Mon Oct 21 23:39:34 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D37CA37B401; Mon, 21 Oct 2002 23:39:32 -0700 (PDT) Received: from out4.mx.nwbl.wi.voyager.net (out4.mx.nwbl.wi.voyager.net [169.207.3.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B71B43E65; Mon, 21 Oct 2002 23:39:32 -0700 (PDT) (envelope-from silby@silby.com) Received: from [10.1.1.6] (d53.as5.nwbl0.wi.voyager.net [169.207.137.181]) by out4.mx.nwbl.wi.voyager.net (Postfix) with ESMTP id 03802C2CEB; Tue, 22 Oct 2002 01:39:30 -0500 (CDT) Date: Tue, 22 Oct 2002 01:44:09 -0500 (CDT) From: Mike Silbersack To: freebsd-net@freebsd.org Cc: jlemon@freebsd.org, Harti Brandt Subject: MII problem, need more eyes Message-ID: <20021022013605.D1194-100000@patrocles.silby.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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