Blame view
net/mac80211/rc80211_minstrel.h
3.89 KB
d2912cb15 treewide: Replace... |
1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
cccf129f8 mac80211: add the... |
2 3 |
/* * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org> |
cccf129f8 mac80211: add the... |
4 5 6 7 |
*/ #ifndef __RC_MINSTREL_H #define __RC_MINSTREL_H |
eea85999e mac80211: optimiz... |
8 9 |
#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */ #define EWMA_DIV 128 |
f744bf81f mac80211: add low... |
10 |
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */ |
c8ca8c2f9 mac80211: merge v... |
11 |
/* scaled fraction values */ |
0217eefa6 mac80211: minstre... |
12 |
#define MINSTREL_SCALE 12 |
c8ca8c2f9 mac80211: merge v... |
13 14 |
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) |
2ff2b690c mac80211: improve... |
15 16 |
/* number of highest throughput rates to consider*/ #define MAX_THR_RATES 4 |
a512d4b54 mac80211: merge E... |
17 |
/* |
b1103d256 mac80211: minstre... |
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
* Coefficients for moving average with noise filter (period=16), * scaled by 10 bits * * a1 = exp(-pi * sqrt(2) / period) * coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period) * coeff3 = -sqr(a1) * coeff1 = 1 - coeff2 - coeff3 */ #define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \ MINSTREL_AVG_COEFF2 - \ MINSTREL_AVG_COEFF3) #define MINSTREL_AVG_COEFF2 0x00001499 #define MINSTREL_AVG_COEFF3 -0x0000092e /* |
a512d4b54 mac80211: merge E... |
33 |
* Perform EWMA (Exponentially Weighted Moving Average) calculation |
6d4885177 mac80211: add new... |
34 |
*/ |
a512d4b54 mac80211: merge E... |
35 36 37 |
static inline int minstrel_ewma(int old, int new, int weight) { |
ade6d4a2e mac80211: reduce ... |
38 39 40 41 42 43 |
int diff, incr; diff = new - old; incr = (EWMA_DIV - weight) * diff / EWMA_DIV; return old + incr; |
a512d4b54 mac80211: merge E... |
44 |
} |
5f63afe02 mac80211: minstre... |
45 |
static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in) |
b1103d256 mac80211: minstre... |
46 |
{ |
5f63afe02 mac80211: minstre... |
47 48 |
s32 out_1 = *prev_1; s32 out_2 = *prev_2; |
b1103d256 mac80211: minstre... |
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
s32 val; if (!in) in += 1; if (!out_1) { val = out_1 = in; goto out; } val = MINSTREL_AVG_COEFF1 * in; val += MINSTREL_AVG_COEFF2 * out_1; val += MINSTREL_AVG_COEFF3 * out_2; val >>= MINSTREL_SCALE; if (val > 1 << MINSTREL_SCALE) val = 1 << MINSTREL_SCALE; if (val < 0) val = 1; out: |
5f63afe02 mac80211: minstre... |
70 71 |
*prev_2 = out_1; *prev_1 = val; |
b1103d256 mac80211: minstre... |
72 73 74 |
return val; } |
ca12c0c83 mac80211: Unify r... |
75 76 |
struct minstrel_rate_stats { /* current / last sampling period attempts/success counters */ |
8d819a92c mac80211: minstre... |
77 78 |
u16 attempts, last_attempts; u16 success, last_success; |
ca12c0c83 mac80211: Unify r... |
79 80 |
/* total attempts/success counters */ |
70550df2d mac80211: minstre... |
81 |
u32 att_hist, succ_hist; |
ca12c0c83 mac80211: Unify r... |
82 |
|
5f63afe02 mac80211: minstre... |
83 84 85 |
/* prob_avg - moving average of prob */ u16 prob_avg; u16 prob_avg_1; |
ca12c0c83 mac80211: Unify r... |
86 87 |
/* maximum retry counts */ |
8d819a92c mac80211: minstre... |
88 89 |
u8 retry_count; u8 retry_count_rtscts; |
ca12c0c83 mac80211: Unify r... |
90 91 92 93 |
u8 sample_skipped; bool retry_updated; }; |
a512d4b54 mac80211: merge E... |
94 |
|
cccf129f8 mac80211: add the... |
95 96 |
struct minstrel_rate { int bitrate; |
8d819a92c mac80211: minstre... |
97 98 99 100 |
s8 rix; u8 retry_count_cts; u8 adjusted_retry_count; |
cccf129f8 mac80211: add the... |
101 102 103 |
unsigned int perfect_tx_time; unsigned int ack_time; |
f4a8cd94f minstrel: improve... |
104 |
int sample_limit; |
cccf129f8 mac80211: add the... |
105 |
|
ca12c0c83 mac80211: Unify r... |
106 |
struct minstrel_rate_stats stats; |
cccf129f8 mac80211: add the... |
107 108 109 |
}; struct minstrel_sta_info { |
06d961a8e mac80211/minstrel... |
110 |
struct ieee80211_sta *sta; |
9134073bc mac80211: improve... |
111 |
unsigned long last_stats_update; |
cccf129f8 mac80211: add the... |
112 113 114 115 |
unsigned int sp_ack_dur; unsigned int rate_avg; unsigned int lowest_rix; |
2ff2b690c mac80211: improve... |
116 117 |
u8 max_tp_rate[MAX_THR_RATES]; u8 max_prob_rate; |
ca12c0c83 mac80211: Unify r... |
118 119 |
unsigned int total_packets; unsigned int sample_packets; |
cccf129f8 mac80211: add the... |
120 |
int sample_deferred; |
8f1576119 mac80211: add doc... |
121 |
unsigned int sample_row; |
cccf129f8 mac80211: add the... |
122 123 124 125 |
unsigned int sample_column; int n_rates; struct minstrel_rate *r; |
f4a8cd94f minstrel: improve... |
126 |
bool prev_sample; |
cccf129f8 mac80211: add the... |
127 128 129 |
/* sampling table */ u8 *sample_table; |
cccf129f8 mac80211: add the... |
130 131 132 133 134 |
}; struct minstrel_priv { struct ieee80211_hw *hw; bool has_mrr; |
b1103d256 mac80211: minstre... |
135 |
bool new_avg; |
48cb39522 mac80211: minstre... |
136 |
u32 sample_switch; |
cccf129f8 mac80211: add the... |
137 138 139 |
unsigned int cw_min; unsigned int cw_max; unsigned int max_retry; |
cccf129f8 mac80211: add the... |
140 141 142 143 |
unsigned int segment_size; unsigned int update_interval; unsigned int lookaround_rate; unsigned int lookaround_rate_mrr; |
24f7580e8 minstrel_ht: fixe... |
144 |
|
a0497f9f5 mac80211/minstrel... |
145 |
u8 cck_rates[4]; |
24f7580e8 minstrel_ht: fixe... |
146 147 148 149 150 151 152 153 |
#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; |
24f7580e8 minstrel_ht: fixe... |
154 |
#endif |
cccf129f8 mac80211: add the... |
155 |
}; |
44ac91ea8 minstrel: simplif... |
156 157 158 159 |
struct minstrel_debugfs_info { size_t len; char buf[]; }; |
631ad703b mac80211: make ra... |
160 |
extern const struct rate_control_ops mac80211_minstrel; |
cccf129f8 mac80211: add the... |
161 |
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir); |
cccf129f8 mac80211: add the... |
162 |
|
f62838bcc mac80211: unify M... |
163 |
/* Recalculate success probabilities and counters for a given rate using EWMA */ |
b1103d256 mac80211: minstre... |
164 165 |
void minstrel_calc_rate_stats(struct minstrel_priv *mp, struct minstrel_rate_stats *mrs); |
5f63afe02 mac80211: minstre... |
166 |
int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_avg); |
f62838bcc mac80211: unify M... |
167 |
|
eae44756d minstrel: make th... |
168 169 |
/* debugfs */ int minstrel_stats_open(struct inode *inode, struct file *file); |
6d4885177 mac80211: add new... |
170 |
int minstrel_stats_csv_open(struct inode *inode, struct file *file); |
eae44756d minstrel: make th... |
171 |
|
cccf129f8 mac80211: add the... |
172 |
#endif |