2 * SPDX-License-Identifier: ISC
4 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
5 * Copyright (c) 2002-2006 Atheros Communications, Inc.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #include "ah_internal.h"
27 #include "ar5211/ar5211.h"
28 #include "ar5211/ar5211reg.h"
29 #include "ar5211/ar5211desc.h"
32 * Update Tx FIFO trigger level.
34 * Set bIncTrigLevel to TRUE to increase the trigger level.
35 * Set bIncTrigLevel to FALSE to decrease the trigger level.
37 * Returns TRUE if the trigger level was updated
40 ar5211UpdateTxTrigLevel(struct ath_hal *ah, HAL_BOOL bIncTrigLevel)
42 uint32_t curTrigLevel, txcfg;
43 HAL_INT ints = ar5211GetInterrupts(ah);
46 * Disable chip interrupts. This is because halUpdateTxTrigLevel
47 * is called from both ISR and non-ISR contexts.
49 ar5211SetInterrupts(ah, ints &~ HAL_INT_GLOBAL);
50 txcfg = OS_REG_READ(ah, AR_TXCFG);
51 curTrigLevel = (txcfg & AR_TXCFG_FTRIG_M) >> AR_TXCFG_FTRIG_S;
53 /* increase the trigger level */
54 curTrigLevel = curTrigLevel +
55 ((MAX_TX_FIFO_THRESHOLD - curTrigLevel) / 2);
57 /* decrease the trigger level if not already at the minimum */
58 if (curTrigLevel > MIN_TX_FIFO_THRESHOLD) {
59 /* decrease the trigger level */
62 /* no update to the trigger level */
63 /* re-enable chip interrupts */
64 ar5211SetInterrupts(ah, ints);
68 /* Update the trigger level */
69 OS_REG_WRITE(ah, AR_TXCFG, (txcfg &~ AR_TXCFG_FTRIG_M) |
70 ((curTrigLevel << AR_TXCFG_FTRIG_S) & AR_TXCFG_FTRIG_M));
71 /* re-enable chip interrupts */
72 ar5211SetInterrupts(ah, ints);
77 * Set the properties of the tx queue with the parameters
78 * from qInfo. The queue must previously have been setup
79 * with a call to ar5211SetupTxQueue.
82 ar5211SetTxQueueProps(struct ath_hal *ah, int q, const HAL_TXQ_INFO *qInfo)
84 struct ath_hal_5211 *ahp = AH5211(ah);
86 if (q >= HAL_NUM_TX_QUEUES) {
87 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
91 return ath_hal_setTxQProps(ah, &ahp->ah_txq[q], qInfo);
95 * Return the properties for the specified tx queue.
98 ar5211GetTxQueueProps(struct ath_hal *ah, int q, HAL_TXQ_INFO *qInfo)
100 struct ath_hal_5211 *ahp = AH5211(ah);
102 if (q >= HAL_NUM_TX_QUEUES) {
103 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
107 return ath_hal_getTxQProps(ah, qInfo, &ahp->ah_txq[q]);
111 * Allocate and initialize a tx DCU/QCU combination.
114 ar5211SetupTxQueue(struct ath_hal *ah, HAL_TX_QUEUE type,
115 const HAL_TXQ_INFO *qInfo)
117 struct ath_hal_5211 *ahp = AH5211(ah);
118 HAL_TX_QUEUE_INFO *qi;
122 case HAL_TX_QUEUE_BEACON:
125 case HAL_TX_QUEUE_CAB:
128 case HAL_TX_QUEUE_DATA:
130 if (ahp->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE)
134 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad tx queue type %u\n",
139 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
141 qi = &ahp->ah_txq[q];
142 if (qi->tqi_type != HAL_TX_QUEUE_INACTIVE) {
143 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: tx queue %u already active\n",
147 OS_MEMZERO(qi, sizeof(HAL_TX_QUEUE_INFO));
149 if (qInfo == AH_NULL) {
150 /* by default enable OK+ERR+DESC+URN interrupts */
152 HAL_TXQ_TXOKINT_ENABLE
153 | HAL_TXQ_TXERRINT_ENABLE
154 | HAL_TXQ_TXDESCINT_ENABLE
155 | HAL_TXQ_TXURNINT_ENABLE
157 qi->tqi_aifs = INIT_AIFS;
158 qi->tqi_cwmin = HAL_TXQ_USEDEFAULT; /* NB: do at reset */
159 qi->tqi_cwmax = INIT_CWMAX;
160 qi->tqi_shretry = INIT_SH_RETRY;
161 qi->tqi_lgretry = INIT_LG_RETRY;
163 (void) ar5211SetTxQueueProps(ah, q, qInfo);
168 * Update the h/w interrupt registers to reflect a tx q's configuration.
171 setTxQInterrupts(struct ath_hal *ah, HAL_TX_QUEUE_INFO *qi)
173 struct ath_hal_5211 *ahp = AH5211(ah);
175 HALDEBUG(ah, HAL_DEBUG_TXQUEUE,
176 "%s: tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n", __func__
177 , ahp->ah_txOkInterruptMask
178 , ahp->ah_txErrInterruptMask
179 , ahp->ah_txDescInterruptMask
180 , ahp->ah_txEolInterruptMask
181 , ahp->ah_txUrnInterruptMask
184 OS_REG_WRITE(ah, AR_IMR_S0,
185 SM(ahp->ah_txOkInterruptMask, AR_IMR_S0_QCU_TXOK)
186 | SM(ahp->ah_txDescInterruptMask, AR_IMR_S0_QCU_TXDESC)
188 OS_REG_WRITE(ah, AR_IMR_S1,
189 SM(ahp->ah_txErrInterruptMask, AR_IMR_S1_QCU_TXERR)
190 | SM(ahp->ah_txEolInterruptMask, AR_IMR_S1_QCU_TXEOL)
192 OS_REG_RMW_FIELD(ah, AR_IMR_S2,
193 AR_IMR_S2_QCU_TXURN, ahp->ah_txUrnInterruptMask);
198 * Free a tx DCU/QCU combination.
201 ar5211ReleaseTxQueue(struct ath_hal *ah, u_int q)
203 struct ath_hal_5211 *ahp = AH5211(ah);
204 HAL_TX_QUEUE_INFO *qi;
206 if (q >= HAL_NUM_TX_QUEUES) {
207 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
211 qi = &ahp->ah_txq[q];
212 if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
213 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
218 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: release queue %u\n", __func__, q);
220 qi->tqi_type = HAL_TX_QUEUE_INACTIVE;
221 ahp->ah_txOkInterruptMask &= ~(1 << q);
222 ahp->ah_txErrInterruptMask &= ~(1 << q);
223 ahp->ah_txDescInterruptMask &= ~(1 << q);
224 ahp->ah_txEolInterruptMask &= ~(1 << q);
225 ahp->ah_txUrnInterruptMask &= ~(1 << q);
226 setTxQInterrupts(ah, qi);
232 * Set the retry, aifs, cwmin/max, readyTime regs for specified queue
235 ar5211ResetTxQueue(struct ath_hal *ah, u_int q)
237 struct ath_hal_5211 *ahp = AH5211(ah);
238 const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan;
239 HAL_TX_QUEUE_INFO *qi;
240 uint32_t cwMin, chanCwMin, value;
242 if (q >= HAL_NUM_TX_QUEUES) {
243 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
247 qi = &ahp->ah_txq[q];
248 if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
249 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
251 return AH_TRUE; /* XXX??? */
254 if (qi->tqi_cwmin == HAL_TXQ_USEDEFAULT) {
256 * Select cwmin according to channel type.
257 * NB: chan can be NULL during attach
259 if (chan && IEEE80211_IS_CHAN_B(chan))
260 chanCwMin = INIT_CWMIN_11B;
262 chanCwMin = INIT_CWMIN;
263 /* make sure that the CWmin is of the form (2^n - 1) */
264 for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1)
267 cwMin = qi->tqi_cwmin;
269 /* set cwMin/Max and AIFS values */
270 OS_REG_WRITE(ah, AR_DLCL_IFS(q),
271 SM(cwMin, AR_D_LCL_IFS_CWMIN)
272 | SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX)
273 | SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
275 /* Set retry limit values */
276 OS_REG_WRITE(ah, AR_DRETRY_LIMIT(q),
277 SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH)
278 | SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG)
279 | SM(qi->tqi_lgretry, AR_D_RETRY_LIMIT_FR_LG)
280 | SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH)
283 /* enable early termination on the QCU */
284 OS_REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
286 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU) {
287 /* Configure DCU to use the global sequence count */
288 OS_REG_WRITE(ah, AR_DMISC(q), AR5311_D_MISC_SEQ_NUM_CONTROL);
290 /* multiqueue support */
291 if (qi->tqi_cbrPeriod) {
292 OS_REG_WRITE(ah, AR_QCBRCFG(q),
293 SM(qi->tqi_cbrPeriod,AR_Q_CBRCFG_CBR_INTERVAL)
294 | SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_CBR_OVF_THRESH));
295 OS_REG_WRITE(ah, AR_QMISC(q),
296 OS_REG_READ(ah, AR_QMISC(q)) |
298 (qi->tqi_cbrOverflowLimit ?
299 AR_Q_MISC_CBR_EXP_CNTR_LIMIT : 0));
301 if (qi->tqi_readyTime) {
302 OS_REG_WRITE(ah, AR_QRDYTIMECFG(q),
303 SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_INT) |
306 if (qi->tqi_burstTime) {
307 OS_REG_WRITE(ah, AR_DCHNTIME(q),
308 SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
310 if (qi->tqi_qflags & HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE) {
311 OS_REG_WRITE(ah, AR_QMISC(q),
312 OS_REG_READ(ah, AR_QMISC(q)) |
313 AR_Q_MISC_RDYTIME_EXP_POLICY);
317 if (qi->tqi_qflags & HAL_TXQ_BACKOFF_DISABLE) {
318 OS_REG_WRITE(ah, AR_DMISC(q),
319 OS_REG_READ(ah, AR_DMISC(q)) |
320 AR_D_MISC_POST_FR_BKOFF_DIS);
322 if (qi->tqi_qflags & HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE) {
323 OS_REG_WRITE(ah, AR_DMISC(q),
324 OS_REG_READ(ah, AR_DMISC(q)) |
325 AR_D_MISC_FRAG_BKOFF_EN);
327 switch (qi->tqi_type) {
328 case HAL_TX_QUEUE_BEACON:
329 /* Configure QCU for beacons */
330 OS_REG_WRITE(ah, AR_QMISC(q),
331 OS_REG_READ(ah, AR_QMISC(q))
332 | AR_Q_MISC_FSP_DBA_GATED
333 | AR_Q_MISC_BEACON_USE
334 | AR_Q_MISC_CBR_INCR_DIS1);
335 /* Configure DCU for beacons */
336 value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
337 | AR_D_MISC_BEACON_USE | AR_D_MISC_POST_FR_BKOFF_DIS;
338 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)
339 value |= AR5311_D_MISC_SEQ_NUM_CONTROL;
340 OS_REG_WRITE(ah, AR_DMISC(q), value);
342 case HAL_TX_QUEUE_CAB:
343 /* Configure QCU for CAB (Crap After Beacon) frames */
344 OS_REG_WRITE(ah, AR_QMISC(q),
345 OS_REG_READ(ah, AR_QMISC(q))
346 | AR_Q_MISC_FSP_DBA_GATED | AR_Q_MISC_CBR_INCR_DIS1
347 | AR_Q_MISC_CBR_INCR_DIS0 | AR_Q_MISC_RDYTIME_EXP_POLICY);
349 value = (ahp->ah_beaconInterval
350 - (ah->ah_config.ah_sw_beacon_response_time
351 - ah->ah_config.ah_dma_beacon_response_time)
352 - ah->ah_config.ah_additional_swba_backoff) * 1024;
353 OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);
355 /* Configure DCU for CAB */
356 value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S);
357 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)
358 value |= AR5311_D_MISC_SEQ_NUM_CONTROL;
359 OS_REG_WRITE(ah, AR_QMISC(q), value);
362 /* NB: silence compiler */
367 * Always update the secondary interrupt mask registers - this
368 * could be a new queue getting enabled in a running system or
369 * hw getting re-initialized during a reset!
371 * Since we don't differentiate between tx interrupts corresponding
372 * to individual queues - secondary tx mask regs are always unmasked;
373 * tx interrupts are enabled/disabled for all queues collectively
374 * using the primary mask reg
376 if (qi->tqi_qflags & HAL_TXQ_TXOKINT_ENABLE)
377 ahp->ah_txOkInterruptMask |= 1 << q;
379 ahp->ah_txOkInterruptMask &= ~(1 << q);
380 if (qi->tqi_qflags & HAL_TXQ_TXERRINT_ENABLE)
381 ahp->ah_txErrInterruptMask |= 1 << q;
383 ahp->ah_txErrInterruptMask &= ~(1 << q);
384 if (qi->tqi_qflags & HAL_TXQ_TXDESCINT_ENABLE)
385 ahp->ah_txDescInterruptMask |= 1 << q;
387 ahp->ah_txDescInterruptMask &= ~(1 << q);
388 if (qi->tqi_qflags & HAL_TXQ_TXEOLINT_ENABLE)
389 ahp->ah_txEolInterruptMask |= 1 << q;
391 ahp->ah_txEolInterruptMask &= ~(1 << q);
392 if (qi->tqi_qflags & HAL_TXQ_TXURNINT_ENABLE)
393 ahp->ah_txUrnInterruptMask |= 1 << q;
395 ahp->ah_txUrnInterruptMask &= ~(1 << q);
396 setTxQInterrupts(ah, qi);
402 * Get the TXDP for the specified data queue.
405 ar5211GetTxDP(struct ath_hal *ah, u_int q)
407 HALASSERT(q < HAL_NUM_TX_QUEUES);
408 return OS_REG_READ(ah, AR_QTXDP(q));
412 * Set the TxDP for the specified tx queue.
415 ar5211SetTxDP(struct ath_hal *ah, u_int q, uint32_t txdp)
417 HALASSERT(q < HAL_NUM_TX_QUEUES);
418 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
421 * Make sure that TXE is deasserted before setting the TXDP. If TXE
422 * is still asserted, setting TXDP will have no effect.
424 HALASSERT((OS_REG_READ(ah, AR_Q_TXE) & (1 << q)) == 0);
426 OS_REG_WRITE(ah, AR_QTXDP(q), txdp);
432 * Set Transmit Enable bits for the specified queues.
435 ar5211StartTxDma(struct ath_hal *ah, u_int q)
437 HALASSERT(q < HAL_NUM_TX_QUEUES);
438 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
440 /* Check that queue is not already active */
441 HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1<<q)) == 0);
443 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
445 /* Check to be sure we're not enabling a q that has its TXD bit set. */
446 HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1 << q)) == 0);
448 OS_REG_WRITE(ah, AR_Q_TXE, 1 << q);
453 * Return the number of frames pending on the specified queue.
456 ar5211NumTxPending(struct ath_hal *ah, u_int q)
460 HALASSERT(q < HAL_NUM_TX_QUEUES);
461 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
463 n = OS_REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT_M;
465 * Pending frame count (PFC) can momentarily go to zero
466 * while TXE remains asserted. In other words a PFC of
467 * zero is not sufficient to say that the queue has stopped.
469 if (n == 0 && (OS_REG_READ(ah, AR_Q_TXE) & (1<<q)))
470 n = 1; /* arbitrarily pick 1 */
475 * Stop transmit on the specified queue
478 ar5211StopTxDma(struct ath_hal *ah, u_int q)
482 HALASSERT(q < HAL_NUM_TX_QUEUES);
483 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
485 OS_REG_WRITE(ah, AR_Q_TXD, 1<<q);
486 for (i = 0; i < 10000; i++) {
487 if (ar5211NumTxPending(ah, q) == 0)
491 OS_REG_WRITE(ah, AR_Q_TXD, 0);
497 * Descriptor Access Functions
500 #define VALID_PKT_TYPES \
501 ((1<<HAL_PKT_TYPE_NORMAL)|(1<<HAL_PKT_TYPE_ATIM)|\
502 (1<<HAL_PKT_TYPE_PSPOLL)|(1<<HAL_PKT_TYPE_PROBE_RESP)|\
503 (1<<HAL_PKT_TYPE_BEACON))
504 #define isValidPktType(_t) ((1<<(_t)) & VALID_PKT_TYPES)
505 #define VALID_TX_RATES \
506 ((1<<0x0b)|(1<<0x0f)|(1<<0x0a)|(1<<0x0e)|(1<<0x09)|(1<<0x0d)|\
507 (1<<0x08)|(1<<0x0c)|(1<<0x1b)|(1<<0x1a)|(1<<0x1e)|(1<<0x19)|\
508 (1<<0x1d)|(1<<0x18)|(1<<0x1c))
509 #define isValidTxRate(_r) ((1<<(_r)) & VALID_TX_RATES)
512 ar5211SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
517 u_int txRate0, u_int txTries0,
522 u_int rtsctsDuration,
527 struct ar5211_desc *ads = AR5211DESC(ds);
531 (void) rtsctsRate; (void) rtsctsDuration;
533 HALASSERT(txTries0 != 0);
534 HALASSERT(isValidPktType(type));
535 HALASSERT(isValidTxRate(txRate0));
536 /* XXX validate antMode */
538 ads->ds_ctl0 = (pktLen & AR_FrameLen)
539 | (txRate0 << AR_XmitRate_S)
540 | (antMode << AR_AntModeXmit_S)
541 | (flags & HAL_TXDESC_CLRDMASK ? AR_ClearDestMask : 0)
542 | (flags & HAL_TXDESC_INTREQ ? AR_TxInterReq : 0)
543 | (flags & HAL_TXDESC_RTSENA ? AR_RTSCTSEnable : 0)
544 | (flags & HAL_TXDESC_VEOL ? AR_VEOL : 0)
546 ads->ds_ctl1 = (type << 26)
547 | (flags & HAL_TXDESC_NOACK ? AR_NoAck : 0)
550 if (keyIx != HAL_TXKEYIX_INVALID) {
552 (keyIx << AR_EncryptKeyIdx_S) & AR_EncryptKeyIdx;
553 ads->ds_ctl0 |= AR_EncryptKeyValid;
560 ar5211SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds,
561 u_int txRate1, u_int txTries1,
562 u_int txRate2, u_int txTries2,
563 u_int txRate3, u_int txTries3)
565 (void) ah; (void) ds;
566 (void) txRate1; (void) txTries1;
567 (void) txRate2; (void) txTries2;
568 (void) txRate3; (void) txTries3;
573 ar5211IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *ds)
575 struct ar5211_desc *ads = AR5211DESC(ds);
577 ads->ds_ctl0 |= AR_TxInterReq;
581 ar5211FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
582 HAL_DMA_ADDR *bufAddrList, uint32_t *segLenList, u_int qcuId,
583 u_int descId, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
584 const struct ath_desc *ds0)
586 struct ar5211_desc *ads = AR5211DESC(ds);
587 uint32_t segLen = segLenList[0];
589 ds->ds_data = bufAddrList[0];
591 HALASSERT((segLen &~ AR_BufLen) == 0);
595 * First descriptor, don't clobber xmit control data
596 * setup by ar5211SetupTxDesc.
598 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_More);
599 } else if (lastSeg) { /* !firstSeg && lastSeg */
601 * Last descriptor in a multi-descriptor frame,
602 * copy the transmit parameters from the first
603 * frame for processing on completion.
605 ads->ds_ctl0 = AR5211DESC_CONST(ds0)->ds_ctl0;
606 ads->ds_ctl1 = segLen;
607 } else { /* !firstSeg && !lastSeg */
609 * Intermediate descriptor in a multi-descriptor frame.
612 ads->ds_ctl1 = segLen | AR_More;
614 ads->ds_status0 = ads->ds_status1 = 0;
619 * Processing of HW TX descriptor.
622 ar5211ProcTxDesc(struct ath_hal *ah,
623 struct ath_desc *ds, struct ath_tx_status *ts)
625 struct ar5211_desc *ads = AR5211DESC(ds);
627 if ((ads->ds_status1 & AR_Done) == 0)
628 return HAL_EINPROGRESS;
630 /* Update software copies of the HW status */
631 ts->ts_seqnum = MS(ads->ds_status1, AR_SeqNum);
632 ts->ts_tstamp = MS(ads->ds_status0, AR_SendTimestamp);
634 if ((ads->ds_status0 & AR_FrmXmitOK) == 0) {
635 if (ads->ds_status0 & AR_ExcessiveRetries)
636 ts->ts_status |= HAL_TXERR_XRETRY;
637 if (ads->ds_status0 & AR_Filtered)
638 ts->ts_status |= HAL_TXERR_FILT;
639 if (ads->ds_status0 & AR_FIFOUnderrun)
640 ts->ts_status |= HAL_TXERR_FIFO;
642 ts->ts_rate = MS(ads->ds_ctl0, AR_XmitRate);
643 ts->ts_rssi = MS(ads->ds_status1, AR_AckSigStrength);
644 ts->ts_shortretry = MS(ads->ds_status0, AR_ShortRetryCnt);
645 ts->ts_longretry = MS(ads->ds_status0, AR_LongRetryCnt);
646 ts->ts_virtcol = MS(ads->ds_status0, AR_VirtCollCnt);
647 ts->ts_antenna = 0; /* NB: don't know */
650 * NB: the number of retries is one less than it should be.
651 * Also, 0 retries and 1 retry are both reported as 0 retries.
653 if (ts->ts_shortretry > 0)
655 if (ts->ts_longretry > 0)
662 * Determine which tx queues need interrupt servicing.
666 ar5211GetTxIntrQueue(struct ath_hal *ah, uint32_t *txqs)
672 * Retrieve the rate table from the given TX completion descriptor
675 ar5211GetTxCompletionRates(struct ath_hal *ah, const struct ath_desc *ds0, int *rates, int *tries)
682 ar5211SetTxDescLink(struct ath_hal *ah, void *ds, uint32_t link)
684 struct ar5211_desc *ads = AR5211DESC(ds);
690 ar5211GetTxDescLink(struct ath_hal *ah, void *ds, uint32_t *link)
692 struct ar5211_desc *ads = AR5211DESC(ds);
694 *link = ads->ds_link;
698 ar5211GetTxDescLinkPtr(struct ath_hal *ah, void *ds, uint32_t **linkptr)
700 struct ar5211_desc *ads = AR5211DESC(ds);
702 *linkptr = &ads->ds_link;