Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / sys / dev / netif / ath / hal / ath_hal / ar5210 / ar5210_xmit.c
1 /*
2  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3  * Copyright (c) 2002-2004 Atheros Communications, Inc.
4  *
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.
8  *
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.
16  *
17  * $FreeBSD: head/sys/dev/ath/ath_hal/ar5210/ar5210_xmit.c 187831 2009-01-28 18:00:22Z sam $
18  * $DragonFly$
19  */
20 #include "opt_ah.h"
21
22 #include "ah.h"
23 #include "ah_internal.h"
24 #include "ah_desc.h"
25
26 #include "ar5210/ar5210.h"
27 #include "ar5210/ar5210reg.h"
28 #include "ar5210/ar5210phy.h"
29 #include "ar5210/ar5210desc.h"
30
31 /*
32  * Set the properties of the tx queue with the parameters
33  * from qInfo.  The queue must previously have been setup
34  * with a call to ar5210SetupTxQueue.
35  */
36 HAL_BOOL
37 ar5210SetTxQueueProps(struct ath_hal *ah, int q, const HAL_TXQ_INFO *qInfo)
38 {
39         struct ath_hal_5210 *ahp = AH5210(ah);
40
41         if (q >= HAL_NUM_TX_QUEUES) {
42                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
43                     __func__, q);
44                 return AH_FALSE;
45         }
46         return ath_hal_setTxQProps(ah, &ahp->ah_txq[q], qInfo);
47 }
48
49 /*
50  * Return the properties for the specified tx queue.
51  */
52 HAL_BOOL
53 ar5210GetTxQueueProps(struct ath_hal *ah, int q, HAL_TXQ_INFO *qInfo)
54 {
55         struct ath_hal_5210 *ahp = AH5210(ah);
56
57         if (q >= HAL_NUM_TX_QUEUES) {
58                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
59                     __func__, q);
60                 return AH_FALSE;
61         }
62         return ath_hal_getTxQProps(ah, qInfo, &ahp->ah_txq[q]);
63 }
64
65 /*
66  * Allocate and initialize a tx DCU/QCU combination.
67  */
68 int
69 ar5210SetupTxQueue(struct ath_hal *ah, HAL_TX_QUEUE type,
70         const HAL_TXQ_INFO *qInfo)
71 {
72         struct ath_hal_5210 *ahp = AH5210(ah);
73         HAL_TX_QUEUE_INFO *qi;
74         int q;
75
76         switch (type) {
77         case HAL_TX_QUEUE_BEACON:
78                 q = 2;
79                 break;
80         case HAL_TX_QUEUE_CAB:
81                 q = 1;
82                 break;
83         case HAL_TX_QUEUE_DATA:
84                 q = 0;
85                 break;
86         default:
87                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad tx queue type %u\n",
88                     __func__, type);
89                 return -1;
90         }
91
92         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
93
94         qi = &ahp->ah_txq[q];
95         if (qi->tqi_type != HAL_TX_QUEUE_INACTIVE) {
96                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: tx queue %u already active\n",
97                     __func__, q);
98                 return -1;
99         }
100         OS_MEMZERO(qi, sizeof(HAL_TX_QUEUE_INFO));
101         qi->tqi_type = type;
102         if (qInfo == AH_NULL) {
103                 /* by default enable OK+ERR+DESC+URN interrupts */
104                 qi->tqi_qflags =
105                           HAL_TXQ_TXOKINT_ENABLE
106                         | HAL_TXQ_TXERRINT_ENABLE
107                         | HAL_TXQ_TXDESCINT_ENABLE
108                         | HAL_TXQ_TXURNINT_ENABLE
109                         ;
110                 qi->tqi_aifs = INIT_AIFS;
111                 qi->tqi_cwmin = HAL_TXQ_USEDEFAULT;     /* NB: do at reset */
112                 qi->tqi_shretry = INIT_SH_RETRY;
113                 qi->tqi_lgretry = INIT_LG_RETRY;
114         } else
115                 (void) ar5210SetTxQueueProps(ah, q, qInfo);
116         /* NB: must be followed by ar5210ResetTxQueue */
117         return q;
118 }
119
120 /*
121  * Free a tx DCU/QCU combination.
122  */
123 HAL_BOOL
124 ar5210ReleaseTxQueue(struct ath_hal *ah, u_int q)
125 {
126         struct ath_hal_5210 *ahp = AH5210(ah);
127         HAL_TX_QUEUE_INFO *qi;
128
129         if (q >= HAL_NUM_TX_QUEUES) {
130                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
131                     __func__, q);
132                 return AH_FALSE;
133         }
134         qi = &ahp->ah_txq[q];
135         if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
136                 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
137                     __func__, q);
138                 return AH_FALSE;
139         }
140
141         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: release queue %u\n", __func__, q);
142
143         qi->tqi_type = HAL_TX_QUEUE_INACTIVE;
144         ahp->ah_txOkInterruptMask &= ~(1 << q);
145         ahp->ah_txErrInterruptMask &= ~(1 << q);
146         ahp->ah_txDescInterruptMask &= ~(1 << q);
147         ahp->ah_txEolInterruptMask &= ~(1 << q);
148         ahp->ah_txUrnInterruptMask &= ~(1 << q);
149
150         return AH_TRUE;
151 #undef N
152 }
153
154 HAL_BOOL
155 ar5210ResetTxQueue(struct ath_hal *ah, u_int q)
156 {
157         struct ath_hal_5210 *ahp = AH5210(ah);
158         const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan;
159         HAL_TX_QUEUE_INFO *qi;
160         uint32_t cwMin;
161
162         if (q >= HAL_NUM_TX_QUEUES) {
163                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",
164                     __func__, q);
165                 return AH_FALSE;
166         }
167         qi = &ahp->ah_txq[q];
168         if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
169                 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
170                     __func__, q);
171                 return AH_FALSE;
172         }
173
174         /*
175          * Ignore any non-data queue(s).
176          */
177         if (qi->tqi_type != HAL_TX_QUEUE_DATA)
178                 return AH_TRUE;
179
180         /* Set turbo mode / base mode parameters on or off */
181         if (IEEE80211_IS_CHAN_TURBO(chan)) {
182                 OS_REG_WRITE(ah, AR_SLOT_TIME, INIT_SLOT_TIME_TURBO);
183                 OS_REG_WRITE(ah, AR_TIME_OUT, INIT_ACK_CTS_TIMEOUT_TURBO);
184                 OS_REG_WRITE(ah, AR_USEC, INIT_TRANSMIT_LATENCY_TURBO);
185                 OS_REG_WRITE(ah, AR_IFS0, 
186                         ((INIT_SIFS_TURBO + qi->tqi_aifs * INIT_SLOT_TIME_TURBO)
187                                 << AR_IFS0_DIFS_S)
188                         | INIT_SIFS_TURBO);
189                 OS_REG_WRITE(ah, AR_IFS1, INIT_PROTO_TIME_CNTRL_TURBO);
190                 OS_REG_WRITE(ah, AR_PHY(17),
191                         (OS_REG_READ(ah, AR_PHY(17)) & ~0x7F) | 0x38);
192                 OS_REG_WRITE(ah, AR_PHY_FRCTL,
193                         AR_PHY_SERVICE_ERR | AR_PHY_TXURN_ERR |
194                         AR_PHY_ILLLEN_ERR | AR_PHY_ILLRATE_ERR |
195                         AR_PHY_PARITY_ERR | AR_PHY_TIMING_ERR |
196                         0x2020 |
197                         AR_PHY_TURBO_MODE | AR_PHY_TURBO_SHORT);
198         } else {
199                 OS_REG_WRITE(ah, AR_SLOT_TIME, INIT_SLOT_TIME);
200                 OS_REG_WRITE(ah, AR_TIME_OUT, INIT_ACK_CTS_TIMEOUT);
201                 OS_REG_WRITE(ah, AR_USEC, INIT_TRANSMIT_LATENCY);
202                 OS_REG_WRITE(ah, AR_IFS0, 
203                         ((INIT_SIFS + qi->tqi_aifs * INIT_SLOT_TIME)
204                                 << AR_IFS0_DIFS_S)
205                         | INIT_SIFS);
206                 OS_REG_WRITE(ah, AR_IFS1, INIT_PROTO_TIME_CNTRL);
207                 OS_REG_WRITE(ah, AR_PHY(17),
208                         (OS_REG_READ(ah, AR_PHY(17)) & ~0x7F) | 0x1C);
209                 OS_REG_WRITE(ah, AR_PHY_FRCTL,
210                         AR_PHY_SERVICE_ERR | AR_PHY_TXURN_ERR |
211                         AR_PHY_ILLLEN_ERR | AR_PHY_ILLRATE_ERR |
212                         AR_PHY_PARITY_ERR | AR_PHY_TIMING_ERR | 0x1020);
213         }
214
215         if (qi->tqi_cwmin == HAL_TXQ_USEDEFAULT)
216                 cwMin = INIT_CWMIN;
217         else
218                 cwMin = qi->tqi_cwmin;
219
220         /* Set cwmin and retry limit values */
221         OS_REG_WRITE(ah, AR_RETRY_LMT, 
222                   (cwMin << AR_RETRY_LMT_CW_MIN_S)
223                  | SM(INIT_SLG_RETRY, AR_RETRY_LMT_SLG_RETRY)
224                  | SM(INIT_SSH_RETRY, AR_RETRY_LMT_SSH_RETRY)
225                  | SM(qi->tqi_lgretry, AR_RETRY_LMT_LG_RETRY)
226                  | SM(qi->tqi_shretry, AR_RETRY_LMT_SH_RETRY)
227         );
228
229         if (qi->tqi_qflags & HAL_TXQ_TXOKINT_ENABLE)
230                 ahp->ah_txOkInterruptMask |= 1 << q;
231         else
232                 ahp->ah_txOkInterruptMask &= ~(1 << q);
233         if (qi->tqi_qflags & HAL_TXQ_TXERRINT_ENABLE)
234                 ahp->ah_txErrInterruptMask |= 1 << q;
235         else
236                 ahp->ah_txErrInterruptMask &= ~(1 << q);
237         if (qi->tqi_qflags & HAL_TXQ_TXDESCINT_ENABLE)
238                 ahp->ah_txDescInterruptMask |= 1 << q;
239         else
240                 ahp->ah_txDescInterruptMask &= ~(1 << q);
241         if (qi->tqi_qflags & HAL_TXQ_TXEOLINT_ENABLE)
242                 ahp->ah_txEolInterruptMask |= 1 << q;
243         else
244                 ahp->ah_txEolInterruptMask &= ~(1 << q);
245         if (qi->tqi_qflags & HAL_TXQ_TXURNINT_ENABLE)
246                 ahp->ah_txUrnInterruptMask |= 1 << q;
247         else
248                 ahp->ah_txUrnInterruptMask &= ~(1 << q);
249
250         return AH_TRUE;
251 }
252
253 /*
254  * Get the TXDP for the "main" data queue.  Needs to be extended
255  * for multiple Q functionality
256  */
257 uint32_t
258 ar5210GetTxDP(struct ath_hal *ah, u_int q)
259 {
260         struct ath_hal_5210 *ahp = AH5210(ah);
261         HAL_TX_QUEUE_INFO *qi;
262
263         HALASSERT(q < HAL_NUM_TX_QUEUES);
264
265         qi = &ahp->ah_txq[q];
266         switch (qi->tqi_type) {
267         case HAL_TX_QUEUE_DATA:
268                 return OS_REG_READ(ah, AR_TXDP0);
269         case HAL_TX_QUEUE_INACTIVE:
270                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
271                     __func__, q);
272                 /* fall thru... */
273         default:
274                 break;
275         }
276         return 0xffffffff;
277 }
278
279 /*
280  * Set the TxDP for the "main" data queue.
281  */
282 HAL_BOOL
283 ar5210SetTxDP(struct ath_hal *ah, u_int q, uint32_t txdp)
284 {
285         struct ath_hal_5210 *ahp = AH5210(ah);
286         HAL_TX_QUEUE_INFO *qi;
287
288         HALASSERT(q < HAL_NUM_TX_QUEUES);
289
290         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u 0x%x\n",
291             __func__, q, txdp);
292         qi = &ahp->ah_txq[q];
293         switch (qi->tqi_type) {
294         case HAL_TX_QUEUE_DATA:
295 #ifdef AH_DEBUG
296                 /*
297                  * Make sure that TXE is deasserted before setting the
298                  * TXDP.  If TXE is still asserted, setting TXDP will
299                  * have no effect.
300                  */
301                 if (OS_REG_READ(ah, AR_CR) & AR_CR_TXE0)
302                         ath_hal_printf(ah, "%s: TXE asserted; AR_CR=0x%x\n",
303                                 __func__, OS_REG_READ(ah, AR_CR));
304 #endif
305                 OS_REG_WRITE(ah, AR_TXDP0, txdp);
306                 break;
307         case HAL_TX_QUEUE_BEACON:
308         case HAL_TX_QUEUE_CAB:
309                 OS_REG_WRITE(ah, AR_TXDP1, txdp);
310                 break;
311         case HAL_TX_QUEUE_INACTIVE:
312                 HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",
313                     __func__, q);
314                 /* fall thru... */
315         default:
316                 return AH_FALSE;
317         }
318         return AH_TRUE;
319 }
320
321 /*
322  * Update Tx FIFO trigger level.
323  *
324  * Set bIncTrigLevel to TRUE to increase the trigger level.
325  * Set bIncTrigLevel to FALSE to decrease the trigger level.
326  *
327  * Returns TRUE if the trigger level was updated
328  */
329 HAL_BOOL
330 ar5210UpdateTxTrigLevel(struct ath_hal *ah, HAL_BOOL bIncTrigLevel)
331 {
332         uint32_t curTrigLevel;
333         HAL_INT ints = ar5210GetInterrupts(ah);
334
335         /*
336          * Disable chip interrupts. This is because halUpdateTxTrigLevel
337          * is called from both ISR and non-ISR contexts.
338          */
339         (void) ar5210SetInterrupts(ah, ints &~ HAL_INT_GLOBAL);
340         curTrigLevel = OS_REG_READ(ah, AR_TRIG_LEV);
341         if (bIncTrigLevel){
342                 /* increase the trigger level */
343                 curTrigLevel = curTrigLevel +
344                         ((MAX_TX_FIFO_THRESHOLD - curTrigLevel) / 2);
345         } else {
346                 /* decrease the trigger level if not already at the minimum */
347                 if (curTrigLevel > MIN_TX_FIFO_THRESHOLD) {
348                         /* decrease the trigger level */
349                         curTrigLevel--;
350                 } else {
351                         /* no update to the trigger level */
352                         /* re-enable chip interrupts */
353                         ar5210SetInterrupts(ah, ints);
354                         return AH_FALSE;
355                 }
356         }
357         /* Update the trigger level */
358         OS_REG_WRITE(ah, AR_TRIG_LEV, curTrigLevel);
359         /* re-enable chip interrupts */
360         ar5210SetInterrupts(ah, ints);
361         return AH_TRUE;
362 }
363
364 /*
365  * Set Transmit Enable bits for the specified queues.
366  */
367 HAL_BOOL
368 ar5210StartTxDma(struct ath_hal *ah, u_int q)
369 {
370         struct ath_hal_5210 *ahp = AH5210(ah);
371         HAL_TX_QUEUE_INFO *qi;
372
373         HALASSERT(q < HAL_NUM_TX_QUEUES);
374
375         cpu_sfence();
376         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
377         qi = &ahp->ah_txq[q];
378         switch (qi->tqi_type) {
379         case HAL_TX_QUEUE_DATA:
380                 OS_REG_WRITE(ah, AR_CR, AR_CR_TXE0);
381                 break;
382         case HAL_TX_QUEUE_CAB:
383                 OS_REG_WRITE(ah, AR_CR, AR_CR_TXE1);    /* enable altq xmit */
384                 OS_REG_WRITE(ah, AR_BCR,
385                         AR_BCR_TQ1V | AR_BCR_BDMAE | AR_BCR_TQ1FV);
386                 break;
387         case HAL_TX_QUEUE_BEACON:
388                 /* XXX add CR_BCR_BCMD if IBSS mode */
389                 OS_REG_WRITE(ah, AR_BCR, AR_BCR_TQ1V | AR_BCR_BDMAE);
390                 break;
391         case HAL_TX_QUEUE_INACTIVE:
392                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
393                     __func__, q);
394                 /* fal thru... */
395         default:
396                 return AH_FALSE;
397         }
398         return AH_TRUE;
399 }
400
401 uint32_t
402 ar5210NumTxPending(struct ath_hal *ah, u_int q)
403 {
404         struct ath_hal_5210 *ahp = AH5210(ah);
405         HAL_TX_QUEUE_INFO *qi;
406         uint32_t v;
407
408         HALASSERT(q < HAL_NUM_TX_QUEUES);
409
410         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
411         qi = &ahp->ah_txq[q];
412         switch (qi->tqi_type) {
413         case HAL_TX_QUEUE_DATA:
414                 v = OS_REG_READ(ah, AR_CFG);
415                 return MS(v, AR_CFG_TXCNT);
416         case HAL_TX_QUEUE_INACTIVE:
417                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
418                     __func__, q);
419                 /* fall thru... */
420         default:
421                 break;
422         }
423         return 0;
424 }
425
426 /*
427  * Stop transmit on the specified queue
428  */
429 HAL_BOOL
430 ar5210StopTxDma(struct ath_hal *ah, u_int q)
431 {
432         struct ath_hal_5210 *ahp = AH5210(ah);
433         HAL_TX_QUEUE_INFO *qi;
434
435         HALASSERT(q < HAL_NUM_TX_QUEUES);
436
437         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
438         qi = &ahp->ah_txq[q];
439         switch (qi->tqi_type) {
440         case HAL_TX_QUEUE_DATA: {
441                 int i;
442                 OS_REG_WRITE(ah, AR_CR, AR_CR_TXD0);
443                 for (i = 0; i < 1000; i++) {
444                         if ((OS_REG_READ(ah, AR_CFG) & AR_CFG_TXCNT) == 0)
445                                 break;
446                         OS_DELAY(10);
447                 }
448                 OS_REG_WRITE(ah, AR_CR, 0);
449                 return (i < 1000);
450         }
451         case HAL_TX_QUEUE_BEACON:
452                 return ath_hal_wait(ah, AR_BSR, AR_BSR_TXQ1F, 0);
453         case HAL_TX_QUEUE_INACTIVE:
454                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
455                     __func__, q);
456                 /* fall thru... */
457         default:
458                 break;
459         }
460         return AH_FALSE;
461 }
462
463 /*
464  * Descriptor Access Functions
465  */
466
467 #define VALID_PKT_TYPES \
468         ((1<<HAL_PKT_TYPE_NORMAL)|(1<<HAL_PKT_TYPE_ATIM)|\
469          (1<<HAL_PKT_TYPE_PSPOLL)|(1<<HAL_PKT_TYPE_PROBE_RESP)|\
470          (1<<HAL_PKT_TYPE_BEACON))
471 #define isValidPktType(_t)      ((1<<(_t)) & VALID_PKT_TYPES)
472 #define VALID_TX_RATES \
473         ((1<<0x0b)|(1<<0x0f)|(1<<0x0a)|(1<<0x0e)|(1<<0x09)|(1<<0x0d)|\
474          (1<<0x08)|(1<<0x0c)|(1<<0x1b)|(1<<0x1a)|(1<<0x1e)|(1<<0x19)|\
475          (1<<0x1d)|(1<<0x18)|(1<<0x1c))
476 #define isValidTxRate(_r)       ((1<<(_r)) & VALID_TX_RATES)
477
478 HAL_BOOL
479 ar5210SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
480         u_int pktLen,
481         u_int hdrLen,
482         HAL_PKT_TYPE type,
483         u_int txPower,
484         u_int txRate0, u_int txTries0,
485         u_int keyIx,
486         u_int antMode,
487         u_int flags,
488         u_int rtsctsRate,
489         u_int rtsctsDuration,
490         u_int compicvLen,
491         u_int compivLen,
492         u_int comp)
493 {
494         struct ar5210_desc *ads = AR5210DESC(ds);
495         uint32_t frtype;
496
497         (void) txPower;
498         (void) rtsctsDuration;
499
500         HALASSERT(txTries0 != 0);
501         HALASSERT(isValidPktType(type));
502         HALASSERT(isValidTxRate(txRate0));
503
504         if (type == HAL_PKT_TYPE_BEACON || type == HAL_PKT_TYPE_PROBE_RESP)
505                 frtype = AR_Frm_NoDelay;
506         else
507                 frtype = type << 26;
508         ads->ds_ctl0 = (pktLen & AR_FrameLen)
509                      | (txRate0 << AR_XmitRate_S)
510                      | ((hdrLen << AR_HdrLen_S) & AR_HdrLen)
511                      | frtype
512                      | (flags & HAL_TXDESC_CLRDMASK ? AR_ClearDestMask : 0)
513                      | (flags & HAL_TXDESC_INTREQ ? AR_TxInterReq : 0)
514                      | (antMode ? AR_AntModeXmit : 0)
515                      ;
516         if (keyIx != HAL_TXKEYIX_INVALID) {
517                 ads->ds_ctl1 = (keyIx << AR_EncryptKeyIdx_S) & AR_EncryptKeyIdx;
518                 ads->ds_ctl0 |= AR_EncryptKeyValid;
519         } else
520                 ads->ds_ctl1 = 0;
521         if (flags & HAL_TXDESC_RTSENA) {
522                 ads->ds_ctl0 |= AR_RTSCTSEnable;
523                 ads->ds_ctl1 |= rtsctsDuration & AR_RTSDuration;
524         }
525         return AH_TRUE;
526 }
527
528 HAL_BOOL
529 ar5210SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds,
530         u_int txRate1, u_int txTries1,
531         u_int txRate2, u_int txTries2,
532         u_int txRate3, u_int txTries3)
533 {
534         (void) ah; (void) ds;
535         (void) txRate1; (void) txTries1;
536         (void) txRate2; (void) txTries2;
537         (void) txRate3; (void) txTries3;
538         return AH_FALSE;
539 }
540
541 void
542 ar5210IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *ds)
543 {
544         struct ar5210_desc *ads = AR5210DESC(ds);
545
546         ads->ds_ctl0 |= AR_TxInterReq;
547 }
548
549 HAL_BOOL
550 ar5210FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
551         u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
552         const struct ath_desc *ds0)
553 {
554         struct ar5210_desc *ads = AR5210DESC(ds);
555
556         HALASSERT((segLen &~ AR_BufLen) == 0);
557
558         if (firstSeg) {
559                 /*
560                  * First descriptor, don't clobber xmit control data
561                  * setup by ar5210SetupTxDesc.
562                  */
563                 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_More);
564         } else if (lastSeg) {           /* !firstSeg && lastSeg */
565                 /*
566                  * Last descriptor in a multi-descriptor frame,
567                  * copy the transmit parameters from the first
568                  * frame for processing on completion. 
569                  */
570                 ads->ds_ctl0 = AR5210DESC_CONST(ds0)->ds_ctl0;
571                 ads->ds_ctl1 = segLen;
572         } else {                        /* !firstSeg && !lastSeg */
573                 /*
574                  * Intermediate descriptor in a multi-descriptor frame.
575                  */
576                 ads->ds_ctl0 = 0;
577                 ads->ds_ctl1 = segLen | AR_More;
578         }
579         ads->ds_status0 = ads->ds_status1 = 0;
580         return AH_TRUE;
581 }
582
583 /*
584  * Processing of HW TX descriptor.
585  */
586 HAL_STATUS
587 ar5210ProcTxDesc(struct ath_hal *ah,
588         struct ath_desc *ds, struct ath_tx_status *ts)
589 {
590         struct ar5210_desc *ads = AR5210DESC(ds);
591
592         if ((ads->ds_status1 & AR_Done) == 0)
593                 return HAL_EINPROGRESS;
594
595         /* Update software copies of the HW status */
596         ts->ts_seqnum = ads->ds_status1 & AR_SeqNum;
597         ts->ts_tstamp = MS(ads->ds_status0, AR_SendTimestamp);
598         ts->ts_status = 0;
599         if ((ads->ds_status0 & AR_FrmXmitOK) == 0) {
600                 if (ads->ds_status0 & AR_ExcessiveRetries)
601                         ts->ts_status |= HAL_TXERR_XRETRY;
602                 if (ads->ds_status0 & AR_Filtered)
603                         ts->ts_status |= HAL_TXERR_FILT;
604                 if (ads->ds_status0  & AR_FIFOUnderrun)
605                         ts->ts_status |= HAL_TXERR_FIFO;
606         }
607         ts->ts_rate = MS(ads->ds_ctl0, AR_XmitRate);
608         ts->ts_rssi = MS(ads->ds_status1, AR_AckSigStrength);
609         ts->ts_shortretry = MS(ads->ds_status0, AR_ShortRetryCnt);
610         ts->ts_longretry = MS(ads->ds_status0, AR_LongRetryCnt);
611         ts->ts_antenna = 0;             /* NB: don't know */
612         ts->ts_finaltsi = 0;
613
614         return HAL_OK;
615 }
616
617 /*
618  * Determine which tx queues need interrupt servicing.
619  * STUB.
620  */
621 void
622 ar5210GetTxIntrQueue(struct ath_hal *ah, uint32_t *txqs)
623 {
624         return;
625 }