1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef SPECTRAL_H
18#define SPECTRAL_H
19
20
21
22
23
24
25
26
27
28
29
30enum spectral_mode {
31 SPECTRAL_DISABLED = 0,
32 SPECTRAL_BACKGROUND,
33 SPECTRAL_MANUAL,
34 SPECTRAL_CHANSCAN,
35};
36
37#define SPECTRAL_SCAN_BITMASK 0x10
38
39struct ath_radar_info {
40 u8 pulse_length_pri;
41 u8 pulse_length_ext;
42 u8 pulse_bw_info;
43} __packed;
44
45
46
47
48
49
50
51
52struct ath_ht20_mag_info {
53 u8 all_bins[3];
54 u8 max_exp;
55} __packed;
56
57#define SPECTRAL_HT20_NUM_BINS 56
58
59
60
61
62struct ath_ht20_fft_packet {
63 u8 data[SPECTRAL_HT20_NUM_BINS];
64 struct ath_ht20_mag_info mag_info;
65 struct ath_radar_info radar_info;
66} __packed;
67
68#define SPECTRAL_HT20_TOTAL_DATA_LEN (sizeof(struct ath_ht20_fft_packet))
69
70
71
72
73
74
75
76
77
78
79
80struct ath_ht20_40_mag_info {
81 u8 lower_bins[3];
82 u8 upper_bins[3];
83 u8 max_exp;
84} __packed;
85
86#define SPECTRAL_HT20_40_NUM_BINS 128
87
88
89
90
91struct ath_ht20_40_fft_packet {
92 u8 data[SPECTRAL_HT20_40_NUM_BINS];
93 struct ath_ht20_40_mag_info mag_info;
94 struct ath_radar_info radar_info;
95} __packed;
96
97
98#define SPECTRAL_HT20_40_TOTAL_DATA_LEN (sizeof(struct ath_ht20_40_fft_packet))
99
100
101static inline u16 spectral_max_magnitude(u8 *bins)
102{
103 return (bins[0] & 0xc0) >> 6 |
104 (bins[1] & 0xff) << 2 |
105 (bins[2] & 0x03) << 10;
106}
107
108
109static inline u8 spectral_max_index(u8 *bins)
110{
111 s8 m = (bins[2] & 0xfc) >> 2;
112
113
114 if (m > 32)
115 m |= 0xe0;
116 else
117 m &= ~0xe0;
118
119 return m + 29;
120}
121
122
123static inline u8 spectral_bitmap_weight(u8 *bins)
124{
125 return bins[0] & 0x3f;
126}
127
128
129
130
131
132
133
134
135
136enum ath_fft_sample_type {
137 ATH_FFT_SAMPLE_HT20 = 1,
138 ATH_FFT_SAMPLE_HT20_40,
139};
140
141struct fft_sample_tlv {
142 u8 type;
143 __be16 length;
144
145} __packed;
146
147struct fft_sample_ht20 {
148 struct fft_sample_tlv tlv;
149
150 u8 max_exp;
151
152 __be16 freq;
153 s8 rssi;
154 s8 noise;
155
156 __be16 max_magnitude;
157 u8 max_index;
158 u8 bitmap_weight;
159
160 __be64 tsf;
161
162 u8 data[SPECTRAL_HT20_NUM_BINS];
163} __packed;
164
165struct fft_sample_ht20_40 {
166 struct fft_sample_tlv tlv;
167
168 u8 channel_type;
169 __be16 freq;
170
171 s8 lower_rssi;
172 s8 upper_rssi;
173
174 __be64 tsf;
175
176 s8 lower_noise;
177 s8 upper_noise;
178
179 __be16 lower_max_magnitude;
180 __be16 upper_max_magnitude;
181
182 u8 lower_max_index;
183 u8 upper_max_index;
184
185 u8 lower_bitmap_weight;
186 u8 upper_bitmap_weight;
187
188 u8 max_exp;
189
190 u8 data[SPECTRAL_HT20_40_NUM_BINS];
191} __packed;
192
193void ath9k_spectral_init_debug(struct ath_softc *sc);
194void ath9k_spectral_deinit_debug(struct ath_softc *sc);
195
196void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw);
197int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
198 enum spectral_mode spectral_mode);
199
200#ifdef CONFIG_ATH9K_DEBUGFS
201int ath_process_fft(struct ath_softc *sc, struct ieee80211_hdr *hdr,
202 struct ath_rx_status *rs, u64 tsf);
203#else
204static inline int ath_process_fft(struct ath_softc *sc,
205 struct ieee80211_hdr *hdr,
206 struct ath_rx_status *rs, u64 tsf)
207{
208 return 0;
209}
210#endif
211
212#endif
213