aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>2013-03-04 17:30:05 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-03-06 10:36:09 -0500
commitf744bf81f7501d03f45ba23f9cf947abc3b422c9 (patch)
tree365aa54da77095cc1e31fdf63a6d51669633f0c0 /net
parent1e9c27df7b4a59f2269b9c88a5cef1e9018e77f6 (diff)
mac80211: add lowest rate into minstrel's random rate sampling table
While minstrel bootstraps and fills the success probabilities of each rate the lowest rate has typically a very high success probability (often 100% in our tests). Its statistics are never updated but considered to setup the mrr chain. In our tests we see that especially the 3rd mrr stage (which is that rate providing highest success probability) is filled with the lowest rate because its initial high sucess probability is never updated. By design the 4th mrr stage is filled with the lowest rate so often 3rd and 4th mrr stage are equal. This patch follows minstrels general approach of assuming as little as possible about rate dependencies. Consequently we include the lowest rate into the random sampling table to get balanced up-to-date statistics of all rates and therefore balanced decisions. 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')
-rw-r--r--net/mac80211/rc80211_minstrel.c20
-rw-r--r--net/mac80211/rc80211_minstrel.h4
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c1
3 files changed, 10 insertions, 15 deletions
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index aa59f2962c38..5c0f5327c77f 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -55,7 +55,6 @@
55#include "rate.h" 55#include "rate.h"
56#include "rc80211_minstrel.h" 56#include "rc80211_minstrel.h"
57 57
58#define SAMPLE_COLUMNS 10
59#define SAMPLE_TBL(_mi, _idx, _col) \ 58#define SAMPLE_TBL(_mi, _idx, _col) \
60 _mi->sample_table[(_idx * SAMPLE_COLUMNS) + _col] 59 _mi->sample_table[(_idx * SAMPLE_COLUMNS) + _col]
61 60
@@ -210,7 +209,7 @@ minstrel_get_next_sample(struct minstrel_sta_info *mi)
210 unsigned int sample_ndx; 209 unsigned int sample_ndx;
211 sample_ndx = SAMPLE_TBL(mi, mi->sample_row, mi->sample_column); 210 sample_ndx = SAMPLE_TBL(mi, mi->sample_row, mi->sample_column);
212 mi->sample_row++; 211 mi->sample_row++;
213 if ((int) mi->sample_row > (mi->n_rates - 2)) { 212 if ((int) mi->sample_row >= mi->n_rates) {
214 mi->sample_row = 0; 213 mi->sample_row = 0;
215 mi->sample_column++; 214 mi->sample_column++;
216 if (mi->sample_column >= SAMPLE_COLUMNS) 215 if (mi->sample_column >= SAMPLE_COLUMNS)
@@ -370,26 +369,21 @@ static void
370init_sample_table(struct minstrel_sta_info *mi) 369init_sample_table(struct minstrel_sta_info *mi)
371{ 370{
372 unsigned int i, col, new_idx; 371 unsigned int i, col, new_idx;
373 unsigned int n_srates = mi->n_rates - 1;
374 u8 rnd[8]; 372 u8 rnd[8];
375 373
376 mi->sample_column = 0; 374 mi->sample_column = 0;
377 mi->sample_row = 0; 375 mi->sample_row = 0;
378 memset(mi->sample_table, 0, SAMPLE_COLUMNS * mi->n_rates); 376 memset(mi->sample_table, 0xff, SAMPLE_COLUMNS * mi->n_rates);
379 377
380 for (col = 0; col < SAMPLE_COLUMNS; col++) { 378 for (col = 0; col < SAMPLE_COLUMNS; col++) {
381 for (i = 0; i < n_srates; i++) { 379 for (i = 0; i < mi->n_rates; i++) {
382 get_random_bytes(rnd, sizeof(rnd)); 380 get_random_bytes(rnd, sizeof(rnd));
383 new_idx = (i + rnd[i & 7]) % n_srates; 381 new_idx = (i + rnd[i & 7]) % mi->n_rates;
384 382
385 while (SAMPLE_TBL(mi, new_idx, col) != 0) 383 while (SAMPLE_TBL(mi, new_idx, col) != 0xff)
386 new_idx = (new_idx + 1) % n_srates; 384 new_idx = (new_idx + 1) % mi->n_rates;
387 385
388 /* Don't sample the slowest rate (i.e. slowest base 386 SAMPLE_TBL(mi, new_idx, col) = i;
389 * rate). We must presume that the slowest rate works
390 * fine, or else other management frames will also be
391 * failing and the link will break */
392 SAMPLE_TBL(mi, new_idx, col) = i + 1;
393 } 387 }
394 } 388 }
395} 389}
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 200b7e3632da..a0ccc5779910 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -9,7 +9,9 @@
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 [%] */ 12#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
13#define SAMPLE_COLUMNS 10 /* number of columns in sample table */
14
13 15
14/* scaled fraction values */ 16/* scaled fraction values */
15#define MINSTREL_SCALE 16 17#define MINSTREL_SCALE 16
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 3009e457e758..749552bdcfe1 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -17,7 +17,6 @@
17#include "rc80211_minstrel_ht.h" 17#include "rc80211_minstrel_ht.h"
18 18
19#define AVG_PKT_SIZE 1200 19#define AVG_PKT_SIZE 1200
20#define SAMPLE_COLUMNS 10
21 20
22/* Number of bits for an average sized packet */ 21/* Number of bits for an average sized packet */
23#define MCS_NBITS (AVG_PKT_SIZE << 3) 22#define MCS_NBITS (AVG_PKT_SIZE << 3)