a8e6e899544932a33753d444be2b8ff71498d3f2
[openwrt/staging/chunkeey.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat, 26 Dec 2020 19:08:19 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: improve ampdu length estimation
4
5 If the driver does not report A-MPDU length, estimate it based on the rate.
6
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
9
10 --- a/net/mac80211/rc80211_minstrel_ht.c
11 +++ b/net/mac80211/rc80211_minstrel_ht.c
12 @@ -382,13 +382,37 @@ minstrel_get_ratestats(struct minstrel_h
13 return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
14 }
15
16 +static inline int
17 +minstrel_get_duration(int index)
18 +{
19 + const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
20 + unsigned int duration = group->duration[index % MCS_GROUP_RATES];
21 + return duration << group->shift;
22 +}
23 +
24 static unsigned int
25 minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi)
26 {
27 - if (!mi->avg_ampdu_len)
28 - return AVG_AMPDU_SIZE;
29 + int duration;
30 +
31 + if (mi->avg_ampdu_len)
32 + return MINSTREL_TRUNC(mi->avg_ampdu_len);
33 +
34 + if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES))
35 + return 1;
36 +
37 + duration = minstrel_get_duration(mi->max_tp_rate[0]);
38
39 - return MINSTREL_TRUNC(mi->avg_ampdu_len);
40 + if (duration > 400 * 1000)
41 + return 2;
42 +
43 + if (duration > 250 * 1000)
44 + return 4;
45 +
46 + if (duration > 150 * 1000)
47 + return 8;
48 +
49 + return 16;
50 }
51
52 /*
53 @@ -588,14 +612,6 @@ minstrel_ht_prob_rate_reduce_streams(str
54 }
55 }
56
57 -static inline int
58 -minstrel_get_duration(int index)
59 -{
60 - const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
61 - unsigned int duration = group->duration[index % MCS_GROUP_RATES];
62 - return duration << group->shift;
63 -}
64 -
65 static bool
66 minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group,
67 int tp_idx, const struct mcs_group *group)