Lines Matching +full:last +full:- +full:level
33 * - "noise immunity"
35 * - "spur immunity"
37 * - "firstep level"
39 * - "OFDM weak signal detection"
41 * - "CCK weak signal detection"
61 * ath5k_ani_set_noise_immunity_level() - Set noise immunity level
63 * @level: level between 0 and @ATH5K_ANI_MAX_NOISE_IMM_LVL
66 ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level) in ath5k_ani_set_noise_immunity_level() argument
70 * and ath9k use only the last two levels, making this in ath5k_ani_set_noise_immunity_level()
75 static const s8 lo[] = { -52, -56, -60, -64, -70 }; in ath5k_ani_set_noise_immunity_level()
76 static const s8 hi[] = { -18, -18, -16, -14, -12 }; in ath5k_ani_set_noise_immunity_level()
77 static const s8 sz[] = { -34, -41, -48, -55, -62 }; in ath5k_ani_set_noise_immunity_level()
78 static const s8 fr[] = { -70, -72, -75, -78, -80 }; in ath5k_ani_set_noise_immunity_level()
80 static const s8 lo[] = { -64, -70 }; in ath5k_ani_set_noise_immunity_level()
81 static const s8 hi[] = { -14, -12 }; in ath5k_ani_set_noise_immunity_level()
82 static const s8 sz[] = { -55, -62 }; in ath5k_ani_set_noise_immunity_level()
83 static const s8 fr[] = { -78, -80 }; in ath5k_ani_set_noise_immunity_level()
85 if (level < 0 || level >= ARRAY_SIZE(sz)) { in ath5k_ani_set_noise_immunity_level()
86 ATH5K_ERR(ah, "noise immunity level %d out of range", in ath5k_ani_set_noise_immunity_level()
87 level); in ath5k_ani_set_noise_immunity_level()
92 AR5K_PHY_DESIRED_SIZE_TOT, sz[level]); in ath5k_ani_set_noise_immunity_level()
94 AR5K_PHY_AGCCOARSE_LO, lo[level]); in ath5k_ani_set_noise_immunity_level()
96 AR5K_PHY_AGCCOARSE_HI, hi[level]); in ath5k_ani_set_noise_immunity_level()
98 AR5K_PHY_SIG_FIRPWR, fr[level]); in ath5k_ani_set_noise_immunity_level()
100 ah->ani_state.noise_imm_level = level; in ath5k_ani_set_noise_immunity_level()
101 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); in ath5k_ani_set_noise_immunity_level()
105 * ath5k_ani_set_spur_immunity_level() - Set spur immunity level
107 * @level: level between 0 and @max_spur_level (the maximum level is dependent
111 ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level) in ath5k_ani_set_spur_immunity_level() argument
115 if (level < 0 || level >= ARRAY_SIZE(val) || in ath5k_ani_set_spur_immunity_level()
116 level > ah->ani_state.max_spur_level) { in ath5k_ani_set_spur_immunity_level()
117 ATH5K_ERR(ah, "spur immunity level %d out of range", in ath5k_ani_set_spur_immunity_level()
118 level); in ath5k_ani_set_spur_immunity_level()
123 AR5K_PHY_OFDM_SELFCORR_CYPWR_THR1, val[level]); in ath5k_ani_set_spur_immunity_level()
125 ah->ani_state.spur_level = level; in ath5k_ani_set_spur_immunity_level()
126 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); in ath5k_ani_set_spur_immunity_level()
130 * ath5k_ani_set_firstep_level() - Set "firstep" level
132 * @level: level between 0 and @ATH5K_ANI_MAX_FIRSTEP_LVL
135 ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level) in ath5k_ani_set_firstep_level() argument
139 if (level < 0 || level >= ARRAY_SIZE(val)) { in ath5k_ani_set_firstep_level()
140 ATH5K_ERR(ah, "firstep level %d out of range", level); in ath5k_ani_set_firstep_level()
145 AR5K_PHY_SIG_FIRSTEP, val[level]); in ath5k_ani_set_firstep_level()
147 ah->ani_state.firstep_level = level; in ath5k_ani_set_firstep_level()
148 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); in ath5k_ani_set_firstep_level()
152 * ath5k_ani_set_ofdm_weak_signal_detection() - Set OFDM weak signal detection
186 ah->ani_state.ofdm_weak_sig = on; in ath5k_ani_set_ofdm_weak_signal_detection()
192 * ath5k_ani_set_cck_weak_signal_detection() - Set CCK weak signal detection
202 ah->ani_state.cck_weak_sig = on; in ath5k_ani_set_cck_weak_signal_detection()
213 * ath5k_ani_raise_immunity() - Increase noise immunity
226 int rssi = ewma_beacon_rssi_read(&ah->ah_beacon_rssi_avg); in ath5k_ani_raise_immunity()
232 if (as->noise_imm_level < ATH5K_ANI_MAX_NOISE_IMM_LVL) { in ath5k_ani_raise_immunity()
233 ath5k_ani_set_noise_immunity_level(ah, as->noise_imm_level + 1); in ath5k_ani_raise_immunity()
237 /* only OFDM: raise spur immunity level */ in ath5k_ani_raise_immunity()
239 as->spur_level < ah->ani_state.max_spur_level) { in ath5k_ani_raise_immunity()
240 ath5k_ani_set_spur_immunity_level(ah, as->spur_level + 1); in ath5k_ani_raise_immunity()
245 if (ah->opmode == NL80211_IFTYPE_AP) { in ath5k_ani_raise_immunity()
246 if (as->firstep_level < ATH5K_ANI_MAX_FIRSTEP_LVL) in ath5k_ani_raise_immunity()
247 ath5k_ani_set_firstep_level(ah, as->firstep_level + 1); in ath5k_ani_raise_immunity()
262 if (ofdm_trigger && as->ofdm_weak_sig) { in ath5k_ani_raise_immunity()
267 /* as a last resort or CCK: raise firstep level */ in ath5k_ani_raise_immunity()
268 if (as->firstep_level < ATH5K_ANI_MAX_FIRSTEP_LVL) { in ath5k_ani_raise_immunity()
269 ath5k_ani_set_firstep_level(ah, as->firstep_level + 1); in ath5k_ani_raise_immunity()
274 * but can raise firstep level */ in ath5k_ani_raise_immunity()
277 if (ofdm_trigger && !as->ofdm_weak_sig) in ath5k_ani_raise_immunity()
279 if (as->firstep_level < ATH5K_ANI_MAX_FIRSTEP_LVL) in ath5k_ani_raise_immunity()
280 ath5k_ani_set_firstep_level(ah, as->firstep_level + 1); in ath5k_ani_raise_immunity()
282 } else if (ah->ah_current_channel->band == NL80211_BAND_2GHZ) { in ath5k_ani_raise_immunity()
284 * detect and zero firstep level to maximize CCK sensitivity */ in ath5k_ani_raise_immunity()
287 if (ofdm_trigger && as->ofdm_weak_sig) in ath5k_ani_raise_immunity()
289 if (as->firstep_level > 0) in ath5k_ani_raise_immunity()
295 if (as->cck_weak_sig == true) { in ath5k_ani_raise_immunity()
302 * ath5k_ani_lower_immunity() - Decrease noise immunity
312 int rssi = ewma_beacon_rssi_read(&ah->ah_beacon_rssi_avg); in ath5k_ani_lower_immunity()
316 if (ah->opmode == NL80211_IFTYPE_AP) { in ath5k_ani_lower_immunity()
318 if (as->firstep_level > 0) { in ath5k_ani_lower_immunity()
319 ath5k_ani_set_firstep_level(ah, as->firstep_level - 1); in ath5k_ani_lower_immunity()
329 /* beacon RSSI is mid-range: turn on ODFM weak signal in ath5k_ani_lower_immunity()
330 * detection and next, lower firstep level */ in ath5k_ani_lower_immunity()
331 if (!as->ofdm_weak_sig) { in ath5k_ani_lower_immunity()
336 if (as->firstep_level > 0) { in ath5k_ani_lower_immunity()
338 as->firstep_level - 1); in ath5k_ani_lower_immunity()
342 /* beacon signal is low: only reduce firstep level */ in ath5k_ani_lower_immunity()
343 if (as->firstep_level > 0) { in ath5k_ani_lower_immunity()
345 as->firstep_level - 1); in ath5k_ani_lower_immunity()
352 if (as->spur_level > 0) { in ath5k_ani_lower_immunity()
353 ath5k_ani_set_spur_immunity_level(ah, as->spur_level - 1); in ath5k_ani_lower_immunity()
358 if (as->noise_imm_level > 0) { in ath5k_ani_lower_immunity()
359 ath5k_ani_set_noise_immunity_level(ah, as->noise_imm_level - 1); in ath5k_ani_lower_immunity()
365 * ath5k_hw_ani_get_listen_time() - Update counters and return listening time
370 * since the last call of this function.
379 spin_lock_bh(&common->cc_lock); in ath5k_hw_ani_get_listen_time()
382 memcpy(&as->last_cc, &common->cc_ani, sizeof(as->last_cc)); in ath5k_hw_ani_get_listen_time()
384 /* clears common->cc_ani */ in ath5k_hw_ani_get_listen_time()
387 spin_unlock_bh(&common->cc_lock); in ath5k_hw_ani_get_listen_time()
393 * ath5k_ani_save_and_clear_phy_errors() - Clear and save PHY error counters
411 if (!ah->ah_capabilities.cap_has_phyerr_counters) in ath5k_ani_save_and_clear_phy_errors()
418 ath5k_hw_reg_write(ah, ATH5K_PHYERR_CNT_MAX - ATH5K_ANI_OFDM_TRIG_HIGH, in ath5k_ani_save_and_clear_phy_errors()
420 ath5k_hw_reg_write(ah, ATH5K_PHYERR_CNT_MAX - ATH5K_ANI_CCK_TRIG_HIGH, in ath5k_ani_save_and_clear_phy_errors()
423 ofdm_err = ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - ofdm_err); in ath5k_ani_save_and_clear_phy_errors()
424 cck_err = ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX - cck_err); in ath5k_ani_save_and_clear_phy_errors()
433 as->ofdm_errors += ofdm_err; in ath5k_ani_save_and_clear_phy_errors()
434 as->sum_ofdm_errors += ofdm_err; in ath5k_ani_save_and_clear_phy_errors()
437 as->cck_errors += cck_err; in ath5k_ani_save_and_clear_phy_errors()
438 as->sum_cck_errors += cck_err; in ath5k_ani_save_and_clear_phy_errors()
444 * ath5k_ani_period_restart() - Restart ANI period
452 /* keep last values for debugging */ in ath5k_ani_period_restart()
453 as->last_ofdm_errors = as->ofdm_errors; in ath5k_ani_period_restart()
454 as->last_cck_errors = as->cck_errors; in ath5k_ani_period_restart()
455 as->last_listen = as->listen_time; in ath5k_ani_period_restart()
457 as->ofdm_errors = 0; in ath5k_ani_period_restart()
458 as->cck_errors = 0; in ath5k_ani_period_restart()
459 as->listen_time = 0; in ath5k_ani_period_restart()
463 * ath5k_ani_calibration() - The main ANI calibration function
477 struct ath5k_ani_state *as = &ah->ani_state; in ath5k_ani_calibration()
480 /* get listen time since last call and add it to the counter because we in ath5k_ani_calibration()
481 * might not have restarted the "ani period" last time. in ath5k_ani_calibration()
484 as->listen_time += listen; in ath5k_ani_calibration()
486 if (as->ani_mode != ATH5K_ANI_MODE_AUTO) in ath5k_ani_calibration()
491 ofdm_high = as->listen_time * ATH5K_ANI_OFDM_TRIG_HIGH / 1000; in ath5k_ani_calibration()
492 cck_high = as->listen_time * ATH5K_ANI_CCK_TRIG_HIGH / 1000; in ath5k_ani_calibration()
493 ofdm_low = as->listen_time * ATH5K_ANI_OFDM_TRIG_LOW / 1000; in ath5k_ani_calibration()
494 cck_low = as->listen_time * ATH5K_ANI_CCK_TRIG_LOW / 1000; in ath5k_ani_calibration()
497 "listen %d (now %d)", as->listen_time, listen); in ath5k_ani_calibration()
500 as->ofdm_errors, ofdm_high, as->cck_errors, cck_high); in ath5k_ani_calibration()
502 if (as->ofdm_errors > ofdm_high || as->cck_errors > cck_high) { in ath5k_ani_calibration()
503 /* too many PHY errors - we have to raise immunity */ in ath5k_ani_calibration()
504 bool ofdm_flag = as->ofdm_errors > ofdm_high; in ath5k_ani_calibration()
508 } else if (as->listen_time > 5 * ATH5K_ANI_LISTEN_PERIOD) { in ath5k_ani_calibration()
513 as->ofdm_errors, ofdm_low, as->cck_errors, cck_low); in ath5k_ani_calibration()
515 if (as->ofdm_errors <= ofdm_low && as->cck_errors <= cck_low) in ath5k_ani_calibration()
528 * ath5k_ani_mib_intr() - Interrupt handler for ANI MIB counters
541 struct ath5k_ani_state *as = &ah->ani_state; in ath5k_ani_mib_intr()
543 /* nothing to do here if HW does not have PHY error counters - they in ath5k_ani_mib_intr()
545 if (!ah->ah_capabilities.cap_has_phyerr_counters) in ath5k_ani_mib_intr()
552 if (ah->ani_state.ani_mode != ATH5K_ANI_MODE_AUTO) in ath5k_ani_mib_intr()
561 if (as->ofdm_errors > ATH5K_ANI_OFDM_TRIG_HIGH || in ath5k_ani_mib_intr()
562 as->cck_errors > ATH5K_ANI_CCK_TRIG_HIGH) in ath5k_ani_mib_intr()
563 tasklet_schedule(&ah->ani_tasklet); in ath5k_ani_mib_intr()
567 * ath5k_ani_phy_error_report - Used by older HW to report PHY errors
573 * on a frame-by-frame basis, instead of the interrupt.
579 struct ath5k_ani_state *as = &ah->ani_state; in ath5k_ani_phy_error_report()
582 as->ofdm_errors++; in ath5k_ani_phy_error_report()
583 if (as->ofdm_errors > ATH5K_ANI_OFDM_TRIG_HIGH) in ath5k_ani_phy_error_report()
584 tasklet_schedule(&ah->ani_tasklet); in ath5k_ani_phy_error_report()
586 as->cck_errors++; in ath5k_ani_phy_error_report()
587 if (as->cck_errors > ATH5K_ANI_CCK_TRIG_HIGH) in ath5k_ani_phy_error_report()
588 tasklet_schedule(&ah->ani_tasklet); in ath5k_ani_phy_error_report()
598 * ath5k_enable_phy_err_counters() - Enable PHY error counters
606 ath5k_hw_reg_write(ah, ATH5K_PHYERR_CNT_MAX - ATH5K_ANI_OFDM_TRIG_HIGH, in ath5k_enable_phy_err_counters()
608 ath5k_hw_reg_write(ah, ATH5K_PHYERR_CNT_MAX - ATH5K_ANI_CCK_TRIG_HIGH, in ath5k_enable_phy_err_counters()
619 * ath5k_disable_phy_err_counters() - Disable PHY error counters
638 * ath5k_ani_init() - Initialize ANI
648 if (ah->ah_version < AR5K_AR5212) in ath5k_ani_init()
657 memset(&ah->ani_state, 0, sizeof(ah->ani_state)); in ath5k_ani_init()
660 if (ah->ah_mac_srev < AR5K_SREV_AR2414) in ath5k_ani_init()
661 ah->ani_state.max_spur_level = 7; in ath5k_ani_init()
663 ah->ani_state.max_spur_level = 2; in ath5k_ani_init()
670 "ANI manual low -> high sensitivity\n"); in ath5k_ani_init()
678 "ANI manual high -> low sensitivity\n"); in ath5k_ani_init()
682 ah->ani_state.max_spur_level); in ath5k_ani_init()
700 if (ah->ah_capabilities.cap_has_phyerr_counters) in ath5k_ani_init()
706 if (ah->ah_capabilities.cap_has_phyerr_counters) in ath5k_ani_init()
713 ah->ani_state.ani_mode = mode; in ath5k_ani_init()
724 * ath5k_ani_print_counters() - Print ANI counters