From owner-svn-src-all@FreeBSD.ORG Fri Jan 14 19:39:12 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B916110656A3; Fri, 14 Jan 2011 19:39:12 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A76CD8FC14; Fri, 14 Jan 2011 19:39:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0EJdC0e098502; Fri, 14 Jan 2011 19:39:12 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EJdCPH098500; Fri, 14 Jan 2011 19:39:12 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201101141939.p0EJdCPH098500@svn.freebsd.org> From: Marius Strobl Date: Fri, 14 Jan 2011 19:39:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217415 - head/sys/dev/mii X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 19:39:12 -0000 Author: marius Date: Fri Jan 14 19:39:12 2011 New Revision: 217415 URL: http://svn.freebsd.org/changeset/base/217415 Log: - Allow IFM_FLAG0 to be set indicating that auto-negotiation with manual configuration, which is used to work around issues with certain setups (see r161237) by default, should not be triggered as it may in turn cause harm in some edge cases. - 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. - Announce PAUSE support also for manually selected 1000BASE-T, but for all manually selected media types only in full-duplex mode. Announce asymmetric PAUSE support only for manually selected 1000BASE-T. - Simplify setting the manual configuration bits to only once after we have figured them all out. This also means we no longer unnecessarily update the hardware along the road. - Remove a stale comment. Reviewed by: yongari (plus additional testing) MFC after: 3 days Modified: head/sys/dev/mii/rgephy.c Modified: head/sys/dev/mii/rgephy.c ============================================================================== --- head/sys/dev/mii/rgephy.c Fri Jan 14 19:33:58 2011 (r217414) +++ head/sys/dev/mii/rgephy.c Fri Jan 14 19:39:12 2011 (r217415) @@ -146,6 +146,13 @@ rgephy_attach(device_t dev) mii_phy_add_media(sc); printf("\n"); #undef ADD + /* + * Allow IFM_FLAG0 to be set indicating that auto-negotiation with + * manual configuration, which is used to work around issues with + * certain setups by default, should not be triggered as it may in + * turn cause harm in some edge cases. + */ + mii->mii_media.ifm_mask |= IFM_FLAG0; rgephy_reset(sc); MIIBUS_MEDIAINIT(sc->mii_dev); @@ -201,37 +208,38 @@ rgephy_service(struct mii_softc *sc, str speed = RGEPHY_S10; anar |= RGEPHY_ANAR_10_FD | RGEPHY_ANAR_10; setit: - rgephy_loop(sc); - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { + if ((ife->ifm_media & IFM_FLOW) != 0 && + (mii->mii_media.ifm_media & IFM_FLAG0) != 0) + return (EINVAL); + + if ((ife->ifm_media & IFM_FDX) != 0) { speed |= RGEPHY_BMCR_FDX; gig = RGEPHY_1000CTL_AFD; anar &= ~(RGEPHY_ANAR_TX | RGEPHY_ANAR_10); + if ((ife->ifm_media & IFM_FLOW) != 0 || + (sc->mii_flags & MIIF_FORCEPAUSE) != 0) + anar |= + RGEPHY_ANAR_PC | RGEPHY_ANAR_ASP; } else { gig = RGEPHY_1000CTL_AHD; anar &= ~(RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_10_FD); } - - if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) { - PHY_WRITE(sc, RGEPHY_MII_1000CTL, 0); - PHY_WRITE(sc, RGEPHY_MII_ANAR, anar); - PHY_WRITE(sc, RGEPHY_MII_BMCR, speed | - RGEPHY_BMCR_AUTOEN | - RGEPHY_BMCR_STARTNEG); - break; + if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) { + gig |= RGEPHY_1000CTL_MSE; + if ((ife->ifm_media & IFM_ETH_MASTER) != 0) + gig |= RGEPHY_1000CTL_MSC; + } else { + gig = 0; + anar &= ~RGEPHY_ANAR_ASP; } - - if ((ife->ifm_media & IFM_FLOW) != 0 || - (sc->mii_flags & MIIF_FORCEPAUSE) != 0) - anar |= RGEPHY_ANAR_PC | RGEPHY_ANAR_ASP; - - gig |= RGEPHY_1000CTL_MSE; - if ((ife->ifm_media & IFM_ETH_MASTER) != 0) - gig |= RGEPHY_1000CTL_MSC; + if ((mii->mii_media.ifm_media & IFM_FLAG0) == 0) + speed |= + RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG; + rgephy_loop(sc); PHY_WRITE(sc, RGEPHY_MII_1000CTL, gig); PHY_WRITE(sc, RGEPHY_MII_ANAR, anar); - PHY_WRITE(sc, RGEPHY_MII_BMCR, speed | - RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG); + PHY_WRITE(sc, RGEPHY_MII_BMCR, speed); break; case IFM_NONE: PHY_WRITE(sc, MII_BMCR, BMCR_ISO | BMCR_PDOWN); @@ -258,8 +266,7 @@ setit: /* * Check to see if we have link. If we do, we don't - * need to restart the autonegotiation process. Read - * the BMSR twice in case it's latched. + * need to restart the autonegotiation process. */ if (rsc->mii_revision >= 2) { /* RTL8211B(L) */