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 */
7 -static bool use_new_ani(struct ath_hw *ah)
9 - return AR_SREV_9300_20_OR_LATER(ah) || modparam_force_new_ani;
12 static void ath9k_hw_update_mibstats(struct ath_hw *ah,
13 struct ath9k_mib_stats *stats)
15 @@ -122,8 +117,6 @@ static void ath9k_hw_update_mibstats(str
16 static void ath9k_ani_restart(struct ath_hw *ah)
18 struct ar5416AniState *aniState;
19 - struct ath_common *common = ath9k_hw_common(ah);
20 - u32 ofdm_base = 0, cck_base = 0;
24 @@ -131,18 +124,10 @@ static void ath9k_ani_restart(struct ath
25 aniState = &ah->curchan->ani;
26 aniState->listenTime = 0;
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;
33 - ath_dbg(common, ANI, "Writing ofdmbase=%u cckbase=%u\n",
34 - ofdm_base, cck_base);
36 ENABLE_REGWRITE_BUFFER(ah);
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);
45 @@ -154,110 +139,6 @@ static void ath9k_ani_restart(struct ath
46 aniState->cckPhyErrCount = 0;
49 -static void ath9k_hw_ani_ofdm_err_trigger_old(struct ath_hw *ah)
51 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
52 - struct ar5416AniState *aniState;
55 - aniState = &ah->curchan->ani;
57 - if (aniState->noiseImmunityLevel < HAL_NOISE_IMMUNE_MAX) {
58 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
59 - aniState->noiseImmunityLevel + 1)) {
64 - if (aniState->spurImmunityLevel < HAL_SPUR_IMMUNE_MAX) {
65 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
66 - aniState->spurImmunityLevel + 1)) {
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);
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,
84 - ath9k_hw_ani_control(ah,
85 - ATH9K_ANI_SPUR_IMMUNITY_LEVEL, 0);
89 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX) {
90 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
91 - aniState->firstepLevel + 1);
94 - } else if (rssi > aniState->rssiThrLow) {
95 - if (aniState->ofdmWeakSigDetectOff)
96 - ath9k_hw_ani_control(ah,
97 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
99 - if (aniState->firstepLevel < HAL_FIRST_STEP_MAX)
100 - ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
101 - aniState->firstepLevel + 1);
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,
110 - if (aniState->firstepLevel > 0)
111 - ath9k_hw_ani_control(ah,
112 - ATH9K_ANI_FIRSTEP_LEVEL, 0);
118 -static void ath9k_hw_ani_cck_err_trigger_old(struct ath_hw *ah)
120 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
121 - struct ar5416AniState *aniState;
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)) {
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);
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);
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);
153 /* Adjust the OFDM Noise Immunity Level */
154 static void ath9k_hw_set_ofdm_nil(struct ath_hw *ah, u8 immunityLevel)
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;
161 - aniState->noiseFloor = BEACON_RSSI(ah);
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);
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;
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);
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)
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);
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;
199 + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI;
200 + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
204 @@ -308,11 +196,6 @@ static void ath9k_hw_ani_ofdm_err_trigge
208 - if (!use_new_ani(ah)) {
209 - ath9k_hw_ani_ofdm_err_trigger_old(ah);
213 aniState = &ah->curchan->ani;
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;
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);
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;
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;
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
247 - if (!use_new_ani(ah)) {
248 - ath9k_hw_ani_cck_err_trigger_old(ah);
252 aniState = &ah->curchan->ani;
254 if (aniState->cckNoiseImmunityLevel < ATH9K_ANI_CCK_MAX_LEVEL)
255 ath9k_hw_set_cck_nil(ah, aniState->cckNoiseImmunityLevel + 1);
258 -static void ath9k_hw_ani_lower_immunity_old(struct ath_hw *ah)
260 - struct ar5416AniState *aniState;
263 - aniState = &ah->curchan->ani;
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))
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,
282 - if (aniState->firstepLevel > 0) {
283 - if (ath9k_hw_ani_control(ah,
284 - ATH9K_ANI_FIRSTEP_LEVEL,
285 - aniState->firstepLevel - 1))
289 - if (aniState->firstepLevel > 0) {
290 - if (ath9k_hw_ani_control(ah,
291 - ATH9K_ANI_FIRSTEP_LEVEL,
292 - aniState->firstepLevel - 1))
298 - if (aniState->spurImmunityLevel > 0) {
299 - if (ath9k_hw_ani_control(ah, ATH9K_ANI_SPUR_IMMUNITY_LEVEL,
300 - aniState->spurImmunityLevel - 1))
304 - if (aniState->noiseImmunityLevel > 0) {
305 - ath9k_hw_ani_control(ah, ATH9K_ANI_NOISE_IMMUNITY_LEVEL,
306 - aniState->noiseImmunityLevel - 1);
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(
316 aniState = &ah->curchan->ani;
318 - if (!use_new_ani(ah)) {
319 - ath9k_hw_ani_lower_immunity_old(ah);
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);
330 -static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
332 - struct ar5416AniState *aniState;
333 - struct ath9k_channel *chan = ah->curchan;
334 - struct ath_common *common = ath9k_hw_common(ah);
339 - aniState = &ah->curchan->ani;
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++;
346 - if (ah->opmode == NL80211_IFTYPE_AP) {
348 - * ath9k_hw_ani_control() will only process items set on
351 - if (IS_CHAN_2GHZ(chan))
352 - ah->ani_function = (ATH9K_ANI_SPUR_IMMUNITY_LEVEL |
353 - ATH9K_ANI_FIRSTEP_LEVEL);
355 - ah->ani_function = 0;
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);
366 - ath9k_ani_restart(ah);
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);
386 - ath9k_ani_restart(ah);
388 - ENABLE_REGWRITE_BUFFER(ah);
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);
393 - REGWRITE_BUFFER_FLUSH(ah);
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;
408 - if (!use_new_ani(ah))
409 - return ath9k_ani_reset_old(ah, is_scanning);
411 BUG_ON(aniState == NULL);
412 ah->stats.ast_ani_reset++;
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;
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);
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);
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;
437 @@ -603,11 +356,9 @@ void ath9k_ani_reset(struct ath_hw *ah,
438 aniState->cckNoiseImmunityLevel);
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);
446 + ath9k_hw_set_ofdm_nil(ah, ofdm_nil);
447 + ath9k_hw_set_cck_nil(ah, cck_nil);
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
453 struct ath_common *common = ath9k_hw_common(ah);
454 struct ar5416AniState *aniState = &ah->curchan->ani;
457 - u32 ofdmPhyErrCnt, cckPhyErrCnt;
458 u32 phyCnt1, phyCnt2;
461 @@ -642,11 +390,6 @@ static bool ath9k_hw_ani_read_counters(s
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;
470 aniState->listenTime += listenTime;
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);
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);
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);
496 + ah->stats.ast_ani_ofdmerrs += phyCnt1 - aniState->ofdmPhyErrCount;
497 + aniState->ofdmPhyErrCount = phyCnt1;
499 + ah->stats.ast_ani_cckerrs += phyCnt2 - aniState->cckPhyErrCount;
500 + aniState->cckPhyErrCount = phyCnt2;
502 - ofdmPhyErrCnt = phyCnt1 - ofdm_base;
503 - ah->stats.ast_ani_ofdmerrs +=
504 - ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
505 - aniState->ofdmPhyErrCount = ofdmPhyErrCnt;
507 - cckPhyErrCnt = phyCnt2 - cck_base;
508 - ah->stats.ast_ani_cckerrs +=
509 - cckPhyErrCnt - aniState->cckPhyErrCount;
510 - aniState->cckPhyErrCount = cckPhyErrCnt;
514 @@ -716,21 +436,10 @@ void ath9k_hw_ani_monitor(struct ath_hw
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) ||
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
540 EXPORT_SYMBOL(ath9k_hw_disable_mib_counters);
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.
547 -void ath9k_hw_proc_mib_event(struct ath_hw *ah)
549 - u32 phyCnt1, phyCnt2;
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);
557 - /* Clear the mib counters and save them in the stats */
558 - ath9k_hw_update_mibstats(ah, &ah->ah_mibStats);
562 - * We must always clear the interrupt cause by
563 - * resetting the phy error regs.
565 - REG_WRITE(ah, AR_PHY_ERR_1, 0);
566 - REG_WRITE(ah, AR_PHY_ERR_2, 0);
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)) {
576 - if (!use_new_ani(ah))
577 - ath9k_hw_ani_read_counters(ah);
579 - /* NB: always restart to insure the h/w counters are reset */
580 - ath9k_ani_restart(ah);
583 -EXPORT_SYMBOL(ath9k_hw_proc_mib_event);
585 void ath9k_hw_ani_setup(struct ath_hw *ah)
588 @@ -845,50 +511,31 @@ void ath9k_hw_ani_init(struct ath_hw *ah
590 ath_dbg(common, ANI, "Initialize ANI\n");
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;
598 - ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH_NEW;
599 - ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW_NEW;
601 - ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_OLD;
602 - ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW_OLD;
604 - ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH_OLD;
605 - ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW_OLD;
607 + ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH;
608 + ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW;
610 for (i = 0; i < ARRAY_SIZE(ah->channels); i++) {
611 struct ath9k_channel *chan = &ah->channels[i];
612 struct ar5416AniState *ani = &chan->ani;
614 - if (use_new_ani(ah)) {
615 - ani->spurImmunityLevel =
616 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW;
617 + ani->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
619 - ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL_NEW;
620 + ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
622 - if (AR_SREV_9300_20_OR_LATER(ah))
624 - !ATH9K_ANI_ENABLE_MRC_CCK;
626 - ani->mrcCCKOff = true;
628 - ani->ofdmsTurn = true;
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))
635 + !ATH9K_ANI_ENABLE_MRC_CCK;
637 + ani->mrcCCKOff = true;
639 - ani->cckWeakSigThreshold =
640 - ATH9K_ANI_CCK_WEAK_SIG_THR;
642 + ani->ofdmsTurn = true;
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.
656 - if (use_new_ani(ah)) {
657 - ah->aniperiod = ATH9K_ANI_PERIOD_NEW;
658 - ah->config.ani_poll_interval = ATH9K_ANI_POLLINTERVAL_NEW;
660 - ah->aniperiod = ATH9K_ANI_PERIOD_OLD;
661 - ah->config.ani_poll_interval = ATH9K_ANI_POLLINTERVAL_OLD;
663 + ah->aniperiod = ATH9K_ANI_PERIOD;
664 + ah->config.ani_poll_interval = ATH9K_ANI_POLLINTERVAL;
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
671 #define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
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
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
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
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
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
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
703 -#define ATH9K_ANI_FIRSTEP_LVL_OLD 0
704 -#define ATH9K_ANI_FIRSTEP_LVL_NEW 2
705 +#define ATH9K_ANI_FIRSTEP_LVL 2
707 #define ATH9K_ANI_RSSI_THR_HIGH 40
708 #define ATH9K_ANI_RSSI_THR_LOW 7
710 -#define ATH9K_ANI_PERIOD_OLD 100
711 -#define ATH9K_ANI_PERIOD_NEW 300
712 +#define ATH9K_ANI_PERIOD 300
715 -#define ATH9K_ANI_POLLINTERVAL_OLD 100
716 -#define ATH9K_ANI_POLLINTERVAL_NEW 1000
717 +#define ATH9K_ANI_POLLINTERVAL 1000
719 #define HAL_NOISE_IMMUNE_MAX 4
720 #define HAL_SPUR_IMMUNE_MAX 7
721 @@ -122,13 +114,12 @@ struct ar5416AniState {
723 u8 spurImmunityLevel;
725 - u8 ofdmWeakSigDetectOff;
726 + u8 ofdmWeakSigDetect;
727 u8 cckWeakSigThreshold;
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
742 -static bool ar5008_hw_ani_control_old(struct ath_hw *ah,
743 - enum ath9k_ani_cmd cmd,
746 - struct ar5416AniState *aniState = &ah->curchan->ani;
747 - struct ath_common *common = ath9k_hw_common(ah);
749 - switch (cmd & ah->ani_function) {
750 - case ATH9K_ANI_NOISE_IMMUNITY_LEVEL:{
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));
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]);
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;
779 - case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
780 - u32 on = param ? 1 : 0;
783 - REG_SET_BIT(ah, AR_PHY_SFCORR_LOW,
784 - AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
786 - REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW,
787 - AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW);
789 - if (!on != aniState->ofdmWeakSigDetectOff) {
791 - ah->stats.ast_ani_ofdmon++;
793 - ah->stats.ast_ani_ofdmoff++;
794 - aniState->ofdmWeakSigDetectOff = !on;
798 - case ATH9K_ANI_CCK_WEAK_SIGNAL_THR:{
799 - static const int weakSigThrCck[] = { 8, 6 };
800 - u32 high = param ? 1 : 0;
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) {
807 - ah->stats.ast_ani_cckhigh++;
809 - ah->stats.ast_ani_ccklow++;
810 - aniState->cckWeakSigThreshold = high;
814 - case ATH9K_ANI_FIRSTEP_LEVEL:{
815 - static const int firstep[] = { 0, 4, 8 };
818 - if (level >= ARRAY_SIZE(firstep)) {
819 - ath_dbg(common, ANI, "level out of range (%u > %zu)\n",
820 - level, ARRAY_SIZE(firstep));
823 - REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
824 - AR_PHY_FIND_SIG_FIRSTEP,
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;
833 - case ATH9K_ANI_SPUR_IMMUNITY_LEVEL:{
834 - static const int cycpwrThr1[] = { 2, 4, 6, 8, 10, 12, 14, 16 };
837 - if (level >= ARRAY_SIZE(cycpwrThr1)) {
838 - ath_dbg(common, ANI, "level out of range (%u > %zu)\n",
839 - level, ARRAY_SIZE(cycpwrThr1));
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;
852 - case ATH9K_ANI_PRESENT:
855 - ath_dbg(common, ANI, "invalid cmd %u\n", cmd);
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);
877 static bool ar5008_hw_ani_control_new(struct ath_hw *ah,
878 enum ath9k_ani_cmd cmd,
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);
884 - if (!on != aniState->ofdmWeakSigDetectOff) {
885 + if (on != aniState->ofdmWeakSigDetect) {
887 "** ch %d: ofdm weak signal: %s=>%s\n",
889 - !aniState->ofdmWeakSigDetectOff ?
890 + aniState->ofdmWeakSigDetect ?
894 ah->stats.ast_ani_ofdmon++;
896 ah->stats.ast_ani_ofdmoff++;
897 - aniState->ofdmWeakSigDetectOff = !on;
898 + aniState->ofdmWeakSigDetect = on;
902 @@ -1236,7 +1101,7 @@ static bool ar5008_hw_ani_control_new(st
903 * from INI file & cap value
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
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
922 aniState->firstepLevel,
924 - ATH9K_ANI_FIRSTEP_LVL_NEW,
925 + ATH9K_ANI_FIRSTEP_LVL,
927 aniState->iniDef.firstep);
929 @@ -1275,7 +1140,7 @@ static bool ar5008_hw_ani_control_new(st
931 aniState->firstepLevel,
933 - ATH9K_ANI_FIRSTEP_LVL_NEW,
934 + ATH9K_ANI_FIRSTEP_LVL,
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
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
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
958 aniState->spurImmunityLevel,
960 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
961 + ATH9K_ANI_SPUR_IMMUNE_LVL,
963 aniState->iniDef.cycpwrThr1);
965 @@ -1339,7 +1204,7 @@ static bool ar5008_hw_ani_control_new(st
967 aniState->spurImmunityLevel,
969 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
970 + ATH9K_ANI_SPUR_IMMUNE_LVL,
972 aniState->iniDef.cycpwrThr1Ext);
973 if (level > aniState->spurImmunityLevel)
974 @@ -1367,7 +1232,7 @@ static bool ar5008_hw_ani_control_new(st
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);
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 */
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;
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;
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;
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
1013 #include "ar9002_initvals.h"
1014 #include "ar9002_phy.h"
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");
1020 /* General hardware code for the A5008/AR9001/AR9002 hadware families */
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);
1029 - if (!on != aniState->ofdmWeakSigDetectOff) {
1030 + if (on != aniState->ofdmWeakSigDetect) {
1031 ath_dbg(common, ANI,
1032 "** ch %d: ofdm weak signal: %s=>%s\n",
1034 - !aniState->ofdmWeakSigDetectOff ?
1035 + aniState->ofdmWeakSigDetect ?
1039 ah->stats.ast_ani_ofdmon++;
1041 ah->stats.ast_ani_ofdmoff++;
1042 - aniState->ofdmWeakSigDetectOff = !on;
1043 + aniState->ofdmWeakSigDetect = on;
1047 @@ -855,7 +855,7 @@ static bool ar9003_hw_ani_control(struct
1048 * from INI file & cap value
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
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
1067 aniState->firstepLevel,
1069 - ATH9K_ANI_FIRSTEP_LVL_NEW,
1070 + ATH9K_ANI_FIRSTEP_LVL,
1072 aniState->iniDef.firstep);
1073 ath_dbg(common, ANI,
1074 @@ -894,7 +894,7 @@ static bool ar9003_hw_ani_control(struct
1076 aniState->firstepLevel,
1078 - ATH9K_ANI_FIRSTEP_LVL_NEW,
1079 + ATH9K_ANI_FIRSTEP_LVL,
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
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
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
1103 aniState->spurImmunityLevel,
1105 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
1106 + ATH9K_ANI_SPUR_IMMUNE_LVL,
1108 aniState->iniDef.cycpwrThr1);
1109 ath_dbg(common, ANI,
1110 @@ -958,7 +958,7 @@ static bool ar9003_hw_ani_control(struct
1112 aniState->spurImmunityLevel,
1114 - ATH9K_ANI_SPUR_IMMUNE_LVL_NEW,
1115 + ATH9K_ANI_SPUR_IMMUNE_LVL,
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);
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;
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);
1157 void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
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.
1165 -extern int modparam_force_new_ani;
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);
1171 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1172 --- a/drivers/net/wireless/ath/ath9k/main.c
1173 +++ b/drivers/net/wireless/ath/ath9k/main.c
1178 -static u8 parse_mpdudensity(u8 mpdudensity)
1179 +u8 ath9k_parse_mpdudensity(u8 mpdudensity)
1182 * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
1183 @@ -320,6 +320,7 @@ static void ath_node_attach(struct ath_s
1184 struct ieee80211_vif *vif)
1186 struct ath_node *an;
1188 an = (struct ath_node *)sta->drv_priv;
1190 #ifdef CONFIG_ATH9K_DEBUGFS
1191 @@ -334,7 +335,8 @@ static void ath_node_attach(struct ath_s
1192 ath_tx_node_init(sc, an);
1193 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
1194 sta->ht_cap.ampdu_factor);
1195 - an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);
1196 + density = ath9k_parse_mpdudensity(sta->ht_cap.ampdu_density);
1197 + an->mpdudensity = density;
1201 @@ -516,24 +518,6 @@ irqreturn_t ath_isr(int irq, void *dev)
1202 ath9k_hw_set_interrupts(ah);
1205 - if (status & ATH9K_INT_MIB) {
1207 - * Disable interrupts until we service the MIB
1208 - * interrupt; otherwise it will continue to
1211 - ath9k_hw_disable_interrupts(ah);
1213 - * Let the hal handle the event. We assume
1214 - * it will clear whatever condition caused
1217 - spin_lock(&common->cc_lock);
1218 - ath9k_hw_proc_mib_event(ah);
1219 - spin_unlock(&common->cc_lock);
1220 - ath9k_hw_enable_interrupts(ah);
1223 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
1224 if (status & ATH9K_INT_TIM_TIMER) {
1225 if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
1226 @@ -959,14 +943,10 @@ static void ath9k_calculate_summary_stat
1228 * Enable MIB interrupts when there are hardware phy counters.
1230 - if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0) {
1231 - if (ah->config.enable_ani)
1232 - ah->imask |= ATH9K_INT_MIB;
1233 + if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0)
1234 ah->imask |= ATH9K_INT_TSFOOR;
1236 - ah->imask &= ~ATH9K_INT_MIB;
1238 ah->imask &= ~ATH9K_INT_TSFOOR;
1241 ath9k_hw_set_interrupts(ah);
1243 --- a/net/mac80211/agg-rx.c
1244 +++ b/net/mac80211/agg-rx.c
1245 @@ -201,6 +201,8 @@ static void ieee80211_send_addba_resp(st
1246 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1247 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1248 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
1249 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
1250 + memcpy(mgmt->bssid, da, ETH_ALEN);
1252 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1253 IEEE80211_STYPE_ACTION);
1254 --- a/net/mac80211/agg-tx.c
1255 +++ b/net/mac80211/agg-tx.c
1256 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
1257 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
1258 if (sdata->vif.type == NL80211_IFTYPE_AP ||
1259 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1260 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
1261 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
1262 + sdata->vif.type == NL80211_IFTYPE_WDS)
1263 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
1264 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
1265 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1266 @@ -456,6 +457,7 @@ int ieee80211_start_tx_ba_session(struct
1267 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1268 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1269 sdata->vif.type != NL80211_IFTYPE_AP &&
1270 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1271 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1274 --- a/net/mac80211/debugfs_sta.c
1275 +++ b/net/mac80211/debugfs_sta.c
1276 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
1277 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
1279 int res = scnprintf(buf, sizeof(buf),
1280 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1281 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1282 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
1283 TEST(PS_DRIVER), TEST(AUTHORIZED),
1284 TEST(SHORT_PREAMBLE),
1285 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
1286 + TEST(WME), TEST(CLEAR_PS_FILT),
1287 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
1288 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
1289 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
1290 --- a/net/mac80211/iface.c
1291 +++ b/net/mac80211/iface.c
1292 @@ -284,7 +284,6 @@ static int ieee80211_do_open(struct net_
1294 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1295 struct ieee80211_local *local = sdata->local;
1296 - struct sta_info *sta;
1299 u32 hw_reconf_flags = 0;
1300 @@ -430,28 +429,6 @@ static int ieee80211_do_open(struct net_
1302 set_bit(SDATA_STATE_RUNNING, &sdata->state);
1304 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
1305 - /* Create STA entry for the WDS peer */
1306 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1310 - goto err_del_interface;
1313 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1314 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1315 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1317 - res = sta_info_insert(sta);
1319 - /* STA has been freed */
1320 - goto err_del_interface;
1323 - rate_control_rate_init(sta);
1327 * set_multicast_list will be invoked by the networking core
1328 * which will check whether any increments here were done in
1329 @@ -639,6 +616,8 @@ static void ieee80211_do_stop(struct iee
1330 ieee80211_configure_filter(local);
1333 + flush_work(&local->hw_roc_start);
1334 + flush_work(&local->hw_roc_done);
1335 flush_work(&sdata->work);
1337 * When we get here, the interface is marked down.
1338 @@ -845,6 +824,72 @@ static void ieee80211_if_setup(struct ne
1339 dev->destructor = free_netdev;
1342 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1343 + struct sk_buff *skb)
1345 + struct ieee80211_local *local = sdata->local;
1346 + struct ieee80211_rx_status *rx_status;
1347 + struct ieee802_11_elems elems;
1348 + struct ieee80211_mgmt *mgmt;
1349 + struct sta_info *sta;
1354 + enum ieee80211_band band = local->hw.conf.channel->band;
1355 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
1357 + rx_status = IEEE80211_SKB_RXCB(skb);
1358 + mgmt = (struct ieee80211_mgmt *) skb->data;
1359 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1361 + if (stype != IEEE80211_STYPE_BEACON)
1364 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1365 + if (baselen > skb->len)
1368 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1369 + skb->len - baselen, &elems);
1371 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
1375 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1378 + rcu_read_unlock();
1379 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1387 + sta->last_rx = jiffies;
1388 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
1390 + if (elems.ht_cap_elem)
1391 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1392 + elems.ht_cap_elem, &sta->sta.ht_cap);
1394 + if (elems.wmm_param)
1395 + set_sta_flag(sta, WLAN_STA_WME);
1398 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1399 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1400 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1401 + rate_control_rate_init(sta);
1402 + sta_info_insert_rcu(sta);
1405 + rcu_read_unlock();
1408 static void ieee80211_iface_work(struct work_struct *work)
1410 struct ieee80211_sub_if_data *sdata =
1411 @@ -949,6 +994,9 @@ static void ieee80211_iface_work(struct
1413 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1415 + case NL80211_IFTYPE_WDS:
1416 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1419 WARN(1, "frame for unexpected interface type");
1421 --- a/net/mac80211/rx.c
1422 +++ b/net/mac80211/rx.c
1423 @@ -2281,6 +2281,7 @@ ieee80211_rx_h_action(struct ieee80211_r
1424 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1425 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1426 sdata->vif.type != NL80211_IFTYPE_AP &&
1427 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1428 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1431 @@ -2495,14 +2496,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
1433 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1434 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
1435 - sdata->vif.type != NL80211_IFTYPE_STATION)
1436 + sdata->vif.type != NL80211_IFTYPE_STATION &&
1437 + sdata->vif.type != NL80211_IFTYPE_WDS)
1438 return RX_DROP_MONITOR;
1441 case cpu_to_le16(IEEE80211_STYPE_AUTH):
1442 case cpu_to_le16(IEEE80211_STYPE_BEACON):
1443 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
1444 - /* process for all: mesh, mlme, ibss */
1445 + /* process for all: mesh, mlme, ibss, wds */
1447 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
1448 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
1449 @@ -2833,10 +2835,16 @@ static int prepare_for_handlers(struct i
1452 case NL80211_IFTYPE_WDS:
1453 - if (bssid || !ieee80211_is_data(hdr->frame_control))
1455 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
1458 + if (ieee80211_is_data(hdr->frame_control) ||
1459 + ieee80211_is_action(hdr->frame_control)) {
1460 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
1462 + } else if (!ieee80211_is_beacon(hdr->frame_control))
1467 /* should never get here */
1468 --- a/net/mac80211/sta_info.h
1469 +++ b/net/mac80211/sta_info.h
1471 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
1473 * @WLAN_STA_WME: Station is a QoS-STA.
1474 - * @WLAN_STA_WDS: Station is one of our WDS peers.
1475 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
1476 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
1477 * frame to this station is transmitted.
1478 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
1479 WLAN_STA_AUTHORIZED,
1480 WLAN_STA_SHORT_PREAMBLE,
1483 WLAN_STA_CLEAR_PS_FILT,
1486 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
1487 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
1488 @@ -214,6 +214,7 @@ struct ath_frame_info {
1489 enum ath9k_key_type keytype;
1495 struct ath_buf_state {
1496 @@ -721,6 +722,7 @@ extern int ath9k_modparam_nohwcrypt;
1497 extern int led_blink;
1498 extern bool is_ath9k_unloaded;
1500 +u8 ath9k_parse_mpdudensity(u8 mpdudensity);
1501 irqreturn_t ath_isr(int irq, void *dev);
1502 int ath9k_init_device(u16 devid, struct ath_softc *sc,
1503 const struct ath_bus_ops *bus_ops);
1504 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1505 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1506 @@ -938,6 +938,7 @@ static void ath_buf_set_rate(struct ath_
1507 struct ieee80211_tx_rate *rates;
1508 const struct ieee80211_rate *rate;
1509 struct ieee80211_hdr *hdr;
1510 + struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
1514 @@ -948,18 +949,7 @@ static void ath_buf_set_rate(struct ath_
1516 /* set dur_update_en for l-sig computation except for PS-Poll frames */
1517 info->dur_update = !ieee80211_is_pspoll(hdr->frame_control);
1520 - * We check if Short Preamble is needed for the CTS rate by
1521 - * checking the BSS's global flag.
1522 - * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
1524 - rate = ieee80211_get_rts_cts_rate(sc->hw, tx_info);
1525 - info->rtscts_rate = rate->hw_value;
1527 - if (tx_info->control.vif &&
1528 - tx_info->control.vif->bss_conf.use_short_preamble)
1529 - info->rtscts_rate |= rate->hw_value_short;
1530 + info->rtscts_rate = fi->rtscts_rate;
1532 for (i = 0; i < 4; i++) {
1533 bool is_40, is_sgi, is_sp;
1534 @@ -1001,13 +991,13 @@ static void ath_buf_set_rate(struct ath_
1538 + rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx];
1539 if ((tx_info->band == IEEE80211_BAND_2GHZ) &&
1540 !(rate->flags & IEEE80211_RATE_ERP_G))
1541 phy = WLAN_RC_PHY_CCK;
1543 phy = WLAN_RC_PHY_OFDM;
1545 - rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx];
1546 info->rates[i].Rate = rate->hw_value;
1547 if (rate->hw_value_short) {
1548 if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
1549 @@ -1175,6 +1165,7 @@ int ath_tx_aggr_start(struct ath_softc *
1551 struct ath_atx_tid *txtid;
1552 struct ath_node *an;
1555 an = (struct ath_node *)sta->drv_priv;
1556 txtid = ATH_AN_2_TID(an, tid);
1557 @@ -1182,6 +1173,17 @@ int ath_tx_aggr_start(struct ath_softc *
1558 if (txtid->state & (AGGR_CLEANUP | AGGR_ADDBA_COMPLETE))
1561 + /* update ampdu factor/density, they may have changed. This may happen
1562 + * in HT IBSS when a beacon with HT-info is received after the station
1563 + * has already been added.
1565 + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
1566 + an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
1567 + sta->ht_cap.ampdu_factor);
1568 + density = ath9k_parse_mpdudensity(sta->ht_cap.ampdu_density);
1569 + an->mpdudensity = density;
1572 txtid->state |= AGGR_ADDBA_PROGRESS;
1573 txtid->paused = true;
1574 *ssn = txtid->seq_start = txtid->seq_next;
1575 @@ -1776,10 +1778,22 @@ static void setup_frame_info(struct ieee
1576 struct ieee80211_sta *sta = tx_info->control.sta;
1577 struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
1578 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1579 + const struct ieee80211_rate *rate;
1580 struct ath_frame_info *fi = get_frame_info(skb);
1581 struct ath_node *an = NULL;
1582 enum ath9k_key_type keytype;
1583 + bool short_preamble = false;
1586 + * We check if Short Preamble is needed for the CTS rate by
1587 + * checking the BSS's global flag.
1588 + * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
1590 + if (tx_info->control.vif &&
1591 + tx_info->control.vif->bss_conf.use_short_preamble)
1592 + short_preamble = true;
1594 + rate = ieee80211_get_rts_cts_rate(hw, tx_info);
1595 keytype = ath9k_cmn_get_hw_crypto_keytype(skb);
1598 @@ -1794,6 +1808,9 @@ static void setup_frame_info(struct ieee
1599 fi->keyix = ATH9K_TXKEYIX_INVALID;
1600 fi->keytype = keytype;
1601 fi->framelen = framelen;
1602 + fi->rtscts_rate = rate->hw_value;
1603 + if (short_preamble)
1604 + fi->rtscts_rate |= rate->hw_value_short;
1607 u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate)
1608 --- a/net/wireless/nl80211.c
1609 +++ b/net/wireless/nl80211.c
1610 @@ -2246,6 +2246,33 @@ static int nl80211_parse_beacon(struct g
1614 +static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev,
1615 + struct cfg80211_ap_settings *params)
1617 + struct wireless_dev *wdev;
1620 + mutex_lock(&rdev->devlist_mtx);
1622 + list_for_each_entry(wdev, &rdev->netdev_list, list) {
1623 + if (wdev->iftype != NL80211_IFTYPE_AP &&
1624 + wdev->iftype != NL80211_IFTYPE_P2P_GO)
1627 + if (!wdev->preset_chan)
1630 + params->channel = wdev->preset_chan;
1631 + params->channel_type = wdev->preset_chantype;
1636 + mutex_unlock(&rdev->devlist_mtx);
1641 static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
1643 struct cfg80211_registered_device *rdev = info->user_ptr[0];
1644 @@ -2348,7 +2375,7 @@ static int nl80211_start_ap(struct sk_bu
1645 } else if (wdev->preset_chan) {
1646 params.channel = wdev->preset_chan;
1647 params.channel_type = wdev->preset_chantype;
1649 + } else if (!nl80211_get_ap_channel(rdev, ¶ms))
1652 if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, params.channel,
1653 @@ -2356,8 +2383,11 @@ static int nl80211_start_ap(struct sk_bu
1656 err = rdev->ops->start_ap(&rdev->wiphy, dev, ¶ms);
1659 + wdev->preset_chan = params.channel;
1660 + wdev->preset_chantype = params.channel_type;
1661 wdev->beacon_interval = params.beacon_interval;
1666 --- a/drivers/net/wireless/ath/ath9k/link.c
1667 +++ b/drivers/net/wireless/ath/ath9k/link.c
1668 @@ -407,6 +407,7 @@ void ath_ani_calibrate(unsigned long dat
1669 longcal ? "long" : "", shortcal ? "short" : "",
1670 aniflag ? "ani" : "", common->ani.caldone ? "true" : "false");
1672 + ath9k_debug_samp_bb_mac(sc);
1673 ath9k_ps_restore(sc);
1676 @@ -415,7 +416,6 @@ set_timer:
1677 * The interval must be the shortest necessary to satisfy ANI,
1678 * short calibration and long calibration.
1680 - ath9k_debug_samp_bb_mac(sc);
1681 cal_interval = ATH_LONG_CALINTERVAL;
1682 if (sc->sc_ah->config.enable_ani)
1683 cal_interval = min(cal_interval,