Skip to content

Commit 3318111

Browse files
nbd168jmberg-intel
authored andcommitted
mac80211: reduce duplication in tx status functions
Move redundant functionality from __ieee80211_tx_status into ieee80211_tx_status_ext. Preparation for unifying with the 802.3 tx status codepath. Signed-off-by: Felix Fietkau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 6aea26c commit 3318111

File tree

1 file changed

+35
-66
lines changed

1 file changed

+35
-66
lines changed

net/mac80211/status.c

Lines changed: 35 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,6 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
184184
struct ieee80211_mgmt *mgmt = (void *) skb->data;
185185
struct ieee80211_local *local = sta->local;
186186
struct ieee80211_sub_if_data *sdata = sta->sdata;
187-
struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
188-
189-
if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
190-
sta->status_stats.last_ack = jiffies;
191-
if (txinfo->status.is_valid_ack_signal) {
192-
sta->status_stats.last_ack_signal =
193-
(s8)txinfo->status.ack_signal;
194-
sta->status_stats.ack_signal_filled = true;
195-
ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
196-
-txinfo->status.ack_signal);
197-
}
198-
}
199187

200188
if (ieee80211_is_data_qos(mgmt->frame_control)) {
201189
struct ieee80211_hdr *hdr = (void *) skb->data;
@@ -890,7 +878,8 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
890878
}
891879

892880
static void __ieee80211_tx_status(struct ieee80211_hw *hw,
893-
struct ieee80211_tx_status *status)
881+
struct ieee80211_tx_status *status,
882+
int rates_idx, int retry_count)
894883
{
895884
struct sk_buff *skb = status->skb;
896885
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -899,8 +888,6 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
899888
struct sta_info *sta;
900889
__le16 fc;
901890
struct ieee80211_supported_band *sband;
902-
int retry_count;
903-
int rates_idx;
904891
bool send_to_cooked;
905892
bool acked;
906893
bool noack_success;
@@ -909,8 +896,6 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
909896
int tid = IEEE80211_NUM_TIDS;
910897
u16 tx_time_est;
911898

912-
rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
913-
914899
sband = local->hw.wiphy->bands[info->band];
915900
fc = hdr->frame_control;
916901

@@ -987,24 +972,14 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
987972
if (info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
988973
ieee80211_handle_filtered_frame(local, sta, skb);
989974
return;
990-
} else {
975+
} else if (ieee80211_is_data_present(fc)) {
991976
if (!acked && !noack_success)
992-
sta->status_stats.retry_failed++;
993-
sta->status_stats.retry_count += retry_count;
977+
sta->status_stats.msdu_failed[tid]++;
994978

995-
if (ieee80211_is_data_present(fc)) {
996-
if (!acked && !noack_success)
997-
sta->status_stats.msdu_failed[tid]++;
998-
999-
sta->status_stats.msdu_retries[tid] +=
1000-
retry_count;
1001-
}
979+
sta->status_stats.msdu_retries[tid] +=
980+
retry_count;
1002981
}
1003982

1004-
rate_control_tx_status(local, sband, status);
1005-
if (ieee80211_vif_is_mesh(&sta->sdata->vif))
1006-
ieee80211s_update_metric(local, sta, status);
1007-
1008983
if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
1009984
ieee80211_frame_acked(sta, skb);
1010985

@@ -1029,20 +1004,6 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
10291004
true);
10301005
ieee80211_info_set_tx_time_est(info, 0);
10311006
}
1032-
1033-
if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
1034-
if (acked) {
1035-
if (sta->status_stats.lost_packets)
1036-
sta->status_stats.lost_packets = 0;
1037-
1038-
/* Track when last TDLS packet was ACKed */
1039-
sta->status_stats.last_pkt_time = jiffies;
1040-
} else if (noack_success) {
1041-
/* nothing to do here, do not account as lost */
1042-
} else {
1043-
ieee80211_lost_packet(sta, info);
1044-
}
1045-
}
10461007
}
10471008

10481009
/* SNMP counters
@@ -1126,7 +1087,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
11261087
if (sta)
11271088
status.sta = &sta->sta;
11281089

1129-
__ieee80211_tx_status(hw, &status);
1090+
ieee80211_tx_status_ext(hw, &status);
11301091
rcu_read_unlock();
11311092
}
11321093
EXPORT_SYMBOL(ieee80211_tx_status);
@@ -1139,7 +1100,7 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
11391100
struct ieee80211_sta *pubsta = status->sta;
11401101
struct ieee80211_supported_band *sband;
11411102
struct sta_info *sta;
1142-
int retry_count;
1103+
int rates_idx, retry_count;
11431104
bool acked, noack_success;
11441105

11451106
if (pubsta) {
@@ -1149,13 +1110,7 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
11491110
sta->tx_stats.last_rate_info = *status->rate;
11501111
}
11511112

1152-
if (status->skb)
1153-
return __ieee80211_tx_status(hw, status);
1154-
1155-
if (!status->sta)
1156-
return;
1157-
1158-
ieee80211_tx_get_rates(hw, info, &retry_count);
1113+
rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
11591114

11601115
sband = hw->wiphy->bands[info->band];
11611116

@@ -1167,27 +1122,41 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
11671122
sta->status_stats.retry_failed++;
11681123
sta->status_stats.retry_count += retry_count;
11691124

1170-
if (acked) {
1171-
sta->status_stats.last_ack = jiffies;
1125+
if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
1126+
if (acked) {
1127+
sta->status_stats.last_ack = jiffies;
11721128

1173-
if (sta->status_stats.lost_packets)
1174-
sta->status_stats.lost_packets = 0;
1129+
if (sta->status_stats.lost_packets)
1130+
sta->status_stats.lost_packets = 0;
11751131

1176-
/* Track when last packet was ACKed */
1177-
sta->status_stats.last_pkt_time = jiffies;
1178-
} else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
1179-
return;
1180-
} else if (noack_success) {
1181-
/* nothing to do here, do not account as lost */
1182-
} else {
1183-
ieee80211_lost_packet(sta, info);
1132+
/* Track when last packet was ACKed */
1133+
sta->status_stats.last_pkt_time = jiffies;
1134+
1135+
if (info->status.is_valid_ack_signal) {
1136+
sta->status_stats.last_ack_signal =
1137+
(s8)info->status.ack_signal;
1138+
sta->status_stats.ack_signal_filled = true;
1139+
ewma_avg_signal_add(&sta->status_stats.avg_ack_signal,
1140+
-info->status.ack_signal);
1141+
}
1142+
} else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
1143+
return;
1144+
} else if (noack_success) {
1145+
/* nothing to do here, do not account as lost */
1146+
} else {
1147+
ieee80211_lost_packet(sta, info);
1148+
}
11841149
}
11851150

11861151
rate_control_tx_status(local, sband, status);
11871152
if (ieee80211_vif_is_mesh(&sta->sdata->vif))
11881153
ieee80211s_update_metric(local, sta, status);
11891154
}
11901155

1156+
if (status->skb)
1157+
return __ieee80211_tx_status(hw, status, rates_idx,
1158+
retry_count);
1159+
11911160
if (acked || noack_success) {
11921161
I802_DEBUG_INC(local->dot11TransmittedFrameCount);
11931162
if (!pubsta)

0 commit comments

Comments
 (0)