522c1ef9696a615e381b93ed396359ab2949bdae
[openwrt.git] / package / mac80211 / patches / 572-ath9k_xmit_queue_cleanup.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -195,7 +195,6 @@ enum ATH_AGGR_STATUS {
4  
5  #define ATH_TXFIFO_DEPTH 8
6  struct ath_txq {
7 -       int axq_class;
8         u32 axq_qnum;
9         u32 *axq_link;
10         struct list_head axq_q;
11 @@ -208,11 +207,12 @@ struct ath_txq {
12         struct list_head txq_fifo_pending;
13         u8 txq_headidx;
14         u8 txq_tailidx;
15 +       int pending_frames;
16  };
17  
18  struct ath_atx_ac {
19 +       struct ath_txq *txq;
20         int sched;
21 -       int qnum;
22         struct list_head list;
23         struct list_head tid_q;
24  };
25 @@ -290,12 +290,11 @@ struct ath_tx_control {
26  struct ath_tx {
27         u16 seq_no;
28         u32 txqsetup;
29 -       int hwq_map[WME_NUM_AC];
30         spinlock_t txbuflock;
31         struct list_head txbuf;
32         struct ath_txq txq[ATH9K_NUM_TX_QUEUES];
33         struct ath_descdma txdma;
34 -       int pending_frames[WME_NUM_AC];
35 +       struct ath_txq *txq_map[WME_NUM_AC];
36  };
37  
38  struct ath_rx_edma {
39 @@ -325,7 +324,6 @@ void ath_rx_cleanup(struct ath_softc *sc
40  int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp);
41  struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
42  void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
43 -int ath_tx_setup(struct ath_softc *sc, int haltype);
44  void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
45  void ath_draintxq(struct ath_softc *sc,
46                      struct ath_txq *txq, bool retry_tx);
47 @@ -665,7 +663,6 @@ struct ath_wiphy {
48  
49  void ath9k_tasklet(unsigned long data);
50  int ath_reset(struct ath_softc *sc, bool retry_tx);
51 -int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc);
52  int ath_cabq_update(struct ath_softc *);
53  
54  static inline void ath_read_cachesize(struct ath_common *common, int *csz)
55 --- a/drivers/net/wireless/ath/ath9k/beacon.c
56 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
57 @@ -28,7 +28,7 @@ int ath_beaconq_config(struct ath_softc 
58         struct ath_hw *ah = sc->sc_ah;
59         struct ath_common *common = ath9k_hw_common(ah);
60         struct ath9k_tx_queue_info qi, qi_be;
61 -       int qnum;
62 +       struct ath_txq *txq;
63  
64         ath9k_hw_get_txq_props(ah, sc->beacon.beaconq, &qi);
65         if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
66 @@ -38,8 +38,8 @@ int ath_beaconq_config(struct ath_softc 
67                 qi.tqi_cwmax = 0;
68         } else {
69                 /* Adhoc mode; important thing is to use 2x cwmin. */
70 -               qnum = sc->tx.hwq_map[WME_AC_BE];
71 -               ath9k_hw_get_txq_props(ah, qnum, &qi_be);
72 +               txq = sc->tx.txq_map[WME_AC_BE];
73 +               ath9k_hw_get_txq_props(ah, txq->axq_qnum, &qi_be);
74                 qi.tqi_aifs = qi_be.tqi_aifs;
75                 qi.tqi_cwmin = 4*qi_be.tqi_cwmin;
76                 qi.tqi_cwmax = qi_be.tqi_cwmax;
77 --- a/drivers/net/wireless/ath/ath9k/common.h
78 +++ b/drivers/net/wireless/ath/ath9k/common.h
79 @@ -31,10 +31,11 @@
80  #define WME_MAX_BA              WME_BA_BMP_SIZE
81  #define ATH_TID_MAX_BUFS        (2 * WME_MAX_BA)
82  
83 -#define WME_AC_BE   0
84 -#define WME_AC_BK   1
85 -#define WME_AC_VI   2
86 -#define WME_AC_VO   3
87 +/* These must match mac80211 skb queue mapping numbers */
88 +#define WME_AC_VO   0
89 +#define WME_AC_VI   1
90 +#define WME_AC_BE   2
91 +#define WME_AC_BK   3
92  #define WME_NUM_AC  4
93  
94  #define ATH_RSSI_DUMMY_MARKER   0x127
95 --- a/drivers/net/wireless/ath/ath9k/main.c
96 +++ b/drivers/net/wireless/ath/ath9k/main.c
97 @@ -331,7 +331,7 @@ void ath_paprd_calibrate(struct work_str
98         struct ath_tx_control txctl;
99         struct ath9k_hw_cal_data *caldata = ah->caldata;
100         struct ath_common *common = ath9k_hw_common(ah);
101 -       int qnum, ftype;
102 +       int ftype;
103         int chain_ok = 0;
104         int chain;
105         int len = 1800;
106 @@ -358,8 +358,7 @@ void ath_paprd_calibrate(struct work_str
107         memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
108  
109         memset(&txctl, 0, sizeof(txctl));
110 -       qnum = sc->tx.hwq_map[WME_AC_BE];
111 -       txctl.txq = &sc->tx.txq[qnum];
112 +       txctl.txq = sc->tx.txq_map[WME_AC_BE];
113  
114         ath9k_ps_wakeup(sc);
115         ar9003_paprd_init_table(ah);
116 @@ -1025,56 +1024,6 @@ int ath_reset(struct ath_softc *sc, bool
117         return r;
118  }
119  
120 -static int ath_get_hal_qnum(u16 queue, struct ath_softc *sc)
121 -{
122 -       int qnum;
123 -
124 -       switch (queue) {
125 -       case 0:
126 -               qnum = sc->tx.hwq_map[WME_AC_VO];
127 -               break;
128 -       case 1:
129 -               qnum = sc->tx.hwq_map[WME_AC_VI];
130 -               break;
131 -       case 2:
132 -               qnum = sc->tx.hwq_map[WME_AC_BE];
133 -               break;
134 -       case 3:
135 -               qnum = sc->tx.hwq_map[WME_AC_BK];
136 -               break;
137 -       default:
138 -               qnum = sc->tx.hwq_map[WME_AC_BE];
139 -               break;
140 -       }
141 -
142 -       return qnum;
143 -}
144 -
145 -int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc)
146 -{
147 -       int qnum;
148 -
149 -       switch (queue) {
150 -       case WME_AC_VO:
151 -               qnum = 0;
152 -               break;
153 -       case WME_AC_VI:
154 -               qnum = 1;
155 -               break;
156 -       case WME_AC_BE:
157 -               qnum = 2;
158 -               break;
159 -       case WME_AC_BK:
160 -               qnum = 3;
161 -               break;
162 -       default:
163 -               qnum = -1;
164 -               break;
165 -       }
166 -
167 -       return qnum;
168 -}
169 -
170  /* XXX: Remove me once we don't depend on ath9k_channel for all
171   * this redundant data */
172  void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw,
173 @@ -1244,7 +1193,6 @@ static int ath9k_tx(struct ieee80211_hw 
174         struct ath_tx_control txctl;
175         int padpos, padsize;
176         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
177 -       int qnum;
178  
179         if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
180                 ath_print(common, ATH_DBG_XMIT,
181 @@ -1317,8 +1265,7 @@ static int ath9k_tx(struct ieee80211_hw 
182                 memmove(skb->data, skb->data + padsize, padpos);
183         }
184  
185 -       qnum = ath_get_hal_qnum(skb_get_queue_mapping(skb), sc);
186 -       txctl.txq = &sc->tx.txq[qnum];
187 +       txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
188  
189         ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
190  
191 @@ -1802,12 +1749,15 @@ static int ath9k_conf_tx(struct ieee8021
192         struct ath_wiphy *aphy = hw->priv;
193         struct ath_softc *sc = aphy->sc;
194         struct ath_common *common = ath9k_hw_common(sc->sc_ah);
195 +       struct ath_txq *txq;
196         struct ath9k_tx_queue_info qi;
197 -       int ret = 0, qnum;
198 +       int ret = 0;
199  
200         if (queue >= WME_NUM_AC)
201                 return 0;
202  
203 +       txq = sc->tx.txq_map[queue];
204 +
205         mutex_lock(&sc->mutex);
206  
207         memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
208 @@ -1816,20 +1766,19 @@ static int ath9k_conf_tx(struct ieee8021
209         qi.tqi_cwmin = params->cw_min;
210         qi.tqi_cwmax = params->cw_max;
211         qi.tqi_burstTime = params->txop;
212 -       qnum = ath_get_hal_qnum(queue, sc);
213  
214         ath_print(common, ATH_DBG_CONFIG,
215                   "Configure tx [queue/halq] [%d/%d],  "
216                   "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
217 -                 queue, qnum, params->aifs, params->cw_min,
218 +                 queue, txq->axq_qnum, params->aifs, params->cw_min,
219                   params->cw_max, params->txop);
220  
221 -       ret = ath_txq_update(sc, qnum, &qi);
222 +       ret = ath_txq_update(sc, txq->axq_qnum, &qi);
223         if (ret)
224                 ath_print(common, ATH_DBG_FATAL, "TXQ Update failed\n");
225  
226         if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)
227 -               if ((qnum == sc->tx.hwq_map[WME_AC_BE]) && !ret)
228 +               if (queue == WME_AC_BE && !ret)
229                         ath_beaconq_config(sc);
230  
231         mutex_unlock(&sc->mutex);
232 --- a/drivers/net/wireless/ath/ath9k/xmit.c
233 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
234 @@ -124,7 +124,7 @@ static void ath_tx_queue_tid(struct ath_
235  
236  static void ath_tx_resume_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
237  {
238 -       struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
239 +       struct ath_txq *txq = tid->ac->txq;
240  
241         WARN_ON(!tid->paused);
242  
243 @@ -142,7 +142,7 @@ unlock:
244  
245  static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
246  {
247 -       struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
248 +       struct ath_txq *txq = tid->ac->txq;
249         struct ath_buf *bf;
250         struct list_head bf_head;
251         struct ath_tx_status ts;
252 @@ -817,7 +817,7 @@ void ath_tx_aggr_stop(struct ath_softc *
253  {
254         struct ath_node *an = (struct ath_node *)sta->drv_priv;
255         struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid);
256 -       struct ath_txq *txq = &sc->tx.txq[txtid->ac->qnum];
257 +       struct ath_txq *txq = txtid->ac->txq;
258  
259         if (txtid->state & AGGR_CLEANUP)
260                 return;
261 @@ -888,10 +888,16 @@ struct ath_txq *ath_txq_setup(struct ath
262         struct ath_hw *ah = sc->sc_ah;
263         struct ath_common *common = ath9k_hw_common(ah);
264         struct ath9k_tx_queue_info qi;
265 +       static const int subtype_txq_to_hwq[] = {
266 +               [WME_AC_BE] = ATH_TXQ_AC_BE,
267 +               [WME_AC_BK] = ATH_TXQ_AC_BK,
268 +               [WME_AC_VI] = ATH_TXQ_AC_VI,
269 +               [WME_AC_VO] = ATH_TXQ_AC_VO,
270 +       };
271         int qnum, i;
272  
273         memset(&qi, 0, sizeof(qi));
274 -       qi.tqi_subtype = subtype;
275 +       qi.tqi_subtype = subtype_txq_to_hwq[subtype];
276         qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT;
277         qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
278         qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT;
279 @@ -940,7 +946,6 @@ struct ath_txq *ath_txq_setup(struct ath
280         if (!ATH_TXQ_SETUP(sc, qnum)) {
281                 struct ath_txq *txq = &sc->tx.txq[qnum];
282  
283 -               txq->axq_class = subtype;
284                 txq->axq_qnum = qnum;
285                 txq->axq_link = NULL;
286                 INIT_LIST_HEAD(&txq->axq_q);
287 @@ -1210,24 +1215,6 @@ void ath_txq_schedule(struct ath_softc *
288         }
289  }
290  
291 -int ath_tx_setup(struct ath_softc *sc, int haltype)
292 -{
293 -       struct ath_txq *txq;
294 -
295 -       if (haltype >= ARRAY_SIZE(sc->tx.hwq_map)) {
296 -               ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
297 -                         "HAL AC %u out of range, max %zu!\n",
298 -                        haltype, ARRAY_SIZE(sc->tx.hwq_map));
299 -               return 0;
300 -       }
301 -       txq = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, haltype);
302 -       if (txq != NULL) {
303 -               sc->tx.hwq_map[haltype] = txq->axq_qnum;
304 -               return 1;
305 -       } else
306 -               return 0;
307 -}
308 -
309  /***********/
310  /* TX, DMA */
311  /***********/
312 @@ -1747,6 +1734,7 @@ int ath_tx_start(struct ieee80211_hw *hw
313                 return -1;
314         }
315  
316 +       q = skb_get_queue_mapping(skb);
317         r = ath_tx_setup_buffer(hw, bf, skb, txctl);
318         if (unlikely(r)) {
319                 ath_print(common, ATH_DBG_FATAL, "TX mem alloc failure\n");
320 @@ -1756,8 +1744,9 @@ int ath_tx_start(struct ieee80211_hw *hw
321                  * we will at least have to run TX completionon one buffer
322                  * on the queue */
323                 spin_lock_bh(&txq->axq_lock);
324 -               if (!txq->stopped && txq->axq_depth > 1) {
325 -                       ath_mac80211_stop_queue(sc, skb_get_queue_mapping(skb));
326 +               if (txq == sc->tx.txq_map[q] && !txq->stopped &&
327 +                   txq->axq_depth > 1) {
328 +                       ath_mac80211_stop_queue(sc, q);
329                         txq->stopped = 1;
330                 }
331                 spin_unlock_bh(&txq->axq_lock);
332 @@ -1767,13 +1756,10 @@ int ath_tx_start(struct ieee80211_hw *hw
333                 return r;
334         }
335  
336 -       q = skb_get_queue_mapping(skb);
337 -       if (q >= 4)
338 -               q = 0;
339 -
340         spin_lock_bh(&txq->axq_lock);
341 -       if (++sc->tx.pending_frames[q] > ATH_MAX_QDEPTH && !txq->stopped) {
342 -               ath_mac80211_stop_queue(sc, skb_get_queue_mapping(skb));
343 +       if (txq == sc->tx.txq_map[q] &&
344 +           ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
345 +               ath_mac80211_stop_queue(sc, q);
346                 txq->stopped = 1;
347         }
348         spin_unlock_bh(&txq->axq_lock);
349 @@ -1887,12 +1873,12 @@ static void ath_tx_complete(struct ath_s
350         if (unlikely(tx_info->pad[0] & ATH_TX_INFO_FRAME_TYPE_INTERNAL))
351                 ath9k_tx_status(hw, skb);
352         else {
353 -               q = skb_get_queue_mapping(skb);
354 -               if (q >= 4)
355 -                       q = 0;
356 +               struct ath_txq *txq;
357  
358 -               if (--sc->tx.pending_frames[q] < 0)
359 -                       sc->tx.pending_frames[q] = 0;
360 +               q = skb_get_queue_mapping(skb);
361 +               txq = sc->tx.txq_map[q];
362 +               if (--txq->pending_frames < 0)
363 +                       txq->pending_frames = 0;
364  
365                 ieee80211_tx_status(hw, skb);
366         }
367 @@ -1927,7 +1913,7 @@ static void ath_tx_complete_buf(struct a
368                 else
369                         complete(&sc->paprd_complete);
370         } else {
371 -               ath_debug_stat_tx(sc, txq, bf, ts);
372 +               ath_debug_stat_tx(sc, bf, ts);
373                 ath_tx_complete(sc, skb, bf->aphy, tx_flags);
374         }
375         /* At this point, skb (bf->bf_mpdu) is consumed...make sure we don't
376 @@ -2018,16 +2004,13 @@ static void ath_tx_rc_status(struct ath_
377         tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1;
378  }
379  
380 -static void ath_wake_mac80211_queue(struct ath_softc *sc, struct ath_txq *txq)
381 +static void ath_wake_mac80211_queue(struct ath_softc *sc, int qnum)
382  {
383 -       int qnum;
384 -
385 -       qnum = ath_get_mac80211_qnum(txq->axq_class, sc);
386 -       if (qnum == -1)
387 -               return;
388 +       struct ath_txq *txq;
389  
390 +       txq = sc->tx.txq_map[qnum];
391         spin_lock_bh(&txq->axq_lock);
392 -       if (txq->stopped && sc->tx.pending_frames[qnum] < ATH_MAX_QDEPTH) {
393 +       if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
394                 if (ath_mac80211_start_queue(sc, qnum))
395                         txq->stopped = 0;
396         }
397 @@ -2044,6 +2027,7 @@ static void ath_tx_processq(struct ath_s
398         struct ath_tx_status ts;
399         int txok;
400         int status;
401 +       int qnum;
402  
403         ath_print(common, ATH_DBG_QUEUE, "tx queue %d (%x), link %p\n",
404                   txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
405 @@ -2119,12 +2103,15 @@ static void ath_tx_processq(struct ath_s
406                         ath_tx_rc_status(bf, &ts, txok ? 0 : 1, txok, true);
407                 }
408  
409 +               qnum = skb_get_queue_mapping(bf->bf_mpdu);
410 +
411                 if (bf_isampdu(bf))
412                         ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, txok);
413                 else
414                         ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
415  
416 -               ath_wake_mac80211_queue(sc, txq);
417 +               if (txq == sc->tx.txq_map[qnum])
418 +                       ath_wake_mac80211_queue(sc, qnum);
419  
420                 spin_lock_bh(&txq->axq_lock);
421                 if (sc->sc_flags & SC_OP_TXAGGR)
422 @@ -2194,6 +2181,7 @@ void ath_tx_edma_tasklet(struct ath_soft
423         struct list_head bf_head;
424         int status;
425         int txok;
426 +       int qnum;
427  
428         for (;;) {
429                 status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs);
430 @@ -2237,13 +2225,16 @@ void ath_tx_edma_tasklet(struct ath_soft
431                         ath_tx_rc_status(bf, &txs, txok ? 0 : 1, txok, true);
432                 }
433  
434 +               qnum = skb_get_queue_mapping(bf->bf_mpdu);
435 +
436                 if (bf_isampdu(bf))
437                         ath_tx_complete_aggr(sc, txq, bf, &bf_head, &txs, txok);
438                 else
439                         ath_tx_complete_buf(sc, bf, txq, &bf_head,
440                                             &txs, txok, 0);
441  
442 -               ath_wake_mac80211_queue(sc, txq);
443 +               if (txq == sc->tx.txq_map[qnum])
444 +                       ath_wake_mac80211_queue(sc, qnum);
445  
446                 spin_lock_bh(&txq->axq_lock);
447                 if (!list_empty(&txq->txq_fifo_pending)) {
448 @@ -2375,7 +2366,7 @@ void ath_tx_node_init(struct ath_softc *
449         for (acno = 0, ac = &an->ac[acno];
450              acno < WME_NUM_AC; acno++, ac++) {
451                 ac->sched    = false;
452 -               ac->qnum = sc->tx.hwq_map[acno];
453 +               ac->txq = sc->tx.txq_map[acno];
454                 INIT_LIST_HEAD(&ac->tid_q);
455         }
456  }
457 @@ -2385,17 +2376,13 @@ void ath_tx_node_cleanup(struct ath_soft
458         struct ath_atx_ac *ac;
459         struct ath_atx_tid *tid;
460         struct ath_txq *txq;
461 -       int i, tidno;
462 +       int tidno;
463  
464         for (tidno = 0, tid = &an->tid[tidno];
465              tidno < WME_NUM_TID; tidno++, tid++) {
466 -               i = tid->ac->qnum;
467 -
468 -               if (!ATH_TXQ_SETUP(sc, i))
469 -                       continue;
470  
471 -               txq = &sc->tx.txq[i];
472                 ac = tid->ac;
473 +               txq = ac->txq;
474  
475                 spin_lock_bh(&txq->axq_lock);
476  
477 --- a/drivers/net/wireless/ath/ath9k/hw.h
478 +++ b/drivers/net/wireless/ath/ath9k/hw.h
479 @@ -157,6 +157,13 @@
480  #define PAPRD_GAIN_TABLE_ENTRIES    32
481  #define PAPRD_TABLE_SZ              24
482  
483 +enum ath_hw_txq_subtype {
484 +       ATH_TXQ_AC_BE = 0,
485 +       ATH_TXQ_AC_BK = 1,
486 +       ATH_TXQ_AC_VI = 2,
487 +       ATH_TXQ_AC_VO = 3,
488 +};
489 +
490  enum ath_ini_subsys {
491         ATH_INI_PRE = 0,
492         ATH_INI_CORE,
493 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
494 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
495 @@ -20,8 +20,15 @@
496  /* TX */
497  /******/
498  
499 +static const int subtype_txq_to_hwq[] = {
500 +       [WME_AC_BE] = ATH_TXQ_AC_BE,
501 +       [WME_AC_BK] = ATH_TXQ_AC_BK,
502 +       [WME_AC_VI] = ATH_TXQ_AC_VI,
503 +       [WME_AC_VO] = ATH_TXQ_AC_VO,
504 +};
505 +
506  #define ATH9K_HTC_INIT_TXQ(subtype) do {                       \
507 -               qi.tqi_subtype = subtype;                       \
508 +               qi.tqi_subtype = subtype_txq_to_hwq[subtype];   \
509                 qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT;             \
510                 qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT;            \
511                 qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT;            \
512 --- a/drivers/net/wireless/ath/ath9k/init.c
513 +++ b/drivers/net/wireless/ath/ath9k/init.c
514 @@ -396,7 +396,8 @@ static void ath9k_init_crypto(struct ath
515  
516  static int ath9k_init_btcoex(struct ath_softc *sc)
517  {
518 -       int r, qnum;
519 +       struct ath_txq *txq;
520 +       int r;
521  
522         switch (sc->sc_ah->btcoex_hw.scheme) {
523         case ATH_BTCOEX_CFG_NONE:
524 @@ -409,8 +410,8 @@ static int ath9k_init_btcoex(struct ath_
525                 r = ath_init_btcoex_timer(sc);
526                 if (r)
527                         return -1;
528 -               qnum = sc->tx.hwq_map[WME_AC_BE];
529 -               ath9k_hw_init_btcoex_hw(sc->sc_ah, qnum);
530 +               txq = sc->tx.txq_map[WME_AC_BE];
531 +               ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum);
532                 sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
533                 break;
534         default:
535 @@ -423,59 +424,18 @@ static int ath9k_init_btcoex(struct ath_
536  
537  static int ath9k_init_queues(struct ath_softc *sc)
538  {
539 -       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
540         int i = 0;
541  
542 -       for (i = 0; i < ARRAY_SIZE(sc->tx.hwq_map); i++)
543 -               sc->tx.hwq_map[i] = -1;
544 -
545         sc->beacon.beaconq = ath9k_hw_beaconq_setup(sc->sc_ah);
546 -       if (sc->beacon.beaconq == -1) {
547 -               ath_print(common, ATH_DBG_FATAL,
548 -                         "Unable to setup a beacon xmit queue\n");
549 -               goto err;
550 -       }
551 -
552         sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0);
553 -       if (sc->beacon.cabq == NULL) {
554 -               ath_print(common, ATH_DBG_FATAL,
555 -                         "Unable to setup CAB xmit queue\n");
556 -               goto err;
557 -       }
558  
559         sc->config.cabqReadytime = ATH_CABQ_READY_TIME;
560         ath_cabq_update(sc);
561  
562 -       if (!ath_tx_setup(sc, WME_AC_BK)) {
563 -               ath_print(common, ATH_DBG_FATAL,
564 -                         "Unable to setup xmit queue for BK traffic\n");
565 -               goto err;
566 -       }
567 -
568 -       if (!ath_tx_setup(sc, WME_AC_BE)) {
569 -               ath_print(common, ATH_DBG_FATAL,
570 -                         "Unable to setup xmit queue for BE traffic\n");
571 -               goto err;
572 -       }
573 -       if (!ath_tx_setup(sc, WME_AC_VI)) {
574 -               ath_print(common, ATH_DBG_FATAL,
575 -                         "Unable to setup xmit queue for VI traffic\n");
576 -               goto err;
577 -       }
578 -       if (!ath_tx_setup(sc, WME_AC_VO)) {
579 -               ath_print(common, ATH_DBG_FATAL,
580 -                         "Unable to setup xmit queue for VO traffic\n");
581 -               goto err;
582 -       }
583 +       for (i = 0; i < WME_NUM_AC; i++)
584 +               sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
585  
586         return 0;
587 -
588 -err:
589 -       for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
590 -               if (ATH_TXQ_SETUP(sc, i))
591 -                       ath_tx_cleanupq(sc, &sc->tx.txq[i]);
592 -
593 -       return -EIO;
594  }
595  
596  static int ath9k_init_channels_rates(struct ath_softc *sc)
597 --- a/drivers/net/wireless/ath/ath9k/virtual.c
598 +++ b/drivers/net/wireless/ath/ath9k/virtual.c
599 @@ -187,7 +187,7 @@ static int ath9k_send_nullfunc(struct at
600         info->control.rates[1].idx = -1;
601  
602         memset(&txctl, 0, sizeof(struct ath_tx_control));
603 -       txctl.txq = &sc->tx.txq[sc->tx.hwq_map[WME_AC_VO]];
604 +       txctl.txq = sc->tx.txq_map[WME_AC_VO];
605         txctl.frame_type = ps ? ATH9K_IFT_PAUSE : ATH9K_IFT_UNPAUSE;
606  
607         if (ath_tx_start(aphy->hw, skb, &txctl) != 0)
608 --- a/drivers/net/wireless/ath/ath9k/debug.c
609 +++ b/drivers/net/wireless/ath/ath9k/debug.c
610 @@ -579,10 +579,10 @@ static const struct file_operations fops
611         do {                                                            \
612                 len += snprintf(buf + len, size - len,                  \
613                                 "%s%13u%11u%10u%10u\n", str,            \
614 -               sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BE]].elem, \
615 -               sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BK]].elem, \
616 -               sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VI]].elem, \
617 -               sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VO]].elem); \
618 +               sc->debug.stats.txstats[WME_AC_BE].elem, \
619 +               sc->debug.stats.txstats[WME_AC_BK].elem, \
620 +               sc->debug.stats.txstats[WME_AC_VI].elem, \
621 +               sc->debug.stats.txstats[WME_AC_VO].elem); \
622  } while(0)
623  
624  static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
625 @@ -624,33 +624,35 @@ static ssize_t read_file_xmit(struct fil
626         return retval;
627  }
628  
629 -void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
630 -                      struct ath_buf *bf, struct ath_tx_status *ts)
631 +void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
632 +                      struct ath_tx_status *ts)
633  {
634 -       TX_STAT_INC(txq->axq_qnum, tx_pkts_all);
635 -       sc->debug.stats.txstats[txq->axq_qnum].tx_bytes_all += bf->bf_mpdu->len;
636 +       int qnum = skb_get_queue_mapping(bf->bf_mpdu);
637 +
638 +       TX_STAT_INC(qnum, tx_pkts_all);
639 +       sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
640  
641         if (bf_isampdu(bf)) {
642                 if (bf_isxretried(bf))
643 -                       TX_STAT_INC(txq->axq_qnum, a_xretries);
644 +                       TX_STAT_INC(qnum, a_xretries);
645                 else
646 -                       TX_STAT_INC(txq->axq_qnum, a_completed);
647 +                       TX_STAT_INC(qnum, a_completed);
648         } else {
649 -               TX_STAT_INC(txq->axq_qnum, completed);
650 +               TX_STAT_INC(qnum, completed);
651         }
652  
653         if (ts->ts_status & ATH9K_TXERR_FIFO)
654 -               TX_STAT_INC(txq->axq_qnum, fifo_underrun);
655 +               TX_STAT_INC(qnum, fifo_underrun);
656         if (ts->ts_status & ATH9K_TXERR_XTXOP)
657 -               TX_STAT_INC(txq->axq_qnum, xtxop);
658 +               TX_STAT_INC(qnum, xtxop);
659         if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
660 -               TX_STAT_INC(txq->axq_qnum, timer_exp);
661 +               TX_STAT_INC(qnum, timer_exp);
662         if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
663 -               TX_STAT_INC(txq->axq_qnum, desc_cfg_err);
664 +               TX_STAT_INC(qnum, desc_cfg_err);
665         if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
666 -               TX_STAT_INC(txq->axq_qnum, data_underrun);
667 +               TX_STAT_INC(qnum, data_underrun);
668         if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
669 -               TX_STAT_INC(txq->axq_qnum, delim_underrun);
670 +               TX_STAT_INC(qnum, delim_underrun);
671  }
672  
673  static const struct file_operations fops_xmit = {
674 --- a/drivers/net/wireless/ath/ath9k/debug.h
675 +++ b/drivers/net/wireless/ath/ath9k/debug.h
676 @@ -169,8 +169,8 @@ void ath9k_exit_debug(struct ath_hw *ah)
677  int ath9k_debug_create_root(void);
678  void ath9k_debug_remove_root(void);
679  void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
680 -void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
681 -                      struct ath_buf *bf, struct ath_tx_status *ts);
682 +void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
683 +                      struct ath_tx_status *ts);
684  void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs);
685  
686  #else