From owner-freebsd-net Tue Oct 22 0:51: 0 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 55DED37B401; Tue, 22 Oct 2002 00:50:58 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 388D243E4A; Tue, 22 Oct 2002 00:50:57 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id RAA26021; Tue, 22 Oct 2002 17:50:49 +1000 Date: Tue, 22 Oct 2002 18:01:46 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Mike Silbersack Cc: freebsd-net@FreeBSD.ORG, , Harti Brandt Subject: Re: MII problem, need more eyes In-Reply-To: <20021022013605.D1194-100000@patrocles.silby.com> Message-ID: <20021022174319.V13842-100000@gamplex.bde.org> 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 On Tue, 22 Oct 2002, Mike Silbersack wrote: > 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. > ... > 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); This return of 0 is apparently intentional. The comment before this says: /* * If we're not doing autonegotiation, we don't need to do * any extra work here. However, we need to check the link * status so we can generate an announcement if the status * changes. */ Here the "However" clause is not in RELENG_4. Returning 0 gets the status updated. I think this is just too expensive to do every second. Autonegotiation is only retried every 17 seconds (every 5 seconds in RELENG_4). > > /* 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); > } I think the "However" clause applies to this return too. The status update code does lots more than the above to determine the exact state. > 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. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message