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