Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 May 2011 19:51:29 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r221407 - in head/sys: dev/ae dev/age dev/alc dev/ale dev/bce dev/bfe dev/bge dev/dc dev/ed dev/et dev/fxp dev/hme dev/jme dev/lge dev/mii dev/nfe dev/nge dev/nve dev/pcn dev/sf dev/sge...
Message-ID:  <201105031951.p43JpTnT010228@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Tue May  3 19:51:29 2011
New Revision: 221407
URL: http://svn.freebsd.org/changeset/base/221407

Log:
  - Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOP
    (reporting IFM_LOOP based on BMCR_LOOP is left in place though as
    it might provide useful for debugging). For most mii(4) drivers it
    was unclear whether the PHYs driven by them actually support
    loopback or not. Moreover, typically loopback mode also needs to
    be activated on the MAC, which none of the Ethernet drivers using
    mii(4) implements. Given that loopback media has no real use (and
    obviously hardly had a chance to actually work) besides for driver
    development (which just loopback mode should be sufficient for
    though, i.e one doesn't necessary need support for loopback media)
    support for it is just dropped as both NetBSD and OpenBSD already
    did quite some time ago.
  - Let mii_phy_add_media() also announce the support of IFM_NONE.
  - Restructure the PHY entry points to use a structure of entry points
    instead of discrete function pointers, and extend this to include
    a "reset" entry point. Make sure any PHY-specific reset routine is
    always used, and provide one for lxtphy(4) which disables MII
    interrupts (as is done for a few other PHYs we have drivers for).
    This includes changing NIC drivers which previously just called the
    generic mii_phy_reset() to now actually call the PHY-specific reset
    routine, which might be crucial in some cases. While at it, the
    redundant checks in these NIC drivers for mii->mii_instance not being
    zero before calling the reset routines were removed because as soon
    as one PHY driver attaches mii->mii_instance is incremented and we
    hardly can end up in their media change callbacks etc if no PHY driver
    has attached as mii_attach() would have failed in that case and not
    attach a miibus(4) instance.
    Consequently, NIC drivers now no longer should call mii_phy_reset()
    directly, so it was removed from EXPORT_SYMS.
  - Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe().
    The purpose of that function is to perform the common steps to attach
    a PHY driver instance and to hook it up to the miibus(4) instance and to
    optionally also handle the probing, addition and initialization of the
    supported media. So all a PHY driver without any special requirements
    has to do in its bus attach method is to call mii_phy_dev_attach()
    along with PHY-specific MIIF_* flags, a pointer to its PHY functions
    and the add_media set to one. All PHY drivers were updated to take
    advantage of mii_phy_dev_attach() as appropriate. Along with these
    changes the capability mask was added to the mii_softc structure so
    PHY drivers taking advantage of mii_phy_dev_attach() but still
    handling media on their own do not need to fiddle with the MII attach
    arguments anyway.
  - Keep track of the PHY offset in the mii_softc structure. This is done
    for compatibility with NetBSD/OpenBSD.
  - Keep track of the PHY's OUI, model and revision in the mii_softc
    structure. Several PHY drivers require this information also after
    attaching and previously had to wrap their own softc around mii_softc.
    NetBSD/OpenBSD also keep track of the model and revision on their
    mii_softc structure. All PHY drivers were updated to take advantage
    as appropriate.
  - Convert the mebers of the MII data structure to unsigned where
    appropriate. This is partly inspired by NetBSD/OpenBSD.
  - According to IEEE 802.3-2002 the bits actually have to be reversed
    when mapping an OUI to the MII ID registers. All PHY drivers and
    miidevs where changed as necessary. Actually this now again allows to
    largely share miidevs with NetBSD, which fixed this problem already
    9 years ago. Consequently miidevs was synced as far as possible.
  - Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that
    weren't explicitly converted to support flow control before. It's
    unclear whether flow control actually works with these but typically
    it should and their net behavior should be more correct with these
    changes in place than without if the MAC driver sets MIIF_DOPAUSE.
  
  Obtained from:	NetBSD (partially)
  Reviewed by:	yongari (earlier version), silence on arch@ and net@

Modified:
  head/sys/dev/ae/if_ae.c
  head/sys/dev/age/if_age.c
  head/sys/dev/alc/if_alc.c
  head/sys/dev/ale/if_ale.c
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bfe/if_bfe.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/dc/dcphy.c
  head/sys/dev/dc/pnphy.c
  head/sys/dev/ed/if_ed_pccard.c
  head/sys/dev/et/if_et.c
  head/sys/dev/fxp/if_fxp.c
  head/sys/dev/hme/if_hme.c
  head/sys/dev/jme/if_jme.c
  head/sys/dev/lge/if_lge.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/mii.h
  head/sys/dev/mii/mii_physubr.c
  head/sys/dev/mii/miidevs
  head/sys/dev/mii/miivar.h
  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/rdcphy.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
  head/sys/dev/nfe/if_nfe.c
  head/sys/dev/nge/if_nge.c
  head/sys/dev/nve/if_nve.c
  head/sys/dev/pcn/if_pcn.c
  head/sys/dev/sf/if_sf.c
  head/sys/dev/sge/if_sge.c
  head/sys/dev/sis/if_sis.c
  head/sys/dev/ste/if_ste.c
  head/sys/dev/tx/if_tx.c
  head/sys/dev/usb/net/if_aue.c
  head/sys/dev/usb/net/if_axe.c
  head/sys/dev/usb/net/if_rue.c
  head/sys/dev/usb/net/if_udav.c
  head/sys/dev/vr/if_vr.c
  head/sys/dev/vte/if_vte.c
  head/sys/dev/wb/if_wb.c
  head/sys/mips/atheros/if_arge.c
  head/sys/mips/cavium/octe/octe.c
  head/sys/mips/idt/if_kr.c
  head/sys/modules/mii/Makefile

Modified: head/sys/dev/ae/if_ae.c
==============================================================================
--- head/sys/dev/ae/if_ae.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/ae/if_ae.c	Tue May  3 19:51:29 2011	(r221407)
@@ -903,10 +903,8 @@ ae_mediachange(struct ifnet *ifp)
 	KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__));
 	AE_LOCK(sc);
 	mii = device_get_softc(sc->miibus);
-	if (mii->mii_instance != 0) {
-		LIST_FOREACH(mii_sc, &mii->mii_phys, mii_list)
-			mii_phy_reset(mii_sc);
-	}
+	LIST_FOREACH(mii_sc, &mii->mii_phys, mii_list)
+		PHY_RESET(mii_sc);
 	error = mii_mediachg(mii);
 	AE_UNLOCK(sc);
 

Modified: head/sys/dev/age/if_age.c
==============================================================================
--- head/sys/dev/age/if_age.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/age/if_age.c	Tue May  3 19:51:29 2011	(r221407)
@@ -301,10 +301,8 @@ age_mediachange(struct ifnet *ifp)
 	sc = ifp->if_softc;
 	AGE_LOCK(sc);
 	mii = device_get_softc(sc->age_miibus);
-	if (mii->mii_instance != 0) {
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	error = mii_mediachg(mii);
 	AGE_UNLOCK(sc);
 

Modified: head/sys/dev/alc/if_alc.c
==============================================================================
--- head/sys/dev/alc/if_alc.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/alc/if_alc.c	Tue May  3 19:51:29 2011	(r221407)
@@ -365,10 +365,8 @@ alc_mediachange(struct ifnet *ifp)
 	sc = ifp->if_softc;
 	ALC_LOCK(sc);
 	mii = device_get_softc(sc->alc_miibus);
-	if (mii->mii_instance != 0) {
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	error = mii_mediachg(mii);
 	ALC_UNLOCK(sc);
 

Modified: head/sys/dev/ale/if_ale.c
==============================================================================
--- head/sys/dev/ale/if_ale.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/ale/if_ale.c	Tue May  3 19:51:29 2011	(r221407)
@@ -286,10 +286,8 @@ ale_mediachange(struct ifnet *ifp)
 	sc = ifp->if_softc;
 	ALE_LOCK(sc);
 	mii = device_get_softc(sc->ale_miibus);
-	if (mii->mii_instance != 0) {
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	error = mii_mediachg(mii);
 	ALE_UNLOCK(sc);
 

Modified: head/sys/dev/bce/if_bce.c
==============================================================================
--- head/sys/dev/bce/if_bce.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/bce/if_bce.c	Tue May  3 19:51:29 2011	(r221407)
@@ -6141,6 +6141,7 @@ bce_ifmedia_upd_locked(struct ifnet *ifp
 {
 	struct bce_softc *sc = ifp->if_softc;
 	struct mii_data *mii;
+	struct mii_softc *miisc;
 	int error;
 
 	DBENTER(BCE_VERBOSE_PHY);
@@ -6153,12 +6154,8 @@ bce_ifmedia_upd_locked(struct ifnet *ifp
 	/* Make sure the MII bus has been enumerated. */
 	if (mii) {
 		sc->bce_link_up = FALSE;
-		if (mii->mii_instance) {
-			struct mii_softc *miisc;
-
-			LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			    mii_phy_reset(miisc);
-		}
+		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		    PHY_RESET(miisc);
 		error = mii_mediachg(mii);
 	}
 

Modified: head/sys/dev/bfe/if_bfe.c
==============================================================================
--- head/sys/dev/bfe/if_bfe.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/bfe/if_bfe.c	Tue May  3 19:51:29 2011	(r221407)
@@ -1736,18 +1736,15 @@ bfe_ifmedia_upd(struct ifnet *ifp)
 {
 	struct bfe_softc *sc;
 	struct mii_data *mii;
+	struct mii_softc *miisc;
 	int error;
 
 	sc = ifp->if_softc;
 	BFE_LOCK(sc);
 
 	mii = device_get_softc(sc->bfe_miibus);
-	if (mii->mii_instance) {
-		struct mii_softc *miisc;
-		for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
-				miisc = LIST_NEXT(miisc, mii_list))
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	error = mii_mediachg(mii);
 	BFE_UNLOCK(sc);
 

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/bge/if_bge.c	Tue May  3 19:51:29 2011	(r221407)
@@ -4854,9 +4854,8 @@ bge_ifmedia_upd_locked(struct ifnet *ifp
 
 	sc->bge_link_evt++;
 	mii = device_get_softc(sc->bge_miibus);
-	if (mii->mii_instance)
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	mii_mediachg(mii);
 
 	/*

Modified: head/sys/dev/dc/dcphy.c
==============================================================================
--- head/sys/dev/dc/dcphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/dc/dcphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -114,6 +114,12 @@ static void	dcphy_status(struct mii_soft
 static void	dcphy_reset(struct mii_softc *);
 static int	dcphy_auto(struct mii_softc *);
 
+static const struct mii_phy_funcs dcphy_funcs = {
+	dcphy_service,
+	dcphy_status,
+	dcphy_reset
+};
+
 static int
 dcphy_probe(device_t dev)
 {
@@ -138,30 +144,16 @@ static int
 dcphy_attach(device_t dev)
 {
 	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
 	struct dc_softc		*dc_sc;
 	device_t brdev;
 
 	sc = device_get_softc(dev);
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = dcphy_service;
-	sc->mii_pdata = mii;
 
-	/*
-	 * Apparently, we can neither isolate nor do loopback.
-	 */
-	sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
+	mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
+	    &dcphy_funcs, 0);
 
-	/*dcphy_reset(sc);*/
-	dc_sc = mii->mii_ifp->if_softc;
+	/*PHY_RESET(sc);*/
+	dc_sc = sc->mii_pdata->mii_ifp->if_softc;
 	CSR_WRITE_4(dc_sc, DC_10BTSTAT, 0);
 	CSR_WRITE_4(dc_sc, DC_10BTCTRL, 0);
 
@@ -182,7 +174,7 @@ dcphy_attach(device_t dev)
 		break;
 	}
 
-	sc->mii_capabilities &= ma->mii_capmask;
+	sc->mii_capabilities &= sc->mii_capmask;
 	device_printf(dev, " ");
 	mii_phy_add_media(sc);
 	printf("\n");
@@ -219,11 +211,11 @@ dcphy_service(struct mii_softc *sc, stru
 
 		switch (IFM_SUBTYPE(ife->ifm_media)) {
 		case IFM_AUTO:
-			/*dcphy_reset(sc);*/
-			(void) dcphy_auto(sc);
+			/*PHY_RESET(sc);*/
+			(void)dcphy_auto(sc);
 			break;
 		case IFM_100_TX:
-			dcphy_reset(sc);
+			PHY_RESET(sc);
 			DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
 			mode |= DC_NETCFG_PORTSEL | DC_NETCFG_PCS |
 			    DC_NETCFG_SCRAMBLER;
@@ -292,7 +284,7 @@ dcphy_service(struct mii_softc *sc, stru
 	}
 
 	/* Update the media status. */
-	dcphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);

Modified: head/sys/dev/dc/pnphy.c
==============================================================================
--- head/sys/dev/dc/pnphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/dc/pnphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -90,6 +90,13 @@ DRIVER_MODULE(pnphy, miibus, pnphy_drive
 
 static int	pnphy_service(struct mii_softc *, struct mii_data *, int);
 static void	pnphy_status(struct mii_softc *);
+static void	pnphy_reset(struct mii_softc *);
+
+static const struct mii_phy_funcs pnphy_funcs = {
+	pnphy_service,
+	pnphy_status,
+	pnphy_reset
+};
 
 static int
 pnphy_probe(device_t dev)
@@ -115,29 +122,15 @@ static int
 pnphy_attach(device_t dev)
 {
 	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
 
 	sc = device_get_softc(dev);
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = pnphy_service;
-	sc->mii_pdata = mii;
 
-	/*
-	 * Apparently, we can neither isolate nor do loopback.
-	 */
-	sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
+	mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
+	    &pnphy_funcs, 0);
 
 	sc->mii_capabilities =
 	    BMSR_100TXFDX | BMSR_100TXHDX | BMSR_10TFDX | BMSR_10THDX;
-	sc->mii_capabilities &= ma->mii_capmask;
+	sc->mii_capabilities &= sc->mii_capmask;
 	device_printf(dev, " ");
 	mii_phy_add_media(sc);
 	printf("\n");
@@ -194,7 +187,7 @@ pnphy_service(struct mii_softc *sc, stru
 	}
 
 	/* Update the media status. */
-	pnphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);
@@ -226,3 +219,9 @@ pnphy_status(struct mii_softc *sc)
 	else
 		mii->mii_media_active |= IFM_HDX;
 }
+
+static void
+pnphy_reset(struct mii_softc *sc __unused)
+{
+
+}

Modified: head/sys/dev/ed/if_ed_pccard.c
==============================================================================
--- head/sys/dev/ed/if_ed_pccard.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/ed/if_ed_pccard.c	Tue May  3 19:51:29 2011	(r221407)
@@ -401,17 +401,9 @@ ed_pccard_kick_phy(struct ed_softc *sc)
 	struct mii_softc *miisc;
 	struct mii_data *mii;
 
-	/*
-	 * Many of the PHYs that wind up on PC Cards are weird in
-	 * this way.  Generally, we don't need to worry so much about
-	 * the Isolation protocol since there's only one PHY in
-	 * these designs, so this workaround is reasonable.
-	 */
 	mii = device_get_softc(sc->miibus);
-	LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
-		miisc->mii_flags |= MIIF_FORCEANEG;
-		mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	return (mii_mediachg(mii));
 }
 
@@ -582,13 +574,13 @@ ed_pccard_attach(device_t dev)
 		ed_pccard_dl100xx_mii_reset(sc);
 		(void)mii_attach(dev, &sc->miibus, sc->ifp, ed_ifmedia_upd,
 		    ed_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
-		    MII_OFFSET_ANY, 0);
+		    MII_OFFSET_ANY, MIIF_FORCEANEG);
 	} else if (sc->chip_type == ED_CHIP_TYPE_AX88190 ||
 	    sc->chip_type == ED_CHIP_TYPE_AX88790 ||
 	    sc->chip_type == ED_CHIP_TYPE_TC5299J) {
 		error = mii_attach(dev, &sc->miibus, sc->ifp, ed_ifmedia_upd,
 		    ed_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
-		    MII_OFFSET_ANY, 0);
+		    MII_OFFSET_ANY, MIIF_FORCEANEG);
 		if (error != 0) {
 			device_printf(dev, "attaching PHYs failed\n");
 			goto bad;

Modified: head/sys/dev/et/if_et.c
==============================================================================
--- head/sys/dev/et/if_et.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/et/if_et.c	Tue May  3 19:51:29 2011	(r221407)
@@ -515,13 +515,10 @@ et_ifmedia_upd_locked(struct ifnet *ifp)
 {
 	struct et_softc *sc = ifp->if_softc;
 	struct mii_data *mii = device_get_softc(sc->sc_miibus);
+	struct mii_softc *miisc;
 
-	if (mii->mii_instance != 0) {
-		struct mii_softc *miisc;
-
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	mii_mediachg(mii);
 
 	return (0);

Modified: head/sys/dev/fxp/if_fxp.c
==============================================================================
--- head/sys/dev/fxp/if_fxp.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/fxp/if_fxp.c	Tue May  3 19:51:29 2011	(r221407)
@@ -2555,14 +2555,12 @@ fxp_ifmedia_upd(struct ifnet *ifp)
 {
 	struct fxp_softc *sc = ifp->if_softc;
 	struct mii_data *mii;
+		struct mii_softc	*miisc;
 
 	mii = device_get_softc(sc->miibus);
 	FXP_LOCK(sc);
-	if (mii->mii_instance) {
-		struct mii_softc	*miisc;
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	mii_mediachg(mii);
 	FXP_UNLOCK(sc);
 	return (0);

Modified: head/sys/dev/hme/if_hme.c
==============================================================================
--- head/sys/dev/hme/if_hme.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/hme/if_hme.c	Tue May  3 19:51:29 2011	(r221407)
@@ -1566,7 +1566,7 @@ hme_mediachange_locked(struct hme_softc 
 	 */
 	if (sc->sc_phys[0] != -1 && sc->sc_phys[1] != -1)
 		LIST_FOREACH(child, &sc->sc_mii->mii_phys, mii_list)
-			mii_phy_reset(child);
+			PHY_RESET(child);
 	return (mii_mediachg(sc->sc_mii));
 }
 

Modified: head/sys/dev/jme/if_jme.c
==============================================================================
--- head/sys/dev/jme/if_jme.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/jme/if_jme.c	Tue May  3 19:51:29 2011	(r221407)
@@ -318,10 +318,8 @@ jme_mediachange(struct ifnet *ifp)
 	sc = ifp->if_softc;
 	JME_LOCK(sc);
 	mii = device_get_softc(sc->jme_miibus);
-	if (mii->mii_instance != 0) {
-		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	error = mii_mediachg(mii);
 	JME_UNLOCK(sc);
 

Modified: head/sys/dev/lge/if_lge.c
==============================================================================
--- head/sys/dev/lge/if_lge.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/lge/if_lge.c	Tue May  3 19:51:29 2011	(r221407)
@@ -1402,18 +1402,15 @@ lge_ifmedia_upd_locked(ifp)
 {
 	struct lge_softc	*sc;
 	struct mii_data		*mii;
+	struct mii_softc	*miisc;
 
 	sc = ifp->if_softc;
 
 	LGE_LOCK_ASSERT(sc);
 	mii = device_get_softc(sc->lge_miibus);
 	sc->lge_link = 0;
-	if (mii->mii_instance) {
-		struct mii_softc	*miisc;
-		for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
-		    miisc = LIST_NEXT(miisc, mii_list))
-			mii_phy_reset(miisc);
-	}
+	LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
+		PHY_RESET(miisc);
 	mii_mediachg(mii);
 }
 

Modified: head/sys/dev/mii/acphy.c
==============================================================================
--- head/sys/dev/mii/acphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/mii/acphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -105,13 +105,19 @@ static void	acphy_reset(struct mii_softc
 static void	acphy_status(struct mii_softc *);
 
 static const struct mii_phydesc acphys[] = {
-	MII_PHY_DESC(xxALTIMA, AC101),
-	MII_PHY_DESC(xxALTIMA, AC101L),
+	MII_PHY_DESC(ALTIMA, AC101),
+	MII_PHY_DESC(ALTIMA, AC101L),
 	/* XXX This is reported to work, but it's not from any data sheet. */
-	MII_PHY_DESC(xxALTIMA, ACXXX),
+	MII_PHY_DESC(ALTIMA, ACXXX),
 	MII_PHY_END
 };
 
+static const struct mii_phy_funcs acphy_funcs = {
+	acphy_service,
+	acphy_status,
+	acphy_reset
+};
+
 static int
 acphy_probe(device_t dev)
 {
@@ -123,27 +129,17 @@ static int
 acphy_attach(device_t dev)
 {
 	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
 
 	sc = device_get_softc(dev);
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = acphy_service;
-	sc->mii_pdata = mii;
 
-	acphy_reset(sc);
+	mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &acphy_funcs, 0);
+
+	PHY_RESET(sc);
 
-	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & sc->mii_capmask;
 	device_printf(dev, " ");
 
-#define	ADD(m, c)	ifmedia_add(&mii->mii_media, (m), (c), NULL)
+#define	ADD(m, c)	ifmedia_add(&sc->mii_pdata->mii_media, (m), (c), NULL)
 	if ((PHY_READ(sc, MII_ACPHY_MCTL) & AC_MCTL_FX_SEL) != 0) {
 		sc->mii_flags |= MIIF_HAVEFIBER;
 		ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_FX, 0, sc->mii_inst),
@@ -200,7 +196,7 @@ acphy_service(struct mii_softc *sc, stru
 	}
 
 	/* Update the media status. */
-	acphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);
@@ -245,7 +241,8 @@ acphy_status(struct mii_softc *sc)
 			mii->mii_media_active |= IFM_10_T;
 
 		if (diag & AC_DIAG_DUPLEX)
-			mii->mii_media_active |= IFM_FDX;
+			mii->mii_media_active |=
+			    IFM_FDX | mii_phy_flowstatus(sc);
 		else
 			mii->mii_media_active |= IFM_HDX;
 	} else

Modified: head/sys/dev/mii/amphy.c
==============================================================================
--- head/sys/dev/mii/amphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/mii/amphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -83,12 +83,18 @@ static int	amphy_service(struct mii_soft
 static void	amphy_status(struct mii_softc *);
 
 static const struct mii_phydesc amphys[] = {
-	MII_PHY_DESC(DAVICOM, DM9102),
-	MII_PHY_DESC(xxAMD, 79C873),
+	MII_PHY_DESC(xxDAVICOM, DM9102),
 	MII_PHY_DESC(xxDAVICOM, DM9101),
+	MII_PHY_DESC(yyDAVICOM, DM9101),
 	MII_PHY_END
 };
 
+static const struct mii_phy_funcs amphy_funcs = {
+	amphy_service,
+	amphy_status,
+	mii_phy_reset
+};
+
 static int
 amphy_probe(device_t dev)
 {
@@ -99,37 +105,8 @@ amphy_probe(device_t dev)
 static int
 amphy_attach(device_t dev)
 {
-	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
-
-	sc = device_get_softc(dev);
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = amphy_service;
-	sc->mii_pdata = mii;
-
-#define	ADD(m, c)	ifmedia_add(&mii->mii_media, (m), (c), NULL)
-
-#if 0
-	ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
-	    MII_MEDIA_100_TX);
-#endif
-
-	mii_phy_reset(sc);
-
-	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
-	device_printf(dev, " ");
-	mii_phy_add_media(sc);
-	printf("\n");
-#undef ADD
-	MIIBUS_MEDIAINIT(sc->mii_dev);
+
+	mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &amphy_funcs, 1);
 	return (0);
 }
 
@@ -158,7 +135,7 @@ amphy_service(struct mii_softc *sc, stru
 	}
 
 	/* Update the media status. */
-	amphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);
@@ -231,6 +208,8 @@ amphy_status(struct mii_softc *sc)
 			mii->mii_media_active |= IFM_10_T|IFM_HDX;
 		else if (par & DSCSR_10HDX)
 			mii->mii_media_active |= IFM_10_T|IFM_HDX;
+		if ((mii->mii_media_active & IFM_FDX) != 0)
+			mii->mii_media_active |= mii_phy_flowstatus(sc);
 	} else
 		mii->mii_media_active = ife->ifm_media;
 }

Modified: head/sys/dev/mii/atphy.c
==============================================================================
--- head/sys/dev/mii/atphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/mii/atphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -53,13 +53,6 @@ __FBSDID("$FreeBSD$");
 static int atphy_probe(device_t);
 static int atphy_attach(device_t);
 
-struct atphy_softc {
-	struct mii_softc mii_sc;
-	int mii_oui;
-	int mii_model;
-	int mii_rev;
-};
-
 static device_method_t atphy_methods[] = {
 	/* Device interface. */
 	DEVMETHOD(device_probe,		atphy_probe),
@@ -73,7 +66,7 @@ static devclass_t atphy_devclass;
 static driver_t atphy_driver = {
 	"atphy",
 	atphy_methods,
-	sizeof(struct atphy_softc)
+	sizeof(struct mii_softc)
 };
 
 DRIVER_MODULE(atphy, miibus, atphy_driver, atphy_devclass, 0, 0);
@@ -85,12 +78,18 @@ static uint16_t	atphy_anar(struct ifmedi
 static int	atphy_setmedia(struct mii_softc *, int);
 
 static const struct mii_phydesc atphys[] = {
-	MII_PHY_DESC(ATHEROS, F1),
-	MII_PHY_DESC(ATHEROS, F1_7),
-	MII_PHY_DESC(ATHEROS, F2),
+	MII_PHY_DESC(xxATHEROS, F1),
+	MII_PHY_DESC(xxATHEROS, F1_7),
+	MII_PHY_DESC(xxATHEROS, F2),
 	MII_PHY_END
 };
 
+static const struct mii_phy_funcs atphy_funcs = {
+	atphy_service,
+	atphy_status,
+	atphy_reset
+};
+
 static int
 atphy_probe(device_t dev)
 {
@@ -101,41 +100,8 @@ atphy_probe(device_t dev)
 static int
 atphy_attach(device_t dev)
 {
-	struct atphy_softc *asc;
-	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
-
-	asc = device_get_softc(dev);
-	sc = &asc->mii_sc;
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = atphy_service;
-	sc->mii_pdata = mii;
-
-	asc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
-	asc->mii_model = MII_MODEL(ma->mii_id2);
-	asc->mii_rev = MII_REV(ma->mii_id2);
-	if (bootverbose)
-		device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
-		    asc->mii_oui, asc->mii_model, asc->mii_rev);
-
-	atphy_reset(sc);
-
-	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, " ");
-	mii_phy_add_media(sc);
-	printf("\n");
 
-	MIIBUS_MEDIAINIT(sc->mii_dev);
+	mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &atphy_funcs, 1);
 	return (0);
 }
 
@@ -244,7 +210,7 @@ done:
 	}
 
 	/* Update the media status. */
-	atphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);
@@ -318,12 +284,9 @@ static void
 atphy_reset(struct mii_softc *sc)
 {
 	struct ifmedia_entry *ife = sc->mii_pdata->mii_media.ifm_cur;
-	struct atphy_softc *asc;
 	uint32_t reg;
 	int i;
 
-	asc = (struct atphy_softc *)sc;
-
 	/* Take PHY out of power down mode. */
 	PHY_WRITE(sc, 29, 0x29);
 	PHY_WRITE(sc, 30, 0);

Modified: head/sys/dev/mii/axphy.c
==============================================================================
--- head/sys/dev/mii/axphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/mii/axphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -73,10 +73,16 @@ static int	axphy_service(struct mii_soft
 static void	axphy_status(struct mii_softc *);
 
 static const struct mii_phydesc axphys[] = {
-	MII_PHY_DESC(ASIX, AX88X9X),
+	MII_PHY_DESC(xxASIX, AX88X9X),
 	MII_PHY_END
 };
 
+static const struct mii_phy_funcs axphy_funcs = {
+	axphy_service,
+	axphy_status,
+	mii_phy_reset
+};
+
 static int
 axphy_probe(device_t dev)
 {
@@ -88,31 +94,11 @@ static int
 axphy_attach(device_t dev)
 {
 	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
 
 	sc = device_get_softc(dev);
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	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_phy_reset(sc);
-
-	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
-	device_printf(dev, " ");
-	mii_phy_add_media(sc);
-	printf("\n");
 
-	MIIBUS_MEDIAINIT(sc->mii_dev);
+	mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
+	    &axphy_funcs, 1);
 	mii_phy_setmedia(sc);
 
 	return (0);
@@ -143,7 +129,7 @@ axphy_service(struct mii_softc *sc, stru
 	}
 
 	/* Update the media status. */
-	axphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);
@@ -187,7 +173,8 @@ axphy_status(struct mii_softc *sc)
 		else
 			mii->mii_media_active |= IFM_10_T;
 		if (scr & SCR_FDX)
-			mii->mii_media_active |= IFM_FDX;
+			mii->mii_media_active |=
+			    IFM_FDX | mii_phy_flowstatus(sc);
 		else
 			mii->mii_media_active |= IFM_HDX;
 #endif

Modified: head/sys/dev/mii/bmtphy.c
==============================================================================
--- head/sys/dev/mii/bmtphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/mii/bmtphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -85,11 +85,6 @@ __FBSDID("$FreeBSD$");
 static int	bmtphy_probe(device_t);
 static int	bmtphy_attach(device_t);
 
-struct bmtphy_softc {
-	struct mii_softc mii_sc;
-	int mii_model;
-};
-
 static device_method_t bmtphy_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		bmtphy_probe),
@@ -105,7 +100,7 @@ static devclass_t	bmtphy_devclass;
 static driver_t	bmtphy_driver = {
 	"bmtphy",
 	bmtphy_methods,
-	sizeof(struct bmtphy_softc)
+	sizeof(struct mii_softc)
 };
 
 DRIVER_MODULE(bmtphy, miibus, bmtphy_driver, bmtphy_devclass, 0, 0);
@@ -115,20 +110,26 @@ static void	bmtphy_status(struct mii_sof
 static void	bmtphy_reset(struct mii_softc *);
 
 static const struct mii_phydesc bmtphys_dp[] = {
-	MII_PHY_DESC(BROADCOM, BCM4401),
-	MII_PHY_DESC(BROADCOM, BCM5201),
-	MII_PHY_DESC(BROADCOM, BCM5214),
-	MII_PHY_DESC(BROADCOM, BCM5221),
-	MII_PHY_DESC(BROADCOM, BCM5222),
+	MII_PHY_DESC(xxBROADCOM, BCM4401),
+	MII_PHY_DESC(xxBROADCOM, BCM5201),
+	MII_PHY_DESC(xxBROADCOM, BCM5214),
+	MII_PHY_DESC(xxBROADCOM, BCM5221),
+	MII_PHY_DESC(xxBROADCOM, BCM5222),
 	MII_PHY_END
 };
 
 static const struct mii_phydesc bmtphys_lp[] = {
-	MII_PHY_DESC(BROADCOM, 3C905B),
-	MII_PHY_DESC(BROADCOM, 3C905C),
+	MII_PHY_DESC(xxBROADCOM, 3C905B),
+	MII_PHY_DESC(xxBROADCOM, 3C905C),
 	MII_PHY_END
 };
 
+static const struct mii_phy_funcs bmtphy_funcs = {
+	bmtphy_service,
+	bmtphy_status,
+	bmtphy_reset 
+};
+
 static int
 bmtphy_probe(device_t dev)
 {
@@ -145,37 +146,8 @@ bmtphy_probe(device_t dev)
 static int
 bmtphy_attach(device_t dev)
 {
-	struct bmtphy_softc *bsc;
-	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
-
-	bsc = device_get_softc(dev);
-	sc = &bsc->mii_sc;
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = bmtphy_service;
-	sc->mii_pdata = mii;
-
-	sc->mii_flags |= MIIF_NOMANPAUSE;
-
-	bsc->mii_model = MII_MODEL(ma->mii_id2);
-
-	bmtphy_reset(sc);
-
-	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
-	device_printf(dev, " ");
-	mii_phy_add_media(sc);
-	printf("\n");
-
-	MIIBUS_MEDIAINIT(sc->mii_dev);
 
+	mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &bmtphy_funcs, 1);
 	return (0);
 }
 
@@ -204,7 +176,7 @@ bmtphy_service(struct mii_softc *sc, str
 	}
 
 	/* Update the media status. */
-	bmtphy_status(sc);
+	PHY_STATUS(sc);
 
 	/* Callback if something changed. */
 	mii_phy_update(sc, cmd);
@@ -267,14 +239,11 @@ bmtphy_status(struct mii_softc *sc)
 static void
 bmtphy_reset(struct mii_softc *sc)
 {
-	struct bmtphy_softc *bsc;
 	u_int16_t data;
 
-	bsc = (struct bmtphy_softc *)sc;
-
 	mii_phy_reset(sc);
 
-	if (bsc->mii_model == MII_MODEL_BROADCOM_BCM5221) {
+	if (sc->mii_mpd_model == MII_MODEL_xxBROADCOM_BCM5221) {
 		/* Enable shadow register mode. */
 		data = PHY_READ(sc, 0x1f);
 		PHY_WRITE(sc, 0x1f, data | 0x0080);

Modified: head/sys/dev/mii/brgphy.c
==============================================================================
--- head/sys/dev/mii/brgphy.c	Tue May  3 19:50:39 2011	(r221406)
+++ head/sys/dev/mii/brgphy.c	Tue May  3 19:51:29 2011	(r221407)
@@ -68,9 +68,6 @@ static int brgphy_attach(device_t);
 
 struct brgphy_softc {
 	struct mii_softc mii_sc;
-	int mii_oui;
-	int mii_model;
-	int mii_rev;
 	int serdes_flags;	/* Keeps track of the serdes type used */
 #define BRGPHY_5706S		0x0001
 #define BRGPHY_5708S		0x0002
@@ -117,37 +114,43 @@ static void	brgphy_ethernet_wirespeed(st
 static void	brgphy_jumbo_settings(struct mii_softc *, u_long);
 
 static const struct mii_phydesc brgphys[] = {
-	MII_PHY_DESC(xxBROADCOM, BCM5400),
-	MII_PHY_DESC(xxBROADCOM, BCM5401),
-	MII_PHY_DESC(xxBROADCOM, BCM5411),
-	MII_PHY_DESC(xxBROADCOM, BCM54K2),
-	MII_PHY_DESC(xxBROADCOM, BCM5701),
-	MII_PHY_DESC(xxBROADCOM, BCM5703),
-	MII_PHY_DESC(xxBROADCOM, BCM5704),
-	MII_PHY_DESC(xxBROADCOM, BCM5705),
-	MII_PHY_DESC(xxBROADCOM, BCM5706),
-	MII_PHY_DESC(xxBROADCOM, BCM5714),
-	MII_PHY_DESC(xxBROADCOM, BCM5750),
-	MII_PHY_DESC(xxBROADCOM, BCM5752),
-	MII_PHY_DESC(xxBROADCOM, BCM5754),
-	MII_PHY_DESC(xxBROADCOM, BCM5780),
-	MII_PHY_DESC(xxBROADCOM, BCM5708C),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5482S),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5755),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5787),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5708S),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709CAX),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5722),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5784),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709C),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5761),
-	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709S),
-	MII_PHY_DESC(xxBROADCOM_ALT2, BCM5717C),
-	MII_PHY_DESC(xxBROADCOM_ALT2, BCM57765),
-	MII_PHY_DESC(BROADCOM2, BCM5906),
+	MII_PHY_DESC(BROADCOM, BCM5400),
+	MII_PHY_DESC(BROADCOM, BCM5401),
+	MII_PHY_DESC(BROADCOM, BCM5411),
+	MII_PHY_DESC(BROADCOM, BCM54K2),
+	MII_PHY_DESC(BROADCOM, BCM5701),
+	MII_PHY_DESC(BROADCOM, BCM5703),
+	MII_PHY_DESC(BROADCOM, BCM5704),
+	MII_PHY_DESC(BROADCOM, BCM5705),
+	MII_PHY_DESC(BROADCOM, BCM5706),
+	MII_PHY_DESC(BROADCOM, BCM5714),
+	MII_PHY_DESC(BROADCOM, BCM5421),
+	MII_PHY_DESC(BROADCOM, BCM5750),
+	MII_PHY_DESC(BROADCOM, BCM5752),
+	MII_PHY_DESC(BROADCOM, BCM5780),
+	MII_PHY_DESC(BROADCOM, BCM5708C),
+	MII_PHY_DESC(BROADCOM2, BCM5482),
+	MII_PHY_DESC(BROADCOM2, BCM5708S),
+	MII_PHY_DESC(BROADCOM2, BCM5709C),
+	MII_PHY_DESC(BROADCOM2, BCM5709S),
+	MII_PHY_DESC(BROADCOM2, BCM5709CAX),
+	MII_PHY_DESC(BROADCOM2, BCM5722),
+	MII_PHY_DESC(BROADCOM2, BCM5755),
+	MII_PHY_DESC(BROADCOM2, BCM5754),
+	MII_PHY_DESC(BROADCOM2, BCM5761),
+	MII_PHY_DESC(BROADCOM2, BCM5784),
+	MII_PHY_DESC(BROADCOM3, BCM5717C),
+	MII_PHY_DESC(BROADCOM3, BCM57765),
+	MII_PHY_DESC(xxBROADCOM_ALT1, BCM5906),
 	MII_PHY_END
 };
 
+static const struct mii_phy_funcs brgphy_funcs = {
+	brgphy_service,
+	brgphy_status,
+	brgphy_reset
+};
+
 #define HS21_PRODUCT_ID	"IBM eServer BladeCenter HS21"
 #define HS21_BCM_CHIPID	0x57081021
 
@@ -186,49 +189,22 @@ brgphy_attach(device_t dev)
 	struct bge_softc *bge_sc = NULL;
 	struct bce_softc *bce_sc = NULL;
 	struct mii_softc *sc;
-	struct mii_attach_args *ma;
-	struct mii_data *mii;
 	struct ifnet *ifp;
 
 	bsc = device_get_softc(dev);
 	sc = &bsc->mii_sc;
-	ma = device_get_ivars(dev);
-	sc->mii_dev = device_get_parent(dev);
-	mii = ma->mii_data;
-	LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
-	/* Initialize mii_softc structure */
-	sc->mii_flags = miibus_get_flags(dev);
-	sc->mii_inst = mii->mii_instance++;
-	sc->mii_phy = ma->mii_phyno;
-	sc->mii_service = brgphy_service;
-	sc->mii_pdata = mii;
 
-	/*
-	 * At least some variants wedge when isolating, at least some also
-	 * don't support loopback.
-	 */
-	sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP | MIIF_NOMANPAUSE;
+	mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE,
+	    &brgphy_funcs, 0);
 
-	/* Initialize brgphy_softc structure */
-	bsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
-	bsc->mii_model = MII_MODEL(ma->mii_id2);
-	bsc->mii_rev = MII_REV(ma->mii_id2);
 	bsc->serdes_flags = 0;
 
-	if (bootverbose)
-		device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
-		    bsc->mii_oui, bsc->mii_model, bsc->mii_rev);
-
 	/* Handle any special cases based on the PHY ID */
-	switch (bsc->mii_oui) {
+	switch (sc->mii_mpd_oui) {
 	case MII_OUI_BROADCOM:
-	case MII_OUI_BROADCOM2:
-		break;
-	case MII_OUI_xxBROADCOM:
-		switch (bsc->mii_model) {
-		case MII_MODEL_xxBROADCOM_BCM5706:
-		case MII_MODEL_xxBROADCOM_BCM5714:
+		switch (sc->mii_mpd_model) {

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105031951.p43JpTnT010228>