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