svn commit: r213808 - head/sys/dev/bge

Pyun YongHyeon yongari at FreeBSD.org
Wed Oct 13 21:53:37 UTC 2010


Author: yongari
Date: Wed Oct 13 21:53:37 2010
New Revision: 213808
URL: http://svn.freebsd.org/changeset/base/213808

Log:
  Add more checks for resolved link speed in bge_miibus_statchg().
  Link UP state could be reported first before actual completion of
  auto-negotiation. This change makes bge(4) reprogram BGE_MAC_MODE,
  BGE_TX_MODE and BGE_RX_MODE register only after controller got a
  valid link.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Wed Oct 13 21:45:56 2010	(r213807)
+++ head/sys/dev/bge/if_bge.c	Wed Oct 13 21:53:37 2010	(r213808)
@@ -878,6 +878,29 @@ bge_miibus_statchg(device_t dev)
 	sc = device_get_softc(dev);
 	mii = device_get_softc(sc->bge_miibus);
 
+	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
+	    (IFM_ACTIVE | IFM_AVALID)) {
+		switch (IFM_SUBTYPE(mii->mii_media_active)) {
+		case IFM_10_T:
+		case IFM_100_TX:
+			sc->bge_link = 1;
+			break;
+		case IFM_1000_T:
+		case IFM_1000_SX:
+		case IFM_2500_SX:
+			if (sc->bge_asicrev != BGE_ASICREV_BCM5906)
+				sc->bge_link = 1;
+			else
+				sc->bge_link = 0;
+			break;
+		default:
+			sc->bge_link = 0;
+			break;
+		}
+	} else
+		sc->bge_link = 0;
+	if (sc->bge_link == 0)
+		return;
 	BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE);
 	if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T ||
 	    IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX)
@@ -5065,12 +5088,7 @@ bge_link_upd(struct bge_softc *sc)
 		 */
 		mii = device_get_softc(sc->bge_miibus);
 		mii_pollstat(mii);
-		if (!sc->bge_link && mii->mii_media_status & IFM_ACTIVE &&
-		    IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
-			bge_miibus_statchg(sc->bge_dev);
-			sc->bge_link = 1;
-		} else
-			sc->bge_link = 0;
+		bge_miibus_statchg(sc->bge_dev);
 	}
 
 	/* Clear the attention. */


More information about the svn-src-all mailing list