0b7c8dd49bcfba23c5fd258c4aecb126336760d5
[openwrt/staging/zorun.git] / package / kernel / mac80211 / patches / subsys / 370-mac80211-fix-TXQ-AC-confusion.patch
1 From: Johannes Berg <johannes.berg@intel.com>
2 Date: Tue, 23 Mar 2021 21:05:01 +0100
3 Subject: [PATCH] mac80211: fix TXQ AC confusion
4
5 Normally, TXQs have
6
7 txq->tid = tid;
8 txq->ac = ieee80211_ac_from_tid(tid);
9
10 However, the special management TXQ actually has
11
12 txq->tid = IEEE80211_NUM_TIDS; // 16
13 txq->ac = IEEE80211_AC_VO;
14
15 This makes sense, but ieee80211_ac_from_tid(16) is the same
16 as ieee80211_ac_from_tid(0) which is just IEEE80211_AC_BE.
17
18 Now, normally this is fine. However, if the netdev queues
19 were stopped, then the code in ieee80211_tx_dequeue() will
20 propagate the stop from the interface (vif->txqs_stopped[])
21 if the AC 2 (ieee80211_ac_from_tid(txq->tid)) is marked as
22 stopped. On wake, however, __ieee80211_wake_txqs() will wake
23 the TXQ if AC 0 (txq->ac) is woken up.
24
25 If a driver stops all queues with ieee80211_stop_tx_queues()
26 and then wakes them again with ieee80211_wake_tx_queues(),
27 the ieee80211_wake_txqs() tasklet will run to resync queue
28 and TXQ state. If all queues were woken, then what'll happen
29 is that _ieee80211_wake_txqs() will run in order of HW queues
30 0-3, typically (and certainly for iwlwifi) corresponding to
31 ACs 0-3, so it'll call __ieee80211_wake_txqs() for each AC in
32 order 0-3.
33
34 When __ieee80211_wake_txqs() is called for AC 0 (VO) that'll
35 wake up the management TXQ (remember its tid is 16), and the
36 driver's wake_tx_queue() will be called. That tries to get a
37 frame, which will immediately *stop* the TXQ again, because
38 now we check against AC 2, and AC 2 hasn't yet been marked as
39 woken up again in sdata->vif.txqs_stopped[] since we're only
40 in the __ieee80211_wake_txqs() call for AC 0.
41
42 Thus, the management TXQ will never be started again.
43
44 Fix this by checking txq->ac directly instead of calculating
45 the AC as ieee80211_ac_from_tid(txq->tid).
46
47 Fixes: adf8ed01e4fd ("mac80211: add an optional TXQ for other PS-buffered frames")
48 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
49 ---
50
51 --- a/net/mac80211/tx.c
52 +++ b/net/mac80211/tx.c
53 @@ -3589,7 +3589,7 @@ begin:
54 test_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags))
55 goto out;
56
57 - if (vif->txqs_stopped[ieee80211_ac_from_tid(txq->tid)]) {
58 + if (vif->txqs_stopped[txq->ac]) {
59 set_bit(IEEE80211_TXQ_STOP_NETIF_TX, &txqi->flags);
60 goto out;
61 }