svn commit: r214267 - in stable/7/sys/dev: dc mii

Marius Strobl marius at FreeBSD.org
Sun Oct 24 13:39:27 UTC 2010


Author: marius
Date: Sun Oct 24 13:39:26 2010
New Revision: 214267
URL: http://svn.freebsd.org/changeset/base/214267

Log:
  MFC: r213364
  
  - 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:
  stable/7/sys/dev/dc/dcphy.c
  stable/7/sys/dev/dc/pnphy.c
  stable/7/sys/dev/mii/acphy.c
  stable/7/sys/dev/mii/amphy.c
  stable/7/sys/dev/mii/atphy.c
  stable/7/sys/dev/mii/bmtphy.c
  stable/7/sys/dev/mii/brgphy.c
  stable/7/sys/dev/mii/ciphy.c
  stable/7/sys/dev/mii/e1000phy.c
  stable/7/sys/dev/mii/exphy.c
  stable/7/sys/dev/mii/gentbi.c
  stable/7/sys/dev/mii/icsphy.c
  stable/7/sys/dev/mii/inphy.c
  stable/7/sys/dev/mii/ip1000phy.c
  stable/7/sys/dev/mii/jmphy.c
  stable/7/sys/dev/mii/lxtphy.c
  stable/7/sys/dev/mii/mii.c
  stable/7/sys/dev/mii/mlphy.c
  stable/7/sys/dev/mii/nsgphy.c
  stable/7/sys/dev/mii/nsphy.c
  stable/7/sys/dev/mii/nsphyter.c
  stable/7/sys/dev/mii/pnaphy.c
  stable/7/sys/dev/mii/qsphy.c
  stable/7/sys/dev/mii/rgephy.c
  stable/7/sys/dev/mii/rlphy.c
  stable/7/sys/dev/mii/rlswitch.c
  stable/7/sys/dev/mii/ruephy.c
  stable/7/sys/dev/mii/tdkphy.c
  stable/7/sys/dev/mii/tlphy.c
  stable/7/sys/dev/mii/truephy.c
  stable/7/sys/dev/mii/ukphy.c
  stable/7/sys/dev/mii/xmphy.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/dev/dc/dcphy.c
==============================================================================
--- stable/7/sys/dev/dc/dcphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/dc/dcphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/dc/pnphy.c
==============================================================================
--- stable/7/sys/dev/dc/pnphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/dc/pnphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/acphy.c
==============================================================================
--- stable/7/sys/dev/mii/acphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/acphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/amphy.c
==============================================================================
--- stable/7/sys/dev/mii/amphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/amphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/atphy.c
==============================================================================
--- stable/7/sys/dev/mii/atphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/atphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/bmtphy.c
==============================================================================
--- stable/7/sys/dev/mii/bmtphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/bmtphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/brgphy.c
==============================================================================
--- stable/7/sys/dev/mii/brgphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/brgphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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);
 }
 
 static void
@@ -1170,4 +1151,3 @@ brgphy_reset(struct mii_softc *sc)
 
 	}
 }
-

Modified: stable/7/sys/dev/mii/ciphy.c
==============================================================================
--- stable/7/sys/dev/mii/ciphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/ciphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/e1000phy.c
==============================================================================
--- stable/7/sys/dev/mii/e1000phy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/e1000phy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/exphy.c
==============================================================================
--- stable/7/sys/dev/mii/exphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/exphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/gentbi.c
==============================================================================
--- stable/7/sys/dev/mii/gentbi.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/gentbi.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/icsphy.c
==============================================================================
--- stable/7/sys/dev/mii/icsphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/icsphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/inphy.c
==============================================================================
--- stable/7/sys/dev/mii/inphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/inphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/ip1000phy.c
==============================================================================
--- stable/7/sys/dev/mii/ip1000phy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/ip1000phy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/jmphy.c
==============================================================================
--- stable/7/sys/dev/mii/jmphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/jmphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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: stable/7/sys/dev/mii/lxtphy.c
==============================================================================
--- stable/7/sys/dev/mii/lxtphy.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/lxtphy.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -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)
-			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)
@@ -214,11 +195,6 @@ lxtphy_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: stable/7/sys/dev/mii/mii.c
==============================================================================
--- stable/7/sys/dev/mii/mii.c	Sun Oct 24 13:39:19 2010	(r214266)
+++ stable/7/sys/dev/mii/mii.c	Sun Oct 24 13:39:26 2010	(r214267)
@@ -359,12 +359,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) {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list