1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat, 23 Jan 2021 07:18:26 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: remove sample rate switching code for
6 This was added to mitigate the effects of too much sampling on devices that
7 use a static global fallback table instead of configurable multi-rate retry.
8 Now that the sampling algorithm is improved, this code path no longer performs
9 any better than the standard probing on affected devices.
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 --- a/net/mac80211/rc80211_minstrel_ht.c
15 +++ b/net/mac80211/rc80211_minstrel_ht.c
16 @@ -648,27 +648,6 @@ __minstrel_ht_get_sample_rate(struct min
21 -minstrel_ht_rate_sample_switch(struct minstrel_priv *mp,
22 - struct minstrel_ht_sta *mi)
27 - * Use rate switching instead of probing packets for devices with
28 - * little control over retry fallback behavior
30 - if (mp->hw->max_rates > 1)
33 - rate = __minstrel_ht_get_sample_rate(mi, MINSTREL_SAMPLE_TYPE_INC);
37 - mi->sample_rate = rate;
38 - mi->sample_mode = MINSTREL_SAMPLE_ACTIVE;
42 minstrel_ewma(int old, int new, int weight)
44 @@ -1012,8 +991,7 @@ minstrel_ht_refill_sample_rates(struct m
45 * higher throughput rates, even if the probablity is a bit lower
48 -minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
50 +minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
52 struct minstrel_mcs_group_data *mg;
53 struct minstrel_rate_stats *mrs;
54 @@ -1023,18 +1001,6 @@ minstrel_ht_update_stats(struct minstrel
56 bool ht_supported = mi->sta->ht_cap.ht_supported;
58 - mi->sample_mode = MINSTREL_SAMPLE_IDLE;
61 - mi->total_packets_cur = mi->total_packets -
62 - mi->total_packets_last;
63 - mi->total_packets_last = mi->total_packets;
65 - if (!mp->sample_switch)
67 - if (mi->total_packets_cur < SAMPLE_SWITCH_THR && mp->sample_switch != 1)
70 if (mi->ampdu_packets > 0) {
71 if (!ieee80211_hw_check(mp->hw, TX_STATUS_NO_AMPDU_LEN))
72 mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
73 @@ -1149,16 +1115,12 @@ minstrel_ht_update_stats(struct minstrel
74 minstrel_ht_prob_rate_reduce_streams(mi);
75 minstrel_ht_refill_sample_rates(mi);
78 - minstrel_ht_rate_sample_switch(mp, mi);
80 #ifdef CPTCFG_MAC80211_DEBUGFS
81 /* use fixed index if set */
82 if (mp->fixed_rate_idx != -1) {
83 for (i = 0; i < 4; i++)
84 mi->max_tp_rate[i] = mp->fixed_rate_idx;
85 mi->max_prob_rate = mp->fixed_rate_idx;
86 - mi->sample_mode = MINSTREL_SAMPLE_IDLE;
90 @@ -1248,11 +1210,10 @@ minstrel_ht_tx_status(void *priv, struct
91 struct ieee80211_tx_info *info = st->info;
92 struct minstrel_ht_sta *mi = priv_sta;
93 struct ieee80211_tx_rate *ar = info->status.rates;
94 - struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL;
95 + struct minstrel_rate_stats *rate, *rate2;
96 struct minstrel_priv *mp = priv;
97 u32 update_interval = mp->update_interval;
98 bool last, update = false;
99 - bool sample_status = false;
102 /* This packet was aggregated but doesn't carry status info */
103 @@ -1279,49 +1240,18 @@ minstrel_ht_tx_status(void *priv, struct
105 mi->ampdu_len += info->status.ampdu_len;
107 - if (mi->sample_mode != MINSTREL_SAMPLE_IDLE)
108 - rate_sample = minstrel_get_ratestats(mi, mi->sample_rate);
110 last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]);
111 for (i = 0; !last; i++) {
112 last = (i == IEEE80211_TX_MAX_RATES - 1) ||
113 !minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]);
115 rate = minstrel_ht_get_stats(mp, mi, &ar[i]);
116 - if (rate == rate_sample)
117 - sample_status = true;
120 rate->success += info->status.ampdu_ack_len;
122 rate->attempts += ar[i].count * info->status.ampdu_len;
125 - switch (mi->sample_mode) {
126 - case MINSTREL_SAMPLE_IDLE:
127 - if (mp->hw->max_rates > 1 ||
128 - mi->total_packets_cur < SAMPLE_SWITCH_THR)
129 - update_interval /= 2;
132 - case MINSTREL_SAMPLE_ACTIVE:
133 - if (!sample_status)
136 - mi->sample_mode = MINSTREL_SAMPLE_PENDING;
140 - case MINSTREL_SAMPLE_PENDING:
145 - minstrel_ht_update_stats(mp, mi, false);
150 if (mp->hw->max_rates > 1) {
152 * check for sudden death of spatial multiplexing,
153 @@ -1344,7 +1274,7 @@ minstrel_ht_tx_status(void *priv, struct
155 if (time_after(jiffies, mi->last_stats_update + update_interval)) {
157 - minstrel_ht_update_stats(mp, mi, true);
158 + minstrel_ht_update_stats(mp, mi);
162 @@ -1523,18 +1453,14 @@ static void
163 minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
165 struct ieee80211_sta_rates *rates;
166 - u16 first_rate = mi->max_tp_rate[0];
169 - if (mi->sample_mode == MINSTREL_SAMPLE_ACTIVE)
170 - first_rate = mi->sample_rate;
172 rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
176 /* Start with max_tp_rate[0] */
177 - minstrel_ht_set_rate(mp, mi, rates, i++, first_rate);
178 + minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]);
180 if (mp->hw->max_rates >= 3) {
181 /* At least 3 tx rates supported, use max_tp_rate[1] next */
182 @@ -1593,11 +1519,6 @@ minstrel_ht_get_rate(void *priv, struct
183 (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO))
186 - if (mp->hw->max_rates == 1 && mp->sample_switch &&
187 - (mi->total_packets_cur >= SAMPLE_SWITCH_THR ||
188 - mp->sample_switch == 1))
191 if (time_is_before_jiffies(mi->sample_time))
194 @@ -1811,7 +1732,7 @@ minstrel_ht_update_caps(void *priv, stru
195 minstrel_ht_update_ofdm(mp, mi, sband, sta);
197 /* create an initial rate table with the lowest supported rates */
198 - minstrel_ht_update_stats(mp, mi, true);
199 + minstrel_ht_update_stats(mp, mi);
200 minstrel_ht_update_rates(mp, mi);
203 @@ -1927,8 +1848,6 @@ minstrel_ht_alloc(struct ieee80211_hw *h
207 - mp->sample_switch = -1;
209 /* contention window settings
210 * Just an approximation. Using the per-queue values would complicate
211 * the calculations and is probably unnecessary */
212 @@ -1948,7 +1867,7 @@ minstrel_ht_alloc(struct ieee80211_hw *h
216 - mp->update_interval = HZ / 10;
217 + mp->update_interval = HZ / 20;
219 minstrel_ht_init_cck_rates(mp);
220 for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++)
221 @@ -1966,8 +1885,6 @@ static void minstrel_ht_add_debugfs(stru
222 mp->fixed_rate_idx = (u32) -1;
223 debugfs_create_u32("fixed_rate_idx", S_IRUGO | S_IWUGO, debugfsdir,
224 &mp->fixed_rate_idx);
225 - debugfs_create_u32("sample_switch", S_IRUGO | S_IWUSR, debugfsdir,
226 - &mp->sample_switch);
230 --- a/net/mac80211/rc80211_minstrel_ht.h
231 +++ b/net/mac80211/rc80211_minstrel_ht.h
233 struct minstrel_priv {
234 struct ieee80211_hw *hw;
239 unsigned int max_retry;
240 @@ -147,12 +146,6 @@ struct minstrel_mcs_group_data {
241 struct minstrel_rate_stats rates[MCS_GROUP_RATES];
244 -enum minstrel_sample_mode {
245 - MINSTREL_SAMPLE_IDLE,
246 - MINSTREL_SAMPLE_ACTIVE,
247 - MINSTREL_SAMPLE_PENDING,
250 struct minstrel_sample_category {
252 u16 sample_rates[MINSTREL_SAMPLE_RATES];
253 @@ -182,23 +175,19 @@ struct minstrel_ht_sta {
254 unsigned int overhead_legacy;
255 unsigned int overhead_legacy_rtscts;
257 - unsigned int total_packets_last;
258 - unsigned int total_packets_cur;
259 unsigned int total_packets;
260 unsigned int sample_packets;
262 /* tx flags to add for frames for this sta */
265 - unsigned long sample_time;
266 - struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX];
271 - enum minstrel_sample_mode sample_mode;
275 + unsigned long sample_time;
276 + struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX];
278 /* Bitfield of supported MCS rates of all groups */
279 u16 supported[MINSTREL_GROUPS_NB];