ab16576bcdc8b0826b066e2f22fcd483f3ece2b9
[openwrt/staging/hauke.git] /
1 From: Ryder Lee <ryder.lee@mediatek.com>
2 Date: Fri, 28 May 2021 14:05:41 +0800
3 Subject: [PATCH] mac80211: call ieee80211_tx_h_rate_ctrl() when dequeue
4
5 Make ieee80211_tx_h_rate_ctrl() get called on dequeue to improve
6 performance since it reduces the turnaround time for rate control.
7
8 Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
9 ---
10
11 --- a/net/mac80211/tx.c
12 +++ b/net/mac80211/tx.c
13 @@ -1765,8 +1765,6 @@ static int invoke_tx_handlers_early(stru
14 CALL_TXH(ieee80211_tx_h_ps_buf);
15 CALL_TXH(ieee80211_tx_h_check_control_port_protocol);
16 CALL_TXH(ieee80211_tx_h_select_key);
17 - if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
18 - CALL_TXH(ieee80211_tx_h_rate_ctrl);
19
20 txh_done:
21 if (unlikely(res == TX_DROP)) {
22 @@ -1799,6 +1797,9 @@ static int invoke_tx_handlers_late(struc
23 goto txh_done;
24 }
25
26 + if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
27 + CALL_TXH(ieee80211_tx_h_rate_ctrl);
28 +
29 CALL_TXH(ieee80211_tx_h_michael_mic_add);
30 CALL_TXH(ieee80211_tx_h_sequence);
31 CALL_TXH(ieee80211_tx_h_fragment);
32 @@ -3353,15 +3354,21 @@ out:
33 * Can be called while the sta lock is held. Anything that can cause packets to
34 * be generated will cause deadlock!
35 */
36 -static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
37 - struct sta_info *sta, u8 pn_offs,
38 - struct ieee80211_key *key,
39 - struct sk_buff *skb)
40 +static ieee80211_tx_result
41 +ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
42 + struct sta_info *sta, u8 pn_offs,
43 + struct ieee80211_key *key,
44 + struct ieee80211_tx_data *tx)
45 {
46 + struct sk_buff *skb = tx->skb;
47 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
48 struct ieee80211_hdr *hdr = (void *)skb->data;
49 u8 tid = IEEE80211_NUM_TIDS;
50
51 + if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL) &&
52 + ieee80211_tx_h_rate_ctrl(tx) != TX_CONTINUE)
53 + return TX_DROP;
54 +
55 if (key)
56 info->control.hw_key = &key->conf;
57
58 @@ -3410,6 +3417,8 @@ static void ieee80211_xmit_fast_finish(s
59 break;
60 }
61 }
62 +
63 + return TX_CONTINUE;
64 }
65
66 static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
67 @@ -3513,24 +3522,17 @@ static bool ieee80211_xmit_fast(struct i
68 tx.sta = sta;
69 tx.key = fast_tx->key;
70
71 - if (!ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
72 - tx.skb = skb;
73 - r = ieee80211_tx_h_rate_ctrl(&tx);
74 - skb = tx.skb;
75 - tx.skb = NULL;
76 -
77 - if (r != TX_CONTINUE) {
78 - if (r != TX_QUEUED)
79 - kfree_skb(skb);
80 - return true;
81 - }
82 - }
83 -
84 if (ieee80211_queue_skb(local, sdata, sta, skb))
85 return true;
86
87 - ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
88 - fast_tx->key, skb);
89 + tx.skb = skb;
90 + r = ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
91 + fast_tx->key, &tx);
92 + tx.skb = NULL;
93 + if (r == TX_DROP) {
94 + kfree_skb(skb);
95 + return true;
96 + }
97
98 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
99 sdata = container_of(sdata->bss,
100 @@ -3641,8 +3643,12 @@ begin:
101 (tx.key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
102 pn_offs = ieee80211_hdrlen(hdr->frame_control);
103
104 - ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
105 - tx.key, skb);
106 + r = ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
107 + tx.key, &tx);
108 + if (r != TX_CONTINUE) {
109 + ieee80211_free_txskb(&local->hw, skb);
110 + goto begin;
111 + }
112 } else {
113 if (invoke_tx_handlers_late(&tx))
114 goto begin;