mac80211: fix AP multi-BSSID support (#11698)
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/ani.c
2 +++ b/drivers/net/wireless/ath/ath9k/ani.c
3 @@ -104,11 +104,6 @@ static const struct ani_cck_level_entry
4 #define ATH9K_ANI_CCK_DEF_LEVEL \
5 2 /* default level - matches the INI settings */
6
7 -static bool use_new_ani(struct ath_hw *ah)
8 -{
9 - return AR_SREV_9300_20_OR_LATER(ah) || modparam_force_new_ani;
10 -}
11 -
12 static void ath9k_hw_update_mibstats(struct ath_hw *ah,
13 struct ath9k_mib_stats *stats)
14 {
15 @@ -122,8 +117,6 @@ static void ath9k_hw_update_mibstats(str
16 static void ath9k_ani_restart(struct ath_hw *ah)
17 {
18 struct ar5416AniState *aniState;
19 - struct ath_common *common = ath9k_hw_common(ah);
20 - u32 ofdm_base = 0, cck_base = 0;
21
22 if (!DO_ANI(ah))
23 return;
24 @@ -131,18 +124,10 @@ static void ath9k_ani_restart(struct ath
25 aniState = &ah->curchan->ani;
26 aniState->listenTime = 0;
27
28 - if (!use_new_ani(ah)) {
29 - ofdm_base = AR_PHY_COUNTMAX - ah->config.ofdm_trig_high;
30 - cck_base = AR_PHY_COUNTMAX - ah->config.cck_trig_high;
31 - }
32 -
33 - ath_dbg(common, ANI, "Writing ofdmbase=%u cckbase=%u\n",
34 - ofdm_base, cck_base);
35 -
36 ENABLE_REGWRITE_BUFFER(ah);
37
38 - REG_WRITE(ah, AR_PHY_ERR_1, ofdm_base);
39 - REG_WRITE(ah, AR_PHY_ERR_2, cck_base);
40 + REG_WRITE(ah, AR_PHY_ERR_1, 0);
41 + REG_WRITE(ah, AR_PHY_ERR_2, 0);
42 REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
43 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
44
45 @@ -154,110 +139,6 @@ static void ath9k_ani_restart(struct ath
46 aniState->cckPhyErrCount = 0;
47 }
48
49 -static void ath9k_hw_ani_ofdm_err_trigger_old(struct ath_hw *ah)
50 -{
51 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
52 - struct ar5416AniState *aniState;
53 - int32_t rssi;
54 -
55 - aniState = &ah->curchan->ani;
56 -
57 - if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
58 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
59 - aniState->noiseImmunityLevel + 1)) {
60 - return;
61 - }
62 - }
63 -
64 - if (aniState->spurImmunityLevel < HAL_SPUR_IMMUNE_MAX) {
65 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
66 - aniState->spurImmunityLevel + 1)) {
67 - return;
68 - }
69 - }
70 -
71 - if (ah->opmode == NL80211_IFTYPE_AP) {
72 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
73 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
74 - aniState->firstepLevel + 1);
75 - }
76 - return;
77 - }
78 - rssi = BEACON_RSSI(ah);
79 - if (rssi > aniState->rssiThrHigh) {
80 - if (!aniState->ofdmWeakSigDetectOff) {
81 - if (ath9k_hw_ani_control(ah,
82 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
83 - false)) {
84 - ath9k_hw_ani_control(ah,
85 - ATH9K_ANI_SPUR_IMMUNITY_LEVEL, 0);
86 - return;
87 - }
88 - }
89 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
90 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
91 - aniState->firstepLevel + 1);
92 - return;
93 - }
94 - } else if (rssi > aniState->rssiThrLow) {
95 - if (aniState->ofdmWeakSigDetectOff)
96 - ath9k_hw_ani_control(ah,
97 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
98 - true);
99 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
100 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
101 - aniState->firstepLevel + 1);
102 - return;
103 - } else {
104 - if ((conf->channel->band == IEEE80211_BAND_2GHZ) &&
105 - !conf_is_ht(conf)) {
106 - if (!aniState->ofdmWeakSigDetectOff)
107 - ath9k_hw_ani_control(ah,
108 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
109 - false);
110 - if (aniState->firstepLevel > 0)
111 - ath9k_hw_ani_control(ah,
112 - ATH9K_ANI_FIRSTEP_LEVEL, 0);
113 - return;
114 - }
115 - }
116 -}
117 -
118 -static void ath9k_hw_ani_cck_err_trigger_old(struct ath_hw *ah)
119 -{
120 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
121 - struct ar5416AniState *aniState;
122 - int32_t rssi;
123 -
124 - aniState = &ah->curchan->ani;
125 - if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
126 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
127 - aniState->noiseImmunityLevel + 1)) {
128 - return;
129 - }
130 - }
131 - if (ah->opmode == NL80211_IFTYPE_AP) {
132 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
133 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
134 - aniState->firstepLevel + 1);
135 - }
136 - return;
137 - }
138 - rssi = BEACON_RSSI(ah);
139 - if (rssi > aniState->rssiThrLow) {
140 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
141 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
142 - aniState->firstepLevel + 1);
143 - } else {
144 - if ((conf->channel->band == IEEE80211_BAND_2GHZ) &&
145 - !conf_is_ht(conf)) {
146 - if (aniState->firstepLevel > 0)
147 - ath9k_hw_ani_control(ah,
148 - ATH9K_ANI_FIRSTEP_LEVEL, 0);
149 - }
150 - }
151 -}
152 -
153 /* Adjust the OFDM Noise Immunity Level */
154 static void ath9k_hw_set_ofdm_nil(struct ath_hw *ah, u8 immunityLevel)
155 {
156 @@ -265,18 +146,15 @@ static void ath9k_hw_set_ofdm_nil(struct
157 struct ath_common *common = ath9k_hw_common(ah);
158 const struct ani_ofdm_level_entry *entry_ofdm;
159 const struct ani_cck_level_entry *entry_cck;
160 -
161 - aniState->noiseFloor = BEACON_RSSI(ah);
162 + bool weak_sig;
163
164 ath_dbg(common, ANI, "**** ofdmlevel %d=>%d, rssi=%d[lo=%d hi=%d]\n",
165 aniState->ofdmNoiseImmunityLevel,
166 - immunityLevel, aniState->noiseFloor,
167 + immunityLevel, BEACON_RSSI(ah),
168 aniState->rssiThrLow, aniState->rssiThrHigh);
169
170 if (aniState->update_ani)
171 - aniState->ofdmNoiseImmunityLevel =
172 - (immunityLevel > ATH9K_ANI_OFDM_DEF_LEVEL) ?
173 - immunityLevel : ATH9K_ANI_OFDM_DEF_LEVEL;
174 + aniState->ofdmNoiseImmunityLevel = immunityLevel;
175
176 entry_ofdm = &ofdm_level_table[aniState->ofdmNoiseImmunityLevel];
177 entry_cck = &cck_level_table[aniState->cckNoiseImmunityLevel];
178 @@ -292,12 +170,22 @@ static void ath9k_hw_set_ofdm_nil(struct
179 ATH9K_ANI_FIRSTEP_LEVEL,
180 entry_ofdm->fir_step_level);
181
182 - if ((aniState->noiseFloor >= aniState->rssiThrHigh) &&
183 - (!aniState->ofdmWeakSigDetectOff !=
184 - entry_ofdm->ofdm_weak_signal_on)) {
185 + weak_sig = entry_ofdm->ofdm_weak_signal_on;
186 + if (ah->opmode == NL80211_IFTYPE_STATION &&
187 + BEACON_RSSI(ah) <= aniState->rssiThrHigh)
188 + weak_sig = true;
189 +
190 + if (aniState->ofdmWeakSigDetect != weak_sig)
191 ath9k_hw_ani_control(ah,
192 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
193 entry_ofdm->ofdm_weak_signal_on);
194 +
195 + if (aniState->ofdmNoiseImmunityLevel >= ATH9K_ANI_OFDM_DEF_LEVEL) {
196 + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
197 + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI;
198 + } else {
199 + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI;
200 + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
201 }
202 }
203
204 @@ -308,11 +196,6 @@ static void ath9k_hw_ani_ofdm_err_trigge
205 if (!DO_ANI(ah))
206 return;
207
208 - if (!use_new_ani(ah)) {
209 - ath9k_hw_ani_ofdm_err_trigger_old(ah);
210 - return;
211 - }
212 -
213 aniState = &ah->curchan->ani;
214
215 if (aniState->ofdmNoiseImmunityLevel < ATH9K_ANI_OFDM_MAX_LEVEL)
216 @@ -329,22 +212,18 @@ static void ath9k_hw_set_cck_nil(struct
217 const struct ani_ofdm_level_entry *entry_ofdm;
218 const struct ani_cck_level_entry *entry_cck;
219
220 - aniState->noiseFloor = BEACON_RSSI(ah);
221 ath_dbg(common, ANI, "**** ccklevel %d=>%d, rssi=%d[lo=%d hi=%d]\n",
222 aniState->cckNoiseImmunityLevel, immunityLevel,
223 - aniState->noiseFloor, aniState->rssiThrLow,
224 + BEACON_RSSI(ah), aniState->rssiThrLow,
225 aniState->rssiThrHigh);
226
227 - if ((ah->opmode == NL80211_IFTYPE_STATION ||
228 - ah->opmode == NL80211_IFTYPE_ADHOC) &&
229 - aniState->noiseFloor <= aniState->rssiThrLow &&
230 + if (ah->opmode == NL80211_IFTYPE_STATION &&
231 + BEACON_RSSI(ah) <= aniState->rssiThrLow &&
232 immunityLevel > ATH9K_ANI_CCK_MAX_LEVEL_LOW_RSSI)
233 immunityLevel = ATH9K_ANI_CCK_MAX_LEVEL_LOW_RSSI;
234
235 if (aniState->update_ani)
236 - aniState->cckNoiseImmunityLevel =
237 - (immunityLevel > ATH9K_ANI_CCK_DEF_LEVEL) ?
238 - immunityLevel : ATH9K_ANI_CCK_DEF_LEVEL;
239 + aniState->cckNoiseImmunityLevel = immunityLevel;
240
241 entry_ofdm = &ofdm_level_table[aniState->ofdmNoiseImmunityLevel];
242 entry_cck = &cck_level_table[aniState->cckNoiseImmunityLevel];
243 @@ -372,70 +251,12 @@ static void ath9k_hw_ani_cck_err_trigger
244 if (!DO_ANI(ah))
245 return;
246
247 - if (!use_new_ani(ah)) {
248 - ath9k_hw_ani_cck_err_trigger_old(ah);
249 - return;
250 - }
251 -
252 aniState = &ah->curchan->ani;
253
254 if (aniState->cckNoiseImmunityLevel < ATH9K_ANI_CCK_MAX_LEVEL)
255 ath9k_hw_set_cck_nil(ah, aniState->cckNoiseImmunityLevel + 1);
256 }
257
258 -static void ath9k_hw_ani_lower_immunity_old(struct ath_hw *ah)
259 -{
260 - struct ar5416AniState *aniState;
261 - int32_t rssi;
262 -
263 - aniState = &ah->curchan->ani;
264 -
265 - if (ah->opmode == NL80211_IFTYPE_AP) {
266 - if (aniState->firstepLevel > 0) {
267 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
268 - aniState->firstepLevel - 1))
269 - return;
270 - }
271 - } else {
272 - rssi = BEACON_RSSI(ah);
273 - if (rssi > aniState->rssiThrHigh) {
274 - /* XXX: Handle me */
275 - } else if (rssi > aniState->rssiThrLow) {
276 - if (aniState->ofdmWeakSigDetectOff) {
277 - if (ath9k_hw_ani_control(ah,
278 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
279 - true))
280 - return;
281 - }
282 - if (aniState->firstepLevel > 0) {
283 - if (ath9k_hw_ani_control(ah,
284 - ATH9K_ANI_FIRSTEP_LEVEL,
285 - aniState->firstepLevel - 1))
286 - return;
287 - }
288 - } else {
289 - if (aniState->firstepLevel > 0) {
290 - if (ath9k_hw_ani_control(ah,
291 - ATH9K_ANI_FIRSTEP_LEVEL,
292 - aniState->firstepLevel - 1))
293 - return;
294 - }
295 - }
296 - }
297 -
298 - if (aniState->spurImmunityLevel > 0) {
299 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
300 - aniState->spurImmunityLevel - 1))
301 - return;
302 - }
303 -
304 - if (aniState->noiseImmunityLevel > 0) {
305 - ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
306 - aniState->noiseImmunityLevel - 1);
307 - return;
308 - }
309 -}
310 -
311 /*
312 * only lower either OFDM or CCK errors per turn
313 * we lower the other one next time
314 @@ -446,11 +267,6 @@ static void ath9k_hw_ani_lower_immunity(
315
316 aniState = &ah->curchan->ani;
317
318 - if (!use_new_ani(ah)) {
319 - ath9k_hw_ani_lower_immunity_old(ah);
320 - return;
321 - }
322 -
323 /* lower OFDM noise immunity */
324 if (aniState->ofdmNoiseImmunityLevel > 0 &&
325 (aniState->ofdmsTurn || aniState->cckNoiseImmunityLevel == 0)) {
326 @@ -463,72 +279,6 @@ static void ath9k_hw_ani_lower_immunity(
327 ath9k_hw_set_cck_nil(ah, aniState->cckNoiseImmunityLevel - 1);
328 }
329
330 -static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
331 -{
332 - struct ar5416AniState *aniState;
333 - struct ath9k_channel *chan = ah->curchan;
334 - struct ath_common *common = ath9k_hw_common(ah);
335 -
336 - if (!DO_ANI(ah))
337 - return;
338 -
339 - aniState = &ah->curchan->ani;
340 -
341 - if (ah->opmode != NL80211_IFTYPE_STATION
342 - && ah->opmode != NL80211_IFTYPE_ADHOC) {
343 - ath_dbg(common, ANI, "Reset ANI state opmode %u\n", ah->opmode);
344 - ah->stats.ast_ani_reset++;
345 -
346 - if (ah->opmode == NL80211_IFTYPE_AP) {
347 - /*
348 - * ath9k_hw_ani_control() will only process items set on
349 - * ah->ani_function
350 - */
351 - if (IS_CHAN_2GHZ(chan))
352 - ah->ani_function = (ATH9K_ANI_SPUR_IMMUNITY_LEVEL |
353 - ATH9K_ANI_FIRSTEP_LEVEL);
354 - else
355 - ah->ani_function = 0;
356 - }
357 -
358 - ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL, 0);
359 - ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL, 0);
360 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL, 0);
361 - ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
362 - !ATH9K_ANI_USE_OFDM_WEAK_SIG);
363 - ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
364 - ATH9K_ANI_CCK_WEAK_SIG_THR);
365 -
366 - ath9k_ani_restart(ah);
367 - return;
368 - }
369 -
370 - if (aniState->noiseImmunityLevel != 0)
371 - ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
372 - aniState->noiseImmunityLevel);
373 - if (aniState->spurImmunityLevel != 0)
374 - ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
375 - aniState->spurImmunityLevel);
376 - if (aniState->ofdmWeakSigDetectOff)
377 - ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
378 - !aniState->ofdmWeakSigDetectOff);
379 - if (aniState->cckWeakSigThreshold)
380 - ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
381 - aniState->cckWeakSigThreshold);
382 - if (aniState->firstepLevel != 0)
383 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
384 - aniState->firstepLevel);
385 -
386 - ath9k_ani_restart(ah);
387 -
388 - ENABLE_REGWRITE_BUFFER(ah);
389 -
390 - REG_WRITE(ah, AR_PHY_ERR_MASK_1, AR_PHY_ERR_OFDM_TIMING);
391 - REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING);
392 -
393 - REGWRITE_BUFFER_FLUSH(ah);
394 -}
395 -
396 /*
397 * Restore the ANI parameters in the HAL and reset the statistics.
398 * This routine should be called for every hardware reset and for
399 @@ -539,13 +289,11 @@ void ath9k_ani_reset(struct ath_hw *ah,
400 struct ar5416AniState *aniState = &ah->curchan->ani;
401 struct ath9k_channel *chan = ah->curchan;
402 struct ath_common *common = ath9k_hw_common(ah);
403 + int ofdm_nil, cck_nil;
404
405 if (!DO_ANI(ah))
406 return;
407
408 - if (!use_new_ani(ah))
409 - return ath9k_ani_reset_old(ah, is_scanning);
410 -
411 BUG_ON(aniState == NULL);
412 ah->stats.ast_ani_reset++;
413
414 @@ -563,6 +311,11 @@ void ath9k_ani_reset(struct ath_hw *ah,
415 /* always allow mode (on/off) to be controlled */
416 ah->ani_function |= ATH9K_ANI_MODE;
417
418 + ofdm_nil = max_t(int, ATH9K_ANI_OFDM_DEF_LEVEL,
419 + aniState->ofdmNoiseImmunityLevel);
420 + cck_nil = max_t(int, ATH9K_ANI_CCK_DEF_LEVEL,
421 + aniState->cckNoiseImmunityLevel);
422 +
423 if (is_scanning ||
424 (ah->opmode != NL80211_IFTYPE_STATION &&
425 ah->opmode != NL80211_IFTYPE_ADHOC)) {
426 @@ -586,8 +339,8 @@ void ath9k_ani_reset(struct ath_hw *ah,
427 aniState->cckNoiseImmunityLevel);
428
429 aniState->update_ani = false;
430 - ath9k_hw_set_ofdm_nil(ah, ATH9K_ANI_OFDM_DEF_LEVEL);
431 - ath9k_hw_set_cck_nil(ah, ATH9K_ANI_CCK_DEF_LEVEL);
432 + ofdm_nil = ATH9K_ANI_OFDM_DEF_LEVEL;
433 + cck_nil = ATH9K_ANI_CCK_DEF_LEVEL;
434 }
435 } else {
436 /*
437 @@ -603,11 +356,9 @@ void ath9k_ani_reset(struct ath_hw *ah,
438 aniState->cckNoiseImmunityLevel);
439
440 aniState->update_ani = true;
441 - ath9k_hw_set_ofdm_nil(ah,
442 - aniState->ofdmNoiseImmunityLevel);
443 - ath9k_hw_set_cck_nil(ah,
444 - aniState->cckNoiseImmunityLevel);
445 }
446 + ath9k_hw_set_ofdm_nil(ah, ofdm_nil);
447 + ath9k_hw_set_cck_nil(ah, cck_nil);
448
449 /*
450 * enable phy counters if hw supports or if not, enable phy
451 @@ -627,9 +378,6 @@ static bool ath9k_hw_ani_read_counters(s
452 {
453 struct ath_common *common = ath9k_hw_common(ah);
454 struct ar5416AniState *aniState = &ah->curchan->ani;
455 - u32 ofdm_base = 0;
456 - u32 cck_base = 0;
457 - u32 ofdmPhyErrCnt, cckPhyErrCnt;
458 u32 phyCnt1, phyCnt2;
459 int32_t listenTime;
460
461 @@ -642,11 +390,6 @@ static bool ath9k_hw_ani_read_counters(s
462 return false;
463 }
464
465 - if (!use_new_ani(ah)) {
466 - ofdm_base = AR_PHY_COUNTMAX - ah->config.ofdm_trig_high;
467 - cck_base = AR_PHY_COUNTMAX - ah->config.cck_trig_high;
468 - }
469 -
470 aniState->listenTime += listenTime;
471
472 ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
473 @@ -654,35 +397,12 @@ static bool ath9k_hw_ani_read_counters(s
474 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
475 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
476
477 - if (!use_new_ani(ah) && (phyCnt1 < ofdm_base || phyCnt2 < cck_base)) {
478 - if (phyCnt1 < ofdm_base) {
479 - ath_dbg(common, ANI,
480 - "phyCnt1 0x%x, resetting counter value to 0x%x\n",
481 - phyCnt1, ofdm_base);
482 - REG_WRITE(ah, AR_PHY_ERR_1, ofdm_base);
483 - REG_WRITE(ah, AR_PHY_ERR_MASK_1,
484 - AR_PHY_ERR_OFDM_TIMING);
485 - }
486 - if (phyCnt2 < cck_base) {
487 - ath_dbg(common, ANI,
488 - "phyCnt2 0x%x, resetting counter value to 0x%x\n",
489 - phyCnt2, cck_base);
490 - REG_WRITE(ah, AR_PHY_ERR_2, cck_base);
491 - REG_WRITE(ah, AR_PHY_ERR_MASK_2,
492 - AR_PHY_ERR_CCK_TIMING);
493 - }
494 - return false;
495 - }
496 + ah->stats.ast_ani_ofdmerrs += phyCnt1 - aniState->ofdmPhyErrCount;
497 + aniState->ofdmPhyErrCount = phyCnt1;
498 +
499 + ah->stats.ast_ani_cckerrs += phyCnt2 - aniState->cckPhyErrCount;
500 + aniState->cckPhyErrCount = phyCnt2;
501
502 - ofdmPhyErrCnt = phyCnt1 - ofdm_base;
503 - ah->stats.ast_ani_ofdmerrs +=
504 - ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
505 - aniState->ofdmPhyErrCount = ofdmPhyErrCnt;
506 -
507 - cckPhyErrCnt = phyCnt2 - cck_base;
508 - ah->stats.ast_ani_cckerrs +=
509 - cckPhyErrCnt - aniState->cckPhyErrCount;
510 - aniState->cckPhyErrCount = cckPhyErrCnt;
511 return true;
512 }
513
514 @@ -716,21 +436,10 @@ void ath9k_hw_ani_monitor(struct ath_hw
515
516 if (aniState->listenTime > ah->aniperiod) {
517 if (cckPhyErrRate < ah->config.cck_trig_low &&
518 - ((ofdmPhyErrRate < ah->config.ofdm_trig_low &&
519 - aniState->ofdmNoiseImmunityLevel <
520 - ATH9K_ANI_OFDM_DEF_LEVEL) ||
521 - (ofdmPhyErrRate < ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI &&
522 - aniState->ofdmNoiseImmunityLevel >=
523 - ATH9K_ANI_OFDM_DEF_LEVEL))) {
524 + ofdmPhyErrRate < ah->config.ofdm_trig_low) {
525 ath9k_hw_ani_lower_immunity(ah);
526 aniState->ofdmsTurn = !aniState->ofdmsTurn;
527 - } else if ((ofdmPhyErrRate > ah->config.ofdm_trig_high &&
528 - aniState->ofdmNoiseImmunityLevel >=
529 - ATH9K_ANI_OFDM_DEF_LEVEL) ||
530 - (ofdmPhyErrRate >
531 - ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI &&
532 - aniState->ofdmNoiseImmunityLevel <
533 - ATH9K_ANI_OFDM_DEF_LEVEL)) {
534 + } else if (ofdmPhyErrRate > ah->config.ofdm_trig_high) {
535 ath9k_hw_ani_ofdm_err_trigger(ah);
536 aniState->ofdmsTurn = false;
537 } else if (cckPhyErrRate > ah->config.cck_trig_high) {
538 @@ -778,49 +487,6 @@ void ath9k_hw_disable_mib_counters(struc
539 }
540 EXPORT_SYMBOL(ath9k_hw_disable_mib_counters);
541
542 -/*
543 - * Process a MIB interrupt. We may potentially be invoked because
544 - * any of the MIB counters overflow/trigger so don't assume we're
545 - * here because a PHY error counter triggered.
546 - */
547 -void ath9k_hw_proc_mib_event(struct ath_hw *ah)
548 -{
549 - u32 phyCnt1, phyCnt2;
550 -
551 - /* Reset these counters regardless */
552 - REG_WRITE(ah, AR_FILT_OFDM, 0);
553 - REG_WRITE(ah, AR_FILT_CCK, 0);
554 - if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING))
555 - REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
556 -
557 - /* Clear the mib counters and save them in the stats */
558 - ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
559 -
560 - if (!DO_ANI(ah)) {
561 - /*
562 - * We must always clear the interrupt cause by
563 - * resetting the phy error regs.
564 - */
565 - REG_WRITE(ah, AR_PHY_ERR_1, 0);
566 - REG_WRITE(ah, AR_PHY_ERR_2, 0);
567 - return;
568 - }
569 -
570 - /* NB: these are not reset-on-read */
571 - phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
572 - phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
573 - if (((phyCnt1 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK) ||
574 - ((phyCnt2 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK)) {
575 -
576 - if (!use_new_ani(ah))
577 - ath9k_hw_ani_read_counters(ah);
578 -
579 - /* NB: always restart to insure the h/w counters are reset */
580 - ath9k_ani_restart(ah);
581 - }
582 -}
583 -EXPORT_SYMBOL(ath9k_hw_proc_mib_event);
584 -
585 void ath9k_hw_ani_setup(struct ath_hw *ah)
586 {
587 int i;
588 @@ -845,50 +511,31 @@ void ath9k_hw_ani_init(struct ath_hw *ah
589
590 ath_dbg(common, ANI, "Initialize ANI\n");
591
592 - if (use_new_ani(ah)) {
593 - ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_NEW;
594 - ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW_NEW;
595 + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
596 + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
597
598 - ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH_NEW;
599 - ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW_NEW;
600 - } else {
601 - ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_OLD;
602 - ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW_OLD;
603 -
604 - ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH_OLD;
605 - ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW_OLD;
606 - }
607 + ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH;
608 + ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW;
609
610 for (i = 0; i < ARRAY_SIZE(ah->channels); i++) {
611 struct ath9k_channel *chan = &ah->channels[i];
612 struct ar5416AniState *ani = &chan->ani;
613
614 - if (use_new_ani(ah)) {
615 - ani->spurImmunityLevel =
616 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW;
617 + ani->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
618
619 - ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL_NEW;
620 + ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
621
622 - if (AR_SREV_9300_20_OR_LATER(ah))
623 - ani->mrcCCKOff =
624 - !ATH9K_ANI_ENABLE_MRC_CCK;
625 - else
626 - ani->mrcCCKOff = true;
627 -
628 - ani->ofdmsTurn = true;
629 - } else {
630 - ani->spurImmunityLevel =
631 - ATH9K_ANI_SPUR_IMMUNE_LVL_OLD;
632 - ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL_OLD;
633 + if (AR_SREV_9300_20_OR_LATER(ah))
634 + ani->mrcCCKOff =
635 + !ATH9K_ANI_ENABLE_MRC_CCK;
636 + else
637 + ani->mrcCCKOff = true;
638
639 - ani->cckWeakSigThreshold =
640 - ATH9K_ANI_CCK_WEAK_SIG_THR;
641 - }
642 + ani->ofdmsTurn = true;
643
644 ani->rssiThrHigh = ATH9K_ANI_RSSI_THR_HIGH;
645 ani->rssiThrLow = ATH9K_ANI_RSSI_THR_LOW;
646 - ani->ofdmWeakSigDetectOff =
647 - !ATH9K_ANI_USE_OFDM_WEAK_SIG;
648 + ani->ofdmWeakSigDetect = ATH9K_ANI_USE_OFDM_WEAK_SIG;
649 ani->cckNoiseImmunityLevel = ATH9K_ANI_CCK_DEF_LEVEL;
650 ani->ofdmNoiseImmunityLevel = ATH9K_ANI_OFDM_DEF_LEVEL;
651 ani->update_ani = false;
652 @@ -898,13 +545,8 @@ void ath9k_hw_ani_init(struct ath_hw *ah
653 * since we expect some ongoing maintenance on the tables, let's sanity
654 * check here default level should not modify INI setting.
655 */
656 - if (use_new_ani(ah)) {
657 - ah->aniperiod = ATH9K_ANI_PERIOD_NEW;
658 - ah->config.ani_poll_interval = ATH9K_ANI_POLLINTERVAL_NEW;
659 - } else {
660 - ah->aniperiod = ATH9K_ANI_PERIOD_OLD;
661 - ah->config.ani_poll_interval = ATH9K_ANI_POLLINTERVAL_OLD;
662 - }
663 + ah->aniperiod = ATH9K_ANI_PERIOD;
664 + ah->config.ani_poll_interval = ATH9K_ANI_POLLINTERVAL;
665
666 if (ah->config.enable_ani)
667 ah->proc_phyerr |= HAL_PROCESS_ANI;
668 --- a/drivers/net/wireless/ath/ath9k/ani.h
669 +++ b/drivers/net/wireless/ath/ath9k/ani.h
670 @@ -24,42 +24,34 @@
671 #define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
672
673 /* units are errors per second */
674 -#define ATH9K_ANI_OFDM_TRIG_HIGH_OLD 500
675 -#define ATH9K_ANI_OFDM_TRIG_HIGH_NEW 3500
676 +#define ATH9K_ANI_OFDM_TRIG_HIGH 3500
677 #define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
678
679 /* units are errors per second */
680 -#define ATH9K_ANI_OFDM_TRIG_LOW_OLD 200
681 -#define ATH9K_ANI_OFDM_TRIG_LOW_NEW 400
682 +#define ATH9K_ANI_OFDM_TRIG_LOW 400
683 #define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
684
685 /* units are errors per second */
686 -#define ATH9K_ANI_CCK_TRIG_HIGH_OLD 200
687 -#define ATH9K_ANI_CCK_TRIG_HIGH_NEW 600
688 +#define ATH9K_ANI_CCK_TRIG_HIGH 600
689
690 /* units are errors per second */
691 -#define ATH9K_ANI_CCK_TRIG_LOW_OLD 100
692 -#define ATH9K_ANI_CCK_TRIG_LOW_NEW 300
693 +#define ATH9K_ANI_CCK_TRIG_LOW 300
694
695 #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
696 #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
697 #define ATH9K_ANI_CCK_WEAK_SIG_THR false
698
699 -#define ATH9K_ANI_SPUR_IMMUNE_LVL_OLD 7
700 -#define ATH9K_ANI_SPUR_IMMUNE_LVL_NEW 3
701 +#define ATH9K_ANI_SPUR_IMMUNE_LVL 3
702
703 -#define ATH9K_ANI_FIRSTEP_LVL_OLD 0
704 -#define ATH9K_ANI_FIRSTEP_LVL_NEW 2
705 +#define ATH9K_ANI_FIRSTEP_LVL 2
706
707 #define ATH9K_ANI_RSSI_THR_HIGH 40
708 #define ATH9K_ANI_RSSI_THR_LOW 7
709
710 -#define ATH9K_ANI_PERIOD_OLD 100
711 -#define ATH9K_ANI_PERIOD_NEW 300
712 +#define ATH9K_ANI_PERIOD 300
713
714 /* in ms */
715 -#define ATH9K_ANI_POLLINTERVAL_OLD 100
716 -#define ATH9K_ANI_POLLINTERVAL_NEW 1000
717 +#define ATH9K_ANI_POLLINTERVAL 1000
718
719 #define HAL_NOISE_IMMUNE_MAX 4
720 #define HAL_SPUR_IMMUNE_MAX 7
721 @@ -122,13 +114,12 @@ struct ar5416AniState {
722 u8 mrcCCKOff;
723 u8 spurImmunityLevel;
724 u8 firstepLevel;
725 - u8 ofdmWeakSigDetectOff;
726 + u8 ofdmWeakSigDetect;
727 u8 cckWeakSigThreshold;
728 bool update_ani;
729 u32 listenTime;
730 int32_t rssiThrLow;
731 int32_t rssiThrHigh;
732 - u32 noiseFloor;
733 u32 ofdmPhyErrCount;
734 u32 cckPhyErrCount;
735 int16_t pktRssi[2];
736 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
737 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
738 @@ -995,141 +995,6 @@ static u32 ar5008_hw_compute_pll_control
739 return pll;
740 }
741
742 -static bool ar5008_hw_ani_control_old(struct ath_hw *ah,
743 - enum ath9k_ani_cmd cmd,
744 - int param)
745 -{
746 - struct ar5416AniState *aniState = &ah->curchan->ani;
747 - struct ath_common *common = ath9k_hw_common(ah);
748 -
749 - switch (cmd & ah->ani_function) {
750 - case ATH9K_ANI_NOISE_IMMUNITY_LEVEL:{
751 - u32 level = param;
752 -
753 - if (level >= ARRAY_SIZE(ah->totalSizeDesired)) {
754 - ath_dbg(common, ANI, "level out of range (%u > %zu)\n",
755 - level, ARRAY_SIZE(ah->totalSizeDesired));
756 - return false;
757 - }
758 -
759 - REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ,
760 - AR_PHY_DESIRED_SZ_TOT_DES,
761 - ah->totalSizeDesired[level]);
762 - REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
763 - AR_PHY_AGC_CTL1_COARSE_LOW,
764 - ah->coarse_low[level]);
765 - REG_RMW_FIELD(ah, AR_PHY_AGC_CTL1,
766 - AR_PHY_AGC_CTL1_COARSE_HIGH,
767 - ah->coarse_high[level]);
768 - REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
769 - AR_PHY_FIND_SIG_FIRPWR,
770 - ah->firpwr[level]);
771 -
772 - if (level > aniState->noiseImmunityLevel)
773 - ah->stats.ast_ani_niup++;
774 - else if (level < aniState->noiseImmunityLevel)
775 - ah->stats.ast_ani_nidown++;
776 - aniState->noiseImmunityLevel = level;
777 - break;
778 - }
779 - case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
780 - u32 on = param ? 1 : 0;
781 -
782 - if (on)
783 - REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
784 - AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
785 - else
786 - REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
787 - AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
788 -
789 - if (!on != aniState->ofdmWeakSigDetectOff) {
790 - if (on)
791 - ah->stats.ast_ani_ofdmon++;
792 - else
793 - ah->stats.ast_ani_ofdmoff++;
794 - aniState->ofdmWeakSigDetectOff = !on;
795 - }
796 - break;
797 - }
798 - case ATH9K_ANI_CCK_WEAK_SIGNAL_THR:{
799 - static const int weakSigThrCck[] = { 8, 6 };
800 - u32 high = param ? 1 : 0;
801 -
802 - REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT,
803 - AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK,
804 - weakSigThrCck[high]);
805 - if (high != aniState->cckWeakSigThreshold) {
806 - if (high)
807 - ah->stats.ast_ani_cckhigh++;
808 - else
809 - ah->stats.ast_ani_ccklow++;
810 - aniState->cckWeakSigThreshold = high;
811 - }
812 - break;
813 - }
814 - case ATH9K_ANI_FIRSTEP_LEVEL:{
815 - static const int firstep[] = { 0, 4, 8 };
816 - u32 level = param;
817 -
818 - if (level >= ARRAY_SIZE(firstep)) {
819 - ath_dbg(common, ANI, "level out of range (%u > %zu)\n",
820 - level, ARRAY_SIZE(firstep));
821 - return false;
822 - }
823 - REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
824 - AR_PHY_FIND_SIG_FIRSTEP,
825 - firstep[level]);
826 - if (level > aniState->firstepLevel)
827 - ah->stats.ast_ani_stepup++;
828 - else if (level < aniState->firstepLevel)
829 - ah->stats.ast_ani_stepdown++;
830 - aniState->firstepLevel = level;
831 - break;
832 - }
833 - case ATH9K_ANI_SPUR_IMMUNITY_LEVEL:{
834 - static const int cycpwrThr1[] = { 2, 4, 6, 8, 10, 12, 14, 16 };
835 - u32 level = param;
836 -
837 - if (level >= ARRAY_SIZE(cycpwrThr1)) {
838 - ath_dbg(common, ANI, "level out of range (%u > %zu)\n",
839 - level, ARRAY_SIZE(cycpwrThr1));
840 - return false;
841 - }
842 - REG_RMW_FIELD(ah, AR_PHY_TIMING5,
843 - AR_PHY_TIMING5_CYCPWR_THR1,
844 - cycpwrThr1[level]);
845 - if (level > aniState->spurImmunityLevel)
846 - ah->stats.ast_ani_spurup++;
847 - else if (level < aniState->spurImmunityLevel)
848 - ah->stats.ast_ani_spurdown++;
849 - aniState->spurImmunityLevel = level;
850 - break;
851 - }
852 - case ATH9K_ANI_PRESENT:
853 - break;
854 - default:
855 - ath_dbg(common, ANI, "invalid cmd %u\n", cmd);
856 - return false;
857 - }
858 -
859 - ath_dbg(common, ANI, "ANI parameters:\n");
860 - ath_dbg(common, ANI,
861 - "noiseImmunityLevel=%d, spurImmunityLevel=%d, ofdmWeakSigDetectOff=%d\n",
862 - aniState->noiseImmunityLevel,
863 - aniState->spurImmunityLevel,
864 - !aniState->ofdmWeakSigDetectOff);
865 - ath_dbg(common, ANI,
866 - "cckWeakSigThreshold=%d, firstepLevel=%d, listenTime=%d\n",
867 - aniState->cckWeakSigThreshold,
868 - aniState->firstepLevel,
869 - aniState->listenTime);
870 - ath_dbg(common, ANI, "ofdmPhyErrCount=%d, cckPhyErrCount=%d\n\n",
871 - aniState->ofdmPhyErrCount,
872 - aniState->cckPhyErrCount);
873 -
874 - return true;
875 -}
876 -
877 static bool ar5008_hw_ani_control_new(struct ath_hw *ah,
878 enum ath9k_ani_cmd cmd,
879 int param)
880 @@ -1206,18 +1071,18 @@ static bool ar5008_hw_ani_control_new(st
881 REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
882 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
883
884 - if (!on != aniState->ofdmWeakSigDetectOff) {
885 + if (on != aniState->ofdmWeakSigDetect) {
886 ath_dbg(common, ANI,
887 "** ch %d: ofdm weak signal: %s=>%s\n",
888 chan->channel,
889 - !aniState->ofdmWeakSigDetectOff ?
890 + aniState->ofdmWeakSigDetect ?
891 "on" : "off",
892 on ? "on" : "off");
893 if (on)
894 ah->stats.ast_ani_ofdmon++;
895 else
896 ah->stats.ast_ani_ofdmoff++;
897 - aniState->ofdmWeakSigDetectOff = !on;
898 + aniState->ofdmWeakSigDetect = on;
899 }
900 break;
901 }
902 @@ -1236,7 +1101,7 @@ static bool ar5008_hw_ani_control_new(st
903 * from INI file & cap value
904 */
905 value = firstep_table[level] -
906 - firstep_table[ATH9K_ANI_FIRSTEP_LVL_NEW] +
907 + firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
908 aniState->iniDef.firstep;
909 if (value < ATH9K_SIG_FIRSTEP_SETTING_MIN)
910 value = ATH9K_SIG_FIRSTEP_SETTING_MIN;
911 @@ -1251,7 +1116,7 @@ static bool ar5008_hw_ani_control_new(st
912 * from INI file & cap value
913 */
914 value2 = firstep_table[level] -
915 - firstep_table[ATH9K_ANI_FIRSTEP_LVL_NEW] +
916 + firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
917 aniState->iniDef.firstepLow;
918 if (value2 < ATH9K_SIG_FIRSTEP_SETTING_MIN)
919 value2 = ATH9K_SIG_FIRSTEP_SETTING_MIN;
920 @@ -1267,7 +1132,7 @@ static bool ar5008_hw_ani_control_new(st
921 chan->channel,
922 aniState->firstepLevel,
923 level,
924 - ATH9K_ANI_FIRSTEP_LVL_NEW,
925 + ATH9K_ANI_FIRSTEP_LVL,
926 value,
927 aniState->iniDef.firstep);
928 ath_dbg(common, ANI,
929 @@ -1275,7 +1140,7 @@ static bool ar5008_hw_ani_control_new(st
930 chan->channel,
931 aniState->firstepLevel,
932 level,
933 - ATH9K_ANI_FIRSTEP_LVL_NEW,
934 + ATH9K_ANI_FIRSTEP_LVL,
935 value2,
936 aniState->iniDef.firstepLow);
937 if (level > aniState->firstepLevel)
938 @@ -1300,7 +1165,7 @@ static bool ar5008_hw_ani_control_new(st
939 * from INI file & cap value
940 */
941 value = cycpwrThr1_table[level] -
942 - cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL_NEW] +
943 + cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL] +
944 aniState->iniDef.cycpwrThr1;
945 if (value < ATH9K_SIG_SPUR_IMM_SETTING_MIN)
946 value = ATH9K_SIG_SPUR_IMM_SETTING_MIN;
947 @@ -1316,7 +1181,7 @@ static bool ar5008_hw_ani_control_new(st
948 * from INI file & cap value
949 */
950 value2 = cycpwrThr1_table[level] -
951 - cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL_NEW] +
952 + cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL] +
953 aniState->iniDef.cycpwrThr1Ext;
954 if (value2 < ATH9K_SIG_SPUR_IMM_SETTING_MIN)
955 value2 = ATH9K_SIG_SPUR_IMM_SETTING_MIN;
956 @@ -1331,7 +1196,7 @@ static bool ar5008_hw_ani_control_new(st
957 chan->channel,
958 aniState->spurImmunityLevel,
959 level,
960 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
961 + ATH9K_ANI_SPUR_IMMUNE_LVL,
962 value,
963 aniState->iniDef.cycpwrThr1);
964 ath_dbg(common, ANI,
965 @@ -1339,7 +1204,7 @@ static bool ar5008_hw_ani_control_new(st
966 chan->channel,
967 aniState->spurImmunityLevel,
968 level,
969 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
970 + ATH9K_ANI_SPUR_IMMUNE_LVL,
971 value2,
972 aniState->iniDef.cycpwrThr1Ext);
973 if (level > aniState->spurImmunityLevel)
974 @@ -1367,7 +1232,7 @@ static bool ar5008_hw_ani_control_new(st
975 ath_dbg(common, ANI,
976 "ANI parameters: SI=%d, ofdmWS=%s FS=%d MRCcck=%s listenTime=%d ofdmErrs=%d cckErrs=%d\n",
977 aniState->spurImmunityLevel,
978 - !aniState->ofdmWeakSigDetectOff ? "on" : "off",
979 + aniState->ofdmWeakSigDetect ? "on" : "off",
980 aniState->firstepLevel,
981 !aniState->mrcCCKOff ? "on" : "off",
982 aniState->listenTime,
983 @@ -1454,9 +1319,9 @@ static void ar5008_hw_ani_cache_ini_regs
984 AR_PHY_EXT_TIMING5_CYCPWR_THR1);
985
986 /* these levels just got reset to defaults by the INI */
987 - aniState->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL_NEW;
988 - aniState->firstepLevel = ATH9K_ANI_FIRSTEP_LVL_NEW;
989 - aniState->ofdmWeakSigDetectOff = !ATH9K_ANI_USE_OFDM_WEAK_SIG;
990 + aniState->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
991 + aniState->firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
992 + aniState->ofdmWeakSigDetect = ATH9K_ANI_USE_OFDM_WEAK_SIG;
993 aniState->mrcCCKOff = true; /* not available on pre AR9003 */
994 }
995
996 @@ -1545,11 +1410,8 @@ void ar5008_hw_attach_phy_ops(struct ath
997 priv_ops->do_getnf = ar5008_hw_do_getnf;
998 priv_ops->set_radar_params = ar5008_hw_set_radar_params;
999
1000 - if (modparam_force_new_ani) {
1001 - priv_ops->ani_control = ar5008_hw_ani_control_new;
1002 - priv_ops->ani_cache_ini_regs = ar5008_hw_ani_cache_ini_regs;
1003 - } else
1004 - priv_ops->ani_control = ar5008_hw_ani_control_old;
1005 + priv_ops->ani_control = ar5008_hw_ani_control_new;
1006 + priv_ops->ani_cache_ini_regs = ar5008_hw_ani_cache_ini_regs;
1007
1008 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah))
1009 priv_ops->compute_pll_control = ar9160_hw_compute_pll_control;
1010 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
1011 +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
1012 @@ -21,10 +21,6 @@
1013 #include "ar9002_initvals.h"
1014 #include "ar9002_phy.h"
1015
1016 -int modparam_force_new_ani;
1017 -module_param_named(force_new_ani, modparam_force_new_ani, int, 0444);
1018 -MODULE_PARM_DESC(force_new_ani, "Force new ANI for AR5008, AR9001, AR9002");
1019 -
1020 /* General hardware code for the A5008/AR9001/AR9002 hadware families */
1021
1022 static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
1023 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1024 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
1025 @@ -825,18 +825,18 @@ static bool ar9003_hw_ani_control(struct
1026 REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
1027 AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
1028
1029 - if (!on != aniState->ofdmWeakSigDetectOff) {
1030 + if (on != aniState->ofdmWeakSigDetect) {
1031 ath_dbg(common, ANI,
1032 "** ch %d: ofdm weak signal: %s=>%s\n",
1033 chan->channel,
1034 - !aniState->ofdmWeakSigDetectOff ?
1035 + aniState->ofdmWeakSigDetect ?
1036 "on" : "off",
1037 on ? "on" : "off");
1038 if (on)
1039 ah->stats.ast_ani_ofdmon++;
1040 else
1041 ah->stats.ast_ani_ofdmoff++;
1042 - aniState->ofdmWeakSigDetectOff = !on;
1043 + aniState->ofdmWeakSigDetect = on;
1044 }
1045 break;
1046 }
1047 @@ -855,7 +855,7 @@ static bool ar9003_hw_ani_control(struct
1048 * from INI file & cap value
1049 */
1050 value = firstep_table[level] -
1051 - firstep_table[ATH9K_ANI_FIRSTEP_LVL_NEW] +
1052 + firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
1053 aniState->iniDef.firstep;
1054 if (value < ATH9K_SIG_FIRSTEP_SETTING_MIN)
1055 value = ATH9K_SIG_FIRSTEP_SETTING_MIN;
1056 @@ -870,7 +870,7 @@ static bool ar9003_hw_ani_control(struct
1057 * from INI file & cap value
1058 */
1059 value2 = firstep_table[level] -
1060 - firstep_table[ATH9K_ANI_FIRSTEP_LVL_NEW] +
1061 + firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
1062 aniState->iniDef.firstepLow;
1063 if (value2 < ATH9K_SIG_FIRSTEP_SETTING_MIN)
1064 value2 = ATH9K_SIG_FIRSTEP_SETTING_MIN;
1065 @@ -886,7 +886,7 @@ static bool ar9003_hw_ani_control(struct
1066 chan->channel,
1067 aniState->firstepLevel,
1068 level,
1069 - ATH9K_ANI_FIRSTEP_LVL_NEW,
1070 + ATH9K_ANI_FIRSTEP_LVL,
1071 value,
1072 aniState->iniDef.firstep);
1073 ath_dbg(common, ANI,
1074 @@ -894,7 +894,7 @@ static bool ar9003_hw_ani_control(struct
1075 chan->channel,
1076 aniState->firstepLevel,
1077 level,
1078 - ATH9K_ANI_FIRSTEP_LVL_NEW,
1079 + ATH9K_ANI_FIRSTEP_LVL,
1080 value2,
1081 aniState->iniDef.firstepLow);
1082 if (level > aniState->firstepLevel)
1083 @@ -919,7 +919,7 @@ static bool ar9003_hw_ani_control(struct
1084 * from INI file & cap value
1085 */
1086 value = cycpwrThr1_table[level] -
1087 - cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL_NEW] +
1088 + cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL] +
1089 aniState->iniDef.cycpwrThr1;
1090 if (value < ATH9K_SIG_SPUR_IMM_SETTING_MIN)
1091 value = ATH9K_SIG_SPUR_IMM_SETTING_MIN;
1092 @@ -935,7 +935,7 @@ static bool ar9003_hw_ani_control(struct
1093 * from INI file & cap value
1094 */
1095 value2 = cycpwrThr1_table[level] -
1096 - cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL_NEW] +
1097 + cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL] +
1098 aniState->iniDef.cycpwrThr1Ext;
1099 if (value2 < ATH9K_SIG_SPUR_IMM_SETTING_MIN)
1100 value2 = ATH9K_SIG_SPUR_IMM_SETTING_MIN;
1101 @@ -950,7 +950,7 @@ static bool ar9003_hw_ani_control(struct
1102 chan->channel,
1103 aniState->spurImmunityLevel,
1104 level,
1105 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
1106 + ATH9K_ANI_SPUR_IMMUNE_LVL,
1107 value,
1108 aniState->iniDef.cycpwrThr1);
1109 ath_dbg(common, ANI,
1110 @@ -958,7 +958,7 @@ static bool ar9003_hw_ani_control(struct
1111 chan->channel,
1112 aniState->spurImmunityLevel,
1113 level,
1114 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
1115 + ATH9K_ANI_SPUR_IMMUNE_LVL,
1116 value2,
1117 aniState->iniDef.cycpwrThr1Ext);
1118 if (level > aniState->spurImmunityLevel)
1119 @@ -1002,7 +1002,7 @@ static bool ar9003_hw_ani_control(struct
1120 ath_dbg(common, ANI,
1121 "ANI parameters: SI=%d, ofdmWS=%s FS=%d MRCcck=%s listenTime=%d ofdmErrs=%d cckErrs=%d\n",
1122 aniState->spurImmunityLevel,
1123 - !aniState->ofdmWeakSigDetectOff ? "on" : "off",
1124 + aniState->ofdmWeakSigDetect ? "on" : "off",
1125 aniState->firstepLevel,
1126 !aniState->mrcCCKOff ? "on" : "off",
1127 aniState->listenTime,
1128 @@ -1111,9 +1111,9 @@ static void ar9003_hw_ani_cache_ini_regs
1129 AR_PHY_EXT_CYCPWR_THR1);
1130
1131 /* these levels just got reset to defaults by the INI */
1132 - aniState->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL_NEW;
1133 - aniState->firstepLevel = ATH9K_ANI_FIRSTEP_LVL_NEW;
1134 - aniState->ofdmWeakSigDetectOff = !ATH9K_ANI_USE_OFDM_WEAK_SIG;
1135 + aniState->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
1136 + aniState->firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
1137 + aniState->ofdmWeakSigDetect = ATH9K_ANI_USE_OFDM_WEAK_SIG;
1138 aniState->mrcCCKOff = !ATH9K_ANI_ENABLE_MRC_CCK;
1139 }
1140
1141 --- a/drivers/net/wireless/ath/ath9k/debug.c
1142 +++ b/drivers/net/wireless/ath/ath9k/debug.c
1143 @@ -348,8 +348,6 @@ void ath_debug_stat_interrupt(struct ath
1144 sc->debug.stats.istats.txok++;
1145 if (status & ATH9K_INT_TXURN)
1146 sc->debug.stats.istats.txurn++;
1147 - if (status & ATH9K_INT_MIB)
1148 - sc->debug.stats.istats.mib++;
1149 if (status & ATH9K_INT_RXPHY)
1150 sc->debug.stats.istats.rxphyerr++;
1151 if (status & ATH9K_INT_RXKCM)
1152 --- a/drivers/net/wireless/ath/ath9k/hw.h
1153 +++ b/drivers/net/wireless/ath/ath9k/hw.h
1154 @@ -1019,16 +1019,8 @@ void ar9002_hw_attach_ops(struct ath_hw
1155 void ar9003_hw_attach_ops(struct ath_hw *ah);
1156
1157 void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
1158 -/*
1159 - * ANI work can be shared between all families but a next
1160 - * generation implementation of ANI will be used only for AR9003 only
1161 - * for now as the other families still need to be tested with the same
1162 - * next generation ANI. Feel free to start testing it though for the
1163 - * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani.
1164 - */
1165 -extern int modparam_force_new_ani;
1166 +
1167 void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
1168 -void ath9k_hw_proc_mib_event(struct ath_hw *ah);
1169 void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan);
1170
1171 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1172 --- a/drivers/net/wireless/ath/ath9k/main.c
1173 +++ b/drivers/net/wireless/ath/ath9k/main.c
1174 @@ -516,24 +516,6 @@ irqreturn_t ath_isr(int irq, void *dev)
1175 ath9k_hw_set_interrupts(ah);
1176 }
1177
1178 - if (status & ATH9K_INT_MIB) {
1179 - /*
1180 - * Disable interrupts until we service the MIB
1181 - * interrupt; otherwise it will continue to
1182 - * fire.
1183 - */
1184 - ath9k_hw_disable_interrupts(ah);
1185 - /*
1186 - * Let the hal handle the event. We assume
1187 - * it will clear whatever condition caused
1188 - * the interrupt.
1189 - */
1190 - spin_lock(&common->cc_lock);
1191 - ath9k_hw_proc_mib_event(ah);
1192 - spin_unlock(&common->cc_lock);
1193 - ath9k_hw_enable_interrupts(ah);
1194 - }
1195 -
1196 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
1197 if (status & ATH9K_INT_TIM_TIMER) {
1198 if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
1199 @@ -959,14 +941,10 @@ static void ath9k_calculate_summary_stat
1200 /*
1201 * Enable MIB interrupts when there are hardware phy counters.
1202 */
1203 - if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0) {
1204 - if (ah->config.enable_ani)
1205 - ah->imask |= ATH9K_INT_MIB;
1206 + if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0)
1207 ah->imask |= ATH9K_INT_TSFOOR;
1208 - } else {
1209 - ah->imask &= ~ATH9K_INT_MIB;
1210 + else
1211 ah->imask &= ~ATH9K_INT_TSFOOR;
1212 - }
1213
1214 ath9k_hw_set_interrupts(ah);
1215
1216 --- a/net/mac80211/agg-rx.c
1217 +++ b/net/mac80211/agg-rx.c
1218 @@ -201,6 +201,8 @@ static void ieee80211_send_addba_resp(st
1219 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1220 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1221 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
1222 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
1223 + memcpy(mgmt->bssid, da, ETH_ALEN);
1224
1225 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1226 IEEE80211_STYPE_ACTION);
1227 --- a/net/mac80211/agg-tx.c
1228 +++ b/net/mac80211/agg-tx.c
1229 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
1230 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
1231 if (sdata->vif.type == NL80211_IFTYPE_AP ||
1232 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1233 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
1234 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
1235 + sdata->vif.type == NL80211_IFTYPE_WDS)
1236 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
1237 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
1238 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1239 @@ -456,6 +457,7 @@ int ieee80211_start_tx_ba_session(struct
1240 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1241 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1242 sdata->vif.type != NL80211_IFTYPE_AP &&
1243 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1244 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1245 return -EINVAL;
1246
1247 --- a/net/mac80211/debugfs_sta.c
1248 +++ b/net/mac80211/debugfs_sta.c
1249 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
1250 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
1251
1252 int res = scnprintf(buf, sizeof(buf),
1253 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1254 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1255 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
1256 TEST(PS_DRIVER), TEST(AUTHORIZED),
1257 TEST(SHORT_PREAMBLE),
1258 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
1259 + TEST(WME), TEST(CLEAR_PS_FILT),
1260 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
1261 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
1262 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
1263 --- a/net/mac80211/iface.c
1264 +++ b/net/mac80211/iface.c
1265 @@ -284,7 +284,6 @@ static int ieee80211_do_open(struct net_
1266 {
1267 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1268 struct ieee80211_local *local = sdata->local;
1269 - struct sta_info *sta;
1270 u32 changed = 0;
1271 int res;
1272 u32 hw_reconf_flags = 0;
1273 @@ -430,28 +429,6 @@ static int ieee80211_do_open(struct net_
1274
1275 set_bit(SDATA_STATE_RUNNING, &sdata->state);
1276
1277 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
1278 - /* Create STA entry for the WDS peer */
1279 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1280 - GFP_KERNEL);
1281 - if (!sta) {
1282 - res = -ENOMEM;
1283 - goto err_del_interface;
1284 - }
1285 -
1286 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1287 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1288 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1289 -
1290 - res = sta_info_insert(sta);
1291 - if (res) {
1292 - /* STA has been freed */
1293 - goto err_del_interface;
1294 - }
1295 -
1296 - rate_control_rate_init(sta);
1297 - }
1298 -
1299 /*
1300 * set_multicast_list will be invoked by the networking core
1301 * which will check whether any increments here were done in
1302 @@ -639,6 +616,8 @@ static void ieee80211_do_stop(struct iee
1303 ieee80211_configure_filter(local);
1304 break;
1305 default:
1306 + flush_work(&local->hw_roc_start);
1307 + flush_work(&local->hw_roc_done);
1308 flush_work(&sdata->work);
1309 /*
1310 * When we get here, the interface is marked down.
1311 @@ -845,6 +824,72 @@ static void ieee80211_if_setup(struct ne
1312 dev->destructor = free_netdev;
1313 }
1314
1315 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1316 + struct sk_buff *skb)
1317 +{
1318 + struct ieee80211_local *local = sdata->local;
1319 + struct ieee80211_rx_status *rx_status;
1320 + struct ieee802_11_elems elems;
1321 + struct ieee80211_mgmt *mgmt;
1322 + struct sta_info *sta;
1323 + size_t baselen;
1324 + u32 rates = 0;
1325 + u16 stype;
1326 + bool new = false;
1327 + enum ieee80211_band band = local->hw.conf.channel->band;
1328 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
1329 +
1330 + rx_status = IEEE80211_SKB_RXCB(skb);
1331 + mgmt = (struct ieee80211_mgmt *) skb->data;
1332 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1333 +
1334 + if (stype != IEEE80211_STYPE_BEACON)
1335 + return;
1336 +
1337 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1338 + if (baselen > skb->len)
1339 + return;
1340 +
1341 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1342 + skb->len - baselen, &elems);
1343 +
1344 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
1345 +
1346 + rcu_read_lock();
1347 +
1348 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1349 +
1350 + if (!sta) {
1351 + rcu_read_unlock();
1352 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1353 + GFP_KERNEL);
1354 + if (!sta)
1355 + return;
1356 +
1357 + new = true;
1358 + }
1359 +
1360 + sta->last_rx = jiffies;
1361 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
1362 +
1363 + if (elems.ht_cap_elem)
1364 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1365 + elems.ht_cap_elem, &sta->sta.ht_cap);
1366 +
1367 + if (elems.wmm_param)
1368 + set_sta_flag(sta, WLAN_STA_WME);
1369 +
1370 + if (new) {
1371 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1372 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1373 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1374 + rate_control_rate_init(sta);
1375 + sta_info_insert_rcu(sta);
1376 + }
1377 +
1378 + rcu_read_unlock();
1379 +}
1380 +
1381 static void ieee80211_iface_work(struct work_struct *work)
1382 {
1383 struct ieee80211_sub_if_data *sdata =
1384 @@ -949,6 +994,9 @@ static void ieee80211_iface_work(struct
1385 break;
1386 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1387 break;
1388 + case NL80211_IFTYPE_WDS:
1389 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1390 + break;
1391 default:
1392 WARN(1, "frame for unexpected interface type");
1393 break;
1394 --- a/net/mac80211/rx.c
1395 +++ b/net/mac80211/rx.c
1396 @@ -2281,6 +2281,7 @@ ieee80211_rx_h_action(struct ieee80211_r
1397 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1398 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1399 sdata->vif.type != NL80211_IFTYPE_AP &&
1400 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1401 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1402 break;
1403
1404 @@ -2495,14 +2496,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
1405
1406 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1407 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
1408 - sdata->vif.type != NL80211_IFTYPE_STATION)
1409 + sdata->vif.type != NL80211_IFTYPE_STATION &&
1410 + sdata->vif.type != NL80211_IFTYPE_WDS)
1411 return RX_DROP_MONITOR;
1412
1413 switch (stype) {
1414 case cpu_to_le16(IEEE80211_STYPE_AUTH):
1415 case cpu_to_le16(IEEE80211_STYPE_BEACON):
1416 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
1417 - /* process for all: mesh, mlme, ibss */
1418 + /* process for all: mesh, mlme, ibss, wds */
1419 break;
1420 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
1421 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
1422 @@ -2833,10 +2835,16 @@ static int prepare_for_handlers(struct i
1423 }
1424 break;
1425 case NL80211_IFTYPE_WDS:
1426 - if (bssid || !ieee80211_is_data(hdr->frame_control))
1427 - return 0;
1428 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
1429 return 0;
1430 +
1431 + if (ieee80211_is_data(hdr->frame_control) ||
1432 + ieee80211_is_action(hdr->frame_control)) {
1433 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
1434 + return 0;
1435 + } else if (!ieee80211_is_beacon(hdr->frame_control))
1436 + return 0;
1437 +
1438 break;
1439 default:
1440 /* should never get here */
1441 --- a/net/mac80211/sta_info.h
1442 +++ b/net/mac80211/sta_info.h
1443 @@ -32,7 +32,6 @@
1444 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
1445 * frames.
1446 * @WLAN_STA_WME: Station is a QoS-STA.
1447 - * @WLAN_STA_WDS: Station is one of our WDS peers.
1448 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
1449 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
1450 * frame to this station is transmitted.
1451 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
1452 WLAN_STA_AUTHORIZED,
1453 WLAN_STA_SHORT_PREAMBLE,
1454 WLAN_STA_WME,
1455 - WLAN_STA_WDS,
1456 WLAN_STA_CLEAR_PS_FILT,
1457 WLAN_STA_MFP,
1458 WLAN_STA_BLOCK_BA,
1459 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1460 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1461 @@ -214,6 +214,7 @@ struct ath_frame_info {
1462 enum ath9k_key_type keytype;
1463 u8 keyix;
1464 u8 retries;
1465 + u8 rtscts_rate;
1466 };
1467
1468 struct ath_buf_state {
1469 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1470 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1471 @@ -938,6 +938,7 @@ static void ath_buf_set_rate(struct ath_
1472 struct ieee80211_tx_rate *rates;
1473 const struct ieee80211_rate *rate;
1474 struct ieee80211_hdr *hdr;
1475 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
1476 int i;
1477 u8 rix = 0;
1478
1479 @@ -948,18 +949,7 @@ static void ath_buf_set_rate(struct ath_
1480
1481 /* set dur_update_en for l-sig computation except for PS-Poll frames */
1482 info->dur_update = !ieee80211_is_pspoll(hdr->frame_control);
1483 -
1484 - /*
1485 - * We check if Short Preamble is needed for the CTS rate by
1486 - * checking the BSS's global flag.
1487 - * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
1488 - */
1489 - rate = ieee80211_get_rts_cts_rate(sc->hw, tx_info);
1490 - info->rtscts_rate = rate->hw_value;
1491 -
1492 - if (tx_info->control.vif &&
1493 - tx_info->control.vif->bss_conf.use_short_preamble)
1494 - info->rtscts_rate |= rate->hw_value_short;
1495 + info->rtscts_rate = fi->rtscts_rate;
1496
1497 for (i = 0; i < 4; i++) {
1498 bool is_40, is_sgi, is_sp;
1499 @@ -1001,13 +991,13 @@ static void ath_buf_set_rate(struct ath_
1500 }
1501
1502 /* legacy rates */
1503 + rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx];
1504 if ((tx_info->band == IEEE80211_BAND_2GHZ) &&
1505 !(rate->flags & IEEE80211_RATE_ERP_G))
1506 phy = WLAN_RC_PHY_CCK;
1507 else
1508 phy = WLAN_RC_PHY_OFDM;
1509
1510 - rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx];
1511 info->rates[i].Rate = rate->hw_value;
1512 if (rate->hw_value_short) {
1513 if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
1514 @@ -1776,10 +1766,22 @@ static void setup_frame_info(struct ieee
1515 struct ieee80211_sta *sta = tx_info->control.sta;
1516 struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
1517 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1518 + const struct ieee80211_rate *rate;
1519 struct ath_frame_info *fi = get_frame_info(skb);
1520 struct ath_node *an = NULL;
1521 enum ath9k_key_type keytype;
1522 + bool short_preamble = false;
1523 +
1524 + /*
1525 + * We check if Short Preamble is needed for the CTS rate by
1526 + * checking the BSS's global flag.
1527 + * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
1528 + */
1529 + if (tx_info->control.vif &&
1530 + tx_info->control.vif->bss_conf.use_short_preamble)
1531 + short_preamble = true;
1532
1533 + rate = ieee80211_get_rts_cts_rate(hw, tx_info);
1534 keytype = ath9k_cmn_get_hw_crypto_keytype(skb);
1535
1536 if (sta)
1537 @@ -1794,6 +1796,9 @@ static void setup_frame_info(struct ieee
1538 fi->keyix = ATH9K_TXKEYIX_INVALID;
1539 fi->keytype = keytype;
1540 fi->framelen = framelen;
1541 + fi->rtscts_rate = rate->hw_value;
1542 + if (short_preamble)
1543 + fi->rtscts_rate |= rate->hw_value_short;
1544 }
1545
1546 u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate)
1547 --- a/net/wireless/nl80211.c
1548 +++ b/net/wireless/nl80211.c
1549 @@ -2246,6 +2246,33 @@ static int nl80211_parse_beacon(struct g
1550 return 0;
1551 }
1552
1553 +static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev,
1554 + struct cfg80211_ap_settings *params)
1555 +{
1556 + struct wireless_dev *wdev;
1557 + bool ret = false;
1558 +
1559 + mutex_lock(&rdev->devlist_mtx);
1560 +
1561 + list_for_each_entry(wdev, &rdev->netdev_list, list) {
1562 + if (wdev->iftype != NL80211_IFTYPE_AP &&
1563 + wdev->iftype != NL80211_IFTYPE_P2P_GO)
1564 + continue;
1565 +
1566 + if (!wdev->preset_chan)
1567 + continue;
1568 +
1569 + params->channel = wdev->preset_chan;
1570 + params->channel_type = wdev->preset_chantype;
1571 + ret = true;
1572 + break;
1573 + }
1574 +
1575 + mutex_unlock(&rdev->devlist_mtx);
1576 +
1577 + return ret;
1578 +}
1579 +
1580 static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
1581 {
1582 struct cfg80211_registered_device *rdev = info->user_ptr[0];
1583 @@ -2348,7 +2375,7 @@ static int nl80211_start_ap(struct sk_bu
1584 } else if (wdev->preset_chan) {
1585 params.channel = wdev->preset_chan;
1586 params.channel_type = wdev->preset_chantype;
1587 - } else
1588 + } else if (!nl80211_get_ap_channel(rdev, &params))
1589 return -EINVAL;
1590
1591 if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, params.channel,
1592 @@ -2356,8 +2383,11 @@ static int nl80211_start_ap(struct sk_bu
1593 return -EINVAL;
1594
1595 err = rdev->ops->start_ap(&rdev->wiphy, dev, &params);
1596 - if (!err)
1597 + if (!err) {
1598 + wdev->preset_chan = params.channel;
1599 + wdev->preset_chantype = params.channel_type;
1600 wdev->beacon_interval = params.beacon_interval;
1601 + }
1602 return err;
1603 }
1604