remove ar5416StartPcuReceive
[open-ath9k-htc-firmware.git] / target_firmware / wlan / ar5416_hw.c
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 #include "ah.h"
37 #include "ah_internal.h"
38 #include "ar5416.h"
39 #include "ar5416reg.h"
40 #include "ar5416desc.h"
41
42 #define N(a) (sizeof(a)/sizeof(a[0]))
43 #define AR_INTR_SPURIOUS 0xffffffff
44 #define ar5416_desc ar5416_desc_20
45 #define AR5416_ABORT_LOOPS 1000
46 #define AR5416_ABORT_WAIT  5
47 #define AR5416DESC         AR5416DESC_20
48 #define AR5416DESC_CONST   AR5416DESC_CONST_20
49
50 /*****************/
51 /* Attach/Detach */
52 /*****************/
53
54 static const struct ath_hal_private ar5416hal_10 = {{
55                 .ah_getRateTable        = ar5416GetRateTable,
56                 .ah_detach              = ar5416Detach,
57
58                 /* Transmit functions */
59                 .ah_updateTxTrigLevel   = ar5416UpdateTxTrigLevel,
60                 .ah_setTxDP             = ar5416SetTxDP,
61                 .ah_numTxPending        = ar5416NumTxPending,    
62                 .ah_startTxDma          = ar5416StartTxDma,
63                 .ah_stopTxDma           = ar5416StopTxDma,
64
65                 .ah_abortTxDma          = ar5416AbortTxDma,
66
67                 /* Misc Functions */
68                 .ah_getTsf64            = ar5416GetTsf64,
69                 .ah_setRxFilter         = ar5416SetRxFilter,
70
71                 /* RX Functions */
72                 .ah_setRxDP             = ar5416SetRxDP,
73                 .ah_stopDmaReceive      = ar5416StopDmaReceive,
74                 .ah_enableReceive       = ar5416EnableReceive,
75                 .ah_stopPcuReceive      = ar5416StopPcuReceive,
76
77                 /* Interrupt Functions */
78                 .ah_isInterruptPending   = ar5416IsInterruptPending,
79                 .ah_getPendingInterrupts = ar5416GetPendingInterrupts,
80                 .ah_getInterrupts        = ar5416GetInterrupts,
81                 .ah_setInterrupts        = ar5416SetInterrupts,
82         },
83 };
84
85 void ar5416Detach(struct ath_hal *ah)
86 {
87         HALASSERT(ah != AH_NULL);
88         ath_hal_free(ah);
89 }
90
91 struct ath_hal *
92 ar5416Attach(a_uint32_t devid,HAL_SOFTC sc, adf_os_device_t dev,
93              a_uint32_t flags, HAL_STATUS *status)
94 {
95         struct ath_hal_5416 *ahp;
96         struct ath_hal *ah;
97
98         ahp = ath_hal_malloc(sizeof (struct ath_hal_5416));
99         if (ahp == AH_NULL) {
100                 *status = HAL_ENOMEM;
101                 return AH_NULL;
102         }
103         ah = &ahp->ah_priv.h;
104
105         OS_MEMCPY(&ahp->ah_priv, &ar5416hal_10, sizeof(struct ath_hal_private));
106
107         ah->ah_dev = dev;
108         ah->ah_sc = sc;
109         
110         /* If its a Owl 2.0 chip then change the hal structure to
111            point to the Owl 2.0 ar5416_hal_20 structure */
112         if(1) {
113                 ah->ah_set11nTxDesc        = ar5416Set11nTxDesc_20;
114                 ah->ah_set11nRateScenario  = ar5416Set11nRateScenario_20;
115                 ah->ah_set11nAggrFirst     = ar5416Set11nAggrFirst_20;
116                 ah->ah_set11nAggrMiddle    = ar5416Set11nAggrMiddle_20;
117                 ah->ah_set11nAggrLast      = ar5416Set11nAggrLast_20;
118                 ah->ah_clr11nAggr          = ar5416Clr11nAggr_20;
119                 ah->ah_set11nBurstDuration = ar5416Set11nBurstDuration_20;
120                 ah->ah_setupRxDesc         = ar5416SetupRxDesc_20;
121                 ah->ah_procRxDescFast      = ar5416ProcRxDescFast_20;
122                 ah->ah_updateCTSForBursting = NULL;
123                 ah->ah_setupTxDesc         = ar5416SetupTxDesc_20;
124                 ah->ah_reqTxIntrDesc       = ar5416IntrReqTxDesc_20;
125                 ah->ah_fillTxDesc          = ar5416FillTxDesc_20;
126                 ah->ah_fillKeyTxDesc       = ar5416FillKeyTxDesc_20;
127                 ah->ah_procTxDesc          = ar5416ProcTxDesc_20;
128                 ah->ah_set11nVirtualMoreFrag = ar5416Set11nVirtualMoreFrag_20;
129         }
130
131         return ah;
132 }
133
134 /**********************/
135 /* Interrupt Handling */
136 /**********************/
137
138 HAL_BOOL ar5416IsInterruptPending(struct ath_hal *ah)
139 {
140         a_uint32_t host_isr = OS_REG_READ(ah, AR_INTR_ASYNC_CAUSE);
141         /*
142          * Some platforms trigger our ISR before applying power to
143          * the card, so make sure.
144          */
145         return ((host_isr != AR_INTR_SPURIOUS) && (host_isr & AR_INTR_MAC_IRQ));
146 }
147
148 HAL_BOOL ar5416GetPendingInterrupts(struct ath_hal *ah, HAL_INT *masked)
149 {
150         a_uint32_t isr;
151 #ifndef AR9100
152         HAL_BOOL fatal_int = AH_FALSE;
153         a_uint32_t sync_cause;
154
155         if (OS_REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) {
156                 if ((OS_REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) != AR_RTC_STATUS_ON) {
157                         *masked = 0;
158                         return AH_FALSE;
159                 }
160         } else {
161                 *masked = 0;
162                 return AH_FALSE;
163         }
164 #endif
165         isr = OS_REG_READ(ah, AR_ISR_RAC);
166         if (isr == 0xffffffff) {
167                 *masked = 0;
168                 return AH_FALSE;
169         }
170
171         *masked = isr & HAL_INT_COMMON;
172
173 #ifdef AR5416_INT_MITIGATION
174         if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) {
175                 *masked |= HAL_INT_RX;
176         }
177         if (isr & (AR_ISR_TXMINTR | AR_ISR_TXINTM)) {
178                 *masked |= HAL_INT_TX;
179         }
180 #endif
181
182         if (isr & AR_ISR_BCNMISC) {
183                 a_uint32_t s2_s;
184
185                 s2_s = OS_REG_READ(ah, AR_ISR_S2_S);
186
187                 if (s2_s & AR_ISR_S2_GTT) {
188                         *masked |= HAL_INT_GTT;
189                 }
190
191                 if (s2_s & AR_ISR_S2_CST) {
192                         *masked |= HAL_INT_CST;
193                 }
194         }
195
196         if (isr & (AR_ISR_RXOK | AR_ISR_RXERR))
197                 *masked |= HAL_INT_RX;
198         if (isr & (AR_ISR_TXOK | AR_ISR_TXDESC | AR_ISR_TXERR | AR_ISR_TXEOL)) {
199                 struct ath_hal_5416 *ahp = AH5416(ah);
200                 a_uint32_t           s0_s, s1_s;
201
202                 *masked |= HAL_INT_TX;
203                 s0_s = OS_REG_READ(ah, AR_ISR_S0_S);
204                 s1_s = OS_REG_READ(ah, AR_ISR_S1_S);
205                 ahp->ah_intrTxqs |= MS(s0_s, AR_ISR_S0_QCU_TXOK);
206                 ahp->ah_intrTxqs |= MS(s0_s, AR_ISR_S0_QCU_TXDESC);
207                 ahp->ah_intrTxqs |= MS(s1_s, AR_ISR_S1_QCU_TXERR);
208                 ahp->ah_intrTxqs |= MS(s1_s, AR_ISR_S1_QCU_TXEOL);
209         }
210
211 #ifndef AR9100
212         sync_cause = OS_REG_READ(ah, AR_INTR_SYNC_CAUSE);
213         fatal_int = ((sync_cause != AR_INTR_SPURIOUS) &&
214                      (sync_cause & (AR_INTR_SYNC_HOST1_FATAL | AR_INTR_SYNC_HOST1_PERR))) ?
215                 AH_TRUE : AH_FALSE;
216
217         if (AH_TRUE == fatal_int) {
218                 OS_REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause);
219                 (void) OS_REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR);
220         }
221 #endif
222         return AH_TRUE;
223 }
224
225 HAL_INT ar5416GetInterrupts(struct ath_hal *ah)
226 {
227         return AH5416(ah)->ah_maskReg;
228 }
229
230 HAL_INT
231 ar5416SetInterrupts(struct ath_hal *ah, HAL_INT ints)
232 {
233         struct ath_hal_5416 *ahp = AH5416(ah);
234         a_uint32_t omask = ahp->ah_maskReg;
235         a_uint32_t mask;
236
237         if (omask & HAL_INT_GLOBAL) {
238                 OS_REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
239                 (void) OS_REG_READ(ah, AR_IER);
240         }
241
242         mask = ints & HAL_INT_COMMON;
243         if (ints & HAL_INT_TX) {
244 #ifdef AR5416_INT_MITIGATION
245                 mask |= AR_IMR_TXMINTR | AR_IMR_TXINTM;
246 #else
247                 mask |= AR_IMR_TXOK;
248                 mask |= AR_IMR_TXDESC;
249 #endif
250                 mask |= AR_IMR_TXERR;
251                 mask |= AR_IMR_TXEOL;
252         }
253         if (ints & HAL_INT_RX) {
254                 mask |= AR_IMR_RXERR;
255 #ifdef AR5416_INT_MITIGATION
256                 mask |=  AR_IMR_RXMINTR | AR_IMR_RXINTM;
257 #else
258                 mask |= AR_IMR_RXOK | AR_IMR_RXDESC;
259 #endif
260         }
261
262         if (ints & (HAL_INT_GTT | HAL_INT_CST)) {
263                 mask |= AR_IMR_BCNMISC;
264         }
265
266         OS_REG_WRITE(ah, AR_IMR, mask);
267         (void) OS_REG_READ(ah, AR_IMR);
268         ahp->ah_maskReg = ints;
269
270         /* Re-enable interrupts if they were enabled before. */
271         if (ints & HAL_INT_GLOBAL) {
272                 OS_REG_WRITE(ah, AR_IER, AR_IER_ENABLE);
273                 /* See explanation above... */
274                 (void) OS_REG_READ(ah, AR_IER);
275         }
276
277         OS_REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, AR_INTR_MAC_IRQ);
278         OS_REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ);
279         OS_REG_WRITE(ah, AR_INTR_SYNC_ENABLE, AR_INTR_SYNC_ALL);
280
281         return omask;
282 }
283
284 /****************/
285 /* TSF Handling */
286 /****************/
287
288 u_int64_t ar5416GetTsf64(struct ath_hal *ah)
289 {
290         u_int64_t tsf;
291
292         tsf = OS_REG_READ(ah, AR_TSF_U32);
293         tsf = (tsf << 32) | OS_REG_READ(ah, AR_TSF_L32);
294
295         return tsf;
296 }
297
298 /******/
299 /* RX */
300 /******/
301 void ar5416SetRxDP(struct ath_hal *ah, a_uint32_t rxdp)
302 {
303         OS_REG_WRITE(ah, AR_RXDP, rxdp);
304         HALASSERT(OS_REG_READ(ah, AR_RXDP) == rxdp);
305 }
306
307 void ar5416SetMulticastFilter(struct ath_hal *ah, a_uint32_t filter0, a_uint32_t filter1)
308 {
309         OS_REG_WRITE(ah, AR_MCAST_FIL0, filter0);
310         OS_REG_WRITE(ah, AR_MCAST_FIL1, filter1);
311 }
312
313 HAL_BOOL ar5416ClrMulticastFilterIndex(struct ath_hal *ah, a_uint32_t ix)
314 {
315         a_uint32_t val;
316
317         if (ix >= 64)
318                 return AH_FALSE;
319         if (ix >= 32) {
320                 val = OS_REG_READ(ah, AR_MCAST_FIL1);
321                 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val &~ (1<<(ix-32))));
322         } else {
323                 val = OS_REG_READ(ah, AR_MCAST_FIL0);
324                 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val &~ (1<<ix)));
325         }
326         return AH_TRUE;
327 }
328
329 HAL_BOOL ar5416StopDmaReceive(struct ath_hal *ah)
330 {
331         OS_REG_WRITE(ah, AR_CR, AR_CR_RXD); /* Set receive disable bit */
332         if (!ath_hal_wait(ah, AR_CR, AR_CR_RXE, 0)) {
333                 return AH_FALSE;
334         } else {
335                 return AH_TRUE;
336         }
337 }
338
339 HAL_BOOL ar5416SetMulticastFilterIndex(struct ath_hal *ah, a_uint32_t ix)
340 {
341         a_uint32_t val;
342
343         if (ix >= 64)
344                 return AH_FALSE;
345         if (ix >= 32) {
346                 val = OS_REG_READ(ah, AR_MCAST_FIL1);
347                 OS_REG_WRITE(ah, AR_MCAST_FIL1, (val | (1<<(ix-32))));
348         } else {
349                 val = OS_REG_READ(ah, AR_MCAST_FIL0);
350                 OS_REG_WRITE(ah, AR_MCAST_FIL0, (val | (1<<ix)));
351         }
352         return AH_TRUE;
353 }
354
355 void ar5416SetRxFilter(struct ath_hal *ah, a_uint32_t bits)
356 {
357         a_uint32_t phybits;
358     
359         OS_REG_WRITE(ah, AR_RX_FILTER, (bits & 0xff) | AR_RX_COMPR_BAR);
360         phybits = 0;
361         if (bits & HAL_RX_FILTER_PHYRADAR)
362                 phybits |= AR_PHY_ERR_RADAR;
363         if (bits & HAL_RX_FILTER_PHYERR)
364                 phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
365         OS_REG_WRITE(ah, AR_PHY_ERR, phybits);
366         if (phybits) {
367                 OS_REG_WRITE(ah, AR_RXCFG,OS_REG_READ(ah, AR_RXCFG) | AR_RXCFG_ZLFDMA);
368         } else {
369                 OS_REG_WRITE(ah, AR_RXCFG,OS_REG_READ(ah, AR_RXCFG) &~ AR_RXCFG_ZLFDMA);
370         }
371 }
372
373 void ar5416EnableReceive(struct ath_hal *ah)
374 {
375         OS_REG_WRITE(ah, AR_CR, AR_CR_RXE);
376 }
377
378 void ar5416StopPcuReceive(struct ath_hal *ah)
379 {
380         OS_REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
381 }
382
383 HAL_BOOL ar5416SetupRxDesc_20(struct ath_hal *ah, struct ath_rx_desc *ds,
384                               a_uint32_t size, a_uint32_t flags)
385 {
386         struct ar5416_desc *ads = AR5416DESC(ds);
387
388         HALASSERT((size &~ AR_BufLen) == 0);
389
390         ads->ds_ctl1 = size & AR_BufLen;
391         if (flags & HAL_RXDESC_INTREQ)
392                 ads->ds_ctl1 |= AR_RxIntrReq;
393
394         /* this should be enough */
395         ads->ds_rxstatus8 &= ~AR_RxDone;
396
397         return AH_TRUE;
398 }
399
400 HAL_STATUS ar5416ProcRxDescFast_20(struct ath_hal *ah, struct ath_rx_desc *ds,
401                                    a_uint32_t pa, struct ath_desc *nds,
402                                    struct ath_rx_status *rx_stats)
403 {
404         struct ar5416_desc ads;
405         struct ar5416_desc *adsp = AR5416DESC(ds);
406         struct ar5416_desc *ands = AR5416DESC(nds);
407
408         if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
409                 return HAL_EINPROGRESS;
410         /*
411          * Given the use of a self-linked tail be very sure that the hw is
412          * done with this descriptor; the hw may have done this descriptor
413          * once and picked it up again...make sure the hw has moved on.
414          */
415         if ((ands->ds_rxstatus8 & AR_RxDone) == 0
416             && OS_REG_READ(ah, AR_RXDP) == pa)
417                 return HAL_EINPROGRESS;
418
419         /*
420          * Now we need to get the stats from the descriptor. Since desc are 
421          * uncached, lets make a copy of the stats first. Note that, since we
422          * touch most of the rx stats, a memcpy would always be more efficient
423          *
424          * Next we fill in all values in a caller passed stack variable.
425          * This reduces the number of uncached accesses.
426          * Do this copy here, after the check so that when the checks fail, we
427          * dont end up copying the entire stats uselessly.
428          */
429         ads.u.rx = adsp->u.rx;
430
431         rx_stats->rs_status = 0;
432         rx_stats->rs_flags = 0;
433
434         rx_stats->rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
435         rx_stats->rs_tstamp =  ads.AR_RcvTimestamp;
436
437         /* XXX what about KeyCacheMiss? */
438         rx_stats->rs_rssi_combined = 
439                 MS(ads.ds_rxstatus4, AR_RxRSSICombined);
440         rx_stats->rs_rssi_ctl0 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt00);
441         rx_stats->rs_rssi_ctl1 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt01);
442         rx_stats->rs_rssi_ctl2 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt02);
443         rx_stats->rs_rssi_ext0 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt10);
444         rx_stats->rs_rssi_ext1 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt11);
445         rx_stats->rs_rssi_ext2 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt12);
446         if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
447                 rx_stats->rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
448         else
449                 rx_stats->rs_keyix = HAL_RXKEYIX_INVALID;
450         /* NB: caller expected to do rate table mapping */
451         rx_stats->rs_rate = RXSTATUS_RATE(ah, (&ads));
452         rx_stats->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
453
454         rx_stats->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
455         rx_stats->rs_moreaggr = (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
456         rx_stats->rs_flags  |= (ads.ds_rxstatus3 & AR_GI) ? HAL_RX_GI : 0;
457         rx_stats->rs_flags  |= (ads.ds_rxstatus3 & AR_2040) ? HAL_RX_2040 : 0;
458
459         if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
460                 rx_stats->rs_flags |= HAL_RX_DELIM_CRC_PRE;
461         if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
462                 rx_stats->rs_flags |= HAL_RX_DELIM_CRC_POST;
463         if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
464                 rx_stats->rs_flags |= HAL_RX_DECRYPT_BUSY;
465
466         if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
467                 /*
468                  * These four bits should not be set together.  The
469                  * 5416 spec states a Michael error can only occur if
470                  * DecryptCRCErr not set (and TKIP is used).  Experience
471                  * indicates however that you can also get Michael errors
472                  * when a CRC error is detected, but these are specious.
473                  * Consequently we filter them out here so we don't
474                  * confuse and/or complicate drivers.
475                  */
476                 if (ads.ds_rxstatus8 & AR_CRCErr)
477                         rx_stats->rs_status |= HAL_RXERR_CRC;
478                 else if (ads.ds_rxstatus8 & AR_PHYErr) {
479                         a_uint32_t phyerr;
480
481                         rx_stats->rs_status |= HAL_RXERR_PHY;
482                         phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
483                         rx_stats->rs_phyerr = phyerr;
484                 } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
485                         rx_stats->rs_status |= HAL_RXERR_DECRYPT;
486                 else if (ads.ds_rxstatus8 & AR_MichaelErr)
487                         rx_stats->rs_status |= HAL_RXERR_MIC;
488         }
489         rx_stats->evm0=ads.AR_RxEVM0;
490         rx_stats->evm1=ads.AR_RxEVM1;
491         rx_stats->evm2=ads.AR_RxEVM2;
492
493         return HAL_OK;
494 }
495
496 /******/
497 /* TX */
498 /******/
499
500 HAL_BOOL ar5416UpdateTxTrigLevel(struct ath_hal *ah, HAL_BOOL bIncTrigLevel)
501 {
502         struct ath_hal_5416 *ahp = AH5416(ah);
503         a_uint32_t txcfg, curLevel, newLevel;
504         HAL_INT omask;
505
506         /*
507          * Disable interrupts while futzing with the fifo level.
508          */
509         omask = ar5416SetInterrupts(ah, ahp->ah_maskReg &~ HAL_INT_GLOBAL);
510
511         txcfg = OS_REG_READ(ah, AR_TXCFG);
512         curLevel = MS(txcfg, AR_FTRIG);
513         newLevel = curLevel;
514
515         if (bIncTrigLevel)  {
516                 if (curLevel < MAX_TX_FIFO_THRESHOLD)
517                         newLevel ++;
518         } else if (curLevel > MIN_TX_FIFO_THRESHOLD)
519                 newLevel--;
520         if (newLevel != curLevel)
521                 OS_REG_WRITE(ah, AR_TXCFG,
522                              (txcfg &~ AR_FTRIG) | SM(newLevel, AR_FTRIG));
523
524         /* re-enable chip interrupts */
525         ar5416SetInterrupts(ah, omask);
526
527         return (newLevel != curLevel);
528 }
529
530 HAL_BOOL ar5416SetTxDP(struct ath_hal *ah, a_uint32_t q, a_uint32_t txdp)
531 {
532         HALASSERT(q < AH_PRIVATE(ah)->ah_caps.halTotalQueues);
533         HALASSERT(AH5416(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
534
535         /*
536          * Make sure that TXE is deasserted before setting the TXDP.  If TXE
537          * is still asserted, setting TXDP will have no effect.
538          */
539         HALASSERT((OS_REG_READ(ah, AR_Q_TXE) & (1 << q)) == 0);
540
541         OS_REG_WRITE(ah, AR_QTXDP(q), txdp);
542
543         return AH_TRUE;
544 }
545
546 HAL_BOOL ar5416StartTxDma(struct ath_hal *ah, a_uint32_t q)
547 {
548         HALASSERT(q < AH_PRIVATE(ah)->ah_caps.halTotalQueues);
549         HALASSERT(AH5416(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
550
551         /* Check to be sure we're not enabling a q that has its TXD bit set. */
552         HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1 << q)) == 0);
553
554         OS_REG_WRITE(ah, AR_Q_TXE, 1 << q);
555
556         return AH_TRUE;
557 }
558
559 a_uint32_t ar5416NumTxPending(struct ath_hal *ah, a_uint32_t q)
560 {
561         a_uint32_t npend;
562
563         HALASSERT(q < AH_PRIVATE(ah)->ah_caps.halTotalQueues);
564         HALASSERT(AH5416(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
565
566         npend = OS_REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT;
567         if (npend == 0) {
568                 /*
569                  * Pending frame count (PFC) can momentarily go to zero
570                  * while TXE remains asserted.  In other words a PFC of
571                  * zero is not sufficient to say that the queue has stopped.
572                  */
573                 if (OS_REG_READ(ah, AR_Q_TXE) & (1 << q))
574                         npend = 1;
575         }
576 #ifdef DEBUG
577         if (npend && (AH5416(ah)->ah_txq[q].tqi_type == HAL_TX_QUEUE_CAB)) {
578                 if (OS_REG_READ(ah, AR_Q_RDYTIMESHDN) & (1 << q)) {
579                         isrPrintf("RTSD on CAB queue\n");
580                         /* Clear the ReadyTime shutdown status bits */
581                         OS_REG_WRITE(ah, AR_Q_RDYTIMESHDN, 1 << q);
582                 }
583         }
584 #endif
585         return npend;
586 }
587
588 HAL_BOOL ar5416AbortTxDma(struct ath_hal *ah)
589 {
590         a_int32_t i, q;
591
592         /*
593          * set txd on all queues
594          */
595         OS_REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
596
597         /*
598          * set tx abort bits
599          */
600         OS_REG_SET_BIT(ah, AR_PCU_MISC, (AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF));
601         OS_REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
602         OS_REG_SET_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
603
604         /*
605          * wait on all tx queues
606          */
607         for (q = 0; q < AR_NUM_QCU; q++) {
608                 for (i = 0; i < AR5416_ABORT_LOOPS; i++) {
609                         if (!ar5416NumTxPending(ah, q))
610                                 break;
611
612                         OS_DELAY(AR5416_ABORT_WAIT);
613                 }
614                 if (i == AR5416_ABORT_LOOPS) {
615                         return AH_FALSE;
616                 }
617         }
618
619         /*
620          * clear tx abort bits
621          */
622         OS_REG_CLR_BIT(ah, AR_PCU_MISC, (AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF));
623         OS_REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
624         OS_REG_CLR_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
625
626         /*
627          * clear txd
628          */
629         OS_REG_WRITE(ah, AR_Q_TXD, 0);
630
631         return AH_TRUE;
632 }
633
634 HAL_BOOL ar5416StopTxDma(struct ath_hal*ah, a_uint32_t q)
635 {
636         a_uint32_t i;
637         
638         HALASSERT(q < AH_PRIVATE(ah)->ah_caps.halTotalQueues);
639
640         HALASSERT(AH5416(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);
641
642         OS_REG_WRITE(ah, AR_Q_TXD, 1 << q);
643         for (i = 1000; i != 0; i--) {
644                 if (ar5416NumTxPending(ah, q) == 0)
645                         break;
646                 OS_DELAY(100);        /* XXX get actual value */
647         }
648
649         OS_REG_WRITE(ah, AR_Q_TXD, 0);
650         return (i != 0);
651 }
652
653 void ar5416IntrReqTxDesc_20(struct ath_hal *ah, struct ath_desc *ds)
654 {
655         struct ar5416_desc *ads = AR5416DESC(ds);
656         ads->ds_ctl0 |= AR_TxIntrReq;
657 }
658
659 HAL_BOOL ar5416SetupTxDesc_20(struct ath_hal *ah, struct ath_tx_desc *ds,
660                               a_uint32_t pktLen,
661                               a_uint32_t hdrLen,
662                               HAL_PKT_TYPE type,
663                               a_uint32_t txPower,
664                               a_uint32_t txRate0, a_uint32_t txTries0,
665                               a_uint32_t keyIx,
666                               a_uint32_t antMode,
667                               a_uint32_t flags,
668                               a_uint32_t rtsctsRate,
669                               a_uint32_t rtsctsDuration,
670                               a_uint32_t compicvLen,
671                               a_uint32_t compivLen,
672                               a_uint32_t comp)
673 {
674 #define RTSCTS  (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)
675
676         struct ar5416_desc *ads = AR5416DESC(ds);
677
678         (void) hdrLen;
679
680         ads->ds_txstatus9 &= ~AR_TxDone;
681
682         HALASSERT(txTries0 != 0);
683         HALASSERT(isValidPktType(type));
684         HALASSERT(isValidTxRate(txRate0));
685         HALASSERT((flags & RTSCTS) != RTSCTS);
686
687         if (txPower > 63)
688                 txPower=63;
689
690         ads->ds_ctl0 = (pktLen & AR_FrameLen)
691                 | (txPower << AR_XmitPower_S)
692                 | (flags & HAL_TXDESC_VEOL ? AR_VEOL : 0)
693                 | (flags & HAL_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
694                 | (flags & HAL_TXDESC_INTREQ ? AR_TxIntrReq : 0);
695
696         ads->ds_ctl1 = (type << AR_FrameType_S)
697                 | (flags & HAL_TXDESC_NOACK ? AR_NoAck : 0);
698         ads->ds_ctl2 = SM(txTries0, AR_XmitDataTries0);
699         ads->ds_ctl3 = (txRate0 << AR_XmitRate0_S);
700
701         ads->ds_ctl7 = SM(AR5416_LEGACY_CHAINMASK, AR_ChainSel0) 
702                 | SM(AR5416_LEGACY_CHAINMASK, AR_ChainSel1)
703                 | SM(AR5416_LEGACY_CHAINMASK, AR_ChainSel2) 
704                 | SM(AR5416_LEGACY_CHAINMASK, AR_ChainSel3);
705
706         if (keyIx != HAL_TXKEYIX_INVALID) {
707                 /* XXX validate key index */
708                 ads->ds_ctl1 |= SM(keyIx, AR_DestIdx);
709                 ads->ds_ctl0 |= AR_DestIdxValid;
710         }
711
712         if (flags & RTSCTS) {
713                 if (!isValidTxRate(rtsctsRate)) {
714                         return AH_FALSE;
715                 }
716                 /* XXX validate rtsctsDuration */
717                 ads->ds_ctl0 |= (flags & HAL_TXDESC_CTSENA ? AR_CTSEnable : 0)
718                         | (flags & HAL_TXDESC_RTSENA ? AR_RTSEnable : 0);
719                 ads->ds_ctl2 |= SM(rtsctsDuration, AR_BurstDur);
720                 ads->ds_ctl3 |= (rtsctsRate << AR_RTSCTSRate_S);
721         }
722         return AH_TRUE;
723
724 #undef RTSCTS
725 }
726
727 HAL_BOOL ar5416FillTxDesc_20(struct ath_hal *ah, struct ath_tx_desc *ds,
728                              a_uint32_t segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg,
729                              const struct ath_tx_desc *ds0)
730 {
731         struct ar5416_desc *ads = AR5416DESC(ds);
732
733         HALASSERT((segLen &~ AR_BufLen) == 0);
734
735         if (firstSeg) {
736                 /*
737                  * First descriptor, don't clobber xmit control data
738                  * setup by ar5416SetupTxDesc.
739                  */
740                 ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_TxMore);
741         } else if (lastSeg) {
742                 /*
743                  * Last descriptor in a multi-descriptor frame,
744                  * copy the multi-rate transmit parameters from
745                  * the first frame for processing on completion.
746                  */
747                 ads->ds_ctl0 = 0;
748                 ads->ds_ctl1 = segLen;
749                 ads->ds_ctl2 = AR5416DESC_CONST(ds0)->ds_ctl2;
750                 ads->ds_ctl3 = AR5416DESC_CONST(ds0)->ds_ctl3;
751         } else {
752                 /*
753                  * Intermediate descriptor in a multi-descriptor frame.
754                  */
755                 ads->ds_ctl0 = 0;
756                 ads->ds_ctl1 = segLen | AR_TxMore;
757                 ads->ds_ctl2 = 0;
758                 ads->ds_ctl3 = 0;
759         }
760         ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
761
762         return AH_TRUE;
763 }
764
765 HAL_BOOL ar5416FillKeyTxDesc_20(struct ath_hal *ah, struct ath_tx_desc *ds,
766                                 HAL_KEY_TYPE keyType)
767 {
768         struct ar5416_desc *ads = AR5416DESC(ds);
769
770         ads->ds_ctl6 = SM(keyType, AR_EncrType);
771         return AH_TRUE;
772 }
773
774 HAL_STATUS ar5416ProcTxDesc_20(struct ath_hal *ah, struct ath_tx_desc *gds)
775 {
776         struct ar5416_desc *ads = AR5416DESC(gds);
777         struct ath_tx_desc *ds = (struct ath_tx_desc *)gds;
778         
779         if ((ads->ds_txstatus9 & AR_TxDone) == 0)
780                 return HAL_EINPROGRESS;
781
782         ads->ds_txstatus9 &= ~AR_TxDone;
783
784         /* Update software copies of the HW status */
785         ds->ds_txstat.ts_seqnum = MS(ads->ds_txstatus9, AR_SeqNum);
786         ds->ds_txstat.ts_tstamp = ads->AR_SendTimestamp;
787         ds->ds_txstat.ts_status = 0;
788         ds->ds_txstat.ts_flags  = 0;
789
790         if (ads->ds_txstatus1 & AR_ExcessiveRetries)
791                 ds->ds_txstat.ts_status |= HAL_TXERR_XRETRY;
792         if (ads->ds_txstatus1 & AR_Filtered)
793                 ds->ds_txstat.ts_status |= HAL_TXERR_FILT;
794         if (ads->ds_txstatus1 & AR_FIFOUnderrun)
795                 ds->ds_txstat.ts_status |= HAL_TXERR_FIFO;
796         if (ads->ds_txstatus9 & AR_TxOpExceeded)
797                 ds->ds_txstat.ts_status |= HAL_TXERR_XTXOP;
798         if (ads->ds_txstatus1 & AR_TxTimerExpired)
799                 ds->ds_txstat.ts_status |= HAL_TXERR_TIMER_EXPIRED;
800
801         if (ads->ds_txstatus1 & AR_DescCfgErr)
802                 ds->ds_txstat.ts_flags |= HAL_TX_DESC_CFG_ERR;
803         if (ads->ds_txstatus1 & AR_TxDataUnderrun) {
804                 ds->ds_txstat.ts_flags |= HAL_TX_DATA_UNDERRUN;
805                 ar5416UpdateTxTrigLevel(ah, AH_TRUE);
806         }
807         if (ads->ds_txstatus1 & AR_TxDelimUnderrun) {
808                 ds->ds_txstat.ts_flags |= HAL_TX_DELIM_UNDERRUN;
809                 ar5416UpdateTxTrigLevel(ah, AH_TRUE);
810         }
811         if (ads->ds_txstatus0 & AR_TxBaStatus) {
812                 ds->ds_txstat.ts_flags |= HAL_TX_BA;
813                 ds->ds_txstat.ba_low = ads->AR_BaBitmapLow;
814                 ds->ds_txstat.ba_high = ads->AR_BaBitmapHigh;
815         }
816
817         /*
818          * Extract the transmit rate used and mark the rate as
819          * ``alternate'' if it wasn't the series 0 rate.
820          */
821         ds->ds_txstat.ts_rate = MS(ads->ds_txstatus9, AR_FinalTxIdx);
822         ds->ds_txstat.ts_rssi_combined = 
823                 MS(ads->ds_txstatus5, AR_TxRSSICombined);
824         ds->ds_txstat.ts_rssi_ctl0 = MS(ads->ds_txstatus0, AR_TxRSSIAnt00);
825         ds->ds_txstat.ts_rssi_ctl1 = MS(ads->ds_txstatus0, AR_TxRSSIAnt01);
826         ds->ds_txstat.ts_rssi_ctl2 = MS(ads->ds_txstatus0, AR_TxRSSIAnt02);
827         ds->ds_txstat.ts_rssi_ext0 = MS(ads->ds_txstatus5, AR_TxRSSIAnt10);
828         ds->ds_txstat.ts_rssi_ext1 = MS(ads->ds_txstatus5, AR_TxRSSIAnt11);
829         ds->ds_txstat.ts_rssi_ext2 = MS(ads->ds_txstatus5, AR_TxRSSIAnt12);
830         ds->ds_txstat.evm0 = ads->AR_TxEVM0;
831         ds->ds_txstat.evm1 = ads->AR_TxEVM1;
832         ds->ds_txstat.evm2 = ads->AR_TxEVM2;
833         ds->ds_txstat.ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt);
834         ds->ds_txstat.ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt);
835         ds->ds_txstat.ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt);
836         ds->ds_txstat.ts_antenna = 0;           /* ignored for owl */
837
838         return HAL_OK;
839 }
840
841 void ar5416Set11nTxDesc_20(struct ath_hal *ah, struct ath_tx_desc *ds,
842                            a_uint32_t pktLen, HAL_PKT_TYPE type, a_uint32_t txPower,
843                            a_uint32_t keyIx, HAL_KEY_TYPE keyType,
844                            a_uint32_t flags)
845 {
846         struct ar5416_desc *ads = AR5416DESC(ds);
847
848         HALASSERT(isValidPktType(type));
849         HALASSERT(isValidKeyType(keyType));
850
851         if (txPower > 63)
852                 txPower = 63;
853
854         ads->ds_ctl0 = (pktLen & AR_FrameLen)
855                 | (flags & HAL_TXDESC_VMF ? AR_VirtMoreFrag : 0)
856                 | SM(txPower, AR_XmitPower)
857                 | (flags & HAL_TXDESC_RTSENA ? AR_RTSEnable : 0)
858                 | (flags & HAL_TXDESC_VEOL ? AR_VEOL : 0)
859                 | (flags & HAL_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
860                 | (flags & HAL_TXDESC_INTREQ ? AR_TxIntrReq : 0)
861                 | (keyIx != HAL_TXKEYIX_INVALID ? AR_DestIdxValid : 0)
862                 | (flags & HAL_TXDESC_CTSENA ? AR_CTSEnable : 0);
863
864         ads->ds_ctl1 = (keyIx != HAL_TXKEYIX_INVALID ? SM(keyIx, AR_DestIdx) : 0)
865                 | SM(type, AR_FrameType)
866                 | (flags & HAL_TXDESC_NOACK ? AR_NoAck : 0)
867                 | (flags & HAL_TXDESC_EXT_ONLY ? AR_ExtOnly : 0)
868                 | (flags & HAL_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0);
869
870         ads->ds_ctl6 = SM(keyType, AR_EncrType);
871 }
872
873 #ifdef MAGPIE_MERLIN
874
875 void ar5416Set11nRateScenario_20(struct ath_hal *ah, struct ath_tx_desc *ds,
876                                  a_uint32_t durUpdateEn, a_uint32_t rtsctsRate,
877                                  a_uint32_t rtsctsDuration,
878                                  HAL_11N_RATE_SERIES series[], a_uint32_t nseries,
879                                  a_uint32_t flags)
880 {
881         struct ar5416_desc *ads = AR5416DESC(ds);
882         a_uint32_t ds_ctl0;
883
884         HALASSERT(nseries == 4);
885         (void)nseries;
886
887         /*
888          * Rate control settings override
889          */
890         ds_ctl0 = ads->ds_ctl0;
891
892         if (flags & (HAL_TXDESC_RTSENA | HAL_TXDESC_CTSENA)) {
893                 if (flags & HAL_TXDESC_RTSENA) {
894                         ds_ctl0 &= ~AR_CTSEnable;
895                         ds_ctl0 |= AR_RTSEnable;
896                 } else {
897                         ds_ctl0 &= ~AR_RTSEnable;
898                         ds_ctl0 |= AR_CTSEnable;
899                 }
900         } else {
901                 ds_ctl0 = (ds_ctl0 & ~(AR_RTSEnable | AR_CTSEnable));
902         }
903
904         ads->ds_ctl0 = ds_ctl0;
905
906         ads->ds_ctl2 = set11nTries(series, 0)
907                 |  set11nTries(series, 1)
908                 |  set11nTries(series, 2)
909                 |  set11nTries(series, 3)
910                 |  (durUpdateEn ? AR_DurUpdateEn : 0);
911
912         ads->ds_ctl3 = set11nRate(series, 0)
913                 |  set11nRate(series, 1)
914                 |  set11nRate(series, 2)
915                 |  set11nRate(series, 3);
916
917         ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0)
918                 |  set11nPktDurRTSCTS(series, 1);
919
920         ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2)
921                 |  set11nPktDurRTSCTS(series, 3);
922
923         ads->ds_ctl7 = set11nRateFlags(series, 0)
924                 |  set11nRateFlags(series, 1)
925                 |  set11nRateFlags(series, 2)
926                 |  set11nRateFlags(series, 3)
927                 | SM(rtsctsRate, AR_RTSCTSRate);
928 }
929
930 #else
931
932 void ar5416Set11nRateScenario_20(struct ath_hal *ah, struct ath_tx_desc *ds,
933                                  a_uint32_t durUpdateEn, a_uint32_t rtsctsRate,
934                                  a_uint32_t rtsctsDuration,
935                                  HAL_11N_RATE_SERIES series[], a_uint32_t nseries,
936                                  a_uint32_t flags)
937 {
938         struct ar5416_desc *ads = AR5416DESC(ds);
939         a_uint32_t ds_ctl0;
940
941         HALASSERT(nseries == 4);
942         (void)nseries;
943
944         /*
945          * Rate control settings override
946          */
947         if (flags & (HAL_TXDESC_RTSENA | HAL_TXDESC_CTSENA)) {
948                 ds_ctl0 = ads->ds_ctl0;
949
950                 if (flags & HAL_TXDESC_RTSENA) {
951                         ds_ctl0 &= ~AR_CTSEnable;
952                         ds_ctl0 |= AR_RTSEnable;
953                 } else {
954                         ds_ctl0 &= ~AR_RTSEnable;
955                         ds_ctl0 |= AR_CTSEnable;
956                 }
957
958                 ads->ds_ctl0 = ds_ctl0;
959         }
960
961         ads->ds_ctl2 = set11nTries(series, 0)
962                 |  set11nTries(series, 1)
963                 |  set11nTries(series, 2)
964                 |  set11nTries(series, 3)
965                 |  (durUpdateEn ? AR_DurUpdateEn : 0);
966
967         ads->ds_ctl3 = set11nRate(series, 0)
968                 |  set11nRate(series, 1)
969                 |  set11nRate(series, 2)
970                 |  set11nRate(series, 3);
971
972         ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0)
973                 |  set11nPktDurRTSCTS(series, 1);
974
975         ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2)
976                 |  set11nPktDurRTSCTS(series, 3);
977
978         ads->ds_ctl7 = set11nRateFlags(series, 0)
979                 |  set11nRateFlags(series, 1)
980                 |  set11nRateFlags(series, 2)
981                 |  set11nRateFlags(series, 3)
982                 | SM(rtsctsRate, AR_RTSCTSRate);
983 }
984
985 #endif
986
987 void ar5416Set11nAggrFirst_20(struct ath_hal *ah, struct ath_tx_desc *ds, a_uint32_t aggrLen,
988                               a_uint32_t numDelims)
989 {
990         struct ar5416_desc *ads = AR5416DESC(ds);
991
992         ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
993
994         ads->ds_ctl6 &= ~(AR_AggrLen | AR_PadDelim);
995         ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen) |
996                 SM(numDelims, AR_PadDelim);
997 }
998
999 void ar5416Set11nAggrMiddle_20(struct ath_hal *ah, struct ath_tx_desc *ds, a_uint32_t numDelims)
1000 {
1001         struct ar5416_desc *ads = AR5416DESC(ds);
1002         a_uint32_t ctl6;
1003
1004         ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
1005
1006         /*
1007          * We use a stack variable to manipulate ctl6 to reduce uncached 
1008          * read modify, modfiy, write.
1009          */
1010         ctl6 = ads->ds_ctl6;
1011         ctl6 &= ~AR_PadDelim;
1012         ctl6 |= SM(numDelims, AR_PadDelim);
1013         ads->ds_ctl6 = ctl6;
1014 }
1015
1016 void ar5416Set11nAggrLast_20(struct ath_hal *ah, struct ath_tx_desc *ds)
1017 {
1018         struct ar5416_desc *ads = AR5416DESC(ds);
1019
1020         ads->ds_ctl1 |= AR_IsAggr;
1021         ads->ds_ctl1 &= ~AR_MoreAggr;
1022         ads->ds_ctl6 &= ~AR_PadDelim;
1023 }
1024
1025 void ar5416Clr11nAggr_20(struct ath_hal *ah, struct ath_tx_desc *ds)
1026 {
1027         struct ar5416_desc *ads = AR5416DESC(ds);
1028
1029         ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr);
1030 }
1031
1032 void ar5416Set11nBurstDuration_20(struct ath_hal *ah, struct ath_tx_desc *ds,
1033                                   a_uint32_t burstDuration)
1034 {
1035         struct ar5416_desc *ads = AR5416DESC(ds);
1036
1037         ads->ds_ctl2 &= ~AR_BurstDur;
1038         ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur);
1039 }
1040
1041 void ar5416Set11nVirtualMoreFrag_20(struct ath_hal *ah, struct ath_tx_desc *ds,
1042                                     a_uint32_t vmf)
1043 {
1044         struct ar5416_desc *ads = AR5416DESC(ds);
1045
1046         if (vmf) {
1047                 ads->ds_ctl0 |= AR_VirtMoreFrag;
1048         } else {
1049                 ads->ds_ctl0 &= ~AR_VirtMoreFrag;
1050         }
1051 }