7bb54f499baeb191b9952cff54f961833b723dd5
[openwrt/staging/rmilecki.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 17 Aug 2020 13:54:19 +0200
3 Subject: [PATCH] mac80211: unify 802.3 (offload) and 802.11 tx status
4 codepath
5
6 Make ieee80211_tx_status_8023 call ieee80211_tx_status_ext, similar to
7 ieee80211_tx_status.
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 @@ -903,7 +903,6 @@ static void __ieee80211_tx_status(struct
15 struct ieee80211_bar *bar;
16 int shift = 0;
17 int tid = IEEE80211_NUM_TIDS;
18 - u16 tx_time_est;
19
20 sband = local->hw.wiphy->bands[info->band];
21 fc = hdr->frame_control;
22 @@ -996,17 +995,6 @@ static void __ieee80211_tx_status(struct
23 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
24 ieee80211_sta_tx_notify(sta->sdata, (void *) skb->data,
25 acked, info->status.tx_time);
26 -
27 - if ((tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) {
28 - /* Do this here to avoid the expensive lookup of the sta
29 - * in ieee80211_report_used_skb().
30 - */
31 - ieee80211_sta_update_pending_airtime(local, sta,
32 - skb_get_queue_mapping(skb),
33 - tx_time_est,
34 - true);
35 - ieee80211_info_set_tx_time_est(info, 0);
36 - }
37 }
38
39 /* SNMP counters
40 @@ -1102,9 +1090,11 @@ void ieee80211_tx_status_ext(struct ieee
41 struct ieee80211_tx_info *info = status->info;
42 struct ieee80211_sta *pubsta = status->sta;
43 struct ieee80211_supported_band *sband;
44 - struct sta_info *sta;
45 + struct sk_buff *skb = status->skb;
46 + struct sta_info *sta = NULL;
47 int rates_idx, retry_count;
48 bool acked, noack_success;
49 + u16 tx_time_est;
50
51 if (pubsta) {
52 sta = container_of(pubsta, struct sta_info, sta);
53 @@ -1156,7 +1146,18 @@ void ieee80211_tx_status_ext(struct ieee
54 ieee80211s_update_metric(local, sta, status);
55 }
56
57 - if (status->skb)
58 + if (skb && (tx_time_est = ieee80211_info_get_tx_time_est(info)) > 0) {
59 + /* Do this here to avoid the expensive lookup of the sta
60 + * in ieee80211_report_used_skb().
61 + */
62 + ieee80211_sta_update_pending_airtime(local, sta,
63 + skb_get_queue_mapping(skb),
64 + tx_time_est,
65 + true);
66 + ieee80211_info_set_tx_time_est(info, 0);
67 + }
68 +
69 + if (skb && !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP))
70 return __ieee80211_tx_status(hw, status, rates_idx,
71 retry_count);
72
73 @@ -1171,6 +1172,12 @@ void ieee80211_tx_status_ext(struct ieee
74 } else {
75 I802_DEBUG_INC(local->dot11FailedCount);
76 }
77 +
78 + if (!skb)
79 + return;
80 +
81 + ieee80211_report_used_skb(local, skb, false);
82 + dev_kfree_skb(skb);
83 }
84 EXPORT_SYMBOL(ieee80211_tx_status_ext);
85
86 @@ -1197,66 +1204,23 @@ void ieee80211_tx_status_8023(struct iee
87 struct ieee80211_vif *vif,
88 struct sk_buff *skb)
89 {
90 - struct ieee80211_local *local = hw_to_local(hw);
91 struct ieee80211_sub_if_data *sdata;
92 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
93 + struct ieee80211_tx_status status = {
94 + .skb = skb,
95 + .info = IEEE80211_SKB_CB(skb),
96 + };
97 struct sta_info *sta;
98 - int retry_count;
99 - int rates_idx;
100 - bool acked;
101
102 sdata = vif_to_sdata(vif);
103
104 - acked = info->flags & IEEE80211_TX_STAT_ACK;
105 - rates_idx = ieee80211_tx_get_rates(hw, info, &retry_count);
106 -
107 rcu_read_lock();
108
109 - if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
110 - goto counters_update;
111 -
112 - if (IS_ERR(sta))
113 - goto counters_update;
114 -
115 - if (!acked)
116 - sta->status_stats.retry_failed++;
117 -
118 - if (rates_idx != -1)
119 - sta->tx_stats.last_rate = info->status.rates[rates_idx];
120 -
121 - sta->status_stats.retry_count += retry_count;
122 -
123 - if (ieee80211_hw_check(hw, REPORTS_TX_ACK_STATUS)) {
124 - sta->status_stats.last_ack = jiffies;
125 - if (info->flags & IEEE80211_TX_STAT_ACK) {
126 - if (sta->status_stats.lost_packets)
127 - sta->status_stats.lost_packets = 0;
128 + if (!ieee80211_lookup_ra_sta(sdata, skb, &sta) && !IS_ERR(sta))
129 + status.sta = &sta->sta;
130
131 - sta->status_stats.last_pkt_time = jiffies;
132 - } else {
133 - ieee80211_lost_packet(sta, info);
134 - }
135 - }
136 + ieee80211_tx_status_ext(hw, &status);
137
138 -counters_update:
139 rcu_read_unlock();
140 - ieee80211_led_tx(local);
141 -
142 - if (!(info->flags & IEEE80211_TX_STAT_ACK) &&
143 - !(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED))
144 - goto skip_stats_update;
145 -
146 - I802_DEBUG_INC(local->dot11TransmittedFrameCount);
147 - if (is_multicast_ether_addr(skb->data))
148 - I802_DEBUG_INC(local->dot11MulticastTransmittedFrameCount);
149 - if (retry_count > 0)
150 - I802_DEBUG_INC(local->dot11RetryCount);
151 - if (retry_count > 1)
152 - I802_DEBUG_INC(local->dot11MultipleRetryCount);
153 -
154 -skip_stats_update:
155 - ieee80211_report_used_skb(local, skb, false);
156 - dev_kfree_skb(skb);
157 }
158 EXPORT_SYMBOL(ieee80211_tx_status_8023);
159