9f04276176e802a1374ef05bf7970d79789c3f8a
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 304-ath9k-remove-struct-ath_atx_ac.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sat, 4 Apr 2015 18:39:06 +0200
3 Subject: [PATCH] ath9k: remove struct ath_atx_ac
4
5 struct ath_atx_ac contains a list of active TIDs belonging to one WMM AC.
6 This patch changes the code to track active station TIDs in the txq directly.
7
8 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 ---
10
11 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
12 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
13 @@ -173,14 +173,6 @@ struct ath_txq {
14 struct sk_buff_head complete_q;
15 };
16
17 -struct ath_atx_ac {
18 - struct ath_txq *txq;
19 - struct list_head list;
20 - struct list_head tid_q;
21 - bool clear_ps_filter;
22 - bool sched;
23 -};
24 -
25 struct ath_frame_info {
26 struct ath_buf *bf;
27 u16 framelen;
28 @@ -243,7 +235,7 @@ struct ath_atx_tid {
29 struct sk_buff_head buf_q;
30 struct sk_buff_head retry_q;
31 struct ath_node *an;
32 - struct ath_atx_ac *ac;
33 + struct ath_txq *txq;
34 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
35 u16 seq_start;
36 u16 seq_next;
37 @@ -255,6 +247,7 @@ struct ath_atx_tid {
38 s8 bar_index;
39 bool sched;
40 bool active;
41 + bool clear_ps_filter;
42 };
43
44 struct ath_node {
45 @@ -262,7 +255,6 @@ struct ath_node {
46 struct ieee80211_sta *sta; /* station struct we're part of */
47 struct ieee80211_vif *vif; /* interface with which we're associated */
48 struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
49 - struct ath_atx_ac ac[IEEE80211_NUM_ACS];
50
51 u16 maxampdu;
52 u8 mpdudensity;
53 --- a/drivers/net/wireless/ath/ath9k/xmit.c
54 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
55 @@ -106,7 +106,6 @@ void ath_txq_unlock_complete(struct ath_
56 static void ath_tx_queue_tid(struct ath_softc *sc, struct ath_txq *txq,
57 struct ath_atx_tid *tid)
58 {
59 - struct ath_atx_ac *ac = tid->ac;
60 struct list_head *list;
61 struct ath_vif *avp = (struct ath_vif *) tid->an->vif->drv_priv;
62 struct ath_chanctx *ctx = avp->chanctx;
63 @@ -118,15 +117,8 @@ static void ath_tx_queue_tid(struct ath_
64 return;
65
66 tid->sched = true;
67 - list_add_tail(&tid->list, &ac->tid_q);
68 -
69 - if (ac->sched)
70 - return;
71 -
72 - ac->sched = true;
73 -
74 list = &ctx->acq[TID_TO_WME_AC(tid->tidno)];
75 - list_add_tail(&ac->list, list);
76 + list_add_tail(&tid->list, list);
77 }
78
79 static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
80 @@ -223,7 +215,7 @@ static struct sk_buff *ath_tid_dequeue(s
81 static void
82 ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
83 {
84 - struct ath_txq *txq = tid->ac->txq;
85 + struct ath_txq *txq = tid->txq;
86 struct ieee80211_tx_info *tx_info;
87 struct sk_buff *skb, *tskb;
88 struct ath_buf *bf;
89 @@ -252,7 +244,7 @@ ath_tx_tid_change_state(struct ath_softc
90
91 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
92 {
93 - struct ath_txq *txq = tid->ac->txq;
94 + struct ath_txq *txq = tid->txq;
95 struct sk_buff *skb;
96 struct ath_buf *bf;
97 struct list_head bf_head;
98 @@ -659,7 +651,7 @@ static void ath_tx_complete_aggr(struct
99 ath_tx_queue_tid(sc, txq, tid);
100
101 if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
102 - tid->ac->clear_ps_filter = true;
103 + tid->clear_ps_filter = true;
104 }
105 }
106
107 @@ -749,7 +741,7 @@ static u32 ath_lookup_rate(struct ath_so
108 struct ieee80211_tx_rate *rates;
109 u32 max_4ms_framelen, frmlen;
110 u16 aggr_limit, bt_aggr_limit, legacy = 0;
111 - int q = tid->ac->txq->mac80211_qnum;
112 + int q = tid->txq->mac80211_qnum;
113 int i;
114
115 skb = bf->bf_mpdu;
116 @@ -1486,8 +1478,8 @@ static bool ath_tx_sched_aggr(struct ath
117 if (list_empty(&bf_q))
118 return false;
119
120 - if (tid->ac->clear_ps_filter || tid->an->no_ps_filter) {
121 - tid->ac->clear_ps_filter = false;
122 + if (tid->clear_ps_filter || tid->an->no_ps_filter) {
123 + tid->clear_ps_filter = false;
124 tx_info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT;
125 }
126
127 @@ -1506,7 +1498,7 @@ int ath_tx_aggr_start(struct ath_softc *
128
129 an = (struct ath_node *)sta->drv_priv;
130 txtid = ATH_AN_2_TID(an, tid);
131 - txq = txtid->ac->txq;
132 + txq = txtid->txq;
133
134 ath_txq_lock(sc, txq);
135
136 @@ -1540,7 +1532,7 @@ void ath_tx_aggr_stop(struct ath_softc *
137 {
138 struct ath_node *an = (struct ath_node *)sta->drv_priv;
139 struct ath_atx_tid *txtid = ATH_AN_2_TID(an, tid);
140 - struct ath_txq *txq = txtid->ac->txq;
141 + struct ath_txq *txq = txtid->txq;
142
143 ath_txq_lock(sc, txq);
144 txtid->active = false;
145 @@ -1553,7 +1545,6 @@ void ath_tx_aggr_sleep(struct ieee80211_
146 struct ath_node *an)
147 {
148 struct ath_atx_tid *tid;
149 - struct ath_atx_ac *ac;
150 struct ath_txq *txq;
151 bool buffered;
152 int tidno;
153 @@ -1561,8 +1552,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
154 for (tidno = 0, tid = &an->tid[tidno];
155 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
156
157 - ac = tid->ac;
158 - txq = ac->txq;
159 + txq = tid->txq;
160
161 ath_txq_lock(sc, txq);
162
163 @@ -1576,11 +1566,6 @@ void ath_tx_aggr_sleep(struct ieee80211_
164 tid->sched = false;
165 list_del(&tid->list);
166
167 - if (ac->sched) {
168 - ac->sched = false;
169 - list_del(&ac->list);
170 - }
171 -
172 ath_txq_unlock(sc, txq);
173
174 ieee80211_sta_set_buffered(sta, tidno, buffered);
175 @@ -1590,18 +1575,16 @@ void ath_tx_aggr_sleep(struct ieee80211_
176 void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
177 {
178 struct ath_atx_tid *tid;
179 - struct ath_atx_ac *ac;
180 struct ath_txq *txq;
181 int tidno;
182
183 for (tidno = 0, tid = &an->tid[tidno];
184 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
185
186 - ac = tid->ac;
187 - txq = ac->txq;
188 + txq = tid->txq;
189
190 ath_txq_lock(sc, txq);
191 - ac->clear_ps_filter = true;
192 + tid->clear_ps_filter = true;
193
194 if (ath_tid_has_buffered(tid)) {
195 ath_tx_queue_tid(sc, txq, tid);
196 @@ -1621,7 +1604,7 @@ void ath_tx_aggr_resume(struct ath_softc
197
198 an = (struct ath_node *)sta->drv_priv;
199 tid = ATH_AN_2_TID(an, tidno);
200 - txq = tid->ac->txq;
201 + txq = tid->txq;
202
203 ath_txq_lock(sc, txq);
204
205 @@ -1660,7 +1643,7 @@ void ath9k_release_buffered_frames(struc
206
207 tid = ATH_AN_2_TID(an, i);
208
209 - ath_txq_lock(sc, tid->ac->txq);
210 + ath_txq_lock(sc, tid->txq);
211 while (nframes > 0) {
212 bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
213 if (!bf)
214 @@ -1684,7 +1667,7 @@ void ath9k_release_buffered_frames(struc
215 if (an->sta && !ath_tid_has_buffered(tid))
216 ieee80211_sta_set_buffered(an->sta, i, false);
217 }
218 - ath_txq_unlock_complete(sc, tid->ac->txq);
219 + ath_txq_unlock_complete(sc, tid->txq);
220 }
221
222 if (list_empty(&bf_q))
223 @@ -1933,9 +1916,8 @@ void ath_tx_cleanupq(struct ath_softc *s
224 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
225 {
226 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
227 - struct ath_atx_ac *ac, *last_ac;
228 struct ath_atx_tid *tid, *last_tid;
229 - struct list_head *ac_list;
230 + struct list_head *tid_list;
231 bool sent = false;
232
233 if (txq->mac80211_qnum < 0)
234 @@ -1945,63 +1927,46 @@ void ath_txq_schedule(struct ath_softc *
235 return;
236
237 spin_lock_bh(&sc->chan_lock);
238 - ac_list = &sc->cur_chan->acq[txq->mac80211_qnum];
239 + tid_list = &sc->cur_chan->acq[txq->mac80211_qnum];
240
241 - if (list_empty(ac_list)) {
242 + if (list_empty(tid_list)) {
243 spin_unlock_bh(&sc->chan_lock);
244 return;
245 }
246
247 rcu_read_lock();
248
249 - last_ac = list_entry(ac_list->prev, struct ath_atx_ac, list);
250 - while (!list_empty(ac_list)) {
251 + last_tid = list_entry(tid_list->prev, struct ath_atx_tid, list);
252 + while (!list_empty(tid_list)) {
253 bool stop = false;
254
255 if (sc->cur_chan->stopped)
256 break;
257
258 - ac = list_first_entry(ac_list, struct ath_atx_ac, list);
259 - last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
260 - list_del(&ac->list);
261 - ac->sched = false;
262 -
263 - while (!list_empty(&ac->tid_q)) {
264 -
265 - tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
266 - list);
267 - list_del(&tid->list);
268 - tid->sched = false;
269 -
270 - if (ath_tx_sched_aggr(sc, txq, tid, &stop))
271 - sent = true;
272 -
273 - /*
274 - * add tid to round-robin queue if more frames
275 - * are pending for the tid
276 - */
277 - if (ath_tid_has_buffered(tid))
278 - ath_tx_queue_tid(sc, txq, tid);
279 + tid = list_first_entry(tid_list, struct ath_atx_tid, list);
280 + list_del(&tid->list);
281 + tid->sched = false;
282
283 - if (stop || tid == last_tid)
284 - break;
285 - }
286 + if (ath_tx_sched_aggr(sc, txq, tid, &stop))
287 + sent = true;
288
289 - if (!list_empty(&ac->tid_q) && !ac->sched) {
290 - ac->sched = true;
291 - list_add_tail(&ac->list, ac_list);
292 - }
293 + /*
294 + * add tid to round-robin queue if more frames
295 + * are pending for the tid
296 + */
297 + if (ath_tid_has_buffered(tid))
298 + ath_tx_queue_tid(sc, txq, tid);
299
300 if (stop)
301 break;
302
303 - if (ac == last_ac) {
304 + if (tid == last_tid) {
305 if (!sent)
306 break;
307
308 sent = false;
309 - last_ac = list_entry(ac_list->prev,
310 - struct ath_atx_ac, list);
311 + last_tid = list_entry(tid_list->prev,
312 + struct ath_atx_tid, list);
313 }
314 }
315
316 @@ -2391,10 +2356,10 @@ int ath_tx_start(struct ieee80211_hw *hw
317 txq = sc->tx.uapsdq;
318 ath_txq_lock(sc, txq);
319 } else if (txctl->an && queue) {
320 - WARN_ON(tid->ac->txq != txctl->txq);
321 + WARN_ON(tid->txq != txctl->txq);
322
323 if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
324 - tid->ac->clear_ps_filter = true;
325 + tid->clear_ps_filter = true;
326
327 /*
328 * Add this frame to software queue for scheduling later
329 @@ -2888,7 +2853,6 @@ int ath_tx_init(struct ath_softc *sc, in
330 void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
331 {
332 struct ath_atx_tid *tid;
333 - struct ath_atx_ac *ac;
334 int tidno, acno;
335
336 for (tidno = 0, tid = &an->tid[tidno];
337 @@ -2901,24 +2865,16 @@ void ath_tx_node_init(struct ath_softc *
338 tid->baw_head = tid->baw_tail = 0;
339 tid->sched = false;
340 tid->active = false;
341 + tid->clear_ps_filter = true;
342 __skb_queue_head_init(&tid->buf_q);
343 __skb_queue_head_init(&tid->retry_q);
344 acno = TID_TO_WME_AC(tidno);
345 - tid->ac = &an->ac[acno];
346 - }
347 -
348 - for (acno = 0, ac = &an->ac[acno];
349 - acno < IEEE80211_NUM_ACS; acno++, ac++) {
350 - ac->sched = false;
351 - ac->clear_ps_filter = true;
352 - ac->txq = sc->tx.txq_map[acno];
353 - INIT_LIST_HEAD(&ac->tid_q);
354 + tid->txq = sc->tx.txq_map[acno];
355 }
356 }
357
358 void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an)
359 {
360 - struct ath_atx_ac *ac;
361 struct ath_atx_tid *tid;
362 struct ath_txq *txq;
363 int tidno;
364 @@ -2926,8 +2882,7 @@ void ath_tx_node_cleanup(struct ath_soft
365 for (tidno = 0, tid = &an->tid[tidno];
366 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
367
368 - ac = tid->ac;
369 - txq = ac->txq;
370 + txq = tid->txq;
371
372 ath_txq_lock(sc, txq);
373
374 @@ -2936,11 +2891,6 @@ void ath_tx_node_cleanup(struct ath_soft
375 tid->sched = false;
376 }
377
378 - if (ac->sched) {
379 - list_del(&ac->list);
380 - tid->ac->sched = false;
381 - }
382 -
383 ath_tid_drain(sc, txq, tid);
384 tid->active = false;
385