Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jan 2011 00:40:25 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r217670 - stable/8/sys/dev/mii
Message-ID:  <201101210040.p0L0ePCm033276@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Fri Jan 21 00:40:25 2011
New Revision: 217670
URL: http://svn.freebsd.org/changeset/base/217670

Log:
  MFC: r217412
  
  - Masking IFM_GMASK when also masking IFM_FDX is redundant and just
    complicates the code.
  - Don't let atphy_setmedia() announce PAUSE support for half-duplex when
    MIIF_FORCEPAUSE is set.
  - Simplify e1000phy_service() and ip1000phy_service() to only set the
    manual configuration bits once after we have figured them all out. For
    ip1000phy_service() this also means we no longer unnecessarily update
    the hardware along the road.

Modified:
  stable/8/sys/dev/mii/atphy.c
  stable/8/sys/dev/mii/e1000phy.c
  stable/8/sys/dev/mii/ip1000phy.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/mii/atphy.c
==============================================================================
--- stable/8/sys/dev/mii/atphy.c	Fri Jan 21 00:35:34 2011	(r217669)
+++ stable/8/sys/dev/mii/atphy.c	Fri Jan 21 00:40:25 2011	(r217670)
@@ -187,9 +187,9 @@ atphy_service(struct mii_softc *sc, stru
 		}
 
 		anar = atphy_anar(ife);
-		if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
+		if ((ife->ifm_media & IFM_FDX) != 0) {
 			bmcr |= BMCR_FDX;
-			if (((ife->ifm_media & IFM_GMASK) & IFM_FLOW) != 0 ||
+			if ((ife->ifm_media & IFM_FLOW) != 0 ||
 			    (sc->mii_flags & MIIF_FORCEPAUSE) != 0)
 				anar |= ANAR_PAUSE_TOWARDS;
 		}
@@ -371,7 +371,7 @@ atphy_anar(struct ifmedia_entry *ife)
 		return (0);
 	}
 
-	if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
+	if ((ife->ifm_media & IFM_FDX) != 0) {
 		if (IFM_SUBTYPE(ife->ifm_media) == IFM_100_TX)
 			anar |= ANAR_TX_FD;
 		else
@@ -387,13 +387,13 @@ atphy_setmedia(struct mii_softc *sc, int
 	uint16_t anar;
 
 	anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
-	if (((IFM_SUBTYPE(media) == IFM_AUTO ||
-	    ((media & IFM_GMASK) & IFM_FDX) != 0) &&
-	    ((media & IFM_GMASK) & IFM_FLOW) != 0) ||
-	    (sc->mii_flags & MIIF_FORCEPAUSE) != 0)
+	if ((IFM_SUBTYPE(media) == IFM_AUTO || (media & IFM_FDX) != 0) &&
+	    ((media & IFM_FLOW) != 0 ||
+	    (sc->mii_flags & MIIF_FORCEPAUSE) != 0))
 		anar |= ANAR_PAUSE_TOWARDS;
 	PHY_WRITE(sc, MII_ANAR, anar);
-	if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
+	if ((sc->mii_extcapabilities &
+	     (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
 		PHY_WRITE(sc, MII_100T2CR, GTCR_ADV_1000TFDX |
 		    GTCR_ADV_1000THDX);
 	PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG);

Modified: stable/8/sys/dev/mii/e1000phy.c
==============================================================================
--- stable/8/sys/dev/mii/e1000phy.c	Fri Jan 21 00:35:34 2011	(r217669)
+++ stable/8/sys/dev/mii/e1000phy.c	Fri Jan 21 00:40:25 2011	(r217670)
@@ -358,7 +358,7 @@ e1000phy_service(struct mii_softc *sc, s
 			return (EINVAL);
 		}
 
-		if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
+		if ((ife->ifm_media & IFM_FDX) != 0) {
 			speed |= E1000_CR_FULL_DUPLEX;
 			gig = E1000_1GCR_1000T_FD;
 		} else
@@ -373,10 +373,10 @@ e1000phy_service(struct mii_softc *sc, s
 			if ((ife->ifm_media & IFM_ETH_MASTER) != 0 ||
 			    (mii->mii_ifp->if_flags & IFF_LINK0) != 0)	
 				gig |= E1000_1GCR_MS_VALUE;
-			PHY_WRITE(sc, E1000_1GCR, gig);
 		} else if ((sc->mii_extcapabilities &
 		    (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
-			PHY_WRITE(sc, E1000_1GCR, 0);
+			gig = 0;
+		PHY_WRITE(sc, E1000_1GCR, gig);
 		PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD);
 		PHY_WRITE(sc, E1000_CR, speed | E1000_CR_RESET);
 done:

Modified: stable/8/sys/dev/mii/ip1000phy.c
==============================================================================
--- stable/8/sys/dev/mii/ip1000phy.c	Fri Jan 21 00:35:34 2011	(r217669)
+++ stable/8/sys/dev/mii/ip1000phy.c	Fri Jan 21 00:40:25 2011	(r217670)
@@ -186,23 +186,22 @@ ip1000phy_service(struct mii_softc *sc, 
 			return (EINVAL);
 		}
 
-		if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
+		if ((ife->ifm_media & IFM_FDX) != 0) {
 			speed |= IP1000PHY_BMCR_FDX;
 			gig = IP1000PHY_1000CR_1000T_FDX;
 		} else
 			gig = IP1000PHY_1000CR_1000T;
 
-		PHY_WRITE(sc, IP1000PHY_MII_1000CR, 0);
-		PHY_WRITE(sc, IP1000PHY_MII_BMCR, speed);
-
-		if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)
-			break;
-
-		gig |= IP1000PHY_1000CR_MASTER | IP1000PHY_1000CR_MANUAL;
-		if ((ife->ifm_media & IFM_ETH_MASTER) != 0 ||
-		    (mii->mii_ifp->if_flags & IFF_LINK0) != 0)
-			gig |= IP1000PHY_1000CR_MMASTER;
+		if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
+			gig |=
+			    IP1000PHY_1000CR_MASTER | IP1000PHY_1000CR_MANUAL;
+			if ((ife->ifm_media & IFM_ETH_MASTER) != 0 ||
+			    (mii->mii_ifp->if_flags & IFF_LINK0) != 0)
+				gig |= IP1000PHY_1000CR_MMASTER;
+		} else
+			gig = 0;
 		PHY_WRITE(sc, IP1000PHY_MII_1000CR, gig);
+		PHY_WRITE(sc, IP1000PHY_MII_BMCR, speed);
 
 done:
 		break;



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