2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
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:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
36 #include <adf_os_types.h>
37 #include <adf_os_dma.h>
38 #include <adf_os_timer.h>
39 #include <adf_os_lock.h>
40 #include <adf_os_io.h>
41 #include <adf_os_mem.h>
42 #include <adf_os_util.h>
43 #include <adf_os_stdtypes.h>
44 #include <adf_os_defer.h>
45 #include <adf_os_atomic.h>
48 #include <adf_net_wcmd.h>
50 #include "if_ethersubr.h"
53 #ifdef USE_HEADERLEN_RESV
57 #include <ieee80211_var.h>
58 #include "if_athrate.h"
59 #include "if_athvar.h"
61 #include "if_ath_pci.h"
63 #define ath_tgt_free_skb adf_nbuf_free
65 #define OFDM_PLCP_BITS 22
66 #define HT_RC_2_MCS(_rc) ((_rc) & 0x0f)
67 #define HT_RC_2_STREAMS(_rc) ((((_rc) & 0x78) >> 3) + 1)
73 #define HT_LTF(_ns) (4 * (_ns))
74 #define SYMBOL_TIME(_ns) ((_ns) << 2) // ns * 4 us
75 #define SYMBOL_TIME_HALFGI(_ns) (((_ns) * 18 + 4) / 5) // ns * 3.6 us
77 static a_uint16_t bits_per_symbol[][2] = {
79 { 26, 54 }, // 0: BPSK
80 { 52, 108 }, // 1: QPSK 1/2
81 { 78, 162 }, // 2: QPSK 3/4
82 { 104, 216 }, // 3: 16-QAM 1/2
83 { 156, 324 }, // 4: 16-QAM 3/4
84 { 208, 432 }, // 5: 64-QAM 2/3
85 { 234, 486 }, // 6: 64-QAM 3/4
86 { 260, 540 }, // 7: 64-QAM 5/6
87 { 52, 108 }, // 8: BPSK
88 { 104, 216 }, // 9: QPSK 1/2
89 { 156, 324 }, // 10: QPSK 3/4
90 { 208, 432 }, // 11: 16-QAM 1/2
91 { 312, 648 }, // 12: 16-QAM 3/4
92 { 416, 864 }, // 13: 64-QAM 2/3
93 { 468, 972 }, // 14: 64-QAM 3/4
94 { 520, 1080 }, // 15: 64-QAM 5/6
97 void owltgt_tx_processq(struct ath_softc_tgt *sc, struct ath_txq *txq,
98 owl_txq_state_t txqstate);
99 static void ath_tgt_txqaddbuf(struct ath_softc_tgt *sc, struct ath_txq *txq,
100 struct ath_tx_buf *bf, struct ath_tx_desc *lastds);
101 void ath_rate_findrate_11n_Hardcoded(struct ath_softc_tgt *sc,
102 struct ath_rc_series series[]);
103 void ath_buf_set_rate_Hardcoded(struct ath_softc_tgt *sc,
104 struct ath_tx_buf *bf) ;
105 static a_int32_t ath_tgt_txbuf_setup(struct ath_softc_tgt *sc,
106 struct ath_tx_buf *bf, ath_data_hdr_t *dh);
107 static void ath_tx_freebuf(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
108 static void ath_tx_uc_comp(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
109 static void ath_update_stats(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
110 void adf_print_buf(adf_nbuf_t buf);
111 static void ath_tgt_tx_enqueue(struct ath_txq *txq, struct ath_atx_tid *tid);
113 void ath_tgt_tx_comp_aggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
114 struct ieee80211_frame *ATH_SKB_2_WH(adf_nbuf_t skb);
116 void ath_tgt_tx_send_normal(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
118 static void ath_tgt_tx_sched_normal(struct ath_softc_tgt *sc, ath_atx_tid_t *tid);
119 static void ath_tgt_tx_sched_aggr(struct ath_softc_tgt *sc, ath_atx_tid_t *tid);
121 extern a_int32_t ath_chainmask_sel_logic(void *);
122 static a_int32_t ath_get_pktlen(struct ath_tx_buf *bf, a_int32_t hdrlen);
123 static void ath_tgt_txq_schedule(struct ath_softc_tgt *sc, struct ath_txq *txq);
125 typedef void (*ath_ft_set_atype_t)(struct ath_softc_tgt *sc, struct ath_buf *bf);
128 ath_tx_set_retry(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
131 ath_bar_tx(struct ath_softc_tgt *sc, ath_atx_tid_t *tid, struct ath_tx_buf *bf);
133 ath_tx_update_baw(ath_atx_tid_t *tid, int seqno);
135 ath_tx_retry_subframe(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
136 ath_bufhead *bf_q, struct ath_tx_buf **bar);
139 ath_tx_comp_aggr_error(struct ath_softc_tgt *sc, struct ath_tx_buf *bf, ath_atx_tid_t *tid);
141 void ath_tx_addto_baw(ath_atx_tid_t *tid, struct ath_tx_buf *bf);
142 static inline void ath_tx_retry_unaggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
143 static void ath_tx_comp_unaggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
144 static void ath_update_aggr_stats(struct ath_softc_tgt *sc, struct ath_tx_desc *ds,
145 int nframes, int nbad);
146 static inline void ath_aggr_resume_tid(struct ath_softc_tgt *sc, ath_atx_tid_t *tid);
147 static void ath_tx_comp_cleanup(struct ath_softc_tgt *sc, struct ath_tx_buf *bf);
149 int ath_tgt_tx_add_to_aggr(struct ath_softc_tgt *sc,
150 struct ath_buf *bf,int datatype,
151 ath_atx_tid_t *tid, int is_burst);
153 struct ieee80211_frame *ATH_SKB_2_WH(adf_nbuf_t skb)
158 adf_nbuf_peek_header(skb, &anbdata, &anblen);
160 return((struct ieee80211_frame *)anbdata);
163 #undef adf_os_cpu_to_le16
165 static a_uint16_t adf_os_cpu_to_le16(a_uint16_t x)
167 return ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8));
171 ath_aggr_resume_tid(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
175 txq = TID_TO_ACTXQ(tid->tidno);
178 if (asf_tailq_empty(&tid->buf_q))
181 ath_tgt_tx_enqueue(txq, tid);
182 ath_tgt_txq_schedule(sc, txq);
186 ath_aggr_pause_tid(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
191 static a_uint32_t ath_pkt_duration(struct ath_softc_tgt *sc,
192 a_uint8_t rix, struct ath_tx_buf *bf,
193 a_int32_t width, a_int32_t half_gi)
195 const HAL_RATE_TABLE *rt = sc->sc_currates;
196 a_uint32_t nbits, nsymbits, duration, nsymbols;
201 pktlen = bf->bf_isaggr ? bf->bf_al : bf->bf_pktlen;
202 rc = rt->info[rix].rateCode;
205 return ath_hal_computetxtime(sc->sc_ah, rt, pktlen, rix,
208 nbits = (pktlen << 3) + OFDM_PLCP_BITS;
209 nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width];
210 nsymbols = (nbits + nsymbits - 1) / nsymbits;
213 duration = SYMBOL_TIME(nsymbols);
215 duration = SYMBOL_TIME_HALFGI(nsymbols);
217 streams = HT_RC_2_STREAMS(rc);
218 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
223 static void ath_dma_map(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
225 adf_nbuf_t skb = bf->bf_skb;
227 skb = adf_nbuf_queue_first(&bf->bf_skbhead);
228 adf_nbuf_map(sc->sc_dev, bf->bf_dmamap, skb, ADF_OS_DMA_TO_DEVICE);
231 static void ath_dma_unmap(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
233 adf_nbuf_t skb = bf->bf_skb;
235 skb = adf_nbuf_queue_first(&bf->bf_skbhead);
236 adf_nbuf_unmap( sc->sc_dev, bf->bf_dmamap, ADF_OS_DMA_TO_DEVICE);
239 static void ath_filltxdesc(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
241 struct ath_tx_desc *ds0, *ds = bf->bf_desc;
245 adf_nbuf_dmamap_info(bf->bf_dmamap, &bf->bf_dmamap_info);
247 for (i = 0; i < bf->bf_dmamap_info.nsegs; i++, ds++) {
249 ds->ds_data = bf->bf_dmamap_info.dma_segs[i].paddr;
251 if (i == (bf->bf_dmamap_info.nsegs - 1)) {
255 ds->ds_link = ATH_BUF_GET_DESC_PHY_ADDR_WITH_IDX(bf, i+1);
257 ath_hal_filltxdesc(sc->sc_ah, ds
258 , bf->bf_dmamap_info.dma_segs[i].len
260 , i == (bf->bf_dmamap_info.nsegs - 1)
265 static void ath_tx_tgt_setds(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
267 struct ath_desc *ds = bf->bf_desc;
269 switch (bf->bf_protmode) {
270 case IEEE80211_PROT_RTSCTS:
271 bf->bf_flags |= HAL_TXDESC_RTSENA;
273 case IEEE80211_PROT_CTSONLY:
274 bf->bf_flags |= HAL_TXDESC_CTSENA;
280 ath_hal_set11n_txdesc(sc->sc_ah, ds
286 , bf->bf_flags | HAL_TXDESC_INTREQ);
288 ath_filltxdesc(sc, bf);
291 static struct ath_tx_buf *ath_buf_toggle(struct ath_softc_tgt *sc,
292 struct ath_tx_buf *bf,
295 struct ath_tx_buf *tmp = NULL;
296 adf_nbuf_t buf = NULL;
298 adf_os_assert(sc->sc_txbuf_held != NULL);
300 tmp = sc->sc_txbuf_held;
303 ath_dma_unmap(sc, bf);
304 adf_nbuf_queue_init(&tmp->bf_skbhead);
305 buf = adf_nbuf_queue_remove(&bf->bf_skbhead);
307 adf_nbuf_queue_add(&tmp->bf_skbhead, buf);
309 adf_os_assert(adf_nbuf_queue_len(&bf->bf_skbhead) == 0);
311 tmp->bf_next = bf->bf_next;
312 tmp->bf_endpt = bf->bf_endpt;
313 tmp->bf_tidno = bf->bf_tidno;
314 tmp->bf_skb = bf->bf_skb;
315 tmp->bf_node = bf->bf_node;
316 tmp->bf_isaggr = bf->bf_isaggr;
317 tmp->bf_flags = bf->bf_flags;
318 tmp->bf_state = bf->bf_state;
319 tmp->bf_retries = bf->bf_retries;
320 tmp->bf_comp = bf->bf_comp;
321 tmp->bf_nframes = bf->bf_nframes;
322 tmp->bf_cookie = bf->bf_cookie;
334 ath_dma_map(sc, tmp);
335 ath_tx_tgt_setds(sc, tmp);
338 sc->sc_txbuf_held = bf;
343 static void ath_tgt_skb_free(struct ath_softc_tgt *sc,
344 adf_nbuf_queue_t *head,
345 HTC_ENDPOINT_ID endpt)
349 while (adf_nbuf_queue_len(head) != 0) {
350 tskb = adf_nbuf_queue_remove(head);
351 ath_free_tx_skb(sc->tgt_htc_handle,endpt,tskb);
355 static void ath_buf_comp(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
357 ath_dma_unmap(sc, bf);
358 ath_tgt_skb_free(sc, &bf->bf_skbhead,bf->bf_endpt);
361 bf = ath_buf_toggle(sc, bf, 0);
363 asf_tailq_insert_tail(&sc->sc_txbuf, bf, bf_list);
367 static void ath_buf_set_rate(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
369 struct ath_hal *ah = sc->sc_ah;
370 const HAL_RATE_TABLE *rt;
371 struct ath_desc *ds = bf->bf_desc;
372 HAL_11N_RATE_SERIES series[4];
374 a_uint8_t rix, cix, rtsctsrate;
375 a_uint32_t ctsduration = 0;
376 a_int32_t prot_mode = AH_FALSE;
378 rt = sc->sc_currates;
379 rix = bf->bf_rcs[0].rix;
380 flags = (bf->bf_flags & (HAL_TXDESC_RTSENA | HAL_TXDESC_CTSENA));
381 cix = rt->info[sc->sc_protrix].controlRate;
383 if (bf->bf_protmode != IEEE80211_PROT_NONE &&
384 (rt->info[rix].phy == IEEE80211_T_OFDM ||
385 rt->info[rix].phy == IEEE80211_T_HT) &&
386 (bf->bf_flags & HAL_TXDESC_NOACK) == 0) {
387 cix = rt->info[sc->sc_protrix].controlRate;
390 if (ath_hal_htsupported(ah) && (!bf->bf_ismcast))
391 flags = HAL_TXDESC_RTSENA;
394 if (bf->bf_rcs[i].tries) {
395 cix = rt->info[bf->bf_rcs[i].rix].controlRate;
402 adf_os_mem_set(series, 0, sizeof(HAL_11N_RATE_SERIES) * 4);
404 for (i = 0; i < 4; i++) {
405 if (!bf->bf_rcs[i].tries)
408 rix = bf->bf_rcs[i].rix;
410 series[i].Rate = rt->info[rix].rateCode |
411 (bf->bf_shpream ? rt->info[rix].shortPreamble : 0);
413 series[i].Tries = bf->bf_rcs[i].tries;
415 series[i].RateFlags = ((bf->bf_rcs[i].flags & ATH_RC_RTSCTS_FLAG) ?
416 HAL_RATESERIES_RTS_CTS : 0 ) |
417 ((bf->bf_rcs[i].flags & ATH_RC_CW40_FLAG) ?
418 HAL_RATESERIES_2040 : 0 ) |
419 ((bf->bf_rcs[i].flags & ATH_RC_HT40_SGI_FLAG) ?
420 HAL_RATESERIES_HALFGI : 0 ) |
421 ((bf->bf_rcs[i].flags & ATH_RC_TX_STBC_FLAG) ?
422 HAL_RATESERIES_STBC: 0);
424 series[i].RateFlags = ((bf->bf_rcs[i].flags & ATH_RC_RTSCTS_FLAG) ?
425 HAL_RATESERIES_RTS_CTS : 0 ) |
426 ((bf->bf_rcs[i].flags & ATH_RC_CW40_FLAG) ?
427 HAL_RATESERIES_2040 : 0 ) |
428 ((bf->bf_rcs[i].flags & ATH_RC_HT40_SGI_FLAG) ?
429 HAL_RATESERIES_HALFGI : 0 );
431 series[i].PktDuration = ath_pkt_duration(sc, rix, bf,
432 (bf->bf_rcs[i].flags & ATH_RC_CW40_FLAG) != 0,
433 (bf->bf_rcs[i].flags & ATH_RC_HT40_SGI_FLAG));
435 series[i].ChSel = sc->sc_ic.ic_tx_chainmask;
438 series[i].RateFlags |= HAL_RATESERIES_RTS_CTS;
440 if (bf->bf_rcs[i].flags & ATH_RC_DS_FLAG)
441 series[i].RateFlags |= HAL_RATESERIES_RTS_CTS;
444 rtsctsrate = rt->info[cix].rateCode |
445 (bf->bf_shpream ? rt->info[cix].shortPreamble : 0);
447 ath_hal_set11n_ratescenario(ah, ds, 1,
448 rtsctsrate, ctsduration,
453 static void ath_tgt_rate_findrate(struct ath_softc_tgt *sc,
454 struct ath_node_target *an,
455 a_int32_t shortPreamble,
461 struct ath_rc_series series[],
464 ath_rate_findrate(sc, an, 1, frameLen, 10, 4, 1,
465 ATH_RC_PROBE_ALLOWED, series, isProbe);
468 static void owl_tgt_tid_init(struct ath_atx_tid *tid)
472 tid->seq_start = tid->seq_next = 0;
473 tid->baw_size = WME_MAX_BA;
474 tid->baw_head = tid->baw_tail = 0;
477 tid->sched = AH_FALSE;
479 asf_tailq_init(&tid->buf_q);
481 for (i = 0; i < ATH_TID_MAX_BUFS; i++) {
482 TX_BUF_BITMAP_CLR(tid->tx_buf_bitmap, i);
486 static void owl_tgt_tid_cleanup(struct ath_softc_tgt *sc,
487 struct ath_atx_tid *tid)
494 tid->flag &= ~TID_CLEANUP_INPROGRES;
496 if (tid->flag & TID_REINITIALIZE) {
497 adf_os_print("TID REINIT DONE for tid %p\n", tid);
498 tid->flag &= ~TID_REINITIALIZE;
499 owl_tgt_tid_init(tid);
501 ath_aggr_resume_tid(sc, tid);
505 void owl_tgt_node_init(struct ath_node_target * an)
507 struct ath_atx_tid *tid;
510 for (tidno = 0, tid = &an->tid[tidno]; tidno < WME_NUM_TID;tidno++, tid++) {
514 if ( tid->flag & TID_CLEANUP_INPROGRES ) {
515 tid->flag |= TID_REINITIALIZE;
516 adf_os_print("tid[%p]->incomp is not 0: %d\n",
519 owl_tgt_tid_init(tid);
524 void ath_tx_status_clear(struct ath_softc_tgt *sc)
528 for (i = 0; i < 2; i++) {
529 sc->tx_status[i].cnt = 0;
533 static WMI_TXSTATUS_EVENT *ath_tx_status_get(struct ath_softc_tgt *sc)
535 WMI_TXSTATUS_EVENT *txs = NULL;
538 for (i = 0; i < 2; i++) {
539 if (sc->tx_status[i].cnt < HTC_MAX_TX_STATUS) {
540 txs = &sc->tx_status[i];
548 void ath_tx_status_update(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
550 struct ath_tx_desc *ds = bf->bf_lastds;
551 WMI_TXSTATUS_EVENT *txs;
553 if (sc->sc_tx_draining)
556 txs = ath_tx_status_get(sc);
560 txs->txstatus[txs->cnt].cookie = bf->bf_cookie;
561 txs->txstatus[txs->cnt].ts_rate = SM(bf->bf_endpt, ATH9K_HTC_TXSTAT_EPID);
563 if (ds->ds_txstat.ts_status & HAL_TXERR_FILT)
564 txs->txstatus[txs->cnt].ts_flags |= ATH9K_HTC_TXSTAT_FILT;
566 if (!(ds->ds_txstat.ts_status & HAL_TXERR_XRETRY) &&
567 !(ds->ds_txstat.ts_status & HAL_TXERR_FIFO) &&
568 !(ds->ds_txstat.ts_status & HAL_TXERR_TIMER_EXPIRED) &&
569 !(ds->ds_txstat.ts_status & HAL_TXERR_FILT))
570 txs->txstatus[txs->cnt].ts_flags |= ATH9K_HTC_TXSTAT_ACK;
572 ath_tx_status_update_rate(sc, bf->bf_rcs, ds->ds_txstat.ts_rate, txs);
577 void ath_tx_status_update_aggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
578 struct ath_tx_desc *ds, struct ath_rc_series rcs[],
581 WMI_TXSTATUS_EVENT *txs;
583 if (sc->sc_tx_draining)
586 txs = ath_tx_status_get(sc);
590 txs->txstatus[txs->cnt].cookie = bf->bf_cookie;
591 txs->txstatus[txs->cnt].ts_rate = SM(bf->bf_endpt, ATH9K_HTC_TXSTAT_EPID);
594 txs->txstatus[txs->cnt].ts_flags |= ATH9K_HTC_TXSTAT_ACK;
597 ath_tx_status_update_rate(sc, rcs, ds->ds_txstat.ts_rate, txs);
602 void ath_tx_status_send(struct ath_softc_tgt *sc)
606 if (sc->sc_tx_draining)
609 for (i = 0; i < 2; i++) {
610 if (sc->tx_status[i].cnt) {
611 wmi_event(sc->tgt_wmi_handle, WMI_TXSTATUS_EVENTID,
612 &sc->tx_status[i], sizeof(WMI_TXSTATUS_EVENT));
613 /* FIXME: Handle failures. */
614 sc->tx_status[i].cnt = 0;
619 static void owltgt_tx_process_cabq(struct ath_softc_tgt *sc, struct ath_txq *txq)
621 ath_hal_intrset(sc->sc_ah, sc->sc_imask & ~HAL_INT_SWBA);
622 owltgt_tx_processq(sc, txq, OWL_TXQ_ACTIVE);
623 ath_hal_intrset(sc->sc_ah, sc->sc_imask);
626 void owl_tgt_tx_tasklet(TQUEUE_ARG data)
628 struct ath_softc_tgt *sc = (struct ath_softc_tgt *)data;
632 ath_tx_status_clear(sc);
634 for (i = 0; i < (HAL_NUM_TX_QUEUES - 6); i++) {
635 txq = ATH_TXQ(sc, i);
637 if (ATH_TXQ_SETUP(sc, i)) {
638 if (txq == sc->sc_cabq)
639 owltgt_tx_process_cabq(sc, txq);
641 owltgt_tx_processq(sc, txq, OWL_TXQ_ACTIVE);
645 ath_tx_status_send(sc);
648 void owltgt_tx_processq(struct ath_softc_tgt *sc, struct ath_txq *txq,
649 owl_txq_state_t txqstate)
651 struct ath_tx_buf *bf;
652 struct ath_tx_desc *ds;
656 if (asf_tailq_empty(&txq->axq_q)) {
657 txq->axq_link = NULL;
658 txq->axq_linkbuf = NULL;
662 bf = asf_tailq_first(&txq->axq_q);
665 status = ath_hal_txprocdesc(sc->sc_ah, ds);
667 if (status == HAL_EINPROGRESS) {
668 if (txqstate == OWL_TXQ_ACTIVE)
670 else if (txqstate == OWL_TXQ_STOPPED) {
671 __stats(sc, tx_stopfiltered);
672 ds->ds_txstat.ts_flags = 0;
673 ds->ds_txstat.ts_status = HAL_OK;
675 ds->ds_txstat.ts_flags = HAL_TX_SW_FILTERED;
679 ATH_TXQ_REMOVE_HEAD(txq, bf, bf_list);
680 if ((asf_tailq_empty(&txq->axq_q))) {
681 __stats(sc, tx_qnull);
682 txq->axq_link = NULL;
683 txq->axq_linkbuf = NULL;
689 ath_tx_status_update(sc, bf);
690 ath_buf_comp(sc, bf);
693 if (txqstate == OWL_TXQ_ACTIVE) {
694 ath_tgt_txq_schedule(sc, txq);
699 static struct ieee80211_frame* ATH_SKB2_WH(adf_nbuf_t skb)
704 adf_nbuf_peek_header(skb, &anbdata, &anblen);
705 return((struct ieee80211_frame *)anbdata);
709 ath_tgt_tid_drain(struct ath_softc_tgt *sc, struct ath_atx_tid *tid)
711 struct ath_tx_buf *bf;
713 while (!asf_tailq_empty(&tid->buf_q)) {
714 TAILQ_DEQ(&tid->buf_q, bf, bf_list);
715 ath_tx_freebuf(sc, bf);
718 tid->seq_next = tid->seq_start;
719 tid->baw_tail = tid->baw_head;
722 static void ath_tgt_tx_comp_normal(struct ath_softc_tgt *sc,
723 struct ath_tx_buf *bf)
725 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
726 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
728 if (tid->flag & TID_CLEANUP_INPROGRES) {
729 owl_tgt_tid_cleanup(sc, tid);
733 ath_tx_uc_comp(sc, bf);
736 ath_tx_freebuf(sc, bf);
739 static struct ieee80211_node_target * ath_tgt_find_node(struct ath_softc_tgt *sc,
740 a_int32_t node_index)
742 struct ath_node_target *an;
743 struct ieee80211_node_target *ni;
745 if (node_index > TARGET_NODE_MAX)
748 an = &sc->sc_sta[node_index];
752 if (ni->ni_vap == NULL) {
761 static struct ath_tx_buf* ath_tx_buf_alloc(struct ath_softc_tgt *sc)
763 struct ath_tx_buf *bf = NULL;
765 bf = asf_tailq_first(&sc->sc_txbuf);
767 adf_os_mem_set(&bf->bf_state, 0, sizeof(struct ath_buf_state));
768 asf_tailq_remove(&sc->sc_txbuf, bf, bf_list);
776 struct ath_tx_buf* ath_tgt_tx_prepare(struct ath_softc_tgt *sc,
777 adf_nbuf_t skb, ath_data_hdr_t *dh)
779 struct ath_tx_buf *bf;
780 struct ieee80211_node_target *ni;
781 struct ath_atx_tid *tid;
783 ni = ath_tgt_find_node(sc, dh->ni_index);
787 tid = ATH_AN_2_TID(ATH_NODE_TARGET(ni), dh->tidno);
788 if (tid->flag & TID_REINITIALIZE) {
789 adf_os_print("drop frame due to TID reinit\n");
793 bf = ath_tx_buf_alloc(sc);
795 __stats(sc, tx_nobufs);
799 bf->bf_tidno = dh->tidno;
800 bf->bf_txq = TID_TO_ACTXQ(bf->bf_tidno);
801 bf->bf_keytype = dh->keytype;
802 bf->bf_keyix = dh->keyix;
803 bf->bf_protmode = dh->flags & (IEEE80211_PROT_RTSCTS | IEEE80211_PROT_CTSONLY);
806 adf_nbuf_queue_add(&bf->bf_skbhead, skb);
807 skb = adf_nbuf_queue_first(&(bf->bf_skbhead));
809 if (adf_nbuf_queue_len(&(bf->bf_skbhead)) == 0) {
810 __stats(sc, tx_noskbs);
818 ath_tgt_txbuf_setup(sc, bf, dh);
820 ath_tx_tgt_setds(sc, bf);
825 static void ath_tgt_tx_seqno_normal(struct ath_tx_buf *bf)
827 struct ieee80211_node_target *ni = bf->bf_node;
828 struct ath_node_target *an = ATH_NODE_TARGET(ni);
829 struct ieee80211_frame *wh = ATH_SKB_2_WH(bf->bf_skb);
830 struct ath_atx_tid *tid = ATH_AN_2_TID(an, bf->bf_tidno);
832 u_int8_t fragno = (wh->i_seq[0] & 0xf);
834 INCR(ni->ni_txseqmgmt, IEEE80211_SEQ_MAX);
836 bf->bf_seqno = (tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
838 *(u_int16_t *)wh->i_seq = adf_os_cpu_to_le16(bf->bf_seqno);
839 wh->i_seq[0] |= fragno;
841 if (!(wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG))
842 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
845 static a_int32_t ath_key_setup(struct ieee80211_node_target *ni,
846 struct ath_tx_buf *bf)
848 struct ieee80211_frame *wh = ATH_SKB_2_WH(bf->bf_skb);
850 if (!(wh->i_fc[1] & IEEE80211_FC1_WEP)) {
851 bf->bf_keytype = HAL_KEY_TYPE_CLEAR;
852 bf->bf_keyix = HAL_TXKEYIX_INVALID;
856 switch (bf->bf_keytype) {
857 case HAL_KEY_TYPE_WEP:
858 bf->bf_pktlen += IEEE80211_WEP_ICVLEN;
860 case HAL_KEY_TYPE_AES:
861 bf->bf_pktlen += IEEE80211_WEP_MICLEN;
863 case HAL_KEY_TYPE_TKIP:
864 bf->bf_pktlen += IEEE80211_WEP_ICVLEN;
870 if (bf->bf_keytype == HAL_KEY_TYPE_AES ||
871 bf->bf_keytype == HAL_KEY_TYPE_TKIP)
872 ieee80211_tgt_crypto_encap(wh, ni, bf->bf_keytype);
877 static void ath_tgt_txq_add_ucast(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
879 struct ath_hal *ah = sc->sc_ah;
882 volatile a_int32_t txe_val;
888 status = ath_hal_txprocdesc(sc->sc_ah, bf->bf_lastds);
890 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
892 if (txq->axq_link == NULL) {
893 ath_hal_puttxbuf(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
895 *txq->axq_link = ATH_BUF_GET_DESC_PHY_ADDR(bf);
897 txe_val = OS_REG_READ(ah, 0x840);
898 if (!(txe_val & (1<< txq->axq_qnum)))
899 ath_hal_puttxbuf(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
902 txq->axq_link = &bf->bf_lastds->ds_link;
903 ath_hal_txstart(ah, txq->axq_qnum);
906 static a_int32_t ath_tgt_txbuf_setup(struct ath_softc_tgt *sc,
907 struct ath_tx_buf *bf,
911 struct ieee80211_frame *wh = ATH_SKB2_WH(bf->bf_skb);
913 a_uint32_t flags = adf_os_ntohl(dh->flags);
915 ath_tgt_tx_seqno_normal(bf);
917 bf->bf_txq_add = ath_tgt_txq_add_ucast;
918 bf->bf_hdrlen = ieee80211_anyhdrsize(wh);
919 bf->bf_pktlen = ath_get_pktlen(bf, bf->bf_hdrlen);
920 bf->bf_ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
922 if ((retval = ath_key_setup(bf->bf_node, bf)) < 0)
925 if (flags & ATH_SHORT_PREAMBLE)
926 bf->bf_shpream = AH_TRUE;
928 bf->bf_shpream = AH_FALSE;
930 bf->bf_flags = HAL_TXDESC_CLRDMASK;
931 bf->bf_atype = HAL_PKT_TYPE_NORMAL;
937 ath_get_pktlen(struct ath_tx_buf *bf, a_int32_t hdrlen)
939 adf_nbuf_t skb = bf->bf_skb;
942 skb = adf_nbuf_queue_first(&bf->bf_skbhead);
943 pktlen = adf_nbuf_len(skb);
945 pktlen -= (hdrlen & 3);
946 pktlen += IEEE80211_CRC_LEN;
952 ath_tgt_tx_send_normal(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
954 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
955 struct ath_rc_series rcs[4];
956 struct ath_rc_series mrcs[4];
957 a_int32_t shortPreamble = 0;
958 a_int32_t isProbe = 0;
960 adf_os_mem_set(rcs, 0, sizeof(struct ath_rc_series)*4 );
961 adf_os_mem_set(mrcs, 0, sizeof(struct ath_rc_series)*4 );
963 if (!bf->bf_ismcast) {
964 ath_tgt_rate_findrate(sc, an, shortPreamble,
967 ath_hal_memcpy(bf->bf_rcs, rcs, sizeof(rcs));
969 mrcs[1].tries = mrcs[2].tries = mrcs[3].tries = 0;
970 mrcs[1].rix = mrcs[2].rix = mrcs[3].rix = 0;
974 ath_hal_memcpy(bf->bf_rcs, mrcs, sizeof(mrcs));
977 ath_buf_set_rate(sc, bf);
978 bf->bf_txq_add(sc, bf);
982 ath_tx_freebuf(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
985 struct ath_desc *bfd = NULL;
987 for (bfd = bf->bf_desc, i = 0; i < bf->bf_dmamap_info.nsegs; bfd++, i++) {
988 ath_hal_clr11n_aggr(sc->sc_ah, bfd);
989 ath_hal_set11n_burstduration(sc->sc_ah, bfd, 0);
990 ath_hal_set11n_virtualmorefrag(sc->sc_ah, bfd, 0);
993 ath_dma_unmap(sc, bf);
995 ath_tgt_skb_free(sc, &bf->bf_skbhead,bf->bf_endpt);
1001 bf = ath_buf_toggle(sc, bf, 0);
1003 bf->bf_isretried = 0;
1006 asf_tailq_insert_tail(&sc->sc_txbuf, bf, bf_list);
1010 ath_tx_uc_comp(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1012 ath_tx_status_update(sc, bf);
1013 ath_update_stats(sc, bf);
1014 ath_rate_tx_complete(sc, ATH_NODE_TARGET(bf->bf_node),
1015 bf->bf_lastds, bf->bf_rcs, 1, 0);
1019 ath_update_stats(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1021 struct ath_tx_desc *ds = bf->bf_desc;
1024 if (ds->ds_txstat.ts_status == 0) {
1025 if (ds->ds_txstat.ts_rate & HAL_TXSTAT_ALTRATE)
1026 sc->sc_tx_stats.ast_tx_altrate++;
1028 if (ds->ds_txstat.ts_status & HAL_TXERR_XRETRY)
1029 sc->sc_tx_stats.ast_tx_xretries++;
1030 if (ds->ds_txstat.ts_status & HAL_TXERR_FIFO)
1031 sc->sc_tx_stats.ast_tx_fifoerr++;
1032 if (ds->ds_txstat.ts_status & HAL_TXERR_FILT)
1033 sc->sc_tx_stats.ast_tx_filtered++;
1034 if (ds->ds_txstat.ts_status & HAL_TXERR_TIMER_EXPIRED)
1035 sc->sc_tx_stats.ast_tx_timer_exp++;
1037 sr = ds->ds_txstat.ts_shortretry;
1038 lr = ds->ds_txstat.ts_longretry;
1039 sc->sc_tx_stats.ast_tx_shortretry += sr;
1040 sc->sc_tx_stats.ast_tx_longretry += lr;
1044 ath_tgt_send_mgt(struct ath_softc_tgt *sc,adf_nbuf_t hdr_buf, adf_nbuf_t skb,
1045 HTC_ENDPOINT_ID endpt)
1047 struct ieee80211_node_target *ni;
1048 struct ieee80211vap_target *vap;
1049 struct ath_vap_target *avp;
1050 struct ath_hal *ah = sc->sc_ah;
1051 a_uint8_t rix, txrate, ctsrate, cix = 0xff, *data;
1052 a_uint32_t ivlen = 0, icvlen = 0, subtype, flags, ctsduration;
1053 a_int32_t i, iswep, ismcast, hdrlen, pktlen, try0, len;
1054 struct ath_desc *ds=NULL;
1055 struct ath_txq *txq=NULL;
1056 struct ath_tx_buf *bf;
1058 const HAL_RATE_TABLE *rt;
1059 HAL_BOOL shortPreamble;
1060 struct ieee80211_frame *wh;
1061 struct ath_rc_series rcs[4];
1062 HAL_11N_RATE_SERIES series[4];
1067 adf_nbuf_peek_header(skb, &data, &len);
1068 adf_nbuf_pull_head(skb, sizeof(ath_mgt_hdr_t));
1070 adf_nbuf_peek_header(hdr_buf, &data, &len);
1073 adf_os_assert(len >= sizeof(ath_mgt_hdr_t));
1075 mh = (ath_mgt_hdr_t *)data;
1076 adf_nbuf_peek_header(skb, &data, &len);
1077 wh = (struct ieee80211_frame *)data;
1079 adf_os_mem_set(rcs, 0, sizeof(struct ath_rc_series)*4);
1080 adf_os_mem_set(series, 0, sizeof(HAL_11N_RATE_SERIES)*4);
1082 bf = asf_tailq_first(&sc->sc_txbuf);
1086 asf_tailq_remove(&sc->sc_txbuf, bf, bf_list);
1088 ni = ath_tgt_find_node(sc, mh->ni_index);
1092 bf->bf_endpt = endpt;
1093 bf->bf_cookie = mh->cookie;
1094 bf->bf_protmode = mh->flags & (IEEE80211_PROT_RTSCTS | IEEE80211_PROT_CTSONLY);
1095 txq = &sc->sc_txq[1];
1096 iswep = wh->i_fc[1] & IEEE80211_FC1_WEP;
1097 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
1098 hdrlen = ieee80211_anyhdrsize(wh);
1100 keyix = HAL_TXKEYIX_INVALID;
1101 pktlen -= (hdrlen & 3);
1102 pktlen += IEEE80211_CRC_LEN;
1107 adf_nbuf_map(sc->sc_dev, bf->bf_dmamap, skb, ADF_OS_DMA_TO_DEVICE);
1110 adf_nbuf_queue_add(&bf->bf_skbhead, skb);
1113 rt = sc->sc_currates;
1114 adf_os_assert(rt != NULL);
1116 if (mh->flags == ATH_SHORT_PREAMBLE)
1117 shortPreamble = AH_TRUE;
1119 shortPreamble = AH_FALSE;
1121 flags = HAL_TXDESC_CLRDMASK;
1123 switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) {
1124 case IEEE80211_FC0_TYPE_MGT:
1125 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
1127 if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)
1128 atype = HAL_PKT_TYPE_PROBE_RESP;
1129 else if (subtype == IEEE80211_FC0_SUBTYPE_ATIM)
1130 atype = HAL_PKT_TYPE_ATIM;
1132 atype = HAL_PKT_TYPE_NORMAL;
1136 atype = HAL_PKT_TYPE_NORMAL;
1140 avp = &sc->sc_vap[mh->vap_index];
1142 rcs[0].rix = ath_get_minrateidx(sc, avp);
1143 rcs[0].tries = ATH_TXMAXTRY;
1146 adf_os_mem_copy(bf->bf_rcs, rcs, sizeof(rcs));
1148 try0 = rcs[0].tries;
1149 txrate = rt->info[rix].rateCode;
1152 txrate |= rt->info[rix].shortPreamble;
1159 flags |= HAL_TXDESC_NOACK;
1161 } else if (pktlen > vap->iv_rtsthreshold) {
1162 flags |= HAL_TXDESC_RTSENA;
1163 cix = rt->info[rix].controlRate;
1166 if ((bf->bf_protmode != IEEE80211_PROT_NONE) &&
1167 rt->info[rix].phy == IEEE80211_T_OFDM &&
1168 (flags & HAL_TXDESC_NOACK) == 0) {
1169 cix = rt->info[sc->sc_protrix].controlRate;
1170 sc->sc_tx_stats.ast_tx_protect++;
1173 *(a_uint16_t *)&wh->i_seq[0] = adf_os_cpu_to_le16(ni->ni_txseqmgmt <<
1174 IEEE80211_SEQ_SEQ_SHIFT);
1175 INCR(ni->ni_txseqmgmt, IEEE80211_SEQ_MAX);
1178 if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) {
1179 adf_os_assert(cix != 0xff);
1180 ctsrate = rt->info[cix].rateCode;
1181 if (shortPreamble) {
1182 ctsrate |= rt->info[cix].shortPreamble;
1183 if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */
1184 ctsduration += rt->info[cix].spAckDuration;
1185 if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */
1186 ctsduration += rt->info[cix].spAckDuration;
1188 if (flags & HAL_TXDESC_RTSENA) /* SIFS + CTS */
1189 ctsduration += rt->info[cix].lpAckDuration;
1190 if ((flags & HAL_TXDESC_NOACK) == 0) /* SIFS + ACK */
1191 ctsduration += rt->info[cix].lpAckDuration;
1193 ctsduration += ath_hal_computetxtime(ah,
1194 rt, pktlen, rix, shortPreamble);
1199 flags |= HAL_TXDESC_INTREQ;
1201 ath_hal_setuptxdesc(ah, ds
1214 , ATH_COMP_PROC_NO_COMP_NO_CCS);
1216 bf->bf_flags = flags;
1219 * Set key type in tx desc while sending the encrypted challenge to AP
1220 * in Auth frame 3 of Shared Authentication, owl needs this.
1222 if (iswep && (keyix != HAL_TXKEYIX_INVALID) &&
1223 (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_AUTH)
1224 ath_hal_fillkeytxdesc(ah, ds, mh->keytype);
1226 ath_filltxdesc(sc, bf);
1228 for (i=0; i<4; i++) {
1229 series[i].Tries = 2;
1230 series[i].Rate = txrate;
1231 series[i].ChSel = sc->sc_ic.ic_tx_chainmask;
1232 series[i].RateFlags = 0;
1234 ath_hal_set11n_ratescenario(ah, ds, 0, ctsrate, ctsduration, series, 4, 0);
1235 ath_tgt_txqaddbuf(sc, txq, bf, bf->bf_lastds);
1239 HTC_ReturnBuffers(sc->tgt_htc_handle, endpt, skb);
1244 ath_tgt_txqaddbuf(struct ath_softc_tgt *sc,
1245 struct ath_txq *txq, struct ath_tx_buf *bf,
1246 struct ath_tx_desc *lastds)
1248 struct ath_hal *ah = sc->sc_ah;
1250 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
1252 if (txq->axq_link == NULL) {
1253 ath_hal_puttxbuf(ah, txq->axq_qnum, ATH_BUF_GET_DESC_PHY_ADDR(bf));
1255 *txq->axq_link = ATH_BUF_GET_DESC_PHY_ADDR(bf);
1258 txq->axq_link = &lastds->ds_link;
1259 ath_hal_txstart(ah, txq->axq_qnum);
1262 void ath_tgt_handle_normal(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1265 struct ath_node_target *an;
1267 an = (struct ath_node_target *)bf->bf_node;
1270 tid = &an->tid[bf->bf_tidno];
1273 bf->bf_comp = ath_tgt_tx_comp_normal;
1274 INCR(tid->seq_start, IEEE80211_SEQ_MAX);
1275 ath_tgt_tx_send_normal(sc, bf);
1279 ath_tgt_tx_enqueue(struct ath_txq *txq, struct ath_atx_tid *tid)
1287 tid->sched = AH_TRUE;
1288 asf_tailq_insert_tail(&txq->axq_tidq, tid, tid_qelem);
1292 ath_tgt_txq_schedule(struct ath_softc_tgt *sc, struct ath_txq *txq)
1294 struct ath_atx_tid *tid;
1300 TAILQ_DEQ(&txq->axq_tidq, tid, tid_qelem);
1305 tid->sched = AH_FALSE;
1310 if (!(tid->flag & TID_AGGR_ENABLED))
1311 ath_tgt_tx_sched_normal(sc,tid);
1313 ath_tgt_tx_sched_aggr(sc,tid);
1317 if (!asf_tailq_empty(&tid->buf_q)) {
1318 ath_tgt_tx_enqueue(txq, tid);
1321 } while (!asf_tailq_empty(&txq->axq_tidq) && !bdone);
1325 ath_tgt_handle_aggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1328 struct ath_node_target *an;
1329 struct ath_txq *txq = bf->bf_txq;
1330 a_bool_t queue_frame, within_baw;
1332 an = (struct ath_node_target *)bf->bf_node;
1335 tid = &an->tid[bf->bf_tidno];
1338 bf->bf_comp = ath_tgt_tx_comp_aggr;
1340 within_baw = BAW_WITHIN(tid->seq_start, tid->baw_size,
1341 SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1343 queue_frame = ( (txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) ||
1344 (!asf_tailq_empty(&tid->buf_q)) ||
1345 (tid->paused) || (!within_baw) );
1348 asf_tailq_insert_tail(&tid->buf_q, bf, bf_list);
1349 ath_tgt_tx_enqueue(txq, tid);
1351 ath_tx_addto_baw(tid, bf);
1352 __stats(sc, txaggr_nframes);
1353 ath_tgt_tx_send_normal(sc, bf);
1358 ath_tgt_tx_sched_normal(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
1361 struct ath_txq *txq =TID_TO_ACTXQ(tid->tidno);;
1364 if (asf_tailq_empty(&tid->buf_q))
1367 bf = asf_tailq_first(&tid->buf_q);
1368 asf_tailq_remove(&tid->buf_q, bf, bf_list);
1369 ath_tgt_tx_send_normal(sc, bf);
1371 } while (txq->axq_depth < ATH_AGGR_MIN_QDEPTH);
1375 ath_tgt_tx_sched_aggr(struct ath_softc_tgt *sc, ath_atx_tid_t *tid)
1377 struct ath_tx_buf *bf, *bf_last;
1378 ATH_AGGR_STATUS status;
1380 struct ath_txq *txq = TID_TO_ACTXQ(tid->tidno);
1381 struct ath_desc *ds = NULL;
1385 if (asf_tailq_empty(&tid->buf_q))
1389 if (asf_tailq_empty(&tid->buf_q))
1392 asf_tailq_init(&bf_q);
1394 status = ath_tgt_tx_form_aggr(sc, tid, &bf_q);
1396 if (asf_tailq_empty(&bf_q))
1399 bf = asf_tailq_first(&bf_q);
1400 bf_last = asf_tailq_last(&bf_q, ath_bufhead_s);
1402 if (bf->bf_nframes == 1) {
1404 if(bf->bf_retries == 0)
1405 __stats(sc, txaggr_single);
1407 bf->bf_lastds = &(bf->bf_descarr[bf->bf_dmamap_info.nsegs -1]);
1408 bf->bf_lastds->ds_link = 0;
1411 for(ds = bf->bf_desc; ds <= bf->bf_lastds; ds++)
1412 ath_hal_clr11n_aggr(sc->sc_ah, ds);
1414 ath_buf_set_rate(sc, bf);
1415 bf->bf_txq_add(sc, bf);
1420 bf_last->bf_next = NULL;
1421 bf_last->bf_lastds->ds_link = 0;
1422 bf_last->bf_ndelim = 0;
1425 ath_buf_set_rate(sc, bf);
1426 ath_hal_set11n_aggr_first(sc->sc_ah, bf->bf_desc, bf->bf_al,
1428 bf->bf_lastds = bf_last->bf_lastds;
1430 for (i = 0; i < bf_last->bf_dmamap_info.nsegs; i++)
1431 ath_hal_set11n_aggr_last(sc->sc_ah, &bf_last->bf_descarr[i]);
1433 if (status == ATH_AGGR_8K_LIMITED) {
1438 bf->bf_txq_add(sc, bf);
1439 } while (txq->axq_depth < ATH_AGGR_MIN_QDEPTH &&
1440 status != ATH_TGT_AGGR_BAW_CLOSED);
1443 static u_int32_t ath_lookup_rate(struct ath_softc_tgt *sc,
1444 struct ath_node_target *an,
1445 struct ath_tx_buf *bf)
1448 u_int32_t max4msframelen, frame_length;
1449 u_int16_t aggr_limit, legacy=0;
1450 const HAL_RATE_TABLE *rt = sc->sc_currates;
1451 struct ieee80211_node_target *ieee_node = (struct ieee80211_node_target *)an;
1453 if (bf->bf_ismcast) {
1454 bf->bf_rcs[1].tries = bf->bf_rcs[2].tries = bf->bf_rcs[3].tries = 0;
1455 bf->bf_rcs[0].rix = 0xb;
1456 bf->bf_rcs[0].tries = ATH_TXMAXTRY - 1;
1457 bf->bf_rcs[0].flags = 0;
1459 ath_tgt_rate_findrate(sc, an, AH_TRUE, 0, ATH_TXMAXTRY-1, 4, 1,
1460 ATH_RC_PROBE_ALLOWED, bf->bf_rcs, &prate);
1463 max4msframelen = IEEE80211_AMPDU_LIMIT_MAX;
1465 for (i = 0; i < 4; i++) {
1466 if (bf->bf_rcs[i].tries) {
1467 frame_length = bf->bf_rcs[i].max4msframelen;
1469 if (rt->info[bf->bf_rcs[i].rix].phy != IEEE80211_T_HT) {
1474 max4msframelen = ATH_MIN(max4msframelen, frame_length);
1478 if (prate || legacy)
1481 if (sc->sc_ic.ic_enable_coex)
1482 aggr_limit = ATH_MIN((max4msframelen*3)/8, sc->sc_ic.ic_ampdu_limit);
1484 aggr_limit = ATH_MIN(max4msframelen, sc->sc_ic.ic_ampdu_limit);
1486 if (ieee_node->ni_maxampdu)
1487 aggr_limit = ATH_MIN(aggr_limit, ieee_node->ni_maxampdu);
1492 int ath_tgt_tx_form_aggr(struct ath_softc_tgt *sc, ath_atx_tid_t *tid,
1495 struct ath_tx_buf *bf_first ,*bf_prev = NULL;
1496 int nframes = 0, rl = 0;;
1497 struct ath_desc *ds = NULL;
1498 struct ath_tx_buf *bf;
1499 u_int16_t aggr_limit = (64*1024 -1), al = 0, bpad = 0, al_delta;
1500 u_int16_t h_baw = tid->baw_size/2, prev_al = 0, prev_frames = 0;
1502 bf_first = asf_tailq_first(&tid->buf_q);
1505 bf = asf_tailq_first(&tid->buf_q);
1508 if (!BAW_WITHIN(tid->seq_start, tid->baw_size,
1509 SEQNO_FROM_BF_SEQNO(bf->bf_seqno))) {
1511 bf_first->bf_al= al;
1512 bf_first->bf_nframes = nframes;
1513 return ATH_TGT_AGGR_BAW_CLOSED;
1517 aggr_limit = ath_lookup_rate(sc, tid->an, bf);
1521 al_delta = ATH_AGGR_DELIM_SZ + bf->bf_pktlen;
1523 if (nframes && (aggr_limit < (al + bpad + al_delta + prev_al))) {
1524 bf_first->bf_al= al;
1525 bf_first->bf_nframes = nframes;
1526 return ATH_TGT_AGGR_LIMITED;
1530 if ((nframes + prev_frames) >= ATH_MIN((h_baw), 17)) {
1532 if ((nframes + prev_frames) >= ATH_MIN((h_baw), 22)) {
1534 bf_first->bf_al= al;
1535 bf_first->bf_nframes = nframes;
1536 return ATH_TGT_AGGR_LIMITED;
1539 ath_tx_addto_baw(tid, bf);
1540 asf_tailq_remove(&tid->buf_q, bf, bf_list);
1541 asf_tailq_insert_tail(bf_q, bf, bf_list);
1546 adf_os_assert(bf->bf_comp == ath_tgt_tx_comp_aggr);
1548 al += bpad + al_delta;
1549 bf->bf_ndelim = ATH_AGGR_GET_NDELIM(bf->bf_pktlen);
1551 switch (bf->bf_keytype) {
1552 case HAL_KEY_TYPE_AES:
1553 bf->bf_ndelim += ATH_AGGR_ENCRYPTDELIM;
1555 case HAL_KEY_TYPE_WEP:
1556 case HAL_KEY_TYPE_TKIP:
1557 bf->bf_ndelim += 64;
1559 case HAL_KEY_TYPE_WAPI:
1560 bf->bf_ndelim += 12;
1566 bpad = PADBYTES(al_delta) + (bf->bf_ndelim << 2);
1569 bf_prev->bf_next = bf;
1570 bf_prev->bf_lastds->ds_link = ATH_BUF_GET_DESC_PHY_ADDR(bf);
1574 for(ds = bf->bf_desc; ds <= bf->bf_lastds; ds++)
1575 ath_hal_set11n_aggr_middle(sc->sc_ah, ds, bf->bf_ndelim);
1577 } while (!asf_tailq_empty(&tid->buf_q));
1579 bf_first->bf_al= al;
1580 bf_first->bf_nframes = nframes;
1582 return ATH_TGT_AGGR_DONE;
1585 void ath_tx_addto_baw(ath_atx_tid_t *tid, struct ath_tx_buf *bf)
1589 if (bf->bf_isretried) {
1593 index = ATH_BA_INDEX(tid->seq_start, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1594 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
1596 TX_BUF_BITMAP_SET(tid->tx_buf_bitmap, cindex);
1598 if (index >= ((tid->baw_tail - tid->baw_head) & (ATH_TID_MAX_BUFS - 1))) {
1599 tid->baw_tail = cindex;
1600 INCR(tid->baw_tail, ATH_TID_MAX_BUFS);
1604 void ath_tgt_tx_comp_aggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1606 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
1607 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
1608 struct ath_tx_desc lastds;
1609 struct ath_tx_desc *ds = &lastds;
1610 struct ath_rc_series rcs[4];
1615 int nframes = bf->bf_nframes;
1616 struct ath_buf *bf_next;
1619 struct ath_buf *bar = NULL;
1620 struct ath_txq *txq;
1624 if (tid->flag & TID_CLEANUP_INPROGRES) {
1625 ath_tx_comp_cleanup(sc, bf);
1629 adf_os_mem_copy(ds, bf->bf_lastds, sizeof (struct ath_tx_desc));
1630 adf_os_mem_copy(rcs, bf->bf_rcs, sizeof(rcs));
1632 if (ds->ds_txstat.ts_flags == HAL_TX_SW_FILTERED) {
1637 if (!bf->bf_isaggr) {
1638 ath_tx_comp_unaggr(sc, bf);
1642 __stats(sc, tx_compaggr);
1644 asf_tailq_init(&bf_q);
1646 seq_st = ATH_DS_BA_SEQ(ds);
1647 ba = ATH_DS_BA_BITMAP(ds);
1648 tx_ok = (ATH_DS_TX_STATUS(ds) == HAL_OK);
1650 if (ATH_DS_TX_STATUS(ds) & HAL_TXERR_XRETRY) {
1651 ath_tx_comp_aggr_error(sc, bf, tid);
1655 if (tx_ok && !ATH_DS_TX_BA(ds)) {
1656 __stats(sc, txaggr_babug);
1657 adf_os_print("BA Bug?\n");
1658 ath_tx_comp_aggr_error(sc, bf, tid);
1663 ba_index = ATH_BA_INDEX(seq_st, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1664 bf_next = bf->bf_next;
1666 if (tx_ok && ATH_BA_ISSET(ba, ba_index)) {
1667 __stats(sc, txaggr_compgood);
1668 ath_tx_update_baw(tid, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1669 ath_tx_status_update_aggr(sc, bf, ds, rcs, 1);
1670 ath_tx_freebuf(sc, bf);
1672 ath_tx_retry_subframe(sc, bf, &bf_q, &bar);
1678 ath_update_aggr_stats(sc, ds, nframes, nbad);
1679 ath_rate_tx_complete(sc, an, ds, rcs, nframes, nbad);
1682 ath_bar_tx(sc, tid, bar);
1685 if (!asf_tailq_empty(&bf_q)) {
1686 __stats(sc, txaggr_prepends);
1687 TAILQ_INSERTQ_HEAD(&tid->buf_q, &bf_q, bf_list);
1688 ath_tgt_tx_enqueue(txq, tid);
1693 ath_tx_comp_aggr_error(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
1698 struct ath_tx_desc lastds;
1699 struct ath_desc *ds = &lastds;
1700 struct ath_rc_series rcs[4];
1701 struct ath_buf *bar = NULL;
1702 struct ath_buf *bf_next;
1703 int nframes = bf->bf_nframes;
1705 struct ath_txq *txq;
1707 asf_tailq_init(&bf_q);
1710 adf_os_mem_copy(ds, bf->bf_lastds, sizeof (struct ath_tx_desc));
1711 adf_os_mem_copy(rcs, bf->bf_rcs, sizeof(rcs));
1714 bf_next = bf->bf_next;
1715 ath_tx_retry_subframe(sc, bf, &bf_q, &bar);
1719 ath_update_aggr_stats(sc, ds, nframes, nframes);
1720 ath_rate_tx_complete(sc, tid->an, ds, rcs, nframes, nframes);
1723 ath_bar_tx(sc, tid, bar);
1726 if (!asf_tailq_empty(&bf_q)) {
1727 __stats(sc, txaggr_prepends);
1728 TAILQ_INSERTQ_HEAD(&tid->buf_q, &bf_q, bf_list);
1729 ath_tgt_tx_enqueue(txq, tid);
1734 ath_tx_comp_cleanup(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1737 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
1738 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
1739 struct ath_tx_desc lastds;
1740 struct ath_tx_desc *ds = &lastds;
1741 struct ath_rc_series rcs[4];
1746 int nframes = bf->bf_nframes;
1747 struct ath_buf *bf_next;
1750 adf_os_mem_copy(ds, bf->bf_lastds, sizeof (struct ath_tx_desc));
1751 adf_os_mem_copy(rcs, bf->bf_rcs, sizeof(rcs));
1753 seq_st = ATH_DS_BA_SEQ(ds);
1754 ba = ATH_DS_BA_BITMAP(ds);
1755 tx_ok = (ATH_DS_TX_STATUS(ds) == HAL_OK);
1757 if (!bf->bf_isaggr) {
1758 ath_update_stats(sc, bf);
1760 __stats(sc, tx_compunaggr);
1762 ath_tx_status_update(sc, bf);
1764 ath_tx_freebuf(sc, bf);
1766 if (tid->flag & TID_CLEANUP_INPROGRES) {
1767 owl_tgt_tid_cleanup(sc, tid);
1775 ba_index = ATH_BA_INDEX(seq_st, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1776 bf_next = bf->bf_next;
1778 ath_tx_status_update_aggr(sc, bf, ds, rcs, 0);
1780 ath_tx_freebuf(sc, bf);
1784 tid->flag &= ~TID_CLEANUP_INPROGRES;
1785 ath_aggr_resume_tid(sc, tid);
1792 ath_update_aggr_stats(sc, ds, nframes, nbad);
1793 ath_rate_tx_complete(sc, an, ds, rcs, nframes, nbad);
1797 ath_tx_retry_subframe(struct ath_softc_tgt *sc, struct ath_tx_buf *bf,
1798 ath_bufhead *bf_q, struct ath_tx_buf **bar)
1801 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
1802 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
1803 struct ath_desc *ds = NULL;
1806 __stats(sc, txaggr_compretries);
1808 for(ds = bf->bf_desc, i = 0; i < bf->bf_dmamap_info.nsegs; ds++, i++) {
1809 ath_hal_clr11n_aggr(sc->sc_ah, ds);
1810 ath_hal_set11n_burstduration(sc->sc_ah, ds, 0);
1811 ath_hal_set11n_virtualmorefrag(sc->sc_ah, ds, 0);
1814 if (bf->bf_retries >= OWLMAX_RETRIES) {
1815 __stats(sc, txaggr_xretries);
1816 ath_tx_update_baw(tid, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1817 ath_tx_status_update_aggr(sc, bf, bf->bf_lastds, NULL, 0);
1822 ath_tx_freebuf(sc, bf);
1827 __stats(sc, txaggr_errlast);
1828 bf = ath_buf_toggle(sc, bf, 1);
1830 bf->bf_lastds = &(bf->bf_descarr[bf->bf_dmamap_info.nsegs - 1]);
1832 ath_tx_set_retry(sc, bf);
1833 asf_tailq_insert_tail(bf_q, bf, bf_list);
1837 ath_update_aggr_stats(struct ath_softc_tgt *sc,
1838 struct ath_tx_desc *ds, int nframes,
1842 u_int8_t status = ATH_DS_TX_STATUS(ds);
1843 u_int8_t txflags = ATH_DS_TX_FLAGS(ds);
1845 __statsn(sc, txaggr_longretries, ds->ds_txstat.ts_longretry);
1846 __statsn(sc, txaggr_shortretries, ds->ds_txstat.ts_shortretry);
1848 if (txflags & HAL_TX_DESC_CFG_ERR)
1849 __stats(sc, txaggr_desc_cfgerr);
1851 if (txflags & HAL_TX_DATA_UNDERRUN)
1852 __stats(sc, txaggr_data_urun);
1854 if (txflags & HAL_TX_DELIM_UNDERRUN)
1855 __stats(sc, txaggr_delim_urun);
1861 if (status & HAL_TXERR_XRETRY)
1862 __stats(sc, txaggr_compxretry);
1864 if (status & HAL_TXERR_FILT)
1865 __stats(sc, txaggr_filtered);
1867 if (status & HAL_TXERR_FIFO)
1868 __stats(sc, txaggr_fifo);
1870 if (status & HAL_TXERR_XTXOP)
1871 __stats(sc, txaggr_xtxop);
1873 if (status & HAL_TXERR_TIMER_EXPIRED)
1874 __stats(sc, txaggr_timer_exp);
1878 ath_tx_comp_unaggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1880 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
1881 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
1882 struct ath_desc *ds = bf->bf_lastds;
1884 ath_update_stats(sc, bf);
1885 ath_rate_tx_complete(sc, an, ds, bf->bf_rcs, 1, 0);
1887 if (ATH_DS_TX_STATUS(ds) & HAL_TXERR_XRETRY) {
1888 ath_tx_retry_unaggr(sc, bf);
1891 __stats(sc, tx_compunaggr);
1893 ath_tx_update_baw(tid, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1894 ath_tx_status_update(sc, bf);
1895 ath_tx_freebuf(sc, bf);
1899 ath_tx_retry_unaggr(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1901 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
1902 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
1903 struct ath_txq *txq;
1907 if (bf->bf_retries >= OWLMAX_RETRIES) {
1908 __stats(sc, txunaggr_xretry);
1909 ath_tx_update_baw(tid, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1910 ath_tx_status_update(sc, bf);
1911 ath_bar_tx(sc, tid, bf);
1915 __stats(sc, txunaggr_compretries);
1916 if (!bf->bf_lastds->ds_link) {
1917 __stats(sc, txunaggr_errlast);
1918 bf = ath_buf_toggle(sc, bf, 1);
1921 ath_tx_set_retry(sc, bf);
1922 asf_tailq_insert_head(&tid->buf_q, bf, bf_list);
1923 ath_tgt_tx_enqueue(txq, tid);
1927 ath_tx_update_baw(ath_atx_tid_t *tid, int seqno)
1932 index = ATH_BA_INDEX(tid->seq_start, seqno);
1933 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
1935 TX_BUF_BITMAP_CLR(tid->tx_buf_bitmap, cindex);
1937 while (tid->baw_head != tid->baw_tail &&
1938 (!TX_BUF_BITMAP_IS_SET(tid->tx_buf_bitmap, tid->baw_head))) {
1939 INCR(tid->seq_start, IEEE80211_SEQ_MAX);
1940 INCR(tid->baw_head, ATH_TID_MAX_BUFS);
1944 static void ath_tx_set_retry(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
1946 struct ieee80211_frame *wh;
1948 __stats(sc, txaggr_retries);
1950 bf->bf_isretried = 1;
1952 wh = ATH_SKB_2_WH(bf->bf_skb);
1953 wh->i_fc[1] |= IEEE80211_FC1_RETRY;
1956 void ath_tgt_tx_cleanup(struct ath_softc_tgt *sc, struct ath_node_target *an,
1957 ath_atx_tid_t *tid, a_uint8_t discard_all)
1959 struct ath_tx_buf *bf;
1960 struct ath_tx_buf *bf_next;
1961 struct ath_txq *txq;
1963 txq = TID_TO_ACTXQ(tid->tidno);
1965 bf = asf_tailq_first(&tid->buf_q);
1968 if (discard_all || bf->bf_isretried) {
1969 bf_next = asf_tailq_next(bf, bf_list);
1970 TAILQ_DEQ(&tid->buf_q, bf, bf_list);
1971 if (bf->bf_isretried)
1972 ath_tx_update_baw(tid, SEQNO_FROM_BF_SEQNO(bf->bf_seqno));
1973 ath_tx_freebuf(sc, bf);
1977 bf->bf_comp = ath_tgt_tx_comp_normal;
1978 bf = asf_tailq_next(bf, bf_list);
1981 ath_aggr_pause_tid(sc, tid);
1983 while (tid->baw_head != tid->baw_tail) {
1984 if (TX_BUF_BITMAP_IS_SET(tid->tx_buf_bitmap, tid->baw_head)) {
1986 tid->flag |= TID_CLEANUP_INPROGRES;
1987 TX_BUF_BITMAP_CLR(tid->tx_buf_bitmap, tid->baw_head);
1989 INCR(tid->baw_head, ATH_TID_MAX_BUFS);
1990 INCR(tid->seq_start, IEEE80211_SEQ_MAX);
1993 if (!(tid->flag & TID_CLEANUP_INPROGRES)) {
1994 ath_aggr_resume_tid(sc, tid);
1998 /******************/
1999 /* BAR Management */
2000 /******************/
2002 static void ath_tgt_delba_send(struct ath_softc_tgt *sc,
2003 struct ieee80211_node_target *ni,
2004 a_uint8_t tidno, a_uint8_t initiator,
2005 a_uint16_t reasoncode)
2007 struct ath_node_target *an = ATH_NODE_TARGET(ni);
2008 ath_atx_tid_t *tid = ATH_AN_2_TID(an, tidno);
2009 struct wmi_data_delba wmi_delba;
2011 tid->flag &= ~TID_AGGR_ENABLED;
2013 ath_tgt_tx_cleanup(sc, an, tid, 1);
2015 wmi_delba.ni_nodeindex = ni->ni_nodeindex;
2016 wmi_delba.tidno = tid->tidno;
2017 wmi_delba.initiator = 1;
2018 wmi_delba.reasoncode = IEEE80211_REASON_UNSPECIFIED;
2020 __stats(sc, txbar_xretry);
2021 wmi_event(sc->tgt_wmi_handle,
2027 static void ath_bar_retry(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
2029 struct ath_node_target *an = ATH_NODE_TARGET(bf->bf_node);
2030 ath_atx_tid_t *tid = ATH_AN_2_TID(an, bf->bf_tidno);
2032 if (bf->bf_retries >= OWLMAX_BAR_RETRIES) {
2033 ath_tgt_delba_send(sc, bf->bf_node, tid->tidno, 1,
2034 IEEE80211_REASON_UNSPECIFIED);
2035 ath_tgt_tid_drain(sc, tid);
2038 ath_buf_comp(sc, bf);
2042 __stats(sc, txbar_compretries);
2044 if (!bf->bf_lastds->ds_link) {
2045 __stats(sc, txbar_errlast);
2046 bf = ath_buf_toggle(sc, bf, 1);
2049 bf->bf_lastds->ds_link = 0;
2051 ath_tx_set_retry(sc, bf);
2052 ath_tgt_txq_add_ucast(sc, bf);
2055 static void ath_bar_tx_comp(struct ath_softc_tgt *sc, struct ath_tx_buf *bf)
2057 struct ath_desc *ds = bf->bf_lastds;
2058 struct ath_node_target *an;
2060 struct ath_txq *txq;
2062 an = (struct ath_node_target *)bf->bf_node;
2063 tid = &an->tid[bf->bf_tidno];
2064 txq = TID_TO_ACTXQ(tid->tidno);
2066 if (ATH_DS_TX_STATUS(ds) & HAL_TXERR_XRETRY) {
2067 ath_bar_retry(sc, bf);
2071 ath_aggr_resume_tid(sc, tid);
2074 ath_buf_comp(sc, bf);
2077 static void ath_bar_tx(struct ath_softc_tgt *sc,
2078 ath_atx_tid_t *tid, struct ath_tx_buf *bf)
2081 struct ieee80211_frame_bar *bar;
2083 struct ath_desc *ds, *ds0;
2084 HAL_11N_RATE_SERIES series[4];
2086 adf_nbuf_queue_t skbhead;
2090 __stats(sc, tx_bars);
2092 memset(&series, 0, sizeof(series));
2094 ath_aggr_pause_tid(sc, tid);
2096 skb = adf_nbuf_queue_remove(&bf->bf_skbhead);
2097 adf_nbuf_peek_header(skb, &anbdata, &anblen);
2098 adf_nbuf_trim_tail(skb, anblen);
2099 bar = (struct ieee80211_frame_bar *) anbdata;
2103 ath_dma_unmap(sc, bf);
2104 adf_nbuf_queue_add(&bf->bf_skbhead, skb);
2106 bar->i_fc[1] = IEEE80211_FC1_DIR_NODS;
2107 bar->i_fc[0] = IEEE80211_FC0_VERSION_0 |
2108 IEEE80211_FC0_TYPE_CTL |
2109 IEEE80211_FC0_SUBTYPE_BAR;
2110 bar->i_ctl = tid->tidno << IEEE80211_BAR_CTL_TID_S |
2111 IEEE80211_BAR_CTL_COMBA;
2112 bar->i_seq = adf_os_cpu_to_le16(tid->seq_start << IEEE80211_SEQ_SEQ_SHIFT);
2114 bf->bf_seqno = tid->seq_start << IEEE80211_SEQ_SEQ_SHIFT;
2116 adf_nbuf_put_tail(skb, sizeof(struct ieee80211_frame_bar));
2118 bf->bf_comp = ath_bar_tx_comp;
2119 bf->bf_tidno = tid->tidno;
2120 bf->bf_node = &tid->an->ni;
2121 ath_dma_map(sc, bf);
2122 adf_nbuf_dmamap_info(bf->bf_dmamap, &bf->bf_dmamap_info);
2125 ath_hal_setuptxdesc(sc->sc_ah, ds
2126 , adf_nbuf_len(skb) + IEEE80211_CRC_LEN
2128 , HAL_PKT_TYPE_NORMAL
2135 | HAL_TXDESC_CLRDMASK
2137 , ATH_COMP_PROC_NO_COMP_NO_CCS);
2139 skbhead = bf->bf_skbhead;
2143 for (ds0 = ds, i=0; i < bf->bf_dmamap_info.nsegs; ds0++, i++) {
2144 ath_hal_clr11n_aggr(sc->sc_ah, ds0);
2147 ath_filltxdesc(sc, bf);
2149 for (i = 0 ; i < 4; i++) {
2150 series[i].Tries = ATH_TXMAXTRY;
2151 series[i].Rate = min_rate;
2152 series[i].ChSel = sc->sc_ic.ic_tx_chainmask;
2155 ath_hal_set11n_ratescenario(sc->sc_ah, bf->bf_desc, 0, 0, 0, series, 4, 4);
2156 ath_tgt_txq_add_ucast(sc, bf);