2
* Copyright (c) 2004 Sam Leffler, Errno Consulting
3
* Copyright (c) 2004 Video54 Technologies, Inc.
4
* Copyright (c) 2008-2009 Atheros Communications Inc.
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.
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.
26
#define ATH_RATE_MAX 30
27
#define RATE_TABLE_SIZE 72
28
#define MAX_TX_RATE_PHY 48
31
#define RC_INVALID 0x0000
32
#define RC_LEGACY 0x0001
36
#define RC_HT_20 0x0010
37
#define RC_HT_40 0x0020
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))
45
#define RC_HT_2040 (RC_HT_20 | RC_HT_40)
46
#define RC_ALL_STREAM (RC_SS | RC_DS | RC_TS)
47
#define RC_L_SD (RC_LEGACY | RC_SS | RC_DS)
48
#define RC_L_SDT (RC_LEGACY | RC_SS | RC_DS | RC_TS)
49
#define RC_HT_S_20 (RC_HT_20 | RC_SS)
50
#define RC_HT_D_20 (RC_HT_20 | RC_DS)
51
#define RC_HT_T_20 (RC_HT_20 | RC_TS)
52
#define RC_HT_S_40 (RC_HT_40 | RC_SS)
53
#define RC_HT_D_40 (RC_HT_40 | RC_DS)
54
#define RC_HT_T_40 (RC_HT_40 | RC_TS)
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)
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)
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)
67
#define RC_ALL (RC_LEGACY | RC_HT_2040 | RC_ALL_STREAM)
78
WLAN_RC_PHY_HT_20_SS_HGI,
79
WLAN_RC_PHY_HT_20_DS_HGI,
80
WLAN_RC_PHY_HT_20_TS_HGI,
81
WLAN_RC_PHY_HT_40_SS_HGI,
82
WLAN_RC_PHY_HT_40_DS_HGI,
83
WLAN_RC_PHY_HT_40_TS_HGI,
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))
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))
95
#define WLAN_RC_PHY_20(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS) \
96
|| (_phy == WLAN_RC_PHY_HT_20_DS) \
97
|| (_phy == WLAN_RC_PHY_HT_20_TS) \
98
|| (_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
99
|| (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
100
|| (_phy == WLAN_RC_PHY_HT_20_TS_HGI))
101
#define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \
102
|| (_phy == WLAN_RC_PHY_HT_40_DS) \
103
|| (_phy == WLAN_RC_PHY_HT_40_TS) \
104
|| (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
105
|| (_phy == WLAN_RC_PHY_HT_40_DS_HGI) \
106
|| (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
107
#define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \
108
|| (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \
109
|| (_phy == WLAN_RC_PHY_HT_20_TS_HGI) \
110
|| (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \
111
|| (_phy == WLAN_RC_PHY_HT_40_DS_HGI) \
112
|| (_phy == WLAN_RC_PHY_HT_40_TS_HGI))
114
#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
116
#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
117
((capflag & WLAN_RC_40_FLAG) ? RC_HT_40 : RC_HT_20) : RC_LEGACY))
119
#define WLAN_RC_CAP_STREAM(capflag) (((capflag & WLAN_RC_TS_FLAG) ? \
120
(RC_TS) : ((capflag & WLAN_RC_DS_FLAG) ? RC_DS : RC_SS)))
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.
126
#define WLAN_RC_PHY_HT_VALID(flag, capflag) \
127
(((flag & RC_HT_20) && !(capflag & WLAN_RC_40_FLAG)) || \
128
((flag & RC_HT_40) && (capflag & WLAN_RC_40_FLAG)))
130
#define WLAN_RC_DS_FLAG (0x01)
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)
137
* struct ath_rate_table - Rate Control table
138
* @valid: valid for use in rate control
139
* @valid_single_stream: valid for use in rate control for
140
* single stream operation
142
* @ratekbps: rate in Kbits per second
143
* @user_ratekbps: user rate in Kbits per second
144
* @ratecode: rate that goes into HW descriptors
145
* @short_preamble: Mask for enabling short preamble in ratecode for CCK
146
* @dot11rate: value that goes into supported
147
* rates info element of MLME
148
* @ctrl_rate: Index of next lower basic rate, used for duration computation
149
* @max_4ms_framelen: maximum frame length(bytes) for tx duration
150
* @probe_interval: interval for rate control to probe for other rates
151
* @rssi_reduce_interval: interval for rate control to reduce rssi
152
* @initial_ratemax: initial ratemax value
154
struct ath_rate_table {
168
} info[RATE_TABLE_SIZE];
175
u8 rs_rates[ATH_RATE_MAX];
179
* struct ath_rate_priv - Rate Control priv data
181
* @probe_rate: rate we are probing at
182
* @probe_time: msec timestamp for last probe
183
* @hw_maxretry_pktcnt: num of packets since we got HW max retry error
184
* @max_valid_rate: maximum number of valid rate
185
* @per_down_time: msec timestamp for last PER down step
186
* @valid_phy_ratecnt: valid rate count
187
* @rate_max_phy: phy index for the max rate
188
* @per: PER for every valid rate in %
189
* @probe_interval: interval for ratectrl to probe for other rates
190
* @prev_data_rix: rate idx of last data frame
191
* @ht_cap: HT capabilities
192
* @neg_rates: Negotatied rates
193
* @neg_ht_rates: Negotiated HT rates
195
struct ath_rate_priv {
198
u8 hw_maxretry_pktcnt;
200
u8 valid_rate_index[RATE_TABLE_SIZE];
202
u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
203
u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
205
u8 per[RATE_TABLE_SIZE];
210
u32 tx_triglevel_max;
211
struct ath_rateset neg_rates;
212
struct ath_rateset neg_ht_rates;
213
struct ath_rate_softc *asc;
216
#define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0)
217
#define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1)
218
#define ATH_TX_INFO_XRETRY (1 << 3)
219
#define ATH_TX_INFO_UNDERRUN (1 << 4)
221
enum ath9k_internal_frame_type {
222
ATH9K_IFT_NOT_INTERNAL,
227
int ath_rate_control_register(void);
228
void ath_rate_control_unregister(void);