diff options
-rw-r--r-- | drivers/net/wireless/ath9k/rc.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/ath9k/rc.h | 222 |
2 files changed, 125 insertions, 115 deletions
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c index 1dd7c71daf0a..390019ed398e 100644 --- a/drivers/net/wireless/ath9k/rc.c +++ b/drivers/net/wireless/ath9k/rc.c | |||
@@ -1141,14 +1141,14 @@ static void ath_rc_ratefind(struct ath_softc *sc, | |||
1141 | /* | 1141 | /* |
1142 | * Return the Tx rate series. | 1142 | * Return the Tx rate series. |
1143 | */ | 1143 | */ |
1144 | void ath_rate_findrate(struct ath_softc *sc, | 1144 | static void ath_rate_findrate(struct ath_softc *sc, |
1145 | struct ath_rate_node *ath_rc_priv, | 1145 | struct ath_rate_node *ath_rc_priv, |
1146 | int num_tries, | 1146 | int num_tries, |
1147 | int num_rates, | 1147 | int num_rates, |
1148 | unsigned int rcflag, | 1148 | unsigned int rcflag, |
1149 | struct ath_rc_series series[], | 1149 | struct ath_rc_series series[], |
1150 | int *is_probe, | 1150 | int *is_probe, |
1151 | int is_retry) | 1151 | int is_retry) |
1152 | { | 1152 | { |
1153 | struct ath_vap *avp = ath_rc_priv->avp; | 1153 | struct ath_vap *avp = ath_rc_priv->avp; |
1154 | 1154 | ||
@@ -1942,7 +1942,7 @@ static void ath_get_rate(void *priv, struct net_device *dev, | |||
1942 | struct ath_rate_node *ath_rc_priv; | 1942 | struct ath_rate_node *ath_rc_priv; |
1943 | struct ath_node *an; | 1943 | struct ath_node *an; |
1944 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 1944 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1945 | int is_probe, chk, ret; | 1945 | int is_probe = FALSE, chk, ret; |
1946 | s8 lowest_idx; | 1946 | s8 lowest_idx; |
1947 | __le16 fc = hdr->frame_control; | 1947 | __le16 fc = hdr->frame_control; |
1948 | u8 *qc, tid; | 1948 | u8 *qc, tid; |
diff --git a/drivers/net/wireless/ath9k/rc.h b/drivers/net/wireless/ath9k/rc.h index 71aef9c75232..b95b41508b98 100644 --- a/drivers/net/wireless/ath9k/rc.h +++ b/drivers/net/wireless/ath9k/rc.h | |||
@@ -71,9 +71,6 @@ enum ieee80211_fixed_rate_mode { | |||
71 | */ | 71 | */ |
72 | #define IEEE80211_RATE_IDX_ENTRY(val, idx) (((val&(0xff<<(idx*8)))>>(idx*8))) | 72 | #define IEEE80211_RATE_IDX_ENTRY(val, idx) (((val&(0xff<<(idx*8)))>>(idx*8))) |
73 | 73 | ||
74 | #define SHORT_PRE 1 | ||
75 | #define LONG_PRE 0 | ||
76 | |||
77 | #define WLAN_PHY_HT_20_SS WLAN_RC_PHY_HT_20_SS | 74 | #define WLAN_PHY_HT_20_SS WLAN_RC_PHY_HT_20_SS |
78 | #define WLAN_PHY_HT_20_DS WLAN_RC_PHY_HT_20_DS | 75 | #define WLAN_PHY_HT_20_DS WLAN_RC_PHY_HT_20_DS |
79 | #define WLAN_PHY_HT_20_DS_HGI WLAN_RC_PHY_HT_20_DS_HGI | 76 | #define WLAN_PHY_HT_20_DS_HGI WLAN_RC_PHY_HT_20_DS_HGI |
@@ -102,18 +99,18 @@ enum { | |||
102 | WLAN_RC_PHY_MAX | 99 | WLAN_RC_PHY_MAX |
103 | }; | 100 | }; |
104 | 101 | ||
105 | #define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \ | 102 | #define WLAN_RC_PHY_DS(_phy) ((_phy == WLAN_RC_PHY_HT_20_DS) \ |
106 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ | 103 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ |
107 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ | 104 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ |
108 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) | 105 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
109 | #define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \ | 106 | #define WLAN_RC_PHY_40(_phy) ((_phy == WLAN_RC_PHY_HT_40_SS) \ |
110 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ | 107 | || (_phy == WLAN_RC_PHY_HT_40_DS) \ |
111 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ | 108 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ |
112 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) | 109 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
113 | #define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \ | 110 | #define WLAN_RC_PHY_SGI(_phy) ((_phy == WLAN_RC_PHY_HT_20_SS_HGI) \ |
114 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ | 111 | || (_phy == WLAN_RC_PHY_HT_20_DS_HGI) \ |
115 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ | 112 | || (_phy == WLAN_RC_PHY_HT_40_SS_HGI) \ |
116 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) | 113 | || (_phy == WLAN_RC_PHY_HT_40_DS_HGI)) |
117 | 114 | ||
118 | #define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS) | 115 | #define WLAN_RC_PHY_HT(_phy) (_phy >= WLAN_RC_PHY_HT_20_SS) |
119 | 116 | ||
@@ -135,56 +132,59 @@ enum { | |||
135 | #define WLAN_RC_SGI_FLAG (0x04) | 132 | #define WLAN_RC_SGI_FLAG (0x04) |
136 | #define WLAN_RC_HT_FLAG (0x08) | 133 | #define WLAN_RC_HT_FLAG (0x08) |
137 | 134 | ||
138 | /* Index into the rate table */ | ||
139 | #define INIT_RATE_MAX_20 23 | ||
140 | #define INIT_RATE_MAX_40 40 | ||
141 | |||
142 | #define RATE_TABLE_SIZE 64 | 135 | #define RATE_TABLE_SIZE 64 |
143 | 136 | ||
144 | /* XXX: Convert to kdoc */ | 137 | /** |
138 | * struct ath_rate_table - Rate Control table | ||
139 | * @valid: valid for use in rate control | ||
140 | * @valid_single_stream: valid for use in rate control for | ||
141 | * single stream operation | ||
142 | * @phy: CCK/OFDM | ||
143 | * @ratekbps: rate in Kbits per second | ||
144 | * @user_ratekbps: user rate in Kbits per second | ||
145 | * @ratecode: rate that goes into HW descriptors | ||
146 | * @short_preamble: Mask for enabling short preamble in ratecode for CCK | ||
147 | * @dot11rate: value that goes into supported | ||
148 | * rates info element of MLME | ||
149 | * @ctrl_rate: Index of next lower basic rate, used for duration computation | ||
150 | * @max_4ms_framelen: maximum frame length(bytes) for tx duration | ||
151 | * @probe_interval: interval for rate control to probe for other rates | ||
152 | * @rssi_reduce_interval: interval for rate control to reduce rssi | ||
153 | * @initial_ratemax: initial ratemax value used in ath_rc_sib_update() | ||
154 | */ | ||
145 | struct ath_rate_table { | 155 | struct ath_rate_table { |
146 | int rate_cnt; | 156 | int rate_cnt; |
147 | struct { | 157 | struct { |
148 | int valid; /* Valid for use in rate control */ | 158 | int valid; |
149 | int valid_single_stream;/* Valid for use in rate control | 159 | int valid_single_stream; |
150 | for single stream operation */ | 160 | u8 phy; |
151 | u8 phy; /* CCK/OFDM/TURBO/XR */ | 161 | u32 ratekbps; |
152 | u32 ratekbps; /* Rate in Kbits per second */ | 162 | u32 user_ratekbps; |
153 | u32 user_ratekbps; /* User rate in KBits per second */ | 163 | u8 ratecode; |
154 | u8 ratecode; /* rate that goes into | 164 | u8 short_preamble; |
155 | hw descriptors */ | 165 | u8 dot11rate; |
156 | u8 short_preamble; /* Mask for enabling short preamble | 166 | u8 ctrl_rate; |
157 | in rate code for CCK */ | 167 | int8_t rssi_ack_validmin; |
158 | u8 dot11rate; /* Value that goes into supported | 168 | int8_t rssi_ack_deltamin; |
159 | rates info element of MLME */ | 169 | u8 base_index; |
160 | u8 ctrl_rate; /* Index of next lower basic rate, | 170 | u8 cw40index; |
161 | used for duration computation */ | 171 | u8 sgi_index; |
162 | int8_t rssi_ack_validmin; /* Rate control related */ | 172 | u8 ht_index; |
163 | int8_t rssi_ack_deltamin; /* Rate control related */ | 173 | u32 max_4ms_framelen; |
164 | u8 base_index; /* base rate index */ | ||
165 | u8 cw40index; /* 40cap rate index */ | ||
166 | u8 sgi_index; /* shortgi rate index */ | ||
167 | u8 ht_index; /* shortgi rate index */ | ||
168 | u32 max_4ms_framelen; /* Maximum frame length(bytes) | ||
169 | for 4ms tx duration */ | ||
170 | } info[RATE_TABLE_SIZE]; | 174 | } info[RATE_TABLE_SIZE]; |
171 | u32 probe_interval; /* interval for ratectrl to | 175 | u32 probe_interval; |
172 | probe for other rates */ | 176 | u32 rssi_reduce_interval; |
173 | u32 rssi_reduce_interval; /* interval for ratectrl | 177 | u8 initial_ratemax; |
174 | to reduce RSSI */ | ||
175 | u8 initial_ratemax; /* the initial ratemax value used | ||
176 | in ath_rc_sib_update() */ | ||
177 | }; | 178 | }; |
178 | 179 | ||
179 | #define ATH_RC_PROBE_ALLOWED 0x00000001 | 180 | #define ATH_RC_PROBE_ALLOWED 0x00000001 |
180 | #define ATH_RC_MINRATE_LASTRATE 0x00000002 | 181 | #define ATH_RC_MINRATE_LASTRATE 0x00000002 |
181 | #define ATH_RC_SHORT_PREAMBLE 0x00000004 | ||
182 | 182 | ||
183 | struct ath_rc_series { | 183 | struct ath_rc_series { |
184 | u8 rix; | 184 | u8 rix; |
185 | u8 tries; | 185 | u8 tries; |
186 | u8 flags; | 186 | u8 flags; |
187 | u32 max_4ms_framelen; | 187 | u32 max_4ms_framelen; |
188 | }; | 188 | }; |
189 | 189 | ||
190 | /* rcs_flags definition */ | 190 | /* rcs_flags definition */ |
@@ -201,42 +201,56 @@ struct ath_rc_series { | |||
201 | #define MAX_TX_RATE_PHY 48 | 201 | #define MAX_TX_RATE_PHY 48 |
202 | 202 | ||
203 | struct ath_tx_ratectrl_state { | 203 | struct ath_tx_ratectrl_state { |
204 | int8_t rssi_thres; /* required rssi for this rate (dB) */ | 204 | int8_t rssi_thres; /* required rssi for this rate (dB) */ |
205 | u8 per; /* recent estimate of packet error rate (%) */ | 205 | u8 per; /* recent estimate of packet error rate (%) */ |
206 | }; | 206 | }; |
207 | 207 | ||
208 | /** | ||
209 | * struct ath_tx_ratectrl - TX Rate control Information | ||
210 | * @state: RC state | ||
211 | * @rssi_last: last ACK rssi | ||
212 | * @rssi_last_lookup: last ACK rssi used for lookup | ||
213 | * @rssi_last_prev: previous last ACK rssi | ||
214 | * @rssi_last_prev2: 2nd previous last ACK rssi | ||
215 | * @rssi_sum_cnt: count of rssi_sum for averaging | ||
216 | * @rssi_sum_rate: rate that we are averaging | ||
217 | * @rssi_sum: running sum of rssi for averaging | ||
218 | * @probe_rate: rate we are probing at | ||
219 | * @rssi_time: msec timestamp for last ack rssi | ||
220 | * @rssi_down_time: msec timestamp for last down step | ||
221 | * @probe_time: msec timestamp for last probe | ||
222 | * @hw_maxretry_pktcnt: num of packets since we got HW max retry error | ||
223 | * @max_valid_rate: maximum number of valid rate | ||
224 | * @per_down_time: msec timestamp for last PER down step | ||
225 | * @valid_phy_ratecnt: valid rate count | ||
226 | * @rate_max_phy: phy index for the max rate | ||
227 | * @probe_interval: interval for ratectrl to probe for other rates | ||
228 | */ | ||
208 | struct ath_tx_ratectrl { | 229 | struct ath_tx_ratectrl { |
209 | struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL]; /* state */ | 230 | struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL]; |
210 | int8_t rssi_last; /* last ack rssi */ | 231 | int8_t rssi_last; |
211 | int8_t rssi_last_lookup; /* last ack rssi used for lookup */ | 232 | int8_t rssi_last_lookup; |
212 | int8_t rssi_last_prev; /* previous last ack rssi */ | 233 | int8_t rssi_last_prev; |
213 | int8_t rssi_last_prev2; /* 2nd previous last ack rssi */ | 234 | int8_t rssi_last_prev2; |
214 | int32_t rssi_sum_cnt; /* count of rssi_sum for averaging */ | 235 | int32_t rssi_sum_cnt; |
215 | int32_t rssi_sum_rate; /* rate that we are averaging */ | 236 | int32_t rssi_sum_rate; |
216 | int32_t rssi_sum; /* running sum of rssi for averaging */ | 237 | int32_t rssi_sum; |
217 | u32 valid_txrate_mask; /* mask of valid rates */ | 238 | u8 rate_table_size; |
218 | u8 rate_table_size; /* rate table size */ | 239 | u8 probe_rate; |
219 | u8 rate_max; /* max rate that has recently worked */ | 240 | u32 rssi_time; |
220 | u8 probe_rate; /* rate we are probing at */ | 241 | u32 rssi_down_time; |
221 | u32 rssi_time; /* msec timestamp for last ack rssi */ | 242 | u32 probe_time; |
222 | u32 rssi_down_time; /* msec timestamp for last down step */ | 243 | u8 hw_maxretry_pktcnt; |
223 | u32 probe_time; /* msec timestamp for last probe */ | 244 | u8 max_valid_rate; |
224 | u8 hw_maxretry_pktcnt; /* num packets since we got | 245 | u8 valid_rate_index[MAX_TX_RATE_TBL]; |
225 | HW max retry error */ | 246 | u32 per_down_time; |
226 | u8 max_valid_rate; /* maximum number of valid rate */ | ||
227 | u8 valid_rate_index[MAX_TX_RATE_TBL]; /* valid rate index */ | ||
228 | u32 per_down_time; /* msec timstamp for last | ||
229 | PER down step */ | ||
230 | 247 | ||
231 | /* 11n state */ | 248 | /* 11n state */ |
232 | u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; /* valid rate count */ | 249 | u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; |
233 | u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; | 250 | u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; |
234 | u8 rc_phy_mode; | 251 | u8 rc_phy_mode; |
235 | u8 rate_max_phy; /* Phy index for the max rate */ | 252 | u8 rate_max_phy; |
236 | u32 rate_max_lastused; /* msec timstamp of when we | 253 | u32 probe_interval; |
237 | last used rateMaxPhy */ | ||
238 | u32 probe_interval; /* interval for ratectrl to probe | ||
239 | for other rates */ | ||
240 | }; | 254 | }; |
241 | 255 | ||
242 | struct ath_rateset { | 256 | struct ath_rateset { |
@@ -248,29 +262,32 @@ struct ath_rateset { | |||
248 | struct ath_rate_softc { | 262 | struct ath_rate_softc { |
249 | /* phy tables that contain rate control data */ | 263 | /* phy tables that contain rate control data */ |
250 | const void *hw_rate_table[ATH9K_MODE_MAX]; | 264 | const void *hw_rate_table[ATH9K_MODE_MAX]; |
251 | int fixedrix; /* -1 or index of fixed rate */ | 265 | |
266 | /* -1 or index of fixed rate */ | ||
267 | int fixedrix; | ||
252 | }; | 268 | }; |
253 | 269 | ||
254 | /* per-node state */ | 270 | /* per-node state */ |
255 | struct ath_rate_node { | 271 | struct ath_rate_node { |
256 | struct ath_tx_ratectrl tx_ratectrl; /* rate control state proper */ | 272 | struct ath_tx_ratectrl tx_ratectrl; |
257 | u32 prev_data_rix; /* rate idx of last data frame */ | ||
258 | 273 | ||
259 | /* map of rate ix -> negotiated rate set ix */ | 274 | /* rate idx of last data frame */ |
260 | u8 rixmap[MAX_TX_RATE_TBL]; | 275 | u32 prev_data_rix; |
261 | 276 | ||
262 | /* map of ht rate ix -> negotiated rate set ix */ | 277 | /* ht capabilities */ |
263 | u8 ht_rixmap[MAX_TX_RATE_TBL]; | 278 | u8 ht_cap; |
264 | 279 | ||
265 | u8 ht_cap; /* ht capabilities */ | 280 | /* When TRUE, only single stream Tx possible */ |
266 | u8 ant_tx; /* current transmit antenna */ | 281 | u8 single_stream; |
267 | 282 | ||
268 | u8 single_stream; /* When TRUE, only single | 283 | /* Negotiated rates */ |
269 | stream Tx possible */ | 284 | struct ath_rateset neg_rates; |
270 | struct ath_rateset neg_rates; /* Negotiated rates */ | 285 | |
271 | struct ath_rateset neg_ht_rates; /* Negotiated HT rates */ | 286 | /* Negotiated HT rates */ |
272 | struct ath_rate_softc *asc; /* back pointer to atheros softc */ | 287 | struct ath_rateset neg_ht_rates; |
273 | struct ath_vap *avp; /* back pointer to vap */ | 288 | |
289 | struct ath_rate_softc *asc; | ||
290 | struct ath_vap *avp; | ||
274 | }; | 291 | }; |
275 | 292 | ||
276 | /* Driver data of ieee80211_tx_info */ | 293 | /* Driver data of ieee80211_tx_info */ |
@@ -297,17 +314,10 @@ void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv); | |||
297 | void ath_rate_newstate(struct ath_softc *sc, struct ath_vap *avp); | 314 | void ath_rate_newstate(struct ath_softc *sc, struct ath_vap *avp); |
298 | 315 | ||
299 | /* | 316 | /* |
300 | * Return the tx rate series. | ||
301 | */ | ||
302 | void ath_rate_findrate(struct ath_softc *sc, struct ath_rate_node *ath_rc_priv, | ||
303 | int num_tries, int num_rates, | ||
304 | unsigned int rcflag, struct ath_rc_series[], | ||
305 | int *is_probe, int isretry); | ||
306 | /* | ||
307 | * Return rate index for given Dot11 Rate. | 317 | * Return rate index for given Dot11 Rate. |
308 | */ | 318 | */ |
309 | u8 ath_rate_findrateix(struct ath_softc *sc, | 319 | u8 ath_rate_findrateix(struct ath_softc *sc, |
310 | u8 dot11_rate); | 320 | u8 dot11_rate); |
311 | 321 | ||
312 | /* Routines to register/unregister rate control algorithm */ | 322 | /* Routines to register/unregister rate control algorithm */ |
313 | int ath_rate_control_register(void); | 323 | int ath_rate_control_register(void); |