1 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3 @@ -672,7 +672,7 @@ static void ath_tx_process_buffer(struct
5 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
7 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) && !flush)
9 ath_txq_schedule(sc, txq);
12 @@ -848,6 +848,7 @@ static struct ath_buf *
13 ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
14 struct ath_atx_tid *tid, struct sk_buff_head **q)
16 + struct ieee80211_tx_info *tx_info;
17 struct ath_frame_info *fi;
20 @@ -874,6 +875,16 @@ ath_tx_get_tid_subframe(struct ath_softc
27 + tx_info = IEEE80211_SKB_CB(skb);
28 + tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
29 + if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
30 + bf->bf_state.bf_type = 0;
34 bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR;
35 seqno = bf->bf_state.seqno;
37 @@ -893,58 +904,45 @@ ath_tx_get_tid_subframe(struct ath_softc
49 -static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc,
50 - struct ath_txq *txq,
51 - struct ath_atx_tid *tid,
52 - struct list_head *bf_q,
55 +ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
56 + struct ath_atx_tid *tid, struct list_head *bf_q,
57 + struct ath_buf *bf_first, struct sk_buff_head *tid_q,
60 #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
61 - struct ath_buf *bf, *bf_first = NULL, *bf_prev = NULL;
62 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
63 int nframes = 0, ndelim;
64 u16 aggr_limit = 0, al = 0, bpad = 0,
65 al_delta, h_baw = tid->baw_size / 2;
66 - enum ATH_AGGR_STATUS status = ATH_AGGR_DONE;
67 struct ieee80211_tx_info *tx_info;
68 struct ath_frame_info *fi;
70 - struct sk_buff_head *tid_q;
71 + bool closed = false;
74 - bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
76 - status = ATH_AGGR_BAW_CLOSED;
80 + aggr_limit = ath_lookup_rate(sc, bf, tid);
84 fi = get_frame_info(skb);
88 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
89 - aggr_limit = ath_lookup_rate(sc, bf, tid);
92 /* do not exceed aggregation limit */
93 al_delta = ATH_AGGR_DELIM_SZ + fi->framelen;
95 if (aggr_limit < al + bpad + al_delta ||
96 - ath_lookup_legacy(bf) || nframes >= h_baw) {
97 - status = ATH_AGGR_LIMITED;
98 + ath_lookup_legacy(bf) || nframes >= h_baw)
102 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
103 - if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE)
104 + if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
105 + !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
109 @@ -974,11 +972,26 @@ static enum ATH_AGGR_STATUS ath_tx_form_
113 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
118 } while (ath_tid_has_buffered(tid));
121 + bf->bf_lastbf = bf_prev;
123 + if (bf == bf_prev) {
124 + al = get_frame_info(bf->bf_mpdu)->framelen;
125 + bf->bf_state.bf_type = BUF_AMPDU;
127 + TX_STAT_INC(txq->axq_qnum, a_aggr);
137 @@ -1239,14 +1252,45 @@ static void ath_tx_fill_desc(struct ath_
142 +ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
143 + struct ath_atx_tid *tid, struct list_head *bf_q,
144 + struct ath_buf *bf_first, struct sk_buff_head *tid_q)
146 + struct ath_buf *bf = bf_first, *bf_prev = NULL;
147 + struct sk_buff *skb;
154 + __skb_unlink(skb, tid_q);
155 + list_add_tail(&bf->list, bf_q);
157 + bf_prev->bf_next = bf;
163 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
167 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
171 static void ath_tx_sched_aggr(struct ath_softc *sc, struct ath_txq *txq,
172 struct ath_atx_tid *tid)
175 - enum ATH_AGGR_STATUS status;
176 struct ieee80211_tx_info *tx_info;
177 + struct sk_buff_head *tid_q;
178 struct list_head bf_q;
181 + bool aggr, last = true;
184 if (!ath_tid_has_buffered(tid))
185 @@ -1254,38 +1298,31 @@ static void ath_tx_sched_aggr(struct ath
187 INIT_LIST_HEAD(&bf_q);
189 - status = ath_tx_form_aggr(sc, txq, tid, &bf_q, &aggr_len);
192 - * no frames picked up to be aggregated;
193 - * block-ack window is not open.
195 - if (list_empty(&bf_q))
196 + bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
200 - bf = list_first_entry(&bf_q, struct ath_buf, list);
201 - bf->bf_lastbf = list_entry(bf_q.prev, struct ath_buf, list);
202 tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
203 + aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
204 + if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
205 + (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH))
208 + ath_set_rates(tid->an->vif, tid->an->sta, bf);
210 + last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
213 + ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
215 if (tid->ac->clear_ps_filter) {
216 tid->ac->clear_ps_filter = false;
217 tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
219 - tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
222 - /* if only one frame, send as non-aggregate */
223 - if (bf == bf->bf_lastbf) {
224 - aggr_len = get_frame_info(bf->bf_mpdu)->framelen;
225 - bf->bf_state.bf_type = BUF_AMPDU;
227 - TX_STAT_INC(txq->axq_qnum, a_aggr);
230 ath_tx_fill_desc(sc, bf, txq, aggr_len);
231 ath_tx_txqaddbuf(sc, txq, &bf_q, false);
232 - } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
233 - status != ATH_AGGR_BAW_CLOSED);
237 int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
238 @@ -1844,58 +1881,6 @@ static void ath_tx_txqaddbuf(struct ath_
242 -static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_txq *txq,
243 - struct ath_atx_tid *tid, struct sk_buff *skb,
244 - struct ath_tx_control *txctl)
246 - struct ath_frame_info *fi = get_frame_info(skb);
247 - struct list_head bf_head;
248 - struct ath_buf *bf;
251 - * Do not queue to h/w when any of the following conditions is true:
252 - * - there are pending frames in software queue
253 - * - the TID is currently paused for ADDBA/BAR request
254 - * - seqno is not within block-ack window
255 - * - h/w queue depth exceeds low water mark
257 - if ((ath_tid_has_buffered(tid) || tid->paused ||
258 - !BAW_WITHIN(tid->seq_start, tid->baw_size, tid->seq_next) ||
259 - txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) &&
260 - txq != sc->tx.uapsdq) {
262 - * Add this frame to software queue for scheduling later
265 - TX_STAT_INC(txq->axq_qnum, a_queued_sw);
266 - __skb_queue_tail(&tid->buf_q, skb);
267 - if (!txctl->an || !txctl->an->sleeping)
268 - ath_tx_queue_tid(txq, tid);
272 - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
274 - ath_txq_skb_done(sc, txq, skb);
275 - ieee80211_free_txskb(sc->hw, skb);
279 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
280 - bf->bf_state.bf_type = BUF_AMPDU;
281 - INIT_LIST_HEAD(&bf_head);
282 - list_add(&bf->list, &bf_head);
284 - /* Add sub-frame to BAW */
285 - ath_tx_addto_baw(sc, tid, bf);
287 - /* Queue to h/w without aggregation */
288 - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
289 - bf->bf_lastbf = bf;
290 - ath_tx_fill_desc(sc, bf, txq, fi->framelen);
291 - ath_tx_txqaddbuf(sc, txq, &bf_head, false);
294 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
295 struct ath_atx_tid *tid, struct sk_buff *skb)
297 @@ -2121,20 +2106,25 @@ int ath_tx_start(struct ieee80211_hw *hw
298 ath_txq_unlock(sc, txq);
300 ath_txq_lock(sc, txq);
303 - if (txctl->an && ieee80211_is_data_qos(hdr->frame_control)) {
304 + } else if (txctl->an &&
305 + ieee80211_is_data_present(hdr->frame_control)) {
306 tid = ath_get_skb_tid(sc, txctl->an, skb);
308 WARN_ON(tid->ac->txq != txctl->txq);
311 - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
312 + if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
313 + tid->ac->clear_ps_filter = true;
316 - * Try aggregation if it's a unicast data frame
317 - * and the destination is HT capable.
318 + * Add this frame to software queue for scheduling later
321 - ath_tx_send_ampdu(sc, txq, tid, skb, txctl);
322 + TX_STAT_INC(txq->axq_qnum, a_queued_sw);
323 + __skb_queue_tail(&tid->buf_q, skb);
324 + if (!txctl->an->sleeping)
325 + ath_tx_queue_tid(txq, tid);
327 + ath_txq_schedule(sc, txq);
331 @@ -2397,8 +2387,7 @@ static void ath_tx_processq(struct ath_s
333 if (list_empty(&txq->axq_q)) {
334 txq->axq_link = NULL;
335 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)
336 - ath_txq_schedule(sc, txq);
337 + ath_txq_schedule(sc, txq);
340 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
341 @@ -2628,6 +2617,7 @@ void ath_tx_node_init(struct ath_softc *
342 for (acno = 0, ac = &an->ac[acno];
343 acno < IEEE80211_NUM_ACS; acno++, ac++) {
345 + ac->clear_ps_filter = true;
346 ac->txq = sc->tx.txq_map[acno];
347 INIT_LIST_HEAD(&ac->tid_q);
349 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
350 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
351 @@ -137,6 +137,8 @@ int ath_descdma_setup(struct ath_softc *
352 #define ATH_AGGR_ENCRYPTDELIM 10
353 /* minimum h/w qdepth to be sustained to maximize aggregation */
354 #define ATH_AGGR_MIN_QDEPTH 2
355 +/* minimum h/w qdepth for non-aggregated traffic */
356 +#define ATH_NON_AGGR_MIN_QDEPTH 8
358 #define IEEE80211_SEQ_SEQ_SHIFT 4
359 #define IEEE80211_SEQ_MAX 4096
360 @@ -173,12 +175,6 @@ int ath_descdma_setup(struct ath_softc *
362 #define ATH_TX_COMPLETE_POLL_INT 1000
364 -enum ATH_AGGR_STATUS {
366 - ATH_AGGR_BAW_CLOSED,
370 #define ATH_TXFIFO_DEPTH 8
372 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
373 --- a/drivers/net/wireless/ath/ath9k/main.c
374 +++ b/drivers/net/wireless/ath/ath9k/main.c
375 @@ -1403,9 +1403,6 @@ static void ath9k_sta_notify(struct ieee
376 struct ath_softc *sc = hw->priv;
377 struct ath_node *an = (struct ath_node *) sta->drv_priv;
379 - if (!sta->ht_cap.ht_supported)
383 case STA_NOTIFY_SLEEP: