1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef RC_H
20#define RC_H
21
22#include "hw.h"
23
24struct ath_softc;
25
26#define ATH_RATE_MAX 30
27#define RATE_TABLE_SIZE 72
28
29#define RC_INVALID 0x0000
30#define RC_LEGACY 0x0001
31#define RC_SS 0x0002
32#define RC_DS 0x0004
33#define RC_TS 0x0008
34#define RC_HT_20 0x0010
35#define RC_HT_40 0x0020
36
37#define RC_STREAM_MASK 0xe
38#define RC_DS_OR_LATER(f) ((((f) & RC_STREAM_MASK) == RC_DS) || \
39 (((f) & RC_STREAM_MASK) == (RC_DS | RC_TS)))
40#define RC_TS_ONLY(f) (((f) & RC_STREAM_MASK) == RC_TS)
41#define RC_SS_OR_LEGACY(f) ((f) & (RC_SS | RC_LEGACY))
42
43#define RC_HT_2040 (RC_HT_20 | RC_HT_40)
44#define RC_ALL_STREAM (RC_SS | RC_DS | RC_TS)
45#define RC_L_SD (RC_LEGACY | RC_SS | RC_DS)
46#define RC_L_SDT (RC_LEGACY | RC_SS | RC_DS | RC_TS)
47#define RC_HT_S_20 (RC_HT_20 | RC_SS)
48#define RC_HT_D_20 (RC_HT_20 | RC_DS)
49#define RC_HT_T_20 (RC_HT_20 | RC_TS)
50#define RC_HT_S_40 (RC_HT_40 | RC_SS)
51#define RC_HT_D_40 (RC_HT_40 | RC_DS)
52#define RC_HT_T_40 (RC_HT_40 | RC_TS)
53
54#define RC_HT_SD_20 (RC_HT_20 | RC_SS | RC_DS)
55#define RC_HT_DT_20 (RC_HT_20 | RC_DS | RC_TS)
56#define RC_HT_SD_40 (RC_HT_40 | RC_SS | RC_DS)
57#define RC_HT_DT_40 (RC_HT_40 | RC_DS | RC_TS)
58
59#define RC_HT_SD_2040 (RC_HT_2040 | RC_SS | RC_DS)
60#define RC_HT_SDT_2040 (RC_HT_2040 | RC_SS | RC_DS | RC_TS)
61
62#define RC_HT_SDT_20 (RC_HT_20 | RC_SS | RC_DS | RC_TS)
63#define RC_HT_SDT_40 (RC_HT_40 | RC_SS | RC_DS | RC_TS)
64
65#define RC_ALL (RC_LEGACY | RC_HT_2040 | RC_ALL_STREAM)
66
67enum {
68 WLAN_RC_PHY_OFDM,
69 WLAN_RC_PHY_CCK,
70 WLAN_RC_PHY_HT_20_SS,
71 WLAN_RC_PHY_HT_20_DS,
72 WLAN_RC_PHY_HT_20_TS,
73 WLAN_RC_PHY_HT_40_SS,
74 WLAN_RC_PHY_HT_40_DS,
75 WLAN_RC_PHY_HT_40_TS,
76 WLAN_RC_PHY_HT_20_SS_HGI,
77 WLAN_RC_PHY_HT_20_DS_HGI,
78 WLAN_RC_PHY_HT_20_TS_HGI,
79 WLAN_RC_PHY_HT_40_SS_HGI,
80 WLAN_RC_PHY_HT_40_DS_HGI,
81 WLAN_RC_PHY_HT_40_TS_HGI,
82 WLAN_RC_PHY_MAX
83};
84
85#define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \
86 || (_phy == WLAN_RC_PHY_HT_40_DS) \
87 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
88 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
89#define WLAN_RC_PHY_TS(_phy) ((_phy == WLAN_RC_PHY_HT_20_TS) \
90 || (_phy == WLAN_RC_PHY_HT_40_TS) \
91 || (_phy == WLAN_RC_PHY_HT_20_TS_HGI) \
92 || (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
93#define WLAN_RC_PHY_20(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS) \
94 || (_phy == WLAN_RC_PHY_HT_20_DS) \
95 || (_phy == WLAN_RC_PHY_HT_20_TS) \
96 || (_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
97 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
98 || (_phy == WLAN_RC_PHY_HT_20_TS_HGI))
99#define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \
100 || (_phy == WLAN_RC_PHY_HT_40_DS) \
101 || (_phy == WLAN_RC_PHY_HT_40_TS) \
102 || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
103 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI) \
104 || (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
105#define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
106 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
107 || (_phy == WLAN_RC_PHY_HT_20_TS_HGI) \
108 || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
109 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI) \
110 || (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
111
112#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
113
114#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
115 ((capflag & WLAN_RC_40_FLAG) ? RC_HT_40 : RC_HT_20) : RC_LEGACY))
116
117#define WLAN_RC_CAP_STREAM(capflag) (((capflag & WLAN_RC_TS_FLAG) ? \
118 (RC_TS) : ((capflag & WLAN_RC_DS_FLAG) ? RC_DS : RC_SS)))
119
120
121
122
123
124#define WLAN_RC_PHY_HT_VALID(flag, capflag) \
125 (((flag & RC_HT_20) && !(capflag & WLAN_RC_40_FLAG)) || \
126 ((flag & RC_HT_40) && (capflag & WLAN_RC_40_FLAG)))
127
128#define WLAN_RC_DS_FLAG (0x01)
129#define WLAN_RC_TS_FLAG (0x02)
130#define WLAN_RC_40_FLAG (0x04)
131#define WLAN_RC_SGI_FLAG (0x08)
132#define WLAN_RC_HT_FLAG (0x10)
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153struct ath_rate_table {
154 int rate_cnt;
155 int mcs_start;
156 struct {
157 u16 rate_flags;
158 u8 phy;
159 u32 ratekbps;
160 u32 user_ratekbps;
161 u8 ratecode;
162 u8 dot11rate;
163 } info[RATE_TABLE_SIZE];
164 u32 probe_interval;
165 u8 initial_ratemax;
166};
167
168struct ath_rateset {
169 u8 rs_nrates;
170 u8 rs_rates[ATH_RATE_MAX];
171};
172
173struct ath_rc_stats {
174 u32 success;
175 u32 retries;
176 u32 xretries;
177 u8 per;
178};
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196struct ath_rate_priv {
197 u8 rate_table_size;
198 u8 probe_rate;
199 u8 hw_maxretry_pktcnt;
200 u8 max_valid_rate;
201 u8 valid_rate_index[RATE_TABLE_SIZE];
202 u8 ht_cap;
203 u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
204 u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
205 u8 rate_max_phy;
206 u8 per[RATE_TABLE_SIZE];
207 u32 probe_time;
208 u32 per_down_time;
209 u32 probe_interval;
210 struct ath_rateset neg_rates;
211 struct ath_rateset neg_ht_rates;
212 const struct ath_rate_table *rate_table;
213
214#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS)
215 struct dentry *debugfs_rcstats;
216 struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
217#endif
218};
219
220#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS)
221void ath_debug_stat_rc(struct ath_rate_priv *rc, int final_rate);
222void ath_debug_stat_retries(struct ath_rate_priv *rc, int rix,
223 int xretries, int retries, u8 per);
224#else
225static inline void ath_debug_stat_rc(struct ath_rate_priv *rc, int final_rate)
226{
227}
228static inline void ath_debug_stat_retries(struct ath_rate_priv *rc, int rix,
229 int xretries, int retries, u8 per)
230{
231}
232#endif
233
234#ifdef CONFIG_ATH9K_LEGACY_RATE_CONTROL
235int ath_rate_control_register(void);
236void ath_rate_control_unregister(void);
237#else
238static inline int ath_rate_control_register(void)
239{
240 return 0;
241}
242
243static inline void ath_rate_control_unregister(void)
244{
245}
246#endif
247
248#endif
249