mac80211: add a tx sequence number allocation fix
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 346-mac80211-fix-sequence-number-assignment-for-PS-respo.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sun, 4 Sep 2016 17:46:24 +0200
3 Subject: [PATCH] mac80211: fix sequence number assignment for PS response
4 frames
5
6 When using intermediate queues, sequence number allocation is deferred
7 until dequeue. This doesn't work for PS response frames, which bypass
8 those queues.
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/net/mac80211/tx.c
14 +++ b/net/mac80211/tx.c
15 @@ -792,6 +792,36 @@ static __le16 ieee80211_tx_next_seq(stru
16 return ret;
17 }
18
19 +static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local,
20 + struct ieee80211_vif *vif,
21 + struct ieee80211_sta *pubsta,
22 + struct sk_buff *skb)
23 +{
24 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
25 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
26 + struct ieee80211_txq *txq = NULL;
27 +
28 + if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) ||
29 + (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
30 + return NULL;
31 +
32 + if (!ieee80211_is_data(hdr->frame_control))
33 + return NULL;
34 +
35 + if (pubsta) {
36 + u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
37 +
38 + txq = pubsta->txq[tid];
39 + } else if (vif) {
40 + txq = vif->txq;
41 + }
42 +
43 + if (!txq)
44 + return NULL;
45 +
46 + return to_txq_info(txq);
47 +}
48 +
49 static ieee80211_tx_result debug_noinline
50 ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
51 {
52 @@ -849,7 +879,8 @@ ieee80211_tx_h_sequence(struct ieee80211
53 tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
54 tx->sta->tx_stats.msdu[tid]++;
55
56 - if (!tx->sta->sta.txq[0])
57 + if (!ieee80211_get_txq(tx->local, info->control.vif, &tx->sta->sta,
58 + tx->skb))
59 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
60
61 return TX_CONTINUE;
62 @@ -1238,36 +1269,6 @@ ieee80211_tx_prepare(struct ieee80211_su
63 return TX_CONTINUE;
64 }
65
66 -static struct txq_info *ieee80211_get_txq(struct ieee80211_local *local,
67 - struct ieee80211_vif *vif,
68 - struct ieee80211_sta *pubsta,
69 - struct sk_buff *skb)
70 -{
71 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
72 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
73 - struct ieee80211_txq *txq = NULL;
74 -
75 - if ((info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) ||
76 - (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
77 - return NULL;
78 -
79 - if (!ieee80211_is_data(hdr->frame_control))
80 - return NULL;
81 -
82 - if (pubsta) {
83 - u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
84 -
85 - txq = pubsta->txq[tid];
86 - } else if (vif) {
87 - txq = vif->txq;
88 - }
89 -
90 - if (!txq)
91 - return NULL;
92 -
93 - return to_txq_info(txq);
94 -}
95 -
96 static void ieee80211_set_skb_enqueue_time(struct sk_buff *skb)
97 {
98 IEEE80211_SKB_CB(skb)->control.enqueue_time = codel_get_time();
99 @@ -3265,7 +3266,7 @@ static bool ieee80211_xmit_fast(struct i
100
101 if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
102 *ieee80211_get_qos_ctl(hdr) = tid;
103 - if (!sta->sta.txq[0])
104 + if (!ieee80211_get_txq(local, &sdata->vif, &sta->sta, skb))
105 hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
106 } else {
107 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;