Blame view
net/mac80211/rc80211_minstrel.h
4.11 KB
cccf129f8
|
1 2 3 4 5 6 7 8 9 10 |
/* * 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 |
eea85999e
|
11 12 |
#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */ #define EWMA_DIV 128 |
f744bf81f
|
13 |
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */ |
c8ca8c2f9
|
14 |
/* scaled fraction values */ |
0217eefa6
|
15 |
#define MINSTREL_SCALE 12 |
c8ca8c2f9
|
16 17 |
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) |
2ff2b690c
|
18 19 |
/* number of highest throughput rates to consider*/ #define MAX_THR_RATES 4 |
a512d4b54
|
20 21 |
/* * Perform EWMA (Exponentially Weighted Moving Average) calculation |
6d4885177
|
22 |
*/ |
a512d4b54
|
23 24 25 |
static inline int minstrel_ewma(int old, int new, int weight) { |
ade6d4a2e
|
26 27 28 29 30 31 |
int diff, incr; diff = new - old; incr = (EWMA_DIV - weight) * diff / EWMA_DIV; return old + incr; |
a512d4b54
|
32 |
} |
5f919abc7
|
33 |
/* |
4f0bc9c61
|
34 |
* Perform EWMV (Exponentially Weighted Moving Variance) calculation |
5f919abc7
|
35 36 |
*/ static inline int |
4f0bc9c61
|
37 |
minstrel_ewmv(int old_ewmv, int cur_prob, int prob_ewma, int weight) |
5f919abc7
|
38 |
{ |
4f0bc9c61
|
39 |
int diff, incr; |
5f919abc7
|
40 |
|
4f0bc9c61
|
41 |
diff = cur_prob - prob_ewma; |
5f919abc7
|
42 |
incr = (EWMA_DIV - weight) * diff / EWMA_DIV; |
4f0bc9c61
|
43 |
return weight * (old_ewmv + MINSTREL_TRUNC(diff * incr)) / EWMA_DIV; |
5f919abc7
|
44 |
} |
ca12c0c83
|
45 46 |
struct minstrel_rate_stats { /* current / last sampling period attempts/success counters */ |
8d819a92c
|
47 48 |
u16 attempts, last_attempts; u16 success, last_success; |
ca12c0c83
|
49 50 |
/* total attempts/success counters */ |
70550df2d
|
51 |
u32 att_hist, succ_hist; |
ca12c0c83
|
52 |
|
9134073bc
|
53 |
/* statistis of packet delivery probability |
5f919abc7
|
54 55 |
* prob_ewma - exponential weighted moving average of prob * prob_ewmsd - exp. weighted moving standard deviation of prob */ |
4cae4cd10
|
56 |
u16 prob_ewma; |
4f0bc9c61
|
57 |
u16 prob_ewmv; |
ca12c0c83
|
58 59 |
/* maximum retry counts */ |
8d819a92c
|
60 61 |
u8 retry_count; u8 retry_count_rtscts; |
ca12c0c83
|
62 63 64 65 |
u8 sample_skipped; bool retry_updated; }; |
a512d4b54
|
66 |
|
cccf129f8
|
67 68 |
struct minstrel_rate { int bitrate; |
8d819a92c
|
69 70 71 72 |
s8 rix; u8 retry_count_cts; u8 adjusted_retry_count; |
cccf129f8
|
73 74 75 |
unsigned int perfect_tx_time; unsigned int ack_time; |
f4a8cd94f
|
76 |
int sample_limit; |
cccf129f8
|
77 |
|
ca12c0c83
|
78 |
struct minstrel_rate_stats stats; |
cccf129f8
|
79 80 81 |
}; struct minstrel_sta_info { |
06d961a8e
|
82 |
struct ieee80211_sta *sta; |
9134073bc
|
83 |
unsigned long last_stats_update; |
cccf129f8
|
84 85 86 87 |
unsigned int sp_ack_dur; unsigned int rate_avg; unsigned int lowest_rix; |
2ff2b690c
|
88 89 |
u8 max_tp_rate[MAX_THR_RATES]; u8 max_prob_rate; |
ca12c0c83
|
90 91 |
unsigned int total_packets; unsigned int sample_packets; |
cccf129f8
|
92 |
int sample_deferred; |
8f1576119
|
93 |
unsigned int sample_row; |
cccf129f8
|
94 95 96 97 |
unsigned int sample_column; int n_rates; struct minstrel_rate *r; |
f4a8cd94f
|
98 |
bool prev_sample; |
cccf129f8
|
99 100 101 102 103 104 |
/* sampling table */ u8 *sample_table; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *dbg_stats; |
6d4885177
|
105 |
struct dentry *dbg_stats_csv; |
cccf129f8
|
106 107 108 109 110 111 112 113 114 |
#endif }; struct minstrel_priv { struct ieee80211_hw *hw; bool has_mrr; unsigned int cw_min; unsigned int cw_max; unsigned int max_retry; |
cccf129f8
|
115 116 117 118 |
unsigned int segment_size; unsigned int update_interval; unsigned int lookaround_rate; unsigned int lookaround_rate_mrr; |
24f7580e8
|
119 |
|
a0497f9f5
|
120 |
u8 cck_rates[4]; |
24f7580e8
|
121 122 123 124 125 126 127 128 129 130 |
#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 |
cccf129f8
|
131 |
}; |
44ac91ea8
|
132 133 134 135 |
struct minstrel_debugfs_info { size_t len; char buf[]; }; |
4f0bc9c61
|
136 137 138 139 140 141 142 |
/* Get EWMSD (Exponentially Weighted Moving Standard Deviation) * 10 */ static inline int minstrel_get_ewmsd10(struct minstrel_rate_stats *mrs) { unsigned int ewmv = mrs->prob_ewmv; return int_sqrt(MINSTREL_TRUNC(ewmv * 1000 * 1000)); } |
631ad703b
|
143 |
extern const struct rate_control_ops mac80211_minstrel; |
cccf129f8
|
144 145 |
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); void minstrel_remove_sta_debugfs(void *priv, void *priv_sta); |
f62838bcc
|
146 |
/* Recalculate success probabilities and counters for a given rate using EWMA */ |
9134073bc
|
147 |
void minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs); |
50e55a8ea
|
148 |
int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_ewma); |
f62838bcc
|
149 |
|
eae44756d
|
150 151 |
/* debugfs */ int minstrel_stats_open(struct inode *inode, struct file *file); |
6d4885177
|
152 |
int minstrel_stats_csv_open(struct inode *inode, struct file *file); |
eae44756d
|
153 154 |
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); |
cccf129f8
|
155 |
#endif |