1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 1 Mar 2018 13:28:48 +0100
3 Subject: [PATCH] mac80211: minstrel: fix sampling/reporting of CCK rates
6 Long/short preamble selection cannot be sampled separately, since it
7 depends on the BSS state. Because of that, sampling attempts to
8 currently not used preamble modes are not counted in the statistics,
9 which leads to CCK rates being sampled too often.
11 Fix statistics accounting for long/short preamble by increasing the
12 index where necessary.
13 Fix excessive CCK rate sampling by dropping unsupported sample attempts.
15 This improves throughput on 2.4 GHz channels
17 Signed-off-by: Felix Fietkau <nbd@nbd.name>
20 --- a/net/mac80211/rc80211_minstrel_ht.c
21 +++ b/net/mac80211/rc80211_minstrel_ht.c
22 @@ -281,7 +281,8 @@ minstrel_ht_get_stats(struct minstrel_pr
26 - if (!(mi->supported[group] & BIT(idx)))
27 + if ((mi->supported[group] & BIT(idx + 4)) &&
28 + (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
31 return &mi->groups[group].rates[idx];
32 @@ -1080,18 +1081,23 @@ minstrel_ht_get_rate(void *priv, struct
35 sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
36 + sample_idx %= MCS_GROUP_RATES;
38 + if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP] &&
39 + (sample_idx >= 4) != txrc->short_preamble)
42 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
45 - if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
46 + if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP]) {
47 int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
48 rate->idx = mp->cck_rates[idx];
49 } else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) {
50 ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES,
51 sample_group->streams);
53 - rate->idx = sample_idx % MCS_GROUP_RATES +
54 - (sample_group->streams - 1) * 8;
55 + rate->idx = sample_idx + (sample_group->streams - 1) * 8;
58 rate->flags = sample_group->flags;