Author: marius
Date: Sat Oct  2 18:53:12 2010
New Revision: 213364
URL: http://svn.freebsd.org/changeset/base/213364

Log:
  - 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.

Modified:
  head/sys/dev/dc/dcphy.c
  head/sys/dev/dc/pnphy.c
  head/sys/dev/mii/acphy.c
  head/sys/dev/mii/amphy.c
  head/sys/dev/mii/atphy.c
  head/sys/dev/mii/axphy.c
  head/sys/dev/mii/bmtphy.c
  head/sys/dev/mii/brgphy.c
  head/sys/dev/mii/ciphy.c
  head/sys/dev/mii/e1000phy.c
  head/sys/dev/mii/exphy.c
  head/sys/dev/mii/gentbi.c
  head/sys/dev/mii/icsphy.c
  head/sys/dev/mii/inphy.c
  head/sys/dev/mii/ip1000phy.c
  head/sys/dev/mii/jmphy.c
  head/sys/dev/mii/lxtphy.c
  head/sys/dev/mii/mii.c
  head/sys/dev/mii/mlphy.c
  head/sys/dev/mii/nsgphy.c
  head/sys/dev/mii/nsphy.c
  head/sys/dev/mii/nsphyter.c
  head/sys/dev/mii/pnaphy.c
  head/sys/dev/mii/qsphy.c
  head/sys/dev/mii/rgephy.c
  head/sys/dev/mii/rlphy.c
  head/sys/dev/mii/rlswitch.c
  head/sys/dev/mii/ruephy.c
  head/sys/dev/mii/smcphy.c
  head/sys/dev/mii/tdkphy.c
  head/sys/dev/mii/tlphy.c
  head/sys/dev/mii/truephy.c
  head/sys/dev/mii/ukphy.c
  head/sys/dev/mii/xmphy.c

Modified: head/sys/dev/dc/dcphy.c
==============================================================================
--- head/sys/dev/dc/dcphy.c     Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/dc/dcphy.c     Sat Oct  2 18:53:12 2010        (r213364)
@@ -149,7 +149,7 @@ dcphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = dcphy_service;
        sc->mii_pdata = mii;
@@ -159,8 +159,6 @@ dcphy_attach(device_t dev)
         */
        sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
 
-       mii->mii_instance++;
-
        /*dcphy_reset(sc);*/
        dc_sc = mii->mii_ifp->if_softc;
        CSR_WRITE_4(dc_sc, DC_10BTSTAT, 0);
@@ -204,22 +202,10 @@ dcphy_service(struct mii_softc *sc, stru
 
        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)
@@ -276,12 +262,6 @@ dcphy_service(struct mii_softc *sc, stru
 
        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)

Modified: head/sys/dev/dc/pnphy.c
==============================================================================
--- head/sys/dev/dc/pnphy.c     Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/dc/pnphy.c     Sat Oct  2 18:53:12 2010        (r213364)
@@ -132,7 +132,7 @@ pnphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = pnphy_service;
        sc->mii_pdata = mii;
@@ -142,8 +142,6 @@ pnphy_attach(device_t dev)
         */
        sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
 
-       mii->mii_instance++;
-
        sc->mii_capabilities =
            BMSR_100TXFDX | BMSR_100TXHDX | BMSR_10TFDX | BMSR_10THDX;
        sc->mii_capabilities &= ma->mii_capmask;
@@ -162,22 +160,10 @@ pnphy_service(struct mii_softc *sc, stru
 
        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)
@@ -212,12 +198,6 @@ pnphy_service(struct mii_softc *sc, stru
 
        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)

Modified: head/sys/dev/mii/acphy.c
==============================================================================
--- head/sys/dev/mii/acphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/acphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -132,17 +132,14 @@ acphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = acphy_service;
        sc->mii_pdata = mii;
 
-       mii->mii_instance++;
-
        acphy_reset(sc);
 
-       sc->mii_capabilities =
-           PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
        device_printf(dev, " ");
 
 #define        ADD(m, c)       ifmedia_add(&mii->mii_media, (m), (c), NULL)
@@ -167,22 +164,8 @@ acphy_attach(device_t dev)
 static int
 acphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        int reg;
 
-       /*
-        * If we're not selected, then do nothing, just isolate and power
-        * down, if changing media.
-        */
-       if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
-               if (cmd == MII_MEDIACHG) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO | BMCR_PDOWN);
-               }
-
-               return (0);
-       }
-
        switch (cmd) {
        case MII_POLLSTAT:
                break;

Modified: head/sys/dev/mii/amphy.c
==============================================================================
--- head/sys/dev/mii/amphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/amphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -109,13 +109,11 @@ amphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = amphy_service;
        sc->mii_pdata = mii;
 
-       mii->mii_instance++;
-
 #define        ADD(m, c)       ifmedia_add(&mii->mii_media, (m), (c), NULL)
 
 #if 0
@@ -125,8 +123,7 @@ amphy_attach(device_t dev)
 
        mii_phy_reset(sc);
 
-       sc->mii_capabilities =
-           PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
        device_printf(dev, " ");
        mii_phy_add_media(sc);
        printf("\n");
@@ -138,30 +135,13 @@ amphy_attach(device_t dev)
 static int
 amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int reg;
 
        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) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -171,11 +151,6 @@ amphy_service(struct mii_softc *sc, stru
                break;
 
        case MII_TICK:
-               /*
-                * If we're not currently selected, just return.
-                */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
                if (mii_phy_tick(sc) == EJUSTRETURN)
                        return (0);
                break;

Modified: head/sys/dev/mii/atphy.c
==============================================================================
--- head/sys/dev/mii/atphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/atphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -113,13 +113,10 @@ atphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = atphy_service;
        sc->mii_pdata = mii;
-       sc->mii_anegticks = MII_ANEGTICKS_GIGE;
-
-       mii->mii_instance++;
 
        asc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
        asc->mii_model = MII_MODEL(ma->mii_id2);
@@ -138,7 +135,7 @@ atphy_attach(device_t dev)
        printf("\n");
 
        MIIBUS_MEDIAINIT(sc->mii_dev);
-       return(0);
+       return (0);
 }
 
 static int
@@ -149,25 +146,10 @@ atphy_service(struct mii_softc *sc, stru
 
        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) {
-                       bmcr = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -225,12 +207,6 @@ done:
 
        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)

Modified: head/sys/dev/mii/axphy.c
==============================================================================
--- head/sys/dev/mii/axphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/axphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -99,12 +99,12 @@ axphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = axphy_service;
        sc->mii_pdata = mii;
+
        sc->mii_flags |= MIIF_NOISOLATE;
-       mii->mii_instance++;
 
        mii_phy_reset(sc);
 
@@ -122,22 +122,12 @@ axphy_attach(device_t dev)
 static int
 axphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int reg;
 
        switch (cmd) {
        case MII_POLLSTAT:
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
                break;
 
        case MII_MEDIACHG:
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-                       return (0);
-               }
-
                /*
                 * If the interface is not up, don't do anything.
                 */
@@ -148,8 +138,6 @@ axphy_service(struct mii_softc *sc, stru
                break;
 
        case MII_TICK:
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
                if (mii_phy_tick(sc) == EJUSTRETURN)
                        return (0);
                break;

Modified: head/sys/dev/mii/bmtphy.c
==============================================================================
--- head/sys/dev/mii/bmtphy.c   Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/bmtphy.c   Sat Oct  2 18:53:12 2010        (r213364)
@@ -147,17 +147,14 @@ bmtphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = bmtphy_service;
        sc->mii_pdata = mii;
 
        mii_phy_reset(sc);
 
-       mii->mii_instance++;
-
-       sc->mii_capabilities =
-           PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
        device_printf(dev, " ");
        mii_phy_add_media(sc);
        printf("\n");
@@ -170,32 +167,13 @@ bmtphy_attach(device_t dev)
 static int
 bmtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct  ifmedia_entry *ife;
-       int     reg;
-
-       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) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -205,11 +183,6 @@ bmtphy_service(struct mii_softc *sc, str
                break;
 
        case MII_TICK:
-               /*
-                * If we're not currently selected, just return.
-                */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
                if (mii_phy_tick(sc) == EJUSTRETURN)
                        return (0);
                break;

Modified: head/sys/dev/mii/brgphy.c
==============================================================================
--- head/sys/dev/mii/brgphy.c   Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/brgphy.c   Sat Oct  2 18:53:12 2010        (r213364)
@@ -191,13 +191,17 @@ brgphy_attach(device_t dev)
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
        /* Initialize mii_softc structure */
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = brgphy_service;
        sc->mii_pdata = mii;
-       sc->mii_anegticks = MII_ANEGTICKS_GIGE;
+
+       /*
+        * At least some variants wedge when isolating, at least some also
+        * don't support loopback.
+        */
        sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
-       mii->mii_instance++;
+       sc->mii_anegticks = MII_ANEGTICKS_GIGE;
 
        /* Initialize brgphy_softc structure */
        bsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
@@ -283,9 +287,6 @@ brgphy_attach(device_t dev)
 
 #define        ADD(m, c)       ifmedia_add(&mii->mii_media, (m), (c), NULL)
 
-       /* Create an instance of Ethernet media. */
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), BMCR_ISO);
-
        /* Add the supported media types */
        if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
                ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
@@ -345,26 +346,12 @@ brgphy_service(struct mii_softc *sc, str
 {
        struct brgphy_softc *bsc = (struct brgphy_softc *)sc;
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int error = 0;
        int val;
 
        switch (cmd) {
        case MII_POLLSTAT:
-               /* If we're not polling our PHY instance, just return. */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       goto brgphy_service_exit;
                break;
        case MII_MEDIACHG:
-               /*
-                * If the media indicates a different PHY instance,
-                * isolate ourselves.
-                */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
-                       PHY_WRITE(sc, MII_BMCR,
-                           PHY_READ(sc, MII_BMCR) | BMCR_ISO);
-                       goto brgphy_service_exit;
-               }
-
                /* If the interface is not up, don't do anything. */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
                        break;
@@ -385,18 +372,13 @@ brgphy_service(struct mii_softc *sc, str
                            mii->mii_ifp->if_flags & IFF_LINK0);
                        break;
                default:
-                       error = EINVAL;
-                       goto brgphy_service_exit;
+                       return (EINVAL);
                }
                break;
        case MII_TICK:
-               /* Bail if we're not currently selected. */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       goto brgphy_service_exit;
-
                /* Bail if the interface isn't up. */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
-                       goto brgphy_service_exit;
+                       return (0);
 
 
                /* Bail if autoneg isn't in process. */
@@ -465,8 +447,7 @@ brgphy_service(struct mii_softc *sc, str
                }
        }
        mii_phy_update(sc, cmd);
-brgphy_service_exit:
-       return (error);
+       return (0);
 }
 
 
@@ -1182,4 +1163,3 @@ brgphy_reset(struct mii_softc *sc)
 
        }
 }
-

Modified: head/sys/dev/mii/ciphy.c
==============================================================================
--- head/sys/dev/mii/ciphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/ciphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -118,18 +118,16 @@ ciphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = ciphy_service;
        sc->mii_pdata = mii;
 
        sc->mii_flags |= MIIF_NOISOLATE;
-       mii->mii_instance++;
 
        ciphy_reset(sc);
 
-       sc->mii_capabilities =
-           PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
        if (sc->mii_capabilities & BMSR_EXTSTAT)
                sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
        device_printf(dev, " ");
@@ -148,25 +146,10 @@ ciphy_service(struct mii_softc *sc, stru
 
        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) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -239,12 +222,6 @@ setit:
 
        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)

Modified: head/sys/dev/mii/e1000phy.c
==============================================================================
--- head/sys/dev/mii/e1000phy.c Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/e1000phy.c Sat Oct  2 18:53:12 2010        (r213364)
@@ -144,11 +144,10 @@ e1000phy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = e1000phy_service;
        sc->mii_pdata = mii;
-       mii->mii_instance++;
 
        esc->mii_model = MII_MODEL(ma->mii_id2);
        ifp = sc->mii_pdata->mii_ifp;
@@ -322,25 +321,10 @@ e1000phy_service(struct mii_softc *sc, s
 
        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) {
-                       reg = PHY_READ(sc, E1000_CR);
-                       PHY_WRITE(sc, E1000_CR, reg | E1000_CR_ISOLATE);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -417,12 +401,6 @@ done:
                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)

Modified: head/sys/dev/mii/exphy.c
==============================================================================
--- head/sys/dev/mii/exphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/exphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -136,24 +136,16 @@ exphy_attach(device_t dev)
        ma = device_get_ivars(dev);
        sc->mii_dev = device_get_parent(dev);
        mii = ma->mii_data;
-
-       /*
-        * The 3Com PHY can never be isolated, so never allow non-zero
-        * instances!
-        */
-       if (mii->mii_instance != 0) {
-               device_printf(dev, "ignoring this PHY, non-zero instance\n");
-               return (ENXIO);
-       }
-
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = exphy_service;
        sc->mii_pdata = mii;
-       mii->mii_instance++;
 
+       /*
+        * The 3Com PHY can never be isolated.
+        */
        sc->mii_flags |= MIIF_NOISOLATE;
 
 #define        ADD(m, c)       ifmedia_add(&mii->mii_media, (m), (c), NULL)
@@ -163,8 +155,7 @@ exphy_attach(device_t dev)
 
        exphy_reset(sc);
 
-       sc->mii_capabilities =
-           PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
        device_printf(dev, " ");
        mii_phy_add_media(sc);
        printf("\n");
@@ -176,13 +167,6 @@ exphy_attach(device_t dev)
 static int
 exphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       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(ife->ifm_media) != sc->mii_inst)
-               panic("exphy_service: can't isolate 3Com PHY");
 
        switch (cmd) {
        case MII_POLLSTAT:

Modified: head/sys/dev/mii/gentbi.c
==============================================================================
--- head/sys/dev/mii/gentbi.c   Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/gentbi.c   Sat Oct  2 18:53:12 2010        (r213364)
@@ -55,7 +55,7 @@
  */
 
 /*
- * Driver for generic ten-bit (1000BASE-SX) interfaces, built in to
+ * Driver for generic ten-bit (1000BASE-SX) interfaces, built into
  * many Gigabit Ethernet chips.
  *
  * All we have to do here is correctly report speed and duplex.
@@ -166,13 +166,11 @@ gentbi_attach(device_t dev)
                    MII_OUI(ma->mii_id1, ma->mii_id2),
                    MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = gentbi_service;
        sc->mii_pdata = mii;
 
-       mii->mii_instance++;
-
        mii_phy_reset(sc);
 
        /*
@@ -195,30 +193,13 @@ gentbi_attach(device_t dev)
 static int
 gentbi_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int reg;
 
        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) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -228,12 +209,6 @@ gentbi_service(struct mii_softc *sc, str
                break;
 
        case MII_TICK:
-               /*
-                * If we're not currently selected, just return.
-                */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
-
                if (mii_phy_tick(sc) == EJUSTRETURN)
                        return (0);
                break;

Modified: head/sys/dev/mii/icsphy.c
==============================================================================
--- head/sys/dev/mii/icsphy.c   Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/icsphy.c   Sat Oct  2 18:53:12 2010        (r213364)
@@ -141,14 +141,12 @@ icsphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = icsphy_service;
        sc->mii_pdata = mii;
-       sc->mii_anegticks = MII_ANEGTICKS;
-       sc->mii_flags |= MIIF_NOISOLATE;
 
-       mii->mii_instance++;
+       sc->mii_flags |= MIIF_NOISOLATE;
 
        ifmedia_add(&mii->mii_media,
            IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
@@ -170,20 +168,6 @@ icsphy_attach(device_t dev)
 static int
 icsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int reg;
-
-       /*
-        * If we're not selected, then do nothing, just isolate, if
-        * changing media.
-        */
-       if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
-               if (cmd == MII_MEDIACHG) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-               }
-                return (0);
-        }
 
        switch (cmd) {
        case MII_POLLSTAT:

Modified: head/sys/dev/mii/inphy.c
==============================================================================
--- head/sys/dev/mii/inphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/inphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -107,11 +107,10 @@ inphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = inphy_service;
        sc->mii_pdata = mii;
-       mii->mii_instance++;
 
        ifmedia_add(&mii->mii_media,
            IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
@@ -132,22 +131,12 @@ inphy_attach(device_t dev)
 static int
 inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
-       struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int reg;
 
        switch (cmd) {
        case MII_POLLSTAT:
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
                break;
 
        case MII_MEDIACHG:
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
-                       reg = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
-                       return (0);
-               }
-
                /*
                 * If the interface is not up, don't do anything.
                 */
@@ -158,8 +147,6 @@ inphy_service(struct mii_softc *sc, stru
                break;
 
        case MII_TICK:
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)
-                       return (0);
                if (mii_phy_tick(sc) == EJUSTRETURN)
                        return (0);
                break;

Modified: head/sys/dev/mii/ip1000phy.c
==============================================================================
--- head/sys/dev/mii/ip1000phy.c        Sat Oct  2 17:58:57 2010        
(r213363)
+++ head/sys/dev/mii/ip1000phy.c        Sat Oct  2 18:53:12 2010        
(r213364)
@@ -114,13 +114,12 @@ ip1000phy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = ip1000phy_service;
        sc->mii_pdata = mii;
-       sc->mii_flags |= MIIF_NOISOLATE;
 
-       mii->mii_instance++;
+       sc->mii_flags |= MIIF_NOISOLATE;
 
        isc->model = MII_MODEL(ma->mii_id2);
        isc->revision = MII_REV(ma->mii_id2);
@@ -135,7 +134,7 @@ ip1000phy_attach(device_t dev)
        printf("\n");
 
        MIIBUS_MEDIAINIT(sc->mii_dev);
-       return(0);
+       return (0);
 }
 
 static int
@@ -146,26 +145,10 @@ ip1000phy_service(struct mii_softc *sc, 
 
        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) {
-                       reg = PHY_READ(sc, IP1000PHY_MII_BMCR);
-                       PHY_WRITE(sc, IP1000PHY_MII_BMCR,
-                           reg | IP1000PHY_BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0) {
@@ -237,11 +220,6 @@ done:
 
        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)

Modified: head/sys/dev/mii/jmphy.c
==============================================================================
--- head/sys/dev/mii/jmphy.c    Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/jmphy.c    Sat Oct  2 18:53:12 2010        (r213364)
@@ -112,13 +112,11 @@ jmphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = jmphy_service;
        sc->mii_pdata = mii;
 
-       mii->mii_instance++;
-
        jsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
        jsc->mii_model = MII_MODEL(ma->mii_id2);
        jsc->mii_rev = MII_REV(ma->mii_id2);
@@ -136,36 +134,20 @@ jmphy_attach(device_t dev)
        printf("\n");
 
        MIIBUS_MEDIAINIT(sc->mii_dev);
-       return(0);
+       return (0);
 }
 
 static int
 jmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       uint16_t bmcr;
 
        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) {
-                       bmcr = PHY_READ(sc, MII_BMCR);
-                       PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO);
-                       return (0);
-               }
-
-               /*
                 * If the interface is not up, don't do anything.
                 */
                if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
@@ -177,12 +159,6 @@ jmphy_service(struct mii_softc *sc, stru
 
        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)

Modified: head/sys/dev/mii/lxtphy.c
==============================================================================
--- head/sys/dev/mii/lxtphy.c   Sat Oct  2 17:58:57 2010        (r213363)
+++ head/sys/dev/mii/lxtphy.c   Sat Oct  2 18:53:12 2010        (r213364)
@@ -135,17 +135,14 @@ lxtphy_attach(device_t dev)
        mii = ma->mii_data;
        LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
 
-       sc->mii_inst = mii->mii_instance;
+       sc->mii_inst = mii->mii_instance++;
        sc->mii_phy = ma->mii_phyno;
        sc->mii_service = lxtphy_service;
        sc->mii_pdata = mii;
 
-       mii->mii_instance++;
-
        mii_phy_reset(sc);
 
-       sc->mii_capabilities =
-           PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
        device_printf(dev, " ");
 
        /*
@@ -177,29 +174,13 @@ static int
 lxtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-       int reg;
 
        switch (cmd) {
        case MII_POLLSTAT:
-               /*
-                * If we're not polling our PHY instance, just return.
-                */
-               if (IFM_INST(ife->ifm_media) != sc->mii_inst)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to