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 [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to