18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2010 Bruno Randolf <br1@einfach.org> 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci#ifndef ANI_H 178c2ecf20Sopenharmony_ci#define ANI_H 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include "../ath.h" 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cienum ath5k_phy_error_code; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* these thresholds are relative to the ATH5K_ANI_LISTEN_PERIOD */ 248c2ecf20Sopenharmony_ci#define ATH5K_ANI_LISTEN_PERIOD 100 258c2ecf20Sopenharmony_ci#define ATH5K_ANI_OFDM_TRIG_HIGH 500 268c2ecf20Sopenharmony_ci#define ATH5K_ANI_OFDM_TRIG_LOW 200 278c2ecf20Sopenharmony_ci#define ATH5K_ANI_CCK_TRIG_HIGH 200 288c2ecf20Sopenharmony_ci#define ATH5K_ANI_CCK_TRIG_LOW 100 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* average beacon RSSI thresholds */ 318c2ecf20Sopenharmony_ci#define ATH5K_ANI_RSSI_THR_HIGH 40 328c2ecf20Sopenharmony_ci#define ATH5K_ANI_RSSI_THR_LOW 7 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* maximum available levels */ 358c2ecf20Sopenharmony_ci#define ATH5K_ANI_MAX_FIRSTEP_LVL 2 368c2ecf20Sopenharmony_ci#define ATH5K_ANI_MAX_NOISE_IMM_LVL 1 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/** 408c2ecf20Sopenharmony_ci * enum ath5k_ani_mode - mode for ANI / noise sensitivity 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * @ATH5K_ANI_MODE_OFF: Turn ANI off. This can be useful to just stop the ANI 438c2ecf20Sopenharmony_ci * algorithm after it has been on auto mode. 448c2ecf20Sopenharmony_ci * @ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low, 458c2ecf20Sopenharmony_ci * maximizing sensitivity. ANI will not run. 468c2ecf20Sopenharmony_ci * @ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high, 478c2ecf20Sopenharmony_ci * minimizing sensitivity. ANI will not run. 488c2ecf20Sopenharmony_ci * @ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the 498c2ecf20Sopenharmony_ci * amount of OFDM and CCK frame errors (default). 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_cienum ath5k_ani_mode { 528c2ecf20Sopenharmony_ci ATH5K_ANI_MODE_OFF = 0, 538c2ecf20Sopenharmony_ci ATH5K_ANI_MODE_MANUAL_LOW = 1, 548c2ecf20Sopenharmony_ci ATH5K_ANI_MODE_MANUAL_HIGH = 2, 558c2ecf20Sopenharmony_ci ATH5K_ANI_MODE_AUTO = 3 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/** 608c2ecf20Sopenharmony_ci * struct ath5k_ani_state - ANI state and associated counters 618c2ecf20Sopenharmony_ci * @ani_mode: One of enum ath5k_ani_mode 628c2ecf20Sopenharmony_ci * @noise_imm_level: Noise immunity level 638c2ecf20Sopenharmony_ci * @spur_level: Spur immunity level 648c2ecf20Sopenharmony_ci * @firstep_level: FIRstep level 658c2ecf20Sopenharmony_ci * @ofdm_weak_sig: OFDM weak signal detection state (on/off) 668c2ecf20Sopenharmony_ci * @cck_weak_sig: CCK weak signal detection state (on/off) 678c2ecf20Sopenharmony_ci * @max_spur_level: Max spur immunity level (chip specific) 688c2ecf20Sopenharmony_ci * @listen_time: Listen time 698c2ecf20Sopenharmony_ci * @ofdm_errors: OFDM timing error count 708c2ecf20Sopenharmony_ci * @cck_errors: CCK timing error count 718c2ecf20Sopenharmony_ci * @last_cc: The &struct ath_cycle_counters (for stats) 728c2ecf20Sopenharmony_ci * @last_listen: Listen time from previous run (for stats) 738c2ecf20Sopenharmony_ci * @last_ofdm_errors: OFDM timing error count from previous run (for tats) 748c2ecf20Sopenharmony_ci * @last_cck_errors: CCK timing error count from previous run (for stats) 758c2ecf20Sopenharmony_ci * @sum_ofdm_errors: Sum of OFDM timing errors (for stats) 768c2ecf20Sopenharmony_ci * @sum_cck_errors: Sum of all CCK timing errors (for stats) 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_cistruct ath5k_ani_state { 798c2ecf20Sopenharmony_ci enum ath5k_ani_mode ani_mode; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci /* state */ 828c2ecf20Sopenharmony_ci int noise_imm_level; 838c2ecf20Sopenharmony_ci int spur_level; 848c2ecf20Sopenharmony_ci int firstep_level; 858c2ecf20Sopenharmony_ci bool ofdm_weak_sig; 868c2ecf20Sopenharmony_ci bool cck_weak_sig; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci int max_spur_level; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci /* used by the algorithm */ 918c2ecf20Sopenharmony_ci unsigned int listen_time; 928c2ecf20Sopenharmony_ci unsigned int ofdm_errors; 938c2ecf20Sopenharmony_ci unsigned int cck_errors; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* debug/statistics only: numbers from last ANI calibration */ 968c2ecf20Sopenharmony_ci struct ath_cycle_counters last_cc; 978c2ecf20Sopenharmony_ci unsigned int last_listen; 988c2ecf20Sopenharmony_ci unsigned int last_ofdm_errors; 998c2ecf20Sopenharmony_ci unsigned int last_cck_errors; 1008c2ecf20Sopenharmony_ci unsigned int sum_ofdm_errors; 1018c2ecf20Sopenharmony_ci unsigned int sum_cck_errors; 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_civoid ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode); 1058c2ecf20Sopenharmony_civoid ath5k_ani_mib_intr(struct ath5k_hw *ah); 1068c2ecf20Sopenharmony_civoid ath5k_ani_calibration(struct ath5k_hw *ah); 1078c2ecf20Sopenharmony_civoid ath5k_ani_phy_error_report(struct ath5k_hw *ah, 1088c2ecf20Sopenharmony_ci enum ath5k_phy_error_code phyerr); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* for manual control */ 1118c2ecf20Sopenharmony_civoid ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level); 1128c2ecf20Sopenharmony_civoid ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level); 1138c2ecf20Sopenharmony_civoid ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level); 1148c2ecf20Sopenharmony_civoid ath5k_ani_set_ofdm_weak_signal_detection(struct ath5k_hw *ah, bool on); 1158c2ecf20Sopenharmony_civoid ath5k_ani_set_cck_weak_signal_detection(struct ath5k_hw *ah, bool on); 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_civoid ath5k_ani_print_counters(struct ath5k_hw *ah); 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#endif /* ANI_H */ 120