diff options
author | jlemon <jlemon@FreeBSD.org> | 2001-09-29 19:18:52 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2001-09-29 19:18:52 +0000 |
commit | 6689cad44720247770c3439271c41126ceb5476e (patch) | |
tree | e747bfa7e8d363f3c895759cfbfa10fc7ec0841e | |
parent | 8bad7ad549c81c7741eb484b254cbe6200cba4c3 (diff) | |
download | FreeBSD-src-6689cad44720247770c3439271c41126ceb5476e.zip FreeBSD-src-6689cad44720247770c3439271c41126ceb5476e.tar.gz |
Cleanup pass for mii drivers.
. Make internal service routines static.
. Use a consistent ordering of checks in MII_TICK. Do the work in the
mii_phy_tick() subroutine if appropriate.
. Call mii_phy_update() to trigger the callbacks.
-rw-r--r-- | sys/dev/dc/dcphy.c | 29 | ||||
-rw-r--r-- | sys/dev/dc/pnphy.c | 21 | ||||
-rw-r--r-- | sys/dev/mii/acphy.c | 37 | ||||
-rw-r--r-- | sys/dev/mii/amphy.c | 48 | ||||
-rw-r--r-- | sys/dev/mii/brgphy.c | 38 | ||||
-rw-r--r-- | sys/dev/mii/dcphy.c | 29 | ||||
-rw-r--r-- | sys/dev/mii/e1000phy.c | 58 | ||||
-rw-r--r-- | sys/dev/mii/exphy.c | 23 | ||||
-rw-r--r-- | sys/dev/mii/inphy.c | 45 | ||||
-rw-r--r-- | sys/dev/mii/lxtphy.c | 38 | ||||
-rw-r--r-- | sys/dev/mii/miidevs | 5 | ||||
-rw-r--r-- | sys/dev/mii/miidevs.h | 6 | ||||
-rw-r--r-- | sys/dev/mii/mlphy.c | 31 | ||||
-rw-r--r-- | sys/dev/mii/nsgphy.c | 34 | ||||
-rw-r--r-- | sys/dev/mii/nsphy.c | 46 | ||||
-rw-r--r-- | sys/dev/mii/pnaphy.c | 40 | ||||
-rw-r--r-- | sys/dev/mii/pnphy.c | 21 | ||||
-rw-r--r-- | sys/dev/mii/qsphy.c | 39 | ||||
-rw-r--r-- | sys/dev/mii/rlphy.c | 27 | ||||
-rw-r--r-- | sys/dev/mii/tdkphy.c | 43 | ||||
-rw-r--r-- | sys/dev/mii/tlphy.c | 34 | ||||
-rw-r--r-- | sys/dev/mii/ukphy.c | 42 | ||||
-rw-r--r-- | sys/dev/mii/xmphy.c | 42 |
23 files changed, 233 insertions, 543 deletions
diff --git a/sys/dev/dc/dcphy.c b/sys/dev/dc/dcphy.c index e2d30b9..0968d4a 100644 --- a/sys/dev/dc/dcphy.c +++ b/sys/dev/dc/dcphy.c @@ -116,10 +116,10 @@ static driver_t dcphy_driver = { DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0); -int dcphy_service __P((struct mii_softc *, struct mii_data *, int)); -void dcphy_status __P((struct mii_softc *)); -static int dcphy_auto __P((struct mii_softc *, int)); -static void dcphy_reset __P((struct mii_softc *)); +static int dcphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void dcphy_status __P((struct mii_softc *)); +static void dcphy_reset __P((struct mii_softc *)); +static int dcphy_auto __P((struct mii_softc *, int)); static int dcphy_probe(dev) device_t dev; @@ -221,7 +221,7 @@ static int dcphy_detach(dev) return(0); } -int +static int dcphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -318,22 +318,22 @@ dcphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & (DC_TSTAT_LS10|DC_TSTAT_LS100); if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) - return(0); + break; /* * Only retry autonegotiation every 5 seconds. @@ -353,14 +353,11 @@ dcphy_service(sc, mii, cmd) dcphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void dcphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/dc/pnphy.c b/sys/dev/dc/pnphy.c index e91ffc6..dce8282 100644 --- a/sys/dev/dc/pnphy.c +++ b/sys/dev/dc/pnphy.c @@ -103,8 +103,8 @@ static driver_t pnphy_driver = { DRIVER_MODULE(pnphy, miibus, pnphy_driver, pnphy_devclass, 0, 0); -int pnphy_service __P((struct mii_softc *, struct mii_data *, int)); -void pnphy_status __P((struct mii_softc *)); +static int pnphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void pnphy_status __P((struct mii_softc *)); static int pnphy_probe(dev) device_t dev; @@ -184,7 +184,7 @@ static int pnphy_detach(dev) return(0); } -int +static int pnphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -257,32 +257,23 @@ pnphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); - return(0); + break; } /* Update the media status. */ pnphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void pnphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/acphy.c b/sys/dev/mii/acphy.c index 96fefa2..0008ef0 100644 --- a/sys/dev/mii/acphy.c +++ b/sys/dev/mii/acphy.c @@ -115,9 +115,9 @@ static driver_t acphy_driver = { DRIVER_MODULE(acphy, miibus, acphy_driver, acphy_devclass, 0, 0); -int acphy_service __P((struct mii_softc *, struct mii_data *, int)); -void acphy_reset __P((struct mii_softc *)); -void acphy_status __P((struct mii_softc *)); +static int acphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void acphy_reset __P((struct mii_softc *)); +static void acphy_status __P((struct mii_softc *)); static int acphy_probe(dev) device_t dev; @@ -184,7 +184,7 @@ static int acphy_detach(dev) return(0); } -int +static int acphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -253,26 +253,24 @@ acphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. + * check for link. + * Read the status register twice; BMSR_LINK is latch-low. */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); if (reg & BMSR_LINK) - return (0); + break; /* * Only retry autonegotiation every 5 seconds. @@ -291,14 +289,11 @@ acphy_service(sc, mii, cmd) acphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void acphy_status(sc) struct mii_softc *sc; { @@ -343,7 +338,7 @@ acphy_status(sc) mii->mii_media_active = ife->ifm_media; } -void +static void acphy_reset(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/amphy.c b/sys/dev/mii/amphy.c index e873c85..8c78cf0 100644 --- a/sys/dev/mii/amphy.c +++ b/sys/dev/mii/amphy.c @@ -83,8 +83,8 @@ static driver_t amphy_driver = { DRIVER_MODULE(amphy, miibus, amphy_driver, amphy_devclass, 0, 0); -int amphy_service __P((struct mii_softc *, struct mii_data *, int)); -void amphy_status __P((struct mii_softc *)); +static int amphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void amphy_status __P((struct mii_softc *)); static int amphy_probe(dev) device_t dev; @@ -167,7 +167,8 @@ static int amphy_detach(dev) return(0); } -int + +static int amphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -232,40 +233,8 @@ amphy_service(sc, mii, cmd) */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - - /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. - */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) - break; - - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) - return(0); break; } @@ -273,14 +242,11 @@ amphy_service(sc, mii, cmd) amphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void amphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 1c0d97e..da71240 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -85,9 +85,8 @@ static driver_t brgphy_driver = { DRIVER_MODULE(brgphy, miibus, brgphy_driver, brgphy_devclass, 0, 0); -int brgphy_service __P((struct mii_softc *, struct mii_data *, int)); -void brgphy_status __P((struct mii_softc *)); - +static int brgphy_service(struct mii_softc *, struct mii_data *, int); +static void brgphy_status(struct mii_softc *); static int brgphy_mii_phy_auto __P((struct mii_softc *, int)); extern void mii_phy_auto_timeout __P((void *)); @@ -192,7 +191,8 @@ static int brgphy_detach(dev) return(0); } -int + +static int brgphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -299,24 +299,16 @@ setit: return (0); /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Only retry autonegotiation every 5 seconds. + * Only used for autonegotiation. */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * Check to see if we have link. If we do, we don't @@ -327,9 +319,16 @@ setit: if (reg & BRGPHY_AUXSTS_LINK) break; + /* + * Only retry autonegotiation every 5 seconds. + */ + if (++sc->mii_ticks != 5) + return (0); + + sc->mii_ticks = 0; mii_phy_reset(sc); if (brgphy_mii_phy_auto(sc, 0) == EJUSTRETURN) - return(0); + return (0); break; } @@ -337,14 +336,11 @@ setit: brgphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void brgphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c index e2d30b9..0968d4a 100644 --- a/sys/dev/mii/dcphy.c +++ b/sys/dev/mii/dcphy.c @@ -116,10 +116,10 @@ static driver_t dcphy_driver = { DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0); -int dcphy_service __P((struct mii_softc *, struct mii_data *, int)); -void dcphy_status __P((struct mii_softc *)); -static int dcphy_auto __P((struct mii_softc *, int)); -static void dcphy_reset __P((struct mii_softc *)); +static int dcphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void dcphy_status __P((struct mii_softc *)); +static void dcphy_reset __P((struct mii_softc *)); +static int dcphy_auto __P((struct mii_softc *, int)); static int dcphy_probe(dev) device_t dev; @@ -221,7 +221,7 @@ static int dcphy_detach(dev) return(0); } -int +static int dcphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -318,22 +318,22 @@ dcphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; reg = CSR_READ_4(dc_sc, DC_10BTSTAT) & (DC_TSTAT_LS10|DC_TSTAT_LS100); if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) - return(0); + break; /* * Only retry autonegotiation every 5 seconds. @@ -353,14 +353,11 @@ dcphy_service(sc, mii, cmd) dcphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void dcphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/e1000phy.c b/sys/dev/mii/e1000phy.c index 2be3b882..1f99cce 100644 --- a/sys/dev/mii/e1000phy.c +++ b/sys/dev/mii/e1000phy.c @@ -73,12 +73,12 @@ static driver_t e1000phy_driver = { }; DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0); -int e1000phy_service(struct mii_softc *, struct mii_data *, int); -void e1000phy_status(struct mii_softc *); - +static int e1000phy_service(struct mii_softc *, struct mii_data *, int); +static void e1000phy_status(struct mii_softc *); +static void e1000phy_reset(struct mii_softc *); static int e1000phy_mii_phy_auto(struct mii_softc *, int); + extern void mii_phy_auto_timeout(void *); -static void e1000phy_reset(struct mii_softc *); static int e1000phy_debug = 0; @@ -216,7 +216,7 @@ e1000phy_reset(struct mii_softc *sc) PHY_WRITE(sc, 30, 0x00); } -int +static int e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; @@ -313,43 +313,35 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) } /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); - } /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) { - return (0); - } + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* - * Only retry autonegotiation every 5 seconds. + * check for link. + * Read the status register twice; BMSR_LINK is latch-low. */ - if (++(sc->mii_ticks) != 5) { - return (0); - } - sc->mii_ticks = 0; + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if (reg & BMSR_LINK) + break; /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. + * Only retry autonegotiation every 5 seconds. */ - reg = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR); - - if (reg & E1000_SR_LINK_STATUS) - break; + if (++sc->mii_ticks != 5) + return (0); + sc->mii_ticks = 0; e1000phy_reset(sc); - - if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN) { - return(0); - } - + if (e1000phy_mii_phy_auto(sc, 0) == EJUSTRETURN) + return (0); break; } @@ -357,15 +349,11 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) e1000phy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } - + mii_phy_update(sc, cmd); return (0); } -void +static void e1000phy_status(struct mii_softc *sc) { struct mii_data *mii = sc->mii_pdata; diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c index bbe1cc0..39d0742 100644 --- a/sys/dev/mii/exphy.c +++ b/sys/dev/mii/exphy.c @@ -114,8 +114,8 @@ static driver_t exphy_driver = { DRIVER_MODULE(xlphy, miibus, exphy_driver, exphy_devclass, 0, 0); -int exphy_service __P((struct mii_softc *, struct mii_data *, int)); -void exphy_reset __P((struct mii_softc *)); +static int exphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void exphy_reset __P((struct mii_softc *)); static int exphy_probe(dev) device_t dev; @@ -221,7 +221,7 @@ static int exphy_detach(dev) return(0); } -int +static int exphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -272,16 +272,16 @@ exphy_service(sc, mii, cmd) case MII_TICK: /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * The 3Com PHY's autonegotiation doesn't need to be @@ -294,14 +294,11 @@ exphy_service(sc, mii, cmd) ukphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void exphy_reset(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c index 09bcd5a..c4bd71e 100644 --- a/sys/dev/mii/inphy.c +++ b/sys/dev/mii/inphy.c @@ -74,9 +74,8 @@ static driver_t inphy_driver = { DRIVER_MODULE(inphy, miibus, inphy_driver, inphy_devclass, 0, 0); -int inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd); -void inphy_status(struct mii_softc *sc); - +static int inphy_service(struct mii_softc *, struct mii_data *, int); +static void inphy_status(struct mii_softc *); static int inphy_probe(device_t dev) @@ -171,7 +170,7 @@ inphy_detach(device_t dev) return (0); } -int +static int inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; @@ -222,36 +221,7 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) case MII_TICK: if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * check for link. - * 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) - return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; } @@ -260,14 +230,11 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) inphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void inphy_status(struct mii_softc *sc) { struct mii_data *mii = sc->mii_pdata; diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index d560107..9d28616 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -274,38 +274,7 @@ lxtphy_service(sc, mii, cmd) */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. - */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) - return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; } @@ -314,10 +283,7 @@ lxtphy_service(sc, mii, cmd) lxtphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } diff --git a/sys/dev/mii/miidevs b/sys/dev/mii/miidevs index 5a3e9f6..91acbb1f 100644 --- a/sys/dev/mii/miidevs +++ b/sys/dev/mii/miidevs @@ -65,6 +65,7 @@ oui TDK 0x00c039 TDK oui TI 0x080028 Texas Instruments oui XAQTI 0x00e0ae XaQti Corp. oui MARVELL 0x005043 Marvell Semiconductor +oui xxMARVELL 0x000ac2 Marvell Semiconductor /* in the 79c873, AMD uses another OUI (which matches Davicom!) */ oui xxAMD 0x00606e Advanced Micro Devices @@ -154,4 +155,6 @@ model xxTI 100VGPMI 0x0002 ThunderLAN 100VG-AnyLan media interface model XAQTI XMACII 0x0000 XaQti Corp. XMAC II gigabit interface /* Marvell Semiconductor PHYs */ -model MARVELL E1000 0x0000 Marvell Semiconductor 88E1000* gigabit PHY +model MARVELL E1000 0x0000 Marvell 88E1000 Gigabit PHY +model xxMARVELL E1000 0x0005 Marvell 88E1000 Gigabit PHY + diff --git a/sys/dev/mii/miidevs.h b/sys/dev/mii/miidevs.h index 2679217..62d100d 100644 --- a/sys/dev/mii/miidevs.h +++ b/sys/dev/mii/miidevs.h @@ -72,6 +72,7 @@ #define MII_OUI_TI 0x080028 /* Texas Instruments */ #define MII_OUI_XAQTI 0x00e0ae /* XaQti Corp. */ #define MII_OUI_MARVELL 0x005043 /* Marvell Semiconductor */ +#define MII_OUI_xxMARVELL 0x000ac2 /* Marvell Semiconductor */ /* in the 79c873, AMD uses another OUI (which matches Davicom!) */ #define MII_OUI_xxAMD 0x00606e /* Advanced Micro Devices */ @@ -191,4 +192,7 @@ /* Marvell Semiconductor PHYs */ #define MII_MODEL_MARVELL_E1000 0x0000 -#define MII_STR_MARVELL_E1000 "Marvell Semiconductor 88E1000* gigabit PHY" +#define MII_STR_MARVELL_E1000 "Marvell 88E1000 Gigabit PHY" +#define MII_MODEL_xxMARVELL_E1000 0x0005 +#define MII_STR_xxMARVELL_E1000 "Marvell 88E1000 Gigabit PHY" + diff --git a/sys/dev/mii/mlphy.c b/sys/dev/mii/mlphy.c index decb391..d39362a 100644 --- a/sys/dev/mii/mlphy.c +++ b/sys/dev/mii/mlphy.c @@ -315,24 +315,16 @@ mlphy_service(xsc, mii, cmd) return (0); /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Only retry autonegotiation every 5 seconds. + * Only used for autonegotiation. */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * Check to see if we have link. If we do, we don't @@ -355,11 +347,17 @@ mlphy_service(xsc, mii, cmd) if (!msc->ml_linked) { msc->ml_linked = 1; mlphy_status(sc); - break; } - return(0); + break; } + /* + * Only retry autonegotiation every 5 seconds. + */ + if (++sc->mii_ticks != 5) + return (0); + + sc->mii_ticks = 0; msc->ml_linked = 0; mii->mii_media_active = IFM_NONE; mii_phy_reset(sc); @@ -382,15 +380,12 @@ mlphy_service(xsc, mii, cmd) (void) (*other->mii_service)(other, mii, MII_POLLSTAT); other->mii_inst = other_inst; sc->mii_active = other->mii_active; + sc->mii_status = other->mii_status; } else ukphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } - + mii_phy_update(sc, cmd); return (0); } diff --git a/sys/dev/mii/nsgphy.c b/sys/dev/mii/nsgphy.c index 19a585a..a272054 100644 --- a/sys/dev/mii/nsgphy.c +++ b/sys/dev/mii/nsgphy.c @@ -95,9 +95,8 @@ static driver_t nsgphy_driver = { DRIVER_MODULE(nsgphy, miibus, nsgphy_driver, nsgphy_devclass, 0, 0); -int nsgphy_service __P((struct mii_softc *, struct mii_data *, int)); -void nsgphy_status __P((struct mii_softc *)); - +static int nsgphy_service __P((struct mii_softc *, struct mii_data *,int)); +static void nsgphy_status __P((struct mii_softc *)); static int nsgphy_mii_phy_auto __P((struct mii_softc *, int)); extern void mii_phy_auto_timeout __P((void *)); @@ -301,16 +300,23 @@ nsgphy_service(sc, mii, cmd) return (0); /* + * Is the interface even up? + */ + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + return (0); + + /* * Only used for autonegotiation. */ if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); + break; /* - * Is the interface even up? + * Check to see if we have link. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + reg = PHY_READ(sc, NSGPHY_MII_PHYSUP); + if (reg & NSGPHY_PHYSUP_LNKSTS) + break; /* * Only retry autonegotiation every 5 seconds. @@ -323,13 +329,6 @@ nsgphy_service(sc, mii, cmd) sc->mii_ticks = 0; - /* - * Check to see if we have link. - */ - reg = PHY_READ(sc, NSGPHY_MII_PHYSUP); - if (reg & NSGPHY_PHYSUP_LNKSTS) - break; - mii_phy_reset(sc); if (nsgphy_mii_phy_auto(sc, 0) == EJUSTRETURN) return(0); @@ -340,14 +339,11 @@ nsgphy_service(sc, mii, cmd) nsgphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void nsgphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index f0c1336..3b70ac3 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -118,8 +118,8 @@ static driver_t nsphy_driver = { DRIVER_MODULE(nsphy, miibus, nsphy_driver, nsphy_devclass, 0, 0); -int nsphy_service __P((struct mii_softc *, struct mii_data *, int)); -void nsphy_status __P((struct mii_softc *)); +static int nsphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void nsphy_status __P((struct mii_softc *)); static int nsphy_probe(dev) device_t dev; @@ -208,7 +208,7 @@ static int nsphy_detach(dev) return(0); } -int +static int nsphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -310,38 +310,7 @@ nsphy_service(sc, mii, cmd) */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. - */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) - return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; } @@ -350,14 +319,11 @@ nsphy_service(sc, mii, cmd) nsphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void nsphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/pnaphy.c b/sys/dev/mii/pnaphy.c index 5f8580a..fbb552a 100644 --- a/sys/dev/mii/pnaphy.c +++ b/sys/dev/mii/pnaphy.c @@ -89,7 +89,7 @@ static driver_t pnaphy_driver = { DRIVER_MODULE(pnaphy, miibus, pnaphy_driver, pnaphy_devclass, 0, 0); -int pnaphy_service __P((struct mii_softc *, struct mii_data *, int)); +static int pnaphy_service __P((struct mii_softc *, struct mii_data *,int)); static int pnaphy_probe(dev) @@ -232,38 +232,7 @@ pnaphy_service(sc, mii, cmd) */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. - */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) - return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; } @@ -274,9 +243,6 @@ pnaphy_service(sc, mii, cmd) mii->mii_media_active = IFM_ETHER|IFM_homePNA; /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } diff --git a/sys/dev/mii/pnphy.c b/sys/dev/mii/pnphy.c index e91ffc6..dce8282 100644 --- a/sys/dev/mii/pnphy.c +++ b/sys/dev/mii/pnphy.c @@ -103,8 +103,8 @@ static driver_t pnphy_driver = { DRIVER_MODULE(pnphy, miibus, pnphy_driver, pnphy_devclass, 0, 0); -int pnphy_service __P((struct mii_softc *, struct mii_data *, int)); -void pnphy_status __P((struct mii_softc *)); +static int pnphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void pnphy_status __P((struct mii_softc *)); static int pnphy_probe(dev) device_t dev; @@ -184,7 +184,7 @@ static int pnphy_detach(dev) return(0); } -int +static int pnphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -257,32 +257,23 @@ pnphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); - return(0); + break; } /* Update the media status. */ pnphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void pnphy_status(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index 4f00e46..10ce9f3 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -119,9 +119,9 @@ static driver_t qsphy_driver = { DRIVER_MODULE(qsphy, miibus, qsphy_driver, qsphy_devclass, 0, 0); -int qsphy_service __P((struct mii_softc *, struct mii_data *, int)); -void qsphy_reset __P((struct mii_softc *)); -void qsphy_status __P((struct mii_softc *)); +static int qsphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void qsphy_reset __P((struct mii_softc *)); +static void qsphy_status __P((struct mii_softc *)); static int qsphy_probe(dev) device_t dev; @@ -188,7 +188,7 @@ static int qsphy_detach(dev) return(0); } -int +static int qsphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -252,26 +252,24 @@ qsphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. + * check for link. + * Read the status register twice; BMSR_LINK is latch-low. */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); if (reg & BMSR_LINK) - return (0); + break; /* * Only retry autonegotiation every 5 seconds. @@ -280,7 +278,7 @@ qsphy_service(sc, mii, cmd) return (0); sc->mii_ticks = 0; - mii_phy_reset(sc); + qsphy_reset(sc); if (mii_phy_auto(sc, 0) == EJUSTRETURN) return (0); break; @@ -290,14 +288,11 @@ qsphy_service(sc, mii, cmd) qsphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void qsphy_status(sc) struct mii_softc *sc; { @@ -356,7 +351,7 @@ qsphy_status(sc) mii->mii_media_active = ife->ifm_media; } -void +static void qsphy_reset(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index 0a0e375..f6a4436 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -78,8 +78,8 @@ static driver_t rlphy_driver = { DRIVER_MODULE(rlphy, miibus, rlphy_driver, rlphy_devclass, 0, 0); -int rlphy_service __P((struct mii_softc *, struct mii_data *, int)); -void rlphy_reset __P((struct mii_softc *)); +static int rlphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void rlphy_reset __P((struct mii_softc *)); static int rlphy_probe(dev) device_t dev; @@ -181,7 +181,7 @@ static int rlphy_detach(dev) return(0); } -int +static int rlphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -232,24 +232,16 @@ rlphy_service(sc, mii, cmd) case MII_TICK: /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Only retry autonegotiation every 5 seconds. + * Only used for autonegotiation. */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * The RealTek PHY's autonegotiation doesn't need to be @@ -262,14 +254,11 @@ rlphy_service(sc, mii, cmd) ukphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void rlphy_reset(sc) struct mii_softc *sc; { diff --git a/sys/dev/mii/tdkphy.c b/sys/dev/mii/tdkphy.c index 4c3d6f8..759f0e7 100644 --- a/sys/dev/mii/tdkphy.c +++ b/sys/dev/mii/tdkphy.c @@ -175,7 +175,7 @@ static int tdkphy_detach(device_t dev) return(0); } -int +static int tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; @@ -237,38 +237,7 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. - */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) - return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; } @@ -279,15 +248,13 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) | BMCR_FDX); else PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) & ~BMCR_FDX); + /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void tdkphy_status(struct mii_softc *phy) { struct mii_data *mii = phy->mii_pdata; diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index a3b1ee5..c5efc35 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -125,10 +125,10 @@ static driver_t tlphy_driver = { DRIVER_MODULE(tlphy, miibus, tlphy_driver, tlphy_devclass, 0, 0); -int tlphy_service __P((struct mii_softc *, struct mii_data *, int)); -int tlphy_auto __P((struct tlphy_softc *, int)); -void tlphy_acomp __P((struct tlphy_softc *)); -void tlphy_status __P((struct tlphy_softc *)); +static int tlphy_service __P((struct mii_softc *, struct mii_data *, int)); +static int tlphy_auto __P((struct tlphy_softc *, int)); +static void tlphy_acomp __P((struct tlphy_softc *)); +static void tlphy_status __P((struct tlphy_softc *)); static int tlphy_probe(dev) device_t dev; @@ -241,7 +241,7 @@ static int tlphy_detach(dev) return(0); } -int +static int tlphy_service(self, mii, cmd) struct mii_softc *self; struct mii_data *mii; @@ -312,16 +312,16 @@ tlphy_service(self, mii, cmd) return (0); /* - * Only used for autonegotiation. + * Is the interface even up? */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Is the interface even up? + * Only used for autonegotiation. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * Check to see if we have link. If we do, we don't @@ -333,7 +333,7 @@ tlphy_service(self, mii, cmd) reg = PHY_READ(&sc->sc_mii, MII_BMSR) | PHY_READ(&sc->sc_mii, MII_BMSR); if (reg & BMSR_LINK) - return (0); + break; /* * Only retry autonegotiation every 5 seconds. @@ -352,15 +352,11 @@ tlphy_service(self, mii, cmd) tlphy_status(sc); /* Callback if something changed. */ - if (sc->sc_mii.mii_active != mii->mii_media_active || - cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->sc_mii.mii_dev); - sc->sc_mii.mii_active = mii->mii_media_active; - } + mii_phy_update(&sc->sc_mii, cmd); return (0); } -void +static void tlphy_status(sc) struct tlphy_softc *sc; { @@ -403,7 +399,7 @@ tlphy_status(sc) mii->mii_media_active |= IFM_10_T; } -int +static int tlphy_auto(sc, waitfor) struct tlphy_softc *sc; int waitfor; @@ -431,7 +427,7 @@ tlphy_auto(sc, waitfor) return (error); } -void +static void tlphy_acomp(sc) struct tlphy_softc *sc; { diff --git a/sys/dev/mii/ukphy.c b/sys/dev/mii/ukphy.c index bdc47b4..1385135 100644 --- a/sys/dev/mii/ukphy.c +++ b/sys/dev/mii/ukphy.c @@ -115,7 +115,7 @@ static driver_t ukphy_driver = { DRIVER_MODULE(ukphy, miibus, ukphy_driver, ukphy_devclass, 0, 0); -int ukphy_service __P((struct mii_softc *, struct mii_data *, int)); +static int ukphy_service __P((struct mii_softc *, struct mii_data *, int)); static int ukphy_probe(dev) @@ -199,7 +199,7 @@ static int ukphy_detach(dev) return(0); } -int +static int ukphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -264,38 +264,7 @@ ukphy_service(sc, mii, cmd) */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* - * Is the interface even up? - */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) - return (0); - - /* - * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. - */ - reg = PHY_READ(sc, MII_BMSR) | - PHY_READ(sc, MII_BMSR); - if (reg & BMSR_LINK) - return (0); - - /* - * Only retry autonegotiation every 5 seconds. - */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; - mii_phy_reset(sc); - if (mii_phy_auto(sc, 0) == EJUSTRETURN) + if (mii_phy_tick(sc) == EJUSTRETURN) return (0); break; } @@ -304,9 +273,6 @@ ukphy_service(sc, mii, cmd) ukphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index c147da0..c8f0e08 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -85,9 +85,8 @@ static driver_t xmphy_driver = { DRIVER_MODULE(xmphy, miibus, xmphy_driver, xmphy_devclass, 0, 0); -int xmphy_service __P((struct mii_softc *, struct mii_data *, int)); -void xmphy_status __P((struct mii_softc *)); - +static int xmphy_service __P((struct mii_softc *, struct mii_data *, int)); +static void xmphy_status __P((struct mii_softc *)); static int xmphy_mii_phy_auto __P((struct mii_softc *, int)); extern void mii_phy_auto_timeout __P((void *)); @@ -179,7 +178,8 @@ static int xmphy_detach(dev) return(0); } -int + +static int xmphy_service(sc, mii, cmd) struct mii_softc *sc; struct mii_data *mii; @@ -251,35 +251,34 @@ xmphy_service(sc, mii, cmd) return (0); /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) - return (0); - - /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); /* - * Only retry autonegotiation every 5 seconds. + * Only used for autonegotiation. */ - if (++sc->mii_ticks != 5) - return (0); - - sc->mii_ticks = 0; + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * Check to see if we have link. If we do, we don't * need to restart the autonegotiation process. Read * the BMSR twice in case it's latched. */ - reg = PHY_READ(sc, XMPHY_MII_BMSR) | - PHY_READ(sc, XMPHY_MII_BMSR); - if (reg & XMPHY_BMSR_LINK) + reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if (reg & BMSR_LINK) break; + /* + * Only retry autonegotiation every 5 seconds. + */ + if (++sc->mii_ticks != 5) + return (0); + + sc->mii_ticks = 0; + mii_phy_reset(sc); if (xmphy_mii_phy_auto(sc, 0) == EJUSTRETURN) return(0); @@ -290,14 +289,11 @@ xmphy_service(sc, mii, cmd) xmphy_status(sc); /* Callback if something changed. */ - if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { - MIIBUS_STATCHG(sc->mii_dev); - sc->mii_active = mii->mii_media_active; - } + mii_phy_update(sc, cmd); return (0); } -void +static void xmphy_status(sc) struct mii_softc *sc; { |