mac80211: Update to version 5.9.12-1
[openwrt/staging/rmilecki.git] / package / kernel / mac80211 / patches / subsys / 319-mac80211-reduce-duplication-in-tx-status-functions.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 17 Aug 2020 13:16:59 +0200
3 Subject: [PATCH] mac80211: reduce duplication in tx status functions
4
5 Move redundant functionality from __ieee80211_tx_status into
6 ieee80211_tx_status_ext. Preparation for unifying with the 802.3 tx status
7 codepath.
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/net/mac80211/status.c
13 +++ b/net/mac80211/status.c
14 @@ -184,18 +184,6 @@ static void ieee80211_frame_acked(struct
15 struct ieee80211_mgmt *mgmt = (void *) skb->data;
16 struct ieee80211_local *local = sta->local;
17 struct ieee80211_sub_if_data *sdata = sta->sdata;
18 - struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
19 -
20 - if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
21 - sta->status_stats.last_ack = jiffies;
22 - if (txinfo->status.is_valid_ack_signal) {
23 - sta->status_stats.last_ack_signal =
24 - (s8)txinfo->status.ack_signal;
25 - sta->status_stats.ack_signal_filled = true;
26 - ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
27 - -txinfo->status.ack_signal);
28 - }
29 - }
30
31 if (ieee80211_is_data_qos(mgmt->frame_control)) {
32 struct ieee80211_hdr *hdr = (void *) skb->data;
33 @@ -897,7 +885,8 @@ void ieee80211_tx_monitor(struct ieee802
34 }
35
36 static void __ieee80211_tx_status(struct ieee80211_hw *hw,
37 - struct ieee80211_tx_status *status)
38 + struct ieee80211_tx_status *status,
39 + int rates_idx, int retry_count)
40 {
41 struct sk_buff *skb = status->skb;
42 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
43 @@ -906,8 +895,6 @@ static void __ieee80211_tx_status(struct
44 struct sta_info *sta;
45 __le16 fc;
46 struct ieee80211_supported_band *sband;
47 - int retry_count;
48 - int rates_idx;
49 bool send_to_cooked;
50 bool acked;
51 bool noack_success;
52 @@ -916,8 +903,6 @@ static void __ieee80211_tx_status(struct
53 int tid = IEEE80211_NUM_TIDS;
54 u16 tx_time_est;
55
56 - rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
57 -
58 sband = local->hw.wiphy->bands[info->band];
59 fc = hdr->frame_control;
60
61 @@ -994,24 +979,14 @@ static void __ieee80211_tx_status(struct
62 if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
63 ieee80211_handle_filtered_frame(local, sta, skb);
64 return;
65 - } else {
66 + } else if (ieee80211_is_data_present(fc)) {
67 if (!acked && !noack_success)
68 - sta->status_stats.retry_failed++;
69 - sta->status_stats.retry_count += retry_count;
70 + sta->status_stats.msdu_failed[tid]++;
71
72 - if (ieee80211_is_data_present(fc)) {
73 - if (!acked && !noack_success)
74 - sta->status_stats.msdu_failed[tid]++;
75 -
76 - sta->status_stats.msdu_retries[tid] +=
77 - retry_count;
78 - }
79 + sta->status_stats.msdu_retries[tid] +=
80 + retry_count;
81 }
82
83 - rate_control_tx_status(local, sband, status);
84 - if (ieee80211_vif_is_mesh(&sta->sdata->vif))
85 - ieee80211s_update_metric(local, sta, status);
86 -
87 if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
88 ieee80211_frame_acked(sta, skb);
89
90 @@ -1036,20 +1011,6 @@ static void __ieee80211_tx_status(struct
91 true);
92 ieee80211_info_set_tx_time_est(info, 0);
93 }
94 -
95 - if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
96 - if (acked) {
97 - if (sta->status_stats.lost_packets)
98 - sta->status_stats.lost_packets = 0;
99 -
100 - /* Track when last TDLS packet was ACKed */
101 - sta->status_stats.last_pkt_time = jiffies;
102 - } else if (noack_success) {
103 - /* nothing to do here, do not account as lost */
104 - } else {
105 - ieee80211_lost_packet(sta, info);
106 - }
107 - }
108 }
109
110 /* SNMP counters
111 @@ -1133,7 +1094,7 @@ void ieee80211_tx_status(struct ieee8021
112 if (sta)
113 status.sta = &sta->sta;
114
115 - __ieee80211_tx_status(hw, &status);
116 + ieee80211_tx_status_ext(hw, &status);
117 rcu_read_unlock();
118 }
119 EXPORT_SYMBOL(ieee80211_tx_status);
120 @@ -1146,7 +1107,7 @@ void ieee80211_tx_status_ext(struct ieee
121 struct ieee80211_sta *pubsta = status->sta;
122 struct ieee80211_supported_band *sband;
123 struct sta_info *sta;
124 - int retry_count;
125 + int rates_idx, retry_count;
126 bool acked, noack_success;
127
128 if (pubsta) {
129 @@ -1156,13 +1117,7 @@ void ieee80211_tx_status_ext(struct ieee
130 sta->tx_stats.last_rate_info = *status->rate;
131 }
132
133 - if (status->skb)
134 - return __ieee80211_tx_status(hw, status);
135 -
136 - if (!status->sta)
137 - return;
138 -
139 - ieee80211_tx_get_rates(hw, info, &retry_count);
140 + rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
141
142 sband = hw->wiphy->bands[info->band];
143
144 @@ -1174,20 +1129,30 @@ void ieee80211_tx_status_ext(struct ieee
145 sta->status_stats.retry_failed++;
146 sta->status_stats.retry_count += retry_count;
147
148 - if (acked) {
149 - sta->status_stats.last_ack = jiffies;
150 + if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
151 + if (acked) {
152 + sta->status_stats.last_ack = jiffies;
153
154 - if (sta->status_stats.lost_packets)
155 - sta->status_stats.lost_packets = 0;
156 + if (sta->status_stats.lost_packets)
157 + sta->status_stats.lost_packets = 0;
158
159 - /* Track when last packet was ACKed */
160 - sta->status_stats.last_pkt_time = jiffies;
161 - } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
162 - return;
163 - } else if (noack_success) {
164 - /* nothing to do here, do not account as lost */
165 - } else {
166 - ieee80211_lost_packet(sta, info);
167 + /* Track when last packet was ACKed */
168 + sta->status_stats.last_pkt_time = jiffies;
169 +
170 + if (info->status.is_valid_ack_signal) {
171 + sta->status_stats.last_ack_signal =
172 + (s8)info->status.ack_signal;
173 + sta->status_stats.ack_signal_filled = true;
174 + ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
175 + -info->status.ack_signal);
176 + }
177 + } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
178 + return;
179 + } else if (noack_success) {
180 + /* nothing to do here, do not account as lost */
181 + } else {
182 + ieee80211_lost_packet(sta, info);
183 + }
184 }
185
186 rate_control_tx_status(local, sband, status);
187 @@ -1195,6 +1160,10 @@ void ieee80211_tx_status_ext(struct ieee
188 ieee80211s_update_metric(local, sta, status);
189 }
190
191 + if (status->skb)
192 + return __ieee80211_tx_status(hw, status, rates_idx,
193 + retry_count);
194 +
195 if (acked || noack_success) {
196 I802_DEBUG_INC(local->dot11TransmittedFrameCount);
197 if (!pubsta)