]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/wireless/ath/ath9k/rc.h
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[net-next-2.6.git] / drivers / net / wireless / ath / ath9k / rc.h
CommitLineData
f078f209
LR
1/*
2 * Copyright (c) 2004 Sam Leffler, Errno Consulting
3 * Copyright (c) 2004 Video54 Technologies, Inc.
cee075a2 4 * Copyright (c) 2008-2009 Atheros Communications Inc.
f078f209
LR
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#ifndef RC_H
20#define RC_H
21
db86f07e
LR
22#include "hw.h"
23
f078f209
LR
24struct ath_softc;
25
46d14a58 26#define ATH_RATE_MAX 30
1d9d06a2 27#define RATE_TABLE_SIZE 72
46d14a58 28#define MAX_TX_RATE_PHY 48
f078f209 29
f63b340d
SB
30
31#define RC_INVALID 0x0000
32#define RC_LEGACY 0x0001
33#define RC_SS 0x0002
34#define RC_DS 0x0004
35#define RC_TS 0x0008
36#define RC_HT_20 0x0010
37#define RC_HT_40 0x0020
38
1d9d06a2
SB
39#define RC_STREAM_MASK 0xe
40#define RC_DS_OR_LATER(f) ((((f) & RC_STREAM_MASK) == RC_DS) || \
41 (((f) & RC_STREAM_MASK) == (RC_DS | RC_TS)))
42#define RC_TS_ONLY(f) (((f) & RC_STREAM_MASK) == RC_TS)
43#define RC_SS_OR_LEGACY(f) ((f) & (RC_SS | RC_LEGACY))
f63b340d
SB
44
45#define RC_HT_2040 (RC_HT_20 | RC_HT_40)
1d9d06a2 46#define RC_ALL_STREAM (RC_SS | RC_DS | RC_TS)
f63b340d 47#define RC_L_SD (RC_LEGACY | RC_SS | RC_DS)
1d9d06a2 48#define RC_L_SDT (RC_LEGACY | RC_SS | RC_DS | RC_TS)
f63b340d 49#define RC_HT_S_20 (RC_HT_20 | RC_SS)
f63b340d 50#define RC_HT_D_20 (RC_HT_20 | RC_DS)
1d9d06a2
SB
51#define RC_HT_T_20 (RC_HT_20 | RC_TS)
52#define RC_HT_S_40 (RC_HT_40 | RC_SS)
f63b340d 53#define RC_HT_D_40 (RC_HT_40 | RC_DS)
1d9d06a2
SB
54#define RC_HT_T_40 (RC_HT_40 | RC_TS)
55
56#define RC_HT_SD_20 (RC_HT_20 | RC_SS | RC_DS)
57#define RC_HT_DT_20 (RC_HT_20 | RC_DS | RC_TS)
58#define RC_HT_SD_40 (RC_HT_40 | RC_SS | RC_DS)
59#define RC_HT_DT_40 (RC_HT_40 | RC_DS | RC_TS)
60
61#define RC_HT_SD_2040 (RC_HT_2040 | RC_SS | RC_DS)
62#define RC_HT_SDT_2040 (RC_HT_2040 | RC_SS | RC_DS | RC_TS)
63
64#define RC_HT_SDT_20 (RC_HT_20 | RC_SS | RC_DS | RC_TS)
65#define RC_HT_SDT_40 (RC_HT_40 | RC_SS | RC_DS | RC_TS)
66
f63b340d 67#define RC_ALL (RC_LEGACY | RC_HT_2040 | RC_ALL_STREAM)
f078f209 68
394cf0a1
S
69enum {
70 WLAN_RC_PHY_OFDM,
71 WLAN_RC_PHY_CCK,
72 WLAN_RC_PHY_HT_20_SS,
73 WLAN_RC_PHY_HT_20_DS,
1d9d06a2 74 WLAN_RC_PHY_HT_20_TS,
394cf0a1
S
75 WLAN_RC_PHY_HT_40_SS,
76 WLAN_RC_PHY_HT_40_DS,
1d9d06a2 77 WLAN_RC_PHY_HT_40_TS,
394cf0a1
S
78 WLAN_RC_PHY_HT_20_SS_HGI,
79 WLAN_RC_PHY_HT_20_DS_HGI,
1d9d06a2 80 WLAN_RC_PHY_HT_20_TS_HGI,
394cf0a1
S
81 WLAN_RC_PHY_HT_40_SS_HGI,
82 WLAN_RC_PHY_HT_40_DS_HGI,
1d9d06a2 83 WLAN_RC_PHY_HT_40_TS_HGI,
394cf0a1
S
84 WLAN_RC_PHY_MAX
85};
86
5701ed84
S
87#define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \
88 || (_phy == WLAN_RC_PHY_HT_40_DS) \
89 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
90 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI))
1d9d06a2
SB
91#define WLAN_RC_PHY_TS(_phy) ((_phy == WLAN_RC_PHY_HT_20_TS) \
92 || (_phy == WLAN_RC_PHY_HT_40_TS) \
93 || (_phy == WLAN_RC_PHY_HT_20_TS_HGI) \
94 || (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
c755ad34
LR
95#define WLAN_RC_PHY_20(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS) \
96 || (_phy == WLAN_RC_PHY_HT_20_DS) \
1d9d06a2 97 || (_phy == WLAN_RC_PHY_HT_20_TS) \
c755ad34 98 || (_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
1d9d06a2
SB
99 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
100 || (_phy == WLAN_RC_PHY_HT_20_TS_HGI))
5701ed84
S
101#define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \
102 || (_phy == WLAN_RC_PHY_HT_40_DS) \
1d9d06a2 103 || (_phy == WLAN_RC_PHY_HT_40_TS) \
5701ed84 104 || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
1d9d06a2
SB
105 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI) \
106 || (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
f078f209 107#define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
5701ed84 108 || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
1d9d06a2 109 || (_phy == WLAN_RC_PHY_HT_20_TS_HGI) \
5701ed84 110 || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
1d9d06a2
SB
111 || (_phy == WLAN_RC_PHY_HT_40_DS_HGI) \
112 || (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
f078f209
LR
113
114#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
115
f078f209 116#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
f63b340d
SB
117 ((capflag & WLAN_RC_40_FLAG) ? RC_HT_40 : RC_HT_20) : RC_LEGACY))
118
1d9d06a2
SB
119#define WLAN_RC_CAP_STREAM(capflag) (((capflag & WLAN_RC_TS_FLAG) ? \
120 (RC_TS) : ((capflag & WLAN_RC_DS_FLAG) ? RC_DS : RC_SS)))
f078f209
LR
121
122/* Return TRUE if flag supports HT20 && client supports HT20 or
123 * return TRUE if flag supports HT40 && client supports HT40.
124 * This is used becos some rates overlap between HT20/HT40.
125 */
46d14a58 126#define WLAN_RC_PHY_HT_VALID(flag, capflag) \
f63b340d
SB
127 (((flag & RC_HT_20) && !(capflag & WLAN_RC_40_FLAG)) || \
128 ((flag & RC_HT_40) && (capflag & WLAN_RC_40_FLAG)))
f078f209
LR
129
130#define WLAN_RC_DS_FLAG (0x01)
1d9d06a2
SB
131#define WLAN_RC_TS_FLAG (0x02)
132#define WLAN_RC_40_FLAG (0x04)
133#define WLAN_RC_SGI_FLAG (0x08)
134#define WLAN_RC_HT_FLAG (0x10)
f078f209 135
5701ed84
S
136/**
137 * struct ath_rate_table - Rate Control table
7a826652
MSS
138 * @rate_cnt: total number of rates for the given wireless mode
139 * @mcs_start: MCS rate index offset
140 * @rate_flags: Rate Control flags
141 * @phy: CCK/OFDM/HT20/HT40
5701ed84
S
142 * @ratekbps: rate in Kbits per second
143 * @user_ratekbps: user rate in Kbits per second
144 * @ratecode: rate that goes into HW descriptors
5701ed84
S
145 * @dot11rate: value that goes into supported
146 * rates info element of MLME
147 * @ctrl_rate: Index of next lower basic rate, used for duration computation
7a826652
MSS
148 * @cw40index: Index of rates having 40MHz channel width
149 * @sgi_index: Index of rates having Short Guard Interval
150 * @ht_index: high throughput rates having 40MHz channel width and
151 * Short Guard Interval
5701ed84 152 * @probe_interval: interval for rate control to probe for other rates
46d14a58 153 * @initial_ratemax: initial ratemax value
5701ed84 154 */
f078f209
LR
155struct ath_rate_table {
156 int rate_cnt;
545750d3 157 int mcs_start;
f078f209 158 struct {
f63b340d 159 u16 rate_flags;
5701ed84
S
160 u8 phy;
161 u32 ratekbps;
162 u32 user_ratekbps;
163 u8 ratecode;
5701ed84
S
164 u8 dot11rate;
165 u8 ctrl_rate;
5701ed84
S
166 u8 cw40index;
167 u8 sgi_index;
168 u8 ht_index;
f078f209 169 } info[RATE_TABLE_SIZE];
5701ed84 170 u32 probe_interval;
5701ed84 171 u8 initial_ratemax;
f078f209
LR
172};
173
256b7759
S
174struct ath_rateset {
175 u8 rs_nrates;
176 u8 rs_rates[ATH_RATE_MAX];
177};
178
772d5515
FF
179struct ath_rc_stats {
180 u32 success;
181 u32 retries;
182 u32 xretries;
183 u8 per;
184};
185
5701ed84 186/**
46d14a58 187 * struct ath_rate_priv - Rate Control priv data
5701ed84 188 * @state: RC state
5701ed84 189 * @probe_rate: rate we are probing at
5701ed84
S
190 * @probe_time: msec timestamp for last probe
191 * @hw_maxretry_pktcnt: num of packets since we got HW max retry error
192 * @max_valid_rate: maximum number of valid rate
193 * @per_down_time: msec timestamp for last PER down step
194 * @valid_phy_ratecnt: valid rate count
195 * @rate_max_phy: phy index for the max rate
922bac60 196 * @per: PER for every valid rate in %
5701ed84 197 * @probe_interval: interval for ratectrl to probe for other rates
256b7759
S
198 * @prev_data_rix: rate idx of last data frame
199 * @ht_cap: HT capabilities
256b7759
S
200 * @neg_rates: Negotatied rates
201 * @neg_ht_rates: Negotiated HT rates
5701ed84 202 */
46d14a58 203struct ath_rate_priv {
5701ed84
S
204 u8 rate_table_size;
205 u8 probe_rate;
5701ed84
S
206 u8 hw_maxretry_pktcnt;
207 u8 max_valid_rate;
46d14a58 208 u8 valid_rate_index[RATE_TABLE_SIZE];
256b7759 209 u8 ht_cap;
5701ed84 210 u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
46d14a58 211 u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
5701ed84 212 u8 rate_max_phy;
922bac60 213 u8 per[RATE_TABLE_SIZE];
256b7759
S
214 u32 probe_time;
215 u32 per_down_time;
5701ed84 216 u32 probe_interval;
5701ed84 217 u32 prev_data_rix;
fe7f4a77 218 u32 tx_triglevel_max;
5701ed84 219 struct ath_rateset neg_rates;
5701ed84 220 struct ath_rateset neg_ht_rates;
5701ed84 221 struct ath_rate_softc *asc;
772d5515
FF
222 const struct ath_rate_table *rate_table;
223
224 struct dentry *debugfs_rcstats;
225 struct ath_rc_stats rcstats[RATE_TABLE_SIZE];
f078f209
LR
226};
227
827e69bf
FF
228#define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0)
229#define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1)
827e69bf
FF
230#define ATH_TX_INFO_XRETRY (1 << 3)
231#define ATH_TX_INFO_UNDERRUN (1 << 4)
232
f0ed85c6 233enum ath9k_internal_frame_type {
c81494d5
PR
234 ATH9K_IFT_NOT_INTERNAL,
235 ATH9K_IFT_PAUSE,
236 ATH9K_IFT_UNPAUSE
f0ed85c6
JM
237};
238
6e5c2b4e 239#ifdef CONFIG_ATH9K_RATE_CONTROL
f078f209
LR
240int ath_rate_control_register(void);
241void ath_rate_control_unregister(void);
6e5c2b4e
FF
242#else
243static inline int ath_rate_control_register(void)
244{
245 return 0;
246}
247
248static inline void ath_rate_control_unregister(void)
249{
250}
251#endif
f078f209
LR
252
253#endif /* RC_H */