From owner-freebsd-net@FreeBSD.ORG Sat Mar 21 00:30:03 2009 Return-Path: Delivered-To: freebsd-net@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0478106564A for ; Sat, 21 Mar 2009 00:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8DF538FC16 for ; Sat, 21 Mar 2009 00:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n2L0U37j083196 for ; Sat, 21 Mar 2009 00:30:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n2L0U3kC083193; Sat, 21 Mar 2009 00:30:03 GMT (envelope-from gnats) Date: Sat, 21 Mar 2009 00:30:03 GMT Message-Id: <200903210030.n2L0U3kC083193@freefall.freebsd.org> To: freebsd-net@FreeBSD.org From: dfilter@FreeBSD.ORG (dfilter service) Cc: Subject: Re: kern/119361: commit references a PR X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dfilter service List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2009 00:30:03 -0000 The following reply was made to PR kern/119361; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/119361: commit references a PR Date: Sat, 21 Mar 2009 00:23:17 +0000 (UTC) Author: marius Date: Sat Mar 21 00:23:07 2009 New Revision: 190194 URL: http://svn.freebsd.org/changeset/base/190194 Log: - In bge_ifmedia_upd_locked() take advantrage of LIST_FOREACH(). - If boot verbose, print asicrev, chiprev and bus type on attach. - For PCI Express devices: 1) Adjust max read request size to 4Kbytes 2) Turn on FIFO_LONG_BURST in RDMA during bge_blockinit() Though 1) does not seem to have much to do with the poor TX performance observed on PCI Express bge(4), 2) does fix the problem. [1] - Nuke the RX CPU self-diag, which prevents working cards from working (Linux tg3 does not have this diag neither does OpenBSD's bge(4)). The increasing of the firmware handshaking timeout to 20000 retries done as part of the original commit isn't merged as way already have a way higher BGE_TIMEOUT of 100000. PR: 119361 [1] Obtained from: tg3 via DragonflyBSD [1], DragonflyBSD Modified: head/sys/dev/bge/if_bge.c head/sys/dev/bge/if_bgereg.h Modified: head/sys/dev/bge/if_bge.c ============================================================================== --- head/sys/dev/bge/if_bge.c Fri Mar 20 23:55:01 2009 (r190193) +++ head/sys/dev/bge/if_bge.c Sat Mar 21 00:23:07 2009 (r190194) @@ -384,6 +384,7 @@ static uint32_t bge_readreg_ind(struct b #endif static void bge_writemem_direct(struct bge_softc *, int, int); static void bge_writereg_ind(struct bge_softc *, int, int); +static void bge_set_max_readrq(struct bge_softc *, int); static int bge_miibus_readreg(device_t, int, int); static int bge_miibus_writereg(device_t, int, int, int); @@ -523,6 +524,34 @@ bge_writemem_ind(struct bge_softc *sc, i pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4); } +/* + * PCI Express only + */ +static void +bge_set_max_readrq(struct bge_softc *sc, int expr_ptr) +{ + device_t dev; + uint16_t val; + + KASSERT((sc->bge_flags & BGE_FLAG_PCIE) && expr_ptr != 0, + ("%s: not applicable", __func__)); + + dev = sc->bge_dev; + + val = pci_read_config(dev, expr_ptr + BGE_PCIE_DEVCTL, 2); + if ((val & BGE_PCIE_DEVCTL_MAX_READRQ_MASK) != + BGE_PCIE_DEVCTL_MAX_READRQ_4096) { + if (bootverbose) + device_printf(dev, "adjust device control 0x%04x ", + val); + val &= ~BGE_PCIE_DEVCTL_MAX_READRQ_MASK; + val |= BGE_PCIE_DEVCTL_MAX_READRQ_4096; + pci_write_config(dev, expr_ptr + BGE_PCIE_DEVCTL, val, 2); + if (bootverbose) + printf("-> 0x%04x\n", val); + } +} + #ifdef notdef static uint32_t bge_readreg_ind(struct bge_softc *sc, int off) @@ -1278,18 +1307,6 @@ bge_chipinit(struct bge_softc *sc) /* Set endianness before we access any non-PCI registers. */ pci_write_config(sc->bge_dev, BGE_PCI_MISC_CTL, BGE_INIT, 4); - /* - * Check the 'ROM failed' bit on the RX CPU to see if - * self-tests passed. Skip this check when there's no - * chip containing the Ethernet address fitted, since - * in that case it will always fail. - */ - if ((sc->bge_flags & BGE_FLAG_EADDR) && - CSR_READ_4(sc, BGE_RXCPU_MODE) & BGE_RXCPUMODE_ROMFAIL) { - device_printf(sc->bge_dev, "RX CPU self-diagnostics failed!\n"); - return (ENODEV); - } - /* Clear the MAC control register */ CSR_WRITE_4(sc, BGE_MAC_MODE, 0); @@ -1742,14 +1759,18 @@ bge_blockinit(struct bge_softc *sc) /* Enable host coalescing bug fix. */ if (sc->bge_asicrev == BGE_ASICREV_BCM5755 || sc->bge_asicrev == BGE_ASICREV_BCM5787) - val |= 1 << 29; + val |= 1 << 29; /* Turn on write DMA state machine */ CSR_WRITE_4(sc, BGE_WDMA_MODE, val); + DELAY(40); /* Turn on read DMA state machine */ - CSR_WRITE_4(sc, BGE_RDMA_MODE, - BGE_RDMAMODE_ENABLE | BGE_RDMAMODE_ALL_ATTNS); + val = BGE_RDMAMODE_ENABLE | BGE_RDMAMODE_ALL_ATTNS; + if (sc->bge_flags & BGE_FLAG_PCIE) + val |= BGE_RDMAMODE_FIFO_LONG_BURST; + CSR_WRITE_4(sc, BGE_RDMA_MODE, val); + DELAY(40); /* Turn on RX data completion state machine */ CSR_WRITE_4(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE); @@ -2387,7 +2408,7 @@ bge_attach(device_t dev) goto fail; } - /* Save ASIC rev. */ + /* Save various chip information. */ sc->bge_chipid = pci_read_config(dev, BGE_PCI_MISC_CTL, 4) & BGE_PCIMISCCTL_ASICREV; @@ -2470,14 +2491,17 @@ bge_attach(device_t dev) * Found a PCI Express capabilities register, this * must be a PCI Express device. */ - if (reg != 0) + if (reg != 0) { sc->bge_flags |= BGE_FLAG_PCIE; #else if (BGE_IS_5705_PLUS(sc)) { reg = pci_read_config(dev, BGE_PCIE_CAPID_REG, 4); - if ((reg & 0xFF) == BGE_PCIE_CAPID) + if ((reg & 0xFF) == BGE_PCIE_CAPID) { sc->bge_flags |= BGE_FLAG_PCIE; + reg = BGE_PCIE_CAPID; #endif + bge_set_max_readrq(sc, reg); + } } else { /* * Check if the device is in PCI-X Mode. @@ -2522,6 +2546,13 @@ bge_attach(device_t dev) goto fail; } + if (bootverbose) + device_printf(dev, + "CHIP ID 0x%08x; ASIC REV 0x%02x; CHIP REV 0x%02x; %s\n", + sc->bge_chipid, sc->bge_asicrev, sc->bge_chiprev, + (sc->bge_flags & BGE_FLAG_PCIX) ? "PCI-X" : + ((sc->bge_flags & BGE_FLAG_PCIE) ? "PCI-E" : "PCI")); + BGE_LOCK_INIT(sc, device_get_nameunit(dev)); /* Try to reset the chip. */ @@ -3882,6 +3913,7 @@ bge_ifmedia_upd_locked(struct ifnet *ifp { struct bge_softc *sc = ifp->if_softc; struct mii_data *mii; + struct mii_softc *miisc; struct ifmedia *ifm; BGE_LOCK_ASSERT(sc); @@ -3932,12 +3964,9 @@ bge_ifmedia_upd_locked(struct ifnet *ifp sc->bge_link_evt++; mii = device_get_softc(sc->bge_miibus); - if (mii->mii_instance) { - struct mii_softc *miisc; - for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL; - miisc = LIST_NEXT(miisc, mii_list)) + if (mii->mii_instance) + LIST_FOREACH(miisc, &mii->mii_phys, mii_list) mii_phy_reset(miisc); - } mii_mediachg(mii); /* Modified: head/sys/dev/bge/if_bgereg.h ============================================================================== --- head/sys/dev/bge/if_bgereg.h Fri Mar 20 23:55:01 2009 (r190193) +++ head/sys/dev/bge/if_bgereg.h Sat Mar 21 00:23:07 2009 (r190194) @@ -176,6 +176,22 @@ #define BGE_PCI_MSI_ADDR_LO 0x60 #define BGE_PCI_MSI_DATA 0x64 +/* + * PCI Express definitions + * According to + * PCI Express base specification, REV. 1.0a + */ + +/* PCI Express device control, 16bits */ +#define BGE_PCIE_DEVCTL 0x08 +#define BGE_PCIE_DEVCTL_MAX_READRQ_MASK 0x7000 +#define BGE_PCIE_DEVCTL_MAX_READRQ_128 0x0000 +#define BGE_PCIE_DEVCTL_MAX_READRQ_256 0x1000 +#define BGE_PCIE_DEVCTL_MAX_READRQ_512 0x2000 +#define BGE_PCIE_DEVCTL_MAX_READRQ_1024 0x3000 +#define BGE_PCIE_DEVCTL_MAX_READRQ_2048 0x4000 +#define BGE_PCIE_DEVCTL_MAX_READRQ_4096 0x5000 + /* PCI MSI. ??? */ #define BGE_PCIE_CAPID_REG 0xD0 #define BGE_PCIE_CAPID 0x10 @@ -1359,6 +1375,8 @@ #define BGE_RDMAMODE_PCI_FIFOOREAD_ATTN 0x00000100 #define BGE_RDMAMODE_LOCWRITE_TOOBIG 0x00000200 #define BGE_RDMAMODE_ALL_ATTNS 0x000003FC +#define BGE_RDMAMODE_FIFO_SIZE_128 0x00020000 +#define BGE_RDMAMODE_FIFO_LONG_BURST 0x00030000 /* Read DMA status register */ #define BGE_RDMASTAT_PCI_TGT_ABRT_ATTN 0x00000004 _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"