aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/rc.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath9k/rc.h')
-rw-r--r--drivers/net/wireless/ath9k/rc.h220
1 files changed, 48 insertions, 172 deletions
diff --git a/drivers/net/wireless/ath9k/rc.h b/drivers/net/wireless/ath9k/rc.h
index b95b41508b98..97c60d12e8aa 100644
--- a/drivers/net/wireless/ath9k/rc.h
+++ b/drivers/net/wireless/ath9k/rc.h
@@ -20,84 +20,24 @@
20#define RC_H 20#define RC_H
21 21
22#include "ath9k.h" 22#include "ath9k.h"
23/*
24 * Interface definitions for transmit rate control modules for the
25 * Atheros driver.
26 *
27 * A rate control module is responsible for choosing the transmit rate
28 * for each data frame. Management+control frames are always sent at
29 * a fixed rate.
30 *
31 * Only one module may be present at a time; the driver references
32 * rate control interfaces by symbol name. If multiple modules are
33 * to be supported we'll need to switch to a registration-based scheme
34 * as is currently done, for example, for authentication modules.
35 *
36 * An instance of the rate control module is attached to each device
37 * at attach time and detached when the device is destroyed. The module
38 * may associate data with each device and each node (station). Both
39 * sets of storage are opaque except for the size of the per-node storage
40 * which must be provided when the module is attached.
41 *
42 * The rate control module is notified for each state transition and
43 * station association/reassociation. Otherwise it is queried for a
44 * rate for each outgoing frame and provided status from each transmitted
45 * frame. Any ancillary processing is the responsibility of the module
46 * (e.g. if periodic processing is required then the module should setup
47 * it's own timer).
48 *
49 * In addition to the transmit rate for each frame the module must also
50 * indicate the number of attempts to make at the specified rate. If this
51 * number is != ATH_TXMAXTRY then an additional callback is made to setup
52 * additional transmit state. The rate control code is assumed to write
53 * this additional data directly to the transmit descriptor.
54 */
55 23
56struct ath_softc; 24struct ath_softc;
57 25
58#define TRUE 1 26#define ATH_RATE_MAX 30
59#define FALSE 0 27#define RATE_TABLE_SIZE 64
28#define MAX_TX_RATE_PHY 48
60 29
61#define ATH_RATE_MAX 30 30/* VALID_ALL - valid for 20/40/Legacy,
62#define MCS_SET_SIZE 128 31 * VALID - Legacy only,
32 * VALID_20 - HT 20 only,
33 * VALID_40 - HT 40 only */
63 34
64enum ieee80211_fixed_rate_mode { 35#define INVALID 0x0
65 IEEE80211_FIXED_RATE_NONE = 0, 36#define VALID 0x1
66 IEEE80211_FIXED_RATE_MCS = 1 /* HT rates */ 37#define VALID_20 0x2
67}; 38#define VALID_40 0x4
68 39#define VALID_2040 (VALID_20|VALID_40)
69/* 40#define VALID_ALL (VALID_2040|VALID)
70 * Use the hal os glue code to get ms time
71 */
72#define IEEE80211_RATE_IDX_ENTRY(val, idx) (((val&(0xff<<(idx*8)))>>(idx*8)))
73
74#define WLAN_PHY_HT_20_SS WLAN_RC_PHY_HT_20_SS
75#define WLAN_PHY_HT_20_DS WLAN_RC_PHY_HT_20_DS
76#define WLAN_PHY_HT_20_DS_HGI WLAN_RC_PHY_HT_20_DS_HGI
77#define WLAN_PHY_HT_40_SS WLAN_RC_PHY_HT_40_SS
78#define WLAN_PHY_HT_40_SS_HGI WLAN_RC_PHY_HT_40_SS_HGI
79#define WLAN_PHY_HT_40_DS WLAN_RC_PHY_HT_40_DS
80#define WLAN_PHY_HT_40_DS_HGI WLAN_RC_PHY_HT_40_DS_HGI
81
82#define WLAN_PHY_OFDM PHY_OFDM
83#define WLAN_PHY_CCK PHY_CCK
84
85#define TRUE_20 0x2
86#define TRUE_40 0x4
87#define TRUE_2040 (TRUE_20|TRUE_40)
88#define TRUE_ALL (TRUE_2040|TRUE)
89
90enum {
91 WLAN_RC_PHY_HT_20_SS = 4,
92 WLAN_RC_PHY_HT_20_DS,
93 WLAN_RC_PHY_HT_40_SS,
94 WLAN_RC_PHY_HT_40_DS,
95 WLAN_RC_PHY_HT_20_SS_HGI,
96 WLAN_RC_PHY_HT_20_DS_HGI,
97 WLAN_RC_PHY_HT_40_SS_HGI,
98 WLAN_RC_PHY_HT_40_DS_HGI,
99 WLAN_RC_PHY_MAX
100};
101 41
102#define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \ 42#define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \
103 || (_phy == WLAN_RC_PHY_HT_40_DS) \ 43 || (_phy == WLAN_RC_PHY_HT_40_DS) \
@@ -114,26 +54,22 @@ enum {
114 54
115#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS) 55#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
116 56
117/* Returns the capflag mode */
118#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \ 57#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
119 (capflag & WLAN_RC_40_FLAG) ? TRUE_40 : TRUE_20 : TRUE)) 58 (capflag & WLAN_RC_40_FLAG) ? VALID_40 : VALID_20 : VALID))
120 59
121/* Return TRUE if flag supports HT20 && client supports HT20 or 60/* Return TRUE if flag supports HT20 && client supports HT20 or
122 * return TRUE if flag supports HT40 && client supports HT40. 61 * return TRUE if flag supports HT40 && client supports HT40.
123 * This is used becos some rates overlap between HT20/HT40. 62 * This is used becos some rates overlap between HT20/HT40.
124 */ 63 */
125 64#define WLAN_RC_PHY_HT_VALID(flag, capflag) \
126#define WLAN_RC_PHY_HT_VALID(flag, capflag) (((flag & TRUE_20) && !(capflag \ 65 (((flag & VALID_20) && !(capflag & WLAN_RC_40_FLAG)) || \
127 & WLAN_RC_40_FLAG)) || ((flag & TRUE_40) && \ 66 ((flag & VALID_40) && (capflag & WLAN_RC_40_FLAG)))
128 (capflag & WLAN_RC_40_FLAG)))
129 67
130#define WLAN_RC_DS_FLAG (0x01) 68#define WLAN_RC_DS_FLAG (0x01)
131#define WLAN_RC_40_FLAG (0x02) 69#define WLAN_RC_40_FLAG (0x02)
132#define WLAN_RC_SGI_FLAG (0x04) 70#define WLAN_RC_SGI_FLAG (0x04)
133#define WLAN_RC_HT_FLAG (0x08) 71#define WLAN_RC_HT_FLAG (0x08)
134 72
135#define RATE_TABLE_SIZE 64
136
137/** 73/**
138 * struct ath_rate_table - Rate Control table 74 * struct ath_rate_table - Rate Control table
139 * @valid: valid for use in rate control 75 * @valid: valid for use in rate control
@@ -150,10 +86,11 @@ enum {
150 * @max_4ms_framelen: maximum frame length(bytes) for tx duration 86 * @max_4ms_framelen: maximum frame length(bytes) for tx duration
151 * @probe_interval: interval for rate control to probe for other rates 87 * @probe_interval: interval for rate control to probe for other rates
152 * @rssi_reduce_interval: interval for rate control to reduce rssi 88 * @rssi_reduce_interval: interval for rate control to reduce rssi
153 * @initial_ratemax: initial ratemax value used in ath_rc_sib_update() 89 * @initial_ratemax: initial ratemax value
154 */ 90 */
155struct ath_rate_table { 91struct ath_rate_table {
156 int rate_cnt; 92 int rate_cnt;
93 u8 rateCodeToIndex[256];
157 struct { 94 struct {
158 int valid; 95 int valid;
159 int valid_single_stream; 96 int valid_single_stream;
@@ -171,42 +108,26 @@ struct ath_rate_table {
171 u8 sgi_index; 108 u8 sgi_index;
172 u8 ht_index; 109 u8 ht_index;
173 u32 max_4ms_framelen; 110 u32 max_4ms_framelen;
111 u16 lpAckDuration;
112 u16 spAckDuration;
174 } info[RATE_TABLE_SIZE]; 113 } info[RATE_TABLE_SIZE];
175 u32 probe_interval; 114 u32 probe_interval;
176 u32 rssi_reduce_interval; 115 u32 rssi_reduce_interval;
177 u8 initial_ratemax; 116 u8 initial_ratemax;
178}; 117};
179 118
180#define ATH_RC_PROBE_ALLOWED 0x00000001
181#define ATH_RC_MINRATE_LASTRATE 0x00000002
182
183struct ath_rc_series {
184 u8 rix;
185 u8 tries;
186 u8 flags;
187 u32 max_4ms_framelen;
188};
189
190/* rcs_flags definition */
191#define ATH_RC_DS_FLAG 0x01
192#define ATH_RC_CW40_FLAG 0x02 /* CW 40 */
193#define ATH_RC_SGI_FLAG 0x04 /* Short Guard Interval */
194#define ATH_RC_HT_FLAG 0x08 /* HT */
195#define ATH_RC_RTSCTS_FLAG 0x10 /* RTS-CTS */
196
197/*
198 * State structures for new rate adaptation code
199 */
200#define MAX_TX_RATE_TBL 64
201#define MAX_TX_RATE_PHY 48
202
203struct ath_tx_ratectrl_state { 119struct ath_tx_ratectrl_state {
204 int8_t rssi_thres; /* required rssi for this rate (dB) */ 120 int8_t rssi_thres; /* required rssi for this rate (dB) */
205 u8 per; /* recent estimate of packet error rate (%) */ 121 u8 per; /* recent estimate of packet error rate (%) */
206}; 122};
207 123
124struct ath_rateset {
125 u8 rs_nrates;
126 u8 rs_rates[ATH_RATE_MAX];
127};
128
208/** 129/**
209 * struct ath_tx_ratectrl - TX Rate control Information 130 * struct ath_rate_priv - Rate Control priv data
210 * @state: RC state 131 * @state: RC state
211 * @rssi_last: last ACK rssi 132 * @rssi_last: last ACK rssi
212 * @rssi_last_lookup: last ACK rssi used for lookup 133 * @rssi_last_lookup: last ACK rssi used for lookup
@@ -225,9 +146,13 @@ struct ath_tx_ratectrl_state {
225 * @valid_phy_ratecnt: valid rate count 146 * @valid_phy_ratecnt: valid rate count
226 * @rate_max_phy: phy index for the max rate 147 * @rate_max_phy: phy index for the max rate
227 * @probe_interval: interval for ratectrl to probe for other rates 148 * @probe_interval: interval for ratectrl to probe for other rates
149 * @prev_data_rix: rate idx of last data frame
150 * @ht_cap: HT capabilities
151 * @single_stream: When TRUE, only single TX stream possible
152 * @neg_rates: Negotatied rates
153 * @neg_ht_rates: Negotiated HT rates
228 */ 154 */
229struct ath_tx_ratectrl { 155struct ath_rate_priv {
230 struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL];
231 int8_t rssi_last; 156 int8_t rssi_last;
232 int8_t rssi_last_lookup; 157 int8_t rssi_last_lookup;
233 int8_t rssi_last_prev; 158 int8_t rssi_last_prev;
@@ -237,89 +162,40 @@ struct ath_tx_ratectrl {
237 int32_t rssi_sum; 162 int32_t rssi_sum;
238 u8 rate_table_size; 163 u8 rate_table_size;
239 u8 probe_rate; 164 u8 probe_rate;
240 u32 rssi_time;
241 u32 rssi_down_time;
242 u32 probe_time;
243 u8 hw_maxretry_pktcnt; 165 u8 hw_maxretry_pktcnt;
244 u8 max_valid_rate; 166 u8 max_valid_rate;
245 u8 valid_rate_index[MAX_TX_RATE_TBL]; 167 u8 valid_rate_index[RATE_TABLE_SIZE];
246 u32 per_down_time; 168 u8 ht_cap;
247 169 u8 single_stream;
248 /* 11n state */
249 u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; 170 u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
250 u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; 171 u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
251 u8 rc_phy_mode; 172 u8 rc_phy_mode;
252 u8 rate_max_phy; 173 u8 rate_max_phy;
174 u32 rssi_time;
175 u32 rssi_down_time;
176 u32 probe_time;
177 u32 per_down_time;
253 u32 probe_interval; 178 u32 probe_interval;
254};
255
256struct ath_rateset {
257 u8 rs_nrates;
258 u8 rs_rates[ATH_RATE_MAX];
259};
260
261/* per-device state */
262struct ath_rate_softc {
263 /* phy tables that contain rate control data */
264 const void *hw_rate_table[ATH9K_MODE_MAX];
265
266 /* -1 or index of fixed rate */
267 int fixedrix;
268};
269
270/* per-node state */
271struct ath_rate_node {
272 struct ath_tx_ratectrl tx_ratectrl;
273
274 /* rate idx of last data frame */
275 u32 prev_data_rix; 179 u32 prev_data_rix;
276 180 u32 tx_triglevel_max;
277 /* ht capabilities */ 181 struct ath_tx_ratectrl_state state[RATE_TABLE_SIZE];
278 u8 ht_cap;
279
280 /* When TRUE, only single stream Tx possible */
281 u8 single_stream;
282
283 /* Negotiated rates */
284 struct ath_rateset neg_rates; 182 struct ath_rateset neg_rates;
285
286 /* Negotiated HT rates */
287 struct ath_rateset neg_ht_rates; 183 struct ath_rateset neg_ht_rates;
288
289 struct ath_rate_softc *asc; 184 struct ath_rate_softc *asc;
290 struct ath_vap *avp;
291}; 185};
292 186
293/* Driver data of ieee80211_tx_info */
294struct ath_tx_info_priv { 187struct ath_tx_info_priv {
295 struct ath_rc_series rcs[4];
296 struct ath_tx_status tx; 188 struct ath_tx_status tx;
297 int n_frames; 189 int n_frames;
298 int n_bad_frames; 190 int n_bad_frames;
299 u8 min_rate; 191 bool update_rc;
300}; 192};
301 193
302/* 194#define ATH_TX_INFO_PRIV(tx_info) \
303 * Attach/detach a rate control module. 195 ((struct ath_tx_info_priv *)((tx_info)->rate_driver_data[0]))
304 */
305struct ath_rate_softc *ath_rate_attach(struct ath_hal *ah);
306void ath_rate_detach(struct ath_rate_softc *asc);
307
308/*
309 * Update/reset rate control state for 802.11 state transitions.
310 * Important mostly as the analog to ath_rate_newassoc when operating
311 * in station mode.
312 */
313void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv);
314void ath_rate_newstate(struct ath_softc *sc, struct ath_vap *avp);
315
316/*
317 * Return rate index for given Dot11 Rate.
318 */
319u8 ath_rate_findrateix(struct ath_softc *sc,
320 u8 dot11_rate);
321 196
322/* Routines to register/unregister rate control algorithm */ 197void ath_rate_attach(struct ath_softc *sc);
198u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate);
323int ath_rate_control_register(void); 199int ath_rate_control_register(void);
324void ath_rate_control_unregister(void); 200void ath_rate_control_unregister(void);
325 201