svn commit: r264293 - head/sys/dev/nfe

Pyun YongHyeon yongari at FreeBSD.org
Wed Apr 9 05:15:41 UTC 2014


Author: yongari
Date: Wed Apr  9 05:15:40 2014
New Revision: 264293
URL: http://svnweb.freebsd.org/changeset/base/264293

Log:
  Add workaround for MCP61 Ethernet controller found on MSI K9
  motherboard.  PHY hardware used for the controller responded at
  all possible addresses which in turn resulted in having 32 PHYs
  for the controller.  If driver detects "MSI K9N6PGM2-V2 (MS-7309)"
  motherboard, tell miibus(4) PHY is located at 0.
  
  Tested by:	Chris H

Modified:
  head/sys/dev/nfe/if_nfe.c

Modified: head/sys/dev/nfe/if_nfe.c
==============================================================================
--- head/sys/dev/nfe/if_nfe.c	Wed Apr  9 03:51:05 2014	(r264292)
+++ head/sys/dev/nfe/if_nfe.c	Wed Apr  9 05:15:40 2014	(r264293)
@@ -79,6 +79,7 @@ static int  nfe_suspend(device_t);
 static int  nfe_resume(device_t);
 static int nfe_shutdown(device_t);
 static int  nfe_can_use_msix(struct nfe_softc *);
+static int  nfe_detect_msik9(struct nfe_softc *);
 static void nfe_power(struct nfe_softc *);
 static int  nfe_miibus_readreg(device_t, int, int);
 static int  nfe_miibus_writereg(device_t, int, int, int);
@@ -334,13 +335,38 @@ nfe_alloc_msix(struct nfe_softc *sc, int
 	}
 }
 
+
+static int
+nfe_detect_msik9(struct nfe_softc *sc)
+{
+	static const char *maker = "MSI";
+	static const char *product = "K9N6PGM2-V2 (MS-7309)";
+	char *m, *p;
+	int found;
+
+	found = 0;
+	m = getenv("smbios.planar.maker");
+	p = getenv("smbios.planar.product");
+	if (m != NULL && p != NULL) {
+		if (strcmp(m, maker) == 0 && strcmp(p, product) == 0)
+			found = 1;
+	}
+	if (m != NULL)
+		freeenv(m);
+	if (p != NULL)
+		freeenv(p);
+
+	return (found);
+}
+
+
 static int
 nfe_attach(device_t dev)
 {
 	struct nfe_softc *sc;
 	struct ifnet *ifp;
 	bus_addr_t dma_addr_max;
-	int error = 0, i, msic, reg, rid;
+	int error = 0, i, msic, phyloc, reg, rid;
 
 	sc = device_get_softc(dev);
 	sc->nfe_dev = dev;
@@ -608,8 +634,16 @@ nfe_attach(device_t dev)
 #endif
 
 	/* Do MII setup */
+	phyloc = MII_PHY_ANY;
+	if (sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN1 ||
+	    sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN2 ||
+	    sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN3 ||
+	    sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN4) {
+		if (nfe_detect_msik9(sc) != 0)
+			phyloc = 0;
+	}
 	error = mii_attach(dev, &sc->nfe_miibus, ifp, nfe_ifmedia_upd,
-	    nfe_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY,
+	    nfe_ifmedia_sts, BMSR_DEFCAPMASK, phyloc, MII_OFFSET_ANY,
 	    MIIF_DOPAUSE);
 	if (error != 0) {
 		device_printf(dev, "attaching PHYs failed\n");


More information about the svn-src-all mailing list