mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-19 10:53:58 +00:00
- 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
This commit is contained in:
parent
abc2df4ae4
commit
4f09c4c7e5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190194
@ -384,6 +384,7 @@ static uint32_t bge_readreg_ind(struct bge_softc *, int);
|
||||
#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, int off, int val)
|
||||
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);
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user