summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/dev/dwc
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-03-30 11:51:36 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-10 09:53:33 +0100
commitd9ff8281d707326749e010766f9a32267a395bef (patch)
tree741362c6dcc1999fef18fc2271afabb7ce6fdf0c /freebsd/sys/dev/dwc
parentif_dwc: Fix transmit starvation (diff)
downloadrtems-libbsd-d9ff8281d707326749e010766f9a32267a395bef.tar.bz2
if_dwc: Simplify tx desc setup
Diffstat (limited to 'freebsd/sys/dev/dwc')
-rw-r--r--freebsd/sys/dev/dwc/if_dwc.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/freebsd/sys/dev/dwc/if_dwc.c b/freebsd/sys/dev/dwc/if_dwc.c
index ae0ae876..f7e97756 100644
--- a/freebsd/sys/dev/dwc/if_dwc.c
+++ b/freebsd/sys/dev/dwc/if_dwc.c
@@ -177,40 +177,28 @@ dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr,
uint32_t len)
{
uint32_t flags;
- uint32_t nidx;
-
- nidx = next_txidx(sc, idx);
- /* Addr/len 0 means we're clearing the descriptor after xmit done. */
- if (paddr == 0 || len == 0) {
- flags = 0;
- --sc->txcount;
- } else {
- if (sc->mactype == DWC_GMAC_ALT_DESC)
- flags = DDESC_CNTL_TXCHAIN | DDESC_CNTL_TXFIRST
- | DDESC_CNTL_TXLAST | DDESC_CNTL_TXINT;
- else
- flags = DDESC_TDES0_TXCHAIN | DDESC_TDES0_TXFIRST
- | DDESC_TDES0_TXLAST | DDESC_TDES0_TXINT;
- ++sc->txcount;
- }
+ ++sc->txcount;
sc->txdesc_ring[idx].addr = (uint32_t)(paddr);
if (sc->mactype == DWC_GMAC_ALT_DESC) {
+ flags = DDESC_CNTL_TXCHAIN | DDESC_CNTL_TXFIRST
+ | DDESC_CNTL_TXLAST | DDESC_CNTL_TXINT;
sc->txdesc_ring[idx].tdes0 = 0;
sc->txdesc_ring[idx].tdes1 = flags | len;
} else {
+ flags = DDESC_TDES0_TXCHAIN | DDESC_TDES0_TXFIRST
+ | DDESC_TDES0_TXLAST | DDESC_TDES0_TXINT;
sc->txdesc_ring[idx].tdes0 = flags;
sc->txdesc_ring[idx].tdes1 = len;
}
+ wmb();
- if (paddr && len) {
- wmb();
- sc->txdesc_ring[idx].tdes0 |= DDESC_TDES0_OWN;
- wmb();
- }
+ sc->txdesc_ring[idx].tdes0 = DDESC_TDES0_TXCHAIN | DDESC_TDES0_TXFIRST
+ | DDESC_TDES0_TXLAST | DDESC_TDES0_TXINT | DDESC_TDES0_OWN;
+ wmb();
- return (nidx);
+ return (next_txidx(sc, idx));
}
static int
@@ -728,7 +716,7 @@ dwc_txfinish_locked(struct dwc_softc *sc)
bus_dmamap_unload(sc->txbuf_tag, bmap->map);
m_freem(bmap->mbuf);
bmap->mbuf = NULL;
- dwc_setup_txdesc(sc, sc->tx_idx_tail, 0, 0);
+ --sc->txcount;
sc->tx_idx_tail = next_txidx(sc, sc->tx_idx_tail);
}
@@ -880,6 +868,14 @@ setup_dma(struct dwc_softc *sc)
}
for (idx = 0; idx < TX_DESC_COUNT; idx++) {
+ sc->txdesc_ring[idx].addr = 0;
+ if (sc->mactype == DWC_GMAC_ALT_DESC) {
+ sc->txdesc_ring[idx].tdes0 = 0;
+ sc->txdesc_ring[idx].tdes1 = DDESC_CNTL_TXCHAIN;
+ } else {
+ sc->txdesc_ring[idx].tdes0 = DDESC_TDES0_TXCHAIN;
+ sc->txdesc_ring[idx].tdes1 = 0;
+ }
nidx = next_txidx(sc, idx);
sc->txdesc_ring[idx].addr_next = sc->txdesc_ring_paddr +
(nidx * sizeof(struct dwc_hwdesc));
@@ -910,7 +906,6 @@ setup_dma(struct dwc_softc *sc)
"could not create TX buffer DMA map.\n");
goto out;
}
- dwc_setup_txdesc(sc, idx, 0, 0);
}
/*
@@ -1147,7 +1142,7 @@ dwc_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
sc->rx_idx = 0;
- sc->txcount = TX_DESC_COUNT;
+ sc->txcount = 0;
sc->mii_clk = IF_DWC_MII_CLK(dev);
sc->mactype = IF_DWC_MAC_TYPE(dev);