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
5 Move redundant functionality from __ieee80211_tx_status into
6 ieee80211_tx_status_ext. Preparation for unifying with the 802.3 tx status
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
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);
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);
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
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)
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
46 struct ieee80211_supported_band *sband;
52 @@ -916,8 +903,6 @@ static void __ieee80211_tx_status(struct
53 int tid = IEEE80211_NUM_TIDS;
56 - rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
58 sband = local->hw.wiphy->bands[info->band];
59 fc = hdr->frame_control;
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);
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]++;
72 - if (ieee80211_is_data_present(fc)) {
73 - if (!acked && !noack_success)
74 - sta->status_stats.msdu_failed[tid]++;
76 - sta->status_stats.msdu_retries[tid] +=
79 + sta->status_stats.msdu_retries[tid] +=
83 - rate_control_tx_status(local, sband, status);
84 - if (ieee80211_vif_is_mesh(&sta->sdata->vif))
85 - ieee80211s_update_metric(local, sta, status);
87 if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
88 ieee80211_frame_acked(sta, skb);
90 @@ -1036,20 +1011,6 @@ static void __ieee80211_tx_status(struct
92 ieee80211_info_set_tx_time_est(info, 0);
95 - if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
97 - if (sta->status_stats.lost_packets)
98 - sta->status_stats.lost_packets = 0;
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 */
105 - ieee80211_lost_packet(sta, info);
111 @@ -1133,7 +1094,7 @@ void ieee80211_tx_status(struct ieee8021
113 status.sta = &sta->sta;
115 - __ieee80211_tx_status(hw, &status);
116 + ieee80211_tx_status_ext(hw, &status);
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;
125 + int rates_idx, retry_count;
126 bool acked, noack_success;
129 @@ -1156,13 +1117,7 @@ void ieee80211_tx_status_ext(struct ieee
130 sta->tx_stats.last_rate_info = *status->rate;
134 - return __ieee80211_tx_status(hw, status);
139 - ieee80211_tx_get_rates(hw, info, &retry_count);
140 + rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
142 sband = hw->wiphy->bands[info->band];
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;
149 - sta->status_stats.last_ack = jiffies;
150 + if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
152 + sta->status_stats.last_ack = jiffies;
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;
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)) {
163 - } else if (noack_success) {
164 - /* nothing to do here, do not account as lost */
166 - ieee80211_lost_packet(sta, info);
167 + /* Track when last packet was ACKed */
168 + sta->status_stats.last_pkt_time = jiffies;
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);
177 + } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
179 + } else if (noack_success) {
180 + /* nothing to do here, do not account as lost */
182 + ieee80211_lost_packet(sta, info);
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);
192 + return __ieee80211_tx_status(hw, status, rates_idx,
195 if (acked || noack_success) {
196 I802_DEBUG_INC(local->dot11TransmittedFrameCount);