From f8ee348f1d1b903d0b117c893b5f73aed4e5bce8 Mon Sep 17 00:00:00 2001 From: andre Date: Mon, 3 May 2004 13:01:34 +0000 Subject: [PATCH] Correct the phy_service() routine case MII_TICK to correctly track the falling edge of a media state change. This is in preparation for media state change notification to the routing socket. No objections by: sam, wpaul, ru, bms Brucification by: bde --- sys/dev/dc/dcphy.c | 2 +- sys/dev/mii/brgphy.c | 6 +++--- sys/dev/mii/dcphy.c | 2 +- sys/dev/mii/e1000phy.c | 4 ++-- sys/dev/mii/mii_physubr.c | 6 ++++-- sys/dev/mii/mlphy.c | 4 ++-- sys/dev/mii/rgephy.c | 6 +++--- sys/dev/mii/ruephy.c | 4 ++-- sys/dev/mii/tlphy.c | 4 ++-- sys/dev/mii/xmphy.c | 4 ++-- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/sys/dev/dc/dcphy.c b/sys/dev/dc/dcphy.c index 4c930e504c3a..5b4b8f504f51 100644 --- a/sys/dev/dc/dcphy.c +++ b/sys/dev/dc/dcphy.c @@ -324,7 +324,7 @@ dcphy_service(sc, mii, cmd) * successful autonegotation is never recognised on * these chips. */ - if (++sc->mii_ticks != 50) + if (++sc->mii_ticks <= 50) break; sc->mii_ticks = 0; diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 6b4d38fbe0e2..15ae23df348d 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -362,8 +362,8 @@ brgphy_service(sc, mii, cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks != 5) - return (0); + if (++sc->mii_ticks <= 5) + break; sc->mii_ticks = 0; brgphy_mii_phy_auto(sc); @@ -381,7 +381,6 @@ brgphy_service(sc, mii, cmd) if (sc->mii_media_active != mii->mii_media_active || sc->mii_media_status != mii->mii_media_status || cmd == MII_MEDIACHG) { - mii_phy_update(sc, cmd); switch (brgphy_mii_model) { case MII_MODEL_xxBROADCOM_BCM5401: bcm5401_load_dspcode(sc); @@ -391,6 +390,7 @@ brgphy_service(sc, mii, cmd) break; } } + mii_phy_update(sc, cmd); return (0); } diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c index 4c930e504c3a..5b4b8f504f51 100644 --- a/sys/dev/mii/dcphy.c +++ b/sys/dev/mii/dcphy.c @@ -324,7 +324,7 @@ dcphy_service(sc, mii, cmd) * successful autonegotation is never recognised on * these chips. */ - if (++sc->mii_ticks != 50) + if (++sc->mii_ticks <= 50) break; sc->mii_ticks = 0; diff --git a/sys/dev/mii/e1000phy.c b/sys/dev/mii/e1000phy.c index 6f9f458d432f..ab1ece37225d 100644 --- a/sys/dev/mii/e1000phy.c +++ b/sys/dev/mii/e1000phy.c @@ -333,8 +333,8 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks != 5) - return (0); + if (++sc->mii_ticks <= 5) + break; sc->mii_ticks = 0; e1000phy_reset(sc); diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index 96e481c35b9f..d45881717f36 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -231,9 +231,11 @@ mii_phy_tick(struct mii_softc *sc) /* * Only retry autonegotiation every N seconds. */ - if (sc->mii_anegticks == 0) + if (sc->mii_anegticks == 0) { sc->mii_anegticks = 17; - if (++sc->mii_ticks != sc->mii_anegticks) + return (0); + } + if (++sc->mii_ticks <= sc->mii_anegticks) return (EJUSTRETURN); sc->mii_ticks = 0; diff --git a/sys/dev/mii/mlphy.c b/sys/dev/mii/mlphy.c index 744d3c371012..ecb84f776979 100644 --- a/sys/dev/mii/mlphy.c +++ b/sys/dev/mii/mlphy.c @@ -337,8 +337,8 @@ mlphy_service(xsc, mii, cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks != 5) - return (0); + if (++sc->mii_ticks <= 5) + break; sc->mii_ticks = 0; msc->ml_linked = 0; diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c index 5c0f13d710ad..84681ed61dc1 100644 --- a/sys/dev/mii/rgephy.c +++ b/sys/dev/mii/rgephy.c @@ -298,8 +298,8 @@ rgephy_service(sc, mii, cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks != 5/*10*/) - return (0); + if (++sc->mii_ticks <= 5/*10*/) + break; sc->mii_ticks = 0; rgephy_mii_phy_auto(sc); @@ -317,9 +317,9 @@ rgephy_service(sc, mii, cmd) if (sc->mii_media_active != mii->mii_media_active || sc->mii_media_status != mii->mii_media_status || cmd == MII_MEDIACHG) { - mii_phy_update(sc, cmd); rgephy_load_dspcode(sc); } + mii_phy_update(sc, cmd); return (0); } diff --git a/sys/dev/mii/ruephy.c b/sys/dev/mii/ruephy.c index f2dbc1602f66..494bd7449baf 100644 --- a/sys/dev/mii/ruephy.c +++ b/sys/dev/mii/ruephy.c @@ -226,8 +226,8 @@ ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks != 5) - return (0); + if (++sc->mii_ticks <= 5) + break; sc->mii_ticks = 0; ruephy_reset(sc); diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index ca9f854cfcc0..cf3ce2e57af6 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -325,8 +325,8 @@ tlphy_service(self, mii, cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->sc_mii.mii_ticks != 5) - return (0); + if (++sc->sc_mii.mii_ticks <= 5) + break; sc->sc_mii.mii_ticks = 0; mii_phy_reset(&sc->sc_mii); diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index 2a1ee8060174..22ecd73deff2 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -255,8 +255,8 @@ xmphy_service(sc, mii, cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks != 5) - return (0); + if (++sc->mii_ticks <= 5) + break; sc->mii_ticks = 0;