blob: 77a06fd40287aae33ff95de948cb7ce5b330bc0c [file] [log] [blame]
Sujith394cf0a2009-02-09 13:26:54 +05301/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2008-2011 Atheros Communications Inc.
Sujith394cf0a2009-02-09 13:26:54 +05303 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef ANI_H
18#define ANI_H
19
Vasanthakumar Thiagarajan22e66a42009-08-19 16:23:40 +053020#define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
Sujith394cf0a2009-02-09 13:26:54 +053021
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040022/* units are errors per second */
Sujith Manoharanfca97d72013-06-13 08:52:09 +053023#define ATH9K_ANI_OFDM_TRIG_HIGH 1000
Felix Fietkau465dce62012-06-15 15:25:24 +020024#define ATH9K_ANI_OFDM_TRIG_LOW 400
Felix Fietkau465dce62012-06-15 15:25:24 +020025#define ATH9K_ANI_CCK_TRIG_HIGH 600
Felix Fietkau465dce62012-06-15 15:25:24 +020026#define ATH9K_ANI_CCK_TRIG_LOW 300
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040027
Felix Fietkau465dce62012-06-15 15:25:24 +020028#define ATH9K_ANI_SPUR_IMMUNE_LVL 3
Felix Fietkau465dce62012-06-15 15:25:24 +020029#define ATH9K_ANI_FIRSTEP_LVL 2
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040030
Sujith394cf0a2009-02-09 13:26:54 +053031#define ATH9K_ANI_RSSI_THR_HIGH 40
32#define ATH9K_ANI_RSSI_THR_LOW 7
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040033
Felix Fietkau465dce62012-06-15 15:25:24 +020034#define ATH9K_ANI_PERIOD 300
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040035
36/* in ms */
Felix Fietkau465dce62012-06-15 15:25:24 +020037#define ATH9K_ANI_POLLINTERVAL 1000
Sujith394cf0a2009-02-09 13:26:54 +053038
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040039#define ATH9K_SIG_FIRSTEP_SETTING_MIN 0
40#define ATH9K_SIG_FIRSTEP_SETTING_MAX 20
41#define ATH9K_SIG_SPUR_IMM_SETTING_MIN 0
42#define ATH9K_SIG_SPUR_IMM_SETTING_MAX 22
43
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040044/* values here are relative to the INI */
45
Sujith394cf0a2009-02-09 13:26:54 +053046enum ath9k_ani_cmd {
47 ATH9K_ANI_PRESENT = 0x1,
48 ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
49 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
50 ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
51 ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
52 ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
53 ATH9K_ANI_MODE = 0x40,
54 ATH9K_ANI_PHYERR_RESET = 0x80,
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040055 ATH9K_ANI_MRC_CCK = 0x100,
56 ATH9K_ANI_ALL = 0xfff
Sujith394cf0a2009-02-09 13:26:54 +053057};
58
59struct ath9k_mib_stats {
60 u32 ackrcv_bad;
61 u32 rts_bad;
62 u32 rts_good;
63 u32 fcs_bad;
64 u32 beacons;
65};
66
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040067/* INI default values for ANI registers */
68struct ath9k_ani_default {
69 u16 m1ThreshLow;
70 u16 m2ThreshLow;
71 u16 m1Thresh;
72 u16 m2Thresh;
73 u16 m2CountThr;
74 u16 m2CountThrLow;
75 u16 m1ThreshLowExt;
76 u16 m2ThreshLowExt;
77 u16 m1ThreshExt;
78 u16 m2ThreshExt;
79 u16 firstep;
80 u16 firstepLow;
81 u16 cycpwrThr1;
82 u16 cycpwrThr1Ext;
83};
84
Sujithee6e8d12009-02-09 13:29:49 +053085struct ar5416AniState {
Sujithee6e8d12009-02-09 13:29:49 +053086 u8 noiseImmunityLevel;
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040087 u8 ofdmNoiseImmunityLevel;
88 u8 cckNoiseImmunityLevel;
89 bool ofdmsTurn;
Rajkumar Manoharan81b67fd62012-06-21 20:33:59 +053090 u8 mrcCCK;
Sujithee6e8d12009-02-09 13:29:49 +053091 u8 spurImmunityLevel;
92 u8 firstepLevel;
Sujith Manoharan4f4395c2013-06-03 09:19:27 +053093 bool ofdmWeakSigDetect;
Sujithee6e8d12009-02-09 13:29:49 +053094 u32 listenTime;
Sujithee6e8d12009-02-09 13:29:49 +053095 u32 ofdmPhyErrCount;
96 u32 cckPhyErrCount;
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -040097 struct ath9k_ani_default iniDef;
Sujithee6e8d12009-02-09 13:29:49 +053098};
99
Sujith394cf0a2009-02-09 13:26:54 +0530100struct ar5416Stats {
Sujith394cf0a2009-02-09 13:26:54 +0530101 u32 ast_ani_spurup;
102 u32 ast_ani_spurdown;
103 u32 ast_ani_ofdmon;
104 u32 ast_ani_ofdmoff;
105 u32 ast_ani_cckhigh;
106 u32 ast_ani_ccklow;
107 u32 ast_ani_stepup;
108 u32 ast_ani_stepdown;
109 u32 ast_ani_ofdmerrs;
110 u32 ast_ani_cckerrs;
111 u32 ast_ani_reset;
Mohammed Shafi Shajakhan107021c2011-08-26 11:19:57 +0530112 u32 ast_ani_lneg_or_lzero;
Vasanthakumar Thiagarajan22e66a42009-08-19 16:23:40 +0530113 u32 avgbrssi;
Sujith394cf0a2009-02-09 13:26:54 +0530114 struct ath9k_mib_stats ast_mibstats;
Sujith394cf0a2009-02-09 13:26:54 +0530115};
Sujith2660b812009-02-09 13:27:26 +0530116#define ah_mibStats stats.ast_mibstats
Sujith394cf0a2009-02-09 13:26:54 +0530117
Sujithcbe61d82009-02-09 13:27:12 +0530118void ath9k_enable_mib_counters(struct ath_hw *ah);
119void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
Luis R. Rodriguezf637cfd2009-08-03 12:24:46 -0700120void ath9k_hw_ani_init(struct ath_hw *ah);
Sujith394cf0a2009-02-09 13:26:54 +0530121
122#endif /* ANI_H */