Date: Fri, 14 Jan 2011 19:16:59 +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: r217412 - head/sys/dev/mii Message-ID: <201101141916.p0EJGxtd097865@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Fri Jan 14 19:16:59 2011 New Revision: 217412 URL: http://svn.freebsd.org/changeset/base/217412 Log: - 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. MFC after: 1 week Modified: head/sys/dev/mii/atphy.c head/sys/dev/mii/e1000phy.c head/sys/dev/mii/ip1000phy.c Modified: head/sys/dev/mii/atphy.c ============================================================================== --- head/sys/dev/mii/atphy.c Fri Jan 14 18:43:14 2011 (r217411) +++ head/sys/dev/mii/atphy.c Fri Jan 14 19:16:59 2011 (r217412) @@ -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: head/sys/dev/mii/e1000phy.c ============================================================================== --- head/sys/dev/mii/e1000phy.c Fri Jan 14 18:43:14 2011 (r217411) +++ head/sys/dev/mii/e1000phy.c Fri Jan 14 19:16:59 2011 (r217412) @@ -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 @@ -372,10 +372,10 @@ e1000phy_service(struct mii_softc *sc, s gig |= E1000_1GCR_MS_ENABLE; if ((ife->ifm_media & IFM_ETH_MASTER) != 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: head/sys/dev/mii/ip1000phy.c ============================================================================== --- head/sys/dev/mii/ip1000phy.c Fri Jan 14 18:43:14 2011 (r217411) +++ head/sys/dev/mii/ip1000phy.c Fri Jan 14 19:16:59 2011 (r217412) @@ -186,22 +186,21 @@ 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) - 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) + 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?201101141916.p0EJGxtd097865>