13fdfc330SAdrian Chadd /*- 23fdfc330SAdrian Chadd * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> 33fdfc330SAdrian Chadd * All rights reserved. 43fdfc330SAdrian Chadd * 53fdfc330SAdrian Chadd * Redistribution and use in source and binary forms, with or without 63fdfc330SAdrian Chadd * modification, are permitted provided that the following conditions 73fdfc330SAdrian Chadd * are met: 83fdfc330SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 93fdfc330SAdrian Chadd * notice, this list of conditions and the following disclaimer, 103fdfc330SAdrian Chadd * without modification. 113fdfc330SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer 123fdfc330SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 133fdfc330SAdrian Chadd * redistribution must be conditioned upon including a substantially 143fdfc330SAdrian Chadd * similar Disclaimer requirement for further binary redistribution. 153fdfc330SAdrian Chadd * 163fdfc330SAdrian Chadd * NO WARRANTY 173fdfc330SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 183fdfc330SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 193fdfc330SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 203fdfc330SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 213fdfc330SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 223fdfc330SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 233fdfc330SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 243fdfc330SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 253fdfc330SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 263fdfc330SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 273fdfc330SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES. 283fdfc330SAdrian Chadd */ 293fdfc330SAdrian Chadd 303fdfc330SAdrian Chadd #include <sys/cdefs.h> 313fdfc330SAdrian Chadd __FBSDID("$FreeBSD$"); 323fdfc330SAdrian Chadd 333fdfc330SAdrian Chadd /* 343fdfc330SAdrian Chadd * Driver for the Atheros Wireless LAN controller. 353fdfc330SAdrian Chadd * 363fdfc330SAdrian Chadd * This software is derived from work of Atsushi Onoe; his contribution 373fdfc330SAdrian Chadd * is greatly appreciated. 383fdfc330SAdrian Chadd */ 393fdfc330SAdrian Chadd 403fdfc330SAdrian Chadd #include "opt_inet.h" 413fdfc330SAdrian Chadd #include "opt_ath.h" 423fdfc330SAdrian Chadd /* 433fdfc330SAdrian Chadd * This is needed for register operations which are performed 443fdfc330SAdrian Chadd * by the driver - eg, calls to ath_hal_gettsf32(). 453fdfc330SAdrian Chadd * 463fdfc330SAdrian Chadd * It's also required for any AH_DEBUG checks in here, eg the 473fdfc330SAdrian Chadd * module dependencies. 483fdfc330SAdrian Chadd */ 493fdfc330SAdrian Chadd #include "opt_ah.h" 503fdfc330SAdrian Chadd #include "opt_wlan.h" 513fdfc330SAdrian Chadd 523fdfc330SAdrian Chadd #include <sys/param.h> 533fdfc330SAdrian Chadd #include <sys/systm.h> 543fdfc330SAdrian Chadd #include <sys/sysctl.h> 553fdfc330SAdrian Chadd #include <sys/mbuf.h> 563fdfc330SAdrian Chadd #include <sys/malloc.h> 573fdfc330SAdrian Chadd #include <sys/lock.h> 583fdfc330SAdrian Chadd #include <sys/mutex.h> 593fdfc330SAdrian Chadd #include <sys/kernel.h> 603fdfc330SAdrian Chadd #include <sys/socket.h> 613fdfc330SAdrian Chadd #include <sys/sockio.h> 623fdfc330SAdrian Chadd #include <sys/errno.h> 633fdfc330SAdrian Chadd #include <sys/callout.h> 643fdfc330SAdrian Chadd #include <sys/bus.h> 653fdfc330SAdrian Chadd #include <sys/endian.h> 663fdfc330SAdrian Chadd #include <sys/kthread.h> 673fdfc330SAdrian Chadd #include <sys/taskqueue.h> 683fdfc330SAdrian Chadd #include <sys/priv.h> 693fdfc330SAdrian Chadd #include <sys/module.h> 703fdfc330SAdrian Chadd #include <sys/ktr.h> 713fdfc330SAdrian Chadd #include <sys/smp.h> /* for mp_ncpus */ 723fdfc330SAdrian Chadd 733fdfc330SAdrian Chadd #include <machine/bus.h> 743fdfc330SAdrian Chadd 753fdfc330SAdrian Chadd #include <net/if.h> 7676039bc8SGleb Smirnoff #include <net/if_var.h> 773fdfc330SAdrian Chadd #include <net/if_dl.h> 783fdfc330SAdrian Chadd #include <net/if_media.h> 793fdfc330SAdrian Chadd #include <net/if_types.h> 803fdfc330SAdrian Chadd #include <net/if_arp.h> 813fdfc330SAdrian Chadd #include <net/ethernet.h> 823fdfc330SAdrian Chadd #include <net/if_llc.h> 833fdfc330SAdrian Chadd 843fdfc330SAdrian Chadd #include <net80211/ieee80211_var.h> 853fdfc330SAdrian Chadd #include <net80211/ieee80211_regdomain.h> 863fdfc330SAdrian Chadd #ifdef IEEE80211_SUPPORT_SUPERG 873fdfc330SAdrian Chadd #include <net80211/ieee80211_superg.h> 883fdfc330SAdrian Chadd #endif 893fdfc330SAdrian Chadd #ifdef IEEE80211_SUPPORT_TDMA 903fdfc330SAdrian Chadd #include <net80211/ieee80211_tdma.h> 913fdfc330SAdrian Chadd #endif 923fdfc330SAdrian Chadd 933fdfc330SAdrian Chadd #include <net/bpf.h> 943fdfc330SAdrian Chadd 953fdfc330SAdrian Chadd #ifdef INET 963fdfc330SAdrian Chadd #include <netinet/in.h> 973fdfc330SAdrian Chadd #include <netinet/if_ether.h> 983fdfc330SAdrian Chadd #endif 993fdfc330SAdrian Chadd 1003fdfc330SAdrian Chadd #include <dev/ath/if_athvar.h> 1013fdfc330SAdrian Chadd #include <dev/ath/ath_hal/ah_devid.h> /* XXX for softled */ 1023fdfc330SAdrian Chadd #include <dev/ath/ath_hal/ah_diagcodes.h> 1033fdfc330SAdrian Chadd 1043fdfc330SAdrian Chadd #include <dev/ath/if_ath_debug.h> 1053fdfc330SAdrian Chadd #include <dev/ath/if_ath_misc.h> 1063fdfc330SAdrian Chadd #include <dev/ath/if_ath_tsf.h> 1073fdfc330SAdrian Chadd #include <dev/ath/if_ath_tx.h> 1083fdfc330SAdrian Chadd #include <dev/ath/if_ath_sysctl.h> 1093fdfc330SAdrian Chadd #include <dev/ath/if_ath_led.h> 1103fdfc330SAdrian Chadd #include <dev/ath/if_ath_keycache.h> 1113fdfc330SAdrian Chadd #include <dev/ath/if_ath_rx.h> 1123fdfc330SAdrian Chadd #include <dev/ath/if_ath_beacon.h> 1133fdfc330SAdrian Chadd #include <dev/ath/if_athdfs.h> 114b45de1ebSAdrian Chadd #include <dev/ath/if_ath_descdma.h> 1153fdfc330SAdrian Chadd 1163fdfc330SAdrian Chadd #ifdef ATH_TX99_DIAG 1173fdfc330SAdrian Chadd #include <dev/ath/ath_tx99/ath_tx99.h> 1183fdfc330SAdrian Chadd #endif 1193fdfc330SAdrian Chadd 1203fdfc330SAdrian Chadd #include <dev/ath/if_ath_tx_edma.h> 1213fdfc330SAdrian Chadd 122b69b0dccSAdrian Chadd #ifdef ATH_DEBUG_ALQ 123b69b0dccSAdrian Chadd #include <dev/ath/if_ath_alq.h> 124b69b0dccSAdrian Chadd #endif 125b69b0dccSAdrian Chadd 1263fdfc330SAdrian Chadd /* 1273fdfc330SAdrian Chadd * some general macros 1283fdfc330SAdrian Chadd */ 1293fdfc330SAdrian Chadd #define INCR(_l, _sz) (_l) ++; (_l) &= ((_sz) - 1) 1303fdfc330SAdrian Chadd #define DECR(_l, _sz) (_l) --; (_l) &= ((_sz) - 1) 1313fdfc330SAdrian Chadd 132ba3fd9d8SAdrian Chadd /* 133ba3fd9d8SAdrian Chadd * XXX doesn't belong here, and should be tunable 134ba3fd9d8SAdrian Chadd */ 135ba3fd9d8SAdrian Chadd #define ATH_TXSTATUS_RING_SIZE 512 136ba3fd9d8SAdrian Chadd 1373fdfc330SAdrian Chadd MALLOC_DECLARE(M_ATHDEV); 1383fdfc330SAdrian Chadd 139ae3815fdSAdrian Chadd static void ath_edma_tx_processq(struct ath_softc *sc, int dosched); 140ae3815fdSAdrian Chadd 14149236b4eSAdrian Chadd #ifdef ATH_DEBUG_ALQ 14249236b4eSAdrian Chadd static void 14349236b4eSAdrian Chadd ath_tx_alq_edma_push(struct ath_softc *sc, int txq, int nframes, 14449236b4eSAdrian Chadd int fifo_depth, int frame_cnt) 14549236b4eSAdrian Chadd { 14649236b4eSAdrian Chadd struct if_ath_alq_tx_fifo_push aq; 14749236b4eSAdrian Chadd 14849236b4eSAdrian Chadd aq.txq = htobe32(txq); 14949236b4eSAdrian Chadd aq.nframes = htobe32(nframes); 15049236b4eSAdrian Chadd aq.fifo_depth = htobe32(fifo_depth); 15149236b4eSAdrian Chadd aq.frame_cnt = htobe32(frame_cnt); 15249236b4eSAdrian Chadd 15349236b4eSAdrian Chadd if_ath_alq_post(&sc->sc_alq, ATH_ALQ_TX_FIFO_PUSH, 15449236b4eSAdrian Chadd sizeof(aq), 15549236b4eSAdrian Chadd (const char *) &aq); 15649236b4eSAdrian Chadd } 15749236b4eSAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 15849236b4eSAdrian Chadd 1594f5ec72aSAdrian Chadd /* 1604f5ec72aSAdrian Chadd * XXX TODO: push an aggregate as a single FIFO slot, even though 1614f5ec72aSAdrian Chadd * it may not meet the TXOP for say, DBA-gated traffic in TDMA mode. 1624f5ec72aSAdrian Chadd * 1634f5ec72aSAdrian Chadd * The TX completion code handles a TX FIFO slot having multiple frames, 1644f5ec72aSAdrian Chadd * aggregate or otherwise, but it may just make things easier to deal 1654f5ec72aSAdrian Chadd * with. 1664f5ec72aSAdrian Chadd * 1674f5ec72aSAdrian Chadd * XXX TODO: track the number of aggregate subframes and put that in the 1684f5ec72aSAdrian Chadd * push alq message. 1694f5ec72aSAdrian Chadd */ 17049236b4eSAdrian Chadd static void 17149236b4eSAdrian Chadd ath_tx_edma_push_staging_list(struct ath_softc *sc, struct ath_txq *txq, 17249236b4eSAdrian Chadd int limit) 17349236b4eSAdrian Chadd { 17449236b4eSAdrian Chadd struct ath_buf *bf, *bf_last; 17549236b4eSAdrian Chadd struct ath_buf *bfi, *bfp; 17649236b4eSAdrian Chadd int i, sqdepth; 17749236b4eSAdrian Chadd TAILQ_HEAD(axq_q_f_s, ath_buf) sq; 17849236b4eSAdrian Chadd 17949236b4eSAdrian Chadd ATH_TXQ_LOCK_ASSERT(txq); 18049236b4eSAdrian Chadd 181*6eb9f206SAdrian Chadd DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_TX_PROC, 182*6eb9f206SAdrian Chadd "%s: called; TXQ=%d, fifo.depth=%d, axq_q empty=%d\n", 183*6eb9f206SAdrian Chadd __func__, 184*6eb9f206SAdrian Chadd txq->axq_qnum, 185*6eb9f206SAdrian Chadd txq->axq_fifo_depth, 186*6eb9f206SAdrian Chadd !! (TAILQ_EMPTY(&txq->axq_q))); 187*6eb9f206SAdrian Chadd 18849236b4eSAdrian Chadd /* 18949236b4eSAdrian Chadd * Don't bother doing any work if it's full. 19049236b4eSAdrian Chadd */ 19149236b4eSAdrian Chadd if (txq->axq_fifo_depth >= HAL_TXFIFO_DEPTH) 19249236b4eSAdrian Chadd return; 19349236b4eSAdrian Chadd 19449236b4eSAdrian Chadd if (TAILQ_EMPTY(&txq->axq_q)) 19549236b4eSAdrian Chadd return; 19649236b4eSAdrian Chadd 19749236b4eSAdrian Chadd TAILQ_INIT(&sq); 19849236b4eSAdrian Chadd 19949236b4eSAdrian Chadd /* 20049236b4eSAdrian Chadd * First pass - walk sq, queue up to 'limit' entries, 20149236b4eSAdrian Chadd * subtract them from the staging queue. 20249236b4eSAdrian Chadd */ 20349236b4eSAdrian Chadd sqdepth = 0; 20449236b4eSAdrian Chadd for (i = 0; i < limit; i++) { 20549236b4eSAdrian Chadd /* Grab the head entry */ 20649236b4eSAdrian Chadd bf = ATH_TXQ_FIRST(txq); 20749236b4eSAdrian Chadd if (bf == NULL) 20849236b4eSAdrian Chadd break; 20949236b4eSAdrian Chadd ATH_TXQ_REMOVE(txq, bf, bf_list); 21049236b4eSAdrian Chadd 21149236b4eSAdrian Chadd /* Queue it into our staging list */ 21249236b4eSAdrian Chadd TAILQ_INSERT_TAIL(&sq, bf, bf_list); 2131a9bf047SAdrian Chadd 2141a9bf047SAdrian Chadd /* Ensure the flags are cleared */ 2151a9bf047SAdrian Chadd bf->bf_flags &= ~(ATH_BUF_FIFOPTR | ATH_BUF_FIFOEND); 21649236b4eSAdrian Chadd sqdepth++; 21749236b4eSAdrian Chadd } 21849236b4eSAdrian Chadd 21949236b4eSAdrian Chadd /* 22049236b4eSAdrian Chadd * Ok, so now we have a staging list of up to 'limit' 22149236b4eSAdrian Chadd * frames from the txq. Now let's wrap that up 22249236b4eSAdrian Chadd * into its own list and pass that to the hardware 22349236b4eSAdrian Chadd * as one FIFO entry. 22449236b4eSAdrian Chadd */ 22549236b4eSAdrian Chadd 22649236b4eSAdrian Chadd bf = TAILQ_FIRST(&sq); 22749236b4eSAdrian Chadd bf_last = TAILQ_LAST(&sq, axq_q_s); 22849236b4eSAdrian Chadd 22949236b4eSAdrian Chadd /* 23049236b4eSAdrian Chadd * Ok, so here's the gymnastics reqiured to make this 23149236b4eSAdrian Chadd * all sensible. 23249236b4eSAdrian Chadd */ 23349236b4eSAdrian Chadd 23449236b4eSAdrian Chadd /* 23549236b4eSAdrian Chadd * Tag the first/last buffer appropriately. 23649236b4eSAdrian Chadd */ 23749236b4eSAdrian Chadd bf->bf_flags |= ATH_BUF_FIFOPTR; 23849236b4eSAdrian Chadd bf_last->bf_flags |= ATH_BUF_FIFOEND; 23949236b4eSAdrian Chadd 24049236b4eSAdrian Chadd /* 24149236b4eSAdrian Chadd * Walk the descriptor list and link them appropriately. 24249236b4eSAdrian Chadd */ 24349236b4eSAdrian Chadd bfp = NULL; 24449236b4eSAdrian Chadd TAILQ_FOREACH(bfi, &sq, bf_list) { 24549236b4eSAdrian Chadd if (bfp != NULL) { 24649236b4eSAdrian Chadd ath_hal_settxdesclink(sc->sc_ah, bfp->bf_lastds, 24749236b4eSAdrian Chadd bfi->bf_daddr); 24849236b4eSAdrian Chadd } 24949236b4eSAdrian Chadd bfp = bfi; 25049236b4eSAdrian Chadd } 25149236b4eSAdrian Chadd 25249236b4eSAdrian Chadd i = 0; 25349236b4eSAdrian Chadd TAILQ_FOREACH(bfi, &sq, bf_list) { 25449236b4eSAdrian Chadd #ifdef ATH_DEBUG 25549236b4eSAdrian Chadd if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) 25649236b4eSAdrian Chadd ath_printtxbuf(sc, bfi, txq->axq_qnum, i, 0); 25749236b4eSAdrian Chadd #endif/* ATH_DEBUG */ 25849236b4eSAdrian Chadd #ifdef ATH_DEBUG_ALQ 25949236b4eSAdrian Chadd if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) 26049236b4eSAdrian Chadd ath_tx_alq_post(sc, bfi); 26149236b4eSAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 26249236b4eSAdrian Chadd i++; 26349236b4eSAdrian Chadd } 26449236b4eSAdrian Chadd 26549236b4eSAdrian Chadd /* 26649236b4eSAdrian Chadd * We now need to push this set of frames onto the tail 26749236b4eSAdrian Chadd * of the FIFO queue. We don't adjust the aggregate 26849236b4eSAdrian Chadd * count, only the queue depth counter(s). 26949236b4eSAdrian Chadd * We also need to blank the link pointer now. 27049236b4eSAdrian Chadd */ 27149236b4eSAdrian Chadd 27249236b4eSAdrian Chadd TAILQ_CONCAT(&txq->fifo.axq_q, &sq, bf_list); 27349236b4eSAdrian Chadd /* Bump total queue tracking in FIFO queue */ 27449236b4eSAdrian Chadd txq->fifo.axq_depth += sqdepth; 27549236b4eSAdrian Chadd 27649236b4eSAdrian Chadd /* Bump FIFO queue */ 27749236b4eSAdrian Chadd txq->axq_fifo_depth++; 278bd3b3362SAdrian Chadd DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_TX_PROC, 27949236b4eSAdrian Chadd "%s: queued %d packets; depth=%d, fifo depth=%d\n", 28049236b4eSAdrian Chadd __func__, sqdepth, txq->fifo.axq_depth, txq->axq_fifo_depth); 28149236b4eSAdrian Chadd 28249236b4eSAdrian Chadd /* Push the first entry into the hardware */ 28349236b4eSAdrian Chadd ath_hal_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr); 28449236b4eSAdrian Chadd 28549236b4eSAdrian Chadd /* Push start on the DMA if it's not already started */ 28649236b4eSAdrian Chadd ath_hal_txstart(sc->sc_ah, txq->axq_qnum); 28749236b4eSAdrian Chadd 28849236b4eSAdrian Chadd #ifdef ATH_DEBUG_ALQ 28949236b4eSAdrian Chadd ath_tx_alq_edma_push(sc, txq->axq_qnum, sqdepth, 29049236b4eSAdrian Chadd txq->axq_fifo_depth, 29149236b4eSAdrian Chadd txq->fifo.axq_depth); 29249236b4eSAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 29349236b4eSAdrian Chadd } 29449236b4eSAdrian Chadd 2954f5ec72aSAdrian Chadd #define TX_BATCH_SIZE 32 2964f5ec72aSAdrian Chadd 29792e84e43SAdrian Chadd /* 29892e84e43SAdrian Chadd * Push some frames into the TX FIFO if we have space. 29992e84e43SAdrian Chadd */ 3004aa8818bSAdrian Chadd static void 3014aa8818bSAdrian Chadd ath_edma_tx_fifo_fill(struct ath_softc *sc, struct ath_txq *txq) 3024aa8818bSAdrian Chadd { 3034aa8818bSAdrian Chadd 304b837332dSAdrian Chadd ATH_TXQ_LOCK_ASSERT(txq); 3054aa8818bSAdrian Chadd 306bd3b3362SAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, 307bd3b3362SAdrian Chadd "%s: Q%d: called; fifo.depth=%d, fifo depth=%d, depth=%d, aggr_depth=%d\n", 30892e84e43SAdrian Chadd __func__, 309bd3b3362SAdrian Chadd txq->axq_qnum, 310bd3b3362SAdrian Chadd txq->fifo.axq_depth, 311bd3b3362SAdrian Chadd txq->axq_fifo_depth, 312bd3b3362SAdrian Chadd txq->axq_depth, 313bd3b3362SAdrian Chadd txq->axq_aggr_depth); 3144aa8818bSAdrian Chadd 31592e84e43SAdrian Chadd /* 316bd3b3362SAdrian Chadd * For now, push up to 32 frames per TX FIFO slot. 31749236b4eSAdrian Chadd * If more are in the hardware queue then they'll 31849236b4eSAdrian Chadd * get populated when we try to send another frame 31949236b4eSAdrian Chadd * or complete a frame - so at most there'll be 320bd3b3362SAdrian Chadd * 32 non-AMPDU frames per node/TID anyway. 32192e84e43SAdrian Chadd * 32249236b4eSAdrian Chadd * Note that the hardware staging queue will limit 32349236b4eSAdrian Chadd * how many frames in total we will have pushed into 32449236b4eSAdrian Chadd * here. 32549236b4eSAdrian Chadd * 32649236b4eSAdrian Chadd * Later on, we'll want to push less frames into 32749236b4eSAdrian Chadd * the TX FIFO since we don't want to necessarily 32849236b4eSAdrian Chadd * fill tens or hundreds of milliseconds of potential 32949236b4eSAdrian Chadd * frames. 33049236b4eSAdrian Chadd * 33149236b4eSAdrian Chadd * However, we need more frames right now because of 33249236b4eSAdrian Chadd * how the MAC implements the frame scheduling policy. 33349236b4eSAdrian Chadd * It only ungates a single FIFO entry at a time, 33449236b4eSAdrian Chadd * and will run that until CHNTIME expires or the 33549236b4eSAdrian Chadd * end of that FIFO entry descriptor list is reached. 33649236b4eSAdrian Chadd * So for TDMA we suffer a big performance penalty - 33749236b4eSAdrian Chadd * single TX FIFO entries mean the MAC only sends out 33849236b4eSAdrian Chadd * one frame per DBA event, which turned out on average 33949236b4eSAdrian Chadd * 6ms per TX frame. 34049236b4eSAdrian Chadd * 34149236b4eSAdrian Chadd * So, for aggregates it's okay - it'll push two at a 34249236b4eSAdrian Chadd * time and this will just do them more efficiently. 34349236b4eSAdrian Chadd * For non-aggregates it'll do 4 at a time, up to the 34449236b4eSAdrian Chadd * non-aggr limit (non_aggr, which is 32.) They should 34549236b4eSAdrian Chadd * be time based rather than a hard count, but I also 34649236b4eSAdrian Chadd * do need sleep. 34792e84e43SAdrian Chadd */ 3484f5ec72aSAdrian Chadd 3494f5ec72aSAdrian Chadd /* 3504f5ec72aSAdrian Chadd * Do some basic, basic batching to the hardware 3514f5ec72aSAdrian Chadd * queue. 3524f5ec72aSAdrian Chadd * 3534f5ec72aSAdrian Chadd * If we have TX_BATCH_SIZE entries in the staging 3544f5ec72aSAdrian Chadd * queue, then let's try to send them all in one hit. 3554f5ec72aSAdrian Chadd * 3564f5ec72aSAdrian Chadd * Ensure we don't push more than TX_BATCH_SIZE worth 3574f5ec72aSAdrian Chadd * in, otherwise we end up draining 8 slots worth of 3584f5ec72aSAdrian Chadd * 32 frames into the hardware queue and then we don't 3594f5ec72aSAdrian Chadd * attempt to push more frames in until we empty the 3604f5ec72aSAdrian Chadd * FIFO. 3614f5ec72aSAdrian Chadd */ 3624f5ec72aSAdrian Chadd if (txq->axq_depth >= TX_BATCH_SIZE / 2 && 3634f5ec72aSAdrian Chadd txq->fifo.axq_depth <= TX_BATCH_SIZE) { 3644f5ec72aSAdrian Chadd ath_tx_edma_push_staging_list(sc, txq, TX_BATCH_SIZE); 3654f5ec72aSAdrian Chadd } 3664f5ec72aSAdrian Chadd 3674f5ec72aSAdrian Chadd /* 3684f5ec72aSAdrian Chadd * Aggregate check: if we have less than two FIFO slots 3694f5ec72aSAdrian Chadd * busy and we have some aggregate frames, queue it. 3704f5ec72aSAdrian Chadd * 3714f5ec72aSAdrian Chadd * Now, ideally we'd just check to see if the scheduler 3724f5ec72aSAdrian Chadd * has given us aggregate frames and push them into the FIFO 3734f5ec72aSAdrian Chadd * as individual slots, as honestly we should just be pushing 3744f5ec72aSAdrian Chadd * a single aggregate in as one FIFO slot. 3754f5ec72aSAdrian Chadd * 3764f5ec72aSAdrian Chadd * Let's do that next once I know this works. 3774f5ec72aSAdrian Chadd */ 3784f5ec72aSAdrian Chadd else if (txq->axq_aggr_depth > 0 && txq->axq_fifo_depth < 2) 3794f5ec72aSAdrian Chadd ath_tx_edma_push_staging_list(sc, txq, TX_BATCH_SIZE); 3804f5ec72aSAdrian Chadd 3814f5ec72aSAdrian Chadd /* 3824f5ec72aSAdrian Chadd * 3834f5ec72aSAdrian Chadd * If we have less, and the TXFIFO isn't empty, let's 3844f5ec72aSAdrian Chadd * wait until we've finished sending the FIFO. 3854f5ec72aSAdrian Chadd * 3864f5ec72aSAdrian Chadd * If we have less, and the TXFIFO is empty, then 3874f5ec72aSAdrian Chadd * send them. 3884f5ec72aSAdrian Chadd */ 3894f5ec72aSAdrian Chadd else if (txq->axq_fifo_depth == 0) { 3904f5ec72aSAdrian Chadd ath_tx_edma_push_staging_list(sc, txq, TX_BATCH_SIZE); 3914f5ec72aSAdrian Chadd } 3924aa8818bSAdrian Chadd } 3934aa8818bSAdrian Chadd 394746bab5bSAdrian Chadd /* 395746bab5bSAdrian Chadd * Re-initialise the DMA FIFO with the current contents of 3963ae723d4SAdrian Chadd * said TXQ. 397746bab5bSAdrian Chadd * 398746bab5bSAdrian Chadd * This should only be called as part of the chip reset path, as it 399746bab5bSAdrian Chadd * assumes the FIFO is currently empty. 400746bab5bSAdrian Chadd */ 401746bab5bSAdrian Chadd static void 402746bab5bSAdrian Chadd ath_edma_dma_restart(struct ath_softc *sc, struct ath_txq *txq) 403746bab5bSAdrian Chadd { 40492e84e43SAdrian Chadd struct ath_buf *bf; 40592e84e43SAdrian Chadd int i = 0; 40692e84e43SAdrian Chadd int fifostart = 1; 40792e84e43SAdrian Chadd int old_fifo_depth; 408746bab5bSAdrian Chadd 40992e84e43SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RESET, "%s: Q%d: called\n", 410746bab5bSAdrian Chadd __func__, 411746bab5bSAdrian Chadd txq->axq_qnum); 4124aa8818bSAdrian Chadd 413b837332dSAdrian Chadd ATH_TXQ_LOCK_ASSERT(txq); 41492e84e43SAdrian Chadd 41592e84e43SAdrian Chadd /* 41692e84e43SAdrian Chadd * Let's log if the tracked FIFO depth doesn't match 41792e84e43SAdrian Chadd * what we actually push in. 41892e84e43SAdrian Chadd */ 41992e84e43SAdrian Chadd old_fifo_depth = txq->axq_fifo_depth; 42092e84e43SAdrian Chadd txq->axq_fifo_depth = 0; 42192e84e43SAdrian Chadd 42292e84e43SAdrian Chadd /* 42392e84e43SAdrian Chadd * Walk the FIFO staging list, looking for "head" entries. 42492e84e43SAdrian Chadd * Since we may have a partially completed list of frames, 42592e84e43SAdrian Chadd * we push the first frame we see into the FIFO and re-mark 42692e84e43SAdrian Chadd * it as the head entry. We then skip entries until we see 42792e84e43SAdrian Chadd * FIFO end, at which point we get ready to push another 42892e84e43SAdrian Chadd * entry into the FIFO. 42992e84e43SAdrian Chadd */ 43092e84e43SAdrian Chadd TAILQ_FOREACH(bf, &txq->fifo.axq_q, bf_list) { 43192e84e43SAdrian Chadd /* 43292e84e43SAdrian Chadd * If we're looking for FIFOEND and we haven't found 43392e84e43SAdrian Chadd * it, skip. 43492e84e43SAdrian Chadd * 43592e84e43SAdrian Chadd * If we're looking for FIFOEND and we've found it, 43692e84e43SAdrian Chadd * reset for another descriptor. 43792e84e43SAdrian Chadd */ 43892e84e43SAdrian Chadd #ifdef ATH_DEBUG 43992e84e43SAdrian Chadd if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) 44092e84e43SAdrian Chadd ath_printtxbuf(sc, bf, txq->axq_qnum, i, 0); 44192e84e43SAdrian Chadd #endif/* ATH_DEBUG */ 44292e84e43SAdrian Chadd #ifdef ATH_DEBUG_ALQ 44392e84e43SAdrian Chadd if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) 44492e84e43SAdrian Chadd ath_tx_alq_post(sc, bf); 44592e84e43SAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 44692e84e43SAdrian Chadd 44792e84e43SAdrian Chadd if (fifostart == 0) { 44892e84e43SAdrian Chadd if (bf->bf_flags & ATH_BUF_FIFOEND) 44992e84e43SAdrian Chadd fifostart = 1; 45092e84e43SAdrian Chadd continue; 45192e84e43SAdrian Chadd } 45292e84e43SAdrian Chadd 45392e84e43SAdrian Chadd /* Make sure we're not overflowing the FIFO! */ 45492e84e43SAdrian Chadd if (txq->axq_fifo_depth >= HAL_TXFIFO_DEPTH) { 45592e84e43SAdrian Chadd device_printf(sc->sc_dev, 45692e84e43SAdrian Chadd "%s: Q%d: more frames in the queue; FIFO depth=%d?!\n", 45792e84e43SAdrian Chadd __func__, 45892e84e43SAdrian Chadd txq->axq_qnum, 45992e84e43SAdrian Chadd txq->axq_fifo_depth); 46092e84e43SAdrian Chadd } 46192e84e43SAdrian Chadd 46292e84e43SAdrian Chadd #if 0 46392e84e43SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RESET, 46492e84e43SAdrian Chadd "%s: Q%d: depth=%d: pushing bf=%p; start=%d, end=%d\n", 46592e84e43SAdrian Chadd __func__, 46692e84e43SAdrian Chadd txq->axq_qnum, 46792e84e43SAdrian Chadd txq->axq_fifo_depth, 46892e84e43SAdrian Chadd bf, 46992e84e43SAdrian Chadd !! (bf->bf_flags & ATH_BUF_FIFOPTR), 47092e84e43SAdrian Chadd !! (bf->bf_flags & ATH_BUF_FIFOEND)); 47192e84e43SAdrian Chadd #endif 47292e84e43SAdrian Chadd 47392e84e43SAdrian Chadd /* 47492e84e43SAdrian Chadd * Set this to be the first buffer in the FIFO 47592e84e43SAdrian Chadd * list - even if it's also the last buffer in 47692e84e43SAdrian Chadd * a FIFO list! 47792e84e43SAdrian Chadd */ 47892e84e43SAdrian Chadd bf->bf_flags |= ATH_BUF_FIFOPTR; 47992e84e43SAdrian Chadd 48092e84e43SAdrian Chadd /* Push it into the FIFO and bump the FIFO count */ 48192e84e43SAdrian Chadd ath_hal_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr); 48292e84e43SAdrian Chadd txq->axq_fifo_depth++; 48392e84e43SAdrian Chadd 48492e84e43SAdrian Chadd /* 48592e84e43SAdrian Chadd * If this isn't the last entry either, let's 48692e84e43SAdrian Chadd * clear fifostart so we continue looking for 48792e84e43SAdrian Chadd * said last entry. 48892e84e43SAdrian Chadd */ 48992e84e43SAdrian Chadd if (! (bf->bf_flags & ATH_BUF_FIFOEND)) 49092e84e43SAdrian Chadd fifostart = 0; 49192e84e43SAdrian Chadd i++; 49292e84e43SAdrian Chadd } 49392e84e43SAdrian Chadd 49492e84e43SAdrian Chadd /* Only bother starting the queue if there's something in it */ 49592e84e43SAdrian Chadd if (i > 0) 49692e84e43SAdrian Chadd ath_hal_txstart(sc->sc_ah, txq->axq_qnum); 49792e84e43SAdrian Chadd 49892e84e43SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RESET, "%s: Q%d: FIFO depth was %d, is %d\n", 49992e84e43SAdrian Chadd __func__, 50092e84e43SAdrian Chadd txq->axq_qnum, 50192e84e43SAdrian Chadd old_fifo_depth, 50292e84e43SAdrian Chadd txq->axq_fifo_depth); 50392e84e43SAdrian Chadd 50492e84e43SAdrian Chadd /* And now, let's check! */ 50592e84e43SAdrian Chadd if (txq->axq_fifo_depth != old_fifo_depth) { 50692e84e43SAdrian Chadd device_printf(sc->sc_dev, 50792e84e43SAdrian Chadd "%s: Q%d: FIFO depth should be %d, is %d\n", 50892e84e43SAdrian Chadd __func__, 50992e84e43SAdrian Chadd txq->axq_qnum, 51092e84e43SAdrian Chadd old_fifo_depth, 51192e84e43SAdrian Chadd txq->axq_fifo_depth); 51292e84e43SAdrian Chadd } 513746bab5bSAdrian Chadd } 514746bab5bSAdrian Chadd 515746bab5bSAdrian Chadd /* 5163ae723d4SAdrian Chadd * Hand off this frame to a hardware queue. 5173ae723d4SAdrian Chadd * 5183ae723d4SAdrian Chadd * Things are a bit hairy in the EDMA world. The TX FIFO is only 5193ae723d4SAdrian Chadd * 8 entries deep, so we need to keep track of exactly what we've 5203ae723d4SAdrian Chadd * pushed into the FIFO and what's just sitting in the TX queue, 5213ae723d4SAdrian Chadd * waiting to go out. 5223ae723d4SAdrian Chadd * 5233ae723d4SAdrian Chadd * So this is split into two halves - frames get appended to the 5243ae723d4SAdrian Chadd * TXQ; then a scheduler is called to push some frames into the 5253ae723d4SAdrian Chadd * actual TX FIFO. 5263ae723d4SAdrian Chadd */ 5273ae723d4SAdrian Chadd static void 5283ae723d4SAdrian Chadd ath_edma_xmit_handoff_hw(struct ath_softc *sc, struct ath_txq *txq, 5293ae723d4SAdrian Chadd struct ath_buf *bf) 5303ae723d4SAdrian Chadd { 5313ae723d4SAdrian Chadd 5320acf45edSAdrian Chadd ATH_TXQ_LOCK(txq); 5333ae723d4SAdrian Chadd 5343ae723d4SAdrian Chadd KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, 5353ae723d4SAdrian Chadd ("%s: busy status 0x%x", __func__, bf->bf_flags)); 5363ae723d4SAdrian Chadd 5373ae723d4SAdrian Chadd /* 5383ae723d4SAdrian Chadd * XXX TODO: write a hard-coded check to ensure that 5393ae723d4SAdrian Chadd * the queue id in the TX descriptor matches txq->axq_qnum. 5403ae723d4SAdrian Chadd */ 5413ae723d4SAdrian Chadd 5423ae723d4SAdrian Chadd /* Update aggr stats */ 5433ae723d4SAdrian Chadd if (bf->bf_state.bfs_aggr) 5443ae723d4SAdrian Chadd txq->axq_aggr_depth++; 5453ae723d4SAdrian Chadd 5463ae723d4SAdrian Chadd /* Push and update frame stats */ 5473ae723d4SAdrian Chadd ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); 5483ae723d4SAdrian Chadd 54992e84e43SAdrian Chadd /* 55092e84e43SAdrian Chadd * Finally, call the FIFO schedule routine to schedule some 55192e84e43SAdrian Chadd * frames to the FIFO. 55292e84e43SAdrian Chadd */ 55392e84e43SAdrian Chadd ath_edma_tx_fifo_fill(sc, txq); 5540acf45edSAdrian Chadd ATH_TXQ_UNLOCK(txq); 5553ae723d4SAdrian Chadd } 5563ae723d4SAdrian Chadd 5573ae723d4SAdrian Chadd /* 5583ae723d4SAdrian Chadd * Hand off this frame to a multicast software queue. 5593ae723d4SAdrian Chadd * 560e3f06688SAdrian Chadd * The EDMA TX CABQ will get a list of chained frames, chained 561e3f06688SAdrian Chadd * together using the next pointer. The single head of that 562e3f06688SAdrian Chadd * particular queue is pushed to the hardware CABQ. 5633ae723d4SAdrian Chadd */ 5643ae723d4SAdrian Chadd static void 5653ae723d4SAdrian Chadd ath_edma_xmit_handoff_mcast(struct ath_softc *sc, struct ath_txq *txq, 5663ae723d4SAdrian Chadd struct ath_buf *bf) 5673ae723d4SAdrian Chadd { 5683ae723d4SAdrian Chadd 5699e7259a2SAdrian Chadd ATH_TX_LOCK_ASSERT(sc); 5703ae723d4SAdrian Chadd KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0, 5713ae723d4SAdrian Chadd ("%s: busy status 0x%x", __func__, bf->bf_flags)); 5723ae723d4SAdrian Chadd 5730acf45edSAdrian Chadd ATH_TXQ_LOCK(txq); 5743ae723d4SAdrian Chadd /* 5753ae723d4SAdrian Chadd * XXX this is mostly duplicated in ath_tx_handoff_mcast(). 5763ae723d4SAdrian Chadd */ 5779e7259a2SAdrian Chadd if (ATH_TXQ_LAST(txq, axq_q_s) != NULL) { 5783ae723d4SAdrian Chadd struct ath_buf *bf_last = ATH_TXQ_LAST(txq, axq_q_s); 5793ae723d4SAdrian Chadd struct ieee80211_frame *wh; 5803ae723d4SAdrian Chadd 5813ae723d4SAdrian Chadd /* mark previous frame */ 5823ae723d4SAdrian Chadd wh = mtod(bf_last->bf_m, struct ieee80211_frame *); 5833ae723d4SAdrian Chadd wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; 5843ae723d4SAdrian Chadd 585caedab2cSAdrian Chadd /* re-sync buffer to memory */ 5863ae723d4SAdrian Chadd bus_dmamap_sync(sc->sc_dmat, bf_last->bf_dmamap, 5873ae723d4SAdrian Chadd BUS_DMASYNC_PREWRITE); 5889cda8c80SAdrian Chadd 5899cda8c80SAdrian Chadd /* link descriptor */ 5909e7259a2SAdrian Chadd ath_hal_settxdesclink(sc->sc_ah, 5919e7259a2SAdrian Chadd bf_last->bf_lastds, 5929e7259a2SAdrian Chadd bf->bf_daddr); 5933ae723d4SAdrian Chadd } 594e3f06688SAdrian Chadd #ifdef ATH_DEBUG_ALQ 595e3f06688SAdrian Chadd if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC)) 596e3f06688SAdrian Chadd ath_tx_alq_post(sc, bf); 597e3f06688SAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 5983ae723d4SAdrian Chadd ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); 5990acf45edSAdrian Chadd ATH_TXQ_UNLOCK(txq); 6003ae723d4SAdrian Chadd } 6013ae723d4SAdrian Chadd 6023ae723d4SAdrian Chadd /* 603746bab5bSAdrian Chadd * Handoff this frame to the hardware. 604746bab5bSAdrian Chadd * 605746bab5bSAdrian Chadd * For the multicast queue, this will treat it as a software queue 606746bab5bSAdrian Chadd * and append it to the list, after updating the MORE_DATA flag 607746bab5bSAdrian Chadd * in the previous frame. The cabq processing code will ensure 608746bab5bSAdrian Chadd * that the queue contents gets transferred over. 609746bab5bSAdrian Chadd * 610746bab5bSAdrian Chadd * For the hardware queues, this will queue a frame to the queue 611746bab5bSAdrian Chadd * like before, then populate the FIFO from that. Since the 612746bab5bSAdrian Chadd * EDMA hardware has 8 FIFO slots per TXQ, this ensures that 613746bab5bSAdrian Chadd * frames such as management frames don't get prematurely dropped. 614746bab5bSAdrian Chadd * 615746bab5bSAdrian Chadd * This does imply that a similar flush-hwq-to-fifoq method will 616746bab5bSAdrian Chadd * need to be called from the processq function, before the 617746bab5bSAdrian Chadd * per-node software scheduler is called. 618746bab5bSAdrian Chadd */ 619746bab5bSAdrian Chadd static void 620746bab5bSAdrian Chadd ath_edma_xmit_handoff(struct ath_softc *sc, struct ath_txq *txq, 621746bab5bSAdrian Chadd struct ath_buf *bf) 622746bab5bSAdrian Chadd { 623746bab5bSAdrian Chadd 6244aa8818bSAdrian Chadd DPRINTF(sc, ATH_DEBUG_XMIT_DESC, 6254aa8818bSAdrian Chadd "%s: called; bf=%p, txq=%p, qnum=%d\n", 626746bab5bSAdrian Chadd __func__, 627746bab5bSAdrian Chadd bf, 628746bab5bSAdrian Chadd txq, 629746bab5bSAdrian Chadd txq->axq_qnum); 630746bab5bSAdrian Chadd 6313ae723d4SAdrian Chadd if (txq->axq_qnum == ATH_TXQ_SWQ) 6323ae723d4SAdrian Chadd ath_edma_xmit_handoff_mcast(sc, txq, bf); 6333ae723d4SAdrian Chadd else 6343ae723d4SAdrian Chadd ath_edma_xmit_handoff_hw(sc, txq, bf); 635746bab5bSAdrian Chadd } 636746bab5bSAdrian Chadd 6373fdfc330SAdrian Chadd static int 63879607afeSAdrian Chadd ath_edma_setup_txfifo(struct ath_softc *sc, int qnum) 63979607afeSAdrian Chadd { 64079607afeSAdrian Chadd struct ath_tx_edma_fifo *te = &sc->sc_txedma[qnum]; 64179607afeSAdrian Chadd 64279607afeSAdrian Chadd te->m_fifo = malloc(sizeof(struct ath_buf *) * HAL_TXFIFO_DEPTH, 64379607afeSAdrian Chadd M_ATHDEV, 64479607afeSAdrian Chadd M_NOWAIT | M_ZERO); 64579607afeSAdrian Chadd if (te->m_fifo == NULL) { 64679607afeSAdrian Chadd device_printf(sc->sc_dev, "%s: malloc failed\n", 64779607afeSAdrian Chadd __func__); 64879607afeSAdrian Chadd return (-ENOMEM); 64979607afeSAdrian Chadd } 65079607afeSAdrian Chadd 65179607afeSAdrian Chadd /* 65279607afeSAdrian Chadd * Set initial "empty" state. 65379607afeSAdrian Chadd */ 65479607afeSAdrian Chadd te->m_fifo_head = te->m_fifo_tail = te->m_fifo_depth = 0; 65579607afeSAdrian Chadd 65679607afeSAdrian Chadd return (0); 65779607afeSAdrian Chadd } 65879607afeSAdrian Chadd 65979607afeSAdrian Chadd static int 66079607afeSAdrian Chadd ath_edma_free_txfifo(struct ath_softc *sc, int qnum) 66179607afeSAdrian Chadd { 66279607afeSAdrian Chadd struct ath_tx_edma_fifo *te = &sc->sc_txedma[qnum]; 66379607afeSAdrian Chadd 66479607afeSAdrian Chadd /* XXX TODO: actually deref the ath_buf entries? */ 66579607afeSAdrian Chadd free(te->m_fifo, M_ATHDEV); 66679607afeSAdrian Chadd return (0); 66779607afeSAdrian Chadd } 66879607afeSAdrian Chadd 66979607afeSAdrian Chadd static int 6703fdfc330SAdrian Chadd ath_edma_dma_txsetup(struct ath_softc *sc) 6713fdfc330SAdrian Chadd { 672ba3fd9d8SAdrian Chadd int error; 67379607afeSAdrian Chadd int i; 6743fdfc330SAdrian Chadd 675ba3fd9d8SAdrian Chadd error = ath_descdma_alloc_desc(sc, &sc->sc_txsdma, 676ba3fd9d8SAdrian Chadd NULL, "txcomp", sc->sc_tx_statuslen, ATH_TXSTATUS_RING_SIZE); 677ba3fd9d8SAdrian Chadd if (error != 0) 678ba3fd9d8SAdrian Chadd return (error); 679ba3fd9d8SAdrian Chadd 680ba3fd9d8SAdrian Chadd ath_hal_setuptxstatusring(sc->sc_ah, 681ba3fd9d8SAdrian Chadd (void *) sc->sc_txsdma.dd_desc, 682ba3fd9d8SAdrian Chadd sc->sc_txsdma.dd_desc_paddr, 683ba3fd9d8SAdrian Chadd ATH_TXSTATUS_RING_SIZE); 684ba3fd9d8SAdrian Chadd 68579607afeSAdrian Chadd for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { 68679607afeSAdrian Chadd ath_edma_setup_txfifo(sc, i); 68779607afeSAdrian Chadd } 68879607afeSAdrian Chadd 6893fdfc330SAdrian Chadd return (0); 6903fdfc330SAdrian Chadd } 6913fdfc330SAdrian Chadd 6923fdfc330SAdrian Chadd static int 6933fdfc330SAdrian Chadd ath_edma_dma_txteardown(struct ath_softc *sc) 6943fdfc330SAdrian Chadd { 69579607afeSAdrian Chadd int i; 69679607afeSAdrian Chadd 69779607afeSAdrian Chadd for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { 69879607afeSAdrian Chadd ath_edma_free_txfifo(sc, i); 69979607afeSAdrian Chadd } 7003fdfc330SAdrian Chadd 701ba3fd9d8SAdrian Chadd ath_descdma_cleanup(sc, &sc->sc_txsdma, NULL); 7023fdfc330SAdrian Chadd return (0); 7033fdfc330SAdrian Chadd } 7043fdfc330SAdrian Chadd 7053ae723d4SAdrian Chadd /* 706788e6aa9SAdrian Chadd * Drain all TXQs, potentially after completing the existing completed 707788e6aa9SAdrian Chadd * frames. 7083ae723d4SAdrian Chadd */ 709788e6aa9SAdrian Chadd static void 710788e6aa9SAdrian Chadd ath_edma_tx_drain(struct ath_softc *sc, ATH_RESET_TYPE reset_type) 711f8418db5SAdrian Chadd { 7124aa8818bSAdrian Chadd int i; 713f8418db5SAdrian Chadd 714ae3815fdSAdrian Chadd DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); 7154aa8818bSAdrian Chadd 7164aa8818bSAdrian Chadd (void) ath_stoptxdma(sc); 7174aa8818bSAdrian Chadd 7184aa8818bSAdrian Chadd /* 7194aa8818bSAdrian Chadd * If reset type is noloss, the TX FIFO needs to be serviced 7204aa8818bSAdrian Chadd * and those frames need to be handled. 7214aa8818bSAdrian Chadd * 7224aa8818bSAdrian Chadd * Otherwise, just toss everything in each TX queue. 7234aa8818bSAdrian Chadd */ 724ae3815fdSAdrian Chadd if (reset_type == ATH_RESET_NOLOSS) { 725ae3815fdSAdrian Chadd ath_edma_tx_processq(sc, 0); 7268328d6e4SAdrian Chadd for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { 7278328d6e4SAdrian Chadd if (ATH_TXQ_SETUP(sc, i)) { 7288328d6e4SAdrian Chadd ATH_TXQ_LOCK(&sc->sc_txq[i]); 7298328d6e4SAdrian Chadd /* 7308328d6e4SAdrian Chadd * Free the holding buffer; DMA is now 7318328d6e4SAdrian Chadd * stopped. 7328328d6e4SAdrian Chadd */ 7338328d6e4SAdrian Chadd ath_txq_freeholdingbuf(sc, &sc->sc_txq[i]); 7348328d6e4SAdrian Chadd /* 7358328d6e4SAdrian Chadd * Reset the link pointer to NULL; there's 7368328d6e4SAdrian Chadd * no frames to chain DMA to. 7378328d6e4SAdrian Chadd */ 7388328d6e4SAdrian Chadd sc->sc_txq[i].axq_link = NULL; 7398328d6e4SAdrian Chadd ATH_TXQ_UNLOCK(&sc->sc_txq[i]); 7408328d6e4SAdrian Chadd } 7418328d6e4SAdrian Chadd } 742ae3815fdSAdrian Chadd } else { 7434aa8818bSAdrian Chadd for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { 7444aa8818bSAdrian Chadd if (ATH_TXQ_SETUP(sc, i)) 7454aa8818bSAdrian Chadd ath_tx_draintxq(sc, &sc->sc_txq[i]); 7464aa8818bSAdrian Chadd } 747ae3815fdSAdrian Chadd } 748ae3815fdSAdrian Chadd 749ae3815fdSAdrian Chadd /* XXX dump out the TX completion FIFO contents */ 750ae3815fdSAdrian Chadd 751ae3815fdSAdrian Chadd /* XXX dump out the frames */ 7524aa8818bSAdrian Chadd 7534aa8818bSAdrian Chadd sc->sc_wd_timer = 0; 754f8418db5SAdrian Chadd } 755f8418db5SAdrian Chadd 7563ae723d4SAdrian Chadd /* 757ae3815fdSAdrian Chadd * TX completion tasklet. 7583ae723d4SAdrian Chadd */ 759ae3815fdSAdrian Chadd 760f8418db5SAdrian Chadd static void 761f8418db5SAdrian Chadd ath_edma_tx_proc(void *arg, int npending) 762f8418db5SAdrian Chadd { 763f8418db5SAdrian Chadd struct ath_softc *sc = (struct ath_softc *) arg; 764ae3815fdSAdrian Chadd 765908341abSAdrian Chadd ATH_PCU_LOCK(sc); 766908341abSAdrian Chadd sc->sc_txproc_cnt++; 767908341abSAdrian Chadd ATH_PCU_UNLOCK(sc); 768908341abSAdrian Chadd 769908341abSAdrian Chadd ATH_LOCK(sc); 770908341abSAdrian Chadd ath_power_set_power_state(sc, HAL_PM_AWAKE); 771908341abSAdrian Chadd ATH_UNLOCK(sc); 772908341abSAdrian Chadd 77392e84e43SAdrian Chadd #if 0 774ae3815fdSAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: called, npending=%d\n", 775ae3815fdSAdrian Chadd __func__, npending); 77692e84e43SAdrian Chadd #endif 777ae3815fdSAdrian Chadd ath_edma_tx_processq(sc, 1); 778908341abSAdrian Chadd 779908341abSAdrian Chadd 780908341abSAdrian Chadd ATH_PCU_LOCK(sc); 781908341abSAdrian Chadd sc->sc_txproc_cnt--; 782908341abSAdrian Chadd ATH_PCU_UNLOCK(sc); 783908341abSAdrian Chadd 784908341abSAdrian Chadd ATH_LOCK(sc); 785908341abSAdrian Chadd ath_power_restore_power_state(sc); 786908341abSAdrian Chadd ATH_UNLOCK(sc); 787908341abSAdrian Chadd 788908341abSAdrian Chadd ath_tx_kick(sc); 789ae3815fdSAdrian Chadd } 790ae3815fdSAdrian Chadd 791ae3815fdSAdrian Chadd /* 792ae3815fdSAdrian Chadd * Process the TX status queue. 793ae3815fdSAdrian Chadd */ 794ae3815fdSAdrian Chadd static void 795ae3815fdSAdrian Chadd ath_edma_tx_processq(struct ath_softc *sc, int dosched) 796ae3815fdSAdrian Chadd { 7973ae723d4SAdrian Chadd struct ath_hal *ah = sc->sc_ah; 7983ae723d4SAdrian Chadd HAL_STATUS status; 7993ae723d4SAdrian Chadd struct ath_tx_status ts; 8003ae723d4SAdrian Chadd struct ath_txq *txq; 8014aa8818bSAdrian Chadd struct ath_buf *bf; 8024aa8818bSAdrian Chadd struct ieee80211_node *ni; 803208be709SAdrian Chadd int nacked = 0; 804d40c846aSAdrian Chadd int idx; 8054f5ec72aSAdrian Chadd int i; 806d40c846aSAdrian Chadd 807d40c846aSAdrian Chadd #ifdef ATH_DEBUG 808d40c846aSAdrian Chadd /* XXX */ 809d40c846aSAdrian Chadd uint32_t txstatus[32]; 810d40c846aSAdrian Chadd #endif 811f8418db5SAdrian Chadd 812*6eb9f206SAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: called\n", __func__); 813*6eb9f206SAdrian Chadd 814d40c846aSAdrian Chadd for (idx = 0; ; idx++) { 8154aa8818bSAdrian Chadd bzero(&ts, sizeof(ts)); 8164aa8818bSAdrian Chadd 8173ae723d4SAdrian Chadd ATH_TXSTATUS_LOCK(sc); 8184c5038c7SAdrian Chadd #ifdef ATH_DEBUG 819d40c846aSAdrian Chadd ath_hal_gettxrawtxdesc(ah, txstatus); 8204c5038c7SAdrian Chadd #endif 821ae3815fdSAdrian Chadd status = ath_hal_txprocdesc(ah, NULL, (void *) &ts); 8223ae723d4SAdrian Chadd ATH_TXSTATUS_UNLOCK(sc); 8233ae723d4SAdrian Chadd 824*6eb9f206SAdrian Chadd if (status == HAL_EINPROGRESS) { 825*6eb9f206SAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, 826*6eb9f206SAdrian Chadd "%s: (%d): EINPROGRESS\n", 827*6eb9f206SAdrian Chadd __func__, idx); 82892e84e43SAdrian Chadd break; 829*6eb9f206SAdrian Chadd } 83092e84e43SAdrian Chadd 831d40c846aSAdrian Chadd #ifdef ATH_DEBUG 832d40c846aSAdrian Chadd if (sc->sc_debug & ATH_DEBUG_TX_PROC) 83392e84e43SAdrian Chadd if (ts.ts_queue_id != sc->sc_bhalq) 834d40c846aSAdrian Chadd ath_printtxstatbuf(sc, NULL, txstatus, ts.ts_queue_id, 835d40c846aSAdrian Chadd idx, (status == HAL_OK)); 836d40c846aSAdrian Chadd #endif 837d40c846aSAdrian Chadd 8383ae723d4SAdrian Chadd /* 8394aa8818bSAdrian Chadd * If there is an error with this descriptor, continue 8404aa8818bSAdrian Chadd * processing. 8414aa8818bSAdrian Chadd * 8424aa8818bSAdrian Chadd * XXX TBD: log some statistics? 8434aa8818bSAdrian Chadd */ 8444aa8818bSAdrian Chadd if (status == HAL_EIO) { 8454aa8818bSAdrian Chadd device_printf(sc->sc_dev, "%s: invalid TX status?\n", 8464aa8818bSAdrian Chadd __func__); 847b92b5f6eSAdrian Chadd break; 8484aa8818bSAdrian Chadd } 8494aa8818bSAdrian Chadd 85069cbcb21SAdrian Chadd #if defined(ATH_DEBUG_ALQ) && defined(ATH_DEBUG) 851bd3b3362SAdrian Chadd if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXSTATUS)) { 852b69b0dccSAdrian Chadd if_ath_alq_post(&sc->sc_alq, ATH_ALQ_EDMA_TXSTATUS, 853b69b0dccSAdrian Chadd sc->sc_tx_statuslen, 854b69b0dccSAdrian Chadd (char *) txstatus); 855bd3b3362SAdrian Chadd } 856b69b0dccSAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 857b69b0dccSAdrian Chadd 8584aa8818bSAdrian Chadd /* 8593ae723d4SAdrian Chadd * At this point we have a valid status descriptor. 8603ae723d4SAdrian Chadd * The QID and descriptor ID (which currently isn't set) 8613ae723d4SAdrian Chadd * is part of the status. 8623ae723d4SAdrian Chadd * 8633ae723d4SAdrian Chadd * We then assume that the descriptor in question is the 8643ae723d4SAdrian Chadd * -head- of the given QID. Eventually we should verify 8653ae723d4SAdrian Chadd * this by using the descriptor ID. 8663ae723d4SAdrian Chadd */ 8674aa8818bSAdrian Chadd 8684aa8818bSAdrian Chadd /* 8694aa8818bSAdrian Chadd * The beacon queue is not currently a "real" queue. 8704aa8818bSAdrian Chadd * Frames aren't pushed onto it and the lock isn't setup. 8714aa8818bSAdrian Chadd * So skip it for now; the beacon handling code will 8724aa8818bSAdrian Chadd * free and alloc more beacon buffers as appropriate. 8734aa8818bSAdrian Chadd */ 8744aa8818bSAdrian Chadd if (ts.ts_queue_id == sc->sc_bhalq) 8754aa8818bSAdrian Chadd continue; 8763ae723d4SAdrian Chadd 8773ae723d4SAdrian Chadd txq = &sc->sc_txq[ts.ts_queue_id]; 8784aa8818bSAdrian Chadd 879b837332dSAdrian Chadd ATH_TXQ_LOCK(txq); 88092e84e43SAdrian Chadd bf = ATH_TXQ_FIRST(&txq->fifo); 8814aa8818bSAdrian Chadd 88292e84e43SAdrian Chadd /* 88392e84e43SAdrian Chadd * Work around the situation where I'm seeing notifications 88492e84e43SAdrian Chadd * for Q1 when no frames are available. That needs to be 88592e84e43SAdrian Chadd * debugged but not by crashing _here_. 88692e84e43SAdrian Chadd */ 88792e84e43SAdrian Chadd if (bf == NULL) { 88892e84e43SAdrian Chadd device_printf(sc->sc_dev, "%s: Q%d: empty?\n", 8894aa8818bSAdrian Chadd __func__, 89092e84e43SAdrian Chadd ts.ts_queue_id); 891b92b5f6eSAdrian Chadd ATH_TXQ_UNLOCK(txq); 89292e84e43SAdrian Chadd continue; 89392e84e43SAdrian Chadd } 89492e84e43SAdrian Chadd 89592e84e43SAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: Q%d, bf=%p, start=%d, end=%d\n", 89692e84e43SAdrian Chadd __func__, 89792e84e43SAdrian Chadd ts.ts_queue_id, bf, 89892e84e43SAdrian Chadd !! (bf->bf_flags & ATH_BUF_FIFOPTR), 89992e84e43SAdrian Chadd !! (bf->bf_flags & ATH_BUF_FIFOEND)); 9004aa8818bSAdrian Chadd 901d40c846aSAdrian Chadd /* XXX TODO: actually output debugging info about this */ 902d40c846aSAdrian Chadd 9034aa8818bSAdrian Chadd #if 0 9044aa8818bSAdrian Chadd /* XXX assert the buffer/descriptor matches the status descid */ 9054aa8818bSAdrian Chadd if (ts.ts_desc_id != bf->bf_descid) { 9064aa8818bSAdrian Chadd device_printf(sc->sc_dev, 9074aa8818bSAdrian Chadd "%s: mismatched descid (qid=%d, tsdescid=%d, " 9084aa8818bSAdrian Chadd "bfdescid=%d\n", 9094aa8818bSAdrian Chadd __func__, 9104aa8818bSAdrian Chadd ts.ts_queue_id, 9114aa8818bSAdrian Chadd ts.ts_desc_id, 9124aa8818bSAdrian Chadd bf->bf_descid); 9133ae723d4SAdrian Chadd } 9144aa8818bSAdrian Chadd #endif 9154aa8818bSAdrian Chadd 9164aa8818bSAdrian Chadd /* This removes the buffer and decrements the queue depth */ 91792e84e43SAdrian Chadd ATH_TXQ_REMOVE(&txq->fifo, bf, bf_list); 9184aa8818bSAdrian Chadd if (bf->bf_state.bfs_aggr) 9194aa8818bSAdrian Chadd txq->axq_aggr_depth--; 92092e84e43SAdrian Chadd 92192e84e43SAdrian Chadd /* 92292e84e43SAdrian Chadd * If this was the end of a FIFO set, decrement FIFO depth 92392e84e43SAdrian Chadd */ 92492e84e43SAdrian Chadd if (bf->bf_flags & ATH_BUF_FIFOEND) 9254aa8818bSAdrian Chadd txq->axq_fifo_depth--; 92692e84e43SAdrian Chadd 92792e84e43SAdrian Chadd /* 92892e84e43SAdrian Chadd * If this isn't the final buffer in a FIFO set, mark 92992e84e43SAdrian Chadd * the buffer as busy so it goes onto the holding queue. 93092e84e43SAdrian Chadd */ 93192e84e43SAdrian Chadd if (! (bf->bf_flags & ATH_BUF_FIFOEND)) 93292e84e43SAdrian Chadd bf->bf_flags |= ATH_BUF_BUSY; 93392e84e43SAdrian Chadd 93492e84e43SAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: Q%d: FIFO depth is now %d (%d)\n", 93592e84e43SAdrian Chadd __func__, 93692e84e43SAdrian Chadd txq->axq_qnum, 93792e84e43SAdrian Chadd txq->axq_fifo_depth, 93892e84e43SAdrian Chadd txq->fifo.axq_depth); 93992e84e43SAdrian Chadd 9404aa8818bSAdrian Chadd /* XXX assert FIFO depth >= 0 */ 941b837332dSAdrian Chadd ATH_TXQ_UNLOCK(txq); 9424aa8818bSAdrian Chadd 9434aa8818bSAdrian Chadd /* 94492e84e43SAdrian Chadd * Outside of the TX lock - if the buffer is end 94592e84e43SAdrian Chadd * end buffer in this FIFO, we don't need a holding 94692e84e43SAdrian Chadd * buffer any longer. 94792e84e43SAdrian Chadd */ 94892e84e43SAdrian Chadd if (bf->bf_flags & ATH_BUF_FIFOEND) { 949caedab2cSAdrian Chadd ATH_TXQ_LOCK(txq); 95092e84e43SAdrian Chadd ath_txq_freeholdingbuf(sc, txq); 951caedab2cSAdrian Chadd ATH_TXQ_UNLOCK(txq); 95292e84e43SAdrian Chadd } 95392e84e43SAdrian Chadd 95492e84e43SAdrian Chadd /* 9554aa8818bSAdrian Chadd * First we need to make sure ts_rate is valid. 9564aa8818bSAdrian Chadd * 9574aa8818bSAdrian Chadd * Pre-EDMA chips pass the whole TX descriptor to 9584aa8818bSAdrian Chadd * the proctxdesc function which will then fill out 9594aa8818bSAdrian Chadd * ts_rate based on the ts_finaltsi (final TX index) 9604aa8818bSAdrian Chadd * in the TX descriptor. However the TX completion 9614aa8818bSAdrian Chadd * FIFO doesn't have this information. So here we 9624aa8818bSAdrian Chadd * do a separate HAL call to populate that information. 9633345c65bSAdrian Chadd * 9643345c65bSAdrian Chadd * The same problem exists with ts_longretry. 9653345c65bSAdrian Chadd * The FreeBSD HAL corrects ts_longretry in the HAL layer; 9663345c65bSAdrian Chadd * the AR9380 HAL currently doesn't. So until the HAL 9673345c65bSAdrian Chadd * is imported and this can be added, we correct for it 9683345c65bSAdrian Chadd * here. 9694aa8818bSAdrian Chadd */ 9704aa8818bSAdrian Chadd /* XXX TODO */ 9714aa8818bSAdrian Chadd /* XXX faked for now. Ew. */ 9724aa8818bSAdrian Chadd if (ts.ts_finaltsi < 4) { 9734aa8818bSAdrian Chadd ts.ts_rate = 9744aa8818bSAdrian Chadd bf->bf_state.bfs_rc[ts.ts_finaltsi].ratecode; 9753345c65bSAdrian Chadd switch (ts.ts_finaltsi) { 9763345c65bSAdrian Chadd case 3: ts.ts_longretry += 9773345c65bSAdrian Chadd bf->bf_state.bfs_rc[2].tries; 9783345c65bSAdrian Chadd case 2: ts.ts_longretry += 9793345c65bSAdrian Chadd bf->bf_state.bfs_rc[1].tries; 9803345c65bSAdrian Chadd case 1: ts.ts_longretry += 9813345c65bSAdrian Chadd bf->bf_state.bfs_rc[0].tries; 9823345c65bSAdrian Chadd } 9834aa8818bSAdrian Chadd } else { 9844aa8818bSAdrian Chadd device_printf(sc->sc_dev, "%s: finaltsi=%d\n", 9854aa8818bSAdrian Chadd __func__, 9864aa8818bSAdrian Chadd ts.ts_finaltsi); 9874aa8818bSAdrian Chadd ts.ts_rate = bf->bf_state.bfs_rc[0].ratecode; 9884aa8818bSAdrian Chadd } 9894aa8818bSAdrian Chadd 9904aa8818bSAdrian Chadd /* 9914aa8818bSAdrian Chadd * XXX This is terrible. 9924aa8818bSAdrian Chadd * 9934aa8818bSAdrian Chadd * Right now, some code uses the TX status that is 9944aa8818bSAdrian Chadd * passed in here, but the completion handlers in the 9954aa8818bSAdrian Chadd * software TX path also use bf_status.ds_txstat. 9964aa8818bSAdrian Chadd * Ew. That should all go away. 9974aa8818bSAdrian Chadd * 9984aa8818bSAdrian Chadd * XXX It's also possible the rate control completion 9994aa8818bSAdrian Chadd * routine is called twice. 10004aa8818bSAdrian Chadd */ 10014aa8818bSAdrian Chadd memcpy(&bf->bf_status, &ts, sizeof(ts)); 10024aa8818bSAdrian Chadd 10034aa8818bSAdrian Chadd ni = bf->bf_node; 10044aa8818bSAdrian Chadd 10054aa8818bSAdrian Chadd /* Update RSSI */ 10064aa8818bSAdrian Chadd /* XXX duplicate from ath_tx_processq */ 10074aa8818bSAdrian Chadd if (ni != NULL && ts.ts_status == 0 && 10084aa8818bSAdrian Chadd ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) { 10094aa8818bSAdrian Chadd nacked++; 10104aa8818bSAdrian Chadd sc->sc_stats.ast_tx_rssi = ts.ts_rssi; 10114aa8818bSAdrian Chadd ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, 10124aa8818bSAdrian Chadd ts.ts_rssi); 10134aa8818bSAdrian Chadd } 10144aa8818bSAdrian Chadd 10154aa8818bSAdrian Chadd /* Handle frame completion and rate control update */ 10164aa8818bSAdrian Chadd ath_tx_process_buf_completion(sc, txq, &ts, bf); 10174aa8818bSAdrian Chadd 10184f5ec72aSAdrian Chadd /* NB: bf is invalid at this point */ 10194aa8818bSAdrian Chadd } 10204aa8818bSAdrian Chadd 10214aa8818bSAdrian Chadd sc->sc_wd_timer = 0; 10224aa8818bSAdrian Chadd 10234aa8818bSAdrian Chadd /* 10244aa8818bSAdrian Chadd * XXX It's inefficient to do this if the FIFO queue is full, 10254aa8818bSAdrian Chadd * but there's no easy way right now to only populate 10264aa8818bSAdrian Chadd * the txq task for _one_ TXQ. This should be fixed. 10274aa8818bSAdrian Chadd */ 10284f5ec72aSAdrian Chadd if (dosched) { 10294f5ec72aSAdrian Chadd /* Attempt to schedule more hardware frames to the TX FIFO */ 10304f5ec72aSAdrian Chadd for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { 10314f5ec72aSAdrian Chadd if (ATH_TXQ_SETUP(sc, i)) { 1032*6eb9f206SAdrian Chadd ATH_TX_LOCK(sc); 1033*6eb9f206SAdrian Chadd ath_txq_sched(sc, &sc->sc_txq[i]); 1034*6eb9f206SAdrian Chadd ATH_TX_UNLOCK(sc); 1035*6eb9f206SAdrian Chadd 10364f5ec72aSAdrian Chadd ATH_TXQ_LOCK(&sc->sc_txq[i]); 10374f5ec72aSAdrian Chadd ath_edma_tx_fifo_fill(sc, &sc->sc_txq[i]); 10384f5ec72aSAdrian Chadd ATH_TXQ_UNLOCK(&sc->sc_txq[i]); 10394f5ec72aSAdrian Chadd } 10404f5ec72aSAdrian Chadd } 10414f5ec72aSAdrian Chadd /* Kick software scheduler */ 104221bca442SAdrian Chadd ath_tx_swq_kick(sc); 1043f8418db5SAdrian Chadd } 1044*6eb9f206SAdrian Chadd 1045*6eb9f206SAdrian Chadd DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: end\n", __func__); 10464f5ec72aSAdrian Chadd } 1047f8418db5SAdrian Chadd 1048f8418db5SAdrian Chadd static void 1049f8418db5SAdrian Chadd ath_edma_attach_comp_func(struct ath_softc *sc) 1050f8418db5SAdrian Chadd { 1051f8418db5SAdrian Chadd 1052f8418db5SAdrian Chadd TASK_INIT(&sc->sc_txtask, 0, ath_edma_tx_proc, sc); 1053f8418db5SAdrian Chadd } 1054f8418db5SAdrian Chadd 10553fdfc330SAdrian Chadd void 10563fdfc330SAdrian Chadd ath_xmit_setup_edma(struct ath_softc *sc) 10573fdfc330SAdrian Chadd { 10583fdfc330SAdrian Chadd 10593fdfc330SAdrian Chadd /* Fetch EDMA field and buffer sizes */ 10603fdfc330SAdrian Chadd (void) ath_hal_gettxdesclen(sc->sc_ah, &sc->sc_tx_desclen); 10613fdfc330SAdrian Chadd (void) ath_hal_gettxstatuslen(sc->sc_ah, &sc->sc_tx_statuslen); 10623fdfc330SAdrian Chadd (void) ath_hal_getntxmaps(sc->sc_ah, &sc->sc_tx_nmaps); 10633fdfc330SAdrian Chadd 1064516a0ac2SAdrian Chadd if (bootverbose) { 10653fdfc330SAdrian Chadd device_printf(sc->sc_dev, "TX descriptor length: %d\n", 10663fdfc330SAdrian Chadd sc->sc_tx_desclen); 10673fdfc330SAdrian Chadd device_printf(sc->sc_dev, "TX status length: %d\n", 10683fdfc330SAdrian Chadd sc->sc_tx_statuslen); 10693fdfc330SAdrian Chadd device_printf(sc->sc_dev, "TX buffers per descriptor: %d\n", 10703fdfc330SAdrian Chadd sc->sc_tx_nmaps); 1071516a0ac2SAdrian Chadd } 10723fdfc330SAdrian Chadd 10733fdfc330SAdrian Chadd sc->sc_tx.xmit_setup = ath_edma_dma_txsetup; 10743fdfc330SAdrian Chadd sc->sc_tx.xmit_teardown = ath_edma_dma_txteardown; 1075f8418db5SAdrian Chadd sc->sc_tx.xmit_attach_comp_func = ath_edma_attach_comp_func; 1076746bab5bSAdrian Chadd 1077746bab5bSAdrian Chadd sc->sc_tx.xmit_dma_restart = ath_edma_dma_restart; 1078746bab5bSAdrian Chadd sc->sc_tx.xmit_handoff = ath_edma_xmit_handoff; 1079788e6aa9SAdrian Chadd sc->sc_tx.xmit_drain = ath_edma_tx_drain; 10803fdfc330SAdrian Chadd } 1081