Merge branch 'wl12xx-next' into for-linville
[deliverable/linux.git] / drivers / net / wireless / ath / ath9k / ani.h
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 HAL_PROCESS_ANI 0x00000001
21
22 #define DO_ANI(ah) (((ah)->proc_phyerr & HAL_PROCESS_ANI) && ah->curchan)
23
24 #define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
25
26 /* units are errors per second */
27 #define ATH9K_ANI_OFDM_TRIG_HIGH 3500
28 #define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
29
30 /* units are errors per second */
31 #define ATH9K_ANI_OFDM_TRIG_LOW 400
32 #define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
33
34 /* units are errors per second */
35 #define ATH9K_ANI_CCK_TRIG_HIGH 600
36
37 /* units are errors per second */
38 #define ATH9K_ANI_CCK_TRIG_LOW 300
39
40 #define ATH9K_ANI_NOISE_IMMUNE_LVL 4
41 #define ATH9K_ANI_USE_OFDM_WEAK_SIG true
42 #define ATH9K_ANI_CCK_WEAK_SIG_THR false
43
44 #define ATH9K_ANI_SPUR_IMMUNE_LVL 3
45
46 #define ATH9K_ANI_FIRSTEP_LVL 2
47
48 #define ATH9K_ANI_RSSI_THR_HIGH 40
49 #define ATH9K_ANI_RSSI_THR_LOW 7
50
51 #define ATH9K_ANI_PERIOD 300
52
53 /* in ms */
54 #define ATH9K_ANI_POLLINTERVAL 1000
55
56 #define HAL_NOISE_IMMUNE_MAX 4
57 #define HAL_SPUR_IMMUNE_MAX 7
58 #define HAL_FIRST_STEP_MAX 2
59
60 #define ATH9K_SIG_FIRSTEP_SETTING_MIN 0
61 #define ATH9K_SIG_FIRSTEP_SETTING_MAX 20
62 #define ATH9K_SIG_SPUR_IMM_SETTING_MIN 0
63 #define ATH9K_SIG_SPUR_IMM_SETTING_MAX 22
64
65 #define ATH9K_ANI_ENABLE_MRC_CCK true
66
67 /* values here are relative to the INI */
68
69 enum ath9k_ani_cmd {
70 ATH9K_ANI_PRESENT = 0x1,
71 ATH9K_ANI_NOISE_IMMUNITY_LEVEL = 0x2,
72 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x4,
73 ATH9K_ANI_CCK_WEAK_SIGNAL_THR = 0x8,
74 ATH9K_ANI_FIRSTEP_LEVEL = 0x10,
75 ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x20,
76 ATH9K_ANI_MODE = 0x40,
77 ATH9K_ANI_PHYERR_RESET = 0x80,
78 ATH9K_ANI_MRC_CCK = 0x100,
79 ATH9K_ANI_ALL = 0xfff
80 };
81
82 struct ath9k_mib_stats {
83 u32 ackrcv_bad;
84 u32 rts_bad;
85 u32 rts_good;
86 u32 fcs_bad;
87 u32 beacons;
88 };
89
90 /* INI default values for ANI registers */
91 struct ath9k_ani_default {
92 u16 m1ThreshLow;
93 u16 m2ThreshLow;
94 u16 m1Thresh;
95 u16 m2Thresh;
96 u16 m2CountThr;
97 u16 m2CountThrLow;
98 u16 m1ThreshLowExt;
99 u16 m2ThreshLowExt;
100 u16 m1ThreshExt;
101 u16 m2ThreshExt;
102 u16 firstep;
103 u16 firstepLow;
104 u16 cycpwrThr1;
105 u16 cycpwrThr1Ext;
106 };
107
108 struct ar5416AniState {
109 struct ath9k_channel *c;
110 u8 noiseImmunityLevel;
111 u8 ofdmNoiseImmunityLevel;
112 u8 cckNoiseImmunityLevel;
113 bool ofdmsTurn;
114 u8 mrcCCKOff;
115 u8 spurImmunityLevel;
116 u8 firstepLevel;
117 u8 ofdmWeakSigDetect;
118 u8 cckWeakSigThreshold;
119 bool update_ani;
120 u32 listenTime;
121 int32_t rssiThrLow;
122 int32_t rssiThrHigh;
123 u32 ofdmPhyErrCount;
124 u32 cckPhyErrCount;
125 int16_t pktRssi[2];
126 int16_t ofdmErrRssi[2];
127 int16_t cckErrRssi[2];
128 struct ath9k_ani_default iniDef;
129 };
130
131 struct ar5416Stats {
132 u32 ast_ani_niup;
133 u32 ast_ani_nidown;
134 u32 ast_ani_spurup;
135 u32 ast_ani_spurdown;
136 u32 ast_ani_ofdmon;
137 u32 ast_ani_ofdmoff;
138 u32 ast_ani_cckhigh;
139 u32 ast_ani_ccklow;
140 u32 ast_ani_stepup;
141 u32 ast_ani_stepdown;
142 u32 ast_ani_ofdmerrs;
143 u32 ast_ani_cckerrs;
144 u32 ast_ani_reset;
145 u32 ast_ani_lneg_or_lzero;
146 u32 avgbrssi;
147 struct ath9k_mib_stats ast_mibstats;
148 };
149 #define ah_mibStats stats.ast_mibstats
150
151 void ath9k_enable_mib_counters(struct ath_hw *ah);
152 void ath9k_hw_disable_mib_counters(struct ath_hw *ah);
153 void ath9k_hw_ani_setup(struct ath_hw *ah);
154 void ath9k_hw_ani_init(struct ath_hw *ah);
155
156 #endif /* ANI_H */
This page took 0.053276 seconds and 6 git commands to generate.