e0049c36eb60205e08b7a6b56b3baf45019e6ca6
[openwrt/staging/dangole.git] /
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
4 in HT mode
5
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.
10
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.
14
15 This improves throughput on 2.4 GHz channels
16
17 Signed-off-by: Felix Fietkau <nbd@nbd.name>
18 ---
19
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
23 break;
24
25 /* short preamble */
26 - if (!(mi->supported[group] & BIT(idx)))
27 + if ((mi->supported[group] & BIT(idx + 4)) &&
28 + (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
29 idx += 4;
30 }
31 return &mi->groups[group].rates[idx];
32 @@ -1080,18 +1081,23 @@ minstrel_ht_get_rate(void *priv, struct
33 return;
34
35 sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
36 + sample_idx %= MCS_GROUP_RATES;
37 +
38 + if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP] &&
39 + (sample_idx >= 4) != txrc->short_preamble)
40 + return;
41 +
42 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
43 rate->count = 1;
44
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);
52 } else {
53 - rate->idx = sample_idx % MCS_GROUP_RATES +
54 - (sample_group->streams - 1) * 8;
55 + rate->idx = sample_idx + (sample_group->streams - 1) * 8;
56 }
57
58 rate->flags = sample_group->flags;