diff options
author | marius <marius@FreeBSD.org> | 2010-10-02 18:53:12 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2010-10-02 18:53:12 +0000 |
commit | 9c329941907d63b275da17ba20294c7f0a2e324b (patch) | |
tree | be43fedc87f2ffc4b3d13f6ff4002bb017799ac5 /sys/dev/mii/mii.c | |
parent | e9dc33bfce177d81402bea81ce874ef0bb9f3536 (diff) | |
download | FreeBSD-src-9c329941907d63b275da17ba20294c7f0a2e324b.zip FreeBSD-src-9c329941907d63b275da17ba20294c7f0a2e324b.tar.gz |
- In the spirit of previous simplifications factor out the checks for a
different PHY instance being selected and isolation out into the wrappers
around the service methods rather than duplicating them over and over
again (besides, a PHY driver shouldn't need to care about which instance
it actually is).
- Centralize the check for the need to isolate a non-zero PHY instance not
supporting isolation in mii_mediachg() and just ignore it rather than
panicing, which should sufficient given that a) things are likely to
just work anyway if one doesn't plug in more than one port at a time and
b) refusing to attach in this case just leaves us in a unknown but most
likely also not exactly correct configuration (besides several drivers
setting MIIF_NOISOLATE didn't care about these anyway, probably due to
setting this flag for no real reason).
- Minor fixes like removing unnecessary setting of sc->mii_anegticks,
using sc->mii_anegticks instead of hardcoded values etc.
Diffstat (limited to 'sys/dev/mii/mii.c')
-rw-r--r-- | sys/dev/mii/mii.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c index 799f075f..f19fcc2 100644 --- a/sys/dev/mii/mii.c +++ b/sys/dev/mii/mii.c @@ -350,12 +350,28 @@ int mii_mediachg(struct mii_data *mii) { struct mii_softc *child; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int rv; mii->mii_media_status = 0; mii->mii_media_active = IFM_NONE; LIST_FOREACH(child, &mii->mii_phys, mii_list) { + /* + * If the media indicates a different PHY instance, + * isolate this one. + */ + if (IFM_INST(ife->ifm_media) != child->mii_inst) { + if ((child->mii_flags & MIIF_NOISOLATE) != 0) { + device_printf(child->mii_dev, "%s: " + "can't handle non-zero PHY instance %d\n", + __func__, child->mii_inst); + continue; + } + PHY_WRITE(child, MII_BMCR, PHY_READ(child, MII_BMCR) | + BMCR_ISO); + continue; + } rv = (*child->mii_service)(child, mii, MII_MEDIACHG); if (rv) return (rv); @@ -370,9 +386,17 @@ void mii_tick(struct mii_data *mii) { struct mii_softc *child; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - LIST_FOREACH(child, &mii->mii_phys, mii_list) + LIST_FOREACH(child, &mii->mii_phys, mii_list) { + /* + * If this PHY instance isn't currently selected, just skip + * it. + */ + if (IFM_INST(ife->ifm_media) != child->mii_inst) + continue; (void)(*child->mii_service)(child, mii, MII_TICK); + } } /* @@ -382,12 +406,19 @@ void mii_pollstat(struct mii_data *mii) { struct mii_softc *child; + struct ifmedia_entry *ife = mii->mii_media.ifm_cur; mii->mii_media_status = 0; mii->mii_media_active = IFM_NONE; - LIST_FOREACH(child, &mii->mii_phys, mii_list) + LIST_FOREACH(child, &mii->mii_phys, mii_list) { + /* + * If we're not polling this PHY instance, just skip it. + */ + if (IFM_INST(ife->ifm_media) != child->mii_inst) + continue; (void)(*child->mii_service)(child, mii, MII_POLLSTAT); + } } /* |