Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2010 Bruno Randolf <br1@einfach.org>
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 #ifndef ANI_H
0017 #define ANI_H
0018 
0019 #include "../ath.h"
0020 
0021 enum ath5k_phy_error_code;
0022 
0023 /* these thresholds are relative to the ATH5K_ANI_LISTEN_PERIOD */
0024 #define ATH5K_ANI_LISTEN_PERIOD     100
0025 #define ATH5K_ANI_OFDM_TRIG_HIGH    500
0026 #define ATH5K_ANI_OFDM_TRIG_LOW     200
0027 #define ATH5K_ANI_CCK_TRIG_HIGH     200
0028 #define ATH5K_ANI_CCK_TRIG_LOW      100
0029 
0030 /* average beacon RSSI thresholds */
0031 #define ATH5K_ANI_RSSI_THR_HIGH     40
0032 #define ATH5K_ANI_RSSI_THR_LOW      7
0033 
0034 /* maximum available levels */
0035 #define ATH5K_ANI_MAX_FIRSTEP_LVL   2
0036 #define ATH5K_ANI_MAX_NOISE_IMM_LVL 1
0037 
0038 
0039 /**
0040  * enum ath5k_ani_mode - mode for ANI / noise sensitivity
0041  *
0042  * @ATH5K_ANI_MODE_OFF: Turn ANI off. This can be useful to just stop the ANI
0043  *          algorithm after it has been on auto mode.
0044  * @ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low,
0045  *          maximizing sensitivity. ANI will not run.
0046  * @ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high,
0047  *          minimizing sensitivity. ANI will not run.
0048  * @ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the
0049  *          amount of OFDM and CCK frame errors (default).
0050  */
0051 enum ath5k_ani_mode {
0052     ATH5K_ANI_MODE_OFF      = 0,
0053     ATH5K_ANI_MODE_MANUAL_LOW   = 1,
0054     ATH5K_ANI_MODE_MANUAL_HIGH  = 2,
0055     ATH5K_ANI_MODE_AUTO     = 3
0056 };
0057 
0058 
0059 /**
0060  * struct ath5k_ani_state - ANI state and associated counters
0061  * @ani_mode: One of enum ath5k_ani_mode
0062  * @noise_imm_level: Noise immunity level
0063  * @spur_level: Spur immunity level
0064  * @firstep_level: FIRstep level
0065  * @ofdm_weak_sig: OFDM weak signal detection state (on/off)
0066  * @cck_weak_sig: CCK weak signal detection state (on/off)
0067  * @max_spur_level: Max spur immunity level (chip specific)
0068  * @listen_time: Listen time
0069  * @ofdm_errors: OFDM timing error count
0070  * @cck_errors: CCK timing error count
0071  * @last_cc: The &struct ath_cycle_counters (for stats)
0072  * @last_listen: Listen time from previous run (for stats)
0073  * @last_ofdm_errors: OFDM timing error count from previous run (for tats)
0074  * @last_cck_errors: CCK timing error count from previous run (for stats)
0075  * @sum_ofdm_errors: Sum of OFDM timing errors (for stats)
0076  * @sum_cck_errors: Sum of all CCK timing errors (for stats)
0077  */
0078 struct ath5k_ani_state {
0079     enum ath5k_ani_mode ani_mode;
0080 
0081     /* state */
0082     int         noise_imm_level;
0083     int         spur_level;
0084     int         firstep_level;
0085     bool            ofdm_weak_sig;
0086     bool            cck_weak_sig;
0087 
0088     int         max_spur_level;
0089 
0090     /* used by the algorithm */
0091     unsigned int        listen_time;
0092     unsigned int        ofdm_errors;
0093     unsigned int        cck_errors;
0094 
0095     /* debug/statistics only: numbers from last ANI calibration */
0096     struct ath_cycle_counters last_cc;
0097     unsigned int        last_listen;
0098     unsigned int        last_ofdm_errors;
0099     unsigned int        last_cck_errors;
0100     unsigned int        sum_ofdm_errors;
0101     unsigned int        sum_cck_errors;
0102 };
0103 
0104 void ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode);
0105 void ath5k_ani_mib_intr(struct ath5k_hw *ah);
0106 void ath5k_ani_calibration(struct ath5k_hw *ah);
0107 void ath5k_ani_phy_error_report(struct ath5k_hw *ah,
0108                 enum ath5k_phy_error_code phyerr);
0109 
0110 /* for manual control */
0111 void ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level);
0112 void ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level);
0113 void ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level);
0114 void ath5k_ani_set_ofdm_weak_signal_detection(struct ath5k_hw *ah, bool on);
0115 void ath5k_ani_set_cck_weak_signal_detection(struct ath5k_hw *ah, bool on);
0116 
0117 void ath5k_ani_print_counters(struct ath5k_hw *ah);
0118 
0119 #endif /* ANI_H */