Skip to content

Commit c0eb09a

Browse files
nbd168jmberg-intel
authored andcommitted
mac80211: minstrel_ht: remove sample rate switching code for constrained devices
This was added to mitigate the effects of too much sampling on devices that use a static global fallback table instead of configurable multi-rate retry. Now that the sampling algorithm is improved, this code path no longer performs any better than the standard probing on affected devices. Signed-off-by: Felix Fietkau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 4a8d0c9 commit c0eb09a

File tree

2 files changed

+9
-103
lines changed

2 files changed

+9
-103
lines changed

net/mac80211/rc80211_minstrel_ht.c

Lines changed: 6 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -648,27 +648,6 @@ __minstrel_ht_get_sample_rate(struct minstrel_ht_sta *mi,
648648
return 0;
649649
}
650650

651-
static void
652-
minstrel_ht_rate_sample_switch(struct minstrel_priv *mp,
653-
struct minstrel_ht_sta *mi)
654-
{
655-
u16 rate;
656-
657-
/*
658-
* Use rate switching instead of probing packets for devices with
659-
* little control over retry fallback behavior
660-
*/
661-
if (mp->hw->max_rates > 1)
662-
return;
663-
664-
rate = __minstrel_ht_get_sample_rate(mi, MINSTREL_SAMPLE_TYPE_INC);
665-
if (!rate)
666-
return;
667-
668-
mi->sample_rate = rate;
669-
mi->sample_mode = MINSTREL_SAMPLE_ACTIVE;
670-
}
671-
672651
static inline int
673652
minstrel_ewma(int old, int new, int weight)
674653
{
@@ -1012,8 +991,7 @@ minstrel_ht_refill_sample_rates(struct minstrel_ht_sta *mi)
1012991
* higher throughput rates, even if the probablity is a bit lower
1013992
*/
1014993
static void
1015-
minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
1016-
bool sample)
994+
minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
1017995
{
1018996
struct minstrel_mcs_group_data *mg;
1019997
struct minstrel_rate_stats *mrs;
@@ -1023,18 +1001,6 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
10231001
u16 index;
10241002
bool ht_supported = mi->sta->ht_cap.ht_supported;
10251003

1026-
mi->sample_mode = MINSTREL_SAMPLE_IDLE;
1027-
1028-
if (sample) {
1029-
mi->total_packets_cur = mi->total_packets -
1030-
mi->total_packets_last;
1031-
mi->total_packets_last = mi->total_packets;
1032-
}
1033-
if (!mp->sample_switch)
1034-
sample = false;
1035-
if (mi->total_packets_cur < SAMPLE_SWITCH_THR && mp->sample_switch != 1)
1036-
sample = false;
1037-
10381004
if (mi->ampdu_packets > 0) {
10391005
if (!ieee80211_hw_check(mp->hw, TX_STATUS_NO_AMPDU_LEN))
10401006
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -1148,16 +1114,12 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
11481114
minstrel_ht_prob_rate_reduce_streams(mi);
11491115
minstrel_ht_refill_sample_rates(mi);
11501116

1151-
if (sample)
1152-
minstrel_ht_rate_sample_switch(mp, mi);
1153-
11541117
#ifdef CONFIG_MAC80211_DEBUGFS
11551118
/* use fixed index if set */
11561119
if (mp->fixed_rate_idx != -1) {
11571120
for (i = 0; i < 4; i++)
11581121
mi->max_tp_rate[i] = mp->fixed_rate_idx;
11591122
mi->max_prob_rate = mp->fixed_rate_idx;
1160-
mi->sample_mode = MINSTREL_SAMPLE_IDLE;
11611123
}
11621124
#endif
11631125

@@ -1247,11 +1209,10 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
12471209
struct ieee80211_tx_info *info = st->info;
12481210
struct minstrel_ht_sta *mi = priv_sta;
12491211
struct ieee80211_tx_rate *ar = info->status.rates;
1250-
struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL;
1212+
struct minstrel_rate_stats *rate, *rate2;
12511213
struct minstrel_priv *mp = priv;
12521214
u32 update_interval = mp->update_interval;
12531215
bool last, update = false;
1254-
bool sample_status = false;
12551216
int i;
12561217

12571218
/* This packet was aggregated but doesn't carry status info */
@@ -1278,49 +1239,18 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
12781239
mi->ampdu_packets++;
12791240
mi->ampdu_len += info->status.ampdu_len;
12801241

1281-
if (mi->sample_mode != MINSTREL_SAMPLE_IDLE)
1282-
rate_sample = minstrel_get_ratestats(mi, mi->sample_rate);
1283-
12841242
last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]);
12851243
for (i = 0; !last; i++) {
12861244
last = (i == IEEE80211_TX_MAX_RATES - 1) ||
12871245
!minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]);
12881246

12891247
rate = minstrel_ht_get_stats(mp, mi, &ar[i]);
1290-
if (rate == rate_sample)
1291-
sample_status = true;
1292-
12931248
if (last)
12941249
rate->success += info->status.ampdu_ack_len;
12951250

12961251
rate->attempts += ar[i].count * info->status.ampdu_len;
12971252
}
12981253

1299-
switch (mi->sample_mode) {
1300-
case MINSTREL_SAMPLE_IDLE:
1301-
if (mp->hw->max_rates > 1 ||
1302-
mi->total_packets_cur < SAMPLE_SWITCH_THR)
1303-
update_interval /= 2;
1304-
break;
1305-
1306-
case MINSTREL_SAMPLE_ACTIVE:
1307-
if (!sample_status)
1308-
break;
1309-
1310-
mi->sample_mode = MINSTREL_SAMPLE_PENDING;
1311-
update = true;
1312-
break;
1313-
1314-
case MINSTREL_SAMPLE_PENDING:
1315-
if (sample_status)
1316-
break;
1317-
1318-
update = true;
1319-
minstrel_ht_update_stats(mp, mi, false);
1320-
break;
1321-
}
1322-
1323-
13241254
if (mp->hw->max_rates > 1) {
13251255
/*
13261256
* check for sudden death of spatial multiplexing,
@@ -1343,7 +1273,7 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
13431273

13441274
if (time_after(jiffies, mi->last_stats_update + update_interval)) {
13451275
update = true;
1346-
minstrel_ht_update_stats(mp, mi, true);
1276+
minstrel_ht_update_stats(mp, mi);
13471277
}
13481278

13491279
if (update)
@@ -1522,18 +1452,14 @@ static void
15221452
minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
15231453
{
15241454
struct ieee80211_sta_rates *rates;
1525-
u16 first_rate = mi->max_tp_rate[0];
15261455
int i = 0;
15271456

1528-
if (mi->sample_mode == MINSTREL_SAMPLE_ACTIVE)
1529-
first_rate = mi->sample_rate;
1530-
15311457
rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
15321458
if (!rates)
15331459
return;
15341460

15351461
/* Start with max_tp_rate[0] */
1536-
minstrel_ht_set_rate(mp, mi, rates, i++, first_rate);
1462+
minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]);
15371463

15381464
if (mp->hw->max_rates >= 3) {
15391465
/* At least 3 tx rates supported, use max_tp_rate[1] next */
@@ -1592,11 +1518,6 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
15921518
(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO))
15931519
return;
15941520

1595-
if (mp->hw->max_rates == 1 && mp->sample_switch &&
1596-
(mi->total_packets_cur >= SAMPLE_SWITCH_THR ||
1597-
mp->sample_switch == 1))
1598-
return;
1599-
16001521
if (time_is_before_jiffies(mi->sample_time))
16011522
return;
16021523

@@ -1810,7 +1731,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
18101731
minstrel_ht_update_ofdm(mp, mi, sband, sta);
18111732

18121733
/* create an initial rate table with the lowest supported rates */
1813-
minstrel_ht_update_stats(mp, mi, true);
1734+
minstrel_ht_update_stats(mp, mi);
18141735
minstrel_ht_update_rates(mp, mi);
18151736
}
18161737

@@ -1926,8 +1847,6 @@ minstrel_ht_alloc(struct ieee80211_hw *hw)
19261847
if (!mp)
19271848
return NULL;
19281849

1929-
mp->sample_switch = -1;
1930-
19311850
/* contention window settings
19321851
* Just an approximation. Using the per-queue values would complicate
19331852
* the calculations and is probably unnecessary */
@@ -1947,7 +1866,7 @@ minstrel_ht_alloc(struct ieee80211_hw *hw)
19471866
mp->has_mrr = true;
19481867

19491868
mp->hw = hw;
1950-
mp->update_interval = HZ / 10;
1869+
mp->update_interval = HZ / 20;
19511870

19521871
minstrel_ht_init_cck_rates(mp);
19531872
for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++)
@@ -1965,8 +1884,6 @@ static void minstrel_ht_add_debugfs(struct ieee80211_hw *hw, void *priv,
19651884
mp->fixed_rate_idx = (u32) -1;
19661885
debugfs_create_u32("fixed_rate_idx", S_IRUGO | S_IWUGO, debugfsdir,
19671886
&mp->fixed_rate_idx);
1968-
debugfs_create_u32("sample_switch", S_IRUGO | S_IWUSR, debugfsdir,
1969-
&mp->sample_switch);
19701887
}
19711888
#endif
19721889

net/mac80211/rc80211_minstrel_ht.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
struct minstrel_priv {
7676
struct ieee80211_hw *hw;
7777
bool has_mrr;
78-
u32 sample_switch;
7978
unsigned int cw_min;
8079
unsigned int cw_max;
8180
unsigned int max_retry;
@@ -147,12 +146,6 @@ struct minstrel_mcs_group_data {
147146
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
148147
};
149148

150-
enum minstrel_sample_mode {
151-
MINSTREL_SAMPLE_IDLE,
152-
MINSTREL_SAMPLE_ACTIVE,
153-
MINSTREL_SAMPLE_PENDING,
154-
};
155-
156149
struct minstrel_sample_category {
157150
u8 sample_group;
158151
u16 sample_rates[MINSTREL_SAMPLE_RATES];
@@ -182,23 +175,19 @@ struct minstrel_ht_sta {
182175
unsigned int overhead_legacy;
183176
unsigned int overhead_legacy_rtscts;
184177

185-
unsigned int total_packets_last;
186-
unsigned int total_packets_cur;
187178
unsigned int total_packets;
188179
unsigned int sample_packets;
189180

190181
/* tx flags to add for frames for this sta */
191182
u32 tx_flags;
192183

193-
unsigned long sample_time;
194-
struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX];
184+
u8 band;
195185

196186
u8 sample_seq;
197-
198-
enum minstrel_sample_mode sample_mode;
199187
u16 sample_rate;
200188

201-
u8 band;
189+
unsigned long sample_time;
190+
struct minstrel_sample_category sample[__MINSTREL_SAMPLE_TYPE_MAX];
202191

203192
/* Bitfield of supported MCS rates of all groups */
204193
u16 supported[MINSTREL_GROUPS_NB];

0 commit comments

Comments
 (0)