alistair23-linux/net/mac80211/rc80211_minstrel.h
Thomas Huehn 2ff2b690c5 mac80211: improve minstrels rate sorting by means of throughput & probability
This patch improves the way minstrel sorts rates according to throughput
and success probability. 3 FOR-loops across the entire rate set in function
minstrel_update_stats() which where used to determine the fastest, second
fastest and most robust rate are reduced to 1 FOR-loop.

The sorted list of rates according throughput is extended to the best four
rates as we need them in upcoming joint rate and power control. The sorting
is done via the new function minstrel_sort_best_tp_rates().

The most robust rate selection is aligned with minstrel_ht's approach.
Once any success probability is above 95% the one with the highest
throughput is chosen as most robust rate. If success probabilities of all
rates are below 95%, the rate with the highest succ. prob. is elected as
most robust one

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>
2013-03-06 16:36:10 +01:00

133 lines
2.9 KiB
C

/*
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __RC_MINSTREL_H
#define __RC_MINSTREL_H
#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */
/* scaled fraction values */
#define MINSTREL_SCALE 16
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
/* number of highest throughput rates to consider*/
#define MAX_THR_RATES 4
/*
* Perform EWMA (Exponentially Weighted Moving Average) calculation
*/
static inline int
minstrel_ewma(int old, int new, int weight)
{
return (new * (100 - weight) + old * weight) / 100;
}
struct minstrel_rate {
int bitrate;
int rix;
unsigned int perfect_tx_time;
unsigned int ack_time;
int sample_limit;
unsigned int retry_count;
unsigned int retry_count_cts;
unsigned int retry_count_rtscts;
unsigned int adjusted_retry_count;
u32 success;
u32 attempts;
u32 last_attempts;
u32 last_success;
u8 sample_skipped;
/* parts per thousand */
u32 cur_prob;
u32 probability;
/* per-rate throughput */
u32 cur_tp;
u64 succ_hist;
u64 att_hist;
};
struct minstrel_sta_info {
unsigned long stats_update;
unsigned int sp_ack_dur;
unsigned int rate_avg;
unsigned int lowest_rix;
u8 max_tp_rate[MAX_THR_RATES];
u8 max_prob_rate;
unsigned int packet_count;
unsigned int sample_count;
int sample_deferred;
unsigned int sample_row;
unsigned int sample_column;
int n_rates;
struct minstrel_rate *r;
bool prev_sample;
/* sampling table */
u8 *sample_table;
#ifdef CONFIG_MAC80211_DEBUGFS
struct dentry *dbg_stats;
#endif
};
struct minstrel_priv {
struct ieee80211_hw *hw;
bool has_mrr;
unsigned int cw_min;
unsigned int cw_max;
unsigned int max_retry;
unsigned int segment_size;
unsigned int update_interval;
unsigned int lookaround_rate;
unsigned int lookaround_rate_mrr;
u8 cck_rates[4];
#ifdef CONFIG_MAC80211_DEBUGFS
/*
* enable fixed rate processing per RC
* - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx
* - write -1 to enable RC processing again
* - setting will be applied on next update
*/
u32 fixed_rate_idx;
struct dentry *dbg_fixed_rate;
#endif
};
struct minstrel_debugfs_info {
size_t len;
char buf[];
};
extern 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);
/* debugfs */
int minstrel_stats_open(struct inode *inode, struct file *file);
ssize_t minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);
int minstrel_stats_release(struct inode *inode, struct file *file);
#endif