aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>2013-03-04 17:30:02 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-03-06 10:36:07 -0500
commitc8ca8c2f933a516b5f4586d7dc6055b72107f246 (patch)
tree87a1285588a6dcec2926e804e52fdc4d9bf8fba6
parenta512d4b543ea20ec84f712f90a5229ab88a9709c (diff)
mac80211: merge value scaling macros of minstrel_ht and minstrel
Both minstrel versions use individual ways to scale up integer values to perform calculations. Merge minstrel_ht's scaling macros into minstrels header file and use them in both minstrel versions. 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>
-rw-r--r--net/mac80211/rc80211_minstrel.c9
-rw-r--r--net/mac80211/rc80211_minstrel.h5
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c6
-rw-r--r--net/mac80211/rc80211_minstrel_ht.h5
4 files changed, 12 insertions, 13 deletions
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index d78f629179c7..c9b990237991 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -86,10 +86,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
86 if (!usecs) 86 if (!usecs)
87 usecs = 1000000; 87 usecs = 1000000;
88 88
89 /* To avoid rounding issues, probabilities scale from 0 (0%)
90 * to 18000 (100%) */
91 if (mr->attempts) { 89 if (mr->attempts) {
92 mr->cur_prob = (mr->success * 18000) / mr->attempts; 90 mr->cur_prob = MINSTREL_FRAC(mr->success, mr->attempts);
93 mr->succ_hist += mr->success; 91 mr->succ_hist += mr->success;
94 mr->att_hist += mr->attempts; 92 mr->att_hist += mr->attempts;
95 mr->probability = minstrel_ewma(mr->probability, 93 mr->probability = minstrel_ewma(mr->probability,
@@ -105,7 +103,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
105 103
106 /* Sample less often below the 10% chance of success. 104 /* Sample less often below the 10% chance of success.
107 * Sample less often above the 95% chance of success. */ 105 * Sample less often above the 95% chance of success. */
108 if ((mr->probability > 17100) || (mr->probability < 1800)) { 106 if (mr->probability > MINSTREL_FRAC(95, 100) ||
107 mr->probability < MINSTREL_FRAC(10, 100)) {
109 mr->adjusted_retry_count = mr->retry_count >> 1; 108 mr->adjusted_retry_count = mr->retry_count >> 1;
110 if (mr->adjusted_retry_count > 2) 109 if (mr->adjusted_retry_count > 2)
111 mr->adjusted_retry_count = 2; 110 mr->adjusted_retry_count = 2;
@@ -300,7 +299,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
300 /* If we're not using MRR and the sampling rate already 299 /* If we're not using MRR and the sampling rate already
301 * has a probability of >95%, we shouldn't be attempting 300 * has a probability of >95%, we shouldn't be attempting
302 * to use it, as this only wastes precious airtime */ 301 * to use it, as this only wastes precious airtime */
303 if (!mrr && sample && (mi->r[ndx].probability > 17100)) 302 if (!mrr && sample && (mi->r[ndx].probability > MINSTREL_FRAC(95, 100)))
304 ndx = mi->max_tp_rate; 303 ndx = mi->max_tp_rate;
305 304
306 ar[0].idx = mi->r[ndx].rix; 305 ar[0].idx = mi->r[ndx].rix;
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 98db93f96add..fda4a6154c87 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -11,6 +11,11 @@
11 11
12#define EWMA_LEVEL 75 /* ewma weighting factor [%] */ 12#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
13 13
14/* scaled fraction values */
15#define MINSTREL_SCALE 16
16#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
17#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
18
14/* 19/*
15 * Perform EWMA (Exponentially Weighted Moving Average) calculation 20 * Perform EWMA (Exponentially Weighted Moving Average) calculation
16 */ 21 */
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index d5a56226e675..c0ebfaca6ba0 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -79,9 +79,9 @@ minstrel_stats_open(struct inode *inode, struct file *file)
79 p += sprintf(p, "%3u%s", mr->bitrate / 2, 79 p += sprintf(p, "%3u%s", mr->bitrate / 2,
80 (mr->bitrate & 1 ? ".5" : " ")); 80 (mr->bitrate & 1 ? ".5" : " "));
81 81
82 tp = mr->cur_tp / ((18000 << 10) / 96); 82 tp = MINSTREL_TRUNC(mr->cur_tp / 10);
83 prob = mr->cur_prob / 18; 83 prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
84 eprob = mr->probability / 18; 84 eprob = MINSTREL_TRUNC(mr->probability * 1000);
85 85
86 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " 86 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u "
87 "%3u(%3u) %8llu %8llu\n", 87 "%3u(%3u) %8llu %8llu\n",
diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h
index c6d6a0dc46fc..9b16e9de9923 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -16,11 +16,6 @@
16#define MINSTREL_MAX_STREAMS 3 16#define MINSTREL_MAX_STREAMS 3
17#define MINSTREL_STREAM_GROUPS 4 17#define MINSTREL_STREAM_GROUPS 4
18 18
19/* scaled fraction values */
20#define MINSTREL_SCALE 16
21#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
22#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
23
24#define MCS_GROUP_RATES 8 19#define MCS_GROUP_RATES 8
25 20
26struct mcs_group { 21struct mcs_group {