diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-11-15 08:45:59 -0500 |
---|---|---|
committer | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-11-15 08:45:59 -0500 |
commit | e7392364fcd1004a5e495f15cf21b1e0ef874215 (patch) | |
tree | 5275a1aed29aedc11e09c6bcfff331b90f95686e /drivers/net/wireless/iwlegacy/4965-rs.c | |
parent | f02579e3a81954c8f0944c7d2a95159ee48f052d (diff) |
iwlegacy: indentions and whitespaces
Process iwlegacy source files using:
indent -npro -l500 -nhnl
indent -npro -kr -i8 -ts8 -sob -l80 -nbbo -ss -ncs -cp1 -il0 -psl
Plus manual compilation fixes.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/4965-rs.c')
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965-rs.c | 1094 |
1 files changed, 556 insertions, 538 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index f9db9df21321..3ea236157058 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c | |||
@@ -95,22 +95,23 @@ static const u8 ant_toggle_lookup[] = { | |||
95 | * | 95 | * |
96 | */ | 96 | */ |
97 | const struct il_rate_info il_rates[RATE_COUNT] = { | 97 | const struct il_rate_info il_rates[RATE_COUNT] = { |
98 | IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ | 98 | IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ |
99 | IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ | 99 | IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ |
100 | IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ | 100 | IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ |
101 | IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ | 101 | IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ |
102 | IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ | 102 | IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ |
103 | IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ | 103 | IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ |
104 | IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ | 104 | IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ |
105 | IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ | 105 | IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ |
106 | IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ | 106 | IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ |
107 | IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ | 107 | IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ |
108 | IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ | 108 | IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ |
109 | IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ | 109 | IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV), /* 54mbps */ |
110 | IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ | 110 | IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV), /* 60mbps */ |
111 | }; | 111 | }; |
112 | 112 | ||
113 | static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) | 113 | static int |
114 | il4965_hwrate_to_plcp_idx(u32 rate_n_flags) | ||
114 | { | 115 | { |
115 | int idx = 0; | 116 | int idx = 0; |
116 | 117 | ||
@@ -122,13 +123,13 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
122 | idx = idx - RATE_MIMO2_6M_PLCP; | 123 | idx = idx - RATE_MIMO2_6M_PLCP; |
123 | 124 | ||
124 | idx += IL_FIRST_OFDM_RATE; | 125 | idx += IL_FIRST_OFDM_RATE; |
125 | /* skip 9M not supported in ht*/ | 126 | /* skip 9M not supported in ht */ |
126 | if (idx >= RATE_9M_IDX) | 127 | if (idx >= RATE_9M_IDX) |
127 | idx += 1; | 128 | idx += 1; |
128 | if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) | 129 | if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) |
129 | return idx; | 130 | return idx; |
130 | 131 | ||
131 | /* legacy rate format, search for match in table */ | 132 | /* legacy rate format, search for match in table */ |
132 | } else { | 133 | } else { |
133 | for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) | 134 | for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) |
134 | if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) | 135 | if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) |
@@ -139,21 +140,22 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
139 | } | 140 | } |
140 | 141 | ||
141 | static void il4965_rs_rate_scale_perform(struct il_priv *il, | 142 | static void il4965_rs_rate_scale_perform(struct il_priv *il, |
142 | struct sk_buff *skb, | 143 | struct sk_buff *skb, |
143 | struct ieee80211_sta *sta, | 144 | struct ieee80211_sta *sta, |
144 | struct il_lq_sta *lq_sta); | 145 | struct il_lq_sta *lq_sta); |
145 | static void il4965_rs_fill_link_cmd(struct il_priv *il, | 146 | static void il4965_rs_fill_link_cmd(struct il_priv *il, |
146 | struct il_lq_sta *lq_sta, u32 rate_n_flags); | 147 | struct il_lq_sta *lq_sta, u32 rate_n_flags); |
147 | static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, | 148 | static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, |
148 | bool force_search); | 149 | bool force_search); |
149 | 150 | ||
150 | #ifdef CONFIG_MAC80211_DEBUGFS | 151 | #ifdef CONFIG_MAC80211_DEBUGFS |
151 | static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, | 152 | static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, |
152 | u32 *rate_n_flags, int idx); | 153 | u32 * rate_n_flags, int idx); |
153 | #else | 154 | #else |
154 | static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, | 155 | static void |
155 | u32 *rate_n_flags, int idx) | 156 | il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) |
156 | {} | 157 | { |
158 | } | ||
157 | #endif | 159 | #endif |
158 | 160 | ||
159 | /** | 161 | /** |
@@ -172,55 +174,56 @@ static s32 expected_tpt_legacy[RATE_COUNT] = { | |||
172 | }; | 174 | }; |
173 | 175 | ||
174 | static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { | 176 | static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { |
175 | {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ | 177 | {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ |
176 | {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ | 178 | {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ |
177 | {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ | 179 | {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ |
178 | {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ | 180 | {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ |
179 | }; | 181 | }; |
180 | 182 | ||
181 | static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { | 183 | static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { |
182 | {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ | 184 | {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ |
183 | {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ | 185 | {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ |
184 | {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ | 186 | {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ |
185 | {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ | 187 | {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ |
186 | }; | 188 | }; |
187 | 189 | ||
188 | static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { | 190 | static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { |
189 | {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ | 191 | {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ |
190 | {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ | 192 | {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ |
191 | {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ | 193 | {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ |
192 | {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ | 194 | {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI */ |
193 | }; | 195 | }; |
194 | 196 | ||
195 | static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { | 197 | static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { |
196 | {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ | 198 | {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ |
197 | {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ | 199 | {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ |
198 | {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ | 200 | {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ |
199 | {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ | 201 | {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ |
200 | }; | 202 | }; |
201 | 203 | ||
202 | /* mbps, mcs */ | 204 | /* mbps, mcs */ |
203 | static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { | 205 | static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { |
204 | { "1", "BPSK DSSS"}, | 206 | {"1", "BPSK DSSS"}, |
205 | { "2", "QPSK DSSS"}, | 207 | {"2", "QPSK DSSS"}, |
206 | {"5.5", "BPSK CCK"}, | 208 | {"5.5", "BPSK CCK"}, |
207 | { "11", "QPSK CCK"}, | 209 | {"11", "QPSK CCK"}, |
208 | { "6", "BPSK 1/2"}, | 210 | {"6", "BPSK 1/2"}, |
209 | { "9", "BPSK 1/2"}, | 211 | {"9", "BPSK 1/2"}, |
210 | { "12", "QPSK 1/2"}, | 212 | {"12", "QPSK 1/2"}, |
211 | { "18", "QPSK 3/4"}, | 213 | {"18", "QPSK 3/4"}, |
212 | { "24", "16QAM 1/2"}, | 214 | {"24", "16QAM 1/2"}, |
213 | { "36", "16QAM 3/4"}, | 215 | {"36", "16QAM 3/4"}, |
214 | { "48", "64QAM 2/3"}, | 216 | {"48", "64QAM 2/3"}, |
215 | { "54", "64QAM 3/4"}, | 217 | {"54", "64QAM 3/4"}, |
216 | { "60", "64QAM 5/6"}, | 218 | {"60", "64QAM 5/6"}, |
217 | }; | 219 | }; |
218 | 220 | ||
219 | #define MCS_IDX_PER_STREAM (8) | 221 | #define MCS_IDX_PER_STREAM (8) |
220 | 222 | ||
221 | static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) | 223 | static inline u8 |
224 | il4965_rs_extract_rate(u32 rate_n_flags) | ||
222 | { | 225 | { |
223 | return (u8)(rate_n_flags & 0xFF); | 226 | return (u8) (rate_n_flags & 0xFF); |
224 | } | 227 | } |
225 | 228 | ||
226 | static void | 229 | static void |
@@ -234,7 +237,8 @@ il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) | |||
234 | win->stamp = 0; | 237 | win->stamp = 0; |
235 | } | 238 | } |
236 | 239 | ||
237 | static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) | 240 | static inline u8 |
241 | il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) | ||
238 | { | 242 | { |
239 | return (ant_type & valid_antenna) == ant_type; | 243 | return (ant_type & valid_antenna) == ant_type; |
240 | } | 244 | } |
@@ -264,8 +268,8 @@ il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) | |||
264 | * increment traffic load value for tid and also remove | 268 | * increment traffic load value for tid and also remove |
265 | * any old values if passed the certain time period | 269 | * any old values if passed the certain time period |
266 | */ | 270 | */ |
267 | static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, | 271 | static u8 |
268 | struct ieee80211_hdr *hdr) | 272 | il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, struct ieee80211_hdr *hdr) |
269 | { | 273 | { |
270 | u32 curr_time = jiffies_to_msecs(jiffies); | 274 | u32 curr_time = jiffies_to_msecs(jiffies); |
271 | u32 time_diff; | 275 | u32 time_diff; |
@@ -317,7 +321,8 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, | |||
317 | /* | 321 | /* |
318 | get the traffic load value for tid | 322 | get the traffic load value for tid |
319 | */ | 323 | */ |
320 | static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) | 324 | static u32 |
325 | il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) | ||
321 | { | 326 | { |
322 | u32 curr_time = jiffies_to_msecs(jiffies); | 327 | u32 curr_time = jiffies_to_msecs(jiffies); |
323 | u32 time_diff; | 328 | u32 time_diff; |
@@ -345,9 +350,9 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) | |||
345 | return tl->total; | 350 | return tl->total; |
346 | } | 351 | } |
347 | 352 | ||
348 | static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, | 353 | static int |
349 | struct il_lq_sta *lq_data, u8 tid, | 354 | il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, |
350 | struct ieee80211_sta *sta) | 355 | u8 tid, struct ieee80211_sta *sta) |
351 | { | 356 | { |
352 | int ret = -EAGAIN; | 357 | int ret = -EAGAIN; |
353 | u32 load; | 358 | u32 load; |
@@ -355,8 +360,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, | |||
355 | load = il4965_rs_tl_get_load(lq_data, tid); | 360 | load = il4965_rs_tl_get_load(lq_data, tid); |
356 | 361 | ||
357 | if (load > IL_AGG_LOAD_THRESHOLD) { | 362 | if (load > IL_AGG_LOAD_THRESHOLD) { |
358 | D_HT("Starting Tx agg: STA: %pM tid: %d\n", | 363 | D_HT("Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); |
359 | sta->addr, tid); | ||
360 | ret = ieee80211_start_tx_ba_session(sta, tid, 5000); | 364 | ret = ieee80211_start_tx_ba_session(sta, tid, 5000); |
361 | if (ret == -EAGAIN) { | 365 | if (ret == -EAGAIN) { |
362 | /* | 366 | /* |
@@ -364,33 +368,33 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, | |||
364 | * this might be cause by reloading firmware | 368 | * this might be cause by reloading firmware |
365 | * stop the tx ba session here | 369 | * stop the tx ba session here |
366 | */ | 370 | */ |
367 | IL_ERR("Fail start Tx agg on tid: %d\n", | 371 | IL_ERR("Fail start Tx agg on tid: %d\n", tid); |
368 | tid); | ||
369 | ieee80211_stop_tx_ba_session(sta, tid); | 372 | ieee80211_stop_tx_ba_session(sta, tid); |
370 | } | 373 | } |
371 | } else { | 374 | } else { |
372 | IL_ERR("Aggregation not enabled for tid %d " | 375 | IL_ERR("Aggregation not enabled for tid %d " |
373 | "because load = %u\n", tid, load); | 376 | "because load = %u\n", tid, load); |
374 | } | 377 | } |
375 | return ret; | 378 | return ret; |
376 | } | 379 | } |
377 | 380 | ||
378 | static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, | 381 | static void |
379 | struct il_lq_sta *lq_data, | 382 | il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, struct il_lq_sta *lq_data, |
380 | struct ieee80211_sta *sta) | 383 | struct ieee80211_sta *sta) |
381 | { | 384 | { |
382 | if (tid < TID_MAX_LOAD_COUNT) | 385 | if (tid < TID_MAX_LOAD_COUNT) |
383 | il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); | 386 | il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); |
384 | else | 387 | else |
385 | IL_ERR("tid exceeds max load count: %d/%d\n", | 388 | IL_ERR("tid exceeds max load count: %d/%d\n", tid, |
386 | tid, TID_MAX_LOAD_COUNT); | 389 | TID_MAX_LOAD_COUNT); |
387 | } | 390 | } |
388 | 391 | ||
389 | static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) | 392 | static inline int |
393 | il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) | ||
390 | { | 394 | { |
391 | return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + | 395 | return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + |
392 | !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + | 396 | !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + |
393 | !!(rate_n_flags & RATE_MCS_ANT_C_MSK); | 397 | !!(rate_n_flags & RATE_MCS_ANT_C_MSK); |
394 | } | 398 | } |
395 | 399 | ||
396 | /* | 400 | /* |
@@ -412,11 +416,12 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) | |||
412 | * at this rate. win->data contains the bitmask of successful | 416 | * at this rate. win->data contains the bitmask of successful |
413 | * packets. | 417 | * packets. |
414 | */ | 418 | */ |
415 | static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, | 419 | static int |
416 | int scale_idx, int attempts, int successes) | 420 | il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_idx, |
421 | int attempts, int successes) | ||
417 | { | 422 | { |
418 | struct il_rate_scale_data *win = NULL; | 423 | struct il_rate_scale_data *win = NULL; |
419 | static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); | 424 | static const u64 mask = (((u64) 1) << (RATE_MAX_WINDOW - 1)); |
420 | s32 fail_count, tpt; | 425 | s32 fail_count, tpt; |
421 | 426 | ||
422 | if (scale_idx < 0 || scale_idx >= RATE_COUNT) | 427 | if (scale_idx < 0 || scale_idx >= RATE_COUNT) |
@@ -466,8 +471,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, | |||
466 | 471 | ||
467 | /* Calculate current success ratio, avoid divide-by-0! */ | 472 | /* Calculate current success ratio, avoid divide-by-0! */ |
468 | if (win->counter > 0) | 473 | if (win->counter > 0) |
469 | win->success_ratio = 128 * (100 * win->success_counter) | 474 | win->success_ratio = |
470 | / win->counter; | 475 | 128 * (100 * win->success_counter) / win->counter; |
471 | else | 476 | else |
472 | win->success_ratio = IL_INVALID_VALUE; | 477 | win->success_ratio = IL_INVALID_VALUE; |
473 | 478 | ||
@@ -489,9 +494,9 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, | |||
489 | /* | 494 | /* |
490 | * Fill uCode API rate_n_flags field, based on "search" or "active" table. | 495 | * Fill uCode API rate_n_flags field, based on "search" or "active" table. |
491 | */ | 496 | */ |
492 | static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, | 497 | static u32 |
493 | struct il_scale_tbl_info *tbl, | 498 | il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, |
494 | int idx, u8 use_green) | 499 | int idx, u8 use_green) |
495 | { | 500 | { |
496 | u32 rate_n_flags = 0; | 501 | u32 rate_n_flags = 0; |
497 | 502 | ||
@@ -508,15 +513,15 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, | |||
508 | rate_n_flags = RATE_MCS_HT_MSK; | 513 | rate_n_flags = RATE_MCS_HT_MSK; |
509 | 514 | ||
510 | if (is_siso(tbl->lq_type)) | 515 | if (is_siso(tbl->lq_type)) |
511 | rate_n_flags |= il_rates[idx].plcp_siso; | 516 | rate_n_flags |= il_rates[idx].plcp_siso; |
512 | else | 517 | else |
513 | rate_n_flags |= il_rates[idx].plcp_mimo2; | 518 | rate_n_flags |= il_rates[idx].plcp_mimo2; |
514 | } else { | 519 | } else { |
515 | IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); | 520 | IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); |
516 | } | 521 | } |
517 | 522 | ||
518 | rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & | 523 | rate_n_flags |= |
519 | RATE_MCS_ANT_ABC_MSK); | 524 | ((tbl->ant_type << RATE_MCS_ANT_POS) & RATE_MCS_ANT_ABC_MSK); |
520 | 525 | ||
521 | if (is_Ht(tbl->lq_type)) { | 526 | if (is_Ht(tbl->lq_type)) { |
522 | if (tbl->is_ht40) { | 527 | if (tbl->is_ht40) { |
@@ -543,19 +548,20 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, | |||
543 | * Interpret uCode API's rate_n_flags format, | 548 | * Interpret uCode API's rate_n_flags format, |
544 | * fill "search" or "active" tx mode table. | 549 | * fill "search" or "active" tx mode table. |
545 | */ | 550 | */ |
546 | static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, | 551 | static int |
547 | enum ieee80211_band band, | 552 | il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, |
548 | struct il_scale_tbl_info *tbl, | 553 | enum ieee80211_band band, |
549 | int *rate_idx) | 554 | struct il_scale_tbl_info *tbl, int *rate_idx) |
550 | { | 555 | { |
551 | u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); | 556 | u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); |
552 | u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); | 557 | u8 il4965_num_of_ant = |
558 | il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); | ||
553 | u8 mcs; | 559 | u8 mcs; |
554 | 560 | ||
555 | memset(tbl, 0, sizeof(struct il_scale_tbl_info)); | 561 | memset(tbl, 0, sizeof(struct il_scale_tbl_info)); |
556 | *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); | 562 | *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); |
557 | 563 | ||
558 | if (*rate_idx == RATE_INVALID) { | 564 | if (*rate_idx == RATE_INVALID) { |
559 | *rate_idx = -1; | 565 | *rate_idx = -1; |
560 | return -EINVAL; | 566 | return -EINVAL; |
561 | } | 567 | } |
@@ -574,7 +580,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, | |||
574 | else | 580 | else |
575 | tbl->lq_type = LQ_G; | 581 | tbl->lq_type = LQ_G; |
576 | } | 582 | } |
577 | /* HT rate format */ | 583 | /* HT rate format */ |
578 | } else { | 584 | } else { |
579 | if (rate_n_flags & RATE_MCS_SGI_MSK) | 585 | if (rate_n_flags & RATE_MCS_SGI_MSK) |
580 | tbl->is_SGI = 1; | 586 | tbl->is_SGI = 1; |
@@ -591,8 +597,8 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, | |||
591 | /* SISO */ | 597 | /* SISO */ |
592 | if (mcs <= RATE_SISO_60M_PLCP) { | 598 | if (mcs <= RATE_SISO_60M_PLCP) { |
593 | if (il4965_num_of_ant == 1) | 599 | if (il4965_num_of_ant == 1) |
594 | tbl->lq_type = LQ_SISO; /*else NONE*/ | 600 | tbl->lq_type = LQ_SISO; /*else NONE */ |
595 | /* MIMO2 */ | 601 | /* MIMO2 */ |
596 | } else { | 602 | } else { |
597 | if (il4965_num_of_ant == 2) | 603 | if (il4965_num_of_ant == 2) |
598 | tbl->lq_type = LQ_MIMO2; | 604 | tbl->lq_type = LQ_MIMO2; |
@@ -603,8 +609,9 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, | |||
603 | 609 | ||
604 | /* switch to another antenna/antennas and return 1 */ | 610 | /* switch to another antenna/antennas and return 1 */ |
605 | /* if no other valid antenna found, return 0 */ | 611 | /* if no other valid antenna found, return 0 */ |
606 | static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, | 612 | static int |
607 | struct il_scale_tbl_info *tbl) | 613 | il4965_rs_toggle_antenna(u32 valid_ant, u32 * rate_n_flags, |
614 | struct il_scale_tbl_info *tbl) | ||
608 | { | 615 | { |
609 | u8 new_ant_type; | 616 | u8 new_ant_type; |
610 | 617 | ||
@@ -633,13 +640,14 @@ static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, | |||
633 | * Green-field mode is valid if the station supports it and | 640 | * Green-field mode is valid if the station supports it and |
634 | * there are no non-GF stations present in the BSS. | 641 | * there are no non-GF stations present in the BSS. |
635 | */ | 642 | */ |
636 | static bool il4965_rs_use_green(struct ieee80211_sta *sta) | 643 | static bool |
644 | il4965_rs_use_green(struct ieee80211_sta *sta) | ||
637 | { | 645 | { |
638 | struct il_station_priv *sta_priv = (void *)sta->drv_priv; | 646 | struct il_station_priv *sta_priv = (void *)sta->drv_priv; |
639 | struct il_rxon_context *ctx = sta_priv->common.ctx; | 647 | struct il_rxon_context *ctx = sta_priv->common.ctx; |
640 | 648 | ||
641 | return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && | 649 | return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && |
642 | !(ctx->ht.non_gf_sta_present); | 650 | !(ctx->ht.non_gf_sta_present); |
643 | } | 651 | } |
644 | 652 | ||
645 | /** | 653 | /** |
@@ -649,9 +657,10 @@ static bool il4965_rs_use_green(struct ieee80211_sta *sta) | |||
649 | * basic available rates. | 657 | * basic available rates. |
650 | * | 658 | * |
651 | */ | 659 | */ |
652 | static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, | 660 | static u16 |
653 | struct ieee80211_hdr *hdr, | 661 | il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, |
654 | enum il_table_type rate_type) | 662 | struct ieee80211_hdr *hdr, |
663 | enum il_table_type rate_type) | ||
655 | { | 664 | { |
656 | if (is_legacy(rate_type)) { | 665 | if (is_legacy(rate_type)) { |
657 | return lq_sta->active_legacy_rate; | 666 | return lq_sta->active_legacy_rate; |
@@ -665,7 +674,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, | |||
665 | 674 | ||
666 | static u16 | 675 | static u16 |
667 | il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, | 676 | il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, |
668 | int rate_type) | 677 | int rate_type) |
669 | { | 678 | { |
670 | u8 high = RATE_INVALID; | 679 | u8 high = RATE_INVALID; |
671 | u8 low = RATE_INVALID; | 680 | u8 low = RATE_INVALID; |
@@ -720,9 +729,10 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, | |||
720 | return (high << 8) | low; | 729 | return (high << 8) | low; |
721 | } | 730 | } |
722 | 731 | ||
723 | static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, | 732 | static u32 |
724 | struct il_scale_tbl_info *tbl, | 733 | il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, |
725 | u8 scale_idx, u8 ht_possible) | 734 | struct il_scale_tbl_info *tbl, u8 scale_idx, |
735 | u8 ht_possible) | ||
726 | { | 736 | { |
727 | s32 low; | 737 | s32 low; |
728 | u16 rate_mask; | 738 | u16 rate_mask; |
@@ -744,7 +754,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, | |||
744 | 754 | ||
745 | if (il4965_num_of_ant(tbl->ant_type) > 1) | 755 | if (il4965_num_of_ant(tbl->ant_type) > 1) |
746 | tbl->ant_type = | 756 | tbl->ant_type = |
747 | il4965_first_antenna(il->hw_params.valid_tx_ant); | 757 | il4965_first_antenna(il->hw_params.valid_tx_ant); |
748 | 758 | ||
749 | tbl->is_ht40 = 0; | 759 | tbl->is_ht40 = 0; |
750 | tbl->is_SGI = 0; | 760 | tbl->is_SGI = 0; |
@@ -757,10 +767,11 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, | |||
757 | if (is_legacy(tbl->lq_type)) { | 767 | if (is_legacy(tbl->lq_type)) { |
758 | /* supp_rates has no CCK bits in A mode */ | 768 | /* supp_rates has no CCK bits in A mode */ |
759 | if (lq_sta->band == IEEE80211_BAND_5GHZ) | 769 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
760 | rate_mask = (u16)(rate_mask & | 770 | rate_mask = |
761 | (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); | 771 | (u16) (rate_mask & |
772 | (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); | ||
762 | else | 773 | else |
763 | rate_mask = (u16)(rate_mask & lq_sta->supp_rates); | 774 | rate_mask = (u16) (rate_mask & lq_sta->supp_rates); |
764 | } | 775 | } |
765 | 776 | ||
766 | /* If we switched from HT to legacy, check current rate */ | 777 | /* If we switched from HT to legacy, check current rate */ |
@@ -769,8 +780,8 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, | |||
769 | goto out; | 780 | goto out; |
770 | } | 781 | } |
771 | 782 | ||
772 | high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, | 783 | high_low = |
773 | scale_idx, rate_mask, | 784 | il4965_rs_get_adjacent_rate(lq_sta->drv, scale_idx, rate_mask, |
774 | tbl->lq_type); | 785 | tbl->lq_type); |
775 | low = high_low & 0xff; | 786 | low = high_low & 0xff; |
776 | 787 | ||
@@ -784,8 +795,9 @@ out: | |||
784 | /* | 795 | /* |
785 | * Simple function to compare two rate scale table types | 796 | * Simple function to compare two rate scale table types |
786 | */ | 797 | */ |
787 | static bool il4965_table_type_matches(struct il_scale_tbl_info *a, | 798 | static bool |
788 | struct il_scale_tbl_info *b) | 799 | il4965_table_type_matches(struct il_scale_tbl_info *a, |
800 | struct il_scale_tbl_info *b) | ||
789 | { | 801 | { |
790 | return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && | 802 | return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && |
791 | a->is_SGI == b->is_SGI); | 803 | a->is_SGI == b->is_SGI); |
@@ -796,8 +808,8 @@ static bool il4965_table_type_matches(struct il_scale_tbl_info *a, | |||
796 | */ | 808 | */ |
797 | static void | 809 | static void |
798 | il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | 810 | il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, |
799 | struct ieee80211_sta *sta, void *il_sta, | 811 | struct ieee80211_sta *sta, void *il_sta, |
800 | struct sk_buff *skb) | 812 | struct sk_buff *skb) |
801 | { | 813 | { |
802 | int legacy_success; | 814 | int legacy_success; |
803 | int retries; | 815 | int retries; |
@@ -814,8 +826,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
814 | struct il_station_priv *sta_priv = (void *)sta->drv_priv; | 826 | struct il_station_priv *sta_priv = (void *)sta->drv_priv; |
815 | struct il_rxon_context *ctx = sta_priv->common.ctx; | 827 | struct il_rxon_context *ctx = sta_priv->common.ctx; |
816 | 828 | ||
817 | D_RATE( | 829 | D_RATE("get frame ack response, update rate scale win\n"); |
818 | "get frame ack response, update rate scale win\n"); | ||
819 | 830 | ||
820 | /* Treat uninitialized rate scaling data same as non-existing. */ | 831 | /* Treat uninitialized rate scaling data same as non-existing. */ |
821 | if (!lq_sta) { | 832 | if (!lq_sta) { |
@@ -845,8 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
845 | */ | 856 | */ |
846 | table = &lq_sta->lq; | 857 | table = &lq_sta->lq; |
847 | tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); | 858 | tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); |
848 | il4965_rs_get_tbl_info_from_mcs(tx_rate, | 859 | il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_idx); |
849 | il->band, &tbl_type, &rs_idx); | ||
850 | if (il->band == IEEE80211_BAND_5GHZ) | 860 | if (il->band == IEEE80211_BAND_5GHZ) |
851 | rs_idx -= IL_FIRST_OFDM_RATE; | 861 | rs_idx -= IL_FIRST_OFDM_RATE; |
852 | mac_flags = info->status.rates[0].flags; | 862 | mac_flags = info->status.rates[0].flags; |
@@ -869,12 +879,11 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
869 | tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || | 879 | tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || |
870 | tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || | 880 | tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || |
871 | tbl_type.ant_type != info->antenna_sel_tx || | 881 | tbl_type.ant_type != info->antenna_sel_tx || |
872 | !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || | 882 | !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) |
873 | !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || | 883 | || !!(tx_rate & RATE_MCS_GF_MSK) != |
874 | rs_idx != mac_idx) { | 884 | !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || rs_idx != mac_idx) { |
875 | D_RATE( | 885 | D_RATE("initial rate %d does not match %d (0x%x)\n", mac_idx, |
876 | "initial rate %d does not match %d (0x%x)\n", | 886 | rs_idx, tx_rate); |
877 | mac_idx, rs_idx, tx_rate); | ||
878 | /* | 887 | /* |
879 | * Since rates mis-match, the last LQ command may have failed. | 888 | * Since rates mis-match, the last LQ command may have failed. |
880 | * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with | 889 | * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with |
@@ -883,8 +892,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
883 | lq_sta->missed_rate_counter++; | 892 | lq_sta->missed_rate_counter++; |
884 | if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { | 893 | if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { |
885 | lq_sta->missed_rate_counter = 0; | 894 | lq_sta->missed_rate_counter = 0; |
886 | il_send_lq_cmd(il, ctx, &lq_sta->lq, | 895 | il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); |
887 | CMD_ASYNC, false); | ||
888 | } | 896 | } |
889 | /* Regardless, ignore this status info for outdated rate */ | 897 | /* Regardless, ignore this status info for outdated rate */ |
890 | return; | 898 | return; |
@@ -893,25 +901,25 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
893 | lq_sta->missed_rate_counter = 0; | 901 | lq_sta->missed_rate_counter = 0; |
894 | 902 | ||
895 | /* Figure out if rate scale algorithm is in active or search table */ | 903 | /* Figure out if rate scale algorithm is in active or search table */ |
896 | if (il4965_table_type_matches(&tbl_type, | 904 | if (il4965_table_type_matches |
897 | &(lq_sta->lq_info[lq_sta->active_tbl]))) { | 905 | (&tbl_type, &(lq_sta->lq_info[lq_sta->active_tbl]))) { |
898 | curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 906 | curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
899 | other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); | 907 | other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); |
900 | } else if (il4965_table_type_matches(&tbl_type, | 908 | } else |
901 | &lq_sta->lq_info[1 - lq_sta->active_tbl])) { | 909 | if (il4965_table_type_matches |
910 | (&tbl_type, &lq_sta->lq_info[1 - lq_sta->active_tbl])) { | ||
902 | curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); | 911 | curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); |
903 | other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 912 | other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
904 | } else { | 913 | } else { |
905 | D_RATE( | 914 | D_RATE("Neither active nor search matches tx rate\n"); |
906 | "Neither active nor search matches tx rate\n"); | ||
907 | tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 915 | tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
908 | D_RATE("active- lq:%x, ant:%x, SGI:%d\n", | 916 | D_RATE("active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, |
909 | tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); | 917 | tmp_tbl->ant_type, tmp_tbl->is_SGI); |
910 | tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); | 918 | tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); |
911 | D_RATE("search- lq:%x, ant:%x, SGI:%d\n", | 919 | D_RATE("search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, |
912 | tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); | 920 | tmp_tbl->ant_type, tmp_tbl->is_SGI); |
913 | D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", | 921 | D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, |
914 | tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); | 922 | tbl_type.ant_type, tbl_type.is_SGI); |
915 | /* | 923 | /* |
916 | * no matching table found, let's by-pass the data collection | 924 | * no matching table found, let's by-pass the data collection |
917 | * and continue to perform rate scale to find the rate table | 925 | * and continue to perform rate scale to find the rate table |
@@ -930,21 +938,22 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
930 | if (info->flags & IEEE80211_TX_STAT_AMPDU) { | 938 | if (info->flags & IEEE80211_TX_STAT_AMPDU) { |
931 | tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); | 939 | tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); |
932 | il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, | 940 | il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, |
933 | &rs_idx); | 941 | &rs_idx); |
934 | il4965_rs_collect_tx_data(curr_tbl, rs_idx, | 942 | il4965_rs_collect_tx_data(curr_tbl, rs_idx, |
935 | info->status.ampdu_len, | 943 | info->status.ampdu_len, |
936 | info->status.ampdu_ack_len); | 944 | info->status.ampdu_ack_len); |
937 | 945 | ||
938 | /* Update success/fail counts if not searching for new mode */ | 946 | /* Update success/fail counts if not searching for new mode */ |
939 | if (lq_sta->stay_in_tbl) { | 947 | if (lq_sta->stay_in_tbl) { |
940 | lq_sta->total_success += info->status.ampdu_ack_len; | 948 | lq_sta->total_success += info->status.ampdu_ack_len; |
941 | lq_sta->total_failed += (info->status.ampdu_len - | 949 | lq_sta->total_failed += |
942 | info->status.ampdu_ack_len); | 950 | (info->status.ampdu_len - |
951 | info->status.ampdu_ack_len); | ||
943 | } | 952 | } |
944 | } else { | 953 | } else { |
945 | /* | 954 | /* |
946 | * For legacy, update frame history with for each Tx retry. | 955 | * For legacy, update frame history with for each Tx retry. |
947 | */ | 956 | */ |
948 | retries = info->status.rates[0].count - 1; | 957 | retries = info->status.rates[0].count - 1; |
949 | /* HW doesn't send more than 15 retries */ | 958 | /* HW doesn't send more than 15 retries */ |
950 | retries = min(retries, 15); | 959 | retries = min(retries, 15); |
@@ -955,20 +964,21 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, | |||
955 | for (i = 0; i <= retries; ++i) { | 964 | for (i = 0; i <= retries; ++i) { |
956 | tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); | 965 | tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); |
957 | il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, | 966 | il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, |
958 | &tbl_type, &rs_idx); | 967 | &tbl_type, &rs_idx); |
959 | /* | 968 | /* |
960 | * Only collect stats if retried rate is in the same RS | 969 | * Only collect stats if retried rate is in the same RS |
961 | * table as active/search. | 970 | * table as active/search. |
962 | */ | 971 | */ |
963 | if (il4965_table_type_matches(&tbl_type, curr_tbl)) | 972 | if (il4965_table_type_matches(&tbl_type, curr_tbl)) |
964 | tmp_tbl = curr_tbl; | 973 | tmp_tbl = curr_tbl; |
965 | else if (il4965_table_type_matches(&tbl_type, | 974 | else if (il4965_table_type_matches |
966 | other_tbl)) | 975 | (&tbl_type, other_tbl)) |
967 | tmp_tbl = other_tbl; | 976 | tmp_tbl = other_tbl; |
968 | else | 977 | else |
969 | continue; | 978 | continue; |
970 | il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, | 979 | il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, |
971 | i < retries ? 0 : legacy_success); | 980 | i < |
981 | retries ? 0 : legacy_success); | ||
972 | } | 982 | } |
973 | 983 | ||
974 | /* Update success/fail counts if not searching for new mode */ | 984 | /* Update success/fail counts if not searching for new mode */ |
@@ -993,8 +1003,9 @@ done: | |||
993 | * These control how long we stay using same modulation mode before | 1003 | * These control how long we stay using same modulation mode before |
994 | * searching for a new mode. | 1004 | * searching for a new mode. |
995 | */ | 1005 | */ |
996 | static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, | 1006 | static void |
997 | struct il_lq_sta *lq_sta) | 1007 | il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, |
1008 | struct il_lq_sta *lq_sta) | ||
998 | { | 1009 | { |
999 | D_RATE("we are staying in the same table\n"); | 1010 | D_RATE("we are staying in the same table\n"); |
1000 | lq_sta->stay_in_tbl = 1; /* only place this gets set */ | 1011 | lq_sta->stay_in_tbl = 1; /* only place this gets set */ |
@@ -1017,11 +1028,12 @@ static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, | |||
1017 | /* | 1028 | /* |
1018 | * Find correct throughput table for given mode of modulation | 1029 | * Find correct throughput table for given mode of modulation |
1019 | */ | 1030 | */ |
1020 | static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, | 1031 | static void |
1021 | struct il_scale_tbl_info *tbl) | 1032 | il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, |
1033 | struct il_scale_tbl_info *tbl) | ||
1022 | { | 1034 | { |
1023 | /* Used to choose among HT tables */ | 1035 | /* Used to choose among HT tables */ |
1024 | s32 (*ht_tbl_pointer)[RATE_COUNT]; | 1036 | s32(*ht_tbl_pointer)[RATE_COUNT]; |
1025 | 1037 | ||
1026 | /* Check for invalid LQ type */ | 1038 | /* Check for invalid LQ type */ |
1027 | if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { | 1039 | if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { |
@@ -1044,16 +1056,16 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, | |||
1044 | ht_tbl_pointer = expected_tpt_siso40MHz; | 1056 | ht_tbl_pointer = expected_tpt_siso40MHz; |
1045 | else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) | 1057 | else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) |
1046 | ht_tbl_pointer = expected_tpt_mimo2_20MHz; | 1058 | ht_tbl_pointer = expected_tpt_mimo2_20MHz; |
1047 | else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ | 1059 | else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ |
1048 | ht_tbl_pointer = expected_tpt_mimo2_40MHz; | 1060 | ht_tbl_pointer = expected_tpt_mimo2_40MHz; |
1049 | 1061 | ||
1050 | if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ | 1062 | if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ |
1051 | tbl->expected_tpt = ht_tbl_pointer[0]; | 1063 | tbl->expected_tpt = ht_tbl_pointer[0]; |
1052 | else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ | 1064 | else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ |
1053 | tbl->expected_tpt = ht_tbl_pointer[1]; | 1065 | tbl->expected_tpt = ht_tbl_pointer[1]; |
1054 | else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ | 1066 | else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ |
1055 | tbl->expected_tpt = ht_tbl_pointer[2]; | 1067 | tbl->expected_tpt = ht_tbl_pointer[2]; |
1056 | else /* AGG+SGI */ | 1068 | else /* AGG+SGI */ |
1057 | tbl->expected_tpt = ht_tbl_pointer[3]; | 1069 | tbl->expected_tpt = ht_tbl_pointer[3]; |
1058 | } | 1070 | } |
1059 | 1071 | ||
@@ -1069,10 +1081,9 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, | |||
1069 | * to decrease to match "active" throughput. When moving from MIMO to SISO, | 1081 | * to decrease to match "active" throughput. When moving from MIMO to SISO, |
1070 | * bit rate will typically need to increase, but not if performance was bad. | 1082 | * bit rate will typically need to increase, but not if performance was bad. |
1071 | */ | 1083 | */ |
1072 | static s32 il4965_rs_get_best_rate(struct il_priv *il, | 1084 | static s32 |
1073 | struct il_lq_sta *lq_sta, | 1085 | il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ |
1074 | struct il_scale_tbl_info *tbl, /* "search" */ | 1086 | u16 rate_mask, s8 idx) |
1075 | u16 rate_mask, s8 idx) | ||
1076 | { | 1087 | { |
1077 | /* "active" values */ | 1088 | /* "active" values */ |
1078 | struct il_scale_tbl_info *active_tbl = | 1089 | struct il_scale_tbl_info *active_tbl = |
@@ -1089,8 +1100,9 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, | |||
1089 | 1100 | ||
1090 | new_rate = high = low = start_hi = RATE_INVALID; | 1101 | new_rate = high = low = start_hi = RATE_INVALID; |
1091 | 1102 | ||
1092 | for (; ;) { | 1103 | for (;;) { |
1093 | high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, | 1104 | high_low = |
1105 | il4965_rs_get_adjacent_rate(il, rate, rate_mask, | ||
1094 | tbl->lq_type); | 1106 | tbl->lq_type); |
1095 | 1107 | ||
1096 | low = high_low & 0xff; | 1108 | low = high_low & 0xff; |
@@ -1112,9 +1124,8 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, | |||
1112 | * "active" throughput (under perfect conditions). | 1124 | * "active" throughput (under perfect conditions). |
1113 | */ | 1125 | */ |
1114 | if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && | 1126 | if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && |
1115 | (active_sr > RATE_DECREASE_TH && | 1127 | (active_sr > RATE_DECREASE_TH && active_sr <= RATE_HIGH_TH |
1116 | active_sr <= RATE_HIGH_TH && | 1128 | && tpt_tbl[rate] <= active_tpt)) || |
1117 | tpt_tbl[rate] <= active_tpt)) || | ||
1118 | (active_sr >= RATE_SCALE_SWITCH && | 1129 | (active_sr >= RATE_SCALE_SWITCH && |
1119 | tpt_tbl[rate] > active_tpt)) { | 1130 | tpt_tbl[rate] > active_tpt)) { |
1120 | 1131 | ||
@@ -1136,7 +1147,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, | |||
1136 | else | 1147 | else |
1137 | break; | 1148 | break; |
1138 | 1149 | ||
1139 | /* Else try to raise the "search" rate to match "active" */ | 1150 | /* Else try to raise the "search" rate to match "active" */ |
1140 | } else { | 1151 | } else { |
1141 | /* (2nd or later pass) | 1152 | /* (2nd or later pass) |
1142 | * If we've already tried to lower the rate, and are | 1153 | * If we've already tried to lower the rate, and are |
@@ -1149,7 +1160,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, | |||
1149 | start_hi = high; | 1160 | start_hi = high; |
1150 | rate = high; | 1161 | rate = high; |
1151 | 1162 | ||
1152 | /* Higher rate not available, use the original */ | 1163 | /* Higher rate not available, use the original */ |
1153 | } else { | 1164 | } else { |
1154 | new_rate = rate; | 1165 | new_rate = rate; |
1155 | break; | 1166 | break; |
@@ -1163,11 +1174,11 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, | |||
1163 | /* | 1174 | /* |
1164 | * Set up search table for MIMO2 | 1175 | * Set up search table for MIMO2 |
1165 | */ | 1176 | */ |
1166 | static int il4965_rs_switch_to_mimo2(struct il_priv *il, | 1177 | static int |
1167 | struct il_lq_sta *lq_sta, | 1178 | il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, |
1168 | struct ieee80211_conf *conf, | 1179 | struct ieee80211_conf *conf, |
1169 | struct ieee80211_sta *sta, | 1180 | struct ieee80211_sta *sta, |
1170 | struct il_scale_tbl_info *tbl, int idx) | 1181 | struct il_scale_tbl_info *tbl, int idx) |
1171 | { | 1182 | { |
1172 | u16 rate_mask; | 1183 | u16 rate_mask; |
1173 | s32 rate; | 1184 | s32 rate; |
@@ -1178,8 +1189,8 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, | |||
1178 | if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) | 1189 | if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) |
1179 | return -1; | 1190 | return -1; |
1180 | 1191 | ||
1181 | if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) | 1192 | if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) == |
1182 | == WLAN_HT_CAP_SM_PS_STATIC) | 1193 | WLAN_HT_CAP_SM_PS_STATIC) |
1183 | return -1; | 1194 | return -1; |
1184 | 1195 | ||
1185 | /* Need both Tx chains/antennas to support MIMO */ | 1196 | /* Need both Tx chains/antennas to support MIMO */ |
@@ -1203,30 +1214,27 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, | |||
1203 | 1214 | ||
1204 | rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); | 1215 | rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); |
1205 | 1216 | ||
1206 | D_RATE("LQ: MIMO2 best rate %d mask %X\n", | 1217 | D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); |
1207 | rate, rate_mask); | ||
1208 | if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { | 1218 | if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { |
1209 | D_RATE( | 1219 | D_RATE("Can't switch with idx %d rate mask %x\n", rate, |
1210 | "Can't switch with idx %d rate mask %x\n", | 1220 | rate_mask); |
1211 | rate, rate_mask); | ||
1212 | return -1; | 1221 | return -1; |
1213 | } | 1222 | } |
1214 | tbl->current_rate = il4965_rate_n_flags_from_tbl(il, | 1223 | tbl->current_rate = |
1215 | tbl, rate, is_green); | 1224 | il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); |
1216 | 1225 | ||
1217 | D_RATE("LQ: Switch to new mcs %X idx is green %X\n", | 1226 | D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, |
1218 | tbl->current_rate, is_green); | 1227 | is_green); |
1219 | return 0; | 1228 | return 0; |
1220 | } | 1229 | } |
1221 | 1230 | ||
1222 | /* | 1231 | /* |
1223 | * Set up search table for SISO | 1232 | * Set up search table for SISO |
1224 | */ | 1233 | */ |
1225 | static int il4965_rs_switch_to_siso(struct il_priv *il, | 1234 | static int |
1226 | struct il_lq_sta *lq_sta, | 1235 | il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, |
1227 | struct ieee80211_conf *conf, | 1236 | struct ieee80211_conf *conf, struct ieee80211_sta *sta, |
1228 | struct ieee80211_sta *sta, | 1237 | struct il_scale_tbl_info *tbl, int idx) |
1229 | struct il_scale_tbl_info *tbl, int idx) | ||
1230 | { | 1238 | { |
1231 | u16 rate_mask; | 1239 | u16 rate_mask; |
1232 | u8 is_green = lq_sta->is_green; | 1240 | u8 is_green = lq_sta->is_green; |
@@ -1251,40 +1259,39 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, | |||
1251 | tbl->is_ht40 = 0; | 1259 | tbl->is_ht40 = 0; |
1252 | 1260 | ||
1253 | if (is_green) | 1261 | if (is_green) |
1254 | tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ | 1262 | tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield */ |
1255 | 1263 | ||
1256 | il4965_rs_set_expected_tpt_table(lq_sta, tbl); | 1264 | il4965_rs_set_expected_tpt_table(lq_sta, tbl); |
1257 | rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); | 1265 | rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); |
1258 | 1266 | ||
1259 | D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); | 1267 | D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); |
1260 | if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { | 1268 | if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { |
1261 | D_RATE( | 1269 | D_RATE("can not switch with idx %d rate mask %x\n", rate, |
1262 | "can not switch with idx %d rate mask %x\n", | 1270 | rate_mask); |
1263 | rate, rate_mask); | ||
1264 | return -1; | 1271 | return -1; |
1265 | } | 1272 | } |
1266 | tbl->current_rate = il4965_rate_n_flags_from_tbl(il, | 1273 | tbl->current_rate = |
1267 | tbl, rate, is_green); | 1274 | il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); |
1268 | D_RATE("LQ: Switch to new mcs %X idx is green %X\n", | 1275 | D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, |
1269 | tbl->current_rate, is_green); | 1276 | is_green); |
1270 | return 0; | 1277 | return 0; |
1271 | } | 1278 | } |
1272 | 1279 | ||
1273 | /* | 1280 | /* |
1274 | * Try to switch to new modulation mode from legacy | 1281 | * Try to switch to new modulation mode from legacy |
1275 | */ | 1282 | */ |
1276 | static int il4965_rs_move_legacy_other(struct il_priv *il, | 1283 | static int |
1277 | struct il_lq_sta *lq_sta, | 1284 | il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, |
1278 | struct ieee80211_conf *conf, | 1285 | struct ieee80211_conf *conf, |
1279 | struct ieee80211_sta *sta, | 1286 | struct ieee80211_sta *sta, int idx) |
1280 | int idx) | ||
1281 | { | 1287 | { |
1282 | struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1288 | struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
1283 | struct il_scale_tbl_info *search_tbl = | 1289 | struct il_scale_tbl_info *search_tbl = |
1284 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); | 1290 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
1285 | struct il_rate_scale_data *win = &(tbl->win[idx]); | 1291 | struct il_rate_scale_data *win = &(tbl->win[idx]); |
1286 | u32 sz = (sizeof(struct il_scale_tbl_info) - | 1292 | u32 sz = |
1287 | (sizeof(struct il_rate_scale_data) * RATE_COUNT)); | 1293 | (sizeof(struct il_scale_tbl_info) - |
1294 | (sizeof(struct il_rate_scale_data) * RATE_COUNT)); | ||
1288 | u8 start_action; | 1295 | u8 start_action; |
1289 | u8 valid_tx_ant = il->hw_params.valid_tx_ant; | 1296 | u8 valid_tx_ant = il->hw_params.valid_tx_ant; |
1290 | u8 tx_chains_num = il->hw_params.tx_chains_num; | 1297 | u8 tx_chains_num = il->hw_params.tx_chains_num; |
@@ -1294,7 +1301,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, | |||
1294 | tbl->action = IL_LEGACY_SWITCH_SISO; | 1301 | tbl->action = IL_LEGACY_SWITCH_SISO; |
1295 | 1302 | ||
1296 | start_action = tbl->action; | 1303 | start_action = tbl->action; |
1297 | for (; ;) { | 1304 | for (;;) { |
1298 | lq_sta->action_counter++; | 1305 | lq_sta->action_counter++; |
1299 | switch (tbl->action) { | 1306 | switch (tbl->action) { |
1300 | case IL_LEGACY_SWITCH_ANTENNA1: | 1307 | case IL_LEGACY_SWITCH_ANTENNA1: |
@@ -1302,9 +1309,9 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, | |||
1302 | D_RATE("LQ: Legacy toggle Antenna\n"); | 1309 | D_RATE("LQ: Legacy toggle Antenna\n"); |
1303 | 1310 | ||
1304 | if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && | 1311 | if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && |
1305 | tx_chains_num <= 1) || | 1312 | tx_chains_num <= 1) || |
1306 | (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && | 1313 | (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && |
1307 | tx_chains_num <= 2)) | 1314 | tx_chains_num <= 2)) |
1308 | break; | 1315 | break; |
1309 | 1316 | ||
1310 | /* Don't change antenna if success has been great */ | 1317 | /* Don't change antenna if success has been great */ |
@@ -1314,11 +1321,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, | |||
1314 | /* Set up search table to try other antenna */ | 1321 | /* Set up search table to try other antenna */ |
1315 | memcpy(search_tbl, tbl, sz); | 1322 | memcpy(search_tbl, tbl, sz); |
1316 | 1323 | ||
1317 | if (il4965_rs_toggle_antenna(valid_tx_ant, | 1324 | if (il4965_rs_toggle_antenna |
1318 | &search_tbl->current_rate, search_tbl)) { | 1325 | (valid_tx_ant, &search_tbl->current_rate, |
1326 | search_tbl)) { | ||
1319 | update_search_tbl_counter = 1; | 1327 | update_search_tbl_counter = 1; |
1320 | il4965_rs_set_expected_tpt_table(lq_sta, | 1328 | il4965_rs_set_expected_tpt_table(lq_sta, |
1321 | search_tbl); | 1329 | search_tbl); |
1322 | goto out; | 1330 | goto out; |
1323 | } | 1331 | } |
1324 | break; | 1332 | break; |
@@ -1328,8 +1336,9 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, | |||
1328 | /* Set up search table to try SISO */ | 1336 | /* Set up search table to try SISO */ |
1329 | memcpy(search_tbl, tbl, sz); | 1337 | memcpy(search_tbl, tbl, sz); |
1330 | search_tbl->is_SGI = 0; | 1338 | search_tbl->is_SGI = 0; |
1331 | ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, | 1339 | ret = |
1332 | search_tbl, idx); | 1340 | il4965_rs_switch_to_siso(il, lq_sta, conf, sta, |
1341 | search_tbl, idx); | ||
1333 | if (!ret) { | 1342 | if (!ret) { |
1334 | lq_sta->action_counter = 0; | 1343 | lq_sta->action_counter = 0; |
1335 | goto out; | 1344 | goto out; |
@@ -1352,13 +1361,13 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, | |||
1352 | else | 1361 | else |
1353 | search_tbl->ant_type = ANT_BC; | 1362 | search_tbl->ant_type = ANT_BC; |
1354 | 1363 | ||
1355 | if (!il4965_rs_is_valid_ant(valid_tx_ant, | 1364 | if (!il4965_rs_is_valid_ant |
1356 | search_tbl->ant_type)) | 1365 | (valid_tx_ant, search_tbl->ant_type)) |
1357 | break; | 1366 | break; |
1358 | 1367 | ||
1359 | ret = il4965_rs_switch_to_mimo2(il, lq_sta, | 1368 | ret = |
1360 | conf, sta, | 1369 | il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, |
1361 | search_tbl, idx); | 1370 | search_tbl, idx); |
1362 | if (!ret) { | 1371 | if (!ret) { |
1363 | lq_sta->action_counter = 0; | 1372 | lq_sta->action_counter = 0; |
1364 | goto out; | 1373 | goto out; |
@@ -1390,19 +1399,20 @@ out: | |||
1390 | /* | 1399 | /* |
1391 | * Try to switch to new modulation mode from SISO | 1400 | * Try to switch to new modulation mode from SISO |
1392 | */ | 1401 | */ |
1393 | static int il4965_rs_move_siso_to_other(struct il_priv *il, | 1402 | static int |
1394 | struct il_lq_sta *lq_sta, | 1403 | il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, |
1395 | struct ieee80211_conf *conf, | 1404 | struct ieee80211_conf *conf, |
1396 | struct ieee80211_sta *sta, int idx) | 1405 | struct ieee80211_sta *sta, int idx) |
1397 | { | 1406 | { |
1398 | u8 is_green = lq_sta->is_green; | 1407 | u8 is_green = lq_sta->is_green; |
1399 | struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1408 | struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
1400 | struct il_scale_tbl_info *search_tbl = | 1409 | struct il_scale_tbl_info *search_tbl = |
1401 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); | 1410 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
1402 | struct il_rate_scale_data *win = &(tbl->win[idx]); | 1411 | struct il_rate_scale_data *win = &(tbl->win[idx]); |
1403 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; | 1412 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; |
1404 | u32 sz = (sizeof(struct il_scale_tbl_info) - | 1413 | u32 sz = |
1405 | (sizeof(struct il_rate_scale_data) * RATE_COUNT)); | 1414 | (sizeof(struct il_scale_tbl_info) - |
1415 | (sizeof(struct il_rate_scale_data) * RATE_COUNT)); | ||
1406 | u8 start_action; | 1416 | u8 start_action; |
1407 | u8 valid_tx_ant = il->hw_params.valid_tx_ant; | 1417 | u8 valid_tx_ant = il->hw_params.valid_tx_ant; |
1408 | u8 tx_chains_num = il->hw_params.tx_chains_num; | 1418 | u8 tx_chains_num = il->hw_params.tx_chains_num; |
@@ -1418,17 +1428,18 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, | |||
1418 | case IL_SISO_SWITCH_ANTENNA2: | 1428 | case IL_SISO_SWITCH_ANTENNA2: |
1419 | D_RATE("LQ: SISO toggle Antenna\n"); | 1429 | D_RATE("LQ: SISO toggle Antenna\n"); |
1420 | if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && | 1430 | if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && |
1421 | tx_chains_num <= 1) || | 1431 | tx_chains_num <= 1) || |
1422 | (tbl->action == IL_SISO_SWITCH_ANTENNA2 && | 1432 | (tbl->action == IL_SISO_SWITCH_ANTENNA2 && |
1423 | tx_chains_num <= 2)) | 1433 | tx_chains_num <= 2)) |
1424 | break; | 1434 | break; |
1425 | 1435 | ||
1426 | if (win->success_ratio >= IL_RS_GOOD_RATIO) | 1436 | if (win->success_ratio >= IL_RS_GOOD_RATIO) |
1427 | break; | 1437 | break; |
1428 | 1438 | ||
1429 | memcpy(search_tbl, tbl, sz); | 1439 | memcpy(search_tbl, tbl, sz); |
1430 | if (il4965_rs_toggle_antenna(valid_tx_ant, | 1440 | if (il4965_rs_toggle_antenna |
1431 | &search_tbl->current_rate, search_tbl)) { | 1441 | (valid_tx_ant, &search_tbl->current_rate, |
1442 | search_tbl)) { | ||
1432 | update_search_tbl_counter = 1; | 1443 | update_search_tbl_counter = 1; |
1433 | goto out; | 1444 | goto out; |
1434 | } | 1445 | } |
@@ -1447,22 +1458,22 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, | |||
1447 | else | 1458 | else |
1448 | search_tbl->ant_type = ANT_BC; | 1459 | search_tbl->ant_type = ANT_BC; |
1449 | 1460 | ||
1450 | if (!il4965_rs_is_valid_ant(valid_tx_ant, | 1461 | if (!il4965_rs_is_valid_ant |
1451 | search_tbl->ant_type)) | 1462 | (valid_tx_ant, search_tbl->ant_type)) |
1452 | break; | 1463 | break; |
1453 | 1464 | ||
1454 | ret = il4965_rs_switch_to_mimo2(il, lq_sta, | 1465 | ret = |
1455 | conf, sta, | 1466 | il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, |
1456 | search_tbl, idx); | 1467 | search_tbl, idx); |
1457 | if (!ret) | 1468 | if (!ret) |
1458 | goto out; | 1469 | goto out; |
1459 | break; | 1470 | break; |
1460 | case IL_SISO_SWITCH_GI: | 1471 | case IL_SISO_SWITCH_GI: |
1461 | if (!tbl->is_ht40 && !(ht_cap->cap & | 1472 | if (!tbl->is_ht40 && |
1462 | IEEE80211_HT_CAP_SGI_20)) | 1473 | !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) |
1463 | break; | 1474 | break; |
1464 | if (tbl->is_ht40 && !(ht_cap->cap & | 1475 | if (tbl->is_ht40 && |
1465 | IEEE80211_HT_CAP_SGI_40)) | 1476 | !(ht_cap->cap & IEEE80211_HT_CAP_SGI_40)) |
1466 | break; | 1477 | break; |
1467 | 1478 | ||
1468 | D_RATE("LQ: SISO toggle SGI/NGI\n"); | 1479 | D_RATE("LQ: SISO toggle SGI/NGI\n"); |
@@ -1472,8 +1483,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, | |||
1472 | if (!tbl->is_SGI) | 1483 | if (!tbl->is_SGI) |
1473 | break; | 1484 | break; |
1474 | else | 1485 | else |
1475 | IL_ERR( | 1486 | IL_ERR("SGI was set in GF+SISO\n"); |
1476 | "SGI was set in GF+SISO\n"); | ||
1477 | } | 1487 | } |
1478 | search_tbl->is_SGI = !tbl->is_SGI; | 1488 | search_tbl->is_SGI = !tbl->is_SGI; |
1479 | il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); | 1489 | il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); |
@@ -1483,8 +1493,8 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, | |||
1483 | break; | 1493 | break; |
1484 | } | 1494 | } |
1485 | search_tbl->current_rate = | 1495 | search_tbl->current_rate = |
1486 | il4965_rate_n_flags_from_tbl(il, search_tbl, | 1496 | il4965_rate_n_flags_from_tbl(il, search_tbl, idx, |
1487 | idx, is_green); | 1497 | is_green); |
1488 | update_search_tbl_counter = 1; | 1498 | update_search_tbl_counter = 1; |
1489 | goto out; | 1499 | goto out; |
1490 | } | 1500 | } |
@@ -1498,7 +1508,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, | |||
1498 | search_tbl->lq_type = LQ_NONE; | 1508 | search_tbl->lq_type = LQ_NONE; |
1499 | return 0; | 1509 | return 0; |
1500 | 1510 | ||
1501 | out: | 1511 | out: |
1502 | lq_sta->search_better_tbl = 1; | 1512 | lq_sta->search_better_tbl = 1; |
1503 | tbl->action++; | 1513 | tbl->action++; |
1504 | if (tbl->action > IL_SISO_SWITCH_GI) | 1514 | if (tbl->action > IL_SISO_SWITCH_GI) |
@@ -1512,19 +1522,20 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, | |||
1512 | /* | 1522 | /* |
1513 | * Try to switch to new modulation mode from MIMO2 | 1523 | * Try to switch to new modulation mode from MIMO2 |
1514 | */ | 1524 | */ |
1515 | static int il4965_rs_move_mimo2_to_other(struct il_priv *il, | 1525 | static int |
1516 | struct il_lq_sta *lq_sta, | 1526 | il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, |
1517 | struct ieee80211_conf *conf, | 1527 | struct ieee80211_conf *conf, |
1518 | struct ieee80211_sta *sta, int idx) | 1528 | struct ieee80211_sta *sta, int idx) |
1519 | { | 1529 | { |
1520 | s8 is_green = lq_sta->is_green; | 1530 | s8 is_green = lq_sta->is_green; |
1521 | struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1531 | struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
1522 | struct il_scale_tbl_info *search_tbl = | 1532 | struct il_scale_tbl_info *search_tbl = |
1523 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); | 1533 | &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
1524 | struct il_rate_scale_data *win = &(tbl->win[idx]); | 1534 | struct il_rate_scale_data *win = &(tbl->win[idx]); |
1525 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; | 1535 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; |
1526 | u32 sz = (sizeof(struct il_scale_tbl_info) - | 1536 | u32 sz = |
1527 | (sizeof(struct il_rate_scale_data) * RATE_COUNT)); | 1537 | (sizeof(struct il_scale_tbl_info) - |
1538 | (sizeof(struct il_rate_scale_data) * RATE_COUNT)); | ||
1528 | u8 start_action; | 1539 | u8 start_action; |
1529 | u8 valid_tx_ant = il->hw_params.valid_tx_ant; | 1540 | u8 valid_tx_ant = il->hw_params.valid_tx_ant; |
1530 | u8 tx_chains_num = il->hw_params.tx_chains_num; | 1541 | u8 tx_chains_num = il->hw_params.tx_chains_num; |
@@ -1546,8 +1557,9 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, | |||
1546 | break; | 1557 | break; |
1547 | 1558 | ||
1548 | memcpy(search_tbl, tbl, sz); | 1559 | memcpy(search_tbl, tbl, sz); |
1549 | if (il4965_rs_toggle_antenna(valid_tx_ant, | 1560 | if (il4965_rs_toggle_antenna |
1550 | &search_tbl->current_rate, search_tbl)) { | 1561 | (valid_tx_ant, &search_tbl->current_rate, |
1562 | search_tbl)) { | ||
1551 | update_search_tbl_counter = 1; | 1563 | update_search_tbl_counter = 1; |
1552 | goto out; | 1564 | goto out; |
1553 | } | 1565 | } |
@@ -1567,24 +1579,24 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, | |||
1567 | else | 1579 | else |
1568 | search_tbl->ant_type = ANT_C; | 1580 | search_tbl->ant_type = ANT_C; |
1569 | 1581 | ||
1570 | if (!il4965_rs_is_valid_ant(valid_tx_ant, | 1582 | if (!il4965_rs_is_valid_ant |
1571 | search_tbl->ant_type)) | 1583 | (valid_tx_ant, search_tbl->ant_type)) |
1572 | break; | 1584 | break; |
1573 | 1585 | ||
1574 | ret = il4965_rs_switch_to_siso(il, lq_sta, | 1586 | ret = |
1575 | conf, sta, | 1587 | il4965_rs_switch_to_siso(il, lq_sta, conf, sta, |
1576 | search_tbl, idx); | 1588 | search_tbl, idx); |
1577 | if (!ret) | 1589 | if (!ret) |
1578 | goto out; | 1590 | goto out; |
1579 | 1591 | ||
1580 | break; | 1592 | break; |
1581 | 1593 | ||
1582 | case IL_MIMO2_SWITCH_GI: | 1594 | case IL_MIMO2_SWITCH_GI: |
1583 | if (!tbl->is_ht40 && !(ht_cap->cap & | 1595 | if (!tbl->is_ht40 && |
1584 | IEEE80211_HT_CAP_SGI_20)) | 1596 | !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) |
1585 | break; | 1597 | break; |
1586 | if (tbl->is_ht40 && !(ht_cap->cap & | 1598 | if (tbl->is_ht40 && |
1587 | IEEE80211_HT_CAP_SGI_40)) | 1599 | !(ht_cap->cap & IEEE80211_HT_CAP_SGI_40)) |
1588 | break; | 1600 | break; |
1589 | 1601 | ||
1590 | D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); | 1602 | D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); |
@@ -1605,8 +1617,8 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, | |||
1605 | break; | 1617 | break; |
1606 | } | 1618 | } |
1607 | search_tbl->current_rate = | 1619 | search_tbl->current_rate = |
1608 | il4965_rate_n_flags_from_tbl(il, search_tbl, | 1620 | il4965_rate_n_flags_from_tbl(il, search_tbl, idx, |
1609 | idx, is_green); | 1621 | is_green); |
1610 | update_search_tbl_counter = 1; | 1622 | update_search_tbl_counter = 1; |
1611 | goto out; | 1623 | goto out; |
1612 | 1624 | ||
@@ -1620,7 +1632,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, | |||
1620 | } | 1632 | } |
1621 | search_tbl->lq_type = LQ_NONE; | 1633 | search_tbl->lq_type = LQ_NONE; |
1622 | return 0; | 1634 | return 0; |
1623 | out: | 1635 | out: |
1624 | lq_sta->search_better_tbl = 1; | 1636 | lq_sta->search_better_tbl = 1; |
1625 | tbl->action++; | 1637 | tbl->action++; |
1626 | if (tbl->action > IL_MIMO2_SWITCH_GI) | 1638 | if (tbl->action > IL_MIMO2_SWITCH_GI) |
@@ -1659,9 +1671,9 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) | |||
1659 | /* Elapsed time using current modulation mode */ | 1671 | /* Elapsed time using current modulation mode */ |
1660 | if (lq_sta->flush_timer) | 1672 | if (lq_sta->flush_timer) |
1661 | flush_interval_passed = | 1673 | flush_interval_passed = |
1662 | time_after(jiffies, | 1674 | time_after(jiffies, |
1663 | (unsigned long)(lq_sta->flush_timer + | 1675 | (unsigned long)(lq_sta->flush_timer + |
1664 | RATE_SCALE_FLUSH_INTVL)); | 1676 | RATE_SCALE_FLUSH_INTVL)); |
1665 | 1677 | ||
1666 | /* | 1678 | /* |
1667 | * Check if we should allow search for new modulation mode. | 1679 | * Check if we should allow search for new modulation mode. |
@@ -1677,9 +1689,8 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) | |||
1677 | (!lq_sta->search_better_tbl && lq_sta->flush_timer && | 1689 | (!lq_sta->search_better_tbl && lq_sta->flush_timer && |
1678 | flush_interval_passed)) { | 1690 | flush_interval_passed)) { |
1679 | D_RATE("LQ: stay is expired %d %d %d\n:", | 1691 | D_RATE("LQ: stay is expired %d %d %d\n:", |
1680 | lq_sta->total_failed, | 1692 | lq_sta->total_failed, lq_sta->total_success, |
1681 | lq_sta->total_success, | 1693 | flush_interval_passed); |
1682 | flush_interval_passed); | ||
1683 | 1694 | ||
1684 | /* Allow search for new mode */ | 1695 | /* Allow search for new mode */ |
1685 | lq_sta->stay_in_tbl = 0; /* only place reset */ | 1696 | lq_sta->stay_in_tbl = 0; /* only place reset */ |
@@ -1687,23 +1698,23 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) | |||
1687 | lq_sta->total_success = 0; | 1698 | lq_sta->total_success = 0; |
1688 | lq_sta->flush_timer = 0; | 1699 | lq_sta->flush_timer = 0; |
1689 | 1700 | ||
1690 | /* | 1701 | /* |
1691 | * Else if we've used this modulation mode enough repetitions | 1702 | * Else if we've used this modulation mode enough repetitions |
1692 | * (regardless of elapsed time or success/failure), reset | 1703 | * (regardless of elapsed time or success/failure), reset |
1693 | * history bitmaps and rate-specific stats for all rates in | 1704 | * history bitmaps and rate-specific stats for all rates in |
1694 | * active table. | 1705 | * active table. |
1695 | */ | 1706 | */ |
1696 | } else { | 1707 | } else { |
1697 | lq_sta->table_count++; | 1708 | lq_sta->table_count++; |
1698 | if (lq_sta->table_count >= | 1709 | if (lq_sta->table_count >= lq_sta->table_count_limit) { |
1699 | lq_sta->table_count_limit) { | ||
1700 | lq_sta->table_count = 0; | 1710 | lq_sta->table_count = 0; |
1701 | 1711 | ||
1702 | D_RATE( | 1712 | D_RATE("LQ: stay in table clear win\n"); |
1703 | "LQ: stay in table clear win\n"); | ||
1704 | for (i = 0; i < RATE_COUNT; i++) | 1713 | for (i = 0; i < RATE_COUNT; i++) |
1705 | il4965_rs_rate_scale_clear_win( | 1714 | il4965_rs_rate_scale_clear_win(& |
1706 | &(tbl->win[i])); | 1715 | (tbl-> |
1716 | win | ||
1717 | [i])); | ||
1707 | } | 1718 | } |
1708 | } | 1719 | } |
1709 | 1720 | ||
@@ -1712,8 +1723,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) | |||
1712 | * "search" table). */ | 1723 | * "search" table). */ |
1713 | if (!lq_sta->stay_in_tbl) { | 1724 | if (!lq_sta->stay_in_tbl) { |
1714 | for (i = 0; i < RATE_COUNT; i++) | 1725 | for (i = 0; i < RATE_COUNT; i++) |
1715 | il4965_rs_rate_scale_clear_win( | 1726 | il4965_rs_rate_scale_clear_win(&(tbl->win[i])); |
1716 | &(tbl->win[i])); | ||
1717 | } | 1727 | } |
1718 | } | 1728 | } |
1719 | } | 1729 | } |
@@ -1722,11 +1732,10 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) | |||
1722 | * setup rate table in uCode | 1732 | * setup rate table in uCode |
1723 | * return rate_n_flags as used in the table | 1733 | * return rate_n_flags as used in the table |
1724 | */ | 1734 | */ |
1725 | static u32 il4965_rs_update_rate_tbl(struct il_priv *il, | 1735 | static u32 |
1726 | struct il_rxon_context *ctx, | 1736 | il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, |
1727 | struct il_lq_sta *lq_sta, | 1737 | struct il_lq_sta *lq_sta, |
1728 | struct il_scale_tbl_info *tbl, | 1738 | struct il_scale_tbl_info *tbl, int idx, u8 is_green) |
1729 | int idx, u8 is_green) | ||
1730 | { | 1739 | { |
1731 | u32 rate; | 1740 | u32 rate; |
1732 | 1741 | ||
@@ -1741,10 +1750,10 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *il, | |||
1741 | /* | 1750 | /* |
1742 | * Do rate scaling and search for new modulation mode. | 1751 | * Do rate scaling and search for new modulation mode. |
1743 | */ | 1752 | */ |
1744 | static void il4965_rs_rate_scale_perform(struct il_priv *il, | 1753 | static void |
1745 | struct sk_buff *skb, | 1754 | il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, |
1746 | struct ieee80211_sta *sta, | 1755 | struct ieee80211_sta *sta, |
1747 | struct il_lq_sta *lq_sta) | 1756 | struct il_lq_sta *lq_sta) |
1748 | { | 1757 | { |
1749 | struct ieee80211_hw *hw = il->hw; | 1758 | struct ieee80211_hw *hw = il->hw; |
1750 | struct ieee80211_conf *conf = &hw->conf; | 1759 | struct ieee80211_conf *conf = &hw->conf; |
@@ -1818,8 +1827,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1818 | /* current tx rate */ | 1827 | /* current tx rate */ |
1819 | idx = lq_sta->last_txrate_idx; | 1828 | idx = lq_sta->last_txrate_idx; |
1820 | 1829 | ||
1821 | D_RATE("Rate scale idx %d for type %d\n", idx, | 1830 | D_RATE("Rate scale idx %d for type %d\n", idx, tbl->lq_type); |
1822 | tbl->lq_type); | ||
1823 | 1831 | ||
1824 | /* rates available for this association, and for modulation mode */ | 1832 | /* rates available for this association, and for modulation mode */ |
1825 | rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); | 1833 | rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); |
@@ -1830,11 +1838,12 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1830 | if (is_legacy(tbl->lq_type)) { | 1838 | if (is_legacy(tbl->lq_type)) { |
1831 | if (lq_sta->band == IEEE80211_BAND_5GHZ) | 1839 | if (lq_sta->band == IEEE80211_BAND_5GHZ) |
1832 | /* supp_rates has no CCK bits in A mode */ | 1840 | /* supp_rates has no CCK bits in A mode */ |
1833 | rate_scale_idx_msk = (u16) (rate_mask & | 1841 | rate_scale_idx_msk = |
1834 | (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); | 1842 | (u16) (rate_mask & |
1843 | (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); | ||
1835 | else | 1844 | else |
1836 | rate_scale_idx_msk = (u16) (rate_mask & | 1845 | rate_scale_idx_msk = |
1837 | lq_sta->supp_rates); | 1846 | (u16) (rate_mask & lq_sta->supp_rates); |
1838 | 1847 | ||
1839 | } else | 1848 | } else |
1840 | rate_scale_idx_msk = rate_mask; | 1849 | rate_scale_idx_msk = rate_mask; |
@@ -1845,14 +1854,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1845 | if (!((1 << idx) & rate_scale_idx_msk)) { | 1854 | if (!((1 << idx) & rate_scale_idx_msk)) { |
1846 | IL_ERR("Current Rate is not valid\n"); | 1855 | IL_ERR("Current Rate is not valid\n"); |
1847 | if (lq_sta->search_better_tbl) { | 1856 | if (lq_sta->search_better_tbl) { |
1848 | /* revert to active table if search table is not valid*/ | 1857 | /* revert to active table if search table is not valid */ |
1849 | tbl->lq_type = LQ_NONE; | 1858 | tbl->lq_type = LQ_NONE; |
1850 | lq_sta->search_better_tbl = 0; | 1859 | lq_sta->search_better_tbl = 0; |
1851 | tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); | 1860 | tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); |
1852 | /* get "active" rate info */ | 1861 | /* get "active" rate info */ |
1853 | idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); | 1862 | idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); |
1854 | rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, | 1863 | rate = |
1855 | tbl, idx, is_green); | 1864 | il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, |
1865 | is_green); | ||
1856 | } | 1866 | } |
1857 | return; | 1867 | return; |
1858 | } | 1868 | } |
@@ -1864,8 +1874,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1864 | } | 1874 | } |
1865 | 1875 | ||
1866 | /* force user max rate if set by user */ | 1876 | /* force user max rate if set by user */ |
1867 | if (lq_sta->max_rate_idx != -1 && | 1877 | if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < idx) { |
1868 | lq_sta->max_rate_idx < idx) { | ||
1869 | idx = lq_sta->max_rate_idx; | 1878 | idx = lq_sta->max_rate_idx; |
1870 | update_lq = 1; | 1879 | update_lq = 1; |
1871 | win = &(tbl->win[idx]); | 1880 | win = &(tbl->win[idx]); |
@@ -1884,9 +1893,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1884 | fail_count = win->counter - win->success_counter; | 1893 | fail_count = win->counter - win->success_counter; |
1885 | if (fail_count < RATE_MIN_FAILURE_TH && | 1894 | if (fail_count < RATE_MIN_FAILURE_TH && |
1886 | win->success_counter < RATE_MIN_SUCCESS_TH) { | 1895 | win->success_counter < RATE_MIN_SUCCESS_TH) { |
1887 | D_RATE("LQ: still below TH. succ=%d total=%d " | 1896 | D_RATE("LQ: still below TH. succ=%d total=%d " "for idx %d\n", |
1888 | "for idx %d\n", | 1897 | win->success_counter, win->counter, idx); |
1889 | win->success_counter, win->counter, idx); | ||
1890 | 1898 | ||
1891 | /* Can't calculate this yet; not enough history */ | 1899 | /* Can't calculate this yet; not enough history */ |
1892 | win->average_tpt = IL_INVALID_VALUE; | 1900 | win->average_tpt = IL_INVALID_VALUE; |
@@ -1899,12 +1907,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1899 | } | 1907 | } |
1900 | /* Else we have enough samples; calculate estimate of | 1908 | /* Else we have enough samples; calculate estimate of |
1901 | * actual average throughput */ | 1909 | * actual average throughput */ |
1902 | if (win->average_tpt != ((win->success_ratio * | 1910 | if (win->average_tpt != |
1903 | tbl->expected_tpt[idx] + 64) / 128)) { | 1911 | ((win->success_ratio * tbl->expected_tpt[idx] + 64) / 128)) { |
1904 | IL_ERR( | 1912 | IL_ERR("expected_tpt should have been calculated by now\n"); |
1905 | "expected_tpt should have been calculated by now\n"); | 1913 | win->average_tpt = |
1906 | win->average_tpt = ((win->success_ratio * | 1914 | ((win->success_ratio * tbl->expected_tpt[idx] + 64) / 128); |
1907 | tbl->expected_tpt[idx] + 64) / 128); | ||
1908 | } | 1915 | } |
1909 | 1916 | ||
1910 | /* If we are searching for better modulation mode, check success. */ | 1917 | /* If we are searching for better modulation mode, check success. */ |
@@ -1915,10 +1922,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1915 | if (win->average_tpt > lq_sta->last_tpt) { | 1922 | if (win->average_tpt > lq_sta->last_tpt) { |
1916 | 1923 | ||
1917 | D_RATE("LQ: SWITCHING TO NEW TBL " | 1924 | D_RATE("LQ: SWITCHING TO NEW TBL " |
1918 | "suc=%d cur-tpt=%d old-tpt=%d\n", | 1925 | "suc=%d cur-tpt=%d old-tpt=%d\n", |
1919 | win->success_ratio, | 1926 | win->success_ratio, win->average_tpt, |
1920 | win->average_tpt, | 1927 | lq_sta->last_tpt); |
1921 | lq_sta->last_tpt); | ||
1922 | 1928 | ||
1923 | if (!is_legacy(tbl->lq_type)) | 1929 | if (!is_legacy(tbl->lq_type)) |
1924 | lq_sta->enable_counter = 1; | 1930 | lq_sta->enable_counter = 1; |
@@ -1927,14 +1933,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1927 | lq_sta->active_tbl = active_tbl; | 1933 | lq_sta->active_tbl = active_tbl; |
1928 | current_tpt = win->average_tpt; | 1934 | current_tpt = win->average_tpt; |
1929 | 1935 | ||
1930 | /* Else poor success; go back to mode in "active" table */ | 1936 | /* Else poor success; go back to mode in "active" table */ |
1931 | } else { | 1937 | } else { |
1932 | 1938 | ||
1933 | D_RATE("LQ: GOING BACK TO THE OLD TBL " | 1939 | D_RATE("LQ: GOING BACK TO THE OLD TBL " |
1934 | "suc=%d cur-tpt=%d old-tpt=%d\n", | 1940 | "suc=%d cur-tpt=%d old-tpt=%d\n", |
1935 | win->success_ratio, | 1941 | win->success_ratio, win->average_tpt, |
1936 | win->average_tpt, | 1942 | lq_sta->last_tpt); |
1937 | lq_sta->last_tpt); | ||
1938 | 1943 | ||
1939 | /* Nullify "search" table */ | 1944 | /* Nullify "search" table */ |
1940 | tbl->lq_type = LQ_NONE; | 1945 | tbl->lq_type = LQ_NONE; |
@@ -1960,15 +1965,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1960 | 1965 | ||
1961 | /* (Else) not in search of better modulation mode, try for better | 1966 | /* (Else) not in search of better modulation mode, try for better |
1962 | * starting rate, while staying in this mode. */ | 1967 | * starting rate, while staying in this mode. */ |
1963 | high_low = il4965_rs_get_adjacent_rate(il, idx, | 1968 | high_low = |
1964 | rate_scale_idx_msk, | 1969 | il4965_rs_get_adjacent_rate(il, idx, rate_scale_idx_msk, |
1965 | tbl->lq_type); | 1970 | tbl->lq_type); |
1966 | low = high_low & 0xff; | 1971 | low = high_low & 0xff; |
1967 | high = (high_low >> 8) & 0xff; | 1972 | high = (high_low >> 8) & 0xff; |
1968 | 1973 | ||
1969 | /* If user set max rate, dont allow higher than user constrain */ | 1974 | /* If user set max rate, dont allow higher than user constrain */ |
1970 | if (lq_sta->max_rate_idx != -1 && | 1975 | if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < high) |
1971 | lq_sta->max_rate_idx < high) | ||
1972 | high = RATE_INVALID; | 1976 | high = RATE_INVALID; |
1973 | 1977 | ||
1974 | sr = win->success_ratio; | 1978 | sr = win->success_ratio; |
@@ -1984,13 +1988,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
1984 | 1988 | ||
1985 | /* Too many failures, decrease rate */ | 1989 | /* Too many failures, decrease rate */ |
1986 | if (sr <= RATE_DECREASE_TH || current_tpt == 0) { | 1990 | if (sr <= RATE_DECREASE_TH || current_tpt == 0) { |
1987 | D_RATE( | 1991 | D_RATE("decrease rate because of low success_ratio\n"); |
1988 | "decrease rate because of low success_ratio\n"); | ||
1989 | scale_action = -1; | 1992 | scale_action = -1; |
1990 | 1993 | ||
1991 | /* No throughput measured yet for adjacent rates; try increase. */ | 1994 | /* No throughput measured yet for adjacent rates; try increase. */ |
1992 | } else if (low_tpt == IL_INVALID_VALUE && | 1995 | } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { |
1993 | high_tpt == IL_INVALID_VALUE) { | ||
1994 | 1996 | ||
1995 | if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) | 1997 | if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) |
1996 | scale_action = 1; | 1998 | scale_action = 1; |
@@ -2010,19 +2012,17 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
2010 | /* Higher adjacent rate's throughput is measured */ | 2012 | /* Higher adjacent rate's throughput is measured */ |
2011 | if (high_tpt != IL_INVALID_VALUE) { | 2013 | if (high_tpt != IL_INVALID_VALUE) { |
2012 | /* Higher rate has better throughput */ | 2014 | /* Higher rate has better throughput */ |
2013 | if (high_tpt > current_tpt && | 2015 | if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) { |
2014 | sr >= RATE_INCREASE_TH) { | ||
2015 | scale_action = 1; | 2016 | scale_action = 1; |
2016 | } else { | 2017 | } else { |
2017 | scale_action = 0; | 2018 | scale_action = 0; |
2018 | } | 2019 | } |
2019 | 2020 | ||
2020 | /* Lower adjacent rate's throughput is measured */ | 2021 | /* Lower adjacent rate's throughput is measured */ |
2021 | } else if (low_tpt != IL_INVALID_VALUE) { | 2022 | } else if (low_tpt != IL_INVALID_VALUE) { |
2022 | /* Lower rate has better throughput */ | 2023 | /* Lower rate has better throughput */ |
2023 | if (low_tpt > current_tpt) { | 2024 | if (low_tpt > current_tpt) { |
2024 | D_RATE( | 2025 | D_RATE("decrease rate because of low tpt\n"); |
2025 | "decrease rate because of low tpt\n"); | ||
2026 | scale_action = -1; | 2026 | scale_action = -1; |
2027 | } else if (sr >= RATE_INCREASE_TH) { | 2027 | } else if (sr >= RATE_INCREASE_TH) { |
2028 | scale_action = 1; | 2028 | scale_action = 1; |
@@ -2059,19 +2059,19 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, | |||
2059 | break; | 2059 | break; |
2060 | } | 2060 | } |
2061 | 2061 | ||
2062 | D_RATE("choose rate scale idx %d action %d low %d " | 2062 | D_RATE("choose rate scale idx %d action %d low %d " "high %d type %d\n", |
2063 | "high %d type %d\n", | 2063 | idx, scale_action, low, high, tbl->lq_type); |
2064 | idx, scale_action, low, high, tbl->lq_type); | ||
2065 | 2064 | ||
2066 | lq_update: | 2065 | lq_update: |
2067 | /* Replace uCode's rate table for the destination station. */ | 2066 | /* Replace uCode's rate table for the destination station. */ |
2068 | if (update_lq) | 2067 | if (update_lq) |
2069 | rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, | 2068 | rate = |
2070 | tbl, idx, is_green); | 2069 | il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, |
2070 | is_green); | ||
2071 | 2071 | ||
2072 | /* Should we stay with this modulation mode, | 2072 | /* Should we stay with this modulation mode, |
2073 | * or search for a new one? */ | 2073 | * or search for a new one? */ |
2074 | il4965_rs_stay_in_table(lq_sta, false); | 2074 | il4965_rs_stay_in_table(lq_sta, false); |
2075 | 2075 | ||
2076 | /* | 2076 | /* |
2077 | * Search for new modulation mode if we're: | 2077 | * Search for new modulation mode if we're: |
@@ -2079,41 +2079,35 @@ lq_update: | |||
2079 | * 2) Not just finishing up a search | 2079 | * 2) Not just finishing up a search |
2080 | * 3) Allowing a new search | 2080 | * 3) Allowing a new search |
2081 | */ | 2081 | */ |
2082 | if (!update_lq && !done_search && !lq_sta->stay_in_tbl && | 2082 | if (!update_lq && !done_search && !lq_sta->stay_in_tbl && win->counter) { |
2083 | win->counter) { | 2083 | /* Save current throughput to compare with "search" throughput */ |
2084 | /* Save current throughput to compare with "search" throughput*/ | ||
2085 | lq_sta->last_tpt = current_tpt; | 2084 | lq_sta->last_tpt = current_tpt; |
2086 | 2085 | ||
2087 | /* Select a new "search" modulation mode to try. | 2086 | /* Select a new "search" modulation mode to try. |
2088 | * If one is found, set up the new "search" table. */ | 2087 | * If one is found, set up the new "search" table. */ |
2089 | if (is_legacy(tbl->lq_type)) | 2088 | if (is_legacy(tbl->lq_type)) |
2090 | il4965_rs_move_legacy_other(il, lq_sta, | 2089 | il4965_rs_move_legacy_other(il, lq_sta, conf, sta, idx); |
2091 | conf, sta, idx); | ||
2092 | else if (is_siso(tbl->lq_type)) | 2090 | else if (is_siso(tbl->lq_type)) |
2093 | il4965_rs_move_siso_to_other(il, lq_sta, | 2091 | il4965_rs_move_siso_to_other(il, lq_sta, conf, sta, |
2094 | conf, sta, idx); | 2092 | idx); |
2095 | else /* (is_mimo2(tbl->lq_type)) */ | 2093 | else /* (is_mimo2(tbl->lq_type)) */ |
2096 | il4965_rs_move_mimo2_to_other(il, lq_sta, | 2094 | il4965_rs_move_mimo2_to_other(il, lq_sta, conf, sta, |
2097 | conf, sta, idx); | 2095 | idx); |
2098 | 2096 | ||
2099 | /* If new "search" mode was selected, set up in uCode table */ | 2097 | /* If new "search" mode was selected, set up in uCode table */ |
2100 | if (lq_sta->search_better_tbl) { | 2098 | if (lq_sta->search_better_tbl) { |
2101 | /* Access the "search" table, clear its history. */ | 2099 | /* Access the "search" table, clear its history. */ |
2102 | tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); | 2100 | tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); |
2103 | for (i = 0; i < RATE_COUNT; i++) | 2101 | for (i = 0; i < RATE_COUNT; i++) |
2104 | il4965_rs_rate_scale_clear_win( | 2102 | il4965_rs_rate_scale_clear_win(&(tbl->win[i])); |
2105 | &(tbl->win[i])); | ||
2106 | 2103 | ||
2107 | /* Use new "search" start rate */ | 2104 | /* Use new "search" start rate */ |
2108 | idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); | 2105 | idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); |
2109 | 2106 | ||
2110 | D_RATE( | 2107 | D_RATE("Switch current mcs: %X idx: %d\n", |
2111 | "Switch current mcs: %X idx: %d\n", | 2108 | tbl->current_rate, idx); |
2112 | tbl->current_rate, idx); | 2109 | il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); |
2113 | il4965_rs_fill_link_cmd(il, lq_sta, | 2110 | il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); |
2114 | tbl->current_rate); | ||
2115 | il_send_lq_cmd(il, ctx, | ||
2116 | &lq_sta->lq, CMD_ASYNC, false); | ||
2117 | } else | 2111 | } else |
2118 | done_search = 1; | 2112 | done_search = 1; |
2119 | } | 2113 | } |
@@ -2140,13 +2134,12 @@ lq_update: | |||
2140 | (lq_sta->tx_agg_tid_en & (1 << tid)) && | 2134 | (lq_sta->tx_agg_tid_en & (1 << tid)) && |
2141 | tid != MAX_TID_COUNT) { | 2135 | tid != MAX_TID_COUNT) { |
2142 | tid_data = | 2136 | tid_data = |
2143 | &il->stations[lq_sta->lq.sta_id].tid[tid]; | 2137 | &il->stations[lq_sta->lq.sta_id].tid[tid]; |
2144 | if (tid_data->agg.state == IL_AGG_OFF) { | 2138 | if (tid_data->agg.state == IL_AGG_OFF) { |
2145 | D_RATE( | 2139 | D_RATE("try to aggregate tid %d\n", |
2146 | "try to aggregate tid %d\n", | 2140 | tid); |
2147 | tid); | ||
2148 | il4965_rs_tl_turn_on_agg(il, tid, | 2141 | il4965_rs_tl_turn_on_agg(il, tid, |
2149 | lq_sta, sta); | 2142 | lq_sta, sta); |
2150 | } | 2143 | } |
2151 | } | 2144 | } |
2152 | il4965_rs_set_stay_in_table(il, 0, lq_sta); | 2145 | il4965_rs_set_stay_in_table(il, 0, lq_sta); |
@@ -2154,8 +2147,8 @@ lq_update: | |||
2154 | } | 2147 | } |
2155 | 2148 | ||
2156 | out: | 2149 | out: |
2157 | tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, | 2150 | tbl->current_rate = |
2158 | idx, is_green); | 2151 | il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); |
2159 | i = idx; | 2152 | i = idx; |
2160 | lq_sta->last_txrate_idx = i; | 2153 | lq_sta->last_txrate_idx = i; |
2161 | } | 2154 | } |
@@ -2174,10 +2167,9 @@ out: | |||
2174 | * calling this function (which runs C_TX_LINK_QUALITY_CMD, | 2167 | * calling this function (which runs C_TX_LINK_QUALITY_CMD, |
2175 | * which requires station table entry to exist). | 2168 | * which requires station table entry to exist). |
2176 | */ | 2169 | */ |
2177 | static void il4965_rs_initialize_lq(struct il_priv *il, | 2170 | static void |
2178 | struct ieee80211_conf *conf, | 2171 | il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, |
2179 | struct ieee80211_sta *sta, | 2172 | struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) |
2180 | struct il_lq_sta *lq_sta) | ||
2181 | { | 2173 | { |
2182 | struct il_scale_tbl_info *tbl; | 2174 | struct il_scale_tbl_info *tbl; |
2183 | int rate_idx; | 2175 | int rate_idx; |
@@ -2230,7 +2222,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, | |||
2230 | 2222 | ||
2231 | static void | 2223 | static void |
2232 | il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, | 2224 | il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, |
2233 | struct ieee80211_tx_rate_control *txrc) | 2225 | struct ieee80211_tx_rate_control *txrc) |
2234 | { | 2226 | { |
2235 | 2227 | ||
2236 | struct sk_buff *skb = txrc->skb; | 2228 | struct sk_buff *skb = txrc->skb; |
@@ -2266,28 +2258,28 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, | |||
2266 | if (!lq_sta) | 2258 | if (!lq_sta) |
2267 | return; | 2259 | return; |
2268 | 2260 | ||
2269 | rate_idx = lq_sta->last_txrate_idx; | 2261 | rate_idx = lq_sta->last_txrate_idx; |
2270 | 2262 | ||
2271 | if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { | 2263 | if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { |
2272 | rate_idx -= IL_FIRST_OFDM_RATE; | 2264 | rate_idx -= IL_FIRST_OFDM_RATE; |
2273 | /* 6M and 9M shared same MCS idx */ | 2265 | /* 6M and 9M shared same MCS idx */ |
2274 | rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; | 2266 | rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; |
2275 | if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= | 2267 | if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= |
2276 | RATE_MIMO2_6M_PLCP) | 2268 | RATE_MIMO2_6M_PLCP) |
2277 | rate_idx = rate_idx + MCS_IDX_PER_STREAM; | 2269 | rate_idx = rate_idx + MCS_IDX_PER_STREAM; |
2278 | info->control.rates[0].flags = IEEE80211_TX_RC_MCS; | 2270 | info->control.rates[0].flags = IEEE80211_TX_RC_MCS; |
2279 | if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) | 2271 | if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) |
2280 | info->control.rates[0].flags |= | 2272 | info->control.rates[0].flags |= |
2281 | IEEE80211_TX_RC_SHORT_GI; | 2273 | IEEE80211_TX_RC_SHORT_GI; |
2282 | if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) | 2274 | if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) |
2283 | info->control.rates[0].flags |= | 2275 | info->control.rates[0].flags |= |
2284 | IEEE80211_TX_RC_DUP_DATA; | 2276 | IEEE80211_TX_RC_DUP_DATA; |
2285 | if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) | 2277 | if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) |
2286 | info->control.rates[0].flags |= | 2278 | info->control.rates[0].flags |= |
2287 | IEEE80211_TX_RC_40_MHZ_WIDTH; | 2279 | IEEE80211_TX_RC_40_MHZ_WIDTH; |
2288 | if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) | 2280 | if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) |
2289 | info->control.rates[0].flags |= | 2281 | info->control.rates[0].flags |= |
2290 | IEEE80211_TX_RC_GREEN_FIELD; | 2282 | IEEE80211_TX_RC_GREEN_FIELD; |
2291 | } else { | 2283 | } else { |
2292 | /* Check for invalid rates */ | 2284 | /* Check for invalid rates */ |
2293 | if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || | 2285 | if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || |
@@ -2303,12 +2295,12 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, | |||
2303 | 2295 | ||
2304 | } | 2296 | } |
2305 | 2297 | ||
2306 | static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, | 2298 | static void * |
2307 | gfp_t gfp) | 2299 | il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) |
2308 | { | 2300 | { |
2309 | struct il_lq_sta *lq_sta; | 2301 | struct il_lq_sta *lq_sta; |
2310 | struct il_station_priv *sta_priv = | 2302 | struct il_station_priv *sta_priv = |
2311 | (struct il_station_priv *) sta->drv_priv; | 2303 | (struct il_station_priv *)sta->drv_priv; |
2312 | struct il_priv *il; | 2304 | struct il_priv *il; |
2313 | 2305 | ||
2314 | il = (struct il_priv *)il_rate; | 2306 | il = (struct il_priv *)il_rate; |
@@ -2323,9 +2315,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, | |||
2323 | * Called after adding a new station to initialize rate scaling | 2315 | * Called after adding a new station to initialize rate scaling |
2324 | */ | 2316 | */ |
2325 | void | 2317 | void |
2326 | il4965_rs_rate_init(struct il_priv *il, | 2318 | il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) |
2327 | struct ieee80211_sta *sta, | ||
2328 | u8 sta_id) | ||
2329 | { | 2319 | { |
2330 | int i, j; | 2320 | int i, j; |
2331 | struct ieee80211_hw *hw = il->hw; | 2321 | struct ieee80211_hw *hw = il->hw; |
@@ -2335,28 +2325,26 @@ il4965_rs_rate_init(struct il_priv *il, | |||
2335 | struct il_lq_sta *lq_sta; | 2325 | struct il_lq_sta *lq_sta; |
2336 | struct ieee80211_supported_band *sband; | 2326 | struct ieee80211_supported_band *sband; |
2337 | 2327 | ||
2338 | sta_priv = (struct il_station_priv *) sta->drv_priv; | 2328 | sta_priv = (struct il_station_priv *)sta->drv_priv; |
2339 | lq_sta = &sta_priv->lq_sta; | 2329 | lq_sta = &sta_priv->lq_sta; |
2340 | sband = hw->wiphy->bands[conf->channel->band]; | 2330 | sband = hw->wiphy->bands[conf->channel->band]; |
2341 | 2331 | ||
2342 | |||
2343 | lq_sta->lq.sta_id = sta_id; | 2332 | lq_sta->lq.sta_id = sta_id; |
2344 | 2333 | ||
2345 | for (j = 0; j < LQ_SIZE; j++) | 2334 | for (j = 0; j < LQ_SIZE; j++) |
2346 | for (i = 0; i < RATE_COUNT; i++) | 2335 | for (i = 0; i < RATE_COUNT; i++) |
2347 | il4965_rs_rate_scale_clear_win( | 2336 | il4965_rs_rate_scale_clear_win(&lq_sta->lq_info[j]. |
2348 | &lq_sta->lq_info[j].win[i]); | 2337 | win[i]); |
2349 | 2338 | ||
2350 | lq_sta->flush_timer = 0; | 2339 | lq_sta->flush_timer = 0; |
2351 | lq_sta->supp_rates = sta->supp_rates[sband->band]; | 2340 | lq_sta->supp_rates = sta->supp_rates[sband->band]; |
2352 | for (j = 0; j < LQ_SIZE; j++) | 2341 | for (j = 0; j < LQ_SIZE; j++) |
2353 | for (i = 0; i < RATE_COUNT; i++) | 2342 | for (i = 0; i < RATE_COUNT; i++) |
2354 | il4965_rs_rate_scale_clear_win( | 2343 | il4965_rs_rate_scale_clear_win(&lq_sta->lq_info[j]. |
2355 | &lq_sta->lq_info[j].win[i]); | 2344 | win[i]); |
2356 | 2345 | ||
2357 | D_RATE("LQ:" | 2346 | D_RATE("LQ:" "*** rate scale station global init for station %d ***\n", |
2358 | "*** rate scale station global init for station %d ***\n", | 2347 | sta_id); |
2359 | sta_id); | ||
2360 | /* TODO: what is a good starting rate for STA? About middle? Maybe not | 2348 | /* TODO: what is a good starting rate for STA? About middle? Maybe not |
2361 | * the lowest or the highest rate.. Could consider using RSSI from | 2349 | * the lowest or the highest rate.. Could consider using RSSI from |
2362 | * previous packets? Need to have IEEE 802.1X auth succeed immediately | 2350 | * previous packets? Need to have IEEE 802.1X auth succeed immediately |
@@ -2374,26 +2362,26 @@ il4965_rs_rate_init(struct il_priv *il, | |||
2374 | */ | 2362 | */ |
2375 | lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; | 2363 | lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; |
2376 | lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; | 2364 | lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; |
2377 | lq_sta->active_siso_rate &= ~((u16)0x2); | 2365 | lq_sta->active_siso_rate &= ~((u16) 0x2); |
2378 | lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; | 2366 | lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; |
2379 | 2367 | ||
2380 | /* Same here */ | 2368 | /* Same here */ |
2381 | lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; | 2369 | lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; |
2382 | lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; | 2370 | lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; |
2383 | lq_sta->active_mimo2_rate &= ~((u16)0x2); | 2371 | lq_sta->active_mimo2_rate &= ~((u16) 0x2); |
2384 | lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; | 2372 | lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; |
2385 | 2373 | ||
2386 | /* These values will be overridden later */ | 2374 | /* These values will be overridden later */ |
2387 | lq_sta->lq.general_params.single_stream_ant_msk = | 2375 | lq_sta->lq.general_params.single_stream_ant_msk = |
2388 | il4965_first_antenna(il->hw_params.valid_tx_ant); | 2376 | il4965_first_antenna(il->hw_params.valid_tx_ant); |
2389 | lq_sta->lq.general_params.dual_stream_ant_msk = | 2377 | lq_sta->lq.general_params.dual_stream_ant_msk = |
2390 | il->hw_params.valid_tx_ant & | 2378 | il->hw_params.valid_tx_ant & ~il4965_first_antenna(il->hw_params. |
2391 | ~il4965_first_antenna(il->hw_params.valid_tx_ant); | 2379 | valid_tx_ant); |
2392 | if (!lq_sta->lq.general_params.dual_stream_ant_msk) { | 2380 | if (!lq_sta->lq.general_params.dual_stream_ant_msk) { |
2393 | lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; | 2381 | lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; |
2394 | } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { | 2382 | } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { |
2395 | lq_sta->lq.general_params.dual_stream_ant_msk = | 2383 | lq_sta->lq.general_params.dual_stream_ant_msk = |
2396 | il->hw_params.valid_tx_ant; | 2384 | il->hw_params.valid_tx_ant; |
2397 | } | 2385 | } |
2398 | 2386 | ||
2399 | /* as default allow aggregation for all tids */ | 2387 | /* as default allow aggregation for all tids */ |
@@ -2413,8 +2401,9 @@ il4965_rs_rate_init(struct il_priv *il, | |||
2413 | il4965_rs_initialize_lq(il, conf, sta, lq_sta); | 2401 | il4965_rs_initialize_lq(il, conf, sta, lq_sta); |
2414 | } | 2402 | } |
2415 | 2403 | ||
2416 | static void il4965_rs_fill_link_cmd(struct il_priv *il, | 2404 | static void |
2417 | struct il_lq_sta *lq_sta, u32 new_rate) | 2405 | il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, |
2406 | u32 new_rate) | ||
2418 | { | 2407 | { |
2419 | struct il_scale_tbl_info tbl_type; | 2408 | struct il_scale_tbl_info tbl_type; |
2420 | int idx = 0; | 2409 | int idx = 0; |
@@ -2429,8 +2418,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2429 | il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); | 2418 | il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); |
2430 | 2419 | ||
2431 | /* Interpret new_rate (rate_n_flags) */ | 2420 | /* Interpret new_rate (rate_n_flags) */ |
2432 | il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, | 2421 | il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, |
2433 | &tbl_type, &rate_idx); | 2422 | &rate_idx); |
2434 | 2423 | ||
2435 | /* How many times should we repeat the initial rate? */ | 2424 | /* How many times should we repeat the initial rate? */ |
2436 | if (is_legacy(tbl_type.lq_type)) { | 2425 | if (is_legacy(tbl_type.lq_type)) { |
@@ -2441,19 +2430,18 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2441 | } | 2430 | } |
2442 | 2431 | ||
2443 | lq_cmd->general_params.mimo_delimiter = | 2432 | lq_cmd->general_params.mimo_delimiter = |
2444 | is_mimo(tbl_type.lq_type) ? 1 : 0; | 2433 | is_mimo(tbl_type.lq_type) ? 1 : 0; |
2445 | 2434 | ||
2446 | /* Fill 1st table entry (idx 0) */ | 2435 | /* Fill 1st table entry (idx 0) */ |
2447 | lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); | 2436 | lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); |
2448 | 2437 | ||
2449 | if (il4965_num_of_ant(tbl_type.ant_type) == 1) { | 2438 | if (il4965_num_of_ant(tbl_type.ant_type) == 1) { |
2450 | lq_cmd->general_params.single_stream_ant_msk = | 2439 | lq_cmd->general_params.single_stream_ant_msk = |
2451 | tbl_type.ant_type; | 2440 | tbl_type.ant_type; |
2452 | } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { | 2441 | } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { |
2453 | lq_cmd->general_params.dual_stream_ant_msk = | 2442 | lq_cmd->general_params.dual_stream_ant_msk = tbl_type.ant_type; |
2454 | tbl_type.ant_type; | 2443 | } |
2455 | } /* otherwise we don't modify the existing value */ | 2444 | /* otherwise we don't modify the existing value */ |
2456 | |||
2457 | idx++; | 2445 | idx++; |
2458 | repeat_rate--; | 2446 | repeat_rate--; |
2459 | if (il) | 2447 | if (il) |
@@ -2470,7 +2458,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2470 | ant_toggle_cnt++; | 2458 | ant_toggle_cnt++; |
2471 | else if (il && | 2459 | else if (il && |
2472 | il4965_rs_toggle_antenna(valid_tx_ant, | 2460 | il4965_rs_toggle_antenna(valid_tx_ant, |
2473 | &new_rate, &tbl_type)) | 2461 | &new_rate, |
2462 | &tbl_type)) | ||
2474 | ant_toggle_cnt = 1; | 2463 | ant_toggle_cnt = 1; |
2475 | } | 2464 | } |
2476 | 2465 | ||
@@ -2479,14 +2468,13 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2479 | 2468 | ||
2480 | /* Fill next table entry */ | 2469 | /* Fill next table entry */ |
2481 | lq_cmd->rs_table[idx].rate_n_flags = | 2470 | lq_cmd->rs_table[idx].rate_n_flags = |
2482 | cpu_to_le32(new_rate); | 2471 | cpu_to_le32(new_rate); |
2483 | repeat_rate--; | 2472 | repeat_rate--; |
2484 | idx++; | 2473 | idx++; |
2485 | } | 2474 | } |
2486 | 2475 | ||
2487 | il4965_rs_get_tbl_info_from_mcs(new_rate, | 2476 | il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, |
2488 | lq_sta->band, &tbl_type, | 2477 | &tbl_type, &rate_idx); |
2489 | &rate_idx); | ||
2490 | 2478 | ||
2491 | /* Indicate to uCode which entries might be MIMO. | 2479 | /* Indicate to uCode which entries might be MIMO. |
2492 | * If initial rate was MIMO, this will finally end up | 2480 | * If initial rate was MIMO, this will finally end up |
@@ -2495,8 +2483,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2495 | lq_cmd->general_params.mimo_delimiter = idx; | 2483 | lq_cmd->general_params.mimo_delimiter = idx; |
2496 | 2484 | ||
2497 | /* Get next rate */ | 2485 | /* Get next rate */ |
2498 | new_rate = il4965_rs_get_lower_rate(lq_sta, | 2486 | new_rate = |
2499 | &tbl_type, rate_idx, | 2487 | il4965_rs_get_lower_rate(lq_sta, &tbl_type, rate_idx, |
2500 | use_ht_possible); | 2488 | use_ht_possible); |
2501 | 2489 | ||
2502 | /* How many times should we repeat the next rate? */ | 2490 | /* How many times should we repeat the next rate? */ |
@@ -2505,7 +2493,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2505 | ant_toggle_cnt++; | 2493 | ant_toggle_cnt++; |
2506 | else if (il && | 2494 | else if (il && |
2507 | il4965_rs_toggle_antenna(valid_tx_ant, | 2495 | il4965_rs_toggle_antenna(valid_tx_ant, |
2508 | &new_rate, &tbl_type)) | 2496 | &new_rate, &tbl_type)) |
2509 | ant_toggle_cnt = 1; | 2497 | ant_toggle_cnt = 1; |
2510 | 2498 | ||
2511 | repeat_rate = IL_NUMBER_TRY; | 2499 | repeat_rate = IL_NUMBER_TRY; |
@@ -2531,22 +2519,24 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, | |||
2531 | lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; | 2519 | lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; |
2532 | 2520 | ||
2533 | lq_cmd->agg_params.agg_time_limit = | 2521 | lq_cmd->agg_params.agg_time_limit = |
2534 | cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); | 2522 | cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); |
2535 | } | 2523 | } |
2536 | 2524 | ||
2537 | static void | 2525 | static void * |
2538 | *il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) | 2526 | il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) |
2539 | { | 2527 | { |
2540 | return hw->priv; | 2528 | return hw->priv; |
2541 | } | 2529 | } |
2530 | |||
2542 | /* rate scale requires free function to be implemented */ | 2531 | /* rate scale requires free function to be implemented */ |
2543 | static void il4965_rs_free(void *il_rate) | 2532 | static void |
2533 | il4965_rs_free(void *il_rate) | ||
2544 | { | 2534 | { |
2545 | return; | 2535 | return; |
2546 | } | 2536 | } |
2547 | 2537 | ||
2548 | static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, | 2538 | static void |
2549 | void *il_sta) | 2539 | il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, void *il_sta) |
2550 | { | 2540 | { |
2551 | struct il_priv *il __maybe_unused = il_r; | 2541 | struct il_priv *il __maybe_unused = il_r; |
2552 | 2542 | ||
@@ -2554,15 +2544,16 @@ static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, | |||
2554 | D_RATE("leave\n"); | 2544 | D_RATE("leave\n"); |
2555 | } | 2545 | } |
2556 | 2546 | ||
2557 | |||
2558 | #ifdef CONFIG_MAC80211_DEBUGFS | 2547 | #ifdef CONFIG_MAC80211_DEBUGFS |
2559 | static int il4965_open_file_generic(struct inode *inode, struct file *file) | 2548 | static int |
2549 | il4965_open_file_generic(struct inode *inode, struct file *file) | ||
2560 | { | 2550 | { |
2561 | file->private_data = inode->i_private; | 2551 | file->private_data = inode->i_private; |
2562 | return 0; | 2552 | return 0; |
2563 | } | 2553 | } |
2564 | static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, | 2554 | |
2565 | u32 *rate_n_flags, int idx) | 2555 | static void |
2556 | il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) | ||
2566 | { | 2557 | { |
2567 | struct il_priv *il; | 2558 | struct il_priv *il; |
2568 | u8 valid_tx_ant; | 2559 | u8 valid_tx_ant; |
@@ -2572,16 +2563,17 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, | |||
2572 | valid_tx_ant = il->hw_params.valid_tx_ant; | 2563 | valid_tx_ant = il->hw_params.valid_tx_ant; |
2573 | if (lq_sta->dbg_fixed_rate) { | 2564 | if (lq_sta->dbg_fixed_rate) { |
2574 | ant_sel_tx = | 2565 | ant_sel_tx = |
2575 | ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) | 2566 | ((lq_sta-> |
2576 | >> RATE_MCS_ANT_POS); | 2567 | dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >> |
2568 | RATE_MCS_ANT_POS); | ||
2577 | if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { | 2569 | if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { |
2578 | *rate_n_flags = lq_sta->dbg_fixed_rate; | 2570 | *rate_n_flags = lq_sta->dbg_fixed_rate; |
2579 | D_RATE("Fixed rate ON\n"); | 2571 | D_RATE("Fixed rate ON\n"); |
2580 | } else { | 2572 | } else { |
2581 | lq_sta->dbg_fixed_rate = 0; | 2573 | lq_sta->dbg_fixed_rate = 0; |
2582 | IL_ERR( | 2574 | IL_ERR |
2583 | "Invalid antenna selection 0x%X, Valid is 0x%X\n", | 2575 | ("Invalid antenna selection 0x%X, Valid is 0x%X\n", |
2584 | ant_sel_tx, valid_tx_ant); | 2576 | ant_sel_tx, valid_tx_ant); |
2585 | D_RATE("Fixed rate OFF\n"); | 2577 | D_RATE("Fixed rate OFF\n"); |
2586 | } | 2578 | } |
2587 | } else { | 2579 | } else { |
@@ -2589,8 +2581,10 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, | |||
2589 | } | 2581 | } |
2590 | } | 2582 | } |
2591 | 2583 | ||
2592 | static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, | 2584 | static ssize_t |
2593 | const char __user *user_buf, size_t count, loff_t *ppos) | 2585 | il4965_rs_sta_dbgfs_scale_table_write(struct file *file, |
2586 | const char __user * user_buf, | ||
2587 | size_t count, loff_t * ppos) | ||
2594 | { | 2588 | { |
2595 | struct il_lq_sta *lq_sta = file->private_data; | 2589 | struct il_lq_sta *lq_sta = file->private_data; |
2596 | struct il_priv *il; | 2590 | struct il_priv *il; |
@@ -2598,12 +2592,12 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, | |||
2598 | size_t buf_size; | 2592 | size_t buf_size; |
2599 | u32 parsed_rate; | 2593 | u32 parsed_rate; |
2600 | struct il_station_priv *sta_priv = | 2594 | struct il_station_priv *sta_priv = |
2601 | container_of(lq_sta, struct il_station_priv, lq_sta); | 2595 | container_of(lq_sta, struct il_station_priv, lq_sta); |
2602 | struct il_rxon_context *ctx = sta_priv->common.ctx; | 2596 | struct il_rxon_context *ctx = sta_priv->common.ctx; |
2603 | 2597 | ||
2604 | il = lq_sta->drv; | 2598 | il = lq_sta->drv; |
2605 | memset(buf, 0, sizeof(buf)); | 2599 | memset(buf, 0, sizeof(buf)); |
2606 | buf_size = min(count, sizeof(buf) - 1); | 2600 | buf_size = min(count, sizeof(buf) - 1); |
2607 | if (copy_from_user(buf, user_buf, buf_size)) | 2601 | if (copy_from_user(buf, user_buf, buf_size)) |
2608 | return -EFAULT; | 2602 | return -EFAULT; |
2609 | 2603 | ||
@@ -2613,23 +2607,23 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, | |||
2613 | lq_sta->dbg_fixed_rate = 0; | 2607 | lq_sta->dbg_fixed_rate = 0; |
2614 | 2608 | ||
2615 | lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ | 2609 | lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ |
2616 | lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | 2610 | lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
2617 | lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ | 2611 | lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ |
2618 | 2612 | ||
2619 | D_RATE("sta_id %d rate 0x%X\n", | 2613 | D_RATE("sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, |
2620 | lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); | 2614 | lq_sta->dbg_fixed_rate); |
2621 | 2615 | ||
2622 | if (lq_sta->dbg_fixed_rate) { | 2616 | if (lq_sta->dbg_fixed_rate) { |
2623 | il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); | 2617 | il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); |
2624 | il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, | 2618 | il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, false); |
2625 | false); | ||
2626 | } | 2619 | } |
2627 | 2620 | ||
2628 | return count; | 2621 | return count; |
2629 | } | 2622 | } |
2630 | 2623 | ||
2631 | static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, | 2624 | static ssize_t |
2632 | char __user *user_buf, size_t count, loff_t *ppos) | 2625 | il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user * user_buf, |
2626 | size_t count, loff_t * ppos) | ||
2633 | { | 2627 | { |
2634 | char *buff; | 2628 | char *buff; |
2635 | int desc = 0; | 2629 | int desc = 0; |
@@ -2646,64 +2640,80 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, | |||
2646 | if (!buff) | 2640 | if (!buff) |
2647 | return -ENOMEM; | 2641 | return -ENOMEM; |
2648 | 2642 | ||
2649 | desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); | 2643 | desc += sprintf(buff + desc, "sta_id %d\n", lq_sta->lq.sta_id); |
2650 | desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", | 2644 | desc += |
2651 | lq_sta->total_failed, lq_sta->total_success, | 2645 | sprintf(buff + desc, "failed=%d success=%d rate=0%X\n", |
2652 | lq_sta->active_legacy_rate); | 2646 | lq_sta->total_failed, lq_sta->total_success, |
2653 | desc += sprintf(buff+desc, "fixed rate 0x%X\n", | 2647 | lq_sta->active_legacy_rate); |
2654 | lq_sta->dbg_fixed_rate); | 2648 | desc += |
2655 | desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", | 2649 | sprintf(buff + desc, "fixed rate 0x%X\n", lq_sta->dbg_fixed_rate); |
2656 | (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", | 2650 | desc += |
2657 | (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", | 2651 | sprintf(buff + desc, "valid_tx_ant %s%s%s\n", |
2658 | (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); | 2652 | (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", |
2659 | desc += sprintf(buff+desc, "lq type %s\n", | 2653 | (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", |
2660 | (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); | 2654 | (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); |
2655 | desc += | ||
2656 | sprintf(buff + desc, "lq type %s\n", | ||
2657 | (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); | ||
2661 | if (is_Ht(tbl->lq_type)) { | 2658 | if (is_Ht(tbl->lq_type)) { |
2662 | desc += sprintf(buff+desc, " %s", | 2659 | desc += |
2663 | (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); | 2660 | sprintf(buff + desc, " %s", |
2664 | desc += sprintf(buff+desc, " %s", | 2661 | (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); |
2665 | (tbl->is_ht40) ? "40MHz" : "20MHz"); | 2662 | desc += |
2666 | desc += sprintf(buff+desc, " %s %s %s\n", | 2663 | sprintf(buff + desc, " %s", |
2667 | (tbl->is_SGI) ? "SGI" : "", | 2664 | (tbl->is_ht40) ? "40MHz" : "20MHz"); |
2668 | (lq_sta->is_green) ? "GF enabled" : "", | 2665 | desc += |
2669 | (lq_sta->is_agg) ? "AGG on" : ""); | 2666 | sprintf(buff + desc, " %s %s %s\n", |
2667 | (tbl->is_SGI) ? "SGI" : "", | ||
2668 | (lq_sta->is_green) ? "GF enabled" : "", | ||
2669 | (lq_sta->is_agg) ? "AGG on" : ""); | ||
2670 | } | 2670 | } |
2671 | desc += sprintf(buff+desc, "last tx rate=0x%X\n", | 2671 | desc += |
2672 | lq_sta->last_rate_n_flags); | 2672 | sprintf(buff + desc, "last tx rate=0x%X\n", |
2673 | desc += sprintf(buff+desc, "general:" | 2673 | lq_sta->last_rate_n_flags); |
2674 | "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", | 2674 | desc += |
2675 | lq_sta->lq.general_params.flags, | 2675 | sprintf(buff + desc, |
2676 | lq_sta->lq.general_params.mimo_delimiter, | 2676 | "general:" "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", |
2677 | lq_sta->lq.general_params.single_stream_ant_msk, | 2677 | lq_sta->lq.general_params.flags, |
2678 | lq_sta->lq.general_params.dual_stream_ant_msk); | 2678 | lq_sta->lq.general_params.mimo_delimiter, |
2679 | 2679 | lq_sta->lq.general_params.single_stream_ant_msk, | |
2680 | desc += sprintf(buff+desc, "agg:" | 2680 | lq_sta->lq.general_params.dual_stream_ant_msk); |
2681 | "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", | 2681 | |
2682 | le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), | 2682 | desc += |
2683 | lq_sta->lq.agg_params.agg_dis_start_th, | 2683 | sprintf(buff + desc, |
2684 | lq_sta->lq.agg_params.agg_frame_cnt_limit); | 2684 | "agg:" |
2685 | 2685 | "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", | |
2686 | desc += sprintf(buff+desc, | 2686 | le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), |
2687 | "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", | 2687 | lq_sta->lq.agg_params.agg_dis_start_th, |
2688 | lq_sta->lq.general_params.start_rate_idx[0], | 2688 | lq_sta->lq.agg_params.agg_frame_cnt_limit); |
2689 | lq_sta->lq.general_params.start_rate_idx[1], | 2689 | |
2690 | lq_sta->lq.general_params.start_rate_idx[2], | 2690 | desc += |
2691 | lq_sta->lq.general_params.start_rate_idx[3]); | 2691 | sprintf(buff + desc, |
2692 | "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", | ||
2693 | lq_sta->lq.general_params.start_rate_idx[0], | ||
2694 | lq_sta->lq.general_params.start_rate_idx[1], | ||
2695 | lq_sta->lq.general_params.start_rate_idx[2], | ||
2696 | lq_sta->lq.general_params.start_rate_idx[3]); | ||
2692 | 2697 | ||
2693 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { | 2698 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { |
2694 | idx = il4965_hwrate_to_plcp_idx( | 2699 | idx = |
2695 | le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); | 2700 | il4965_hwrate_to_plcp_idx(le32_to_cpu |
2701 | (lq_sta->lq.rs_table[i]. | ||
2702 | rate_n_flags)); | ||
2696 | if (is_legacy(tbl->lq_type)) { | 2703 | if (is_legacy(tbl->lq_type)) { |
2697 | desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", | 2704 | desc += |
2698 | i, | 2705 | sprintf(buff + desc, " rate[%d] 0x%X %smbps\n", i, |
2699 | le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), | 2706 | le32_to_cpu(lq_sta->lq.rs_table[i]. |
2700 | il_rate_mcs[idx].mbps); | 2707 | rate_n_flags), |
2708 | il_rate_mcs[idx].mbps); | ||
2701 | } else { | 2709 | } else { |
2702 | desc += sprintf(buff+desc, | 2710 | desc += |
2703 | " rate[%d] 0x%X %smbps (%s)\n", | 2711 | sprintf(buff + desc, " rate[%d] 0x%X %smbps (%s)\n", |
2704 | i, | 2712 | i, |
2705 | le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), | 2713 | le32_to_cpu(lq_sta->lq.rs_table[i]. |
2706 | il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); | 2714 | rate_n_flags), |
2715 | il_rate_mcs[idx].mbps, | ||
2716 | il_rate_mcs[idx].mcs); | ||
2707 | } | 2717 | } |
2708 | } | 2718 | } |
2709 | 2719 | ||
@@ -2718,8 +2728,10 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = { | |||
2718 | .open = il4965_open_file_generic, | 2728 | .open = il4965_open_file_generic, |
2719 | .llseek = default_llseek, | 2729 | .llseek = default_llseek, |
2720 | }; | 2730 | }; |
2721 | static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, | 2731 | |
2722 | char __user *user_buf, size_t count, loff_t *ppos) | 2732 | static ssize_t |
2733 | il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, | ||
2734 | size_t count, loff_t * ppos) | ||
2723 | { | 2735 | { |
2724 | char *buff; | 2736 | char *buff; |
2725 | int desc = 0; | 2737 | int desc = 0; |
@@ -2733,22 +2745,22 @@ static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, | |||
2733 | return -ENOMEM; | 2745 | return -ENOMEM; |
2734 | 2746 | ||
2735 | for (i = 0; i < LQ_SIZE; i++) { | 2747 | for (i = 0; i < LQ_SIZE; i++) { |
2736 | desc += sprintf(buff+desc, | 2748 | desc += |
2737 | "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" | 2749 | sprintf(buff + desc, |
2738 | "rate=0x%X\n", | 2750 | "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" |
2739 | lq_sta->active_tbl == i ? "*" : "x", | 2751 | "rate=0x%X\n", lq_sta->active_tbl == i ? "*" : "x", |
2740 | lq_sta->lq_info[i].lq_type, | 2752 | lq_sta->lq_info[i].lq_type, |
2741 | lq_sta->lq_info[i].is_SGI, | 2753 | lq_sta->lq_info[i].is_SGI, |
2742 | lq_sta->lq_info[i].is_ht40, | 2754 | lq_sta->lq_info[i].is_ht40, |
2743 | lq_sta->lq_info[i].is_dup, | 2755 | lq_sta->lq_info[i].is_dup, lq_sta->is_green, |
2744 | lq_sta->is_green, | 2756 | lq_sta->lq_info[i].current_rate); |
2745 | lq_sta->lq_info[i].current_rate); | ||
2746 | for (j = 0; j < RATE_COUNT; j++) { | 2757 | for (j = 0; j < RATE_COUNT; j++) { |
2747 | desc += sprintf(buff+desc, | 2758 | desc += |
2748 | "counter=%d success=%d %%=%d\n", | 2759 | sprintf(buff + desc, |
2749 | lq_sta->lq_info[i].win[j].counter, | 2760 | "counter=%d success=%d %%=%d\n", |
2750 | lq_sta->lq_info[i].win[j].success_counter, | 2761 | lq_sta->lq_info[i].win[j].counter, |
2751 | lq_sta->lq_info[i].win[j].success_ratio); | 2762 | lq_sta->lq_info[i].win[j].success_counter, |
2763 | lq_sta->lq_info[i].win[j].success_ratio); | ||
2752 | } | 2764 | } |
2753 | } | 2765 | } |
2754 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); | 2766 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); |
@@ -2762,8 +2774,10 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { | |||
2762 | .llseek = default_llseek, | 2774 | .llseek = default_llseek, |
2763 | }; | 2775 | }; |
2764 | 2776 | ||
2765 | static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, | 2777 | static ssize_t |
2766 | char __user *user_buf, size_t count, loff_t *ppos) | 2778 | il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, |
2779 | char __user * user_buf, size_t count, | ||
2780 | loff_t * ppos) | ||
2767 | { | 2781 | { |
2768 | char buff[120]; | 2782 | char buff[120]; |
2769 | int desc = 0; | 2783 | int desc = 0; |
@@ -2776,13 +2790,13 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, | |||
2776 | il = lq_sta->drv; | 2790 | il = lq_sta->drv; |
2777 | 2791 | ||
2778 | if (is_Ht(tbl->lq_type)) | 2792 | if (is_Ht(tbl->lq_type)) |
2779 | desc += sprintf(buff+desc, | 2793 | desc += |
2780 | "Bit Rate= %d Mb/s\n", | 2794 | sprintf(buff + desc, "Bit Rate= %d Mb/s\n", |
2781 | tbl->expected_tpt[lq_sta->last_txrate_idx]); | 2795 | tbl->expected_tpt[lq_sta->last_txrate_idx]); |
2782 | else | 2796 | else |
2783 | desc += sprintf(buff+desc, | 2797 | desc += |
2784 | "Bit Rate= %d Mb/s\n", | 2798 | sprintf(buff + desc, "Bit Rate= %d Mb/s\n", |
2785 | il_rates[lq_sta->last_txrate_idx].ieee >> 1); | 2799 | il_rates[lq_sta->last_txrate_idx].ieee >> 1); |
2786 | 2800 | ||
2787 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); | 2801 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); |
2788 | return ret; | 2802 | return ret; |
@@ -2794,26 +2808,27 @@ static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { | |||
2794 | .llseek = default_llseek, | 2808 | .llseek = default_llseek, |
2795 | }; | 2809 | }; |
2796 | 2810 | ||
2797 | static void il4965_rs_add_debugfs(void *il, void *il_sta, | 2811 | static void |
2798 | struct dentry *dir) | 2812 | il4965_rs_add_debugfs(void *il, void *il_sta, struct dentry *dir) |
2799 | { | 2813 | { |
2800 | struct il_lq_sta *lq_sta = il_sta; | 2814 | struct il_lq_sta *lq_sta = il_sta; |
2801 | lq_sta->rs_sta_dbgfs_scale_table_file = | 2815 | lq_sta->rs_sta_dbgfs_scale_table_file = |
2802 | debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, | 2816 | debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, |
2803 | lq_sta, &rs_sta_dbgfs_scale_table_ops); | 2817 | lq_sta, &rs_sta_dbgfs_scale_table_ops); |
2804 | lq_sta->rs_sta_dbgfs_stats_table_file = | 2818 | lq_sta->rs_sta_dbgfs_stats_table_file = |
2805 | debugfs_create_file("rate_stats_table", S_IRUSR, dir, | 2819 | debugfs_create_file("rate_stats_table", S_IRUSR, dir, lq_sta, |
2806 | lq_sta, &rs_sta_dbgfs_stats_table_ops); | 2820 | &rs_sta_dbgfs_stats_table_ops); |
2807 | lq_sta->rs_sta_dbgfs_rate_scale_data_file = | 2821 | lq_sta->rs_sta_dbgfs_rate_scale_data_file = |
2808 | debugfs_create_file("rate_scale_data", S_IRUSR, dir, | 2822 | debugfs_create_file("rate_scale_data", S_IRUSR, dir, lq_sta, |
2809 | lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); | 2823 | &rs_sta_dbgfs_rate_scale_data_ops); |
2810 | lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = | 2824 | lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = |
2811 | debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, | 2825 | debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, |
2812 | &lq_sta->tx_agg_tid_en); | 2826 | &lq_sta->tx_agg_tid_en); |
2813 | 2827 | ||
2814 | } | 2828 | } |
2815 | 2829 | ||
2816 | static void il4965_rs_remove_debugfs(void *il, void *il_sta) | 2830 | static void |
2831 | il4965_rs_remove_debugfs(void *il, void *il_sta) | ||
2817 | { | 2832 | { |
2818 | struct il_lq_sta *lq_sta = il_sta; | 2833 | struct il_lq_sta *lq_sta = il_sta; |
2819 | debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); | 2834 | debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); |
@@ -2833,6 +2848,7 @@ il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, | |||
2833 | struct ieee80211_sta *sta, void *il_sta) | 2848 | struct ieee80211_sta *sta, void *il_sta) |
2834 | { | 2849 | { |
2835 | } | 2850 | } |
2851 | |||
2836 | static struct rate_control_ops rs_4965_ops = { | 2852 | static struct rate_control_ops rs_4965_ops = { |
2837 | .module = NULL, | 2853 | .module = NULL, |
2838 | .name = IL4965_RS_NAME, | 2854 | .name = IL4965_RS_NAME, |
@@ -2849,12 +2865,14 @@ static struct rate_control_ops rs_4965_ops = { | |||
2849 | #endif | 2865 | #endif |
2850 | }; | 2866 | }; |
2851 | 2867 | ||
2852 | int il4965_rate_control_register(void) | 2868 | int |
2869 | il4965_rate_control_register(void) | ||
2853 | { | 2870 | { |
2854 | return ieee80211_rate_control_register(&rs_4965_ops); | 2871 | return ieee80211_rate_control_register(&rs_4965_ops); |
2855 | } | 2872 | } |
2856 | 2873 | ||
2857 | void il4965_rate_control_unregister(void) | 2874 | void |
2875 | il4965_rate_control_unregister(void) | ||
2858 | { | 2876 | { |
2859 | ieee80211_rate_control_unregister(&rs_4965_ops); | 2877 | ieee80211_rate_control_unregister(&rs_4965_ops); |
2860 | } | 2878 | } |