1 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3 @@ -198,6 +198,41 @@ static struct sk_buff *ath_tid_dequeue(s
8 + * ath_tx_tid_change_state:
9 + * - clears a-mpdu flag of previous session
10 + * - force sequence number allocation to fix next BlockAck Window
13 +ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
15 + struct ath_txq *txq = tid->ac->txq;
16 + struct ieee80211_tx_info *tx_info;
17 + struct sk_buff *skb, *tskb;
19 + struct ath_frame_info *fi;
21 + skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
22 + fi = get_frame_info(skb);
25 + tx_info = IEEE80211_SKB_CB(skb);
26 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
31 + bf = ath_tx_setup_buffer(sc, txq, tid, skb);
33 + __skb_unlink(skb, &tid->buf_q);
34 + ath_txq_skb_done(sc, txq, skb);
35 + ieee80211_free_txskb(sc->hw, skb);
42 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
44 struct ath_txq *txq = tid->ac->txq;
45 @@ -212,28 +247,22 @@ static void ath_tx_flush_tid(struct ath_
47 memset(&ts, 0, sizeof(ts));
49 - while ((skb = ath_tid_dequeue(tid))) {
50 + while ((skb = __skb_dequeue(&tid->retry_q))) {
51 fi = get_frame_info(skb);
55 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
57 - ath_txq_skb_done(sc, txq, skb);
58 - ieee80211_free_txskb(sc->hw, skb);
61 + ath_txq_skb_done(sc, txq, skb);
62 + ieee80211_free_txskb(sc->hw, skb);
66 if (fi->baw_tracked) {
67 - list_add_tail(&bf->list, &bf_head);
68 ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
69 - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
72 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
73 - ath_tx_send_normal(sc, txq, NULL, skb);
76 + list_add_tail(&bf->list, &bf_head);
77 + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
81 @@ -911,50 +940,39 @@ ath_tx_get_tid_subframe(struct ath_softc
85 -static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
86 - struct ath_txq *txq,
87 - struct ath_atx_tid *tid,
88 - struct list_head *bf_q,
91 +ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
92 + struct ath_atx_tid *tid, struct list_head *bf_q,
93 + struct ath_buf *bf_first, struct sk_buff_head *tid_q,
96 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
97 - struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
98 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
99 int nframes = 0, ndelim;
100 u16 aggr_limit = 0, al = 0, bpad = 0,
101 al_delta, h_baw = tid->baw_size / 2;
102 - enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
103 struct ieee80211_tx_info *tx_info;
104 struct ath_frame_info *fi;
106 - struct sk_buff_head *tid_q;
107 + bool closed = false;
110 - bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
112 - status = ATH_AGGR_BAW_CLOSED;
116 + aggr_limit = ath_lookup_rate(sc, bf, tid);
120 fi = get_frame_info(skb);
124 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
125 - aggr_limit = ath_lookup_rate(sc, bf, tid);
128 /* do not exceed aggregation limit */
129 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
131 if (aggr_limit < al + bpad + al_delta ||
132 - ath_lookup_legacy(bf) || nframes >= h_baw) {
133 - status = ATH_AGGR_LIMITED;
134 + ath_lookup_legacy(bf) || nframes >= h_baw)
138 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
139 - if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
140 + if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
141 + !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
145 @@ -984,11 +1002,26 @@ static enum ATH_AGGR_STATUS ath_tx_form_
149 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
154 } while (ath_tid_has_buffered(tid));
157 + bf->bf_lastbf = bf_prev;
159 + if (bf == bf_prev) {
160 + al = get_frame_info(bf->bf_mpdu)->framelen;
161 + bf->bf_state.bf_type = BUF_AMPDU;
163 + TX_STAT_INC(txq->axq_qnum, a_aggr);
173 @@ -1249,14 +1282,50 @@ static void ath_tx_fill_desc(struct ath_
178 +ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
179 + struct ath_atx_tid *tid, struct list_head *bf_q,
180 + struct ath_buf *bf_first, struct sk_buff_head *tid_q)
182 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
183 + struct sk_buff *skb;
187 + struct ieee80211_tx_info *tx_info;
191 + __skb_unlink(skb, tid_q);
192 + list_add_tail(&bf->list, bf_q);
194 + bf_prev->bf_next = bf;
200 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
204 + tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
205 + if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
208 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
212 static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
213 struct ath_atx_tid *tid)
216 - enum ATH_AGGR_STATUS status;
217 struct ieee80211_tx_info *tx_info;
218 + struct sk_buff_head *tid_q;
219 struct list_head bf_q;
222 + bool aggr, last = true;
225 if (!ath_tid_has_buffered(tid))
226 @@ -1264,38 +1333,34 @@ static void ath_tx_sched_aggr(struct ath
228 INIT_LIST_HEAD(&bf_q);
230 - status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
233 - * no frames picked up to be aggregated;
234 - * block-ack window is not open.
236 - if (list_empty(&bf_q))
237 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
241 - bf = list_first_entry(&bf_q, struct ath_buf, list);
242 - bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
243 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
244 + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
245 + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
246 + (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH))
249 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
251 + last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
254 + ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
256 + if (list_empty(&bf_q))
259 if (tid->ac->clear_ps_filter) {
260 tid->ac->clear_ps_filter = false;
261 tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
263 - tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
266 - /* if only one frame, send as non-aggregate */
267 - if (bf == bf->bf_lastbf) {
268 - aggr_len = get_frame_info(bf->bf_mpdu)->framelen;
269 - bf->bf_state.bf_type = BUF_AMPDU;
271 - TX_STAT_INC(txq->axq_qnum, a_aggr);
274 ath_tx_fill_desc(sc, bf, txq, aggr_len);
275 ath_tx_txqaddbuf(sc, txq, &bf_q, false);
276 - } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
277 - status != ATH_AGGR_BAW_CLOSED);
281 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
282 @@ -1319,6 +1384,9 @@ int ath_tx_aggr_start(struct ath_softc *
283 an->mpdudensity = density;
286 + /* force sequence number allocation for pending frames */
287 + ath_tx_tid_change_state(sc, txtid);
289 txtid->active = true;
290 txtid->paused = true;
291 *ssn = txtid->seq_start = txtid->seq_next;
292 @@ -1340,6 +1408,7 @@ void ath_tx_aggr_stop(struct ath_softc *
293 txtid->active = false;
294 txtid->paused = false;
295 ath_tx_flush_tid(sc, txtid);
296 + ath_tx_tid_change_state(sc, txtid);
297 ath_txq_unlock_complete(sc, txq);
300 @@ -1854,58 +1923,6 @@ static void ath_tx_txqaddbuf(struct ath_
304 -static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
305 - struct ath_atx_tid *tid, struct sk_buff *skb,
306 - struct ath_tx_control *txctl)
308 - struct ath_frame_info *fi = get_frame_info(skb);
309 - struct list_head bf_head;
310 - struct ath_buf *bf;
313 - * Do not queue to h/w when any of the following conditions is true:
314 - * - there are pending frames in software queue
315 - * - the TID is currently paused for ADDBA/BAR request
316 - * - seqno is not within block-ack window
317 - * - h/w queue depth exceeds low water mark
319 - if ((ath_tid_has_buffered(tid) || tid->paused ||
320 - !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
321 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
322 - txq != sc->tx.uapsdq) {
324 - * Add this frame to software queue for scheduling later
327 - TX_STAT_INC(txq->axq_qnum, a_queued_sw);
328 - __skb_queue_tail(&tid->buf_q, skb);
329 - if (!txctl->an || !txctl->an->sleeping)
330 - ath_tx_queue_tid(txq, tid);
334 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
336 - ath_txq_skb_done(sc, txq, skb);
337 - ieee80211_free_txskb(sc->hw, skb);
341 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
342 - bf->bf_state.bf_type = BUF_AMPDU;
343 - INIT_LIST_HEAD(&bf_head);
344 - list_add(&bf->list, &bf_head);
346 - /* Add sub-frame to BAW */
347 - ath_tx_addto_baw(sc, tid, bf);
349 - /* Queue to h/w without aggregation */
350 - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
351 - bf->bf_lastbf = bf;
352 - ath_tx_fill_desc(sc, bf, txq, fi->framelen);
353 - ath_tx_txqaddbuf(sc, txq, &bf_head, false);
356 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
357 struct ath_atx_tid *tid, struct sk_buff *skb)
359 @@ -2131,20 +2148,25 @@ int ath_tx_start(struct ieee80211_hw *hw
360 ath_txq_unlock(sc, txq);
362 ath_txq_lock(sc, txq);
365 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
366 + } else if (txctl->an &&
367 + ieee80211_is_data_present(hdr->frame_control)) {
368 tid = ath_get_skb_tid(sc, txctl->an, skb);
370 WARN_ON(tid->ac->txq != txctl->txq);
373 - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
374 + if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
375 + tid->ac->clear_ps_filter = true;
378 - * Try aggregation if it's a unicast data frame
379 - * and the destination is HT capable.
380 + * Add this frame to software queue for scheduling later
383 - ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
384 + TX_STAT_INC(txq->axq_qnum, a_queued_sw);
385 + __skb_queue_tail(&tid->buf_q, skb);
386 + if (!txctl->an->sleeping)
387 + ath_tx_queue_tid(txq, tid);
389 + ath_txq_schedule(sc, txq);
393 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
394 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
395 @@ -137,6 +137,8 @@ int ath_descdma_setup(struct ath_softc *
396 #define ATH_AGGR_ENCRYPTDELIM 10
397 /* minimum h/w qdepth to be sustained to maximize aggregation */
398 #define ATH_AGGR_MIN_QDEPTH 2
399 +/* minimum h/w qdepth for non-aggregated traffic */
400 +#define ATH_NON_AGGR_MIN_QDEPTH 8
402 #define IEEE80211_SEQ_SEQ_SHIFT 4
403 #define IEEE80211_SEQ_MAX 4096
404 @@ -173,12 +175,6 @@ int ath_descdma_setup(struct ath_softc *
406 #define ATH_TX_COMPLETE_POLL_INT 1000
408 -enum ATH_AGGR_STATUS {
410 - ATH_AGGR_BAW_CLOSED,
414 #define ATH_TXFIFO_DEPTH 8
416 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */