mac80211: merge EWMA calculation of minstrel_ht and minstrel
[deliverable/linux.git] / net / mac80211 / rc80211_minstrel.h
CommitLineData
cccf129f
FF
1/*
2 * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __RC_MINSTREL_H
10#define __RC_MINSTREL_H
11
a512d4b5
TH
12#define EWMA_LEVEL 75 /* ewma weighting factor [%] */
13
14/*
15 * Perform EWMA (Exponentially Weighted Moving Average) calculation
16 */
17static inline int
18minstrel_ewma(int old, int new, int weight)
19{
20 return (new * (100 - weight) + old * weight) / 100;
21}
22
23
cccf129f
FF
24struct minstrel_rate {
25 int bitrate;
26 int rix;
27
28 unsigned int perfect_tx_time;
29 unsigned int ack_time;
30
f4a8cd94 31 int sample_limit;
cccf129f
FF
32 unsigned int retry_count;
33 unsigned int retry_count_cts;
34 unsigned int retry_count_rtscts;
35 unsigned int adjusted_retry_count;
36
37 u32 success;
38 u32 attempts;
39 u32 last_attempts;
40 u32 last_success;
41
42 /* parts per thousand */
43 u32 cur_prob;
44 u32 probability;
45
46 /* per-rate throughput */
47 u32 cur_tp;
cccf129f
FF
48
49 u64 succ_hist;
50 u64 att_hist;
51};
52
53struct minstrel_sta_info {
54 unsigned long stats_update;
55 unsigned int sp_ack_dur;
56 unsigned int rate_avg;
57
58 unsigned int lowest_rix;
59
60 unsigned int max_tp_rate;
61 unsigned int max_tp_rate2;
62 unsigned int max_prob_rate;
63 unsigned int packet_count;
64 unsigned int sample_count;
65 int sample_deferred;
66
67 unsigned int sample_idx;
68 unsigned int sample_column;
69
70 int n_rates;
71 struct minstrel_rate *r;
f4a8cd94 72 bool prev_sample;
cccf129f
FF
73
74 /* sampling table */
75 u8 *sample_table;
76
77#ifdef CONFIG_MAC80211_DEBUGFS
78 struct dentry *dbg_stats;
79#endif
80};
81
82struct minstrel_priv {
83 struct ieee80211_hw *hw;
84 bool has_mrr;
85 unsigned int cw_min;
86 unsigned int cw_max;
87 unsigned int max_retry;
cccf129f
FF
88 unsigned int segment_size;
89 unsigned int update_interval;
90 unsigned int lookaround_rate;
91 unsigned int lookaround_rate_mrr;
24f7580e 92
a0497f9f
FF
93 u8 cck_rates[4];
94
24f7580e
ZK
95#ifdef CONFIG_MAC80211_DEBUGFS
96 /*
97 * enable fixed rate processing per RC
98 * - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx
99 * - write -1 to enable RC processing again
100 * - setting will be applied on next update
101 */
102 u32 fixed_rate_idx;
103 struct dentry *dbg_fixed_rate;
104#endif
105
cccf129f
FF
106};
107
44ac91ea
FF
108struct minstrel_debugfs_info {
109 size_t len;
110 char buf[];
111};
112
eae44756 113extern struct rate_control_ops mac80211_minstrel;
cccf129f
FF
114void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
115void minstrel_remove_sta_debugfs(void *priv, void *priv_sta);
116
eae44756
FF
117/* debugfs */
118int minstrel_stats_open(struct inode *inode, struct file *file);
119ssize_t minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);
120int minstrel_stats_release(struct inode *inode, struct file *file);
121
cccf129f 122#endif
This page took 0.280495 seconds and 5 git commands to generate.