aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>2013-03-04 17:30:01 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-03-06 10:36:06 -0500
commita512d4b543ea20ec84f712f90a5229ab88a9709c (patch)
treed3c3f6354f371fff701a4b365964b155873ee544 /net/mac80211
parent52c00a37a323ded691b23538ef1181155f51aef3 (diff)
mac80211: merge EWMA calculation of minstrel_ht and minstrel
Both rate control algorithms (minstrel and minstrel_ht) calculate averages based on EWMA. Shift function minstrel_ewma() into rc80211_minstrel.h and make use of it in both minstrel version. Also shift the default EWMA level (75%) definition to the header file and clean up variable usage. Acked-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/rc80211_minstrel.c15
-rw-r--r--net/mac80211/rc80211_minstrel.h13
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c10
3 files changed, 17 insertions, 21 deletions
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index eea45a2c7c35..d78f629179c7 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -76,7 +76,6 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
76 u32 max_tp = 0, index_max_tp = 0, index_max_tp2 = 0; 76 u32 max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
77 u32 max_prob = 0, index_max_prob = 0; 77 u32 max_prob = 0, index_max_prob = 0;
78 u32 usecs; 78 u32 usecs;
79 u32 p;
80 int i; 79 int i;
81 80
82 mi->stats_update = jiffies; 81 mi->stats_update = jiffies;
@@ -90,14 +89,13 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
90 /* To avoid rounding issues, probabilities scale from 0 (0%) 89 /* To avoid rounding issues, probabilities scale from 0 (0%)
91 * to 18000 (100%) */ 90 * to 18000 (100%) */
92 if (mr->attempts) { 91 if (mr->attempts) {
93 p = (mr->success * 18000) / mr->attempts; 92 mr->cur_prob = (mr->success * 18000) / mr->attempts;
94 mr->succ_hist += mr->success; 93 mr->succ_hist += mr->success;
95 mr->att_hist += mr->attempts; 94 mr->att_hist += mr->attempts;
96 mr->cur_prob = p; 95 mr->probability = minstrel_ewma(mr->probability,
97 p = ((p * (100 - mp->ewma_level)) + (mr->probability * 96 mr->cur_prob,
98 mp->ewma_level)) / 100; 97 EWMA_LEVEL);
99 mr->probability = p; 98 mr->cur_tp = mr->probability * (1000000 / usecs);
100 mr->cur_tp = p * (1000000 / usecs);
101 } 99 }
102 100
103 mr->last_success = mr->success; 101 mr->last_success = mr->success;
@@ -542,9 +540,6 @@ minstrel_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
542 mp->lookaround_rate = 5; 540 mp->lookaround_rate = 5;
543 mp->lookaround_rate_mrr = 10; 541 mp->lookaround_rate_mrr = 10;
544 542
545 /* moving average weight for EWMA */
546 mp->ewma_level = 75;
547
548 /* maximum time that the hw is allowed to stay in one MRR segment */ 543 /* maximum time that the hw is allowed to stay in one MRR segment */
549 mp->segment_size = 6000; 544 mp->segment_size = 6000;
550 545
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 5ecf757817f2..98db93f96add 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -9,6 +9,18 @@
9#ifndef __RC_MINSTREL_H 9#ifndef __RC_MINSTREL_H
10#define __RC_MINSTREL_H 10#define __RC_MINSTREL_H
11 11
12#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
13
14/*
15 * Perform EWMA (Exponentially Weighted Moving Average) calculation
16 */
17static inline int
18minstrel_ewma(int old, int new, int weight)
19{
20 return (new * (100 - weight) + old * weight) / 100;
21}
22
23
12struct minstrel_rate { 24struct minstrel_rate {
13 int bitrate; 25 int bitrate;
14 int rix; 26 int rix;
@@ -73,7 +85,6 @@ struct minstrel_priv {
73 unsigned int cw_min; 85 unsigned int cw_min;
74 unsigned int cw_max; 86 unsigned int cw_max;
75 unsigned int max_retry; 87 unsigned int max_retry;
76 unsigned int ewma_level;
77 unsigned int segment_size; 88 unsigned int segment_size;
78 unsigned int update_interval; 89 unsigned int update_interval;
79 unsigned int lookaround_rate; 90 unsigned int lookaround_rate;
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index aa59539e5b27..3009e457e758 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -18,7 +18,6 @@
18 18
19#define AVG_PKT_SIZE 1200 19#define AVG_PKT_SIZE 1200
20#define SAMPLE_COLUMNS 10 20#define SAMPLE_COLUMNS 10
21#define EWMA_LEVEL 75
22 21
23/* Number of bits for an average sized packet */ 22/* Number of bits for an average sized packet */
24#define MCS_NBITS (AVG_PKT_SIZE << 3) 23#define MCS_NBITS (AVG_PKT_SIZE << 3)
@@ -129,15 +128,6 @@ const struct mcs_group minstrel_mcs_groups[] = {
129static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES]; 128static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
130 129
131/* 130/*
132 * Perform EWMA (Exponentially Weighted Moving Average) calculation
133 */
134static int
135minstrel_ewma(int old, int new, int weight)
136{
137 return (new * (100 - weight) + old * weight) / 100;
138}
139
140/*
141 * Look up an MCS group index based on mac80211 rate information 131 * Look up an MCS group index based on mac80211 rate information
142 */ 132 */
143static int 133static int