blob: 51ab3961443f4a402e1731366ecc74e27136e37d [file] [log] [blame]
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301/*
2 * Copyright (c) 2013 Qualcomm Atheros, 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#include <linux/relay.h>
18#include "ath9k.h"
19
20static s8 fix_rssi_inv_only(u8 rssi_val)
21{
22 if (rssi_val == 128)
23 rssi_val = 0;
24 return (s8) rssi_val;
25}
26
Oleksij Rempel1111d422014-11-06 08:53:23 +010027static void ath_debug_send_fft_sample(struct ath_spec_scan_priv *spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +053028 struct fft_sample_tlv *fft_sample_tlv)
29{
30 int length;
Oleksij Rempel1111d422014-11-06 08:53:23 +010031 if (!spec_priv->rfs_chan_spec_scan)
Sujith Manoharanf65c0822013-12-18 09:53:18 +053032 return;
33
34 length = __be16_to_cpu(fft_sample_tlv->length) +
35 sizeof(*fft_sample_tlv);
Oleksij Rempel1111d422014-11-06 08:53:23 +010036 relay_write(spec_priv->rfs_chan_spec_scan, fft_sample_tlv, length);
Sujith Manoharanf65c0822013-12-18 09:53:18 +053037}
38
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +000039typedef int (ath_cmn_fft_idx_validator) (u8 *sample_end, int bytes_read);
40
41static int
42ath_cmn_max_idx_verify_ht20_fft(u8 *sample_end, int bytes_read)
43{
44 struct ath_ht20_mag_info *mag_info;
45 u8 *sample;
46 u16 max_magnitude;
47 u8 max_index;
48 u8 max_exp;
49
50 /* Sanity check so that we don't read outside the read
51 * buffer
52 */
53 if (bytes_read < SPECTRAL_HT20_SAMPLE_LEN - 1)
54 return -1;
55
56 mag_info = (struct ath_ht20_mag_info *) (sample_end -
57 sizeof(struct ath_ht20_mag_info) + 1);
58
59 sample = sample_end - SPECTRAL_HT20_SAMPLE_LEN + 1;
60
61 max_index = spectral_max_index(mag_info->all_bins,
62 SPECTRAL_HT20_NUM_BINS);
63 max_magnitude = spectral_max_magnitude(mag_info->all_bins);
64
65 max_exp = mag_info->max_exp & 0xf;
66
67 /* Don't try to read something outside the read buffer
68 * in case of a missing byte (so bins[0] will be outside
69 * the read buffer)
70 */
71 if (bytes_read < SPECTRAL_HT20_SAMPLE_LEN && max_index < 1)
72 return -1;
73
74 if (sample[max_index] != (max_magnitude >> max_exp))
75 return -1;
76 else
77 return 0;
78}
79
80static int
81ath_cmn_max_idx_verify_ht20_40_fft(u8 *sample_end, int bytes_read)
82{
83 struct ath_ht20_40_mag_info *mag_info;
84 u8 *sample;
85 u16 lower_mag, upper_mag;
86 u8 lower_max_index, upper_max_index;
87 u8 max_exp;
88 int dc_pos = SPECTRAL_HT20_40_NUM_BINS / 2;
89
90 /* Sanity check so that we don't read outside the read
91 * buffer
92 */
93 if (bytes_read < SPECTRAL_HT20_40_SAMPLE_LEN - 1)
94 return -1;
95
96 mag_info = (struct ath_ht20_40_mag_info *) (sample_end -
97 sizeof(struct ath_ht20_40_mag_info) + 1);
98
99 sample = sample_end - SPECTRAL_HT20_40_SAMPLE_LEN + 1;
100
101 lower_mag = spectral_max_magnitude(mag_info->lower_bins);
102 lower_max_index = spectral_max_index(mag_info->lower_bins,
103 SPECTRAL_HT20_40_NUM_BINS);
104
105 upper_mag = spectral_max_magnitude(mag_info->upper_bins);
106 upper_max_index = spectral_max_index(mag_info->upper_bins,
107 SPECTRAL_HT20_40_NUM_BINS);
108
109 max_exp = mag_info->max_exp & 0xf;
110
111 /* Don't try to read something outside the read buffer
112 * in case of a missing byte (so bins[0] will be outside
113 * the read buffer)
114 */
115 if (bytes_read < SPECTRAL_HT20_40_SAMPLE_LEN &&
116 ((upper_max_index < 1) || (lower_max_index < 1)))
117 return -1;
118
119 /* Some time hardware messes up the index and adds
120 * the index of the middle point (dc_pos). Try to fix it.
121 */
122 if ((upper_max_index - dc_pos > 0) &&
123 (sample[upper_max_index] == (upper_mag >> max_exp)))
124 upper_max_index -= dc_pos;
125
126 if ((lower_max_index - dc_pos > 0) &&
127 (sample[lower_max_index - dc_pos] == (lower_mag >> max_exp)))
128 lower_max_index -= dc_pos;
129
130 if ((sample[upper_max_index + dc_pos] != (upper_mag >> max_exp)) ||
131 (sample[lower_max_index] != (lower_mag >> max_exp)))
132 return -1;
133 else
134 return 0;
135}
136
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000137typedef int (ath_cmn_fft_sample_handler) (struct ath_rx_status *rs,
138 struct ath_spec_scan_priv *spec_priv,
139 u8 *sample_buf, u64 tsf, u16 freq, int chan_type);
140
141static int
142ath_cmn_process_ht20_fft(struct ath_rx_status *rs,
143 struct ath_spec_scan_priv *spec_priv,
144 u8 *sample_buf,
145 u64 tsf, u16 freq, int chan_type)
146{
147 struct fft_sample_ht20 fft_sample_20;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000148 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000149 struct ath_hw *ah = spec_priv->ah;
150 struct ath_ht20_mag_info *mag_info;
151 struct fft_sample_tlv *tlv;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000152 int i = 0;
153 int ret = 0;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000154 int dc_pos = SPECTRAL_HT20_NUM_BINS / 2;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000155 u16 magnitude, tmp_mag, length;
156 u8 max_index, bitmap_w, max_exp;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000157
158 length = sizeof(fft_sample_20) - sizeof(struct fft_sample_tlv);
159 fft_sample_20.tlv.type = ATH_FFT_SAMPLE_HT20;
160 fft_sample_20.tlv.length = __cpu_to_be16(length);
161 fft_sample_20.freq = __cpu_to_be16(freq);
162 fft_sample_20.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
163 fft_sample_20.noise = ah->noise;
164
165 mag_info = (struct ath_ht20_mag_info *) (sample_buf +
166 SPECTRAL_HT20_NUM_BINS);
167
168 magnitude = spectral_max_magnitude(mag_info->all_bins);
169 fft_sample_20.max_magnitude = __cpu_to_be16(magnitude);
170
171 max_index = spectral_max_index(mag_info->all_bins,
172 SPECTRAL_HT20_NUM_BINS);
173 fft_sample_20.max_index = max_index;
174
175 bitmap_w = spectral_bitmap_weight(mag_info->all_bins);
176 fft_sample_20.bitmap_weight = bitmap_w;
177
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000178 max_exp = mag_info->max_exp & 0xf;
179 fft_sample_20.max_exp = max_exp;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000180
181 fft_sample_20.tsf = __cpu_to_be64(tsf);
182
183 memcpy(fft_sample_20.data, sample_buf, SPECTRAL_HT20_NUM_BINS);
184
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000185 ath_dbg(common, SPECTRAL_SCAN, "FFT HT20 frame: max mag 0x%X,"
186 "max_mag_idx %i\n",
187 magnitude >> max_exp,
188 max_index);
189
190 if (fft_sample_20.data[max_index] != (magnitude >> max_exp)) {
191 ath_dbg(common, SPECTRAL_SCAN, "Magnitude mismatch !\n");
192 ret = -1;
193 }
194
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000195 /* DC value (value in the middle) is the blind spot of the spectral
196 * sample and invalid, interpolate it.
197 */
198 fft_sample_20.data[dc_pos] = (fft_sample_20.data[dc_pos + 1] +
199 fft_sample_20.data[dc_pos - 1]) / 2;
200
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000201 /* Check if the maximum magnitude is indeed maximum,
202 * also if the maximum value was at dc_pos, calculate
203 * a new one (since value at dc_pos is invalid).
204 */
205 if (max_index == dc_pos) {
206 tmp_mag = 0;
207 for (i = 0; i < dc_pos; i++) {
208 if (fft_sample_20.data[i] > tmp_mag) {
209 tmp_mag = fft_sample_20.data[i];
210 fft_sample_20.max_index = i;
211 }
212 }
213
214 magnitude = tmp_mag << max_exp;
215 fft_sample_20.max_magnitude = __cpu_to_be16(magnitude);
216
217 ath_dbg(common, SPECTRAL_SCAN,
218 "Calculated new lower max 0x%X at %i\n",
219 tmp_mag, fft_sample_20.max_index);
220 } else
221 for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) {
222 if (fft_sample_20.data[i] == (magnitude >> max_exp))
223 ath_dbg(common, SPECTRAL_SCAN,
224 "Got max: 0x%X at index %i\n",
225 fft_sample_20.data[i], i);
226
227 if (fft_sample_20.data[i] > (magnitude >> max_exp)) {
228 ath_dbg(common, SPECTRAL_SCAN,
229 "Got bin %i greater than max: 0x%X\n",
230 i, fft_sample_20.data[i]);
231 ret = -1;
232 }
233 }
234
235 if (ret < 0)
236 return ret;
237
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000238 tlv = (struct fft_sample_tlv *)&fft_sample_20;
239
240 ath_debug_send_fft_sample(spec_priv, tlv);
241
242 return 0;
243}
244
245static int
246ath_cmn_process_ht20_40_fft(struct ath_rx_status *rs,
247 struct ath_spec_scan_priv *spec_priv,
248 u8 *sample_buf,
249 u64 tsf, u16 freq, int chan_type)
250{
251 struct fft_sample_ht20_40 fft_sample_40;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000252 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000253 struct ath_hw *ah = spec_priv->ah;
254 struct ath9k_hw_cal_data *caldata = ah->caldata;
255 struct ath_ht20_40_mag_info *mag_info;
256 struct fft_sample_tlv *tlv;
257 int dc_pos = SPECTRAL_HT20_40_NUM_BINS / 2;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000258 int i = 0;
259 int ret = 0;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000260 s16 ext_nf;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000261 u16 lower_mag, upper_mag, tmp_mag, length;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000262 s8 lower_rssi, upper_rssi;
263 u8 lower_max_index, upper_max_index;
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000264 u8 lower_bitmap_w, upper_bitmap_w, max_exp;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000265
266 if (caldata)
267 ext_nf = ath9k_hw_getchan_noise(ah, ah->curchan,
268 caldata->nfCalHist[3].privNF);
269 else
270 ext_nf = ATH_DEFAULT_NOISE_FLOOR;
271
272 length = sizeof(fft_sample_40) - sizeof(struct fft_sample_tlv);
273 fft_sample_40.tlv.type = ATH_FFT_SAMPLE_HT20_40;
274 fft_sample_40.tlv.length = __cpu_to_be16(length);
275 fft_sample_40.freq = __cpu_to_be16(freq);
276 fft_sample_40.channel_type = chan_type;
277
278 if (chan_type == NL80211_CHAN_HT40PLUS) {
279 lower_rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
280 upper_rssi = fix_rssi_inv_only(rs->rs_rssi_ext[0]);
281
282 fft_sample_40.lower_noise = ah->noise;
283 fft_sample_40.upper_noise = ext_nf;
284 } else {
285 lower_rssi = fix_rssi_inv_only(rs->rs_rssi_ext[0]);
286 upper_rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
287
288 fft_sample_40.lower_noise = ext_nf;
289 fft_sample_40.upper_noise = ah->noise;
290 }
291
292 fft_sample_40.lower_rssi = lower_rssi;
293 fft_sample_40.upper_rssi = upper_rssi;
294
295 mag_info = (struct ath_ht20_40_mag_info *) (sample_buf +
296 SPECTRAL_HT20_40_NUM_BINS);
297
298 lower_mag = spectral_max_magnitude(mag_info->lower_bins);
299 fft_sample_40.lower_max_magnitude = __cpu_to_be16(lower_mag);
300
301 upper_mag = spectral_max_magnitude(mag_info->upper_bins);
302 fft_sample_40.upper_max_magnitude = __cpu_to_be16(upper_mag);
303
304 lower_max_index = spectral_max_index(mag_info->lower_bins,
305 SPECTRAL_HT20_40_NUM_BINS);
306 fft_sample_40.lower_max_index = lower_max_index;
307
308 upper_max_index = spectral_max_index(mag_info->upper_bins,
309 SPECTRAL_HT20_40_NUM_BINS);
310 fft_sample_40.upper_max_index = upper_max_index;
311
312 lower_bitmap_w = spectral_bitmap_weight(mag_info->lower_bins);
313 fft_sample_40.lower_bitmap_weight = lower_bitmap_w;
314
315 upper_bitmap_w = spectral_bitmap_weight(mag_info->upper_bins);
316 fft_sample_40.upper_bitmap_weight = upper_bitmap_w;
317
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000318 max_exp = mag_info->max_exp & 0xf;
319 fft_sample_40.max_exp = max_exp;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000320
321 fft_sample_40.tsf = __cpu_to_be64(tsf);
322
323 memcpy(fft_sample_40.data, sample_buf, SPECTRAL_HT20_40_NUM_BINS);
324
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000325 ath_dbg(common, SPECTRAL_SCAN, "FFT HT20/40 frame: lower mag 0x%X,"
326 "lower_mag_idx %i, upper mag 0x%X,"
327 "upper_mag_idx %i\n",
328 lower_mag >> max_exp,
329 lower_max_index,
330 upper_mag >> max_exp,
331 upper_max_index);
332
333 /* Some time hardware messes up the index and adds
334 * the index of the middle point (dc_pos). Try to fix it.
335 */
336 if ((upper_max_index - dc_pos > 0) &&
337 (fft_sample_40.data[upper_max_index] == (upper_mag >> max_exp))) {
338 upper_max_index -= dc_pos;
339 fft_sample_40.upper_max_index = upper_max_index;
340 }
341
342 if ((lower_max_index - dc_pos > 0) &&
343 (fft_sample_40.data[lower_max_index - dc_pos] ==
344 (lower_mag >> max_exp))) {
345 lower_max_index -= dc_pos;
346 fft_sample_40.lower_max_index = lower_max_index;
347 }
348
349 /* Check if we got the expected magnitude values at
350 * the expected bins
351 */
352 if ((fft_sample_40.data[upper_max_index + dc_pos]
353 != (upper_mag >> max_exp)) ||
354 (fft_sample_40.data[lower_max_index]
355 != (lower_mag >> max_exp))) {
356 ath_dbg(common, SPECTRAL_SCAN, "Magnitude mismatch !\n");
357 ret = -1;
358 }
359
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000360 /* DC value (value in the middle) is the blind spot of the spectral
361 * sample and invalid, interpolate it.
362 */
363 fft_sample_40.data[dc_pos] = (fft_sample_40.data[dc_pos + 1] +
364 fft_sample_40.data[dc_pos - 1]) / 2;
365
Nick Kossifidis7fa580c2015-04-29 23:51:15 +0000366 /* Check if the maximum magnitudes are indeed maximum,
367 * also if the maximum value was at dc_pos, calculate
368 * a new one (since value at dc_pos is invalid).
369 */
370 if (lower_max_index == dc_pos) {
371 tmp_mag = 0;
372 for (i = 0; i < dc_pos; i++) {
373 if (fft_sample_40.data[i] > tmp_mag) {
374 tmp_mag = fft_sample_40.data[i];
375 fft_sample_40.lower_max_index = i;
376 }
377 }
378
379 lower_mag = tmp_mag << max_exp;
380 fft_sample_40.lower_max_magnitude = __cpu_to_be16(lower_mag);
381
382 ath_dbg(common, SPECTRAL_SCAN,
383 "Calculated new lower max 0x%X at %i\n",
384 tmp_mag, fft_sample_40.lower_max_index);
385 } else
386 for (i = 0; i < dc_pos; i++) {
387 if (fft_sample_40.data[i] == (lower_mag >> max_exp))
388 ath_dbg(common, SPECTRAL_SCAN,
389 "Got lower mag: 0x%X at index %i\n",
390 fft_sample_40.data[i], i);
391
392 if (fft_sample_40.data[i] > (lower_mag >> max_exp)) {
393 ath_dbg(common, SPECTRAL_SCAN,
394 "Got lower bin %i higher than max: 0x%X\n",
395 i, fft_sample_40.data[i]);
396 ret = -1;
397 }
398 }
399
400 if (upper_max_index == dc_pos) {
401 tmp_mag = 0;
402 for (i = dc_pos; i < SPECTRAL_HT20_40_NUM_BINS; i++) {
403 if (fft_sample_40.data[i] > tmp_mag) {
404 tmp_mag = fft_sample_40.data[i];
405 fft_sample_40.upper_max_index = i;
406 }
407 }
408 upper_mag = tmp_mag << max_exp;
409 fft_sample_40.upper_max_magnitude = __cpu_to_be16(upper_mag);
410
411 ath_dbg(common, SPECTRAL_SCAN,
412 "Calculated new upper max 0x%X at %i\n",
413 tmp_mag, i);
414 } else
415 for (i = dc_pos; i < SPECTRAL_HT20_40_NUM_BINS; i++) {
416 if (fft_sample_40.data[i] == (upper_mag >> max_exp))
417 ath_dbg(common, SPECTRAL_SCAN,
418 "Got upper mag: 0x%X at index %i\n",
419 fft_sample_40.data[i], i);
420
421 if (fft_sample_40.data[i] > (upper_mag >> max_exp)) {
422 ath_dbg(common, SPECTRAL_SCAN,
423 "Got upper bin %i higher than max: 0x%X\n",
424 i, fft_sample_40.data[i]);
425
426 ret = -1;
427 }
428 }
429
430 if (ret < 0)
431 return ret;
432
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000433 tlv = (struct fft_sample_tlv *)&fft_sample_40;
434
435 ath_debug_send_fft_sample(spec_priv, tlv);
436
437 return 0;
438}
439
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530440/* returns 1 if this was a spectral frame, even if not handled. */
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100441int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530442 struct ath_rx_status *rs, u64 tsf)
443{
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000444 u8 sample_buf[SPECTRAL_SAMPLE_MAX_LEN] = {0};
Oleksij Rempel1111d422014-11-06 08:53:23 +0100445 struct ath_hw *ah = spec_priv->ah;
446 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000447 u8 num_bins, *vdata = (u8 *)hdr;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530448 struct ath_radar_info *radar_info;
449 int len = rs->rs_datalen;
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000450 int i;
451 int got_slen = 0;
452 u8 *sample_start;
453 int sample_bytes = 0;
454 int ret = 0;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000455 u16 fft_len, sample_len, freq = ah->curchan->chan->center_freq;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530456 enum nl80211_channel_type chan_type;
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000457 ath_cmn_fft_idx_validator *fft_idx_validator;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000458 ath_cmn_fft_sample_handler *fft_handler;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530459
460 /* AR9280 and before report via ATH9K_PHYERR_RADAR, AR93xx and newer
461 * via ATH9K_PHYERR_SPECTRAL. Haven't seen ATH9K_PHYERR_FALSE_RADAR_EXT
462 * yet, but this is supposed to be possible as well.
463 */
464 if (rs->rs_phyerr != ATH9K_PHYERR_RADAR &&
465 rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT &&
466 rs->rs_phyerr != ATH9K_PHYERR_SPECTRAL)
467 return 0;
468
469 /* check if spectral scan bit is set. This does not have to be checked
470 * if received through a SPECTRAL phy error, but shouldn't hurt.
471 */
472 radar_info = ((struct ath_radar_info *)&vdata[len]) - 1;
473 if (!(radar_info->pulse_bw_info & SPECTRAL_SCAN_BITMASK))
474 return 0;
475
Oleksij Rempel1111d422014-11-06 08:53:23 +0100476 chan_type = cfg80211_get_chandef_type(&common->hw->conf.chandef);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530477 if ((chan_type == NL80211_CHAN_HT40MINUS) ||
478 (chan_type == NL80211_CHAN_HT40PLUS)) {
479 fft_len = SPECTRAL_HT20_40_TOTAL_DATA_LEN;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000480 sample_len = SPECTRAL_HT20_40_SAMPLE_LEN;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530481 num_bins = SPECTRAL_HT20_40_NUM_BINS;
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000482 fft_idx_validator = &ath_cmn_max_idx_verify_ht20_40_fft;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000483 fft_handler = &ath_cmn_process_ht20_40_fft;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530484 } else {
485 fft_len = SPECTRAL_HT20_TOTAL_DATA_LEN;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000486 sample_len = SPECTRAL_HT20_SAMPLE_LEN;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530487 num_bins = SPECTRAL_HT20_NUM_BINS;
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000488 fft_idx_validator = ath_cmn_max_idx_verify_ht20_fft;
Nick Kossifidis58b5e4c2015-04-29 23:51:14 +0000489 fft_handler = &ath_cmn_process_ht20_fft;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530490 }
491
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000492 ath_dbg(common, SPECTRAL_SCAN, "Got radar dump bw_info: 0x%X,"
493 "len: %i fft_len: %i\n",
494 radar_info->pulse_bw_info,
495 len,
496 fft_len);
497 sample_start = vdata;
498 for (i = 0; i < len - 2; i++) {
499 sample_bytes++;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530500
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000501 /* Only a single sample received, no need to look
502 * for the sample's end, do the correction based
503 * on the packet's length instead. Note that hw
504 * will always put the radar_info structure on
505 * the end.
506 */
507 if (len <= fft_len + 2) {
508 sample_bytes = len - sizeof(struct ath_radar_info);
509 got_slen = 1;
510 }
511
512 /* Search for the end of the FFT frame between
513 * sample_len - 1 and sample_len + 2. exp_max is 3
514 * bits long and it's the only value on the last
515 * byte of the frame so since it'll be smaller than
516 * the next byte (the first bin of the next sample)
517 * 90% of the time, we can use it as a separator.
518 */
519 if (vdata[i] <= 0x7 && sample_bytes >= sample_len - 1) {
520
521 /* Got a frame length within boundaries, there are
522 * four scenarios here:
523 *
524 * a) sample_len -> We got the correct length
525 * b) sample_len + 2 -> 2 bytes added around bin[31]
526 * c) sample_len - 1 -> The first byte is missing
527 * d) sample_len + 1 -> b + c at the same time
528 *
529 * When MAC adds 2 extra bytes, bin[31] and bin[32]
530 * have the same value, so we can use that for further
531 * verification in cases b and d.
532 */
533
534 /* Did we go too far ? If so we couldn't determine
535 * this sample's boundaries, discard any further
536 * data
537 */
538 if ((sample_bytes > sample_len + 2) ||
539 ((sample_bytes > sample_len) &&
540 (sample_start[31] != sample_start[32])))
541 break;
542
543 /* See if we got a valid frame by checking the
544 * consistency of mag_info fields. This is to
545 * prevent from "fixing" a correct frame.
546 * Failure is non-fatal, later frames may
547 * be valid.
548 */
549 if (!fft_idx_validator(&vdata[i], i)) {
550 ath_dbg(common, SPECTRAL_SCAN,
551 "Found valid fft frame at %i\n", i);
552 got_slen = 1;
553 }
554
555 /* We expect 1 - 2 more bytes */
556 else if ((sample_start[31] == sample_start[32]) &&
557 (sample_bytes >= sample_len) &&
558 (sample_bytes < sample_len + 2) &&
559 (vdata[i + 1] <= 0x7))
560 continue;
561
562 /* Try to distinguish cases a and c */
563 else if ((sample_bytes == sample_len - 1) &&
564 (vdata[i + 1] <= 0x7))
565 continue;
566
567 got_slen = 1;
568 }
569
570 if (got_slen) {
571 ath_dbg(common, SPECTRAL_SCAN, "FFT frame len: %i\n",
572 sample_bytes);
573 switch (sample_bytes - sample_len) {
574 case -1:
575 /* First byte missing */
576 memcpy(&sample_buf[1], sample_start,
577 sample_len - 1);
578 break;
579 case 0:
580 /* Length correct, nothing to do. */
581 memcpy(sample_buf, sample_start, sample_len);
582 break;
583 case 1:
584 /* MAC added 2 extra bytes AND first byte
585 * is missing.
586 */
587 memcpy(&sample_buf[1], sample_start, 30);
588 sample_buf[31] = sample_start[31];
589 memcpy(&sample_buf[32], &sample_start[33],
590 sample_len - 32);
591 break;
592 case 2:
593 /* MAC added 2 extra bytes at bin 30 and 32,
594 * remove them.
595 */
596 memcpy(sample_buf, sample_start, 30);
597 sample_buf[30] = sample_start[31];
598 memcpy(&sample_buf[31], &sample_start[33],
599 sample_len - 31);
600 break;
601 default:
602 break;
603 }
604
605 ret = fft_handler(rs, spec_priv, sample_buf, tsf,
606 freq, chan_type);
607 memset(sample_buf, 0, SPECTRAL_SAMPLE_MAX_LEN);
608 sample_start = &vdata[i + 1];
609 /* -1 to grab sample_len -1, -2 since
610 * they 'll get increased by one. In case
611 * of failure try to recover by going byte
612 * by byte instead. */
613 if (ret == 0) {
614 i += num_bins - 2;
615 sample_bytes = num_bins - 2;
616 }
617 got_slen = 0;
618 }
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530619 }
620
Nick Kossifidis72dd2cd2015-04-29 23:51:16 +0000621 i -= num_bins - 2;
622 if (len - i != sizeof(struct ath_radar_info))
623 ath_dbg(common, SPECTRAL_SCAN, "FFT report truncated"
624 "(bytes left: %i)\n",
625 len - i);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530626 return 1;
627}
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100628EXPORT_SYMBOL(ath_cmn_process_fft);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530629
630/*********************/
631/* spectral_scan_ctl */
632/*********************/
633
634static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
635 size_t count, loff_t *ppos)
636{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100637 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530638 char *mode = "";
639 unsigned int len;
640
Oleksij Rempel1111d422014-11-06 08:53:23 +0100641 switch (spec_priv->spectral_mode) {
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530642 case SPECTRAL_DISABLED:
643 mode = "disable";
644 break;
645 case SPECTRAL_BACKGROUND:
646 mode = "background";
647 break;
648 case SPECTRAL_CHANSCAN:
649 mode = "chanscan";
650 break;
651 case SPECTRAL_MANUAL:
652 mode = "manual";
653 break;
654 }
655 len = strlen(mode);
656 return simple_read_from_buffer(user_buf, count, ppos, mode, len);
657}
658
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100659void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
Oleksij Rempelf00a4222014-11-06 08:53:29 +0100660 struct ath_spec_scan_priv *spec_priv)
661{
662 struct ath_hw *ah = spec_priv->ah;
663 u32 rxfilter;
664
665 if (config_enabled(CONFIG_ATH9K_TX99))
666 return;
667
668 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
669 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
670 return;
671 }
672
673 ath_ps_ops(common)->wakeup(common);
674 rxfilter = ath9k_hw_getrxfilter(ah);
675 ath9k_hw_setrxfilter(ah, rxfilter |
676 ATH9K_RX_FILTER_PHYRADAR |
677 ATH9K_RX_FILTER_PHYERR);
678
679 /* TODO: usually this should not be neccesary, but for some reason
680 * (or in some mode?) the trigger must be called after the
681 * configuration, otherwise the register will have its values reset
682 * (on my ar9220 to value 0x01002310)
683 */
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100684 ath9k_cmn_spectral_scan_config(common, spec_priv, spec_priv->spectral_mode);
Oleksij Rempelf00a4222014-11-06 08:53:29 +0100685 ath9k_hw_ops(ah)->spectral_scan_trigger(ah);
686 ath_ps_ops(common)->restore(common);
687}
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100688EXPORT_SYMBOL(ath9k_cmn_spectral_scan_trigger);
Oleksij Rempelf00a4222014-11-06 08:53:29 +0100689
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100690int ath9k_cmn_spectral_scan_config(struct ath_common *common,
Oleksij Rempelf00a4222014-11-06 08:53:29 +0100691 struct ath_spec_scan_priv *spec_priv,
692 enum spectral_mode spectral_mode)
693{
694 struct ath_hw *ah = spec_priv->ah;
695
696 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
697 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
698 return -1;
699 }
700
701 switch (spectral_mode) {
702 case SPECTRAL_DISABLED:
703 spec_priv->spec_config.enabled = 0;
704 break;
705 case SPECTRAL_BACKGROUND:
706 /* send endless samples.
707 * TODO: is this really useful for "background"?
708 */
709 spec_priv->spec_config.endless = 1;
710 spec_priv->spec_config.enabled = 1;
711 break;
712 case SPECTRAL_CHANSCAN:
713 case SPECTRAL_MANUAL:
714 spec_priv->spec_config.endless = 0;
715 spec_priv->spec_config.enabled = 1;
716 break;
717 default:
718 return -1;
719 }
720
721 ath_ps_ops(common)->wakeup(common);
722 ath9k_hw_ops(ah)->spectral_scan_config(ah, &spec_priv->spec_config);
723 ath_ps_ops(common)->restore(common);
724
725 spec_priv->spectral_mode = spectral_mode;
726
727 return 0;
728}
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100729EXPORT_SYMBOL(ath9k_cmn_spectral_scan_config);
Oleksij Rempelf00a4222014-11-06 08:53:29 +0100730
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530731static ssize_t write_file_spec_scan_ctl(struct file *file,
732 const char __user *user_buf,
733 size_t count, loff_t *ppos)
734{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100735 struct ath_spec_scan_priv *spec_priv = file->private_data;
736 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530737 char buf[32];
738 ssize_t len;
739
740 if (config_enabled(CONFIG_ATH9K_TX99))
741 return -EOPNOTSUPP;
742
743 len = min(count, sizeof(buf) - 1);
744 if (copy_from_user(buf, user_buf, len))
745 return -EFAULT;
746
747 buf[len] = '\0';
748
749 if (strncmp("trigger", buf, 7) == 0) {
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100750 ath9k_cmn_spectral_scan_trigger(common, spec_priv);
Maks Naumovded3fb42014-08-16 00:41:07 -0700751 } else if (strncmp("background", buf, 10) == 0) {
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100752 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_BACKGROUND);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530753 ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n");
754 } else if (strncmp("chanscan", buf, 8) == 0) {
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100755 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_CHANSCAN);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530756 ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n");
757 } else if (strncmp("manual", buf, 6) == 0) {
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100758 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_MANUAL);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530759 ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n");
760 } else if (strncmp("disable", buf, 7) == 0) {
Oleksij Rempel67dc74f2014-11-06 08:53:30 +0100761 ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_DISABLED);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530762 ath_dbg(common, CONFIG, "spectral scan: disabled\n");
763 } else {
764 return -EINVAL;
765 }
766
767 return count;
768}
769
770static const struct file_operations fops_spec_scan_ctl = {
771 .read = read_file_spec_scan_ctl,
772 .write = write_file_spec_scan_ctl,
773 .open = simple_open,
774 .owner = THIS_MODULE,
775 .llseek = default_llseek,
776};
777
778/*************************/
779/* spectral_short_repeat */
780/*************************/
781
782static ssize_t read_file_spectral_short_repeat(struct file *file,
783 char __user *user_buf,
784 size_t count, loff_t *ppos)
785{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100786 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530787 char buf[32];
788 unsigned int len;
789
Oleksij Rempel1111d422014-11-06 08:53:23 +0100790 len = sprintf(buf, "%d\n", spec_priv->spec_config.short_repeat);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530791 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
792}
793
794static ssize_t write_file_spectral_short_repeat(struct file *file,
795 const char __user *user_buf,
796 size_t count, loff_t *ppos)
797{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100798 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530799 unsigned long val;
800 char buf[32];
801 ssize_t len;
802
803 len = min(count, sizeof(buf) - 1);
804 if (copy_from_user(buf, user_buf, len))
805 return -EFAULT;
806
807 buf[len] = '\0';
808 if (kstrtoul(buf, 0, &val))
809 return -EINVAL;
810
Andrey Utkin3f557202014-07-17 16:56:37 +0300811 if (val > 1)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530812 return -EINVAL;
813
Oleksij Rempel1111d422014-11-06 08:53:23 +0100814 spec_priv->spec_config.short_repeat = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530815 return count;
816}
817
818static const struct file_operations fops_spectral_short_repeat = {
819 .read = read_file_spectral_short_repeat,
820 .write = write_file_spectral_short_repeat,
821 .open = simple_open,
822 .owner = THIS_MODULE,
823 .llseek = default_llseek,
824};
825
826/******************/
827/* spectral_count */
828/******************/
829
830static ssize_t read_file_spectral_count(struct file *file,
831 char __user *user_buf,
832 size_t count, loff_t *ppos)
833{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100834 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530835 char buf[32];
836 unsigned int len;
837
Oleksij Rempel1111d422014-11-06 08:53:23 +0100838 len = sprintf(buf, "%d\n", spec_priv->spec_config.count);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530839 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
840}
841
842static ssize_t write_file_spectral_count(struct file *file,
843 const char __user *user_buf,
844 size_t count, loff_t *ppos)
845{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100846 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530847 unsigned long val;
848 char buf[32];
849 ssize_t len;
850
851 len = min(count, sizeof(buf) - 1);
852 if (copy_from_user(buf, user_buf, len))
853 return -EFAULT;
854
855 buf[len] = '\0';
856 if (kstrtoul(buf, 0, &val))
857 return -EINVAL;
858
Andrey Utkin3f557202014-07-17 16:56:37 +0300859 if (val > 255)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530860 return -EINVAL;
861
Oleksij Rempel1111d422014-11-06 08:53:23 +0100862 spec_priv->spec_config.count = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530863 return count;
864}
865
866static const struct file_operations fops_spectral_count = {
867 .read = read_file_spectral_count,
868 .write = write_file_spectral_count,
869 .open = simple_open,
870 .owner = THIS_MODULE,
871 .llseek = default_llseek,
872};
873
874/*******************/
875/* spectral_period */
876/*******************/
877
878static ssize_t read_file_spectral_period(struct file *file,
879 char __user *user_buf,
880 size_t count, loff_t *ppos)
881{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100882 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530883 char buf[32];
884 unsigned int len;
885
Oleksij Rempel1111d422014-11-06 08:53:23 +0100886 len = sprintf(buf, "%d\n", spec_priv->spec_config.period);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530887 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
888}
889
890static ssize_t write_file_spectral_period(struct file *file,
891 const char __user *user_buf,
892 size_t count, loff_t *ppos)
893{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100894 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530895 unsigned long val;
896 char buf[32];
897 ssize_t len;
898
899 len = min(count, sizeof(buf) - 1);
900 if (copy_from_user(buf, user_buf, len))
901 return -EFAULT;
902
903 buf[len] = '\0';
904 if (kstrtoul(buf, 0, &val))
905 return -EINVAL;
906
Andrey Utkin3f557202014-07-17 16:56:37 +0300907 if (val > 255)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530908 return -EINVAL;
909
Oleksij Rempel1111d422014-11-06 08:53:23 +0100910 spec_priv->spec_config.period = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530911 return count;
912}
913
914static const struct file_operations fops_spectral_period = {
915 .read = read_file_spectral_period,
916 .write = write_file_spectral_period,
917 .open = simple_open,
918 .owner = THIS_MODULE,
919 .llseek = default_llseek,
920};
921
922/***********************/
923/* spectral_fft_period */
924/***********************/
925
926static ssize_t read_file_spectral_fft_period(struct file *file,
927 char __user *user_buf,
928 size_t count, loff_t *ppos)
929{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100930 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530931 char buf[32];
932 unsigned int len;
933
Oleksij Rempel1111d422014-11-06 08:53:23 +0100934 len = sprintf(buf, "%d\n", spec_priv->spec_config.fft_period);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530935 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
936}
937
938static ssize_t write_file_spectral_fft_period(struct file *file,
939 const char __user *user_buf,
940 size_t count, loff_t *ppos)
941{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100942 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530943 unsigned long val;
944 char buf[32];
945 ssize_t len;
946
947 len = min(count, sizeof(buf) - 1);
948 if (copy_from_user(buf, user_buf, len))
949 return -EFAULT;
950
951 buf[len] = '\0';
952 if (kstrtoul(buf, 0, &val))
953 return -EINVAL;
954
Andrey Utkin3f557202014-07-17 16:56:37 +0300955 if (val > 15)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530956 return -EINVAL;
957
Oleksij Rempel1111d422014-11-06 08:53:23 +0100958 spec_priv->spec_config.fft_period = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530959 return count;
960}
961
962static const struct file_operations fops_spectral_fft_period = {
963 .read = read_file_spectral_fft_period,
964 .write = write_file_spectral_fft_period,
965 .open = simple_open,
966 .owner = THIS_MODULE,
967 .llseek = default_llseek,
968};
969
970/*******************/
971/* Relay interface */
972/*******************/
973
974static struct dentry *create_buf_file_handler(const char *filename,
975 struct dentry *parent,
976 umode_t mode,
977 struct rchan_buf *buf,
978 int *is_global)
979{
980 struct dentry *buf_file;
981
982 buf_file = debugfs_create_file(filename, mode, parent, buf,
983 &relay_file_operations);
984 *is_global = 1;
985 return buf_file;
986}
987
988static int remove_buf_file_handler(struct dentry *dentry)
989{
990 debugfs_remove(dentry);
991
992 return 0;
993}
994
Wei Yongjunf84d1b42013-12-20 10:22:51 +0800995static struct rchan_callbacks rfs_spec_scan_cb = {
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530996 .create_buf_file = create_buf_file_handler,
997 .remove_buf_file = remove_buf_file_handler,
998};
999
1000/*********************/
1001/* Debug Init/Deinit */
1002/*********************/
1003
Oleksij Rempel67dc74f2014-11-06 08:53:30 +01001004void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301005{
Markus Elfringc0420ea2015-02-04 18:48:28 +01001006 if (config_enabled(CONFIG_ATH9K_DEBUGFS)) {
Oleksij Rempel1111d422014-11-06 08:53:23 +01001007 relay_close(spec_priv->rfs_chan_spec_scan);
1008 spec_priv->rfs_chan_spec_scan = NULL;
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301009 }
1010}
Oleksij Rempel67dc74f2014-11-06 08:53:30 +01001011EXPORT_SYMBOL(ath9k_cmn_spectral_deinit_debug);
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301012
Oleksij Rempel67dc74f2014-11-06 08:53:30 +01001013void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv,
1014 struct dentry *debugfs_phy)
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301015{
Oleksij Rempel1111d422014-11-06 08:53:23 +01001016 spec_priv->rfs_chan_spec_scan = relay_open("spectral_scan",
Oleksij Rempelc10b75a2014-11-06 08:53:21 +01001017 debugfs_phy,
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301018 1024, 256, &rfs_spec_scan_cb,
1019 NULL);
1020 debugfs_create_file("spectral_scan_ctl",
1021 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +01001022 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301023 &fops_spec_scan_ctl);
1024 debugfs_create_file("spectral_short_repeat",
1025 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +01001026 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301027 &fops_spectral_short_repeat);
1028 debugfs_create_file("spectral_count",
1029 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +01001030 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301031 &fops_spectral_count);
1032 debugfs_create_file("spectral_period",
1033 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +01001034 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301035 &fops_spectral_period);
1036 debugfs_create_file("spectral_fft_period",
1037 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +01001038 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301039 &fops_spectral_fft_period);
1040}
Oleksij Rempel67dc74f2014-11-06 08:53:30 +01001041EXPORT_SYMBOL(ath9k_cmn_spectral_init_debug);