diff options
-rw-r--r-- | sys/dev/ath/if_ath_tx_edma.c | 42 | ||||
-rw-r--r-- | sys/dev/ath/if_athvar.h | 9 |
2 files changed, 51 insertions, 0 deletions
diff --git a/sys/dev/ath/if_ath_tx_edma.c b/sys/dev/ath/if_ath_tx_edma.c index c4dc384..cd8df0d 100644 --- a/sys/dev/ath/if_ath_tx_edma.c +++ b/sys/dev/ath/if_ath_tx_edma.c @@ -131,9 +131,42 @@ __FBSDID("$FreeBSD$"); MALLOC_DECLARE(M_ATHDEV); static int +ath_edma_setup_txfifo(struct ath_softc *sc, int qnum) +{ + struct ath_tx_edma_fifo *te = &sc->sc_txedma[qnum]; + + te->m_fifo = malloc(sizeof(struct ath_buf *) * HAL_TXFIFO_DEPTH, + M_ATHDEV, + M_NOWAIT | M_ZERO); + if (te->m_fifo == NULL) { + device_printf(sc->sc_dev, "%s: malloc failed\n", + __func__); + return (-ENOMEM); + } + + /* + * Set initial "empty" state. + */ + te->m_fifo_head = te->m_fifo_tail = te->m_fifo_depth = 0; + + return (0); +} + +static int +ath_edma_free_txfifo(struct ath_softc *sc, int qnum) +{ + struct ath_tx_edma_fifo *te = &sc->sc_txedma[qnum]; + + /* XXX TODO: actually deref the ath_buf entries? */ + free(te->m_fifo, M_ATHDEV); + return (0); +} + +static int ath_edma_dma_txsetup(struct ath_softc *sc) { int error; + int i; error = ath_descdma_alloc_desc(sc, &sc->sc_txsdma, NULL, "txcomp", sc->sc_tx_statuslen, ATH_TXSTATUS_RING_SIZE); @@ -145,6 +178,10 @@ ath_edma_dma_txsetup(struct ath_softc *sc) sc->sc_txsdma.dd_desc_paddr, ATH_TXSTATUS_RING_SIZE); + for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { + ath_edma_setup_txfifo(sc, i); + } + return (0); } @@ -152,6 +189,11 @@ ath_edma_dma_txsetup(struct ath_softc *sc) static int ath_edma_dma_txteardown(struct ath_softc *sc) { + int i; + + for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { + ath_edma_free_txfifo(sc, i); + } ath_descdma_cleanup(sc, &sc->sc_txsdma, NULL); return (0); diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index e6edb6b..3c89e08 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -397,6 +397,14 @@ struct ath_rx_edma { struct mbuf *m_rxpending; }; +struct ath_tx_edma_fifo { + struct ath_buf **m_fifo; + int m_fifolen; + int m_fifo_head; + int m_fifo_tail; + int m_fifo_depth; +}; + struct ath_tx_methods { int (*xmit_setup)(struct ath_softc *sc); int (*xmit_teardown)(struct ath_softc *sc); @@ -418,6 +426,7 @@ struct ath_softc { struct ath_rx_methods sc_rx; struct ath_rx_edma sc_rxedma[HAL_NUM_RX_QUEUES]; /* HP/LP queues */ struct ath_tx_methods sc_tx; + struct ath_tx_edma_fifo sc_txedma[HAL_NUM_TX_QUEUES]; int sc_rx_statuslen; int sc_tx_desclen; |