Commit c2b17948 authored by Felix Fietkau's avatar Felix Fietkau Committed by Johannes Berg

mac80211: minstrel_ht: automatically calculate rate duration shift

A per-group shift was added to reduce the size of the per-rate transmit
duration field to u16 without sacrificing a lot of precision
This patch changes the macros to automatically calculate the best value for
this shift based on the lowest rate within the group.
This simplifies adding more groups and slightly improves accuracy for some of
the existing groups.
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 7f2e12e1
...@@ -51,8 +51,13 @@ ...@@ -51,8 +51,13 @@
MINSTREL_MAX_STREAMS * _sgi + \ MINSTREL_MAX_STREAMS * _sgi + \
_streams - 1 _streams - 1
#define _MAX(a, b) (((a)>(b))?(a):(b))
#define GROUP_SHIFT(duration) \
_MAX(0, 16 - __builtin_clz(duration))
/* MCS rate information for an MCS group */ /* MCS rate information for an MCS group */
#define MCS_GROUP(_streams, _sgi, _ht40, _s) \ #define __MCS_GROUP(_streams, _sgi, _ht40, _s) \
[GROUP_IDX(_streams, _sgi, _ht40)] = { \ [GROUP_IDX(_streams, _sgi, _ht40)] = { \
.streams = _streams, \ .streams = _streams, \
.shift = _s, \ .shift = _s, \
...@@ -72,6 +77,13 @@ ...@@ -72,6 +77,13 @@
} \ } \
} }
#define MCS_GROUP_SHIFT(_streams, _sgi, _ht40) \
GROUP_SHIFT(MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26))
#define MCS_GROUP(_streams, _sgi, _ht40) \
__MCS_GROUP(_streams, _sgi, _ht40, \
MCS_GROUP_SHIFT(_streams, _sgi, _ht40))
#define VHT_GROUP_IDX(_streams, _sgi, _bw) \ #define VHT_GROUP_IDX(_streams, _sgi, _bw) \
(MINSTREL_VHT_GROUP_0 + \ (MINSTREL_VHT_GROUP_0 + \
MINSTREL_MAX_STREAMS * 2 * (_bw) + \ MINSTREL_MAX_STREAMS * 2 * (_bw) + \
...@@ -81,7 +93,7 @@ ...@@ -81,7 +93,7 @@
#define BW2VBPS(_bw, r3, r2, r1) \ #define BW2VBPS(_bw, r3, r2, r1) \
(_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1) (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
#define VHT_GROUP(_streams, _sgi, _bw, _s) \ #define __VHT_GROUP(_streams, _sgi, _bw, _s) \
[VHT_GROUP_IDX(_streams, _sgi, _bw)] = { \ [VHT_GROUP_IDX(_streams, _sgi, _bw)] = { \
.streams = _streams, \ .streams = _streams, \
.shift = _s, \ .shift = _s, \
...@@ -114,6 +126,14 @@ ...@@ -114,6 +126,14 @@
} \ } \
} }
#define VHT_GROUP_SHIFT(_streams, _sgi, _bw) \
GROUP_SHIFT(MCS_DURATION(_streams, _sgi, \
BW2VBPS(_bw, 117, 54, 26)))
#define VHT_GROUP(_streams, _sgi, _bw) \
__VHT_GROUP(_streams, _sgi, _bw, \
VHT_GROUP_SHIFT(_streams, _sgi, _bw))
#define CCK_DURATION(_bitrate, _short, _len) \ #define CCK_DURATION(_bitrate, _short, _len) \
(1000 * (10 /* SIFS */ + \ (1000 * (10 /* SIFS */ + \
(_short ? 72 + 24 : 144 + 48) + \ (_short ? 72 + 24 : 144 + 48) + \
...@@ -129,7 +149,7 @@ ...@@ -129,7 +149,7 @@
CCK_ACK_DURATION(55, _short) >> _s, \ CCK_ACK_DURATION(55, _short) >> _s, \
CCK_ACK_DURATION(110, _short) >> _s CCK_ACK_DURATION(110, _short) >> _s
#define CCK_GROUP(_s) \ #define __CCK_GROUP(_s) \
[MINSTREL_CCK_GROUP] = { \ [MINSTREL_CCK_GROUP] = { \
.streams = 1, \ .streams = 1, \
.flags = 0, \ .flags = 0, \
...@@ -140,6 +160,12 @@ ...@@ -140,6 +160,12 @@
} \ } \
} }
#define CCK_GROUP_SHIFT \
GROUP_SHIFT(CCK_ACK_DURATION(10, false))
#define CCK_GROUP __CCK_GROUP(CCK_GROUP_SHIFT)
static bool minstrel_vht_only = true; static bool minstrel_vht_only = true;
module_param(minstrel_vht_only, bool, 0644); module_param(minstrel_vht_only, bool, 0644);
MODULE_PARM_DESC(minstrel_vht_only, MODULE_PARM_DESC(minstrel_vht_only,
...@@ -154,57 +180,57 @@ MODULE_PARM_DESC(minstrel_vht_only, ...@@ -154,57 +180,57 @@ MODULE_PARM_DESC(minstrel_vht_only,
* BW -> SGI -> #streams * BW -> SGI -> #streams
*/ */
const struct mcs_group minstrel_mcs_groups[] = { const struct mcs_group minstrel_mcs_groups[] = {
MCS_GROUP(1, 0, BW_20, 5), MCS_GROUP(1, 0, BW_20),
MCS_GROUP(2, 0, BW_20, 4), MCS_GROUP(2, 0, BW_20),
MCS_GROUP(3, 0, BW_20, 4), MCS_GROUP(3, 0, BW_20),
MCS_GROUP(4, 0, BW_20, 4), MCS_GROUP(4, 0, BW_20),
MCS_GROUP(1, 1, BW_20, 5), MCS_GROUP(1, 1, BW_20),
MCS_GROUP(2, 1, BW_20, 4), MCS_GROUP(2, 1, BW_20),
MCS_GROUP(3, 1, BW_20, 4), MCS_GROUP(3, 1, BW_20),
MCS_GROUP(4, 1, BW_20, 4), MCS_GROUP(4, 1, BW_20),
MCS_GROUP(1, 0, BW_40, 4), MCS_GROUP(1, 0, BW_40),
MCS_GROUP(2, 0, BW_40, 4), MCS_GROUP(2, 0, BW_40),
MCS_GROUP(3, 0, BW_40, 4), MCS_GROUP(3, 0, BW_40),
MCS_GROUP(4, 0, BW_40, 4), MCS_GROUP(4, 0, BW_40),
MCS_GROUP(1, 1, BW_40, 4), MCS_GROUP(1, 1, BW_40),
MCS_GROUP(2, 1, BW_40, 4), MCS_GROUP(2, 1, BW_40),
MCS_GROUP(3, 1, BW_40, 4), MCS_GROUP(3, 1, BW_40),
MCS_GROUP(4, 1, BW_40, 4), MCS_GROUP(4, 1, BW_40),
CCK_GROUP(8), CCK_GROUP,
VHT_GROUP(1, 0, BW_20, 5), VHT_GROUP(1, 0, BW_20),
VHT_GROUP(2, 0, BW_20, 4), VHT_GROUP(2, 0, BW_20),
VHT_GROUP(3, 0, BW_20, 4), VHT_GROUP(3, 0, BW_20),
VHT_GROUP(4, 0, BW_20, 4), VHT_GROUP(4, 0, BW_20),
VHT_GROUP(1, 1, BW_20, 5), VHT_GROUP(1, 1, BW_20),
VHT_GROUP(2, 1, BW_20, 4), VHT_GROUP(2, 1, BW_20),
VHT_GROUP(3, 1, BW_20, 4), VHT_GROUP(3, 1, BW_20),
VHT_GROUP(4, 1, BW_20, 4), VHT_GROUP(4, 1, BW_20),
VHT_GROUP(1, 0, BW_40, 4), VHT_GROUP(1, 0, BW_40),
VHT_GROUP(2, 0, BW_40, 4), VHT_GROUP(2, 0, BW_40),
VHT_GROUP(3, 0, BW_40, 4), VHT_GROUP(3, 0, BW_40),
VHT_GROUP(4, 0, BW_40, 3), VHT_GROUP(4, 0, BW_40),
VHT_GROUP(1, 1, BW_40, 4), VHT_GROUP(1, 1, BW_40),
VHT_GROUP(2, 1, BW_40, 4), VHT_GROUP(2, 1, BW_40),
VHT_GROUP(3, 1, BW_40, 4), VHT_GROUP(3, 1, BW_40),
VHT_GROUP(4, 1, BW_40, 3), VHT_GROUP(4, 1, BW_40),
VHT_GROUP(1, 0, BW_80, 4), VHT_GROUP(1, 0, BW_80),
VHT_GROUP(2, 0, BW_80, 4), VHT_GROUP(2, 0, BW_80),
VHT_GROUP(3, 0, BW_80, 4), VHT_GROUP(3, 0, BW_80),
VHT_GROUP(4, 0, BW_80, 2), VHT_GROUP(4, 0, BW_80),
VHT_GROUP(1, 1, BW_80, 4), VHT_GROUP(1, 1, BW_80),
VHT_GROUP(2, 1, BW_80, 4), VHT_GROUP(2, 1, BW_80),
VHT_GROUP(3, 1, BW_80, 4), VHT_GROUP(3, 1, BW_80),
VHT_GROUP(4, 1, BW_80, 2), VHT_GROUP(4, 1, BW_80),
}; };
static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly; static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment