aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>2015-03-24 16:09:38 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-04-01 14:44:31 -0400
commitf62838bcc5f58f580961aaf8c9fe59036b7be825 (patch)
tree59cef7078d28c0371f00c46afbd7fb027e15e90a /net/mac80211
parent2cae0b6a70d666f8905f0f4bf788e56df1273878 (diff)
mac80211: unify Minstrel & Minstrel-HTs calculation of rate statistics
This patch unifies the calculation of Minstrels and Minstrel-HTs per-rate statistic. The new common function minstrel_calc_rate_stats() is called when a statistic update is performed. Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de> Acked-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/rc80211_minstrel.c44
-rw-r--r--net/mac80211/rc80211_minstrel.h3
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c28
3 files changed, 32 insertions, 43 deletions
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index ef6e8a6c4253..5528037021ad 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -127,6 +127,32 @@ minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
127 rate_control_set_rates(mp->hw, mi->sta, ratetbl); 127 rate_control_set_rates(mp->hw, mi->sta, ratetbl);
128} 128}
129 129
130/*
131* Recalculate success probabilities and counters for a given rate using EWMA
132*/
133void
134minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
135{
136 if (unlikely(mrs->attempts > 0)) {
137 mrs->sample_skipped = 0;
138 mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
139 if (unlikely(!mrs->att_hist))
140 mrs->probability = mrs->cur_prob;
141 else
142 mrs->probability = minstrel_ewma(mrs->probability,
143 mrs->cur_prob, EWMA_LEVEL);
144 mrs->att_hist += mrs->attempts;
145 mrs->succ_hist += mrs->success;
146 } else {
147 mrs->sample_skipped++;
148 }
149
150 mrs->last_success = mrs->success;
151 mrs->last_attempts = mrs->attempts;
152 mrs->success = 0;
153 mrs->attempts = 0;
154}
155
130static void 156static void
131minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) 157minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
132{ 158{
@@ -146,22 +172,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
146 if (!usecs) 172 if (!usecs)
147 usecs = 1000000; 173 usecs = 1000000;
148 174
149 if (unlikely(mrs->attempts > 0)) { 175 /* Update success probabilities per rate */
150 mrs->sample_skipped = 0; 176 minstrel_calc_rate_stats(mrs);
151 mrs->cur_prob = MINSTREL_FRAC(mrs->success,
152 mrs->attempts);
153 mrs->succ_hist += mrs->success;
154 mrs->att_hist += mrs->attempts;
155 mrs->probability = minstrel_ewma(mrs->probability,
156 mrs->cur_prob,
157 EWMA_LEVEL);
158 } else
159 mrs->sample_skipped++;
160
161 mrs->last_success = mrs->success;
162 mrs->last_attempts = mrs->attempts;
163 mrs->success = 0;
164 mrs->attempts = 0;
165 177
166 /* Update throughput per rate, reset thr. below 10% success */ 178 /* Update throughput per rate, reset thr. below 10% success */
167 if (mrs->probability < MINSTREL_FRAC(10, 100)) 179 if (mrs->probability < MINSTREL_FRAC(10, 100))
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 9613e7392c7d..728144c8df3f 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -132,6 +132,9 @@ extern const struct rate_control_ops mac80211_minstrel;
132void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); 132void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
133void minstrel_remove_sta_debugfs(void *priv, void *priv_sta); 133void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
134 134
135/* Recalculate success probabilities and counters for a given rate using EWMA */
136void minstrel_calc_rate_stats(struct minstrel_rate_stats *mr);
137
135/* debugfs */ 138/* debugfs */
136int minstrel_stats_open(struct inode *inode, struct file *file); 139int minstrel_stats_open(struct inode *inode, struct file *file);
137int minstrel_stats_csv_open(struct inode *inode, struct file *file); 140int minstrel_stats_csv_open(struct inode *inode, struct file *file);
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 60698fc7042e..7afa5623a5ee 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -313,32 +313,6 @@ minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
313 return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES]; 313 return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
314} 314}
315 315
316
317/*
318 * Recalculate success probabilities and counters for a rate using EWMA
319 */
320static void
321minstrel_calc_rate_ewma(struct minstrel_rate_stats *mr)
322{
323 if (unlikely(mr->attempts > 0)) {
324 mr->sample_skipped = 0;
325 mr->cur_prob = MINSTREL_FRAC(mr->success, mr->attempts);
326 if (!mr->att_hist)
327 mr->probability = mr->cur_prob;
328 else
329 mr->probability = minstrel_ewma(mr->probability,
330 mr->cur_prob, EWMA_LEVEL);
331 mr->att_hist += mr->attempts;
332 mr->succ_hist += mr->success;
333 } else {
334 mr->sample_skipped++;
335 }
336 mr->last_success = mr->success;
337 mr->last_attempts = mr->attempts;
338 mr->success = 0;
339 mr->attempts = 0;
340}
341
342/* 316/*
343 * Calculate throughput based on the average A-MPDU length, taking into account 317 * Calculate throughput based on the average A-MPDU length, taking into account
344 * the expected number of retransmissions and their expected length 318 * the expected number of retransmissions and their expected length
@@ -567,7 +541,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
567 541
568 mr = &mg->rates[i]; 542 mr = &mg->rates[i];
569 mr->retry_updated = false; 543 mr->retry_updated = false;
570 minstrel_calc_rate_ewma(mr); 544 minstrel_calc_rate_stats(mr);
571 minstrel_ht_calc_tp(mi, group, i); 545 minstrel_ht_calc_tp(mi, group, i);
572 546
573 if (!mr->cur_tp) 547 if (!mr->cur_tp)