Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / networks / atheros5000 / hal / ar5211 / ar5211_xmit.c
blobbc8cd825b7b4c7a6caded93633e27a4afa8bc3d5
1 /*
2 * Copyright (c) 2002-2008 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 * $Id$
19 #include "opt_ah.h"
21 #ifdef AH_SUPPORT_AR5211
23 #include "ah.h"
24 #include "ah_internal.h"
25 #include "ah_desc.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
39 HAL_BOOL
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;
52 if (bIncTrigLevel){
53 /* increase the trigger level */
54 curTrigLevel = curTrigLevel +
55 ((MAX_TX_FIFO_THRESHOLD - curTrigLevel) / 2);
56 } else {
57 /* decrease the trigger level if not already at the minimum */
58 if (curTrigLevel > MIN_TX_FIFO_THRESHOLD) {
59 /* decrease the trigger level */
60 curTrigLevel--;
61 } else {
62 /* no update to the trigger level */
63 /* re-enable chip interrupts */
64 ar5211SetInterrupts(ah, ints);
65 return AH_FALSE;
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);
73 return AH_TRUE;
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.
81 HAL_BOOL
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",
88 __func__, q);
89 return AH_FALSE;
91 return ath_hal_setTxQProps(ah, &ahp->ah_txq[q], qInfo);
95 * Return the properties for the specified tx queue.
97 HAL_BOOL
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",
104 __func__, q);
105 return AH_FALSE;
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;
119 int q;
121 switch (type) {
122 case HAL_TX_QUEUE_BEACON:
123 q = 9;
124 break;
125 case HAL_TX_QUEUE_CAB:
126 q = 8;
127 break;
128 case HAL_TX_QUEUE_DATA:
129 q = 0;
130 if (ahp->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE)
131 return q;
132 break;
133 default:
134 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad tx queue type %u\n",
135 __func__, type);
136 return -1;
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",
144 __func__, q);
145 return -1;
147 OS_MEMZERO(qi, sizeof(HAL_TX_QUEUE_INFO));
148 qi->tqi_type = type;
149 if (qInfo == AH_NULL) {
150 /* by default enable OK+ERR+DESC+URN interrupts */
151 qi->tqi_qflags =
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;
162 } else
163 (void) ar5211SetTxQueueProps(ah, q, qInfo);
164 return q;
168 * Update the h/w interrupt registers to reflect a tx q's configuration.
170 static void
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.
200 HAL_BOOL
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",
208 __func__, q);
209 return AH_FALSE;
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",
214 __func__, q);
215 return AH_FALSE;
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);
228 return AH_TRUE;
232 * Set the retry, aifs, cwmin/max, readyTime regs for specified queue
234 HAL_BOOL
235 ar5211ResetTxQueue(struct ath_hal *ah, u_int q)
237 struct ath_hal_5211 *ahp = AH5211(ah);
238 HAL_CHANNEL_INTERNAL *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",
244 __func__, q);
245 return AH_FALSE;
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",
250 __func__, q);
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 && IS_CHAN_B(chan))
260 chanCwMin = INIT_CWMIN_11B;
261 else
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)
266 } else
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)) |
297 AR_Q_MISC_FSP_CBR |
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) |
304 AR_Q_RDYTIMECFG_EN);
306 if (qi->tqi_burstTime) {
307 OS_REG_WRITE(ah, AR_DCHNTIME(q),
308 SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
309 AR_D_CHNTIME_EN);
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);
341 break;
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 - (ath_hal_sw_beacon_response_time - ath_hal_dma_beacon_response_time)
351 - ath_hal_additional_swba_backoff) * 1024;
352 OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);
354 /* Configure DCU for CAB */
355 value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S);
356 if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)
357 value |= AR5311_D_MISC_SEQ_NUM_CONTROL;
358 OS_REG_WRITE(ah, AR_QMISC(q), value);
359 break;
360 default:
361 /* NB: silence compiler */
362 break;
365 #ifndef AH_DISABLE_WME
367 * This is a really not the right way to do it, but
368 * it does get the lockout bits and backoff set for the
369 * high-pri WME queues for testing. We need to either extend
370 * the meaning of queueInfo->mode, or create something like
371 * queueInfo->dcumode.
373 if (qi->tqi_intFlags & HAL_TXQ_USE_LOCKOUT_BKOFF_DIS) {
374 OS_REG_WRITE(ah, AR_DMISC(q),
375 OS_REG_READ(ah, AR_DMISC(q)) |
376 SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
377 AR_D_MISC_ARB_LOCKOUT_CNTRL)|
378 AR_D_MISC_POST_FR_BKOFF_DIS);
380 #endif
383 * Always update the secondary interrupt mask registers - this
384 * could be a new queue getting enabled in a running system or
385 * hw getting re-initialized during a reset!
387 * Since we don't differentiate between tx interrupts corresponding
388 * to individual queues - secondary tx mask regs are always unmasked;
389 * tx interrupts are enabled/disabled for all queues collectively
390 * using the primary mask reg
392 if (qi->tqi_qflags & HAL_TXQ_TXOKINT_ENABLE)
393 ahp->ah_txOkInterruptMask |= 1 << q;
394 else
395 ahp->ah_txOkInterruptMask &= ~(1 << q);
396 if (qi->tqi_qflags & HAL_TXQ_TXERRINT_ENABLE)
397 ahp->ah_txErrInterruptMask |= 1 << q;
398 else
399 ahp->ah_txErrInterruptMask &= ~(1 << q);
400 if (qi->tqi_qflags & HAL_TXQ_TXDESCINT_ENABLE)
401 ahp->ah_txDescInterruptMask |= 1 << q;
402 else
403 ahp->ah_txDescInterruptMask &= ~(1 << q);
404 if (qi->tqi_qflags & HAL_TXQ_TXEOLINT_ENABLE)
405 ahp->ah_txEolInterruptMask |= 1 << q;
406 else
407 ahp->ah_txEolInterruptMask &= ~(1 << q);
408 if (qi->tqi_qflags & HAL_TXQ_TXURNINT_ENABLE)
409 ahp->ah_txUrnInterruptMask |= 1 << q;
410 else
411 ahp->ah_txUrnInterruptMask &= ~(1 << q);
412 setTxQInterrupts(ah, qi);
414 return AH_TRUE;
418 * Get the TXDP for the specified data queue.
420 uint32_t
421 ar5211GetTxDP(struct ath_hal *ah, u_int q)
423 HALASSERT(q < HAL_NUM_TX_QUEUES);
424 return OS_REG_READ(ah, AR_QTXDP(q));
428 * Set the TxDP for the specified tx queue.
430 HAL_BOOL
431 ar5211SetTxDP(struct ath_hal *ah, u_int q, uint32_t txdp)
433 HALASSERT(q < HAL_NUM_TX_QUEUES);
434 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
437 * Make sure that TXE is deasserted before setting the TXDP. If TXE
438 * is still asserted, setting TXDP will have no effect.
440 HALASSERT((OS_REG_READ(ah, AR_Q_TXE) & (1 << q)) == 0);
442 OS_REG_WRITE(ah, AR_QTXDP(q), txdp);
444 return AH_TRUE;
448 * Set Transmit Enable bits for the specified queues.
450 HAL_BOOL
451 ar5211StartTxDma(struct ath_hal *ah, u_int q)
453 HALASSERT(q < HAL_NUM_TX_QUEUES);
454 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
456 /* Check that queue is not already active */
457 HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1<<q)) == 0);
459 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
461 /* Check to be sure we're not enabling a q that has its TXD bit set. */
462 HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1 << q)) == 0);
464 OS_REG_WRITE(ah, AR_Q_TXE, 1 << q);
465 return AH_TRUE;
469 * Return the number of frames pending on the specified queue.
471 uint32_t
472 ar5211NumTxPending(struct ath_hal *ah, u_int q)
474 uint32_t n;
476 HALASSERT(q < HAL_NUM_TX_QUEUES);
477 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
479 n = OS_REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT_M;
481 * Pending frame count (PFC) can momentarily go to zero
482 * while TXE remains asserted. In other words a PFC of
483 * zero is not sufficient to say that the queue has stopped.
485 if (n == 0 && (OS_REG_READ(ah, AR_Q_TXE) & (1<<q)))
486 n = 1; /* arbitrarily pick 1 */
487 return n;
491 * Stop transmit on the specified queue
493 HAL_BOOL
494 ar5211StopTxDma(struct ath_hal *ah, u_int q)
496 int i;
498 HALASSERT(q < HAL_NUM_TX_QUEUES);
499 HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
501 OS_REG_WRITE(ah, AR_Q_TXD, 1<<q);
502 for (i = 0; i < 10000; i++) {
503 if (ar5211NumTxPending(ah, q) == 0)
504 break;
505 OS_DELAY(10);
507 OS_REG_WRITE(ah, AR_Q_TXD, 0);
509 return (i < 10000);
513 * Descriptor Access Functions
516 #define VALID_PKT_TYPES \
517 ((1<<HAL_PKT_TYPE_NORMAL)|(1<<HAL_PKT_TYPE_ATIM)|\
518 (1<<HAL_PKT_TYPE_PSPOLL)|(1<<HAL_PKT_TYPE_PROBE_RESP)|\
519 (1<<HAL_PKT_TYPE_BEACON))
520 #define isValidPktType(_t) ((1<<(_t)) & VALID_PKT_TYPES)
521 #define VALID_TX_RATES \
522 ((1<<0x0b)|(1<<0x0f)|(1<<0x0a)|(1<<0x0e)|(1<<0x09)|(1<<0x0d)|\
523 (1<<0x08)|(1<<0x0c)|(1<<0x1b)|(1<<0x1a)|(1<<0x1e)|(1<<0x19)|\
524 (1<<0x1d)|(1<<0x18)|(1<<0x1c))
525 #define isValidTxRate(_r) ((1<<(_r)) & VALID_TX_RATES)
527 HAL_BOOL
528 ar5211SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
529 u_int pktLen,
530 u_int hdrLen,
531 HAL_PKT_TYPE type,
532 u_int txPower,
533 u_int txRate0, u_int txTries0,
534 u_int keyIx,
535 u_int antMode,
536 u_int flags,
537 u_int rtsctsRate,
538 u_int rtsctsDuration,
539 u_int compicvLen,
540 u_int compivLen,
541 u_int comp)
543 struct ar5211_desc *ads = AR5211DESC(ds);
545 (void) hdrLen;
546 (void) txPower;
547 (void) rtsctsRate; (void) rtsctsDuration;
549 HALASSERT(txTries0 != 0);
550 HALASSERT(isValidPktType(type));
551 HALASSERT(isValidTxRate(txRate0));
552 /* XXX validate antMode */
554 ads->ds_ctl0 = (pktLen & AR_FrameLen)
555 | (txRate0 << AR_XmitRate_S)
556 | (antMode << AR_AntModeXmit_S)
557 | (flags & HAL_TXDESC_CLRDMASK ? AR_ClearDestMask : 0)
558 | (flags & HAL_TXDESC_INTREQ ? AR_TxInterReq : 0)
559 | (flags & HAL_TXDESC_RTSENA ? AR_RTSCTSEnable : 0)
560 | (flags & HAL_TXDESC_VEOL ? AR_VEOL : 0)
562 ads->ds_ctl1 = (type << 26)
563 | (flags & HAL_TXDESC_NOACK ? AR_NoAck : 0)
566 if (keyIx != HAL_TXKEYIX_INVALID) {
567 ads->ds_ctl1 |=
568 (keyIx << AR_EncryptKeyIdx_S) & AR_EncryptKeyIdx;
569 ads->ds_ctl0 |= AR_EncryptKeyValid;
571 return AH_TRUE;
572 #undef RATE
575 HAL_BOOL
576 ar5211SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds,
577 u_int txRate1, u_int txTries1,
578 u_int txRate2, u_int txTries2,
579 u_int txRate3, u_int txTries3)
581 (void) ah; (void) ds;
582 (void) txRate1; (void) txTries1;
583 (void) txRate2; (void) txTries2;
584 (void) txRate3; (void) txTries3;
585 return AH_FALSE;
588 void
589 ar5211IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *ds)
591 struct ar5211_desc *ads = AR5211DESC(ds);
593 ads->ds_ctl0 |= AR_TxInterReq;
596 HAL_BOOL
597 ar5211FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
598 u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
599 const struct ath_desc *ds0)
601 struct ar5211_desc *ads = AR5211DESC(ds);
603 HALASSERT((segLen &~ AR_BufLen) == 0);
605 if (firstSeg) {
607 * First descriptor, don't clobber xmit control data
608 * setup by ar5211SetupTxDesc.
610 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_More);
611 } else if (lastSeg) { /* !firstSeg && lastSeg */
613 * Last descriptor in a multi-descriptor frame,
614 * copy the transmit parameters from the first
615 * frame for processing on completion.
617 ads->ds_ctl0 = AR5211DESC_CONST(ds0)->ds_ctl0;
618 ads->ds_ctl1 = segLen;
619 } else { /* !firstSeg && !lastSeg */
621 * Intermediate descriptor in a multi-descriptor frame.
623 ads->ds_ctl0 = 0;
624 ads->ds_ctl1 = segLen | AR_More;
626 ads->ds_status0 = ads->ds_status1 = 0;
627 return AH_TRUE;
631 * Processing of HW TX descriptor.
633 HAL_STATUS
634 ar5211ProcTxDesc(struct ath_hal *ah,
635 struct ath_desc *ds, struct ath_tx_status *ts)
637 struct ar5211_desc *ads = AR5211DESC(ds);
639 if ((ads->ds_status1 & AR_Done) == 0)
640 return HAL_EINPROGRESS;
642 /* Update software copies of the HW status */
643 ts->ts_seqnum = MS(ads->ds_status1, AR_SeqNum);
644 ts->ts_tstamp = MS(ads->ds_status0, AR_SendTimestamp);
645 ts->ts_status = 0;
646 if ((ads->ds_status0 & AR_FrmXmitOK) == 0) {
647 if (ads->ds_status0 & AR_ExcessiveRetries)
648 ts->ts_status |= HAL_TXERR_XRETRY;
649 if (ads->ds_status0 & AR_Filtered)
650 ts->ts_status |= HAL_TXERR_FILT;
651 if (ads->ds_status0 & AR_FIFOUnderrun)
652 ts->ts_status |= HAL_TXERR_FIFO;
654 ts->ts_rate = MS(ads->ds_ctl0, AR_XmitRate);
655 ts->ts_rssi = MS(ads->ds_status1, AR_AckSigStrength);
656 ts->ts_shortretry = MS(ads->ds_status0, AR_ShortRetryCnt);
657 ts->ts_longretry = MS(ads->ds_status0, AR_LongRetryCnt);
658 ts->ts_virtcol = MS(ads->ds_status0, AR_VirtCollCnt);
659 ts->ts_antenna = 0; /* NB: don't know */
660 ts->ts_finaltsi = 0;
662 * NB: the number of retries is one less than it should be.
663 * Also, 0 retries and 1 retry are both reported as 0 retries.
665 if (ts->ts_shortretry > 0)
666 ts->ts_shortretry++;
667 if (ts->ts_longretry > 0)
668 ts->ts_longretry++;
670 return HAL_OK;
674 * Determine which tx queues need interrupt servicing.
675 * STUB.
677 void
678 ar5211GetTxIntrQueue(struct ath_hal *ah, uint32_t *txqs)
680 return;
682 #endif /* AH_SUPPORT_AR5211 */