Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/pci Pull up following revision(s) (requested by b...
details: https://anonhg.NetBSD.org/src/rev/c5941f4bb1ae
branches: netbsd-8
changeset: 446497:c5941f4bb1ae
user: martin <martin%NetBSD.org@localhost>
date: Sat Dec 08 12:10:22 2018 +0000
description:
Pull up following revision(s) (requested by bouyer in ticket #1130):
sys/dev/pci/if_bge.c: revision 1.320
sys/dev/pci/if_bgevar.h: revision 1.24
sys/dev/pci/if_bge.c: revision 1.317
sys/dev/pci/if_bgereg.h: revision 1.94
More TSO4 fixes, from the freebsd driver:
- the chip doens't want the lenght of options, but the complete lenght of
ip headers (ip + tcp + options). Fix this for the BGE_IS_5717_PLUS()
and BGE_IS_5705_PLUS() cases; FreeBSD doens't cover the last case so
leave it as is for now. This fixes checksum failures for heavy transfers.
- It looks like the transmit engine hangs if the TCP segment crosses a 4GB
boundary. FreeBSD fixes it by mapping everything below 4GB; instead
try detect when this happens and do the bounce only when needed.
With these fixes I could transfers 3GB images over ftp at gigabit speed
(112MB/s with wget) without problems. Tested on a
bge0 at pci4 dev 0 function 0: Broadcom BCM5720 Gigabit Ethernet
bge0: APE firmware NCSI 1.4.22.0
bge0: interrupting at msi1 vec 0
bge0: HW config 002b1194, 00006014, 0002aa38, 00000000 0000000c
bge0: ASIC BCM5720 A0 (0x5720000), Ethernet address d0:94:66:8b:9c:18
bge0: setting short Tx thresholds
brgphy0 at bge0 phy 1: BCM5720C 1000BASE-T media interface, rev. 0
-
Don't destroy the dma maps if we're not disabling the adapter, avoids
a KASSERT() when bus_dmamap_destroy() is called from interrupt
context via bge_watchdog()
Set IFF_OACTIVE only when bge_encap() fails on adapter ressource shortage.
Otherwise we may set IFF_OACTIVE while no transmit is in progress, and
nothing will clear it.
If bus_dmamap_load_mbuf() fails with EFBIG, m_defrag() the chain and retry.
Refine the check for the 4GB boundary workaround (a fragment should also
not cross the boundary), and do it only for TSO.
If bge_encap() fails and didn't set IFF_OACTIVE, drop the packet.
Bring in more hardware bug workarounds from freebsd.
With these it seems that a BCM5720 A0 can survive a few hours of internet
load with TSO4 enabled.
diffstat:
sys/dev/pci/if_bge.c | 274 +++++++++++++++++++++++++++++++++++++----------
sys/dev/pci/if_bgereg.h | 7 +-
sys/dev/pci/if_bgevar.h | 6 +-
3 files changed, 224 insertions(+), 63 deletions(-)
diffs (truncated from 600 to 300 lines):
diff -r d014f86350e6 -r c5941f4bb1ae sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c Fri Dec 07 19:41:30 2018 +0000
+++ b/sys/dev/pci/if_bge.c Sat Dec 08 12:10:22 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bge.c,v 1.310.2.3 2018/11/26 17:22:32 snj Exp $ */
+/* $NetBSD: if_bge.c,v 1.310.2.4 2018/12/08 12:10:22 martin Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.3 2018/11/26 17:22:32 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.4 2018/12/08 12:10:22 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -233,10 +233,10 @@
bus_dmamap_t);
static int bge_newbuf_jumbo(struct bge_softc *, int, struct mbuf *);
static int bge_init_rx_ring_std(struct bge_softc *);
-static void bge_free_rx_ring_std(struct bge_softc *);
+static void bge_free_rx_ring_std(struct bge_softc *m, bool);
static int bge_init_rx_ring_jumbo(struct bge_softc *);
static void bge_free_rx_ring_jumbo(struct bge_softc *);
-static void bge_free_tx_ring(struct bge_softc *);
+static void bge_free_tx_ring(struct bge_softc *m, bool);
static int bge_init_tx_ring(struct bge_softc *);
static int bge_chipinit(struct bge_softc *);
@@ -1713,6 +1713,9 @@
struct bge_rx_bd *r;
int error;
+ if (dmamap == NULL)
+ dmamap = sc->bge_cdata.bge_rx_std_map[i];
+
if (dmamap == NULL) {
error = bus_dmamap_create(sc->bge_dmatag, MCLBYTES, 1,
MCLBYTES, 0, BUS_DMA_NOWAIT, &dmamap);
@@ -1852,7 +1855,7 @@
}
static void
-bge_free_rx_ring_std(struct bge_softc *sc)
+bge_free_rx_ring_std(struct bge_softc *sc, bool disable)
{
int i;
@@ -1863,8 +1866,11 @@
if (sc->bge_cdata.bge_rx_std_chain[i] != NULL) {
m_freem(sc->bge_cdata.bge_rx_std_chain[i]);
sc->bge_cdata.bge_rx_std_chain[i] = NULL;
- bus_dmamap_destroy(sc->bge_dmatag,
- sc->bge_cdata.bge_rx_std_map[i]);
+ if (disable) {
+ bus_dmamap_destroy(sc->bge_dmatag,
+ sc->bge_cdata.bge_rx_std_map[i]);
+ sc->bge_cdata.bge_rx_std_map[i] = NULL;
+ }
}
memset((char *)&sc->bge_rdata->bge_rx_std_ring[i], 0,
sizeof(struct bge_rx_bd));
@@ -1920,7 +1926,7 @@
}
static void
-bge_free_tx_ring(struct bge_softc *sc)
+bge_free_tx_ring(struct bge_softc *sc, bool disable)
{
int i;
struct txdmamap_pool_entry *dma;
@@ -1940,10 +1946,17 @@
sizeof(struct bge_tx_bd));
}
- while ((dma = SLIST_FIRST(&sc->txdma_list))) {
- SLIST_REMOVE_HEAD(&sc->txdma_list, link);
- bus_dmamap_destroy(sc->bge_dmatag, dma->dmamap);
- free(dma, M_DEVBUF);
+ if (disable) {
+ while ((dma = SLIST_FIRST(&sc->txdma_list))) {
+ SLIST_REMOVE_HEAD(&sc->txdma_list, link);
+ bus_dmamap_destroy(sc->bge_dmatag, dma->dmamap);
+ if (sc->bge_dma64) {
+ bus_dmamap_destroy(sc->bge_dmatag32,
+ dma->dmamap32);
+ }
+ free(dma, M_DEVBUF);
+ }
+ SLIST_INIT(&sc->txdma_list);
}
sc->bge_flags &= ~BGEF_TXRING_VALID;
@@ -1954,7 +1967,7 @@
{
struct ifnet *ifp = &sc->ethercom.ec_if;
int i;
- bus_dmamap_t dmamap;
+ bus_dmamap_t dmamap, dmamap32;
bus_size_t maxsegsz;
struct txdmamap_pool_entry *dma;
@@ -1985,25 +1998,43 @@
maxsegsz = 4096;
else
maxsegsz = ETHER_MAX_LEN_JUMBO;
- SLIST_INIT(&sc->txdma_list);
+
+ if (SLIST_FIRST(&sc->txdma_list) != NULL)
+ goto alloc_done;
+
for (i = 0; i < BGE_TX_RING_CNT; i++) {
if (bus_dmamap_create(sc->bge_dmatag, BGE_TXDMA_MAX,
- BGE_NTXSEG, maxsegsz, 0, BUS_DMA_NOWAIT,
+ BGE_NTXSEG, maxsegsz, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
&dmamap))
return ENOBUFS;
if (dmamap == NULL)
panic("dmamap NULL in bge_init_tx_ring");
+ if (sc->bge_dma64) {
+ if (bus_dmamap_create(sc->bge_dmatag32, BGE_TXDMA_MAX,
+ BGE_NTXSEG, maxsegsz, 0,
+ BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
+ &dmamap32)) {
+ bus_dmamap_destroy(sc->bge_dmatag, dmamap);
+ return ENOBUFS;
+ }
+ if (dmamap32 == NULL)
+ panic("dmamap32 NULL in bge_init_tx_ring");
+ } else
+ dmamap32 = dmamap;
dma = malloc(sizeof(*dma), M_DEVBUF, M_NOWAIT);
if (dma == NULL) {
aprint_error_dev(sc->bge_dev,
"can't alloc txdmamap_pool_entry\n");
bus_dmamap_destroy(sc->bge_dmatag, dmamap);
+ if (sc->bge_dma64)
+ bus_dmamap_destroy(sc->bge_dmatag32, dmamap32);
return ENOMEM;
}
dma->dmamap = dmamap;
+ dma->dmamap32 = dmamap32;
SLIST_INSERT_HEAD(&sc->txdma_list, dma, link);
}
-
+alloc_done:
sc->bge_flags |= BGEF_TXRING_VALID;
return 0;
@@ -3123,12 +3154,30 @@
BGE_RDMA_LSO_CRPTEN_CTRL_BLEN_BD_512 |
BGE_RDMA_LSO_CRPTEN_CTRL_BLEN_LSO_4K);
}
-
/* Turn on read DMA state machine */
CSR_WRITE_4_FLUSH(sc, BGE_RDMA_MODE, val);
/* 5718 step 52 */
delay(40);
+ if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5719 ||
+ BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5720) {
+ for (i = 0; i < BGE_NUM_RDMA_CHANNELS / 2; i++) {
+ val = CSR_READ_4(sc, BGE_RDMA_LENGTH + i * 4);
+ if ((val & 0xFFFF) > BGE_FRAMELEN)
+ break;
+ if (((val >> 16) & 0xFFFF) > BGE_FRAMELEN)
+ break;
+ }
+ if (i != BGE_NUM_RDMA_CHANNELS / 2) {
+ val = CSR_READ_4(sc, BGE_RDMA_LSO_CRPTEN_CTRL);
+ if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5719)
+ val |= BGE_RDMA_TX_LENGTH_WA_5719;
+ else
+ val |= BGE_RDMA_TX_LENGTH_WA_5720;
+ CSR_WRITE_4(sc, BGE_RDMA_LSO_CRPTEN_CTRL, val);
+ }
+ }
+
/* 5718 step 56, 57XX step 84 */
/* Turn on RX data completion state machine */
CSR_WRITE_4(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE);
@@ -3875,10 +3924,15 @@
aprint_normal(", Ethernet address %s\n", ether_sprintf(eaddr));
/* Allocate the general information block and ring buffers. */
- if (pci_dma64_available(pa))
+ if (pci_dma64_available(pa)) {
sc->bge_dmatag = pa->pa_dmat64;
- else
+ sc->bge_dmatag32 = pa->pa_dmat;
+ sc->bge_dma64 = true;
+ } else {
sc->bge_dmatag = pa->pa_dmat;
+ sc->bge_dmatag32 = pa->pa_dmat;
+ sc->bge_dma64 = false;
+ }
/* 40bit DMA workaround */
if (sizeof(bus_addr_t) > 4) {
@@ -3895,6 +3949,7 @@
}
}
}
+ SLIST_INIT(&sc->txdma_list);
DPRINTFN(5, ("bus_dmamem_alloc\n"));
if (bus_dmamem_alloc(sc->bge_dmatag, sizeof(struct bge_ring_data),
PAGE_SIZE, 0, &sc->bge_ring_seg, 1,
@@ -4574,7 +4629,7 @@
sc->bge_cdata.bge_rx_std_chain[rxidx] = NULL;
stdcnt++;
dmamap = sc->bge_cdata.bge_rx_std_map[rxidx];
- sc->bge_cdata.bge_rx_std_map[rxidx] = 0;
+ sc->bge_cdata.bge_rx_std_map[rxidx] = NULL;
if (dmamap == NULL) {
ifp->if_ierrors++;
bge_newbuf_std(sc, sc->bge_std, m, dmamap);
@@ -4729,9 +4784,18 @@
if (m != NULL) {
sc->bge_cdata.bge_tx_chain[idx] = NULL;
dma = sc->txdma[idx];
- bus_dmamap_sync(sc->bge_dmatag, dma->dmamap, 0,
- dma->dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE);
- bus_dmamap_unload(sc->bge_dmatag, dma->dmamap);
+ if (dma->is_dma32) {
+ bus_dmamap_sync(sc->bge_dmatag32, dma->dmamap32,
+ 0, dma->dmamap32->dm_mapsize,
+ BUS_DMASYNC_POSTWRITE);
+ bus_dmamap_unload(
+ sc->bge_dmatag32, dma->dmamap32);
+ } else {
+ bus_dmamap_sync(sc->bge_dmatag, dma->dmamap,
+ 0, dma->dmamap->dm_mapsize,
+ BUS_DMASYNC_POSTWRITE);
+ bus_dmamap_unload(sc->bge_dmatag, dma->dmamap);
+ }
SLIST_INSERT_HEAD(&sc->txdma_list, dma, link);
sc->txdma[idx] = NULL;
@@ -4913,7 +4977,17 @@
ifp->if_collisions += CSR_READ_4(sc, BGE_MAC_STATS +
offsetof(struct bge_mac_stats_regs, etherStatsCollisions));
- ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS);
+ /*
+ * On BCM5717, BCM5718, BCM5719 A0 and BCM5720 A0,
+ * RXLP_LOCSTAT_IFIN_DROPS includes unwanted multicast frames
+ * (silicon bug). There's no reliable workaround so just
+ * ignore the counter
+ */
+ if (BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5717 &&
+ BGE_ASICREV(sc->bge_chipid) != BGE_CHIPID_BCM5719_A0 &&
+ BGE_ASICREV(sc->bge_chipid) != BGE_CHIPID_BCM5720_A0) {
+ ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS);
+ }
ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS);
ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_OUT_OF_BDS);
}
@@ -5132,18 +5206,19 @@
static int
bge_encap(struct bge_softc *sc, struct mbuf *m_head, uint32_t *txidx)
{
- struct bge_tx_bd *f = NULL;
+ struct ifnet *ifp = &sc->ethercom.ec_if;
+ struct bge_tx_bd *f, *prev_f;
uint32_t frag, cur;
uint16_t csum_flags = 0;
uint16_t txbd_tso_flags = 0;
struct txdmamap_pool_entry *dma;
bus_dmamap_t dmamap;
+ bus_dma_tag_t dmatag;
int i = 0;
int use_tso, maxsegsize, error;
bool have_vtag;
uint16_t vtag;
-
- cur = frag = *txidx;
+ bool remap;
if (m_head->m_pkthdr.csum_flags) {
if (m_head->m_pkthdr.csum_flags & M_CSUM_IPv4)
@@ -5167,7 +5242,7 @@
goto check_dma_bug;
if (bge_cksum_pad(m_head) != 0)
- return ENOBUFS;
+ return ENOBUFS;
check_dma_bug:
if (!(BGE_CHIPREV(sc->bge_chipid) == BGE_CHIPREV_5700_BX))
@@ -5183,9 +5258,13 @@
doit:
dma = SLIST_FIRST(&sc->txdma_list);
- if (dma == NULL)
+ if (dma == NULL) {
+ ifp->if_flags |= IFF_OACTIVE;
return ENOBUFS;
+ }
Home |
Main Index |
Thread Index |
Old Index