mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 16:01:05 +08:00
if_dwc: Simplify tx desc setup
This commit is contained in:
@@ -177,40 +177,28 @@ dwc_setup_txdesc(struct dwc_softc *sc, int idx, bus_addr_t paddr,
|
|||||||
uint32_t len)
|
uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t nidx;
|
|
||||||
|
|
||||||
nidx = next_txidx(sc, idx);
|
++sc->txcount;
|
||||||
|
|
||||||
/* 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->txdesc_ring[idx].addr = (uint32_t)(paddr);
|
sc->txdesc_ring[idx].addr = (uint32_t)(paddr);
|
||||||
if (sc->mactype == DWC_GMAC_ALT_DESC) {
|
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].tdes0 = 0;
|
||||||
sc->txdesc_ring[idx].tdes1 = flags | len;
|
sc->txdesc_ring[idx].tdes1 = flags | len;
|
||||||
} else {
|
} else {
|
||||||
|
flags = DDESC_TDES0_TXCHAIN | DDESC_TDES0_TXFIRST
|
||||||
|
| DDESC_TDES0_TXLAST | DDESC_TDES0_TXINT;
|
||||||
sc->txdesc_ring[idx].tdes0 = flags;
|
sc->txdesc_ring[idx].tdes0 = flags;
|
||||||
sc->txdesc_ring[idx].tdes1 = len;
|
sc->txdesc_ring[idx].tdes1 = len;
|
||||||
}
|
}
|
||||||
|
wmb();
|
||||||
|
|
||||||
if (paddr && len) {
|
sc->txdesc_ring[idx].tdes0 = DDESC_TDES0_TXCHAIN | DDESC_TDES0_TXFIRST
|
||||||
wmb();
|
| DDESC_TDES0_TXLAST | DDESC_TDES0_TXINT | DDESC_TDES0_OWN;
|
||||||
sc->txdesc_ring[idx].tdes0 |= DDESC_TDES0_OWN;
|
wmb();
|
||||||
wmb();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (nidx);
|
return (next_txidx(sc, idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -728,7 +716,7 @@ dwc_txfinish_locked(struct dwc_softc *sc)
|
|||||||
bus_dmamap_unload(sc->txbuf_tag, bmap->map);
|
bus_dmamap_unload(sc->txbuf_tag, bmap->map);
|
||||||
m_freem(bmap->mbuf);
|
m_freem(bmap->mbuf);
|
||||||
bmap->mbuf = NULL;
|
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);
|
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++) {
|
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);
|
nidx = next_txidx(sc, idx);
|
||||||
sc->txdesc_ring[idx].addr_next = sc->txdesc_ring_paddr +
|
sc->txdesc_ring[idx].addr_next = sc->txdesc_ring_paddr +
|
||||||
(nidx * sizeof(struct dwc_hwdesc));
|
(nidx * sizeof(struct dwc_hwdesc));
|
||||||
@@ -910,7 +906,6 @@ setup_dma(struct dwc_softc *sc)
|
|||||||
"could not create TX buffer DMA map.\n");
|
"could not create TX buffer DMA map.\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
dwc_setup_txdesc(sc, idx, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1147,7 +1142,7 @@ dwc_attach(device_t dev)
|
|||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
sc->dev = dev;
|
sc->dev = dev;
|
||||||
sc->rx_idx = 0;
|
sc->rx_idx = 0;
|
||||||
sc->txcount = TX_DESC_COUNT;
|
sc->txcount = 0;
|
||||||
sc->mii_clk = IF_DWC_MII_CLK(dev);
|
sc->mii_clk = IF_DWC_MII_CLK(dev);
|
||||||
sc->mactype = IF_DWC_MAC_TYPE(dev);
|
sc->mactype = IF_DWC_MAC_TYPE(dev);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user