2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2006 Atheros Communications, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c 187831 2009-01-28 18:00:22Z sam $
23 #include "ah_internal.h"
26 #include "ar5211/ar5211.h"
27 #include "ar5211/ar5211reg.h"
28 #include "ar5211/ar5211desc.h"
31 * Update Tx FIFO trigger level.
33 * Set bIncTrigLevel to TRUE to increase the trigger level.
34 * Set bIncTrigLevel to FALSE to decrease the trigger level.
36 * Returns TRUE if the trigger level was updated
39 ar5211UpdateTxTrigLevel(struct ath_hal *ah, HAL_BOOL bIncTrigLevel)
41 uint32_t curTrigLevel, txcfg;
42 HAL_INT ints = ar5211GetInterrupts(ah);
45 * Disable chip interrupts. This is because halUpdateTxTrigLevel
46 * is called from both ISR and non-ISR contexts.
48 ar5211SetInterrupts(ah, ints &~ HAL_INT_GLOBAL);
49 txcfg = OS_REG_READ(ah, AR_TXCFG);
50 curTrigLevel = (txcfg & AR_TXCFG_FTRIG_M) >> AR_TXCFG_FTRIG_S;
52 /* increase the trigger level */
53 curTrigLevel = curTrigLevel +
54 ((MAX_TX_FIFO_THRESHOLD - curTrigLevel) / 2);
56 /* decrease the trigger level if not already at the minimum */
57 if (curTrigLevel > MIN_TX_FIFO_THRESHOLD) {
58 /* decrease the trigger level */
61 /* no update to the trigger level */
62 /* re-enable chip interrupts */
63 ar5211SetInterrupts(ah, ints);
67 /* Update the trigger level */
68 OS_REG_WRITE(ah, AR_TXCFG, (txcfg &~ AR_TXCFG_FTRIG_M) |
69 ((curTrigLevel << AR_TXCFG_FTRIG_S) & AR_TXCFG_FTRIG_M));
70 /* re-enable chip interrupts */
71 ar5211SetInterrupts(ah, ints);
76 * Set the properties of the tx queue with the parameters
77 * from qInfo. The queue must previously have been setup
78 * with a call to ar5211SetupTxQueue.
81 ar5211SetTxQueueProps(struct ath_hal *ah, int q, const HAL_TXQ_INFO *qInfo)
83 struct ath_hal_5211 *ahp = AH5211(ah);
85 if (q >= HAL_NUM_TX_QUEUES) {
86 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
90 return ath_hal_setTxQProps(ah, &ahp->ah_txq[q], qInfo);
94 * Return the properties for the specified tx queue.
97 ar5211GetTxQueueProps(struct ath_hal *ah, int q, HAL_TXQ_INFO *qInfo)
99 struct ath_hal_5211 *ahp = AH5211(ah);
101 if (q >= HAL_NUM_TX_QUEUES) {
102 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
106 return ath_hal_getTxQProps(ah, qInfo, &ahp->ah_txq[q]);
110 * Allocate and initialize a tx DCU/QCU combination.
113 ar5211SetupTxQueue(struct ath_hal *ah, HAL_TX_QUEUE type,
114 const HAL_TXQ_INFO *qInfo)
116 struct ath_hal_5211 *ahp = AH5211(ah);
117 HAL_TX_QUEUE_INFO *qi;
121 case HAL_TX_QUEUE_BEACON:
124 case HAL_TX_QUEUE_CAB:
127 case HAL_TX_QUEUE_DATA:
129 if (ahp->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE)
133 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad tx queue type %u\n",
138 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
140 qi = &ahp->ah_txq[q];
141 if (qi->tqi_type != HAL_TX_QUEUE_INACTIVE) {
142 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: tx queue %u already active\n",
146 OS_MEMZERO(qi, sizeof(HAL_TX_QUEUE_INFO));
148 if (qInfo == AH_NULL) {
149 /* by default enable OK+ERR+DESC+URN interrupts */
151 HAL_TXQ_TXOKINT_ENABLE
152 | HAL_TXQ_TXERRINT_ENABLE
153 | HAL_TXQ_TXDESCINT_ENABLE
154 | HAL_TXQ_TXURNINT_ENABLE
156 qi->tqi_aifs = INIT_AIFS;
157 qi->tqi_cwmin = HAL_TXQ_USEDEFAULT; /* NB: do at reset */
158 qi->tqi_cwmax = INIT_CWMAX;
159 qi->tqi_shretry = INIT_SH_RETRY;
160 qi->tqi_lgretry = INIT_LG_RETRY;
162 (void) ar5211SetTxQueueProps(ah, q, qInfo);
167 * Update the h/w interrupt registers to reflect a tx q's configuration.
170 setTxQInterrupts(struct ath_hal *ah, HAL_TX_QUEUE_INFO *qi)
172 struct ath_hal_5211 *ahp = AH5211(ah);
174 HALDEBUG(ah, HAL_DEBUG_TXQUEUE,
175 "%s: tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n", __func__
176 , ahp->ah_txOkInterruptMask
177 , ahp->ah_txErrInterruptMask
178 , ahp->ah_txDescInterruptMask
179 , ahp->ah_txEolInterruptMask
180 , ahp->ah_txUrnInterruptMask
183 OS_REG_WRITE(ah, AR_IMR_S0,
184 SM(ahp->ah_txOkInterruptMask, AR_IMR_S0_QCU_TXOK)
185 | SM(ahp->ah_txDescInterruptMask, AR_IMR_S0_QCU_TXDESC)
187 OS_REG_WRITE(ah, AR_IMR_S1,
188 SM(ahp->ah_txErrInterruptMask, AR_IMR_S1_QCU_TXERR)
189 | SM(ahp->ah_txEolInterruptMask, AR_IMR_S1_QCU_TXEOL)
191 OS_REG_RMW_FIELD(ah, AR_IMR_S2,
192 AR_IMR_S2_QCU_TXURN, ahp->ah_txUrnInterruptMask);
197 * Free a tx DCU/QCU combination.
200 ar5211ReleaseTxQueue(struct ath_hal *ah, u_int q)
202 struct ath_hal_5211 *ahp = AH5211(ah);
203 HAL_TX_QUEUE_INFO *qi;
205 if (q >= HAL_NUM_TX_QUEUES) {
206 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
210 qi = &ahp->ah_txq[q];
211 if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
212 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
217 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: release queue %u\n", __func__, q);
219 qi->tqi_type = HAL_TX_QUEUE_INACTIVE;
220 ahp->ah_txOkInterruptMask &= ~(1 << q);
221 ahp->ah_txErrInterruptMask &= ~(1 << q);
222 ahp->ah_txDescInterruptMask &= ~(1 << q);
223 ahp->ah_txEolInterruptMask &= ~(1 << q);
224 ahp->ah_txUrnInterruptMask &= ~(1 << q);
225 setTxQInterrupts(ah, qi);
231 * Set the retry, aifs, cwmin/max, readyTime regs for specified queue
234 ar5211ResetTxQueue(struct ath_hal *ah, u_int q)
236 struct ath_hal_5211 *ahp = AH5211(ah);
237 const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan;
238 HAL_TX_QUEUE_INFO *qi;
239 uint32_t cwMin, chanCwMin, value;
241 if (q >= HAL_NUM_TX_QUEUES) {
242 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
246 qi = &ahp->ah_txq[q];
247 if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
248 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
250 return AH_TRUE; /* XXX??? */
253 if (qi->tqi_cwmin == HAL_TXQ_USEDEFAULT) {
255 * Select cwmin according to channel type.
256 * NB: chan can be NULL during attach
258 if (chan && IEEE80211_IS_CHAN_B(chan))
259 chanCwMin = INIT_CWMIN_11B;
261 chanCwMin = INIT_CWMIN;
262 /* make sure that the CWmin is of the form (2^n - 1) */
263 for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1)
266 cwMin = qi->tqi_cwmin;
268 /* set cwMin/Max and AIFS values */
269 OS_REG_WRITE(ah, AR_DLCL_IFS(q),
270 SM(cwMin, AR_D_LCL_IFS_CWMIN)
271 | SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX)
272 | SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
274 /* Set retry limit values */
275 OS_REG_WRITE(ah, AR_DRETRY_LIMIT(q),
276 SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH)
277 | SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG)
278 | SM(qi->tqi_lgretry, AR_D_RETRY_LIMIT_FR_LG)
279 | SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH)
282 /* enable early termination on the QCU */
283 OS_REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
285 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU) {
286 /* Configure DCU to use the global sequence count */
287 OS_REG_WRITE(ah, AR_DMISC(q), AR5311_D_MISC_SEQ_NUM_CONTROL);
289 /* multiqueue support */
290 if (qi->tqi_cbrPeriod) {
291 OS_REG_WRITE(ah, AR_QCBRCFG(q),
292 SM(qi->tqi_cbrPeriod,AR_Q_CBRCFG_CBR_INTERVAL)
293 | SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_CBR_OVF_THRESH));
294 OS_REG_WRITE(ah, AR_QMISC(q),
295 OS_REG_READ(ah, AR_QMISC(q)) |
297 (qi->tqi_cbrOverflowLimit ?
298 AR_Q_MISC_CBR_EXP_CNTR_LIMIT : 0));
300 if (qi->tqi_readyTime) {
301 OS_REG_WRITE(ah, AR_QRDYTIMECFG(q),
302 SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_INT) |
305 if (qi->tqi_burstTime) {
306 OS_REG_WRITE(ah, AR_DCHNTIME(q),
307 SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
309 if (qi->tqi_qflags & HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE) {
310 OS_REG_WRITE(ah, AR_QMISC(q),
311 OS_REG_READ(ah, AR_QMISC(q)) |
312 AR_Q_MISC_RDYTIME_EXP_POLICY);
316 if (qi->tqi_qflags & HAL_TXQ_BACKOFF_DISABLE) {
317 OS_REG_WRITE(ah, AR_DMISC(q),
318 OS_REG_READ(ah, AR_DMISC(q)) |
319 AR_D_MISC_POST_FR_BKOFF_DIS);
321 if (qi->tqi_qflags & HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE) {
322 OS_REG_WRITE(ah, AR_DMISC(q),
323 OS_REG_READ(ah, AR_DMISC(q)) |
324 AR_D_MISC_FRAG_BKOFF_EN);
326 switch (qi->tqi_type) {
327 case HAL_TX_QUEUE_BEACON:
328 /* Configure QCU for beacons */
329 OS_REG_WRITE(ah, AR_QMISC(q),
330 OS_REG_READ(ah, AR_QMISC(q))
331 | AR_Q_MISC_FSP_DBA_GATED
332 | AR_Q_MISC_BEACON_USE
333 | AR_Q_MISC_CBR_INCR_DIS1);
334 /* Configure DCU for beacons */
335 value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
336 | AR_D_MISC_BEACON_USE | AR_D_MISC_POST_FR_BKOFF_DIS;
337 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)
338 value |= AR5311_D_MISC_SEQ_NUM_CONTROL;
339 OS_REG_WRITE(ah, AR_DMISC(q), value);
341 case HAL_TX_QUEUE_CAB:
342 /* Configure QCU for CAB (Crap After Beacon) frames */
343 OS_REG_WRITE(ah, AR_QMISC(q),
344 OS_REG_READ(ah, AR_QMISC(q))
345 | AR_Q_MISC_FSP_DBA_GATED | AR_Q_MISC_CBR_INCR_DIS1
346 | AR_Q_MISC_CBR_INCR_DIS0 | AR_Q_MISC_RDYTIME_EXP_POLICY);
348 value = (ahp->ah_beaconInterval
349 - (ath_hal_sw_beacon_response_time - ath_hal_dma_beacon_response_time)
350 - ath_hal_additional_swba_backoff) * 1024;
351 OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);
353 /* Configure DCU for CAB */
354 value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S);
355 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)
356 value |= AR5311_D_MISC_SEQ_NUM_CONTROL;
357 OS_REG_WRITE(ah, AR_QMISC(q), value);
360 /* NB: silence compiler */
365 * Always update the secondary interrupt mask registers - this
366 * could be a new queue getting enabled in a running system or
367 * hw getting re-initialized during a reset!
369 * Since we don't differentiate between tx interrupts corresponding
370 * to individual queues - secondary tx mask regs are always unmasked;
371 * tx interrupts are enabled/disabled for all queues collectively
372 * using the primary mask reg
374 if (qi->tqi_qflags & HAL_TXQ_TXOKINT_ENABLE)
375 ahp->ah_txOkInterruptMask |= 1 << q;
377 ahp->ah_txOkInterruptMask &= ~(1 << q);
378 if (qi->tqi_qflags & HAL_TXQ_TXERRINT_ENABLE)
379 ahp->ah_txErrInterruptMask |= 1 << q;
381 ahp->ah_txErrInterruptMask &= ~(1 << q);
382 if (qi->tqi_qflags & HAL_TXQ_TXDESCINT_ENABLE)
383 ahp->ah_txDescInterruptMask |= 1 << q;
385 ahp->ah_txDescInterruptMask &= ~(1 << q);
386 if (qi->tqi_qflags & HAL_TXQ_TXEOLINT_ENABLE)
387 ahp->ah_txEolInterruptMask |= 1 << q;
389 ahp->ah_txEolInterruptMask &= ~(1 << q);
390 if (qi->tqi_qflags & HAL_TXQ_TXURNINT_ENABLE)
391 ahp->ah_txUrnInterruptMask |= 1 << q;
393 ahp->ah_txUrnInterruptMask &= ~(1 << q);
394 setTxQInterrupts(ah, qi);
400 * Get the TXDP for the specified data queue.
403 ar5211GetTxDP(struct ath_hal *ah, u_int q)
405 HALASSERT(q < HAL_NUM_TX_QUEUES);
406 return OS_REG_READ(ah, AR_QTXDP(q));
410 * Set the TxDP for the specified tx queue.
413 ar5211SetTxDP(struct ath_hal *ah, u_int q, uint32_t txdp)
415 HALASSERT(q < HAL_NUM_TX_QUEUES);
416 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
419 * Make sure that TXE is deasserted before setting the TXDP. If TXE
420 * is still asserted, setting TXDP will have no effect.
422 HALASSERT((OS_REG_READ(ah, AR_Q_TXE) & (1 << q)) == 0);
424 OS_REG_WRITE(ah, AR_QTXDP(q), txdp);
430 * Set Transmit Enable bits for the specified queues.
433 ar5211StartTxDma(struct ath_hal *ah, u_int q)
435 HALASSERT(q < HAL_NUM_TX_QUEUES);
436 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
439 /* Check that queue is not already active */
440 HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1<<q)) == 0);
442 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
444 /* Check to be sure we're not enabling a q that has its TXD bit set. */
445 HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1 << q)) == 0);
447 OS_REG_WRITE(ah, AR_Q_TXE, 1 << q);
452 * Return the number of frames pending on the specified queue.
455 ar5211NumTxPending(struct ath_hal *ah, u_int q)
459 HALASSERT(q < HAL_NUM_TX_QUEUES);
460 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
462 n = OS_REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT_M;
464 * Pending frame count (PFC) can momentarily go to zero
465 * while TXE remains asserted. In other words a PFC of
466 * zero is not sufficient to say that the queue has stopped.
468 if (n == 0 && (OS_REG_READ(ah, AR_Q_TXE) & (1<<q)))
469 n = 1; /* arbitrarily pick 1 */
474 * Stop transmit on the specified queue
477 ar5211StopTxDma(struct ath_hal *ah, u_int q)
481 HALASSERT(q < HAL_NUM_TX_QUEUES);
482 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
484 OS_REG_WRITE(ah, AR_Q_TXD, 1<<q);
485 for (i = 0; i < 10000; i++) {
486 if (ar5211NumTxPending(ah, q) == 0)
490 OS_REG_WRITE(ah, AR_Q_TXD, 0);
496 * Descriptor Access Functions
499 #define VALID_PKT_TYPES \
500 ((1<<HAL_PKT_TYPE_NORMAL)|(1<<HAL_PKT_TYPE_ATIM)|\
501 (1<<HAL_PKT_TYPE_PSPOLL)|(1<<HAL_PKT_TYPE_PROBE_RESP)|\
502 (1<<HAL_PKT_TYPE_BEACON))
503 #define isValidPktType(_t) ((1<<(_t)) & VALID_PKT_TYPES)
504 #define VALID_TX_RATES \
505 ((1<<0x0b)|(1<<0x0f)|(1<<0x0a)|(1<<0x0e)|(1<<0x09)|(1<<0x0d)|\
506 (1<<0x08)|(1<<0x0c)|(1<<0x1b)|(1<<0x1a)|(1<<0x1e)|(1<<0x19)|\
507 (1<<0x1d)|(1<<0x18)|(1<<0x1c))
508 #define isValidTxRate(_r) ((1<<(_r)) & VALID_TX_RATES)
511 ar5211SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
516 u_int txRate0, u_int txTries0,
521 u_int rtsctsDuration,
526 struct ar5211_desc *ads = AR5211DESC(ds);
530 (void) rtsctsRate; (void) rtsctsDuration;
532 HALASSERT(txTries0 != 0);
533 HALASSERT(isValidPktType(type));
534 HALASSERT(isValidTxRate(txRate0));
535 /* XXX validate antMode */
537 ads->ds_ctl0 = (pktLen & AR_FrameLen)
538 | (txRate0 << AR_XmitRate_S)
539 | (antMode << AR_AntModeXmit_S)
540 | (flags & HAL_TXDESC_CLRDMASK ? AR_ClearDestMask : 0)
541 | (flags & HAL_TXDESC_INTREQ ? AR_TxInterReq : 0)
542 | (flags & HAL_TXDESC_RTSENA ? AR_RTSCTSEnable : 0)
543 | (flags & HAL_TXDESC_VEOL ? AR_VEOL : 0)
545 ads->ds_ctl1 = (type << 26)
546 | (flags & HAL_TXDESC_NOACK ? AR_NoAck : 0)
549 if (keyIx != HAL_TXKEYIX_INVALID) {
551 (keyIx << AR_EncryptKeyIdx_S) & AR_EncryptKeyIdx;
552 ads->ds_ctl0 |= AR_EncryptKeyValid;
559 ar5211SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds,
560 u_int txRate1, u_int txTries1,
561 u_int txRate2, u_int txTries2,
562 u_int txRate3, u_int txTries3)
564 (void) ah; (void) ds;
565 (void) txRate1; (void) txTries1;
566 (void) txRate2; (void) txTries2;
567 (void) txRate3; (void) txTries3;
572 ar5211IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *ds)
574 struct ar5211_desc *ads = AR5211DESC(ds);
576 ads->ds_ctl0 |= AR_TxInterReq;
580 ar5211FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
581 u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
582 const struct ath_desc *ds0)
584 struct ar5211_desc *ads = AR5211DESC(ds);
586 HALASSERT((segLen &~ AR_BufLen) == 0);
590 * First descriptor, don't clobber xmit control data
591 * setup by ar5211SetupTxDesc.
593 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_More);
594 } else if (lastSeg) { /* !firstSeg && lastSeg */
596 * Last descriptor in a multi-descriptor frame,
597 * copy the transmit parameters from the first
598 * frame for processing on completion.
600 ads->ds_ctl0 = AR5211DESC_CONST(ds0)->ds_ctl0;
601 ads->ds_ctl1 = segLen;
602 } else { /* !firstSeg && !lastSeg */
604 * Intermediate descriptor in a multi-descriptor frame.
607 ads->ds_ctl1 = segLen | AR_More;
609 ads->ds_status0 = ads->ds_status1 = 0;
614 * Processing of HW TX descriptor.
617 ar5211ProcTxDesc(struct ath_hal *ah,
618 struct ath_desc *ds, struct ath_tx_status *ts)
620 struct ar5211_desc *ads = AR5211DESC(ds);
622 if ((ads->ds_status1 & AR_Done) == 0)
623 return HAL_EINPROGRESS;
625 /* Update software copies of the HW status */
626 ts->ts_seqnum = MS(ads->ds_status1, AR_SeqNum);
627 ts->ts_tstamp = MS(ads->ds_status0, AR_SendTimestamp);
629 if ((ads->ds_status0 & AR_FrmXmitOK) == 0) {
630 if (ads->ds_status0 & AR_ExcessiveRetries)
631 ts->ts_status |= HAL_TXERR_XRETRY;
632 if (ads->ds_status0 & AR_Filtered)
633 ts->ts_status |= HAL_TXERR_FILT;
634 if (ads->ds_status0 & AR_FIFOUnderrun)
635 ts->ts_status |= HAL_TXERR_FIFO;
637 ts->ts_rate = MS(ads->ds_ctl0, AR_XmitRate);
638 ts->ts_rssi = MS(ads->ds_status1, AR_AckSigStrength);
639 ts->ts_shortretry = MS(ads->ds_status0, AR_ShortRetryCnt);
640 ts->ts_longretry = MS(ads->ds_status0, AR_LongRetryCnt);
641 ts->ts_virtcol = MS(ads->ds_status0, AR_VirtCollCnt);
642 ts->ts_antenna = 0; /* NB: don't know */
645 * NB: the number of retries is one less than it should be.
646 * Also, 0 retries and 1 retry are both reported as 0 retries.
648 if (ts->ts_shortretry > 0)
650 if (ts->ts_longretry > 0)
657 * Determine which tx queues need interrupt servicing.
661 ar5211GetTxIntrQueue(struct ath_hal *ah, uint32_t *txqs)