add chaos_calmer branch
[15.05/openwrt.git] / package / kernel / mac80211 / patches / 308-mac80211-minstrel_ht-fix-rounding-issue-in-MCS-durat.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Fri, 13 Mar 2015 10:49:40 +0100
3 Subject: [PATCH] mac80211: minstrel_ht: fix rounding issue in MCS duration
4  calculation
5
6 On very high MCS bitrates, the calculated duration of rates that are
7 next to each other can be very imprecise, due to the small packet size
8 used as reference (1200 bytes).
9 This is most visible in VHT80 nss=2 MCS8/9, for which minstrel shows the
10 same throughput when the probability is also the same. This leads to a
11 bad rate selection for such rates.
12
13 Fix this issue by introducing an average A-MPDU size factor into the
14 calculation.
15
16 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
17 ---
18
19 --- a/net/mac80211/rc80211_minstrel_ht.c
20 +++ b/net/mac80211/rc80211_minstrel_ht.c
21 @@ -17,10 +17,11 @@
22  #include "rc80211_minstrel.h"
23  #include "rc80211_minstrel_ht.h"
24  
25 +#define AVG_AMPDU_SIZE 16
26  #define AVG_PKT_SIZE   1200
27  
28  /* Number of bits for an average sized packet */
29 -#define MCS_NBITS (AVG_PKT_SIZE << 3)
30 +#define MCS_NBITS ((AVG_PKT_SIZE * AVG_AMPDU_SIZE) << 3)
31  
32  /* Number of symbols for a packet with (bps) bits per symbol */
33  #define MCS_NSYMS(bps) DIV_ROUND_UP(MCS_NBITS, (bps))
34 @@ -33,7 +34,8 @@
35         )
36  
37  /* Transmit duration for the raw data part of an average sized packet */
38 -#define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps)))
39 +#define MCS_DURATION(streams, sgi, bps) \
40 +       (MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps))) / AVG_AMPDU_SIZE)
41  
42  #define BW_20                  0
43  #define BW_40                  1