mac80211: minstrel: Enable STBC and LDPC for VHT Rates
Subsystems (2)
PATCH 1/9 mac80211: minstrel: Enable STBC and LDPC for VHT Rates
From: Chaitanya T K <[email protected]>
If peer support reception of STBC and LDPC, enable them for better performance.
--- include/linux/ieee80211.h | 1 + net/mac80211/rc80211_minstrel_ht.c | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-)
include/linux/ieee80211.h +1 -0
@@ -1670,6 +1670,7 @@ struct ieee80211_mu_edca_param_set {#define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300#define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400#define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 +#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000#define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
net/mac80211/rc80211_minstrel_ht.c +15 -8
@@ -1130,7 +1130,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,struct minstrel_ht_sta_priv *msp = priv_sta;struct minstrel_ht_sta *mi = &msp->ht;struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs; -u16 sta_cap = sta->ht_cap.cap; +u16 ht_cap = sta->ht_cap.cap;struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; struct sta_info *sinfo = container_of(sta, struct sta_info, sta);int use_vht;
@@ -1138,6 +1138,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,int ack_dur;int stbc;int i; +bool ldpc;/* fall back to the old minstrel for legacy stations */ if (!sta->ht_cap.ht_supported)
@@ -1175,16 +1176,22 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband, } mi->sample_tries =4 ; -/* TODO tx_flags for vht - ATM the RC API is not fine-grained enough */ if (!use_vht) { - stbc = (sta_cap &IEEE80211_HT_CAP_RX_STBC ) >> + stbc = (ht_cap &IEEE80211_HT_CAP_RX_STBC ) >>IEEE80211_HT_CAP_RX_STBC_SHIFT ; - mi->tx_flags |= stbc <<IEEE80211_TX_CTL_STBC_SHIFT ; -if (sta_cap &IEEE80211_HT_CAP_LDPC_CODING ) - mi->tx_flags |=IEEE80211_TX_CTL_LDPC ; + ldpc = ht_cap &IEEE80211_HT_CAP_LDPC_CODING ; + }else { + stbc = (vht_cap->cap &IEEE80211_VHT_CAP_RXSTBC_MASK ) >> +IEEE80211_VHT_CAP_RXSTBC_SHIFT ; + + ldpc = vht_cap->cap &IEEE80211_VHT_CAP_RXLDPC ; } + mi->tx_flags |= stbc <<IEEE80211_TX_CTL_STBC_SHIFT ; +if (ldpc) + mi->tx_flags |=IEEE80211_TX_CTL_LDPC ; +for (i =0 ; i <ARRAY_SIZE (mi->groups); i++) {u32 gflags = minstrel_mcs_groups[i].flags;int bw, nss;
@@ -1197,10 +1204,10 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,if (gflags &IEEE80211_TX_RC_SHORT_GI ) {if (gflags &IEEE80211_TX_RC_40_MHZ_WIDTH ) { -if (!(sta_cap &IEEE80211_HT_CAP_SGI_40 )) +if (!(ht_cap &IEEE80211_HT_CAP_SGI_40 ))continue ; }else { -if (!(sta_cap &IEEE80211_HT_CAP_SGI_20 )) +if (!(ht_cap &IEEE80211_HT_CAP_SGI_20 ))continue ; } }
Signature · 1 line
2.17.0
PATCH 2/9 mac80211: minstrel: remove unnecessary debugfs cleanup code
debugfs entries are cleaned up by debugfs_remove_recursive already.
--- net/mac80211/rc80211_minstrel.c | 8 ++------ net/mac80211/rc80211_minstrel.h | 7 ------- net/mac80211/rc80211_minstrel_debugfs.c | 18 +++--------------- net/mac80211/rc80211_minstrel_ht.c | 1 - net/mac80211/rc80211_minstrel_ht.h | 5 ----- net/mac80211/rc80211_minstrel_ht_debugfs.c | 17 ++++------------- 6 files changed, 9 insertions(+), 47 deletions(-)
net/mac80211/rc80211_minstrel.c +2 -6
@@ -689,8 +689,8 @@ minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)#ifdef CONFIG_MAC80211_DEBUGFS mp->fixed_rate_idx = (u32) -1 ; - mp->dbg_fixed_rate =debugfs_create_u32 ("fixed_rate_idx" , -0666 , debugfsdir, &mp->fixed_rate_idx); +debugfs_create_u32 ("fixed_rate_idx" ,0666 , debugfsdir, + &mp->fixed_rate_idx);#endif minstrel_init_cck_rates (mp);
@@ -701,9 +701,6 @@ minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)static void minstrel_free (void *priv) { -#ifdef CONFIG_MAC80211_DEBUGFS -debugfs_remove (((struct minstrel_priv *)priv)->dbg_fixed_rate); -#endif kfree (priv); }
@@ -735,7 +732,6 @@ const struct rate_control_ops mac80211_minstrel = { .free_sta = minstrel_free_sta, #ifdef CONFIG_MAC80211_DEBUGFS .add_sta_debugfs = minstrel_add_sta_debugfs, - .remove_sta_debugfs = minstrel_remove_sta_debugfs, #endif .get_expected_throughput = minstrel_get_expected_throughput, };
net/mac80211/rc80211_minstrel.h +0 -7
@@ -109,11 +109,6 @@ struct minstrel_sta_info {/* sampling table */ u8 *sample_table; - -#ifdef CONFIG_MAC80211_DEBUGFS -struct dentry *dbg_stats; -struct dentry *dbg_stats_csv; -#endif };struct minstrel_priv {
@@ -137,7 +132,6 @@ struct minstrel_priv {* - setting will be applied on next update */ u32 fixed_rate_idx; -struct dentry *dbg_fixed_rate;#endif };
@@ -156,7 +150,6 @@ minstrel_get_ewmsd10(struct minstrel_rate_stats *mrs)extern const struct rate_control_ops mac80211_minstrel;void minstrel_add_sta_debugfs (void *priv,void *priv_sta,struct dentry *dir); -void minstrel_remove_sta_debugfs (void *priv,void *priv_sta);/* Recalculate success probabilities and counters for a given rate using EWMA */ void minstrel_calc_rate_stats (struct minstrel_rate_stats *mrs);
net/mac80211/rc80211_minstrel_debugfs.c +3 -15
@@ -214,19 +214,7 @@ minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir) {struct minstrel_sta_info *mi = priv_sta; - mi->dbg_stats =debugfs_create_file ("rc_stats" ,0444 , dir, mi, - &minstrel_stat_fops); - - mi->dbg_stats_csv =debugfs_create_file ("rc_stats_csv" ,0444 , dir, mi, - &minstrel_stat_csv_fops); -} - -void -minstrel_remove_sta_debugfs (void *priv,void *priv_sta) -{ -struct minstrel_sta_info *mi = priv_sta; - -debugfs_remove (mi->dbg_stats); - -debugfs_remove (mi->dbg_stats_csv); +debugfs_create_file ("rc_stats" ,0444 , dir, mi, &minstrel_stat_fops); +debugfs_create_file ("rc_stats_csv" ,0444 , dir, mi, + &minstrel_stat_csv_fops); }
net/mac80211/rc80211_minstrel_ht.c +0 -1
@@ -1391,7 +1391,6 @@ static const struct rate_control_ops mac80211_minstrel_ht = { .free = minstrel_ht_free, #ifdef CONFIG_MAC80211_DEBUGFS .add_sta_debugfs = minstrel_ht_add_sta_debugfs, - .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs, #endif .get_expected_throughput = minstrel_ht_get_expected_throughput, };
net/mac80211/rc80211_minstrel_ht.h +0 -5
@@ -110,17 +110,12 @@ struct minstrel_ht_sta_priv {struct minstrel_ht_sta ht;struct minstrel_sta_info legacy; }; -#ifdef CONFIG_MAC80211_DEBUGFS -struct dentry *dbg_stats; -struct dentry *dbg_stats_csv; -#endif void *ratelist;void *sample_table;bool is_ht; };void minstrel_ht_add_sta_debugfs (void *priv,void *priv_sta,struct dentry *dir); -void minstrel_ht_remove_sta_debugfs (void *priv,void *priv_sta);int minstrel_ht_get_tp_avg (struct minstrel_ht_sta *mi,int group,int rate,int prob_ewma);
net/mac80211/rc80211_minstrel_ht_debugfs.c +4 -13
@@ -303,17 +303,8 @@ minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir) {struct minstrel_ht_sta_priv *msp = priv_sta; - msp->dbg_stats =debugfs_create_file ("rc_stats" ,0444 , dir, msp, - &minstrel_ht_stat_fops); - msp->dbg_stats_csv =debugfs_create_file ("rc_stats_csv" ,0444 , dir, msp, - &minstrel_ht_stat_csv_fops); -} - -void -minstrel_ht_remove_sta_debugfs (void *priv,void *priv_sta) -{ -struct minstrel_ht_sta_priv *msp = priv_sta; - -debugfs_remove (msp->dbg_stats); -debugfs_remove (msp->dbg_stats_csv); +debugfs_create_file ("rc_stats" ,0444 , dir, msp, + &minstrel_ht_stat_fops); +debugfs_create_file ("rc_stats_csv" ,0444 , dir, msp, + &minstrel_ht_stat_csv_fops); }
Signature · 1 line
2.17.0
PATCH 3/9 mac80211: minstrel: merge with minstrel_ht, always enable VHT support
In reply to Felix FietkauLegacy-only devices are not very common and the overhead of the extra code for HT and VHT rates is not big enough to justify all those extra lines of code to make it optional.
--- net/mac80211/Kconfig | 17 +-- net/mac80211/Makefile | 11 +- net/mac80211/main.c | 7 - net/mac80211/rate.h | 13 -- net/mac80211/rc80211_minstrel.c | 152 --------------------- net/mac80211/rc80211_minstrel.h | 2 - net/mac80211/rc80211_minstrel_debugfs.c | 42 ------ net/mac80211/rc80211_minstrel_ht.c | 91 ++++++++++-- net/mac80211/rc80211_minstrel_ht.h | 8 -- net/mac80211/rc80211_minstrel_ht_debugfs.c | 16 +++ 10 files changed, 101 insertions(+), 258 deletions(-)
net/mac80211/Kconfig +1 -16
@@ -27,20 +27,6 @@ config MAC80211_RC_MINSTREL ---help--- This option enables the 'minstrel' TX rate control algorithm -config MAC80211_RC_MINSTREL_HT - bool "Minstrel 802.11n support" if EXPERT - depends on MAC80211_RC_MINSTREL - default y - ---help--- - This option enables the 'minstrel_ht' TX rate control algorithm - -config MAC80211_RC_MINSTREL_VHT - bool "Minstrel 802.11ac support" if EXPERT - depends on MAC80211_RC_MINSTREL_HT - default n - ---help--- - This option enables VHT in the 'minstrel_ht' TX rate control algorithm - choice prompt "Default rate control algorithm" depends on MAC80211_HAS_RC
@@ -62,8 +48,7 @@ endchoice config MAC80211_RC_DEFAULT string - default "minstrel_ht" if MAC80211_RC_DEFAULT_MINSTREL && MAC80211_RC_MINSTREL_HT - default "minstrel" if MAC80211_RC_DEFAULT_MINSTREL + default "minstrel_ht" if MAC80211_RC_DEFAULT_MINSTREL default "" endif
net/mac80211/Makefile +6 -5
@@ -53,13 +53,14 @@ mac80211-$(CONFIG_PM) += pm.o CFLAGS_trace.o := -I$(src) -rc80211_minstrel-y := rc80211_minstrel.o -rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_debugfs.o +rc80211_minstrel-y := \ + rc80211_minstrel.o \ + rc80211_minstrel_ht.o -rc80211_minstrel_ht-y := rc80211_minstrel_ht.o -rc80211_minstrel_ht-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_ht_debugfs.o +rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \ + rc80211_minstrel_debugfs.o \ + rc80211_minstrel_ht_debugfs.o mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) -mac80211-$(CONFIG_MAC80211_RC_MINSTREL_HT) += $(rc80211_minstrel_ht-y) ccflags-y += -DDEBUG
net/mac80211/main.c +0 -7
@@ -1375,18 +1375,12 @@ static int __init ieee80211_init(void)if (ret)return ret; - ret =rc80211_minstrel_ht_init (); -if (ret) - goto err_minstrel; - ret =ieee80211_iface_init ();if (ret) goto err_netdev;return 0 ; err_netdev: -rc80211_minstrel_ht_exit (); - err_minstrel:rc80211_minstrel_exit ();return ret;
@@ -1394,7 +1388,6 @@ static int __init ieee80211_init(void) static void __exit ieee80211_exit(void) { -rc80211_minstrel_ht_exit ();rc80211_minstrel_exit ();ieee80211s_stop ();
net/mac80211/rate.h +0 -13
@@ -95,18 +95,5 @@ static inline void rc80211_minstrel_exit(void) }#endif -#ifdef CONFIG_MAC80211_RC_MINSTREL_HT -int rc80211_minstrel_ht_init (void ); -void rc80211_minstrel_ht_exit (void ); -#else -static inline int rc80211_minstrel_ht_init (void ) -{ -return 0 ; -} -static inline void rc80211_minstrel_ht_exit (void ) -{ -} -#endif -#endif /* IEEE80211_RATE_H */
net/mac80211/rc80211_minstrel.c +0 -152
166 lines not on this page · raw message
net/mac80211/rc80211_minstrel.h +0 -2
@@ -158,7 +158,5 @@ int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_ewma);/* debugfs */ int minstrel_stats_open (struct inode *inode,struct file *file);int minstrel_stats_csv_open (struct inode *inode,struct file *file); -ssize_t minstrel_stats_read (struct file *file,char __user *buf,size_t len,loff_t *ppos); -int minstrel_stats_release (struct inode *inode,struct file *file);#endif
net/mac80211/rc80211_minstrel_debugfs.c +0 -42
57 lines not on this page · raw message
net/mac80211/rc80211_minstrel_ht.c +78 -13
156 lines not on this page · raw message
net/mac80211/rc80211_minstrel_ht.h +0 -8
@@ -15,11 +15,7 @@*/ #define MINSTREL_MAX_STREAMS 3#define MINSTREL_HT_STREAM_GROUPS 4/* BW(=2) * SGI(=2) */ -#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT #define MINSTREL_VHT_STREAM_GROUPS 6/* BW(=3) * SGI(=2) */ -#else -#define MINSTREL_VHT_STREAM_GROUPS 0 -#endif #define MINSTREL_HT_GROUPS_NB (MINSTREL_MAX_STREAMS * \ MINSTREL_HT_STREAM_GROUPS)
@@ -34,11 +30,7 @@#define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)#define MINSTREL_VHT_GROUP_0 (MINSTREL_CCK_GROUP + 1) -#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT #define MCS_GROUP_RATES 10 -#else -#define MCS_GROUP_RATES 8 -#endif struct mcs_group {u32 flags;
net/mac80211/rc80211_minstrel_ht_debugfs.c +16 -0
@@ -15,6 +15,22 @@#include "rc80211_minstrel.h" #include "rc80211_minstrel_ht.h" +static ssize_t +minstrel_stats_read (struct file *file,char __user *buf,size_t len,loff_t *ppos) +{ +struct minstrel_debugfs_info *ms; + + ms = file->private_data; +return simple_read_from_buffer (buf, len, ppos, ms->buf, ms->len); +} + +static int +minstrel_stats_release (struct inode *inode,struct file *file) +{ +kfree (file->private_data); +return 0 ; +} +static char *minstrel_ht_stats_dump (struct minstrel_ht_sta *mi,int i,char *p) {
Signature · 1 line
2.17.0
PATCH 4/9 mac80211: minstrel: reduce minstrel_mcs_groups size
In reply to Felix FietkauBy storing a shift value for all duration values of a group, we can reduce precision by a neglegible amount to make it fit into a u16 value. This improves cache footprint and reduces size:
Before:
text data bss dec hex filename
10024 116 0 10140 279c rc80211_minstrel_ht.o
After:
text data bss dec hex filename
9368 116 0 9484 250c rc80211_minstrel_ht.o
--- net/mac80211/rc80211_minstrel_ht.c | 153 +++++++++++---------- net/mac80211/rc80211_minstrel_ht.h | 7 +- net/mac80211/rc80211_minstrel_ht_debugfs.c | 11 +- 3 files changed, 93 insertions(+), 78 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +80 -73
@@ -52,22 +52,23 @@ _streams -1 /* MCS rate information for an MCS group */ -#define MCS_GROUP (_streams, _sgi, _ht40) \ +#define MCS_GROUP (_streams, _sgi, _ht40, _s) \ [GROUP_IDX(_streams, _sgi, _ht40)] = { \ .streams = _streams, \ + .shift = _s, \ .flags = \ IEEE80211_TX_RC_MCS | \ (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \ (_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \ .duration = { \ - MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 108 : 52), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 162 : 78), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 216 : 104), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 324 : 156), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 432 : 208), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 486 : 234), \ - MCS_DURATION(_streams, _sgi, _ht40 ? 540 : 260) \ + MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 108 : 52) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 162 : 78) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 216 : 104) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 324 : 156) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 432 : 208) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 486 : 234) >> _s, \ + MCS_DURATION(_streams, _sgi, _ht40 ? 540 : 260) >> _s \ } \ }
@@ -80,9 +81,10 @@#define BW2VBPS (_bw, r3, r2, r1) \ (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1) -#define VHT_GROUP (_streams, _sgi, _bw) \ +#define VHT_GROUP (_streams, _sgi, _bw, _s) \ [VHT_GROUP_IDX(_streams, _sgi, _bw)] = { \ .streams = _streams, \ + .shift = _s, \ .flags = \ IEEE80211_TX_RC_VHT_MCS | \ (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
@@ -90,25 +92,25 @@ _bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \ .duration = { \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,117 ,54 ,26 )), \ +BW2VBPS (_bw,117 ,54 ,26 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,234 ,108 ,52 )), \ +BW2VBPS (_bw,234 ,108 ,52 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,351 ,162 ,78 )), \ +BW2VBPS (_bw,351 ,162 ,78 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,468 ,216 ,104 )), \ +BW2VBPS (_bw,468 ,216 ,104 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,702 ,324 ,156 )), \ +BW2VBPS (_bw,702 ,324 ,156 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,936 ,432 ,208 )), \ +BW2VBPS (_bw,936 ,432 ,208 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,1053 ,486 ,234 )), \ +BW2VBPS (_bw,1053 ,486 ,234 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,1170 ,540 ,260 )), \ +BW2VBPS (_bw,1170 ,540 ,260 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,1404 ,648 ,312 )), \ +BW2VBPS (_bw,1404 ,648 ,312 )) >> _s, \MCS_DURATION (_streams, _sgi, \ -BW2VBPS (_bw,1560 ,720 ,346 )) \ +BW2VBPS (_bw,1560 ,720 ,346 )) >> _s \ } \ }
@@ -121,19 +123,20 @@ (CCK_DURATION ((_bitrate >10 ?20 :10 ), false,60 ) + \ CCK_DURATION(_bitrate, _short, AVG_PKT_SIZE)) -#define CCK_DURATION_LIST (_short) \ - CCK_ACK_DURATION(10, _short), \ - CCK_ACK_DURATION(20, _short), \ - CCK_ACK_DURATION(55, _short), \ - CCK_ACK_DURATION(110, _short) +#define CCK_DURATION_LIST (_short, _s) \ + CCK_ACK_DURATION(10, _short) >> _s, \ + CCK_ACK_DURATION(20, _short) >> _s, \ + CCK_ACK_DURATION(55, _short) >> _s, \ + CCK_ACK_DURATION(110, _short) >> _s -#define CCK_GROUP \ +#define CCK_GROUP (_s) \ [MINSTREL_CCK_GROUP] = { \ .streams = 0, \ .flags = 0, \ + .shift = _s, \ .duration = { \ - CCK_DURATION_LIST(false), \ - CCK_DURATION_LIST(true) \ + CCK_DURATION_LIST(false, _s), \ + CCK_DURATION_LIST(true, _s) \ } \ }
@@ -151,47 +154,47 @@ MODULE_PARM_DESC(minstrel_vht_only,* BW -> SGI -> #streams */ const struct mcs_group minstrel_mcs_groups[] = { -MCS_GROUP (1 ,0 ,BW_20 ), -MCS_GROUP (2 ,0 ,BW_20 ), -MCS_GROUP (3 ,0 ,BW_20 ), +MCS_GROUP (1 ,0 ,BW_20 ,5 ), +MCS_GROUP (2 ,0 ,BW_20 ,4 ), +MCS_GROUP (3 ,0 ,BW_20 ,4 ), -MCS_GROUP (1 ,1 ,BW_20 ), -MCS_GROUP (2 ,1 ,BW_20 ), -MCS_GROUP (3 ,1 ,BW_20 ), +MCS_GROUP (1 ,1 ,BW_20 ,5 ), +MCS_GROUP (2 ,1 ,BW_20 ,4 ), +MCS_GROUP (3 ,1 ,BW_20 ,4 ), -MCS_GROUP (1 ,0 ,BW_40 ), -MCS_GROUP (2 ,0 ,BW_40 ), -MCS_GROUP (3 ,0 ,BW_40 ), +MCS_GROUP (1 ,0 ,BW_40 ,4 ), +MCS_GROUP (2 ,0 ,BW_40 ,4 ), +MCS_GROUP (3 ,0 ,BW_40 ,4 ), -MCS_GROUP (1 ,1 ,BW_40 ), -MCS_GROUP (2 ,1 ,BW_40 ), -MCS_GROUP (3 ,1 ,BW_40 ), +MCS_GROUP (1 ,1 ,BW_40 ,4 ), +MCS_GROUP (2 ,1 ,BW_40 ,4 ), +MCS_GROUP (3 ,1 ,BW_40 ,4 ), -CCK_GROUP , +CCK_GROUP (8 ), -VHT_GROUP (1 ,0 ,BW_20 ), -VHT_GROUP (2 ,0 ,BW_20 ), -VHT_GROUP (3 ,0 ,BW_20 ), +VHT_GROUP (1 ,0 ,BW_20 ,5 ), +VHT_GROUP (2 ,0 ,BW_20 ,4 ), +VHT_GROUP (3 ,0 ,BW_20 ,4 ), -VHT_GROUP (1 ,1 ,BW_20 ), -VHT_GROUP (2 ,1 ,BW_20 ), -VHT_GROUP (3 ,1 ,BW_20 ), +VHT_GROUP (1 ,1 ,BW_20 ,5 ), +VHT_GROUP (2 ,1 ,BW_20 ,4 ), +VHT_GROUP (3 ,1 ,BW_20 ,4 ), -VHT_GROUP (1 ,0 ,BW_40 ), -VHT_GROUP (2 ,0 ,BW_40 ), -VHT_GROUP (3 ,0 ,BW_40 ), +VHT_GROUP (1 ,0 ,BW_40 ,4 ), +VHT_GROUP (2 ,0 ,BW_40 ,4 ), +VHT_GROUP (3 ,0 ,BW_40 ,4 ), -VHT_GROUP (1 ,1 ,BW_40 ), -VHT_GROUP (2 ,1 ,BW_40 ), -VHT_GROUP (3 ,1 ,BW_40 ), +VHT_GROUP (1 ,1 ,BW_40 ,4 ), +VHT_GROUP (2 ,1 ,BW_40 ,4 ), +VHT_GROUP (3 ,1 ,BW_40 ,4 ), -VHT_GROUP (1 ,0 ,BW_80 ), -VHT_GROUP (2 ,0 ,BW_80 ), -VHT_GROUP (3 ,0 ,BW_80 ), +VHT_GROUP (1 ,0 ,BW_80 ,4 ), +VHT_GROUP (2 ,0 ,BW_80 ,4 ), +VHT_GROUP (3 ,0 ,BW_80 ,4 ), -VHT_GROUP (1 ,1 ,BW_80 ), -VHT_GROUP (2 ,1 ,BW_80 ), -VHT_GROUP (3 ,1 ,BW_80 ), +VHT_GROUP (1 ,1 ,BW_80 ,4 ), +VHT_GROUP (2 ,1 ,BW_80 ,4 ), +VHT_GROUP (3 ,1 ,BW_80 ,4 ), };static u8 sample_table[SAMPLE_COLUMNS ][MCS_GROUP_RATES ]__read_mostly ;
@@ -307,7 +310,8 @@ minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,if (group !=MINSTREL_CCK_GROUP ) nsecs =1000 * mi->overhead /MINSTREL_TRUNC (mi->avg_ampdu_len); - nsecs += minstrel_mcs_groups[group].duration[rate]; + nsecs += minstrel_mcs_groups[group].duration[rate] << + minstrel_mcs_groups[group].shift;/* * For the throughput calculation, limit the probability value to 90% to
@@ -755,12 +759,19 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,minstrel_ht_update_rates (mp, mi); } +static inline int +minstrel_get_duration (int index) +{ +const struct mcs_group *group = &minstrel_mcs_groups[index /MCS_GROUP_RATES ]; +unsigned int duration = group->duration[index %MCS_GROUP_RATES ]; +return duration << group->shift; +} +static void minstrel_calc_retransmit (struct minstrel_priv *mp,struct minstrel_ht_sta *mi,int index) {struct minstrel_rate_stats *mrs; -const struct mcs_group *group;unsigned int tx_time, tx_time_rtscts, tx_time_data;unsigned int cw = mp->cw_min;unsigned int ctime =0 ;
@@ -779,8 +790,7 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, mrs->retry_count_rtscts =2 ; mrs->retry_updated = true; - group = &minstrel_mcs_groups[index /MCS_GROUP_RATES ]; - tx_time_data = group->duration[index %MCS_GROUP_RATES ] * ampdu_len /1000 ; + tx_time_data =minstrel_get_duration (index) * ampdu_len /1000 ;/* Contention time for first 2 tries */ ctime = (t_slot * cw) >>1 ;
@@ -874,20 +884,24 @@ minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi)int group = mi->max_prob_rate /MCS_GROUP_RATES ;const struct mcs_group *g = &minstrel_mcs_groups[group];int rate = mi->max_prob_rate %MCS_GROUP_RATES ; +unsigned int duration;/* Disable A-MSDU if max_prob_rate is bad */ if (mi->groups[group].rates[rate].prob_ewma <MINSTREL_FRAC (50 ,100 ))return 1 ; + duration = g->duration[rate]; + duration <<= g->shift; +/* If the rate is slower than single-stream MCS1, make A-MSDU limit small */ -if (g->duration[rate] >MCS_DURATION (1 ,0 ,52 )) +if (duration >MCS_DURATION (1 ,0 ,52 ))return 500 ;/* * If the rate is slower than single-stream MCS4, limit A-MSDU to usual * data packet size */ -if (g->duration[rate] >MCS_DURATION (1 ,0 ,104 )) +if (duration >MCS_DURATION (1 ,0 ,104 ))return 1600 ;/*
@@ -895,7 +909,7 @@ minstrel_ht_get_max_amsdu_len(struct minstrel_ht_sta *mi)* rate success probability is less than 75%, limit A-MSDU to twice the usual * data packet size */ -if (g->duration[rate] >MCS_DURATION (1 ,0 ,260 ) || +if (duration >MCS_DURATION (1 ,0 ,260 ) || (minstrel_ht_get_prob_ewma (mi, mi->max_tp_rate[0 ]) <MINSTREL_FRAC (75 ,100 )))return 3200 ;
@@ -942,13 +956,6 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)rate_control_set_rates (mp->hw, mi->sta, rates); } -static inline int -minstrel_get_duration (int index) -{ -const struct mcs_group *group = &minstrel_mcs_groups[index /MCS_GROUP_RATES ]; -return group->duration[index %MCS_GROUP_RATES ]; -} -static int minstrel_get_sample_rate (struct minstrel_priv *mp,struct minstrel_ht_sta *mi) {
net/mac80211/rc80211_minstrel_ht.h +4 -3
@@ -33,9 +33,10 @@#define MCS_GROUP_RATES 10struct mcs_group { -u32 flags; -unsigned int streams; -unsigned int duration[MCS_GROUP_RATES ]; +u16 flags; +u8 streams; +u8 shift; +u16 duration[MCS_GROUP_RATES ]; };extern const struct mcs_group minstrel_mcs_groups[];
net/mac80211/rc80211_minstrel_ht_debugfs.c +9 -2
@@ -58,6 +58,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)static const int bitrates[4 ] = {10 ,20 ,55 ,110 };int idx = i *MCS_GROUP_RATES + j;unsigned int prob_ewmsd; +unsigned int duration;if (!(mi->supported[i] &BIT (j)))continue ;
@@ -95,7 +96,9 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) p +=sprintf (p," %3u " , idx);/* tx_time[rate(i)] in usec */ - tx_time =DIV_ROUND_CLOSEST (mg->duration[j],1000 ); + duration = mg->duration[j]; + duration <<= mg->shift; + tx_time =DIV_ROUND_CLOSEST (duration,1000 ); p +=sprintf (p,"%6u " , tx_time); tp_max =minstrel_ht_get_tp_avg (mi, i, j,MINSTREL_FRAC (100 ,100 ));
@@ -204,6 +207,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)static const int bitrates[4 ] = {10 ,20 ,55 ,110 };int idx = i *MCS_GROUP_RATES + j;unsigned int prob_ewmsd; +unsigned int duration;if (!(mi->supported[i] &BIT (j)))continue ;
@@ -238,7 +242,10 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) } p +=sprintf (p,"%u," , idx); - tx_time =DIV_ROUND_CLOSEST (mg->duration[j],1000 ); + + duration = mg->duration[j]; + duration <<= mg->shift; + tx_time =DIV_ROUND_CLOSEST (duration,1000 ); p +=sprintf (p,"%u," , tx_time); tp_max =minstrel_ht_get_tp_avg (mi, i, j,MINSTREL_FRAC (100 ,100 ));
Signature · 1 line
2.17.0
PATCH 5/9 mac80211: minstrel: fix using short preamble CCK rates on HT clients
In reply to Felix Fietkaumi->supported[MINSTREL_CCK_GROUP] needs to be updated
short preamble rates need to be marked as supported regardless of whether it's currently enabled. Its state can change at any time without a rate_update call.
--- net/mac80211/rc80211_minstrel_ht.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +1 -3
@@ -1135,7 +1135,6 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;u16 ht_cap = sta->ht_cap.cap;struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap; - struct sta_info *sinfo = container_of(sta, struct sta_info, sta);int use_vht;int n_supported =0 ;int ack_dur;
@@ -1265,8 +1264,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,if (!n_supported) goto use_legacy; -if (test_sta_flag (sinfo,WLAN_STA_SHORT_PREAMBLE )) - mi->cck_supported_short |= mi->cck_supported_short <<4 ; + mi->supported[MINSTREL_CCK_GROUP ] |= mi->cck_supported_short <<4 ;/* create an initial rate table with the lowest supported rates */ minstrel_ht_update_stats (mp, mi);
Signature · 1 line
2.17.0
PATCH 6/9 mac80211: minstrel: fix CCK rate group streams value
In reply to Felix FietkauFixes a harmless underflow issue when CCK rates are actively being used
--- net/mac80211/rc80211_minstrel_ht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rc80211_minstrel_ht.c +1 -1
@@ -131,7 +131,7 @@#define CCK_GROUP (_s) \ [MINSTREL_CCK_GROUP] = { \ - .streams = 0, \ + .streams = 1, \ .flags = 0, \ .shift = _s, \ .duration = { \
Signature · 1 line
2.17.0
PATCH 7/9 mac80211: minstrel: fix sampling/reporting of CCK rates in HT mode
In reply to Felix FietkauLong/short preamble selection cannot be sampled separately, since it depends on the BSS state. Because of that, sampling attempts to currently not used preamble modes are not counted in the statistics, which leads to CCK rates being sampled too often.
Fix statistics accounting for long/short preamble by increasing the index where necessary.
Fix excessive CCK rate sampling by dropping unsupported sample attempts.
This improves throughput on 2.4 GHz channels
--- net/mac80211/rc80211_minstrel_ht.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +10 -4
@@ -281,7 +281,8 @@ minstrel_ht_get_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,break ;/* short preamble */ -if (!(mi->supported[group] &BIT (idx))) +if ((mi->supported[group] &BIT (idx +4 )) && + (rate->flags &IEEE80211_TX_RC_USE_SHORT_PREAMBLE )) idx +=4 ; }return &mi->groups[group].rates[idx];
@@ -1080,18 +1081,23 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,return ; sample_group = &minstrel_mcs_groups[sample_idx /MCS_GROUP_RATES ]; + sample_idx %=MCS_GROUP_RATES ; + +if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP ] && + (sample_idx >=4 ) != txrc->short_preamble) +return ; + info->flags |=IEEE80211_TX_CTL_RATE_CTRL_PROBE ; rate->count =1 ; -if (sample_idx /MCS_GROUP_RATES ==MINSTREL_CCK_GROUP ) { +if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP ]) {int idx = sample_idx %ARRAY_SIZE (mp->cck_rates); rate->idx = mp->cck_rates[idx]; }else if (sample_group->flags &IEEE80211_TX_RC_VHT_MCS ) {ieee80211_rate_set_vht (rate, sample_idx %MCS_GROUP_RATES , sample_group->streams); }else { - rate->idx = sample_idx %MCS_GROUP_RATES + - (sample_group->streams -1 ) *8 ; + rate->idx = sample_idx + (sample_group->streams -1 ) *8 ; } rate->flags = sample_group->flags;
Signature · 1 line
2.17.0
PATCH 8/9 mac80211: minstrel: do not sample rates 3 times slower than max_prob_rate
In reply to Felix FietkauThese rates are highly unlikely to be used quickly, even if the link deteriorates rapidly. This improves throughput in cases where CCK rates are not reliable enough to be skipped entirely during sampling. Sampling these rates regularly can cost a lot of airtime.
--- net/mac80211/rc80211_minstrel_ht.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +6 -4
@@ -1004,10 +1004,13 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)return -1 ;/* -* Do not sample if the probability is already higher than 95% -* to avoid wasting airtime. +* Do not sample if the probability is already higher than 95%, +* or if the rate is 3 times slower than the current max probability +* rate, to avoid wasting airtime. */ -if (mrs->prob_ewma >MINSTREL_FRAC (95 ,100 )) + sample_dur =minstrel_get_duration (sample_idx); +if (mrs->prob_ewma >MINSTREL_FRAC (95 ,100 ) || +minstrel_get_duration (mi->max_prob_rate) *3 < sample_dur)return -1 ;/*
@@ -1017,7 +1020,6 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) cur_max_tp_streams = minstrel_mcs_groups[tp_rate1 /MCS_GROUP_RATES ].streams; - sample_dur =minstrel_get_duration (sample_idx); if (sample_dur >= minstrel_get_duration(tp_rate2) && (cur_max_tp_streams - 1 < minstrel_mcs_groups[sample_group].streams ||
Signature · 1 line
2.17.0
PATCH 9/9 mac80211: rc80211_minstrel: remove variance / stddev calculation
In reply to Felix FietkauWhen there are few packets (e.g. for sampling attempts), the exponentially weighted variance is usually vastly overestimated, making the resulting data essentially useless. As far as I know, there has not been any practical use for this, so let's not waste any cycles on it.
--- net/mac80211/rc80211_minstrel.c | 6 ----- net/mac80211/rc80211_minstrel.h | 26 +--------------------- net/mac80211/rc80211_minstrel_debugfs.c | 14 ++++-------- net/mac80211/rc80211_minstrel_ht_debugfs.c | 14 ++++-------- 4 files changed, 9 insertions(+), 51 deletions(-)
net/mac80211/rc80211_minstrel.c +0 -6
@@ -167,12 +167,6 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)if (unlikely (!mrs->att_hist)) { mrs->prob_ewma = cur_prob; }else { -/* update exponential weighted moving variance */ - mrs->prob_ewmv =minstrel_ewmv (mrs->prob_ewmv, - cur_prob, - mrs->prob_ewma, -EWMA_LEVEL ); -/*update exponential weighted moving avarage */ mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma, cur_prob,
net/mac80211/rc80211_minstrel.h +1 -25
@@ -35,19 +35,6 @@ minstrel_ewma(int old, int new, int weight)return old + incr; } -/* -* Perform EWMV (Exponentially Weighted Moving Variance) calculation -*/ -static inline int -minstrel_ewmv (int old_ewmv,int cur_prob,int prob_ewma,int weight) -{ -int diff, incr; - - diff = cur_prob - prob_ewma; - incr = (EWMA_DIV - weight) * diff /EWMA_DIV ; -return weight * (old_ewmv +MINSTREL_TRUNC (diff * incr)) /EWMA_DIV ; -} -struct minstrel_rate_stats {/* current / last sampling period attempts/success counters */ u16 attempts, last_attempts;
@@ -56,11 +43,8 @@ struct minstrel_rate_stats {/* total attempts/success counters */ u32 att_hist, succ_hist; -/* statistis of packet delivery probability -* prob_ewma - exponential weighted moving average of prob -* prob_ewmsd - exp. weighted moving standard deviation of prob */ +/* prob_ewma - exponential weighted moving average of prob */ u16 prob_ewma; -u16 prob_ewmv;/* maximum retry counts */ u8 retry_count;
@@ -140,14 +124,6 @@ struct minstrel_debugfs_info {char buf[]; }; -/* Get EWMSD (Exponentially Weighted Moving Standard Deviation) * 10 */ -static inline int -minstrel_get_ewmsd10 (struct minstrel_rate_stats *mrs) -{ -unsigned int ewmv = mrs->prob_ewmv; -return int_sqrt (MINSTREL_TRUNC (ewmv *1000 *1000 )); -} -extern const struct rate_control_ops mac80211_minstrel;void minstrel_add_sta_debugfs (void *priv,void *priv_sta,struct dentry *dir);
net/mac80211/rc80211_minstrel_debugfs.c +4 -10
@@ -70,14 +70,13 @@ minstrel_stats_open(struct inode *inode, struct file *file) p = ms->buf; p +=sprintf (p,"\n" ); p +=sprintf (p, -"best __________rate_________ ________statistics________ ____last_____ ______sum-of________\n" ); +"best __________rate_________ ____statistics___ ____last_____ ______sum-of________\n" ); p +=sprintf (p, -"rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n" ); +"rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n" );for (i =0 ; i < mi->n_rates; i++) {struct minstrel_rate *mr = &mi->r[i];struct minstrel_rate_stats *mrs = &mi->r[i].stats; -unsigned int prob_ewmsd; *(p++) = (i == mi->max_tp_rate[0 ]) ?'A' :' ' ; *(p++) = (i == mi->max_tp_rate[1 ]) ?'B' :' ' ;
@@ -93,15 +92,13 @@ minstrel_stats_open(struct inode *inode, struct file *file) tp_max =minstrel_get_tp_avg (mr,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_get_tp_avg (mr, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u" + p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u" " %3u %3u %-3u " "%9llu %-9llu\n", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,
@@ -137,7 +134,6 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)for (i =0 ; i < mi->n_rates; i++) {struct minstrel_rate *mr = &mi->r[i];struct minstrel_rate_stats *mrs = &mi->r[i].stats; -unsigned int prob_ewmsd; p +=sprintf (p,"%s" ,((i == mi->max_tp_rate[0 ]) ?"A" :"" )); p +=sprintf (p,"%s" ,((i == mi->max_tp_rate[1 ]) ?"B" :"" ));
@@ -153,14 +149,12 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file) tp_max =minstrel_get_tp_avg (mr,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_get_tp_avg (mr, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u," + p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u," "%llu,%llu,%d,%d\n", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,
net/mac80211/rc80211_minstrel_ht_debugfs.c +4 -10
@@ -57,7 +57,6 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];static const int bitrates[4 ] = {10 ,20 ,55 ,110 };int idx = i *MCS_GROUP_RATES + j; -unsigned int prob_ewmsd;unsigned int duration;if (!(mi->supported[i] &BIT (j)))
@@ -104,15 +103,13 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) tp_max =minstrel_ht_get_tp_avg (mi, i, j,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_ht_get_tp_avg (mi, i, j, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u" + p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u" " %3u %3u %-3u " "%9llu %-9llu\n", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,
@@ -149,9 +146,9 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file) p +=sprintf (p,"\n" ); p +=sprintf (p, -" best ____________rate__________ ________statistics________ _____last____ ______sum-of________\n" ); +" best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n" ); p +=sprintf (p, -"mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n" ); +"mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n" ); p =minstrel_ht_stats_dump (mi,MINSTREL_CCK_GROUP , p);for (i =0 ; i <MINSTREL_CCK_GROUP ; i++)
@@ -206,7 +203,6 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];static const int bitrates[4 ] = {10 ,20 ,55 ,110 };int idx = i *MCS_GROUP_RATES + j; -unsigned int prob_ewmsd;unsigned int duration;if (!(mi->supported[i] &BIT (j)))
@@ -251,14 +247,12 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) tp_max =minstrel_ht_get_tp_avg (mi, i, j,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_ht_get_tp_avg (mi, i, j, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u," + p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u," "%u,%llu,%llu,", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,
Signature · 1 line
2.17.0
Re: [PATCH 9/9] mac80211: rc80211_minstrel: remove variance / stddev calculation
Quoted 36 lines · Felix Fietkau
When there are few packets (e.g. for sampling attempts), the exponentially weighted variance is usually vastly overestimated, making the resulting data essentially useless. As far as I know, there has not been any practical use for this, so let's not waste any cycles on it.
Signed-off-by Felix Fietkau <[email protected]>--- net/mac80211/rc80211_minstrel.c | 6 ----- net/mac80211/rc80211_minstrel.h | 26 +--------------------- net/mac80211/rc80211_minstrel_debugfs.c | 14 ++++-------- net/mac80211/rc80211_minstrel_ht_debugfs.c | 14 ++++-------- 4 files changed, 9 insertions(+), 51 deletions(-)net/mac80211/rc80211_minstrel.c +0
-6@@ -167,12 +167,6 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)if (unlikely (!mrs->att_hist)) { mrs->prob_ewma = cur_prob; }else { -/* update exponential weighted moving variance */ - mrs->prob_ewmv =minstrel_ewmv (mrs->prob_ewmv, - cur_prob, - mrs->prob_ewma, -EWMA_LEVEL ); -/*update exponential weighted moving avarage */ mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma, cur_prob,net/mac80211/rc80211_minstrel.h +0
-0
net/mac80211/rc80211_minstrel.h minstrel_ewma(int old, int new, int weight) · line 40
Quoted 6 lines
net/mac80211/rc80211_minstrel.h +0
-3@@ -35,19 +35,6 @@ minstrel_ewma(int old, int new, int weight)return old + incr; } -/* -* Perform EWMV (Exponentially Weighted Moving Variance) calculation -*/
I worry about this one. where are you getting your proof from?
Quoted 171 lines
net/mac80211/rc80211_minstrel.h +1
-22-static inline int -minstrel_ewmv (int old_ewmv,int cur_prob,int prob_ewma,int weight) -{ -int diff, incr; - - diff = cur_prob - prob_ewma; - incr = (EWMA_DIV - weight) * diff /EWMA_DIV ; -return weight * (old_ewmv +MINSTREL_TRUNC (diff * incr)) /EWMA_DIV ; -} -struct minstrel_rate_stats {/* current / last sampling period attempts/success counters */ u16 attempts, last_attempts;@@ -56,11 +43,8 @@ struct minstrel_rate_stats {/* total attempts/success counters */ u32 att_hist, succ_hist; -/* statistis of packet delivery probability -* prob_ewma - exponential weighted moving average of prob -* prob_ewmsd - exp. weighted moving standard deviation of prob */ +/* prob_ewma - exponential weighted moving average of prob */ u16 prob_ewma; -u16 prob_ewmv;/* maximum retry counts */ u8 retry_count;@@ -140,14 +124,6 @@ struct minstrel_debugfs_info {char buf[]; }; -/* Get EWMSD (Exponentially Weighted Moving Standard Deviation) * 10 */ -static inline int -minstrel_get_ewmsd10 (struct minstrel_rate_stats *mrs) -{ -unsigned int ewmv = mrs->prob_ewmv; -return int_sqrt (MINSTREL_TRUNC (ewmv *1000 *1000 )); -} -extern const struct rate_control_ops mac80211_minstrel;void minstrel_add_sta_debugfs (void *priv,void *priv_sta,struct dentry *dir);net/mac80211/rc80211_minstrel_debugfs.c +4
-10@@ -70,14 +70,13 @@ minstrel_stats_open(struct inode *inode, struct file *file) p = ms->buf; p +=sprintf (p,"\n" ); p +=sprintf (p, -"best __________rate_________ ________statistics________ ____last_____ ______sum-of________\n" ); +"best __________rate_________ ____statistics___ ____last_____ ______sum-of________\n" ); p +=sprintf (p, -"rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n" ); +"rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n" );for (i =0 ; i < mi->n_rates; i++) {struct minstrel_rate *mr = &mi->r[i];struct minstrel_rate_stats *mrs = &mi->r[i].stats; -unsigned int prob_ewmsd; *(p++) = (i == mi->max_tp_rate[0 ]) ?'A' :' ' ; *(p++) = (i == mi->max_tp_rate[1 ]) ?'B' :' ' ;@@ -93,15 +92,13 @@ minstrel_stats_open(struct inode *inode, struct file *file) tp_max =minstrel_get_tp_avg (mr,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_get_tp_avg (mr, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u" + p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u" " %3u %3u %-3u " "%9llu %-9llu\n", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,@@ -137,7 +134,6 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)for (i =0 ; i < mi->n_rates; i++) {struct minstrel_rate *mr = &mi->r[i];struct minstrel_rate_stats *mrs = &mi->r[i].stats; -unsigned int prob_ewmsd; p +=sprintf (p,"%s" ,((i == mi->max_tp_rate[0 ]) ?"A" :"" )); p +=sprintf (p,"%s" ,((i == mi->max_tp_rate[1 ]) ?"B" :"" ));@@ -153,14 +149,12 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file) tp_max =minstrel_get_tp_avg (mr,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_get_tp_avg (mr, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u," + p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u," "%llu,%llu,%d,%d\n", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,net/mac80211/rc80211_minstrel_ht_debugfs.c +4
-11@@ -57,7 +57,6 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];static const int bitrates[4 ] = {10 ,20 ,55 ,110 };int idx = i *MCS_GROUP_RATES + j; -unsigned int prob_ewmsd;unsigned int duration;if (!(mi->supported[i] &BIT (j)))@@ -104,15 +103,13 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) tp_max =minstrel_ht_get_tp_avg (mi, i, j,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_ht_get_tp_avg (mi, i, j, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u" + p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u" " %3u %3u %-3u " "%9llu %-9llu\n", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts,@@ -149,9 +146,9 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file) p +=sprintf (p,"\n" ); p +=sprintf (p, -" best ____________rate__________ ________statistics________ _____last____ ______sum-of________\n" ); +" best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n" ); p +=sprintf (p, -"mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n" ); +"mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n" ); p =minstrel_ht_stats_dump (mi,MINSTREL_CCK_GROUP , p);for (i =0 ; i <MINSTREL_CCK_GROUP ; i++)@@ -206,7 +203,6 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];static const int bitrates[4 ] = {10 ,20 ,55 ,110 };int idx = i *MCS_GROUP_RATES + j; -unsigned int prob_ewmsd;unsigned int duration;if (!(mi->supported[i] &BIT (j)))@@ -251,14 +247,12 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) tp_max =minstrel_ht_get_tp_avg (mi, i, j,MINSTREL_FRAC (100 ,100 )); tp_avg =minstrel_ht_get_tp_avg (mi, i, j, mrs->prob_ewma); eprob =MINSTREL_TRUNC (mrs->prob_ewma *1000 ); - prob_ewmsd =minstrel_get_ewmsd10 (mrs); - p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u," + p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u," "%u,%llu,%llu,", tp_max / 10, tp_max % 10, tp_avg / 10, tp_avg % 10, eprob / 10, eprob % 10, - prob_ewmsd / 10, prob_ewmsd % 10, mrs->retry_count, mrs->last_success, mrs->last_attempts, --2.17.0
Signature · 4 lines
Dave Täht CTO, TekLibre, LLC http://www.teklibre.com Tel: 1-831-205-9740
Re: [PATCH 9/9] mac80211: rc80211_minstrel: remove variance / stddev calculation
Quoted 40 lines · Dave Taht
Quoted 39 lines · Felix Fietkau
When there are few packets (e.g. for sampling attempts), the exponentially weighted variance is usually vastly overestimated, making the resulting data essentially useless. As far as I know, there has not been any practical use for this, so let's not waste any cycles on it.
Signed-off-by Felix Fietkau <[email protected]>--- net/mac80211/rc80211_minstrel.c | 6 ----- net/mac80211/rc80211_minstrel.h | 26 +--------------------- net/mac80211/rc80211_minstrel_debugfs.c | 14 ++++-------- net/mac80211/rc80211_minstrel_ht_debugfs.c | 14 ++++-------- 4 files changed, 9 insertions(+), 51 deletions(-)net/mac80211/rc80211_minstrel.c +0
-6@@ -167,12 +167,6 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)if (unlikely (!mrs->att_hist)) { mrs->prob_ewma = cur_prob; }else { -/* update exponential weighted moving variance */ - mrs->prob_ewmv =minstrel_ewmv (mrs->prob_ewmv, - cur_prob, - mrs->prob_ewma, -EWMA_LEVEL ); -/*update exponential weighted moving avarage */ mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma, cur_prob,net/mac80211/rc80211_minstrel.h +0
-0@@ -35,19 +35,6 @@ minstrel_ewma(int old, int new, int weight)return old + incr; }
Quoted 5 lines
net/mac80211/rc80211_minstrel.h minstrel_ewma(int old, int new, int weight) · line 40
Quoted 3 lines
net/mac80211/rc80211_minstrel.h +0
-3-/* -* Perform EWMV (Exponentially Weighted Moving Variance) calculation -*/ I worry about this one. where are you getting your proof from?
I've done quite a few measurements myself to see if this can be usable for further rate control improvements or for the upcoming TPC work. The data this generates simply fluctuates wildly and incoherently based on the sampling behavior, making it completely useless. Together with Thomas (who introduced this code), I tried a few times to fix this, but couldn't find any way to make it coherent and usable.
Thomas and I both agreed that it's better to just remove it until somebody has a better idea what to do.
Also, this was only used for debugfs statistics, not for any actual rate control behavior.
- Felix
Re: [PATCH 9/9] mac80211: rc80211_minstrel: remove variance / stddev calculation
Quoted 54 lines · Felix Fietkau
Quoted 40 lines · Dave Taht
Quoted 39 lines · Felix Fietkau
When there are few packets (e.g. for sampling attempts), the exponentially weighted variance is usually vastly overestimated, making the resulting data essentially useless. As far as I know, there has not been any practical use for this, so let's not waste any cycles on it.
Signed-off-by Felix Fietkau <[email protected]>--- net/mac80211/rc80211_minstrel.c | 6 ----- net/mac80211/rc80211_minstrel.h | 26 +--------------------- net/mac80211/rc80211_minstrel_debugfs.c | 14 ++++-------- net/mac80211/rc80211_minstrel_ht_debugfs.c | 14 ++++-------- 4 files changed, 9 insertions(+), 51 deletions(-)net/mac80211/rc80211_minstrel.c +0
-6@@ -167,12 +167,6 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)if (unlikely (!mrs->att_hist)) { mrs->prob_ewma = cur_prob; }else { -/* update exponential weighted moving variance */ - mrs->prob_ewmv =minstrel_ewmv (mrs->prob_ewmv, - cur_prob, - mrs->prob_ewma, -EWMA_LEVEL ); -/*update exponential weighted moving avarage */ mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma, cur_prob,net/mac80211/rc80211_minstrel.h +0
-0@@ -35,19 +35,6 @@ minstrel_ewma(int old, int new, int weight)return old + incr; }Quoted 5 lines
net/mac80211/rc80211_minstrel.h minstrel_ewma(int old, int new, int weight) · line 40
Quoted 3 lines
net/mac80211/rc80211_minstrel.h +0
-3-/* -* Perform EWMV (Exponentially Weighted Moving Variance) calculation -*/ I worry about this one. where are you getting your proof from?
I've done quite a few measurements myself to see if this can be usable for further rate control improvements or for the upcoming TPC work. The data this generates simply fluctuates wildly and incoherently based on the sampling behavior, making it completely useless. Together with Thomas (who introduced this code), I tried a few times to fix this, but couldn't find any way to make it coherent and usable.
Quoted 5 lines
Thomas and I both agreed that it's better to just remove it until somebody has a better idea what to do.
Also, this was only used for debugfs statistics, not for any actual rate control behavior.
OK, thanks. I'm totally delighted to see this patchset otherwise.
Quoted 1 line
- Felix
Signature · 4 lines
Dave Täht CTO, TekLibre, LLC http://www.teklibre.com Tel: 1-831-205-9740