Date: Fri, 14 Jan 2011 19:29:53 +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: r217413 - head/sys/dev/mii Message-ID: <201101141929.p0EJTrTc098204@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Fri Jan 14 19:29:53 2011 New Revision: 217413 URL: http://svn.freebsd.org/changeset/base/217413 Log: - Even after masking the media with IFM_GMASK the result may have bits besides the duplex ones set so just comparing it with IFM_FDX may lead to false negatives. - Simplify ciphy_service() to only set the manual configuration bits once after we have figured them all out. This also means we no longer unnecessarily update the hardware along the road. MFC after: 1 week Modified: head/sys/dev/mii/brgphy.c head/sys/dev/mii/ciphy.c head/sys/dev/mii/xmphy.c Modified: head/sys/dev/mii/brgphy.c ============================================================================== --- head/sys/dev/mii/brgphy.c Fri Jan 14 19:16:59 2011 (r217412) +++ head/sys/dev/mii/brgphy.c Fri Jan 14 19:29:53 2011 (r217413) @@ -453,7 +453,7 @@ brgphy_setmedia(struct mii_softc *sc, in break; } - if ((media & IFM_GMASK) == IFM_FDX) { + if ((media & IFM_FDX) != 0) { bmcr |= BRGPHY_BMCR_FDX; gig = BRGPHY_1000CTL_AFD; } else { Modified: head/sys/dev/mii/ciphy.c ============================================================================== --- head/sys/dev/mii/ciphy.c Fri Jan 14 19:16:59 2011 (r217412) +++ head/sys/dev/mii/ciphy.c Fri Jan 14 19:29:53 2011 (r217413) @@ -176,26 +176,23 @@ ciphy_service(struct mii_softc *sc, stru case IFM_10_T: speed = CIPHY_S10; setit: - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { + if ((ife->ifm_media & IFM_FDX) != 0) { speed |= CIPHY_BMCR_FDX; gig = CIPHY_1000CTL_AFD; - } else { + } else gig = CIPHY_1000CTL_AHD; - } - PHY_WRITE(sc, CIPHY_MII_1000CTL, 0); + if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) { + gig |= CIPHY_1000CTL_MSE; + if ((ife->ifm_media & IFM_ETH_MASTER) != 0) + gig |= CIPHY_1000CTL_MSC; + speed |= + CIPHY_BMCR_AUTOEN | CIPHY_BMCR_STARTNEG; + } else + gig = 0; + PHY_WRITE(sc, CIPHY_MII_1000CTL, gig); PHY_WRITE(sc, CIPHY_MII_BMCR, speed); PHY_WRITE(sc, CIPHY_MII_ANAR, CIPHY_SEL_TYPE); - - if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) - break; - - gig |= CIPHY_1000CTL_MSE; - if ((ife->ifm_media & IFM_ETH_MASTER) != 0) - gig |= CIPHY_1000CTL_MSC; - PHY_WRITE(sc, CIPHY_MII_1000CTL, gig); - PHY_WRITE(sc, CIPHY_MII_BMCR, - speed | CIPHY_BMCR_AUTOEN | CIPHY_BMCR_STARTNEG); break; case IFM_NONE: PHY_WRITE(sc, MII_BMCR, BMCR_ISO | BMCR_PDOWN); Modified: head/sys/dev/mii/xmphy.c ============================================================================== --- head/sys/dev/mii/xmphy.c Fri Jan 14 19:16:59 2011 (r217412) +++ head/sys/dev/mii/xmphy.c Fri Jan 14 19:29:53 2011 (r217413) @@ -171,7 +171,7 @@ xmphy_service(struct mii_softc *sc, stru break; case IFM_1000_SX: mii_phy_reset(sc); - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { + if ((ife->ifm_media & IFM_FDX) != 0) { PHY_WRITE(sc, XMPHY_MII_ANAR, XMPHY_ANAR_FDX); PHY_WRITE(sc, XMPHY_MII_BMCR, XMPHY_BMCR_FDX); } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101141929.p0EJTrTc098204>