blob: 4549dce60c16d59c823367202146ca2c9b4daf6f [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
39/* returns 1 if this was a spectral frame, even if not handled. */
Oleksij Rempel1111d422014-11-06 08:53:23 +010040int ath_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
Sujith Manoharanf65c0822013-12-18 09:53:18 +053041 struct ath_rx_status *rs, u64 tsf)
42{
Oleksij Rempel1111d422014-11-06 08:53:23 +010043 struct ath_hw *ah = spec_priv->ah;
44 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
Sujith Manoharanf65c0822013-12-18 09:53:18 +053045 u8 num_bins, *bins, *vdata = (u8 *)hdr;
46 struct fft_sample_ht20 fft_sample_20;
47 struct fft_sample_ht20_40 fft_sample_40;
48 struct fft_sample_tlv *tlv;
49 struct ath_radar_info *radar_info;
50 int len = rs->rs_datalen;
51 int dc_pos;
52 u16 fft_len, length, freq = ah->curchan->chan->center_freq;
53 enum nl80211_channel_type chan_type;
54
55 /* AR9280 and before report via ATH9K_PHYERR_RADAR, AR93xx and newer
56 * via ATH9K_PHYERR_SPECTRAL. Haven't seen ATH9K_PHYERR_FALSE_RADAR_EXT
57 * yet, but this is supposed to be possible as well.
58 */
59 if (rs->rs_phyerr != ATH9K_PHYERR_RADAR &&
60 rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT &&
61 rs->rs_phyerr != ATH9K_PHYERR_SPECTRAL)
62 return 0;
63
64 /* check if spectral scan bit is set. This does not have to be checked
65 * if received through a SPECTRAL phy error, but shouldn't hurt.
66 */
67 radar_info = ((struct ath_radar_info *)&vdata[len]) - 1;
68 if (!(radar_info->pulse_bw_info & SPECTRAL_SCAN_BITMASK))
69 return 0;
70
Oleksij Rempel1111d422014-11-06 08:53:23 +010071 chan_type = cfg80211_get_chandef_type(&common->hw->conf.chandef);
Sujith Manoharanf65c0822013-12-18 09:53:18 +053072 if ((chan_type == NL80211_CHAN_HT40MINUS) ||
73 (chan_type == NL80211_CHAN_HT40PLUS)) {
74 fft_len = SPECTRAL_HT20_40_TOTAL_DATA_LEN;
75 num_bins = SPECTRAL_HT20_40_NUM_BINS;
76 bins = (u8 *)fft_sample_40.data;
77 } else {
78 fft_len = SPECTRAL_HT20_TOTAL_DATA_LEN;
79 num_bins = SPECTRAL_HT20_NUM_BINS;
80 bins = (u8 *)fft_sample_20.data;
81 }
82
83 /* Variation in the data length is possible and will be fixed later */
84 if ((len > fft_len + 2) || (len < fft_len - 1))
85 return 1;
86
87 switch (len - fft_len) {
88 case 0:
89 /* length correct, nothing to do. */
90 memcpy(bins, vdata, num_bins);
91 break;
92 case -1:
93 /* first byte missing, duplicate it. */
94 memcpy(&bins[1], vdata, num_bins - 1);
95 bins[0] = vdata[0];
96 break;
97 case 2:
98 /* MAC added 2 extra bytes at bin 30 and 32, remove them. */
99 memcpy(bins, vdata, 30);
100 bins[30] = vdata[31];
101 memcpy(&bins[31], &vdata[33], num_bins - 31);
102 break;
103 case 1:
104 /* MAC added 2 extra bytes AND first byte is missing. */
105 bins[0] = vdata[0];
106 memcpy(&bins[1], vdata, 30);
107 bins[31] = vdata[31];
108 memcpy(&bins[32], &vdata[33], num_bins - 32);
109 break;
110 default:
111 return 1;
112 }
113
114 /* DC value (value in the middle) is the blind spot of the spectral
115 * sample and invalid, interpolate it.
116 */
117 dc_pos = num_bins / 2;
118 bins[dc_pos] = (bins[dc_pos + 1] + bins[dc_pos - 1]) / 2;
119
120 if ((chan_type == NL80211_CHAN_HT40MINUS) ||
121 (chan_type == NL80211_CHAN_HT40PLUS)) {
122 s8 lower_rssi, upper_rssi;
123 s16 ext_nf;
124 u8 lower_max_index, upper_max_index;
125 u8 lower_bitmap_w, upper_bitmap_w;
126 u16 lower_mag, upper_mag;
127 struct ath9k_hw_cal_data *caldata = ah->caldata;
128 struct ath_ht20_40_mag_info *mag_info;
129
130 if (caldata)
131 ext_nf = ath9k_hw_getchan_noise(ah, ah->curchan,
132 caldata->nfCalHist[3].privNF);
133 else
134 ext_nf = ATH_DEFAULT_NOISE_FLOOR;
135
136 length = sizeof(fft_sample_40) - sizeof(struct fft_sample_tlv);
137 fft_sample_40.tlv.type = ATH_FFT_SAMPLE_HT20_40;
138 fft_sample_40.tlv.length = __cpu_to_be16(length);
139 fft_sample_40.freq = __cpu_to_be16(freq);
140 fft_sample_40.channel_type = chan_type;
141
142 if (chan_type == NL80211_CHAN_HT40PLUS) {
143 lower_rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
144 upper_rssi = fix_rssi_inv_only(rs->rs_rssi_ext[0]);
145
146 fft_sample_40.lower_noise = ah->noise;
147 fft_sample_40.upper_noise = ext_nf;
148 } else {
149 lower_rssi = fix_rssi_inv_only(rs->rs_rssi_ext[0]);
150 upper_rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
151
152 fft_sample_40.lower_noise = ext_nf;
153 fft_sample_40.upper_noise = ah->noise;
154 }
155 fft_sample_40.lower_rssi = lower_rssi;
156 fft_sample_40.upper_rssi = upper_rssi;
157
158 mag_info = ((struct ath_ht20_40_mag_info *)radar_info) - 1;
159 lower_mag = spectral_max_magnitude(mag_info->lower_bins);
160 upper_mag = spectral_max_magnitude(mag_info->upper_bins);
161 fft_sample_40.lower_max_magnitude = __cpu_to_be16(lower_mag);
162 fft_sample_40.upper_max_magnitude = __cpu_to_be16(upper_mag);
163 lower_max_index = spectral_max_index(mag_info->lower_bins);
164 upper_max_index = spectral_max_index(mag_info->upper_bins);
165 fft_sample_40.lower_max_index = lower_max_index;
166 fft_sample_40.upper_max_index = upper_max_index;
167 lower_bitmap_w = spectral_bitmap_weight(mag_info->lower_bins);
168 upper_bitmap_w = spectral_bitmap_weight(mag_info->upper_bins);
169 fft_sample_40.lower_bitmap_weight = lower_bitmap_w;
170 fft_sample_40.upper_bitmap_weight = upper_bitmap_w;
171 fft_sample_40.max_exp = mag_info->max_exp & 0xf;
172
173 fft_sample_40.tsf = __cpu_to_be64(tsf);
174
175 tlv = (struct fft_sample_tlv *)&fft_sample_40;
176 } else {
177 u8 max_index, bitmap_w;
178 u16 magnitude;
179 struct ath_ht20_mag_info *mag_info;
180
181 length = sizeof(fft_sample_20) - sizeof(struct fft_sample_tlv);
182 fft_sample_20.tlv.type = ATH_FFT_SAMPLE_HT20;
183 fft_sample_20.tlv.length = __cpu_to_be16(length);
184 fft_sample_20.freq = __cpu_to_be16(freq);
185
186 fft_sample_20.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
187 fft_sample_20.noise = ah->noise;
188
189 mag_info = ((struct ath_ht20_mag_info *)radar_info) - 1;
190 magnitude = spectral_max_magnitude(mag_info->all_bins);
191 fft_sample_20.max_magnitude = __cpu_to_be16(magnitude);
192 max_index = spectral_max_index(mag_info->all_bins);
193 fft_sample_20.max_index = max_index;
194 bitmap_w = spectral_bitmap_weight(mag_info->all_bins);
195 fft_sample_20.bitmap_weight = bitmap_w;
196 fft_sample_20.max_exp = mag_info->max_exp & 0xf;
197
198 fft_sample_20.tsf = __cpu_to_be64(tsf);
199
200 tlv = (struct fft_sample_tlv *)&fft_sample_20;
201 }
202
Oleksij Rempel1111d422014-11-06 08:53:23 +0100203 ath_debug_send_fft_sample(spec_priv, tlv);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530204
205 return 1;
206}
207
208/*********************/
209/* spectral_scan_ctl */
210/*********************/
211
212static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
213 size_t count, loff_t *ppos)
214{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100215 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530216 char *mode = "";
217 unsigned int len;
218
Oleksij Rempel1111d422014-11-06 08:53:23 +0100219 switch (spec_priv->spectral_mode) {
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530220 case SPECTRAL_DISABLED:
221 mode = "disable";
222 break;
223 case SPECTRAL_BACKGROUND:
224 mode = "background";
225 break;
226 case SPECTRAL_CHANSCAN:
227 mode = "chanscan";
228 break;
229 case SPECTRAL_MANUAL:
230 mode = "manual";
231 break;
232 }
233 len = strlen(mode);
234 return simple_read_from_buffer(user_buf, count, ppos, mode, len);
235}
236
237static ssize_t write_file_spec_scan_ctl(struct file *file,
238 const char __user *user_buf,
239 size_t count, loff_t *ppos)
240{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100241 struct ath_spec_scan_priv *spec_priv = file->private_data;
242 struct ath_common *common = ath9k_hw_common(spec_priv->ah);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530243 char buf[32];
244 ssize_t len;
245
246 if (config_enabled(CONFIG_ATH9K_TX99))
247 return -EOPNOTSUPP;
248
249 len = min(count, sizeof(buf) - 1);
250 if (copy_from_user(buf, user_buf, len))
251 return -EFAULT;
252
253 buf[len] = '\0';
254
255 if (strncmp("trigger", buf, 7) == 0) {
Oleksij Rempelef948da2014-11-06 08:53:27 +0100256 ath9k_spectral_scan_trigger(common);
Maks Naumovded3fb42014-08-16 00:41:07 -0700257 } else if (strncmp("background", buf, 10) == 0) {
Oleksij Rempelef948da2014-11-06 08:53:27 +0100258 ath9k_spectral_scan_config(common, SPECTRAL_BACKGROUND);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530259 ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n");
260 } else if (strncmp("chanscan", buf, 8) == 0) {
Oleksij Rempelef948da2014-11-06 08:53:27 +0100261 ath9k_spectral_scan_config(common, SPECTRAL_CHANSCAN);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530262 ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n");
263 } else if (strncmp("manual", buf, 6) == 0) {
Oleksij Rempelef948da2014-11-06 08:53:27 +0100264 ath9k_spectral_scan_config(common, SPECTRAL_MANUAL);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530265 ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n");
266 } else if (strncmp("disable", buf, 7) == 0) {
Oleksij Rempelef948da2014-11-06 08:53:27 +0100267 ath9k_spectral_scan_config(common, SPECTRAL_DISABLED);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530268 ath_dbg(common, CONFIG, "spectral scan: disabled\n");
269 } else {
270 return -EINVAL;
271 }
272
273 return count;
274}
275
276static const struct file_operations fops_spec_scan_ctl = {
277 .read = read_file_spec_scan_ctl,
278 .write = write_file_spec_scan_ctl,
279 .open = simple_open,
280 .owner = THIS_MODULE,
281 .llseek = default_llseek,
282};
283
284/*************************/
285/* spectral_short_repeat */
286/*************************/
287
288static ssize_t read_file_spectral_short_repeat(struct file *file,
289 char __user *user_buf,
290 size_t count, loff_t *ppos)
291{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100292 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530293 char buf[32];
294 unsigned int len;
295
Oleksij Rempel1111d422014-11-06 08:53:23 +0100296 len = sprintf(buf, "%d\n", spec_priv->spec_config.short_repeat);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530297 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
298}
299
300static ssize_t write_file_spectral_short_repeat(struct file *file,
301 const char __user *user_buf,
302 size_t count, loff_t *ppos)
303{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100304 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530305 unsigned long val;
306 char buf[32];
307 ssize_t len;
308
309 len = min(count, sizeof(buf) - 1);
310 if (copy_from_user(buf, user_buf, len))
311 return -EFAULT;
312
313 buf[len] = '\0';
314 if (kstrtoul(buf, 0, &val))
315 return -EINVAL;
316
Andrey Utkin3f557202014-07-17 16:56:37 +0300317 if (val > 1)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530318 return -EINVAL;
319
Oleksij Rempel1111d422014-11-06 08:53:23 +0100320 spec_priv->spec_config.short_repeat = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530321 return count;
322}
323
324static const struct file_operations fops_spectral_short_repeat = {
325 .read = read_file_spectral_short_repeat,
326 .write = write_file_spectral_short_repeat,
327 .open = simple_open,
328 .owner = THIS_MODULE,
329 .llseek = default_llseek,
330};
331
332/******************/
333/* spectral_count */
334/******************/
335
336static ssize_t read_file_spectral_count(struct file *file,
337 char __user *user_buf,
338 size_t count, loff_t *ppos)
339{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100340 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530341 char buf[32];
342 unsigned int len;
343
Oleksij Rempel1111d422014-11-06 08:53:23 +0100344 len = sprintf(buf, "%d\n", spec_priv->spec_config.count);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530345 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
346}
347
348static ssize_t write_file_spectral_count(struct file *file,
349 const char __user *user_buf,
350 size_t count, loff_t *ppos)
351{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100352 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530353 unsigned long val;
354 char buf[32];
355 ssize_t len;
356
357 len = min(count, sizeof(buf) - 1);
358 if (copy_from_user(buf, user_buf, len))
359 return -EFAULT;
360
361 buf[len] = '\0';
362 if (kstrtoul(buf, 0, &val))
363 return -EINVAL;
364
Andrey Utkin3f557202014-07-17 16:56:37 +0300365 if (val > 255)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530366 return -EINVAL;
367
Oleksij Rempel1111d422014-11-06 08:53:23 +0100368 spec_priv->spec_config.count = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530369 return count;
370}
371
372static const struct file_operations fops_spectral_count = {
373 .read = read_file_spectral_count,
374 .write = write_file_spectral_count,
375 .open = simple_open,
376 .owner = THIS_MODULE,
377 .llseek = default_llseek,
378};
379
380/*******************/
381/* spectral_period */
382/*******************/
383
384static ssize_t read_file_spectral_period(struct file *file,
385 char __user *user_buf,
386 size_t count, loff_t *ppos)
387{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100388 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530389 char buf[32];
390 unsigned int len;
391
Oleksij Rempel1111d422014-11-06 08:53:23 +0100392 len = sprintf(buf, "%d\n", spec_priv->spec_config.period);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530393 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
394}
395
396static ssize_t write_file_spectral_period(struct file *file,
397 const char __user *user_buf,
398 size_t count, loff_t *ppos)
399{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100400 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530401 unsigned long val;
402 char buf[32];
403 ssize_t len;
404
405 len = min(count, sizeof(buf) - 1);
406 if (copy_from_user(buf, user_buf, len))
407 return -EFAULT;
408
409 buf[len] = '\0';
410 if (kstrtoul(buf, 0, &val))
411 return -EINVAL;
412
Andrey Utkin3f557202014-07-17 16:56:37 +0300413 if (val > 255)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530414 return -EINVAL;
415
Oleksij Rempel1111d422014-11-06 08:53:23 +0100416 spec_priv->spec_config.period = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530417 return count;
418}
419
420static const struct file_operations fops_spectral_period = {
421 .read = read_file_spectral_period,
422 .write = write_file_spectral_period,
423 .open = simple_open,
424 .owner = THIS_MODULE,
425 .llseek = default_llseek,
426};
427
428/***********************/
429/* spectral_fft_period */
430/***********************/
431
432static ssize_t read_file_spectral_fft_period(struct file *file,
433 char __user *user_buf,
434 size_t count, loff_t *ppos)
435{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100436 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530437 char buf[32];
438 unsigned int len;
439
Oleksij Rempel1111d422014-11-06 08:53:23 +0100440 len = sprintf(buf, "%d\n", spec_priv->spec_config.fft_period);
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530441 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
442}
443
444static ssize_t write_file_spectral_fft_period(struct file *file,
445 const char __user *user_buf,
446 size_t count, loff_t *ppos)
447{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100448 struct ath_spec_scan_priv *spec_priv = file->private_data;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530449 unsigned long val;
450 char buf[32];
451 ssize_t len;
452
453 len = min(count, sizeof(buf) - 1);
454 if (copy_from_user(buf, user_buf, len))
455 return -EFAULT;
456
457 buf[len] = '\0';
458 if (kstrtoul(buf, 0, &val))
459 return -EINVAL;
460
Andrey Utkin3f557202014-07-17 16:56:37 +0300461 if (val > 15)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530462 return -EINVAL;
463
Oleksij Rempel1111d422014-11-06 08:53:23 +0100464 spec_priv->spec_config.fft_period = val;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530465 return count;
466}
467
468static const struct file_operations fops_spectral_fft_period = {
469 .read = read_file_spectral_fft_period,
470 .write = write_file_spectral_fft_period,
471 .open = simple_open,
472 .owner = THIS_MODULE,
473 .llseek = default_llseek,
474};
475
476/*******************/
477/* Relay interface */
478/*******************/
479
480static struct dentry *create_buf_file_handler(const char *filename,
481 struct dentry *parent,
482 umode_t mode,
483 struct rchan_buf *buf,
484 int *is_global)
485{
486 struct dentry *buf_file;
487
488 buf_file = debugfs_create_file(filename, mode, parent, buf,
489 &relay_file_operations);
490 *is_global = 1;
491 return buf_file;
492}
493
494static int remove_buf_file_handler(struct dentry *dentry)
495{
496 debugfs_remove(dentry);
497
498 return 0;
499}
500
Wei Yongjunf84d1b42013-12-20 10:22:51 +0800501static struct rchan_callbacks rfs_spec_scan_cb = {
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530502 .create_buf_file = create_buf_file_handler,
503 .remove_buf_file = remove_buf_file_handler,
504};
505
506/*********************/
507/* Debug Init/Deinit */
508/*********************/
509
Oleksij Rempel1111d422014-11-06 08:53:23 +0100510void ath9k_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530511{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100512 if (config_enabled(CONFIG_ATH9K_DEBUGFS) && spec_priv->rfs_chan_spec_scan) {
513 relay_close(spec_priv->rfs_chan_spec_scan);
514 spec_priv->rfs_chan_spec_scan = NULL;
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530515 }
516}
517
Oleksij Rempel1111d422014-11-06 08:53:23 +0100518void ath9k_spectral_init_debug(struct ath_spec_scan_priv *spec_priv, struct dentry *debugfs_phy)
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530519{
Oleksij Rempel1111d422014-11-06 08:53:23 +0100520 spec_priv->rfs_chan_spec_scan = relay_open("spectral_scan",
Oleksij Rempelc10b75a2014-11-06 08:53:21 +0100521 debugfs_phy,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530522 1024, 256, &rfs_spec_scan_cb,
523 NULL);
524 debugfs_create_file("spectral_scan_ctl",
525 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +0100526 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530527 &fops_spec_scan_ctl);
528 debugfs_create_file("spectral_short_repeat",
529 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +0100530 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530531 &fops_spectral_short_repeat);
532 debugfs_create_file("spectral_count",
533 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +0100534 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530535 &fops_spectral_count);
536 debugfs_create_file("spectral_period",
537 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +0100538 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530539 &fops_spectral_period);
540 debugfs_create_file("spectral_fft_period",
541 S_IRUSR | S_IWUSR,
Oleksij Rempel1111d422014-11-06 08:53:23 +0100542 debugfs_phy, spec_priv,
Sujith Manoharanf65c0822013-12-18 09:53:18 +0530543 &fops_spectral_fft_period);
544}