Merge branch 'master' into net80211-update
[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         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
376         qi = &ahp->ah_txq[q];
377         switch (qi->tqi_type) {
378         case HAL_TX_QUEUE_DATA:
379                 OS_REG_WRITE(ah, AR_CR, AR_CR_TXE0);
380                 break;
381         case HAL_TX_QUEUE_CAB:
382                 OS_REG_WRITE(ah, AR_CR, AR_CR_TXE1);    /* enable altq xmit */
383                 OS_REG_WRITE(ah, AR_BCR,
384                         AR_BCR_TQ1V | AR_BCR_BDMAE | AR_BCR_TQ1FV);
385                 break;
386         case HAL_TX_QUEUE_BEACON:
387                 /* XXX add CR_BCR_BCMD if IBSS mode */
388                 OS_REG_WRITE(ah, AR_BCR, AR_BCR_TQ1V | AR_BCR_BDMAE);
389                 break;
390         case HAL_TX_QUEUE_INACTIVE:
391                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
392                     __func__, q);
393                 /* fal thru... */
394         default:
395                 return AH_FALSE;
396         }
397         return AH_TRUE;
398 }
399
400 uint32_t
401 ar5210NumTxPending(struct ath_hal *ah, u_int q)
402 {
403         struct ath_hal_5210 *ahp = AH5210(ah);
404         HAL_TX_QUEUE_INFO *qi;
405         uint32_t v;
406
407         HALASSERT(q < HAL_NUM_TX_QUEUES);
408
409         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
410         qi = &ahp->ah_txq[q];
411         switch (qi->tqi_type) {
412         case HAL_TX_QUEUE_DATA:
413                 v = OS_REG_READ(ah, AR_CFG);
414                 return MS(v, AR_CFG_TXCNT);
415         case HAL_TX_QUEUE_INACTIVE:
416                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
417                     __func__, q);
418                 /* fall thru... */
419         default:
420                 break;
421         }
422         return 0;
423 }
424
425 /*
426  * Stop transmit on the specified queue
427  */
428 HAL_BOOL
429 ar5210StopTxDma(struct ath_hal *ah, u_int q)
430 {
431         struct ath_hal_5210 *ahp = AH5210(ah);
432         HAL_TX_QUEUE_INFO *qi;
433
434         HALASSERT(q < HAL_NUM_TX_QUEUES);
435
436         HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);
437         qi = &ahp->ah_txq[q];
438         switch (qi->tqi_type) {
439         case HAL_TX_QUEUE_DATA: {
440                 int i;
441                 OS_REG_WRITE(ah, AR_CR, AR_CR_TXD0);
442                 for (i = 0; i < 1000; i++) {
443                         if ((OS_REG_READ(ah, AR_CFG) & AR_CFG_TXCNT) == 0)
444                                 break;
445                         OS_DELAY(10);
446                 }
447                 OS_REG_WRITE(ah, AR_CR, 0);
448                 return (i < 1000);
449         }
450         case HAL_TX_QUEUE_BEACON:
451                 return ath_hal_wait(ah, AR_BSR, AR_BSR_TXQ1F, 0);
452         case HAL_TX_QUEUE_INACTIVE:
453                 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: inactive queue %u\n",
454                     __func__, q);
455                 /* fall thru... */
456         default:
457                 break;
458         }
459         return AH_FALSE;
460 }
461
462 /*
463  * Descriptor Access Functions
464  */
465
466 #define VALID_PKT_TYPES \
467         ((1<<HAL_PKT_TYPE_NORMAL)|(1<<HAL_PKT_TYPE_ATIM)|\
468          (1<<HAL_PKT_TYPE_PSPOLL)|(1<<HAL_PKT_TYPE_PROBE_RESP)|\
469          (1<<HAL_PKT_TYPE_BEACON))
470 #define isValidPktType(_t)      ((1<<(_t)) & VALID_PKT_TYPES)
471 #define VALID_TX_RATES \
472         ((1<<0x0b)|(1<<0x0f)|(1<<0x0a)|(1<<0x0e)|(1<<0x09)|(1<<0x0d)|\
473          (1<<0x08)|(1<<0x0c)|(1<<0x1b)|(1<<0x1a)|(1<<0x1e)|(1<<0x19)|\
474          (1<<0x1d)|(1<<0x18)|(1<<0x1c))
475 #define isValidTxRate(_r)       ((1<<(_r)) & VALID_TX_RATES)
476
477 HAL_BOOL
478 ar5210SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,
479         u_int pktLen,
480         u_int hdrLen,
481         HAL_PKT_TYPE type,
482         u_int txPower,
483         u_int txRate0, u_int txTries0,
484         u_int keyIx,
485         u_int antMode,
486         u_int flags,
487         u_int rtsctsRate,
488         u_int rtsctsDuration,
489         u_int compicvLen,
490         u_int compivLen,
491         u_int comp)
492 {
493         struct ar5210_desc *ads = AR5210DESC(ds);
494         uint32_t frtype;
495
496         (void) txPower;
497         (void) rtsctsDuration;
498
499         HALASSERT(txTries0 != 0);
500         HALASSERT(isValidPktType(type));
501         HALASSERT(isValidTxRate(txRate0));
502
503         if (type == HAL_PKT_TYPE_BEACON || type == HAL_PKT_TYPE_PROBE_RESP)
504                 frtype = AR_Frm_NoDelay;
505         else
506                 frtype = type << 26;
507         ads->ds_ctl0 = (pktLen & AR_FrameLen)
508                      | (txRate0 << AR_XmitRate_S)
509                      | ((hdrLen << AR_HdrLen_S) & AR_HdrLen)
510                      | frtype
511                      | (flags & HAL_TXDESC_CLRDMASK ? AR_ClearDestMask : 0)
512                      | (flags & HAL_TXDESC_INTREQ ? AR_TxInterReq : 0)
513                      | (antMode ? AR_AntModeXmit : 0)
514                      ;
515         if (keyIx != HAL_TXKEYIX_INVALID) {
516                 ads->ds_ctl1 = (keyIx << AR_EncryptKeyIdx_S) & AR_EncryptKeyIdx;
517                 ads->ds_ctl0 |= AR_EncryptKeyValid;
518         } else
519                 ads->ds_ctl1 = 0;
520         if (flags & HAL_TXDESC_RTSENA) {
521                 ads->ds_ctl0 |= AR_RTSCTSEnable;
522                 ads->ds_ctl1 |= rtsctsDuration & AR_RTSDuration;
523         }
524         return AH_TRUE;
525 }
526
527 HAL_BOOL
528 ar5210SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds,
529         u_int txRate1, u_int txTries1,
530         u_int txRate2, u_int txTries2,
531         u_int txRate3, u_int txTries3)
532 {
533         (void) ah; (void) ds;
534         (void) txRate1; (void) txTries1;
535         (void) txRate2; (void) txTries2;
536         (void) txRate3; (void) txTries3;
537         return AH_FALSE;
538 }
539
540 void
541 ar5210IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *ds)
542 {
543         struct ar5210_desc *ads = AR5210DESC(ds);
544
545         ads->ds_ctl0 |= AR_TxInterReq;
546 }
547
548 HAL_BOOL
549 ar5210FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,
550         u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
551         const struct ath_desc *ds0)
552 {
553         struct ar5210_desc *ads = AR5210DESC(ds);
554
555         HALASSERT((segLen &~ AR_BufLen) == 0);
556
557         if (firstSeg) {
558                 /*
559                  * First descriptor, don't clobber xmit control data
560                  * setup by ar5210SetupTxDesc.
561                  */
562                 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_More);
563         } else if (lastSeg) {           /* !firstSeg && lastSeg */
564                 /*
565                  * Last descriptor in a multi-descriptor frame,
566                  * copy the transmit parameters from the first
567                  * frame for processing on completion. 
568                  */
569                 ads->ds_ctl0 = AR5210DESC_CONST(ds0)->ds_ctl0;
570                 ads->ds_ctl1 = segLen;
571         } else {                        /* !firstSeg && !lastSeg */
572                 /*
573                  * Intermediate descriptor in a multi-descriptor frame.
574                  */
575                 ads->ds_ctl0 = 0;
576                 ads->ds_ctl1 = segLen | AR_More;
577         }
578         ads->ds_status0 = ads->ds_status1 = 0;
579         return AH_TRUE;
580 }
581
582 /*
583  * Processing of HW TX descriptor.
584  */
585 HAL_STATUS
586 ar5210ProcTxDesc(struct ath_hal *ah,
587         struct ath_desc *ds, struct ath_tx_status *ts)
588 {
589         struct ar5210_desc *ads = AR5210DESC(ds);
590
591         if ((ads->ds_status1 & AR_Done) == 0)
592                 return HAL_EINPROGRESS;
593
594         /* Update software copies of the HW status */
595         ts->ts_seqnum = ads->ds_status1 & AR_SeqNum;
596         ts->ts_tstamp = MS(ads->ds_status0, AR_SendTimestamp);
597         ts->ts_status = 0;
598         if ((ads->ds_status0 & AR_FrmXmitOK) == 0) {
599                 if (ads->ds_status0 & AR_ExcessiveRetries)
600                         ts->ts_status |= HAL_TXERR_XRETRY;
601                 if (ads->ds_status0 & AR_Filtered)
602                         ts->ts_status |= HAL_TXERR_FILT;
603                 if (ads->ds_status0  & AR_FIFOUnderrun)
604                         ts->ts_status |= HAL_TXERR_FIFO;
605         }
606         ts->ts_rate = MS(ads->ds_ctl0, AR_XmitRate);
607         ts->ts_rssi = MS(ads->ds_status1, AR_AckSigStrength);
608         ts->ts_shortretry = MS(ads->ds_status0, AR_ShortRetryCnt);
609         ts->ts_longretry = MS(ads->ds_status0, AR_LongRetryCnt);
610         ts->ts_antenna = 0;             /* NB: don't know */
611         ts->ts_finaltsi = 0;
612
613         return HAL_OK;
614 }
615
616 /*
617  * Determine which tx queues need interrupt servicing.
618  * STUB.
619  */
620 void
621 ar5210GetTxIntrQueue(struct ath_hal *ah, uint32_t *txqs)
622 {
623         return;
624 }