1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -133,7 +133,6 @@ int ath_descdma_setup(struct ath_softc *
4 #define ATH_AGGR_ENCRYPTDELIM 10
5 /* minimum h/w qdepth to be sustained to maximize aggregation */
6 #define ATH_AGGR_MIN_QDEPTH 2
7 -#define ATH_AMPDU_SUBFRAME_DEFAULT 32
9 #define IEEE80211_SEQ_SEQ_SHIFT 4
10 #define IEEE80211_SEQ_MAX 4096
11 @@ -208,8 +207,9 @@ struct ath_frame_info {
13 enum ath9k_key_type keytype;
21 struct ath_buf_state {
22 @@ -237,6 +237,7 @@ struct ath_buf {
24 struct list_head list;
25 struct sk_buff_head buf_q;
26 + struct sk_buff_head retry_q;
28 struct ath_atx_ac *ac;
29 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
30 --- a/drivers/net/wireless/ath/ath9k/debug.c
31 +++ b/drivers/net/wireless/ath/ath9k/debug.c
32 @@ -607,6 +607,28 @@ static ssize_t read_file_xmit(struct fil
36 +static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
37 + char *buf, ssize_t size)
41 + ath_txq_lock(sc, txq);
43 + len += snprintf(buf + len, size - len, "%s: %d ",
44 + "qnum", txq->axq_qnum);
45 + len += snprintf(buf + len, size - len, "%s: %2d ",
46 + "qdepth", txq->axq_depth);
47 + len += snprintf(buf + len, size - len, "%s: %2d ",
48 + "ampdu-depth", txq->axq_ampdu_depth);
49 + len += snprintf(buf + len, size - len, "%s: %3d ",
50 + "pending", txq->pending_frames);
51 + len += snprintf(buf + len, size - len, "%s: %d\n",
52 + "stopped", txq->stopped);
54 + ath_txq_unlock(sc, txq);
58 static ssize_t read_file_queues(struct file *file, char __user *user_buf,
59 size_t count, loff_t *ppos)
61 @@ -624,24 +646,13 @@ static ssize_t read_file_queues(struct f
63 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
64 txq = sc->tx.txq_map[i];
65 - len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
67 - ath_txq_lock(sc, txq);
69 - len += snprintf(buf + len, size - len, "%s: %d ",
70 - "qnum", txq->axq_qnum);
71 - len += snprintf(buf + len, size - len, "%s: %2d ",
72 - "qdepth", txq->axq_depth);
73 - len += snprintf(buf + len, size - len, "%s: %2d ",
74 - "ampdu-depth", txq->axq_ampdu_depth);
75 - len += snprintf(buf + len, size - len, "%s: %3d ",
76 - "pending", txq->pending_frames);
77 - len += snprintf(buf + len, size - len, "%s: %d\n",
78 - "stopped", txq->stopped);
80 - ath_txq_unlock(sc, txq);
81 + len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
82 + len += print_queue(sc, txq, buf + len, size - len);
85 + len += snprintf(buf + len, size - len, "(CAB): ");
86 + len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);
91 --- a/drivers/net/wireless/ath/ath9k/main.c
92 +++ b/drivers/net/wireless/ath/ath9k/main.c
93 @@ -1402,9 +1402,6 @@ static void ath9k_sta_notify(struct ieee
94 struct ath_softc *sc = hw->priv;
95 struct ath_node *an = (struct ath_node *) sta->drv_priv;
97 - if (!sta->ht_cap.ht_supported)
101 case STA_NOTIFY_SLEEP:
103 --- a/drivers/net/wireless/ath/ath9k/xmit.c
104 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
105 @@ -168,6 +168,36 @@ static void ath_txq_skb_done(struct ath_
109 +static struct ath_atx_tid *
110 +ath_get_skb_tid(struct ath_softc *sc, struct ath_node *an, struct sk_buff *skb)
112 + struct ieee80211_hdr *hdr;
115 + hdr = (struct ieee80211_hdr *) skb->data;
116 + if (ieee80211_is_data_qos(hdr->frame_control))
117 + tidno = ieee80211_get_qos_ctl(hdr)[0];
119 + tidno &= IEEE80211_QOS_CTL_TID_MASK;
120 + return ATH_AN_2_TID(an, tidno);
123 +static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
125 + return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
128 +static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
130 + struct sk_buff *skb;
132 + skb = __skb_dequeue(&tid->retry_q);
134 + skb = __skb_dequeue(&tid->buf_q);
139 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
141 struct ath_txq *txq = tid->ac->txq;
142 @@ -182,7 +212,7 @@ static void ath_tx_flush_tid(struct ath_
144 memset(&ts, 0, sizeof(ts));
146 - while ((skb = __skb_dequeue(&tid->buf_q))) {
147 + while ((skb = ath_tid_dequeue(tid))) {
148 fi = get_frame_info(skb);
151 @@ -195,7 +225,7 @@ static void ath_tx_flush_tid(struct ath_
156 + if (fi->baw_tracked) {
157 list_add_tail(&bf->list, &bf_head);
158 ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
159 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
160 @@ -232,13 +262,16 @@ static void ath_tx_update_baw(struct ath
163 static void ath_tx_addto_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
165 + struct ath_buf *bf)
167 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
168 + u16 seqno = bf->bf_state.seqno;
171 index = ATH_BA_INDEX(tid->seq_start, seqno);
172 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
173 __set_bit(cindex, tid->tx_buf);
174 + fi->baw_tracked = 1;
176 if (index >= ((tid->baw_tail - tid->baw_head) &
177 (ATH_TID_MAX_BUFS - 1))) {
178 @@ -266,7 +299,7 @@ static void ath_tid_drain(struct ath_sof
179 memset(&ts, 0, sizeof(ts));
180 INIT_LIST_HEAD(&bf_head);
182 - while ((skb = __skb_dequeue(&tid->buf_q))) {
183 + while ((skb = ath_tid_dequeue(tid))) {
184 fi = get_frame_info(skb);
187 @@ -403,7 +436,6 @@ static void ath_tx_complete_aggr(struct
188 struct ieee80211_tx_rate rates[4];
189 struct ath_frame_info *fi;
192 bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
195 @@ -440,8 +472,7 @@ static void ath_tx_complete_aggr(struct
198 an = (struct ath_node *)sta->drv_priv;
199 - tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
200 - tid = ATH_AN_2_TID(an, tidno);
201 + tid = ath_get_skb_tid(sc, an, skb);
202 seq_first = tid->seq_start;
203 isba = ts->ts_flags & ATH9K_TX_BA;
205 @@ -453,7 +484,7 @@ static void ath_tx_complete_aggr(struct
206 * Only BlockAcks have a TID and therefore normal Acks cannot be
209 - if (isba && tidno != ts->tid)
210 + if (isba && tid->tidno != ts->tid)
213 isaggr = bf_isaggr(bf);
214 @@ -489,7 +520,8 @@ static void ath_tx_complete_aggr(struct
215 tx_info = IEEE80211_SKB_CB(skb);
216 fi = get_frame_info(skb);
218 - if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
219 + if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
222 * Outside of the current BlockAck window,
223 * maybe part of a previous session
224 @@ -583,7 +615,7 @@ static void ath_tx_complete_aggr(struct
226 ieee80211_sta_set_buffered(sta, tid->tidno, true);
228 - skb_queue_splice(&bf_pending, &tid->buf_q);
229 + skb_queue_splice_tail(&bf_pending, &tid->retry_q);
231 ath_tx_queue_tid(txq, tid);
233 @@ -641,7 +673,7 @@ static void ath_tx_process_buffer(struct
235 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
237 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
239 ath_txq_schedule(sc, txq);
242 @@ -815,15 +847,20 @@ static int ath_compute_num_delims(struct
244 static struct ath_buf *
245 ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
246 - struct ath_atx_tid *tid)
247 + struct ath_atx_tid *tid, struct sk_buff_head **q)
249 + struct ieee80211_tx_info *tx_info;
250 struct ath_frame_info *fi;
256 - skb = skb_peek(&tid->buf_q);
257 + *q = &tid->retry_q;
258 + if (skb_queue_empty(*q))
261 + skb = skb_peek(*q);
265 @@ -833,12 +870,22 @@ ath_tx_get_tid_subframe(struct ath_softc
266 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
269 - __skb_unlink(skb, &tid->buf_q);
270 + __skb_unlink(skb, *q);
271 ath_txq_skb_done(sc, txq, skb);
272 ieee80211_free_txskb(sc->hw, skb);
276 + bf->bf_next = NULL;
277 + bf->bf_lastbf = bf;
279 + tx_info = IEEE80211_SKB_CB(skb);
280 + tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
281 + if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
282 + bf->bf_state.bf_type = 0;
286 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
287 seqno = bf->bf_state.seqno;
289 @@ -852,14 +899,12 @@ ath_tx_get_tid_subframe(struct ath_softc
291 INIT_LIST_HEAD(&bf_head);
292 list_add(&bf->list, &bf_head);
293 - __skb_unlink(skb, &tid->buf_q);
294 + __skb_unlink(skb, *q);
295 ath_tx_update_baw(sc, tid, seqno);
296 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
300 - bf->bf_next = NULL;
301 - bf->bf_lastbf = bf;
305 @@ -874,16 +919,17 @@ static enum ATH_AGGR_STATUS ath_tx_form_
307 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
308 struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
309 - int rl = 0, nframes = 0, ndelim, prev_al = 0;
310 + int nframes = 0, ndelim;
311 u16 aggr_limit = 0, al = 0, bpad = 0,
312 - al_delta, h_baw = tid->baw_size / 2;
313 + al_delta, h_baw = tid->baw_size / 2;
314 enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
315 struct ieee80211_tx_info *tx_info;
316 struct ath_frame_info *fi;
318 + struct sk_buff_head *tid_q;
321 - bf = ath_tx_get_tid_subframe(sc, txq, tid);
322 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
324 status = ATH_AGGR_BAW_CLOSED;
326 @@ -892,33 +938,24 @@ static enum ATH_AGGR_STATUS ath_tx_form_
328 fi = get_frame_info(skb);
335 ath_set_rates(tid->an->vif, tid->an->sta, bf);
336 aggr_limit = ath_lookup_rate(sc, bf, tid);
340 /* do not exceed aggregation limit */
341 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
343 + if (aggr_limit < al + bpad + al_delta ||
344 + ath_lookup_legacy(bf) || nframes >= h_baw) {
345 + status = ATH_AGGR_LIMITED;
350 - ((aggr_limit < (al + bpad + al_delta + prev_al)) ||
351 - ath_lookup_legacy(bf))) {
352 - status = ATH_AGGR_LIMITED;
356 - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
357 - if (nframes && (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE))
360 - /* do not exceed subframe limit */
361 - if (nframes >= min((int)h_baw, ATH_AMPDU_SUBFRAME_DEFAULT)) {
362 - status = ATH_AGGR_LIMITED;
364 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
365 + if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
369 /* add padding for previous frame to aggregation length */
370 @@ -936,18 +973,18 @@ static enum ATH_AGGR_STATUS ath_tx_form_
373 /* link buffers of this frame to the aggregate */
375 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
376 + if (!fi->baw_tracked)
377 + ath_tx_addto_baw(sc, tid, bf);
378 bf->bf_state.ndelim = ndelim;
380 - __skb_unlink(skb, &tid->buf_q);
381 + __skb_unlink(skb, tid_q);
382 list_add_tail(&bf->list, bf_q);
384 bf_prev->bf_next = bf;
388 - } while (!skb_queue_empty(&tid->buf_q));
389 + } while (ath_tid_has_buffered(tid));
393 @@ -1222,7 +1259,7 @@ static void ath_tx_sched_aggr(struct ath
397 - if (skb_queue_empty(&tid->buf_q))
398 + if (!ath_tid_has_buffered(tid))
401 INIT_LIST_HEAD(&bf_q);
402 @@ -1301,7 +1338,7 @@ void ath_tx_aggr_stop(struct ath_softc *
404 ath_txq_lock(sc, txq);
405 txtid->active = false;
406 - txtid->paused = true;
407 + txtid->paused = false;
408 ath_tx_flush_tid(sc, txtid);
409 ath_txq_unlock_complete(sc, txq);
411 @@ -1326,7 +1363,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
413 ath_txq_lock(sc, txq);
415 - buffered = !skb_queue_empty(&tid->buf_q);
416 + buffered = ath_tid_has_buffered(tid);
419 list_del(&tid->list);
420 @@ -1358,7 +1395,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
421 ath_txq_lock(sc, txq);
422 ac->clear_ps_filter = true;
424 - if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
425 + if (!tid->paused && ath_tid_has_buffered(tid)) {
426 ath_tx_queue_tid(txq, tid);
427 ath_txq_schedule(sc, txq);
429 @@ -1383,7 +1420,7 @@ void ath_tx_aggr_resume(struct ath_softc
430 tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
433 - if (!skb_queue_empty(&tid->buf_q)) {
434 + if (ath_tid_has_buffered(tid)) {
435 ath_tx_queue_tid(txq, tid);
436 ath_txq_schedule(sc, txq);
438 @@ -1403,6 +1440,7 @@ void ath9k_release_buffered_frames(struc
439 struct ieee80211_tx_info *info;
440 struct list_head bf_q;
441 struct ath_buf *bf_tail = NULL, *bf;
442 + struct sk_buff_head *tid_q;
446 @@ -1418,15 +1456,15 @@ void ath9k_release_buffered_frames(struc
449 ath_txq_lock(sc, tid->ac->txq);
450 - while (!skb_queue_empty(&tid->buf_q) && nframes > 0) {
451 - bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
452 + while (nframes > 0) {
453 + bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
457 - __skb_unlink(bf->bf_mpdu, &tid->buf_q);
458 + __skb_unlink(bf->bf_mpdu, tid_q);
459 list_add_tail(&bf->list, &bf_q);
460 ath_set_rates(tid->an->vif, tid->an->sta, bf);
461 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
462 + ath_tx_addto_baw(sc, tid, bf);
463 bf->bf_state.bf_type &= ~BUF_AGGR;
465 bf_tail->bf_next = bf;
466 @@ -1436,7 +1474,7 @@ void ath9k_release_buffered_frames(struc
468 TX_STAT_INC(txq->axq_qnum, a_queued_hw);
470 - if (skb_queue_empty(&tid->buf_q))
471 + if (!ath_tid_has_buffered(tid))
472 ieee80211_sta_set_buffered(an->sta, i, false);
474 ath_txq_unlock_complete(sc, tid->ac->txq);
475 @@ -1722,7 +1760,7 @@ void ath_txq_schedule(struct ath_softc *
476 * add tid to round-robin queue if more frames
477 * are pending for the tid
479 - if (!skb_queue_empty(&tid->buf_q))
480 + if (ath_tid_has_buffered(tid))
481 ath_tx_queue_tid(txq, tid);
483 if (tid == last_tid ||
484 @@ -1831,7 +1869,7 @@ static void ath_tx_send_ampdu(struct ath
485 * - seqno is not within block-ack window
486 * - h/w queue depth exceeds low water mark
488 - if ((!skb_queue_empty(&tid->buf_q) || tid->paused ||
489 + if ((ath_tid_has_buffered(tid) || tid->paused ||
490 !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
491 txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
492 txq != sc->tx.uapsdq) {
493 @@ -1859,7 +1897,7 @@ static void ath_tx_send_ampdu(struct ath
494 list_add(&bf->list, &bf_head);
496 /* Add sub-frame to BAW */
497 - ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
498 + ath_tx_addto_baw(sc, tid, bf);
500 /* Queue to h/w without aggregation */
501 TX_STAT_INC(txq->axq_qnum, a_queued_hw);
502 @@ -2066,7 +2104,6 @@ int ath_tx_start(struct ieee80211_hw *hw
503 struct ath_txq *txq = txctl->txq;
504 struct ath_atx_tid *tid = NULL;
510 @@ -2097,9 +2134,7 @@ int ath_tx_start(struct ieee80211_hw *hw
513 if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
514 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
515 - IEEE80211_QOS_CTL_TID_MASK;
516 - tid = ATH_AN_2_TID(txctl->an, tidno);
517 + tid = ath_get_skb_tid(sc, txctl->an, skb);
519 WARN_ON(tid->ac->txq != txctl->txq);
521 @@ -2372,8 +2407,7 @@ static void ath_tx_processq(struct ath_s
523 if (list_empty(&txq->axq_q)) {
524 txq->axq_link = NULL;
525 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
526 - ath_txq_schedule(sc, txq);
527 + ath_txq_schedule(sc, txq);
530 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
531 @@ -2595,6 +2629,7 @@ void ath_tx_node_init(struct ath_softc *
534 __skb_queue_head_init(&tid->buf_q);
535 + __skb_queue_head_init(&tid->retry_q);
536 acno = TID_TO_WME_AC(tidno);
537 tid->ac = &an->ac[acno];
539 @@ -2602,6 +2637,7 @@ void ath_tx_node_init(struct ath_softc *
540 for (acno = 0, ac = &an->ac[acno];
541 acno < IEEE80211_NUM_ACS; acno++, ac++) {
543 + ac->clear_ps_filter = true;
544 ac->txq = sc->tx.txq_map[acno];
545 INIT_LIST_HEAD(&ac->tid_q);