From 1f074c785d34a1409fbed2624b764004ae2a6e8b Mon Sep 17 00:00:00 2001 From: thorpej Date: Mon, 2 Nov 1998 22:31:36 +0000 Subject: [PATCH] When doing a media change service request, use the media word from the current ifmedia_entry, not from the user-supplied media word. The user supplied media word may not necessarily match e.g. instance (if the parent MAC driver is intentionally ignoring instance if its expecting multiple PHYs with non-overlapping media, e.g. TI ThunderLAN) the media word we are actually switching to. Since PHY drivers use `instance' to determine if they should isolate themselves, the ThunderLAN PHY was sometimes being incorrectly isolated when in fact the user attempted to select that PHY (for e.g. BNC operation). --- sys/dev/mii/exphy.c | 16 +++++++--------- sys/dev/mii/inphy.c | 22 +++++++++------------- sys/dev/mii/lxtphy.c | 22 +++++++++------------- sys/dev/mii/nsphy.c | 22 +++++++++------------- sys/dev/mii/qsphy.c | 22 +++++++++------------- sys/dev/mii/tlphy.c | 22 +++++++++------------- 6 files changed, 52 insertions(+), 74 deletions(-) diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c index d716b3e0ae4b..8f8144f8fd67 100644 --- a/sys/dev/mii/exphy.c +++ b/sys/dev/mii/exphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: exphy.c,v 1.7 1998/10/23 01:52:50 thorpej Exp $ */ +/* $NetBSD: exphy.c,v 1.8 1998/11/02 22:31:36 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -187,14 +187,14 @@ exphy_service(self, mii, cmd) int cmd; { struct exphy_softc *sc = (struct exphy_softc *)self; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; /* * We can't isolate the 3Com PHY, so it has to be the only one! */ - if (IFM_INST(mii->mii_media.ifm_media) != sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) panic("exphy_service: can't isolate 3Com PHY"); - switch (cmd) { case MII_POLLSTAT: break; @@ -206,7 +206,7 @@ exphy_service(self, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - switch (IFM_SUBTYPE(mii->mii_media.ifm_media)) { + switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* * If we're already in auto mode, just return. @@ -224,10 +224,8 @@ exphy_service(self, mii, cmd) /* * BMCR data is stored in the ifmedia entry. */ - EXPHY_WRITE(sc, MII_ANAR, - mii_anar(mii->mii_media.ifm_media)); - EXPHY_WRITE(sc, MII_BMCR, - mii->mii_media.ifm_cur->ifm_data); + EXPHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media)); + EXPHY_WRITE(sc, MII_BMCR, ife->ifm_data); } break; @@ -235,7 +233,7 @@ exphy_service(self, mii, cmd) /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(mii->mii_media.ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) return (0); /* diff --git a/sys/dev/mii/inphy.c b/sys/dev/mii/inphy.c index fd5d8bad23be..59642266bdf8 100644 --- a/sys/dev/mii/inphy.c +++ b/sys/dev/mii/inphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: inphy.c,v 1.3 1998/08/12 20:56:35 thorpej Exp $ */ +/* $NetBSD: inphy.c,v 1.4 1998/11/02 22:31:36 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -175,6 +175,7 @@ inphy_service(self, mii, cmd) int cmd; { struct inphy_softc *sc = (struct inphy_softc *)self; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; switch (cmd) { @@ -182,8 +183,7 @@ inphy_service(self, mii, cmd) /* * If we're not polling our PHY instance, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); break; @@ -192,8 +192,7 @@ inphy_service(self, mii, cmd) * If the media indicates a different PHY instance, * isolate ourselves. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) { + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { reg = INPHY_READ(sc, MII_BMCR); INPHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); return (0); @@ -205,7 +204,7 @@ inphy_service(self, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - switch (IFM_SUBTYPE(mii->mii_media.ifm_media)) { + switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* * If we're already in auto mode, just return. @@ -223,10 +222,8 @@ inphy_service(self, mii, cmd) /* * BMCR data is stored in the ifmedia entry. */ - INPHY_WRITE(sc, MII_ANAR, - mii_anar(mii->mii_media.ifm_media)); - INPHY_WRITE(sc, MII_BMCR, - mii->mii_media.ifm_cur->ifm_data); + INPHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media)); + INPHY_WRITE(sc, MII_BMCR, ife->ifm_data); } break; @@ -234,14 +231,13 @@ inphy_service(self, mii, cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(mii->mii_media.ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) return (0); /* diff --git a/sys/dev/mii/lxtphy.c b/sys/dev/mii/lxtphy.c index 9a010b5b5642..71db294c63b3 100644 --- a/sys/dev/mii/lxtphy.c +++ b/sys/dev/mii/lxtphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: lxtphy.c,v 1.1 1998/10/24 00:33:17 thorpej Exp $ */ +/* $NetBSD: lxtphy.c,v 1.2 1998/11/02 22:31:37 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -172,6 +172,7 @@ lxtphy_service(self, mii, cmd) int cmd; { struct lxtphy_softc *sc = (struct lxtphy_softc *)self; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; switch (cmd) { @@ -179,8 +180,7 @@ lxtphy_service(self, mii, cmd) /* * If we're not polling our PHY instance, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); break; @@ -189,8 +189,7 @@ lxtphy_service(self, mii, cmd) * If the media indicates a different PHY instance, * isolate ourselves. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) { + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { reg = LXTPHY_READ(sc, MII_BMCR); LXTPHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); return (0); @@ -202,7 +201,7 @@ lxtphy_service(self, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - switch (IFM_SUBTYPE(mii->mii_media.ifm_media)) { + switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* * If we're already in auto mode, just return. @@ -220,10 +219,8 @@ lxtphy_service(self, mii, cmd) /* * BMCR data is stored in the ifmedia entry. */ - LXTPHY_WRITE(sc, MII_ANAR, - mii_anar(mii->mii_media.ifm_media)); - LXTPHY_WRITE(sc, MII_BMCR, - mii->mii_media.ifm_cur->ifm_data); + LXTPHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media)); + LXTPHY_WRITE(sc, MII_BMCR, ife->ifm_data); } break; @@ -231,14 +228,13 @@ lxtphy_service(self, mii, cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(mii->mii_media.ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) return (0); /* diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index dd72e00b0a52..f53e1b51f179 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: nsphy.c,v 1.9 1998/08/14 00:23:26 thorpej Exp $ */ +/* $NetBSD: nsphy.c,v 1.10 1998/11/02 22:31:37 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -175,6 +175,7 @@ nsphy_service(self, mii, cmd) int cmd; { struct nsphy_softc *sc = (struct nsphy_softc *)self; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; switch (cmd) { @@ -182,8 +183,7 @@ nsphy_service(self, mii, cmd) /* * If we're not polling our PHY instance, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); break; @@ -192,8 +192,7 @@ nsphy_service(self, mii, cmd) * If the media indicates a different PHY instance, * isolate ourselves. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) { + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { reg = NSPHY_READ(sc, MII_BMCR); NSPHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); return (0); @@ -238,7 +237,7 @@ nsphy_service(self, mii, cmd) NSPHY_WRITE(sc, MII_NSPHY_PCR, reg); - switch (IFM_SUBTYPE(mii->mii_media.ifm_media)) { + switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* * If we're already in auto mode, just return. @@ -256,10 +255,8 @@ nsphy_service(self, mii, cmd) /* * BMCR data is stored in the ifmedia entry. */ - NSPHY_WRITE(sc, MII_ANAR, - mii_anar(mii->mii_media.ifm_media)); - NSPHY_WRITE(sc, MII_BMCR, - mii->mii_media.ifm_cur->ifm_data); + NSPHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media)); + NSPHY_WRITE(sc, MII_BMCR, ife->ifm_data); } break; @@ -267,14 +264,13 @@ nsphy_service(self, mii, cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(mii->mii_media.ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) return (0); /* diff --git a/sys/dev/mii/qsphy.c b/sys/dev/mii/qsphy.c index eabd6a14330c..56e1230ddf9f 100644 --- a/sys/dev/mii/qsphy.c +++ b/sys/dev/mii/qsphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: qsphy.c,v 1.3 1998/08/12 20:56:37 thorpej Exp $ */ +/* $NetBSD: qsphy.c,v 1.4 1998/11/02 22:31:37 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -171,6 +171,7 @@ qsphy_service(self, mii, cmd) int cmd; { struct qsphy_softc *sc = (struct qsphy_softc *)self; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; switch (cmd) { @@ -178,8 +179,7 @@ qsphy_service(self, mii, cmd) /* * If we're not polling our PHY instance, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); break; @@ -188,8 +188,7 @@ qsphy_service(self, mii, cmd) * If the media indicates a different PHY instance, * isolate ourselves. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) { + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { reg = QSPHY_READ(sc, MII_BMCR); QSPHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); return (0); @@ -201,7 +200,7 @@ qsphy_service(self, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - switch (IFM_SUBTYPE(mii->mii_media.ifm_media)) { + switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* * If we're already in auto mode, just return. @@ -219,10 +218,8 @@ qsphy_service(self, mii, cmd) /* * BMCR data is stored in the ifmedia entry. */ - QSPHY_WRITE(sc, MII_ANAR, - mii_anar(mii->mii_media.ifm_media)); - QSPHY_WRITE(sc, MII_BMCR, - mii->mii_media.ifm_cur->ifm_data); + QSPHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media)); + QSPHY_WRITE(sc, MII_BMCR, ife->ifm_data); } break; @@ -230,14 +227,13 @@ qsphy_service(self, mii, cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(mii->mii_media.ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) return (0); /* diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index 2771ce3b81f6..f10c3d231f07 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: tlphy.c,v 1.10 1998/08/17 16:41:45 bouyer Exp $ */ +/* $NetBSD: tlphy.c,v 1.11 1998/11/02 22:31:37 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -214,6 +214,7 @@ tlphy_service(self, mii, cmd) int cmd; { struct tlphy_softc *sc = (struct tlphy_softc *)self; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; switch (cmd) { @@ -221,8 +222,7 @@ tlphy_service(self, mii, cmd) /* * If we're not polling our PHY instance, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); break; @@ -231,8 +231,7 @@ tlphy_service(self, mii, cmd) * If the media indicates a different PHY instance, * isolate ourselves. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) { + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { reg = TLPHY_READ(sc, MII_BMCR); TLPHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); return (0); @@ -244,7 +243,7 @@ tlphy_service(self, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - switch (IFM_SUBTYPE(mii->mii_media.ifm_media)) { + switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* * The ThunderLAN PHY doesn't self-configure after @@ -262,10 +261,8 @@ tlphy_service(self, mii, cmd) default: TLPHY_WRITE(sc, MII_TLPHY_CTRL, 0); delay(100000); - TLPHY_WRITE(sc, MII_ANAR, - mii_anar(mii->mii_media.ifm_media)); - TLPHY_WRITE(sc, MII_BMCR, - mii->mii_media.ifm_cur->ifm_data); + TLPHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media)); + TLPHY_WRITE(sc, MII_BMCR, ife->ifm_data); } break; @@ -273,14 +270,13 @@ tlphy_service(self, mii, cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(mii->mii_media.ifm_media) != - sc->sc_mii.mii_inst) + if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) return (0); /* * Only used for autonegotiation. */ - if (IFM_SUBTYPE(mii->mii_media.ifm_media) != IFM_AUTO) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) return (0); /*