1 --- a/drivers/net/wireless/ath/ath9k/hw.h
2 +++ b/drivers/net/wireless/ath/ath9k/hw.h
3 @@ -603,7 +603,6 @@ struct ath_hw_ops {
5 void (*rx_enable)(struct ath_hw *ah);
6 void (*set_desc_link)(void *ds, u32 link);
7 - void (*get_desc_link)(void *ds, u32 **link);
8 bool (*calibrate)(struct ath_hw *ah,
9 struct ath9k_channel *chan,
11 --- a/drivers/net/wireless/ath/ath9k/main.c
12 +++ b/drivers/net/wireless/ath/ath9k/main.c
13 @@ -62,8 +62,6 @@ static bool ath9k_has_pending_frames(str
15 if (txq->axq_depth || !list_empty(&txq->axq_acq))
17 - else if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
18 - pending = !list_empty(&txq->txq_fifo_pending);
20 spin_unlock_bh(&txq->axq_lock);
22 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
23 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
24 @@ -28,11 +28,6 @@ static void ar9002_hw_set_desc_link(void
25 ((struct ath_desc*) ds)->ds_link = ds_link;
28 -static void ar9002_hw_get_desc_link(void *ds, u32 **ds_link)
30 - *ds_link = &((struct ath_desc *)ds)->ds_link;
33 static bool ar9002_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
36 @@ -437,7 +432,6 @@ void ar9002_hw_attach_mac_ops(struct ath
38 ops->rx_enable = ar9002_hw_rx_enable;
39 ops->set_desc_link = ar9002_hw_set_desc_link;
40 - ops->get_desc_link = ar9002_hw_get_desc_link;
41 ops->get_isr = ar9002_hw_get_isr;
42 ops->fill_txdesc = ar9002_hw_fill_txdesc;
43 ops->proc_txdesc = ar9002_hw_proc_txdesc;
44 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
45 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
46 @@ -43,13 +43,6 @@ static void ar9003_hw_set_desc_link(void
47 ads->ctl10 |= ar9003_calc_ptr_chksum(ads);
50 -static void ar9003_hw_get_desc_link(void *ds, u32 **ds_link)
52 - struct ar9003_txc *ads = ds;
54 - *ds_link = &ads->link;
57 static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
60 @@ -498,7 +491,6 @@ void ar9003_hw_attach_mac_ops(struct ath
62 ops->rx_enable = ar9003_hw_rx_enable;
63 ops->set_desc_link = ar9003_hw_set_desc_link;
64 - ops->get_desc_link = ar9003_hw_get_desc_link;
65 ops->get_isr = ar9003_hw_get_isr;
66 ops->fill_txdesc = ar9003_hw_fill_txdesc;
67 ops->proc_txdesc = ar9003_hw_proc_txdesc;
68 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
69 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
70 @@ -179,7 +179,7 @@ enum ATH_AGGR_STATUS {
72 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */
73 u32 axq_qnum; /* ath9k hardware queue number */
76 struct list_head axq_q;
79 @@ -188,7 +188,6 @@ struct ath_txq {
80 bool axq_tx_inprogress;
81 struct list_head axq_acq;
82 struct list_head txq_fifo[ATH_TXFIFO_DEPTH];
83 - struct list_head txq_fifo_pending;
87 --- a/drivers/net/wireless/ath/ath9k/debug.c
88 +++ b/drivers/net/wireless/ath/ath9k/debug.c
89 @@ -550,6 +550,7 @@ static ssize_t read_file_xmit(struct fil
91 PR("MPDUs Queued: ", queued);
92 PR("MPDUs Completed: ", completed);
93 + PR("MPDUs XRetried: ", xretries);
94 PR("Aggregates: ", a_aggr);
95 PR("AMPDUs Queued HW:", a_queued_hw);
96 PR("AMPDUs Queued SW:", a_queued_sw);
97 @@ -587,7 +588,6 @@ static ssize_t read_file_xmit(struct fil
99 PRQLE("axq_q empty: ", axq_q);
100 PRQLE("axq_acq empty: ", axq_acq);
101 - PRQLE("txq_fifo_pending: ", txq_fifo_pending);
102 for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
103 snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
104 PRQLE(tmp, txq_fifo[i]);
105 @@ -807,7 +807,10 @@ void ath_debug_stat_tx(struct ath_softc
107 TX_STAT_INC(qnum, a_completed);
109 - TX_STAT_INC(qnum, completed);
110 + if (bf_isxretried(bf))
111 + TX_STAT_INC(qnum, xretries);
113 + TX_STAT_INC(qnum, completed);
116 if (ts->ts_status & ATH9K_TXERR_FIFO)
117 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
118 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
119 @@ -39,11 +39,6 @@ static inline void ath9k_hw_set_desc_lin
120 ath9k_hw_ops(ah)->set_desc_link(ds, link);
123 -static inline void ath9k_hw_get_desc_link(struct ath_hw *ah, void *ds,
126 - ath9k_hw_ops(ah)->get_desc_link(ds, link);
128 static inline bool ath9k_hw_calibrate(struct ath_hw *ah,
129 struct ath9k_channel *chan,
131 --- a/drivers/net/wireless/ath/ath9k/xmit.c
132 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
133 @@ -53,7 +53,7 @@ static void ath_tx_complete_buf(struct a
134 struct ath_txq *txq, struct list_head *bf_q,
135 struct ath_tx_status *ts, int txok, int sendbar);
136 static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
137 - struct list_head *head);
138 + struct list_head *head, bool internal);
139 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, int len);
140 static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
141 struct ath_tx_status *ts, int nframes, int nbad,
142 @@ -377,8 +377,7 @@ static void ath_tx_complete_aggr(struct
143 bf_next = bf->bf_next;
145 bf->bf_state.bf_type |= BUF_XRETRY;
146 - if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) ||
147 - !bf->bf_stale || bf_next != NULL)
148 + if (!bf->bf_stale || bf_next != NULL)
149 list_move_tail(&bf->list, &bf_head);
151 ath_tx_rc_status(sc, bf, ts, 1, 1, 0, false);
152 @@ -463,20 +462,14 @@ static void ath_tx_complete_aggr(struct
156 - if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
159 - * Make sure the last desc is reclaimed if it
160 - * not a holding desc.
162 - if (!bf_last->bf_stale)
163 - list_move_tail(&bf->list, &bf_head);
165 - INIT_LIST_HEAD(&bf_head);
167 - BUG_ON(list_empty(bf_q));
169 + * Make sure the last desc is reclaimed if it
170 + * not a holding desc.
172 + if (!bf_last->bf_stale || bf_next != NULL)
173 list_move_tail(&bf->list, &bf_head);
176 + INIT_LIST_HEAD(&bf_head);
178 if (!txpending || (tid->state & AGGR_CLEANUP)) {
180 @@ -837,7 +830,7 @@ static void ath_tx_sched_aggr(struct ath
181 bf->bf_state.bf_type &= ~BUF_AGGR;
182 ath9k_hw_clr11n_aggr(sc->sc_ah, bf->bf_desc);
183 ath_buf_set_rate(sc, bf, fi->framelen);
184 - ath_tx_txqaddbuf(sc, txq, &bf_q);
185 + ath_tx_txqaddbuf(sc, txq, &bf_q, false);
189 @@ -849,7 +842,7 @@ static void ath_tx_sched_aggr(struct ath
190 /* anchor last desc of aggregate */
191 ath9k_hw_set11n_aggr_last(sc->sc_ah, bf->bf_lastbf->bf_desc);
193 - ath_tx_txqaddbuf(sc, txq, &bf_q);
194 + ath_tx_txqaddbuf(sc, txq, &bf_q, false);
195 TX_STAT_INC(txq->axq_qnum, a_aggr);
197 } while (txq->axq_ampdu_depth < ATH_AGGR_MIN_QDEPTH &&
198 @@ -1085,7 +1078,6 @@ struct ath_txq *ath_txq_setup(struct ath
199 txq->txq_headidx = txq->txq_tailidx = 0;
200 for (i = 0; i < ATH_TXFIFO_DEPTH; i++)
201 INIT_LIST_HEAD(&txq->txq_fifo[i]);
202 - INIT_LIST_HEAD(&txq->txq_fifo_pending);
204 return &sc->tx.txq[axq_qnum];
206 @@ -1155,13 +1147,8 @@ static bool bf_is_ampdu_not_probing(stru
207 return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE);
211 - * Drain a given TX queue (could be Beacon or Data)
213 - * This assumes output has been stopped and
214 - * we do not need to block ath_tx_tasklet.
216 -void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
217 +static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq,
218 + struct list_head *list, bool retry_tx)
220 struct ath_buf *bf, *lastbf;
221 struct list_head bf_head;
222 @@ -1170,93 +1157,63 @@ void ath_draintxq(struct ath_softc *sc,
223 memset(&ts, 0, sizeof(ts));
224 INIT_LIST_HEAD(&bf_head);
227 - spin_lock_bh(&txq->axq_lock);
228 + while (!list_empty(list)) {
229 + bf = list_first_entry(list, struct ath_buf, list);
231 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
232 - if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
233 - txq->txq_headidx = txq->txq_tailidx = 0;
234 - spin_unlock_bh(&txq->axq_lock);
237 - bf = list_first_entry(&txq->txq_fifo[txq->txq_tailidx],
238 - struct ath_buf, list);
241 - if (list_empty(&txq->axq_q)) {
242 - txq->axq_link = NULL;
243 - spin_unlock_bh(&txq->axq_lock);
246 - bf = list_first_entry(&txq->axq_q, struct ath_buf,
249 - if (bf->bf_stale) {
250 - list_del(&bf->list);
251 - spin_unlock_bh(&txq->axq_lock);
252 + if (bf->bf_stale) {
253 + list_del(&bf->list);
255 - ath_tx_return_buffer(sc, bf);
258 + ath_tx_return_buffer(sc, bf);
262 lastbf = bf->bf_lastbf;
264 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
265 - list_cut_position(&bf_head,
266 - &txq->txq_fifo[txq->txq_tailidx],
268 - INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH);
270 - /* remove ath_buf's of the same mpdu from txq */
271 - list_cut_position(&bf_head, &txq->axq_q, &lastbf->list);
273 + list_cut_position(&bf_head, list, &lastbf->list);
276 if (bf_is_ampdu_not_probing(bf))
277 txq->axq_ampdu_depth--;
278 - spin_unlock_bh(&txq->axq_lock);
280 + spin_unlock_bh(&txq->axq_lock);
282 ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, 0,
285 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
286 + spin_lock_bh(&txq->axq_lock);
291 + * Drain a given TX queue (could be Beacon or Data)
293 + * This assumes output has been stopped and
294 + * we do not need to block ath_tx_tasklet.
296 +void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
298 spin_lock_bh(&txq->axq_lock);
299 - txq->axq_tx_inprogress = false;
300 - spin_unlock_bh(&txq->axq_lock);
302 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
303 - spin_lock_bh(&txq->axq_lock);
304 - while (!list_empty(&txq->txq_fifo_pending)) {
305 - bf = list_first_entry(&txq->txq_fifo_pending,
306 - struct ath_buf, list);
307 - list_cut_position(&bf_head,
308 - &txq->txq_fifo_pending,
309 - &bf->bf_lastbf->list);
310 - spin_unlock_bh(&txq->axq_lock);
311 + int idx = txq->txq_tailidx;
313 - if (bf_isampdu(bf))
314 - ath_tx_complete_aggr(sc, txq, bf, &bf_head,
317 - ath_tx_complete_buf(sc, bf, txq, &bf_head,
319 - spin_lock_bh(&txq->axq_lock);
320 + while (!list_empty(&txq->txq_fifo[idx])) {
321 + ath_drain_txq_list(sc, txq, &txq->txq_fifo[idx],
324 + INCR(idx, ATH_TXFIFO_DEPTH);
326 - spin_unlock_bh(&txq->axq_lock);
327 + txq->txq_tailidx = idx;
330 + txq->axq_link = NULL;
331 + txq->axq_tx_inprogress = false;
332 + ath_drain_txq_list(sc, txq, &txq->axq_q, retry_tx);
334 /* flush any pending frames if aggregation is enabled */
335 - if (sc->sc_flags & SC_OP_TXAGGR) {
337 - spin_lock_bh(&txq->axq_lock);
338 - ath_txq_drain_pending_buffers(sc, txq);
339 - spin_unlock_bh(&txq->axq_lock);
342 + if ((sc->sc_flags & SC_OP_TXAGGR) && !retry_tx)
343 + ath_txq_drain_pending_buffers(sc, txq);
345 + spin_unlock_bh(&txq->axq_lock);
348 bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
349 @@ -1370,11 +1327,13 @@ void ath_txq_schedule(struct ath_softc *
350 * assume the descriptors are already chained together by caller.
352 static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
353 - struct list_head *head)
354 + struct list_head *head, bool internal)
356 struct ath_hw *ah = sc->sc_ah;
357 struct ath_common *common = ath9k_hw_common(ah);
358 - struct ath_buf *bf;
359 + struct ath_buf *bf, *bf_last;
360 + bool puttxbuf = false;
364 * Insert the frame on the outbound list and
365 @@ -1384,51 +1343,49 @@ static void ath_tx_txqaddbuf(struct ath_
366 if (list_empty(head))
369 + edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
370 bf = list_first_entry(head, struct ath_buf, list);
371 + bf_last = list_entry(head->prev, struct ath_buf, list);
373 ath_dbg(common, ATH_DBG_QUEUE,
374 "qnum: %d, txq depth: %d\n", txq->axq_qnum, txq->axq_depth);
376 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
377 - if (txq->axq_depth >= ATH_TXFIFO_DEPTH) {
378 - list_splice_tail_init(head, &txq->txq_fifo_pending);
381 - if (!list_empty(&txq->txq_fifo[txq->txq_headidx]))
382 - ath_dbg(common, ATH_DBG_XMIT,
383 - "Initializing tx fifo %d which is non-empty\n",
385 - INIT_LIST_HEAD(&txq->txq_fifo[txq->txq_headidx]);
386 - list_splice_init(head, &txq->txq_fifo[txq->txq_headidx]);
387 + if (edma && list_empty(&txq->txq_fifo[txq->txq_headidx])) {
388 + list_splice_tail_init(head, &txq->txq_fifo[txq->txq_headidx]);
389 INCR(txq->txq_headidx, ATH_TXFIFO_DEPTH);
390 - TX_STAT_INC(txq->axq_qnum, puttxbuf);
391 - ath9k_hw_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr);
392 - ath_dbg(common, ATH_DBG_XMIT, "TXDP[%u] = %llx (%p)\n",
393 - txq->axq_qnum, ito64(bf->bf_daddr), bf->bf_desc);
396 list_splice_tail_init(head, &txq->axq_q);
398 - if (txq->axq_link == NULL) {
399 - TX_STAT_INC(txq->axq_qnum, puttxbuf);
400 - ath9k_hw_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr);
401 - ath_dbg(common, ATH_DBG_XMIT, "TXDP[%u] = %llx (%p)\n",
402 - txq->axq_qnum, ito64(bf->bf_daddr),
405 - *txq->axq_link = bf->bf_daddr;
406 + if (txq->axq_link) {
407 + ath9k_hw_set_desc_link(ah, txq->axq_link, bf->bf_daddr);
408 ath_dbg(common, ATH_DBG_XMIT,
409 "link[%u] (%p)=%llx (%p)\n",
410 txq->axq_qnum, txq->axq_link,
411 ito64(bf->bf_daddr), bf->bf_desc);
413 - ath9k_hw_get_desc_link(ah, bf->bf_lastbf->bf_desc,
418 + txq->axq_link = bf_last->bf_desc;
422 + TX_STAT_INC(txq->axq_qnum, puttxbuf);
423 + ath9k_hw_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr);
424 + ath_dbg(common, ATH_DBG_XMIT, "TXDP[%u] = %llx (%p)\n",
425 + txq->axq_qnum, ito64(bf->bf_daddr), bf->bf_desc);
429 TX_STAT_INC(txq->axq_qnum, txstart);
430 ath9k_hw_txstart(ah, txq->axq_qnum);
433 - if (bf_is_ampdu_not_probing(bf))
434 - txq->axq_ampdu_depth++;
438 + if (bf_is_ampdu_not_probing(bf))
439 + txq->axq_ampdu_depth++;
443 static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_atx_tid *tid,
444 @@ -1470,7 +1427,7 @@ static void ath_tx_send_ampdu(struct ath
445 TX_STAT_INC(txctl->txq->axq_qnum, a_queued_hw);
447 ath_buf_set_rate(sc, bf, fi->framelen);
448 - ath_tx_txqaddbuf(sc, txctl->txq, &bf_head);
449 + ath_tx_txqaddbuf(sc, txctl->txq, &bf_head, false);
452 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
453 @@ -1490,7 +1447,7 @@ static void ath_tx_send_normal(struct at
455 fi = get_frame_info(bf->bf_mpdu);
456 ath_buf_set_rate(sc, bf, fi->framelen);
457 - ath_tx_txqaddbuf(sc, txq, bf_head);
458 + ath_tx_txqaddbuf(sc, txq, bf_head, false);
459 TX_STAT_INC(txq->axq_qnum, queued);
462 @@ -2077,6 +2034,38 @@ static void ath_tx_rc_status(struct ath_
463 tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1;
466 +static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
467 + struct ath_tx_status *ts, struct ath_buf *bf,
468 + struct list_head *bf_head)
473 + txok = !(ts->ts_status & ATH9K_TXERR_MASK);
474 + txq->axq_tx_inprogress = false;
475 + if (bf_is_ampdu_not_probing(bf))
476 + txq->axq_ampdu_depth--;
478 + spin_unlock_bh(&txq->axq_lock);
480 + if (!bf_isampdu(bf)) {
482 + * This frame is sent out as a single frame.
483 + * Use hardware retry status for this frame.
485 + if (ts->ts_status & ATH9K_TXERR_XRETRY)
486 + bf->bf_state.bf_type |= BUF_XRETRY;
487 + ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok, true);
488 + ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok, 0);
490 + ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok, true);
492 + spin_lock_bh(&txq->axq_lock);
494 + if (sc->sc_flags & SC_OP_TXAGGR)
495 + ath_txq_schedule(sc, txq);
498 static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
500 struct ath_hw *ah = sc->sc_ah;
501 @@ -2085,20 +2074,18 @@ static void ath_tx_processq(struct ath_s
502 struct list_head bf_head;
504 struct ath_tx_status ts;
508 ath_dbg(common, ATH_DBG_QUEUE, "tx queue %d (%x), link %p\n",
509 txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
512 + spin_lock_bh(&txq->axq_lock);
514 - spin_lock_bh(&txq->axq_lock);
515 if (list_empty(&txq->axq_q)) {
516 txq->axq_link = NULL;
517 if (sc->sc_flags & SC_OP_TXAGGR)
518 ath_txq_schedule(sc, txq);
519 - spin_unlock_bh(&txq->axq_lock);
522 bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
523 @@ -2114,13 +2101,11 @@ static void ath_tx_processq(struct ath_s
527 - if (list_is_last(&bf_held->list, &txq->axq_q)) {
528 - spin_unlock_bh(&txq->axq_lock);
529 + if (list_is_last(&bf_held->list, &txq->axq_q))
532 - bf = list_entry(bf_held->list.next,
533 - struct ath_buf, list);
536 + bf = list_entry(bf_held->list.next, struct ath_buf,
540 lastbf = bf->bf_lastbf;
541 @@ -2128,10 +2113,9 @@ static void ath_tx_processq(struct ath_s
543 memset(&ts, 0, sizeof(ts));
544 status = ath9k_hw_txprocdesc(ah, ds, &ts);
545 - if (status == -EINPROGRESS) {
546 - spin_unlock_bh(&txq->axq_lock);
547 + if (status == -EINPROGRESS)
551 TX_STAT_INC(txq->axq_qnum, txprocdesc);
554 @@ -2145,42 +2129,14 @@ static void ath_tx_processq(struct ath_s
555 list_cut_position(&bf_head,
556 &txq->axq_q, lastbf->list.prev);
559 - txok = !(ts.ts_status & ATH9K_TXERR_MASK);
560 - txq->axq_tx_inprogress = false;
563 list_del(&bf_held->list);
565 - if (bf_is_ampdu_not_probing(bf))
566 - txq->axq_ampdu_depth--;
568 - spin_unlock_bh(&txq->axq_lock);
571 ath_tx_return_buffer(sc, bf_held);
573 - if (!bf_isampdu(bf)) {
575 - * This frame is sent out as a single frame.
576 - * Use hardware retry status for this frame.
578 - if (ts.ts_status & ATH9K_TXERR_XRETRY)
579 - bf->bf_state.bf_type |= BUF_XRETRY;
580 - ath_tx_rc_status(sc, bf, &ts, 1, txok ? 0 : 1, txok, true);
583 - if (bf_isampdu(bf))
584 - ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, txok,
587 - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
589 - spin_lock_bh(&txq->axq_lock);
591 - if (sc->sc_flags & SC_OP_TXAGGR)
592 - ath_txq_schedule(sc, txq);
593 - spin_unlock_bh(&txq->axq_lock);
594 + ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
596 + spin_unlock_bh(&txq->axq_lock);
599 static void ath_tx_complete_poll_work(struct work_struct *work)
600 @@ -2237,17 +2193,16 @@ void ath_tx_tasklet(struct ath_softc *sc
602 void ath_tx_edma_tasklet(struct ath_softc *sc)
604 - struct ath_tx_status txs;
605 + struct ath_tx_status ts;
606 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
607 struct ath_hw *ah = sc->sc_ah;
609 struct ath_buf *bf, *lastbf;
610 struct list_head bf_head;
615 - status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs);
616 + status = ath9k_hw_txprocdesc(ah, NULL, (void *)&ts);
617 if (status == -EINPROGRESS)
619 if (status == -EIO) {
620 @@ -2257,12 +2212,13 @@ void ath_tx_edma_tasklet(struct ath_soft
623 /* Skip beacon completions */
624 - if (txs.qid == sc->beacon.beaconq)
625 + if (ts.qid == sc->beacon.beaconq)
628 - txq = &sc->tx.txq[txs.qid];
629 + txq = &sc->tx.txq[ts.qid];
631 spin_lock_bh(&txq->axq_lock);
633 if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
634 spin_unlock_bh(&txq->axq_lock);
636 @@ -2275,41 +2231,21 @@ void ath_tx_edma_tasklet(struct ath_soft
637 INIT_LIST_HEAD(&bf_head);
638 list_cut_position(&bf_head, &txq->txq_fifo[txq->txq_tailidx],
640 - INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH);
642 - txq->axq_tx_inprogress = false;
643 - if (bf_is_ampdu_not_probing(bf))
644 - txq->axq_ampdu_depth--;
645 - spin_unlock_bh(&txq->axq_lock);
647 - txok = !(txs.ts_status & ATH9K_TXERR_MASK);
649 - if (!bf_isampdu(bf)) {
650 - if (txs.ts_status & ATH9K_TXERR_XRETRY)
651 - bf->bf_state.bf_type |= BUF_XRETRY;
652 - ath_tx_rc_status(sc, bf, &txs, 1, txok ? 0 : 1, txok, true);
655 - if (bf_isampdu(bf))
656 - ath_tx_complete_aggr(sc, txq, bf, &bf_head, &txs,
659 - ath_tx_complete_buf(sc, bf, txq, &bf_head,
661 + if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
662 + INCR(txq->txq_tailidx, ATH_TXFIFO_DEPTH);
664 - spin_lock_bh(&txq->axq_lock);
665 + if (!list_empty(&txq->axq_q)) {
666 + struct list_head bf_q;
668 - if (!list_empty(&txq->txq_fifo_pending)) {
669 - INIT_LIST_HEAD(&bf_head);
670 - bf = list_first_entry(&txq->txq_fifo_pending,
671 - struct ath_buf, list);
672 - list_cut_position(&bf_head,
673 - &txq->txq_fifo_pending,
674 - &bf->bf_lastbf->list);
675 - ath_tx_txqaddbuf(sc, txq, &bf_head);
676 - } else if (sc->sc_flags & SC_OP_TXAGGR)
677 - ath_txq_schedule(sc, txq);
678 + INIT_LIST_HEAD(&bf_q);
679 + txq->axq_link = NULL;
680 + list_splice_tail_init(&txq->axq_q, &bf_q);
681 + ath_tx_txqaddbuf(sc, txq, &bf_q, true);
685 + ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
686 spin_unlock_bh(&txq->axq_lock);
689 --- a/net/mac80211/agg-rx.c
690 +++ b/net/mac80211/agg-rx.c
691 @@ -161,6 +161,8 @@ static void ieee80211_send_addba_resp(st
692 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
693 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
694 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
695 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
696 + memcpy(mgmt->bssid, da, ETH_ALEN);
698 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
699 IEEE80211_STYPE_ACTION);
700 --- a/net/mac80211/agg-tx.c
701 +++ b/net/mac80211/agg-tx.c
702 @@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
703 memcpy(mgmt->da, da, ETH_ALEN);
704 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
705 if (sdata->vif.type == NL80211_IFTYPE_AP ||
706 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
707 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
708 + sdata->vif.type == NL80211_IFTYPE_WDS)
709 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
710 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
711 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
712 @@ -388,7 +389,8 @@ int ieee80211_start_tx_ba_session(struct
714 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
715 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
716 - sdata->vif.type != NL80211_IFTYPE_AP)
717 + sdata->vif.type != NL80211_IFTYPE_AP &&
718 + sdata->vif.type != NL80211_IFTYPE_WDS)
721 if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
722 --- a/net/mac80211/debugfs_sta.c
723 +++ b/net/mac80211/debugfs_sta.c
724 @@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
726 struct sta_info *sta = file->private_data;
727 u32 staflags = get_sta_flags(sta);
728 - int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
729 + int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
730 staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
731 staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
732 staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
733 @@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
734 staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
735 staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
736 staflags & WLAN_STA_WME ? "WME\n" : "",
737 - staflags & WLAN_STA_WDS ? "WDS\n" : "",
738 staflags & WLAN_STA_MFP ? "MFP\n" : "");
739 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
741 --- a/net/mac80211/iface.c
742 +++ b/net/mac80211/iface.c
743 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
745 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
746 struct ieee80211_local *local = sdata->local;
747 - struct sta_info *sta;
750 u32 hw_reconf_flags = 0;
751 @@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
753 set_bit(SDATA_STATE_RUNNING, &sdata->state);
755 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
756 - /* Create STA entry for the WDS peer */
757 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
761 - goto err_del_interface;
764 - /* no locking required since STA is not live yet */
765 - sta->flags |= WLAN_STA_AUTHORIZED;
767 - res = sta_info_insert(sta);
769 - /* STA has been freed */
770 - goto err_del_interface;
773 - rate_control_rate_init(sta);
777 * set_multicast_list will be invoked by the networking core
778 * which will check whether any increments here were done in
779 @@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
780 netif_tx_start_all_queues(dev);
784 - drv_remove_interface(local, &sdata->vif);
787 if (!local->open_count)
789 @@ -718,6 +695,70 @@ static void ieee80211_if_setup(struct ne
790 dev->destructor = free_netdev;
793 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
794 + struct sk_buff *skb)
796 + struct ieee80211_local *local = sdata->local;
797 + struct ieee80211_rx_status *rx_status;
798 + struct ieee802_11_elems elems;
799 + struct ieee80211_mgmt *mgmt;
800 + struct sta_info *sta;
805 + enum ieee80211_band band = local->hw.conf.channel->band;
806 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
808 + rx_status = IEEE80211_SKB_RXCB(skb);
809 + mgmt = (struct ieee80211_mgmt *) skb->data;
810 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
812 + if (stype != IEEE80211_STYPE_BEACON)
815 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
816 + if (baselen > skb->len)
819 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
820 + skb->len - baselen, &elems);
822 + rates = ieee80211_sta_get_rates(local, &elems, band);
826 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
830 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
838 + sta->last_rx = jiffies;
839 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
841 + if (elems.ht_cap_elem)
842 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
843 + elems.ht_cap_elem, &sta->sta.ht_cap);
845 + if (elems.wmm_param)
846 + set_sta_flags(sta, WLAN_STA_WME);
849 + sta->flags = WLAN_STA_AUTHORIZED;
850 + rate_control_rate_init(sta);
851 + sta_info_insert_rcu(sta);
857 static void ieee80211_iface_work(struct work_struct *work)
859 struct ieee80211_sub_if_data *sdata =
860 @@ -822,6 +863,9 @@ static void ieee80211_iface_work(struct
862 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
864 + case NL80211_IFTYPE_WDS:
865 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
868 WARN(1, "frame for unexpected interface type");
870 --- a/net/mac80211/rx.c
871 +++ b/net/mac80211/rx.c
872 @@ -2137,7 +2137,8 @@ ieee80211_rx_h_action(struct ieee80211_r
874 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
875 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
876 - sdata->vif.type != NL80211_IFTYPE_AP)
877 + sdata->vif.type != NL80211_IFTYPE_AP &&
878 + sdata->vif.type != NL80211_IFTYPE_WDS)
881 /* verify action_code is present */
882 @@ -2335,13 +2336,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
884 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
885 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
886 - sdata->vif.type != NL80211_IFTYPE_STATION)
887 + sdata->vif.type != NL80211_IFTYPE_STATION &&
888 + sdata->vif.type != NL80211_IFTYPE_WDS)
889 return RX_DROP_MONITOR;
892 case cpu_to_le16(IEEE80211_STYPE_BEACON):
893 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
894 - /* process for all: mesh, mlme, ibss */
895 + /* process for all: mesh, mlme, ibss, wds */
897 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
898 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
899 @@ -2680,10 +2682,16 @@ static int prepare_for_handlers(struct i
902 case NL80211_IFTYPE_WDS:
903 - if (bssid || !ieee80211_is_data(hdr->frame_control))
905 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
908 + if (ieee80211_is_data(hdr->frame_control) ||
909 + ieee80211_is_action(hdr->frame_control)) {
910 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
912 + } else if (!ieee80211_is_beacon(hdr->frame_control))
917 /* should never get here */
918 --- a/net/mac80211/sta_info.h
919 +++ b/net/mac80211/sta_info.h
922 * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
923 * @WLAN_STA_WME: Station is a QoS-STA.
924 - * @WLAN_STA_WDS: Station is one of our WDS peers.
925 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
926 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
927 * frame to this station is transmitted.
928 @@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
929 WLAN_STA_SHORT_PREAMBLE = 1<<4,
930 WLAN_STA_ASSOC_AP = 1<<5,
932 - WLAN_STA_WDS = 1<<7,
933 WLAN_STA_CLEAR_PS_FILT = 1<<9,
934 WLAN_STA_MFP = 1<<10,
935 WLAN_STA_BLOCK_BA = 1<<11,
936 --- a/drivers/net/wireless/ath/ath9k/debug.h
937 +++ b/drivers/net/wireless/ath/ath9k/debug.h
938 @@ -116,6 +116,7 @@ struct ath_tx_stats {
946 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
947 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
948 @@ -4645,10 +4645,16 @@ static void ar9003_hw_set_power_per_rate
952 - scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
953 + if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
954 + scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
959 - scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
960 + if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
961 + scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
967 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
968 +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
969 @@ -524,10 +524,16 @@ static void ath9k_hw_set_ar9287_power_pe
973 - scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
974 + if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
975 + scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
980 - scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
981 + if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
982 + scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
987 scaledPower = max((u16)0, scaledPower);