xref: /linux/drivers/net/wireless/ath/ath9k/ani.h (revision ff5599816711d2e67da2d7561fd36ac48debd433)
1 /*
2  * Copyright (c) 2008-2011 Atheros Communications Inc.
3  *
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 
20 #define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
21 
22 /* units are errors per second */
23 #define ATH9K_ANI_OFDM_TRIG_HIGH           3500
24 #define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
25 
26 #define ATH9K_ANI_OFDM_TRIG_LOW           400
27 #define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
28 
29 #define ATH9K_ANI_CCK_TRIG_HIGH           600
30 #define ATH9K_ANI_CCK_TRIG_LOW            300
31 
32 #define ATH9K_ANI_SPUR_IMMUNE_LVL         3
33 #define ATH9K_ANI_FIRSTEP_LVL             2
34 
35 #define ATH9K_ANI_RSSI_THR_HIGH           40
36 #define ATH9K_ANI_RSSI_THR_LOW            7
37 
38 #define ATH9K_ANI_PERIOD                  300
39 
40 /* in ms */
41 #define ATH9K_ANI_POLLINTERVAL            1000
42 
43 #define ATH9K_SIG_FIRSTEP_SETTING_MIN     0
44 #define ATH9K_SIG_FIRSTEP_SETTING_MAX     20
45 #define ATH9K_SIG_SPUR_IMM_SETTING_MIN    0
46 #define ATH9K_SIG_SPUR_IMM_SETTING_MAX    22
47 
48 /* values here are relative to the INI */
49 
50 enum ath9k_ani_cmd {
51 	ATH9K_ANI_PRESENT = 0x1,
52 	ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
53 	ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
54 	ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
55 	ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
56 	ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
57 	ATH9K_ANI_MODE = 0x40,
58 	ATH9K_ANI_PHYERR_RESET = 0x80,
59 	ATH9K_ANI_MRC_CCK = 0x100,
60 	ATH9K_ANI_ALL = 0xfff
61 };
62 
63 struct ath9k_mib_stats {
64 	u32 ackrcv_bad;
65 	u32 rts_bad;
66 	u32 rts_good;
67 	u32 fcs_bad;
68 	u32 beacons;
69 };
70 
71 /* INI default values for ANI registers */
72 struct ath9k_ani_default {
73 	u16 m1ThreshLow;
74 	u16 m2ThreshLow;
75 	u16 m1Thresh;
76 	u16 m2Thresh;
77 	u16 m2CountThr;
78 	u16 m2CountThrLow;
79 	u16 m1ThreshLowExt;
80 	u16 m2ThreshLowExt;
81 	u16 m1ThreshExt;
82 	u16 m2ThreshExt;
83 	u16 firstep;
84 	u16 firstepLow;
85 	u16 cycpwrThr1;
86 	u16 cycpwrThr1Ext;
87 };
88 
89 struct ar5416AniState {
90 	u8 noiseImmunityLevel;
91 	u8 ofdmNoiseImmunityLevel;
92 	u8 cckNoiseImmunityLevel;
93 	bool ofdmsTurn;
94 	u8 mrcCCK;
95 	u8 spurImmunityLevel;
96 	u8 firstepLevel;
97 	bool ofdmWeakSigDetect;
98 	u32 listenTime;
99 	u32 ofdmPhyErrCount;
100 	u32 cckPhyErrCount;
101 	struct ath9k_ani_default iniDef;
102 };
103 
104 struct ar5416Stats {
105 	u32 ast_ani_spurup;
106 	u32 ast_ani_spurdown;
107 	u32 ast_ani_ofdmon;
108 	u32 ast_ani_ofdmoff;
109 	u32 ast_ani_cckhigh;
110 	u32 ast_ani_ccklow;
111 	u32 ast_ani_stepup;
112 	u32 ast_ani_stepdown;
113 	u32 ast_ani_ofdmerrs;
114 	u32 ast_ani_cckerrs;
115 	u32 ast_ani_reset;
116 	u32 ast_ani_lneg_or_lzero;
117 	u32 avgbrssi;
118 	struct ath9k_mib_stats ast_mibstats;
119 };
120 #define ah_mibStats stats.ast_mibstats
121 
122 void ath9k_enable_mib_counters(struct ath_hw *ah);
123 void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
124 void ath9k_hw_ani_init(struct ath_hw *ah);
125 
126 #endif /* ANI_H */
127