static int pnphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; switch (cmd) { case MII_POLLSTAT: break; case MII_MEDIACHG: /* * If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* NWAY is busted on this chip */ case IFM_100_T4: /* * XXX Not supported as a manual setting right now. */ return (EINVAL); case IFM_100_TX: mii->mii_media_active = IFM_ETHER | IFM_100_TX; if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) mii->mii_media_active |= IFM_FDX; MIIBUS_STATCHG(sc->mii_dev); return (0); case IFM_10_T: mii->mii_media_active = IFM_ETHER | IFM_10_T; if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) mii->mii_media_active |= IFM_FDX; MIIBUS_STATCHG(sc->mii_dev); return (0); default: return (EINVAL); } break; case MII_TICK: /* * Is the interface even up? */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); break; } /* Update the media status. */ pnphy_status(sc); /* Callback if something changed. */ mii_phy_update(sc, cmd); return (0); }
static int pnphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; switch (cmd) { case MII_POLLSTAT: /* * If we're not polling our PHY instance, just return. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) { return (0); } break; case MII_MEDIACHG: /* * If the media indicates a different PHY instance, * isolate ourselves. */ if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); /* * If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; sc->mii_flags = 0; switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* NWAY is busted on this chip */ case IFM_100_T4: /* * XXX Not supported as a manual setting right now. */ return (EINVAL); case IFM_100_TX: mii->mii_media_active = IFM_ETHER|IFM_100_TX; if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) mii->mii_media_active |= IFM_FDX; MIIBUS_STATCHG(sc->mii_dev); return(0); break; case IFM_10_T: mii->mii_media_active = IFM_ETHER|IFM_10_T; if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) mii->mii_media_active |= IFM_FDX; MIIBUS_STATCHG(sc->mii_dev); return(0); break; default: return(EINVAL); break; } break; case MII_TICK: /* * If we're not currently selected, just return. */ 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) break; /* * This PHY's autonegotiation doesn't need to be kicked. */ return(0); } /* Update the media status. */ pnphy_status(sc); /* Callback if something changed. */ mii_phy_update(sc, cmd); return (0); }