From 1006fc0c3bc4da106121abe5ddc72c1b57c6360b Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Mon, 23 Jul 2012 23:40:13 +0000 Subject: [PATCH] Modify ath_descdma_setup() to take a descriptor size parameter. The AR9300 and later descriptors are 128 bytes, however I'd like to make sure that isn't used for earlier chips. * Populate the TX descriptor length field in the softc with sizeof(ath_desc) * Use this field when allocating the TX descriptors * Pre-AR93xx TX/RX descriptors will use the ath_desc size; newer ones will query the HAL for these sizes. --- sys/dev/ath/if_ath.c | 11 ++++++----- sys/dev/ath/if_ath_misc.h | 3 ++- sys/dev/ath/if_ath_rx.c | 5 ++++- sys/dev/ath/if_ath_tx.c | 7 +++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 4b0bae86540a..3f831d85a29d 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -2767,7 +2767,7 @@ ath_load_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error) int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, - const char *name, int nbuf, int ndesc) + const char *name, int ds_size, int nbuf, int ndesc) { #define DS2PHYS(_dd, _ds) \ ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) @@ -2778,7 +2778,7 @@ ath_descdma_setup(struct ath_softc *sc, struct ath_buf *bf; int i, bsize, error; - dd->dd_descsize = sizeof(struct ath_desc); + dd->dd_descsize = ds_size; DPRINTF(sc, ATH_DEBUG_RESET, "%s: %s DMA: %u buffers %u desc/buf, %d bytes per descriptor\n", @@ -3010,14 +3010,15 @@ ath_desc_alloc(struct ath_softc *sc) int error; error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf, - "tx", ath_txbuf, ATH_TXDESC); + "tx", sc->sc_tx_desclen, ath_txbuf, ATH_TXDESC); if (error != 0) { return error; } sc->sc_txbuf_cnt = ath_txbuf; error = ath_descdma_setup(sc, &sc->sc_txdma_mgmt, &sc->sc_txbuf_mgmt, - "tx_mgmt", ath_txbuf_mgmt, ATH_TXDESC); + "tx_mgmt", sc->sc_tx_desclen, ath_txbuf_mgmt, + ATH_TXDESC); if (error != 0) { ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); return error; @@ -3029,7 +3030,7 @@ ath_desc_alloc(struct ath_softc *sc) */ error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf, - "beacon", ATH_BCBUF, 1); + "beacon", sc->sc_tx_desclen, ATH_BCBUF, 1); if (error != 0) { ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, diff --git a/sys/dev/ath/if_ath_misc.h b/sys/dev/ath/if_ath_misc.h index 23c9f68fc640..a1d2e8334b18 100644 --- a/sys/dev/ath/if_ath_misc.h +++ b/sys/dev/ath/if_ath_misc.h @@ -85,7 +85,8 @@ extern void ath_setdefantenna(struct ath_softc *sc, u_int antenna); extern void ath_setslottime(struct ath_softc *sc); extern int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, - ath_bufhead *head, const char *name, int nbuf, int ndesc); + ath_bufhead *head, const char *name, int ds_size, int nbuf, + int ndesc); extern int ath_descdma_setup_rx_edma(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int nbuf, int desclen); diff --git a/sys/dev/ath/if_ath_rx.c b/sys/dev/ath/if_ath_rx.c index 9e90977b9057..4027bfeb74e2 100644 --- a/sys/dev/ath/if_ath_rx.c +++ b/sys/dev/ath/if_ath_rx.c @@ -1075,7 +1075,7 @@ ath_legacy_dma_rxsetup(struct ath_softc *sc) device_printf(sc->sc_dev, "%s: called\n", __func__); error = ath_descdma_setup(sc, &sc->sc_rxdma, &sc->sc_rxbuf, - "rx", ath_rxbuf, 1); + "rx", sizeof(struct ath_desc), ath_rxbuf, 1); if (error != 0) return (error); @@ -1099,6 +1099,9 @@ ath_recv_setup_legacy(struct ath_softc *sc) device_printf(sc->sc_dev, "DMA setup: legacy\n"); + /* Sensible legacy defaults */ + sc->sc_rx_statuslen = 0; + sc->sc_rx.recv_start = ath_legacy_startrecv; sc->sc_rx.recv_stop = ath_legacy_stoprecv; sc->sc_rx.recv_flush = ath_legacy_flushrecv; diff --git a/sys/dev/ath/if_ath_tx.c b/sys/dev/ath/if_ath_tx.c index 848ed14de210..c0dfa2b09c46 100644 --- a/sys/dev/ath/if_ath_tx.c +++ b/sys/dev/ath/if_ath_tx.c @@ -4483,6 +4483,13 @@ ath_legacy_dma_txteardown(struct ath_softc *sc) void ath_xmit_setup_legacy(struct ath_softc *sc) { + /* + * For now, just set the descriptor length to sizeof(ath_desc); + * worry about extracting the real length out of the HAL later. + */ + sc->sc_tx_desclen = sizeof(struct ath_desc); + sc->sc_tx_statuslen = 0; + sc->sc_tx_nmaps = 1; /* only one buffer per TX desc */ sc->sc_tx.xmit_setup = ath_legacy_dma_txsetup; sc->sc_tx.xmit_teardown = ath_legacy_dma_txteardown;