mac80211: extend minstrel's rate sampling to avoid unsampled rates
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>
Mon, 4 Mar 2013 22:30:04 +0000 (23:30 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 6 Mar 2013 15:36:08 +0000 (16:36 +0100)
Minstrel's decision which rate should be directly sampled within the
1st mrr stage is limited to such rates faster than the current max
throughput rate. All rates below the current max. throughput rate
are indirectly sampled via the 2nd mrr stage.
This approach leads to deprecated per rate statistics and therfore
a deprecated mrr chain setup.

This patch uses the sampling approach from minstrel_ht. A counter is
added to sum all indirect sample attempts per rate. After 20 indirect
sampling attempts the rate is directly sampled within the 1st mrr stage.
Therefore more up-to-date statistics for all rates are maintained and
used to setup the mrr chain.

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>
net/mac80211/rc80211_minstrel.c
net/mac80211/rc80211_minstrel.h

index 152bb0e3786576b99731e81b6f6a2d6e14750649..aa59f2962c3827bf3031f6fd395fda0f4fa8f142 100644 (file)
@@ -85,7 +85,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
                if (!usecs)
                        usecs = 1000000;
 
-               if (mr->attempts) {
+               if (unlikely(mr->attempts > 0)) {
+                       mr->sample_skipped = 0;
                        mr->cur_prob = MINSTREL_FRAC(mr->success, mr->attempts);
                        mr->succ_hist += mr->success;
                        mr->att_hist += mr->attempts;
@@ -93,7 +94,8 @@ minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
                                                        mr->cur_prob,
                                                        EWMA_LEVEL);
                        mr->cur_tp = mr->probability * (1000000 / usecs);
-               }
+               } else
+                       mr->sample_skipped++;
 
                mr->last_success = mr->success;
                mr->last_attempts = mr->attempts;
@@ -282,9 +284,12 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
                rate_sampling = true;
 
                /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
-                * rate sampling method should be used */
+                * rate sampling method should be used.
+                * Respect such rates that are not sampled for 20 interations.
+                */
                if (mrr_capable &&
-                   msr->perfect_tx_time > mi->r[ndx].perfect_tx_time)
+                   msr->perfect_tx_time > mi->r[ndx].perfect_tx_time &&
+                   msr->sample_skipped < 20)
                                indirect_rate_sampling = true;
 
                if (!indirect_rate_sampling) {
index 5fb5cb81d0dabc2bb7cfb7c4dcd247e70b9e80cc..200b7e3632da710c5e55c29864dabe530f3c15e6 100644 (file)
@@ -43,6 +43,7 @@ struct minstrel_rate {
        u32 attempts;
        u32 last_attempts;
        u32 last_success;
+       u8 sample_skipped;
 
        /* parts per thousand */
        u32 cur_prob;