]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mac80211: unify Minstrel & Minstrel-HTs calculation of rate statistics
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>
Tue, 24 Mar 2015 20:09:38 +0000 (21:09 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 1 Apr 2015 18:44:31 +0000 (20:44 +0200)
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>
net/mac80211/rc80211_minstrel.c
net/mac80211/rc80211_minstrel.h
net/mac80211/rc80211_minstrel_ht.c

index ef6e8a6c4253c72f6f2398b733e8c427f5b59953..5528037021ad336edbfe527cea89736c38e2ea32 100644 (file)
@@ -127,6 +127,32 @@ minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
        rate_control_set_rates(mp->hw, mi->sta, ratetbl);
 }
 
+/*
+* Recalculate success probabilities and counters for a given rate using EWMA
+*/
+void
+minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
+{
+       if (unlikely(mrs->attempts > 0)) {
+               mrs->sample_skipped = 0;
+               mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
+               if (unlikely(!mrs->att_hist))
+                       mrs->probability = mrs->cur_prob;
+               else
+                       mrs->probability = minstrel_ewma(mrs->probability,
+                                                    mrs->cur_prob, EWMA_LEVEL);
+               mrs->att_hist += mrs->attempts;
+               mrs->succ_hist += mrs->success;
+       } else {
+               mrs->sample_skipped++;
+       }
+
+       mrs->last_success = mrs->success;
+       mrs->last_attempts = mrs->attempts;
+       mrs->success = 0;
+       mrs->attempts = 0;
+}
+
 static void
 minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
 {
@@ -146,22 +172,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
                if (!usecs)
                        usecs = 1000000;
 
-               if (unlikely(mrs->attempts > 0)) {
-                       mrs->sample_skipped = 0;
-                       mrs->cur_prob = MINSTREL_FRAC(mrs->success,
-                                                     mrs->attempts);
-                       mrs->succ_hist += mrs->success;
-                       mrs->att_hist += mrs->attempts;
-                       mrs->probability = minstrel_ewma(mrs->probability,
-                                                        mrs->cur_prob,
-                                                        EWMA_LEVEL);
-               } else
-                       mrs->sample_skipped++;
-
-               mrs->last_success = mrs->success;
-               mrs->last_attempts = mrs->attempts;
-               mrs->success = 0;
-               mrs->attempts = 0;
+               /* Update success probabilities per rate */
+               minstrel_calc_rate_stats(mrs);
 
                /* Update throughput per rate, reset thr. below 10% success */
                if (mrs->probability < MINSTREL_FRAC(10, 100))
index 9613e7392c7d6b88ffe4443da1317d7e0ea208fd..728144c8df3f3d3563a0f6b1f8e284301d9a1021 100644 (file)
@@ -132,6 +132,9 @@ 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 *mr);
+
 /* debugfs */
 int minstrel_stats_open(struct inode *inode, struct file *file);
 int minstrel_stats_csv_open(struct inode *inode, struct file *file);
index 60698fc7042e5d0568f4d65e8d5a10bb05de9e21..7afa5623a5eeb37b72ad50e5c42ddff00f1f2361 100644 (file)
@@ -313,32 +313,6 @@ minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
        return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
 }
 
-
-/*
- * Recalculate success probabilities and counters for a rate using EWMA
- */
-static void
-minstrel_calc_rate_ewma(struct minstrel_rate_stats *mr)
-{
-       if (unlikely(mr->attempts > 0)) {
-               mr->sample_skipped = 0;
-               mr->cur_prob = MINSTREL_FRAC(mr->success, mr->attempts);
-               if (!mr->att_hist)
-                       mr->probability = mr->cur_prob;
-               else
-                       mr->probability = minstrel_ewma(mr->probability,
-                               mr->cur_prob, EWMA_LEVEL);
-               mr->att_hist += mr->attempts;
-               mr->succ_hist += mr->success;
-       } else {
-               mr->sample_skipped++;
-       }
-       mr->last_success = mr->success;
-       mr->last_attempts = mr->attempts;
-       mr->success = 0;
-       mr->attempts = 0;
-}
-
 /*
  * Calculate throughput based on the average A-MPDU length, taking into account
  * 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)
 
                        mr = &mg->rates[i];
                        mr->retry_updated = false;
-                       minstrel_calc_rate_ewma(mr);
+                       minstrel_calc_rate_stats(mr);
                        minstrel_ht_calc_tp(mi, group, i);
 
                        if (!mr->cur_tp)