1394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith/* 25b68138e5659cbfd5df2879d17f9ba0b66477fecSujith Manoharan * Copyright (c) 2008-2011 Atheros Communications Inc. 3394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * 4394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * Permission to use, copy, modify, and/or distribute this software for any 5394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * purpose with or without fee is hereby granted, provided that the above 6394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * copyright notice and this permission notice appear in all copies. 7394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * 8394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith */ 16394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 17394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#ifndef ANI_H 18394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define ANI_H 19394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 20394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define HAL_PROCESS_ANI 0x00000001 21394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 22093115b7fd641f03d89404252044c976928764cbFelix Fietkau#define DO_ANI(ah) (((ah)->proc_phyerr & HAL_PROCESS_ANI) && ah->curchan) 23394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 2422e66a4c15b063aee5d03991c4b9629a3b0c4556Vasanthakumar Thiagarajan#define BEACON_RSSI(ahp) (ahp->stats.avgbrssi) 25394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 26e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* units are errors per second */ 27e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_OFDM_TRIG_HIGH_OLD 500 28e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_OFDM_TRIG_HIGH_NEW 1000 29e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 30e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* units are errors per second */ 31e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_OFDM_TRIG_LOW_OLD 200 32e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_OFDM_TRIG_LOW_NEW 400 33e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 34e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* units are errors per second */ 35e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_CCK_TRIG_HIGH_OLD 200 36e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_CCK_TRIG_HIGH_NEW 600 37e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 38e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* units are errors per second */ 39e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_CCK_TRIG_LOW_OLD 100 40e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_CCK_TRIG_LOW_NEW 300 41e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 42394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define ATH9K_ANI_NOISE_IMMUNE_LVL 4 43394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define ATH9K_ANI_USE_OFDM_WEAK_SIG true 44394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define ATH9K_ANI_CCK_WEAK_SIG_THR false 45e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 46e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_SPUR_IMMUNE_LVL_OLD 7 47e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_SPUR_IMMUNE_LVL_NEW 3 48e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 49e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_FIRSTEP_LVL_OLD 0 50e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_FIRSTEP_LVL_NEW 2 51e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 52394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define ATH9K_ANI_RSSI_THR_HIGH 40 53394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define ATH9K_ANI_RSSI_THR_LOW 7 54e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 55e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_PERIOD_OLD 100 56e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_PERIOD_NEW 1000 57e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 58e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* in ms */ 59e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_POLLINTERVAL_OLD 100 60e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_POLLINTERVAL_NEW 1000 61394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 62394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define HAL_NOISE_IMMUNE_MAX 4 63394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define HAL_SPUR_IMMUNE_MAX 7 64394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#define HAL_FIRST_STEP_MAX 2 65394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 66e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_SIG_FIRSTEP_SETTING_MIN 0 67e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_SIG_FIRSTEP_SETTING_MAX 20 68e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_SIG_SPUR_IMM_SETTING_MIN 0 69e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_SIG_SPUR_IMM_SETTING_MAX 22 70e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 71e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez#define ATH9K_ANI_ENABLE_MRC_CCK true 72e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 73e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* values here are relative to the INI */ 74e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 75394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujithenum ath9k_ani_cmd { 76394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_PRESENT = 0x1, 77394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2, 78394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4, 79394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8, 80394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_FIRSTEP_LEVEL = 0x10, 81394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20, 82394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_MODE = 0x40, 83394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith ATH9K_ANI_PHYERR_RESET = 0x80, 84e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez ATH9K_ANI_MRC_CCK = 0x100, 85e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez ATH9K_ANI_ALL = 0xfff 86394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith}; 87394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 88394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujithstruct ath9k_mib_stats { 89394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ackrcv_bad; 90394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 rts_bad; 91394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 rts_good; 92394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 fcs_bad; 93394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 beacons; 94394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith}; 95394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 96e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez/* INI default values for ANI registers */ 97e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguezstruct ath9k_ani_default { 98e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m1ThreshLow; 99e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m2ThreshLow; 100e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m1Thresh; 101e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m2Thresh; 102e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m2CountThr; 103e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m2CountThrLow; 104e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m1ThreshLowExt; 105e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m2ThreshLowExt; 106e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m1ThreshExt; 107e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 m2ThreshExt; 108e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 firstep; 109e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 firstepLow; 110e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 cycpwrThr1; 111e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u16 cycpwrThr1Ext; 112e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez}; 113e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez 114ee6e8d1c234e62e503f2dd8137643b24cf424886Sujithstruct ar5416AniState { 115ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith struct ath9k_channel *c; 116ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u8 noiseImmunityLevel; 117e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u8 ofdmNoiseImmunityLevel; 118e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u8 cckNoiseImmunityLevel; 119e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez bool ofdmsTurn; 120e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez u8 mrcCCKOff; 121ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u8 spurImmunityLevel; 122ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u8 firstepLevel; 123ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u8 ofdmWeakSigDetectOff; 124ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u8 cckWeakSigThreshold; 125f36369afce40a20b6328590c1f9a777d0810f815Rajkumar Manoharan bool update_ani; 126ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u32 listenTime; 127ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith int32_t rssiThrLow; 128ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith int32_t rssiThrHigh; 129ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u32 noiseFloor; 130ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u32 ofdmPhyErrCount; 131ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith u32 cckPhyErrCount; 132ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith int16_t pktRssi[2]; 133ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith int16_t ofdmErrRssi[2]; 134ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith int16_t cckErrRssi[2]; 135e36b27aff1b10c81c53990b28da4ab6ab0ed0761Luis R. Rodriguez struct ath9k_ani_default iniDef; 136ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith}; 137ee6e8d1c234e62e503f2dd8137643b24cf424886Sujith 138394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujithstruct ar5416Stats { 139394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_niup; 140394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_nidown; 141394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_spurup; 142394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_spurdown; 143394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_ofdmon; 144394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_ofdmoff; 145394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_cckhigh; 146394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_ccklow; 147394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_stepup; 148394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_stepdown; 149394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_ofdmerrs; 150394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_cckerrs; 151394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith u32 ast_ani_reset; 152107021c4ce105c9c9d5406dfc4b1fe0f2aa86455Mohammed Shafi Shajakhan u32 ast_ani_lneg_or_lzero; 15322e66a4c15b063aee5d03991c4b9629a3b0c4556Vasanthakumar Thiagarajan u32 avgbrssi; 154394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith struct ath9k_mib_stats ast_mibstats; 155394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith}; 1562660b81a378ab227b78c4cc618453fa7e19a7c7bSujith#define ah_mibStats stats.ast_mibstats 157394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 158cbe61d8a41210600bc76b212edcd4dc0f55c014fSujithvoid ath9k_enable_mib_counters(struct ath_hw *ah); 159cbe61d8a41210600bc76b212edcd4dc0f55c014fSujithvoid ath9k_hw_disable_mib_counters(struct ath_hw *ah); 160cbe61d8a41210600bc76b212edcd4dc0f55c014fSujithvoid ath9k_hw_ani_setup(struct ath_hw *ah); 161f637cfd6bbacbaeab329f9dfc56e9855cc15849dLuis R. Rodriguezvoid ath9k_hw_ani_init(struct ath_hw *ah); 162394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith 163394cf0a1ca02e7998c8d01975b60a3cdc121e7d8Sujith#endif /* ANI_H */ 164