From owner-svn-src-all@FreeBSD.ORG Tue Apr 22 04:36:54 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 36F4884C; Tue, 22 Apr 2014 04:36:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0945710D6; Tue, 22 Apr 2014 04:36:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3M4arKY018698; Tue, 22 Apr 2014 04:36:53 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3M4arhd018697; Tue, 22 Apr 2014 04:36:53 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201404220436.s3M4arhd018697@svn.freebsd.org> From: Pyun YongHyeon Date: Tue, 22 Apr 2014 04:36:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r264748 - stable/9/sys/dev/nfe X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 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: Tue, 22 Apr 2014 04:36:54 -0000 Author: yongari Date: Tue Apr 22 04:36:53 2014 New Revision: 264748 URL: http://svnweb.freebsd.org/changeset/base/264748 Log: MFC r264293: 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. Modified: stable/9/sys/dev/nfe/if_nfe.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/nfe/if_nfe.c ============================================================================== --- stable/9/sys/dev/nfe/if_nfe.c Tue Apr 22 04:35:07 2014 (r264747) +++ stable/9/sys/dev/nfe/if_nfe.c Tue Apr 22 04:36:53 2014 (r264748) @@ -78,6 +78,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); @@ -333,13 +334,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");