aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/rc.h
diff options
context:
space:
mode:
authorSujith <Sujith.Manoharan@atheros.com>2008-11-17 22:38:13 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-11-26 09:47:31 -0500
commit46d14a58ffb42702e4c1b8bb88cfa05414617f4c (patch)
treebe81f5cf58d58e584828de6699445c499332f06a /drivers/net/wireless/ath9k/rc.h
parente63835b0f4d8545942fd41b3ca32bbf71bd73e4b (diff)
ath9k: General code scrub
Replace TRUE/FALSE macros with VALID/INVALID macros. Follow a consistent variable convention. Remove unnecessary comments. Add all RC phy macros into a single enum. Merge functions into reasonably sized entities. Signed-off-by: Sujith <Sujith.Manoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/rc.h')
-rw-r--r--drivers/net/wireless/ath9k/rc.h110
1 files changed, 22 insertions, 88 deletions
diff --git a/drivers/net/wireless/ath9k/rc.h b/drivers/net/wireless/ath9k/rc.h
index c1e370c7c681..dff4b7ade3df 100644
--- a/drivers/net/wireless/ath9k/rc.h
+++ b/drivers/net/wireless/ath9k/rc.h
@@ -20,73 +20,19 @@
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
60 28#define MAX_TX_RATE_PHY 48
61#define ATH_RATE_MAX 30
62
63#define WLAN_PHY_HT_20_SS WLAN_RC_PHY_HT_20_SS
64#define WLAN_PHY_HT_20_DS WLAN_RC_PHY_HT_20_DS
65#define WLAN_PHY_HT_20_DS_HGI WLAN_RC_PHY_HT_20_DS_HGI
66#define WLAN_PHY_HT_40_SS WLAN_RC_PHY_HT_40_SS
67#define WLAN_PHY_HT_40_SS_HGI WLAN_RC_PHY_HT_40_SS_HGI
68#define WLAN_PHY_HT_40_DS WLAN_RC_PHY_HT_40_DS
69#define WLAN_PHY_HT_40_DS_HGI WLAN_RC_PHY_HT_40_DS_HGI
70
71#define WLAN_PHY_OFDM PHY_OFDM
72#define WLAN_PHY_CCK PHY_CCK
73 29
74#define TRUE_20 0x2 30#define INVALID 0x0
75#define TRUE_40 0x4 31#define VALID 0x1
76#define TRUE_2040 (TRUE_20|TRUE_40) 32#define VALID_20 0x2
77#define TRUE_ALL (TRUE_2040|TRUE) 33#define VALID_40 0x4
78 34#define VALID_2040 (VALID_20|VALID_40)
79enum { 35#define VALID_ALL (VALID_2040|VALID)
80 WLAN_RC_PHY_HT_20_SS = 4,
81 WLAN_RC_PHY_HT_20_DS,
82 WLAN_RC_PHY_HT_40_SS,
83 WLAN_RC_PHY_HT_40_DS,
84 WLAN_RC_PHY_HT_20_SS_HGI,
85 WLAN_RC_PHY_HT_20_DS_HGI,
86 WLAN_RC_PHY_HT_40_SS_HGI,
87 WLAN_RC_PHY_HT_40_DS_HGI,
88 WLAN_RC_PHY_MAX
89};
90 36
91#define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \ 37#define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \
92 || (_phy == WLAN_RC_PHY_HT_40_DS) \ 38 || (_phy == WLAN_RC_PHY_HT_40_DS) \
@@ -103,26 +49,22 @@ enum {
103 49
104#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS) 50#define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS)
105 51
106/* Returns the capflag mode */
107#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \ 52#define WLAN_RC_CAP_MODE(capflag) (((capflag & WLAN_RC_HT_FLAG) ? \
108 (capflag & WLAN_RC_40_FLAG) ? TRUE_40 : TRUE_20 : TRUE)) 53 (capflag & WLAN_RC_40_FLAG) ? VALID_40 : VALID_20 : VALID))
109 54
110/* Return TRUE if flag supports HT20 && client supports HT20 or 55/* Return TRUE if flag supports HT20 && client supports HT20 or
111 * return TRUE if flag supports HT40 && client supports HT40. 56 * return TRUE if flag supports HT40 && client supports HT40.
112 * This is used becos some rates overlap between HT20/HT40. 57 * This is used becos some rates overlap between HT20/HT40.
113 */ 58 */
114 59#define WLAN_RC_PHY_HT_VALID(flag, capflag) \
115#define WLAN_RC_PHY_HT_VALID(flag, capflag) (((flag & TRUE_20) && !(capflag \ 60 (((flag & VALID_20) && !(capflag & WLAN_RC_40_FLAG)) || \
116 & WLAN_RC_40_FLAG)) || ((flag & TRUE_40) && \ 61 ((flag & VALID_40) && (capflag & WLAN_RC_40_FLAG)))
117 (capflag & WLAN_RC_40_FLAG)))
118 62
119#define WLAN_RC_DS_FLAG (0x01) 63#define WLAN_RC_DS_FLAG (0x01)
120#define WLAN_RC_40_FLAG (0x02) 64#define WLAN_RC_40_FLAG (0x02)
121#define WLAN_RC_SGI_FLAG (0x04) 65#define WLAN_RC_SGI_FLAG (0x04)
122#define WLAN_RC_HT_FLAG (0x08) 66#define WLAN_RC_HT_FLAG (0x08)
123 67
124#define RATE_TABLE_SIZE 64
125
126/** 68/**
127 * struct ath_rate_table - Rate Control table 69 * struct ath_rate_table - Rate Control table
128 * @valid: valid for use in rate control 70 * @valid: valid for use in rate control
@@ -139,7 +81,7 @@ enum {
139 * @max_4ms_framelen: maximum frame length(bytes) for tx duration 81 * @max_4ms_framelen: maximum frame length(bytes) for tx duration
140 * @probe_interval: interval for rate control to probe for other rates 82 * @probe_interval: interval for rate control to probe for other rates
141 * @rssi_reduce_interval: interval for rate control to reduce rssi 83 * @rssi_reduce_interval: interval for rate control to reduce rssi
142 * @initial_ratemax: initial ratemax value used in ath_rc_sib_update() 84 * @initial_ratemax: initial ratemax value
143 */ 85 */
144struct ath_rate_table { 86struct ath_rate_table {
145 int rate_cnt; 87 int rate_cnt;
@@ -169,15 +111,6 @@ struct ath_rate_table {
169 u8 initial_ratemax; 111 u8 initial_ratemax;
170}; 112};
171 113
172#define ATH_RC_PROBE_ALLOWED 0x00000001
173#define ATH_RC_MINRATE_LASTRATE 0x00000002
174
175/*
176 * State structures for new rate adaptation code
177 */
178#define MAX_TX_RATE_TBL 64
179#define MAX_TX_RATE_PHY 48
180
181struct ath_tx_ratectrl_state { 114struct ath_tx_ratectrl_state {
182 int8_t rssi_thres; /* required rssi for this rate (dB) */ 115 int8_t rssi_thres; /* required rssi for this rate (dB) */
183 u8 per; /* recent estimate of packet error rate (%) */ 116 u8 per; /* recent estimate of packet error rate (%) */
@@ -189,7 +122,7 @@ struct ath_rateset {
189}; 122};
190 123
191/** 124/**
192 * struct ath_rate_node - Rate Control priv data 125 * struct ath_rate_priv - Rate Control priv data
193 * @state: RC state 126 * @state: RC state
194 * @rssi_last: last ACK rssi 127 * @rssi_last: last ACK rssi
195 * @rssi_last_lookup: last ACK rssi used for lookup 128 * @rssi_last_lookup: last ACK rssi used for lookup
@@ -214,9 +147,7 @@ struct ath_rateset {
214 * @neg_rates: Negotatied rates 147 * @neg_rates: Negotatied rates
215 * @neg_ht_rates: Negotiated HT rates 148 * @neg_ht_rates: Negotiated HT rates
216 */ 149 */
217 150struct ath_rate_priv {
218/* per-node state */
219struct ath_rate_node {
220 int8_t rssi_last; 151 int8_t rssi_last;
221 int8_t rssi_last_lookup; 152 int8_t rssi_last_lookup;
222 int8_t rssi_last_prev; 153 int8_t rssi_last_prev;
@@ -228,11 +159,11 @@ struct ath_rate_node {
228 u8 probe_rate; 159 u8 probe_rate;
229 u8 hw_maxretry_pktcnt; 160 u8 hw_maxretry_pktcnt;
230 u8 max_valid_rate; 161 u8 max_valid_rate;
231 u8 valid_rate_index[MAX_TX_RATE_TBL]; 162 u8 valid_rate_index[RATE_TABLE_SIZE];
232 u8 ht_cap; 163 u8 ht_cap;
233 u8 single_stream; 164 u8 single_stream;
234 u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; 165 u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX];
235 u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; 166 u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][RATE_TABLE_SIZE];
236 u8 rc_phy_mode; 167 u8 rc_phy_mode;
237 u8 rate_max_phy; 168 u8 rate_max_phy;
238 u32 rssi_time; 169 u32 rssi_time;
@@ -242,7 +173,7 @@ struct ath_rate_node {
242 u32 probe_interval; 173 u32 probe_interval;
243 u32 prev_data_rix; 174 u32 prev_data_rix;
244 u32 tx_triglevel_max; 175 u32 tx_triglevel_max;
245 struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL]; 176 struct ath_tx_ratectrl_state state[RATE_TABLE_SIZE];
246 struct ath_rateset neg_rates; 177 struct ath_rateset neg_rates;
247 struct ath_rateset neg_ht_rates; 178 struct ath_rateset neg_ht_rates;
248 struct ath_rate_softc *asc; 179 struct ath_rate_softc *asc;
@@ -254,6 +185,9 @@ struct ath_tx_info_priv {
254 int n_bad_frames; 185 int n_bad_frames;
255}; 186};
256 187
188#define ATH_TX_INFO_PRIV(tx_info) \
189 ((struct ath_tx_info_priv *)((tx_info)->rate_driver_data[0]))
190
257void ath_rate_attach(struct ath_softc *sc); 191void ath_rate_attach(struct ath_softc *sc);
258u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate); 192u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate);
259int ath_rate_control_register(void); 193int ath_rate_control_register(void);