Date: Mon, 23 Mar 2009 20:53:38 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r190335 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/bge dev/cxgb Message-ID: <200903232053.n2NKrc2O021383@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Mon Mar 23 20:53:38 2009 New Revision: 190335 URL: http://svn.freebsd.org/changeset/base/190335 Log: MFC: r190194 - 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: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/bge/if_bge.c stable/7/sys/dev/bge/if_bgereg.h stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/bge/if_bge.c ============================================================================== --- stable/7/sys/dev/bge/if_bge.c Mon Mar 23 20:37:37 2009 (r190334) +++ stable/7/sys/dev/bge/if_bge.c Mon Mar 23 20:53:38 2009 (r190335) @@ -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: stable/7/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/7/sys/dev/bge/if_bgereg.h Mon Mar 23 20:37:37 2009 (r190334) +++ stable/7/sys/dev/bge/if_bgereg.h Mon Mar 23 20:53:38 2009 (r190335) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903232053.n2NKrc2O021383>