Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / iwl-debugfs.c
1 /******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29 #include <linux/slab.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/debugfs.h>
33
34 #include <linux/ieee80211.h>
35 #include <net/mac80211.h>
36
37
38 #include "iwl-dev.h"
39 #include "iwl-debug.h"
40 #include "iwl-core.h"
41 #include "iwl-io.h"
42 #include "iwl-calib.h"
43
44 /* create and remove of files */
45 #define DEBUGFS_ADD_FILE(name, parent, mode) do { \
46 if (!debugfs_create_file(#name, mode, parent, priv, \
47 &iwl_dbgfs_##name##_ops)) \
48 goto err; \
49 } while (0)
50
51 #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
52 struct dentry *__tmp; \
53 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
54 parent, ptr); \
55 if (IS_ERR(__tmp) || !__tmp) \
56 goto err; \
57 } while (0)
58
59 #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
60 struct dentry *__tmp; \
61 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
62 parent, ptr); \
63 if (IS_ERR(__tmp) || !__tmp) \
64 goto err; \
65 } while (0)
66
67 /* file operation */
68 #define DEBUGFS_READ_FUNC(name) \
69 static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
70 char __user *user_buf, \
71 size_t count, loff_t *ppos);
72
73 #define DEBUGFS_WRITE_FUNC(name) \
74 static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
75 const char __user *user_buf, \
76 size_t count, loff_t *ppos);
77
78
79 static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
80 {
81 file->private_data = inode->i_private;
82 return 0;
83 }
84
85 #define DEBUGFS_READ_FILE_OPS(name) \
86 DEBUGFS_READ_FUNC(name); \
87 static const struct file_operations iwl_dbgfs_##name##_ops = { \
88 .read = iwl_dbgfs_##name##_read, \
89 .open = iwl_dbgfs_open_file_generic, \
90 };
91
92 #define DEBUGFS_WRITE_FILE_OPS(name) \
93 DEBUGFS_WRITE_FUNC(name); \
94 static const struct file_operations iwl_dbgfs_##name##_ops = { \
95 .write = iwl_dbgfs_##name##_write, \
96 .open = iwl_dbgfs_open_file_generic, \
97 };
98
99
100 #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
101 DEBUGFS_READ_FUNC(name); \
102 DEBUGFS_WRITE_FUNC(name); \
103 static const struct file_operations iwl_dbgfs_##name##_ops = { \
104 .write = iwl_dbgfs_##name##_write, \
105 .read = iwl_dbgfs_##name##_read, \
106 .open = iwl_dbgfs_open_file_generic, \
107 };
108
109 int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
110 {
111 int p = 0;
112
113 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n",
114 le32_to_cpu(priv->statistics.flag));
115 if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
116 p += scnprintf(buf + p, bufsz - p,
117 "\tStatistics have been cleared\n");
118 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
119 (le32_to_cpu(priv->statistics.flag) &
120 UCODE_STATISTICS_FREQUENCY_MSK)
121 ? "2.4 GHz" : "5.2 GHz");
122 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
123 (le32_to_cpu(priv->statistics.flag) &
124 UCODE_STATISTICS_NARROW_BAND_MSK)
125 ? "enabled" : "disabled");
126 return p;
127 }
128 EXPORT_SYMBOL(iwl_dbgfs_statistics_flag);
129
130 static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
131 char __user *user_buf,
132 size_t count, loff_t *ppos) {
133
134 struct iwl_priv *priv = file->private_data;
135 char *buf;
136 int pos = 0;
137
138 int cnt;
139 ssize_t ret;
140 const size_t bufsz = 100 +
141 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
142 buf = kzalloc(bufsz, GFP_KERNEL);
143 if (!buf)
144 return -ENOMEM;
145 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
146 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
147 pos += scnprintf(buf + pos, bufsz - pos,
148 "\t%25s\t\t: %u\n",
149 get_mgmt_string(cnt),
150 priv->tx_stats.mgmt[cnt]);
151 }
152 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
153 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
154 pos += scnprintf(buf + pos, bufsz - pos,
155 "\t%25s\t\t: %u\n",
156 get_ctrl_string(cnt),
157 priv->tx_stats.ctrl[cnt]);
158 }
159 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
160 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
161 priv->tx_stats.data_cnt);
162 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
163 priv->tx_stats.data_bytes);
164 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
165 kfree(buf);
166 return ret;
167 }
168
169 static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
170 const char __user *user_buf,
171 size_t count, loff_t *ppos)
172 {
173 struct iwl_priv *priv = file->private_data;
174 u32 clear_flag;
175 char buf[8];
176 int buf_size;
177
178 memset(buf, 0, sizeof(buf));
179 buf_size = min(count, sizeof(buf) - 1);
180 if (copy_from_user(buf, user_buf, buf_size))
181 return -EFAULT;
182 if (sscanf(buf, "%x", &clear_flag) != 1)
183 return -EFAULT;
184 iwl_clear_traffic_stats(priv);
185
186 return count;
187 }
188
189 static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
190 char __user *user_buf,
191 size_t count, loff_t *ppos) {
192
193 struct iwl_priv *priv = file->private_data;
194 char *buf;
195 int pos = 0;
196 int cnt;
197 ssize_t ret;
198 const size_t bufsz = 100 +
199 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
200 buf = kzalloc(bufsz, GFP_KERNEL);
201 if (!buf)
202 return -ENOMEM;
203
204 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
205 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
206 pos += scnprintf(buf + pos, bufsz - pos,
207 "\t%25s\t\t: %u\n",
208 get_mgmt_string(cnt),
209 priv->rx_stats.mgmt[cnt]);
210 }
211 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
212 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
213 pos += scnprintf(buf + pos, bufsz - pos,
214 "\t%25s\t\t: %u\n",
215 get_ctrl_string(cnt),
216 priv->rx_stats.ctrl[cnt]);
217 }
218 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
219 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
220 priv->rx_stats.data_cnt);
221 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
222 priv->rx_stats.data_bytes);
223
224 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
225 kfree(buf);
226 return ret;
227 }
228
229 #define BYTE1_MASK 0x000000ff;
230 #define BYTE2_MASK 0x0000ffff;
231 #define BYTE3_MASK 0x00ffffff;
232 static ssize_t iwl_dbgfs_sram_read(struct file *file,
233 char __user *user_buf,
234 size_t count, loff_t *ppos)
235 {
236 u32 val;
237 char *buf;
238 ssize_t ret;
239 int i;
240 int pos = 0;
241 struct iwl_priv *priv = file->private_data;
242 size_t bufsz;
243
244 /* default is to dump the entire data segment */
245 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
246 priv->dbgfs_sram_offset = 0x800000;
247 if (priv->ucode_type == UCODE_INIT)
248 priv->dbgfs_sram_len = priv->ucode_init_data.len;
249 else
250 priv->dbgfs_sram_len = priv->ucode_data.len;
251 }
252 bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10;
253 buf = kmalloc(bufsz, GFP_KERNEL);
254 if (!buf)
255 return -ENOMEM;
256 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
257 priv->dbgfs_sram_len);
258 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
259 priv->dbgfs_sram_offset);
260 for (i = priv->dbgfs_sram_len; i > 0; i -= 4) {
261 val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \
262 priv->dbgfs_sram_len - i);
263 if (i < 4) {
264 switch (i) {
265 case 1:
266 val &= BYTE1_MASK;
267 break;
268 case 2:
269 val &= BYTE2_MASK;
270 break;
271 case 3:
272 val &= BYTE3_MASK;
273 break;
274 }
275 }
276 if (!(i % 16))
277 pos += scnprintf(buf + pos, bufsz - pos, "\n");
278 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
279 }
280 pos += scnprintf(buf + pos, bufsz - pos, "\n");
281
282 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
283 kfree(buf);
284 return ret;
285 }
286
287 static ssize_t iwl_dbgfs_sram_write(struct file *file,
288 const char __user *user_buf,
289 size_t count, loff_t *ppos)
290 {
291 struct iwl_priv *priv = file->private_data;
292 char buf[64];
293 int buf_size;
294 u32 offset, len;
295
296 memset(buf, 0, sizeof(buf));
297 buf_size = min(count, sizeof(buf) - 1);
298 if (copy_from_user(buf, user_buf, buf_size))
299 return -EFAULT;
300
301 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
302 priv->dbgfs_sram_offset = offset;
303 priv->dbgfs_sram_len = len;
304 } else {
305 priv->dbgfs_sram_offset = 0;
306 priv->dbgfs_sram_len = 0;
307 }
308
309 return count;
310 }
311
312 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
313 size_t count, loff_t *ppos)
314 {
315 struct iwl_priv *priv = file->private_data;
316 struct iwl_station_entry *station;
317 int max_sta = priv->hw_params.max_stations;
318 char *buf;
319 int i, j, pos = 0;
320 ssize_t ret;
321 /* Add 30 for initial string */
322 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
323
324 buf = kmalloc(bufsz, GFP_KERNEL);
325 if (!buf)
326 return -ENOMEM;
327
328 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
329 priv->num_stations);
330
331 for (i = 0; i < max_sta; i++) {
332 station = &priv->stations[i];
333 if (station->used) {
334 pos += scnprintf(buf + pos, bufsz - pos,
335 "station %d:\ngeneral data:\n", i+1);
336 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
337 station->sta.sta.sta_id);
338 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
339 station->sta.mode);
340 pos += scnprintf(buf + pos, bufsz - pos,
341 "flags: 0x%x\n",
342 station->sta.station_flags_msk);
343 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
344 pos += scnprintf(buf + pos, bufsz - pos,
345 "seq_num\t\ttxq_id");
346 pos += scnprintf(buf + pos, bufsz - pos,
347 "\tframe_count\twait_for_ba\t");
348 pos += scnprintf(buf + pos, bufsz - pos,
349 "start_idx\tbitmap0\t");
350 pos += scnprintf(buf + pos, bufsz - pos,
351 "bitmap1\trate_n_flags");
352 pos += scnprintf(buf + pos, bufsz - pos, "\n");
353
354 for (j = 0; j < MAX_TID_COUNT; j++) {
355 pos += scnprintf(buf + pos, bufsz - pos,
356 "[%d]:\t\t%u", j,
357 station->tid[j].seq_number);
358 pos += scnprintf(buf + pos, bufsz - pos,
359 "\t%u\t\t%u\t\t%u\t\t",
360 station->tid[j].agg.txq_id,
361 station->tid[j].agg.frame_count,
362 station->tid[j].agg.wait_for_ba);
363 pos += scnprintf(buf + pos, bufsz - pos,
364 "%u\t%llu\t%u",
365 station->tid[j].agg.start_idx,
366 (unsigned long long)station->tid[j].agg.bitmap,
367 station->tid[j].agg.rate_n_flags);
368 pos += scnprintf(buf + pos, bufsz - pos, "\n");
369 }
370 pos += scnprintf(buf + pos, bufsz - pos, "\n");
371 }
372 }
373
374 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
375 kfree(buf);
376 return ret;
377 }
378
379 static ssize_t iwl_dbgfs_nvm_read(struct file *file,
380 char __user *user_buf,
381 size_t count,
382 loff_t *ppos)
383 {
384 ssize_t ret;
385 struct iwl_priv *priv = file->private_data;
386 int pos = 0, ofs = 0, buf_size = 0;
387 const u8 *ptr;
388 char *buf;
389 u16 eeprom_ver;
390 size_t eeprom_len = priv->cfg->eeprom_size;
391 buf_size = 4 * eeprom_len + 256;
392
393 if (eeprom_len % 16) {
394 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
395 return -ENODATA;
396 }
397
398 ptr = priv->eeprom;
399 if (!ptr) {
400 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
401 return -ENOMEM;
402 }
403
404 /* 4 characters for byte 0xYY */
405 buf = kzalloc(buf_size, GFP_KERNEL);
406 if (!buf) {
407 IWL_ERR(priv, "Can not allocate Buffer\n");
408 return -ENOMEM;
409 }
410 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
411 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
412 "version: 0x%x\n",
413 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
414 ? "OTP" : "EEPROM", eeprom_ver);
415 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
416 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
417 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
418 buf_size - pos, 0);
419 pos += strlen(buf + pos);
420 if (buf_size - pos > 0)
421 buf[pos++] = '\n';
422 }
423
424 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
425 kfree(buf);
426 return ret;
427 }
428
429 static ssize_t iwl_dbgfs_log_event_read(struct file *file,
430 char __user *user_buf,
431 size_t count, loff_t *ppos)
432 {
433 struct iwl_priv *priv = file->private_data;
434 char *buf;
435 int pos = 0;
436 ssize_t ret = -ENOMEM;
437
438 ret = pos = priv->cfg->ops->lib->dump_nic_event_log(
439 priv, true, &buf, true);
440 if (buf) {
441 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
442 kfree(buf);
443 }
444 return ret;
445 }
446
447 static ssize_t iwl_dbgfs_log_event_write(struct file *file,
448 const char __user *user_buf,
449 size_t count, loff_t *ppos)
450 {
451 struct iwl_priv *priv = file->private_data;
452 u32 event_log_flag;
453 char buf[8];
454 int buf_size;
455
456 memset(buf, 0, sizeof(buf));
457 buf_size = min(count, sizeof(buf) - 1);
458 if (copy_from_user(buf, user_buf, buf_size))
459 return -EFAULT;
460 if (sscanf(buf, "%d", &event_log_flag) != 1)
461 return -EFAULT;
462 if (event_log_flag == 1)
463 priv->cfg->ops->lib->dump_nic_event_log(priv, true,
464 NULL, false);
465
466 return count;
467 }
468
469
470
471 static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
472 size_t count, loff_t *ppos)
473 {
474 struct iwl_priv *priv = file->private_data;
475 struct ieee80211_channel *channels = NULL;
476 const struct ieee80211_supported_band *supp_band = NULL;
477 int pos = 0, i, bufsz = PAGE_SIZE;
478 char *buf;
479 ssize_t ret;
480
481 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
482 return -EAGAIN;
483
484 buf = kzalloc(bufsz, GFP_KERNEL);
485 if (!buf) {
486 IWL_ERR(priv, "Can not allocate Buffer\n");
487 return -ENOMEM;
488 }
489
490 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
491 if (supp_band) {
492 channels = supp_band->channels;
493
494 pos += scnprintf(buf + pos, bufsz - pos,
495 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
496 supp_band->n_channels);
497
498 for (i = 0; i < supp_band->n_channels; i++)
499 pos += scnprintf(buf + pos, bufsz - pos,
500 "%d: %ddBm: BSS%s%s, %s.\n",
501 ieee80211_frequency_to_channel(
502 channels[i].center_freq),
503 channels[i].max_power,
504 channels[i].flags & IEEE80211_CHAN_RADAR ?
505 " (IEEE 802.11h required)" : "",
506 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
507 || (channels[i].flags &
508 IEEE80211_CHAN_RADAR)) ? "" :
509 ", IBSS",
510 channels[i].flags &
511 IEEE80211_CHAN_PASSIVE_SCAN ?
512 "passive only" : "active/passive");
513 }
514 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
515 if (supp_band) {
516 channels = supp_band->channels;
517
518 pos += scnprintf(buf + pos, bufsz - pos,
519 "Displaying %d channels in 5.2GHz band (802.11a)\n",
520 supp_band->n_channels);
521
522 for (i = 0; i < supp_band->n_channels; i++)
523 pos += scnprintf(buf + pos, bufsz - pos,
524 "%d: %ddBm: BSS%s%s, %s.\n",
525 ieee80211_frequency_to_channel(
526 channels[i].center_freq),
527 channels[i].max_power,
528 channels[i].flags & IEEE80211_CHAN_RADAR ?
529 " (IEEE 802.11h required)" : "",
530 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
531 || (channels[i].flags &
532 IEEE80211_CHAN_RADAR)) ? "" :
533 ", IBSS",
534 channels[i].flags &
535 IEEE80211_CHAN_PASSIVE_SCAN ?
536 "passive only" : "active/passive");
537 }
538 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
539 kfree(buf);
540 return ret;
541 }
542
543 static ssize_t iwl_dbgfs_status_read(struct file *file,
544 char __user *user_buf,
545 size_t count, loff_t *ppos) {
546
547 struct iwl_priv *priv = file->private_data;
548 char buf[512];
549 int pos = 0;
550 const size_t bufsz = sizeof(buf);
551
552 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
553 test_bit(STATUS_HCMD_ACTIVE, &priv->status));
554 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
555 test_bit(STATUS_INT_ENABLED, &priv->status));
556 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
557 test_bit(STATUS_RF_KILL_HW, &priv->status));
558 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
559 test_bit(STATUS_CT_KILL, &priv->status));
560 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
561 test_bit(STATUS_INIT, &priv->status));
562 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
563 test_bit(STATUS_ALIVE, &priv->status));
564 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
565 test_bit(STATUS_READY, &priv->status));
566 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
567 test_bit(STATUS_TEMPERATURE, &priv->status));
568 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
569 test_bit(STATUS_GEO_CONFIGURED, &priv->status));
570 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
571 test_bit(STATUS_EXIT_PENDING, &priv->status));
572 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
573 test_bit(STATUS_STATISTICS, &priv->status));
574 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
575 test_bit(STATUS_SCANNING, &priv->status));
576 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
577 test_bit(STATUS_SCAN_ABORTING, &priv->status));
578 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
579 test_bit(STATUS_SCAN_HW, &priv->status));
580 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
581 test_bit(STATUS_POWER_PMI, &priv->status));
582 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
583 test_bit(STATUS_FW_ERROR, &priv->status));
584 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
585 }
586
587 static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
588 char __user *user_buf,
589 size_t count, loff_t *ppos) {
590
591 struct iwl_priv *priv = file->private_data;
592 int pos = 0;
593 int cnt = 0;
594 char *buf;
595 int bufsz = 24 * 64; /* 24 items * 64 char per item */
596 ssize_t ret;
597
598 buf = kzalloc(bufsz, GFP_KERNEL);
599 if (!buf) {
600 IWL_ERR(priv, "Can not allocate Buffer\n");
601 return -ENOMEM;
602 }
603
604 pos += scnprintf(buf + pos, bufsz - pos,
605 "Interrupt Statistics Report:\n");
606
607 pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
608 priv->isr_stats.hw);
609 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
610 priv->isr_stats.sw);
611 if (priv->isr_stats.sw > 0) {
612 pos += scnprintf(buf + pos, bufsz - pos,
613 "\tLast Restarting Code: 0x%X\n",
614 priv->isr_stats.sw_err);
615 }
616 #ifdef CONFIG_IWLWIFI_DEBUG
617 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
618 priv->isr_stats.sch);
619 pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
620 priv->isr_stats.alive);
621 #endif
622 pos += scnprintf(buf + pos, bufsz - pos,
623 "HW RF KILL switch toggled:\t %u\n",
624 priv->isr_stats.rfkill);
625
626 pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
627 priv->isr_stats.ctkill);
628
629 pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
630 priv->isr_stats.wakeup);
631
632 pos += scnprintf(buf + pos, bufsz - pos,
633 "Rx command responses:\t\t %u\n",
634 priv->isr_stats.rx);
635 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
636 if (priv->isr_stats.rx_handlers[cnt] > 0)
637 pos += scnprintf(buf + pos, bufsz - pos,
638 "\tRx handler[%36s]:\t\t %u\n",
639 get_cmd_string(cnt),
640 priv->isr_stats.rx_handlers[cnt]);
641 }
642
643 pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
644 priv->isr_stats.tx);
645
646 pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
647 priv->isr_stats.unhandled);
648
649 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
650 kfree(buf);
651 return ret;
652 }
653
654 static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
655 const char __user *user_buf,
656 size_t count, loff_t *ppos)
657 {
658 struct iwl_priv *priv = file->private_data;
659 char buf[8];
660 int buf_size;
661 u32 reset_flag;
662
663 memset(buf, 0, sizeof(buf));
664 buf_size = min(count, sizeof(buf) - 1);
665 if (copy_from_user(buf, user_buf, buf_size))
666 return -EFAULT;
667 if (sscanf(buf, "%x", &reset_flag) != 1)
668 return -EFAULT;
669 if (reset_flag == 0)
670 iwl_clear_isr_stats(priv);
671
672 return count;
673 }
674
675 static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
676 size_t count, loff_t *ppos)
677 {
678 struct iwl_priv *priv = file->private_data;
679 int pos = 0, i;
680 char buf[256];
681 const size_t bufsz = sizeof(buf);
682
683 for (i = 0; i < AC_NUM; i++) {
684 pos += scnprintf(buf + pos, bufsz - pos,
685 "\tcw_min\tcw_max\taifsn\ttxop\n");
686 pos += scnprintf(buf + pos, bufsz - pos,
687 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
688 priv->qos_data.def_qos_parm.ac[i].cw_min,
689 priv->qos_data.def_qos_parm.ac[i].cw_max,
690 priv->qos_data.def_qos_parm.ac[i].aifsn,
691 priv->qos_data.def_qos_parm.ac[i].edca_txop);
692 }
693 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
694 }
695
696 static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
697 size_t count, loff_t *ppos)
698 {
699 struct iwl_priv *priv = file->private_data;
700 int pos = 0;
701 char buf[256];
702 const size_t bufsz = sizeof(buf);
703
704 pos += scnprintf(buf + pos, bufsz - pos,
705 "allow blinking: %s\n",
706 (priv->allow_blinking) ? "True" : "False");
707 if (priv->allow_blinking) {
708 pos += scnprintf(buf + pos, bufsz - pos,
709 "Led blinking rate: %u\n",
710 priv->last_blink_rate);
711 pos += scnprintf(buf + pos, bufsz - pos,
712 "Last blink time: %lu\n",
713 priv->last_blink_time);
714 }
715
716 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
717 }
718
719 static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
720 char __user *user_buf,
721 size_t count, loff_t *ppos)
722 {
723 struct iwl_priv *priv = file->private_data;
724 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
725 struct iwl_tt_restriction *restriction;
726 char buf[100];
727 int pos = 0;
728 const size_t bufsz = sizeof(buf);
729
730 pos += scnprintf(buf + pos, bufsz - pos,
731 "Thermal Throttling Mode: %s\n",
732 tt->advanced_tt ? "Advance" : "Legacy");
733 pos += scnprintf(buf + pos, bufsz - pos,
734 "Thermal Throttling State: %d\n",
735 tt->state);
736 if (tt->advanced_tt) {
737 restriction = tt->restriction + tt->state;
738 pos += scnprintf(buf + pos, bufsz - pos,
739 "Tx mode: %d\n",
740 restriction->tx_stream);
741 pos += scnprintf(buf + pos, bufsz - pos,
742 "Rx mode: %d\n",
743 restriction->rx_stream);
744 pos += scnprintf(buf + pos, bufsz - pos,
745 "HT mode: %d\n",
746 restriction->is_ht);
747 }
748 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
749 }
750
751 static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
752 const char __user *user_buf,
753 size_t count, loff_t *ppos)
754 {
755 struct iwl_priv *priv = file->private_data;
756 char buf[8];
757 int buf_size;
758 int ht40;
759
760 memset(buf, 0, sizeof(buf));
761 buf_size = min(count, sizeof(buf) - 1);
762 if (copy_from_user(buf, user_buf, buf_size))
763 return -EFAULT;
764 if (sscanf(buf, "%d", &ht40) != 1)
765 return -EFAULT;
766 if (!iwl_is_associated(priv))
767 priv->disable_ht40 = ht40 ? true : false;
768 else {
769 IWL_ERR(priv, "Sta associated with AP - "
770 "Change to 40MHz channel support is not allowed\n");
771 return -EINVAL;
772 }
773
774 return count;
775 }
776
777 static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
778 char __user *user_buf,
779 size_t count, loff_t *ppos)
780 {
781 struct iwl_priv *priv = file->private_data;
782 char buf[100];
783 int pos = 0;
784 const size_t bufsz = sizeof(buf);
785
786 pos += scnprintf(buf + pos, bufsz - pos,
787 "11n 40MHz Mode: %s\n",
788 priv->disable_ht40 ? "Disabled" : "Enabled");
789 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
790 }
791
792 static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
793 const char __user *user_buf,
794 size_t count, loff_t *ppos)
795 {
796 struct iwl_priv *priv = file->private_data;
797 char buf[8];
798 int buf_size;
799 int value;
800
801 memset(buf, 0, sizeof(buf));
802 buf_size = min(count, sizeof(buf) - 1);
803 if (copy_from_user(buf, user_buf, buf_size))
804 return -EFAULT;
805
806 if (sscanf(buf, "%d", &value) != 1)
807 return -EINVAL;
808
809 /*
810 * Our users expect 0 to be "CAM", but 0 isn't actually
811 * valid here. However, let's not confuse them and present
812 * IWL_POWER_INDEX_1 as "1", not "0".
813 */
814 if (value == 0)
815 return -EINVAL;
816 else if (value > 0)
817 value -= 1;
818
819 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
820 return -EINVAL;
821
822 if (!iwl_is_ready_rf(priv))
823 return -EAGAIN;
824
825 priv->power_data.debug_sleep_level_override = value;
826
827 mutex_lock(&priv->mutex);
828 iwl_power_update_mode(priv, true);
829 mutex_unlock(&priv->mutex);
830
831 return count;
832 }
833
834 static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
835 char __user *user_buf,
836 size_t count, loff_t *ppos)
837 {
838 struct iwl_priv *priv = file->private_data;
839 char buf[10];
840 int pos, value;
841 const size_t bufsz = sizeof(buf);
842
843 /* see the write function */
844 value = priv->power_data.debug_sleep_level_override;
845 if (value >= 0)
846 value += 1;
847
848 pos = scnprintf(buf, bufsz, "%d\n", value);
849 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
850 }
851
852 static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
853 char __user *user_buf,
854 size_t count, loff_t *ppos)
855 {
856 struct iwl_priv *priv = file->private_data;
857 char buf[200];
858 int pos = 0, i;
859 const size_t bufsz = sizeof(buf);
860 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
861
862 pos += scnprintf(buf + pos, bufsz - pos,
863 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
864 pos += scnprintf(buf + pos, bufsz - pos,
865 "RX/TX timeout: %d/%d usec\n",
866 le32_to_cpu(cmd->rx_data_timeout),
867 le32_to_cpu(cmd->tx_data_timeout));
868 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
869 pos += scnprintf(buf + pos, bufsz - pos,
870 "sleep_interval[%d]: %d\n", i,
871 le32_to_cpu(cmd->sleep_interval[i]));
872
873 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
874 }
875
876 DEBUGFS_READ_WRITE_FILE_OPS(sram);
877 DEBUGFS_READ_WRITE_FILE_OPS(log_event);
878 DEBUGFS_READ_FILE_OPS(nvm);
879 DEBUGFS_READ_FILE_OPS(stations);
880 DEBUGFS_READ_FILE_OPS(channels);
881 DEBUGFS_READ_FILE_OPS(status);
882 DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
883 DEBUGFS_READ_FILE_OPS(qos);
884 DEBUGFS_READ_FILE_OPS(led);
885 DEBUGFS_READ_FILE_OPS(thermal_throttling);
886 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
887 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
888 DEBUGFS_READ_FILE_OPS(current_sleep_command);
889
890 static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
891 char __user *user_buf,
892 size_t count, loff_t *ppos)
893 {
894 struct iwl_priv *priv = file->private_data;
895 int pos = 0, ofs = 0;
896 int cnt = 0, entry;
897 struct iwl_tx_queue *txq;
898 struct iwl_queue *q;
899 struct iwl_rx_queue *rxq = &priv->rxq;
900 char *buf;
901 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
902 (priv->cfg->num_of_queues * 32 * 8) + 400;
903 const u8 *ptr;
904 ssize_t ret;
905
906 if (!priv->txq) {
907 IWL_ERR(priv, "txq not ready\n");
908 return -EAGAIN;
909 }
910 buf = kzalloc(bufsz, GFP_KERNEL);
911 if (!buf) {
912 IWL_ERR(priv, "Can not allocate buffer\n");
913 return -ENOMEM;
914 }
915 pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n");
916 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
917 txq = &priv->txq[cnt];
918 q = &txq->q;
919 pos += scnprintf(buf + pos, bufsz - pos,
920 "q[%d]: read_ptr: %u, write_ptr: %u\n",
921 cnt, q->read_ptr, q->write_ptr);
922 }
923 if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) {
924 ptr = priv->tx_traffic;
925 pos += scnprintf(buf + pos, bufsz - pos,
926 "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
927 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
928 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
929 entry++, ofs += 16) {
930 pos += scnprintf(buf + pos, bufsz - pos,
931 "0x%.4x ", ofs);
932 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
933 buf + pos, bufsz - pos, 0);
934 pos += strlen(buf + pos);
935 if (bufsz - pos > 0)
936 buf[pos++] = '\n';
937 }
938 }
939 }
940
941 pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n");
942 pos += scnprintf(buf + pos, bufsz - pos,
943 "read: %u, write: %u\n",
944 rxq->read, rxq->write);
945
946 if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) {
947 ptr = priv->rx_traffic;
948 pos += scnprintf(buf + pos, bufsz - pos,
949 "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
950 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
951 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
952 entry++, ofs += 16) {
953 pos += scnprintf(buf + pos, bufsz - pos,
954 "0x%.4x ", ofs);
955 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
956 buf + pos, bufsz - pos, 0);
957 pos += strlen(buf + pos);
958 if (bufsz - pos > 0)
959 buf[pos++] = '\n';
960 }
961 }
962 }
963
964 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
965 kfree(buf);
966 return ret;
967 }
968
969 static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
970 const char __user *user_buf,
971 size_t count, loff_t *ppos)
972 {
973 struct iwl_priv *priv = file->private_data;
974 char buf[8];
975 int buf_size;
976 int traffic_log;
977
978 memset(buf, 0, sizeof(buf));
979 buf_size = min(count, sizeof(buf) - 1);
980 if (copy_from_user(buf, user_buf, buf_size))
981 return -EFAULT;
982 if (sscanf(buf, "%d", &traffic_log) != 1)
983 return -EFAULT;
984 if (traffic_log == 0)
985 iwl_reset_traffic_log(priv);
986
987 return count;
988 }
989
990 static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
991 char __user *user_buf,
992 size_t count, loff_t *ppos) {
993
994 struct iwl_priv *priv = file->private_data;
995 struct iwl_tx_queue *txq;
996 struct iwl_queue *q;
997 char *buf;
998 int pos = 0;
999 int cnt;
1000 int ret;
1001 const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues;
1002
1003 if (!priv->txq) {
1004 IWL_ERR(priv, "txq not ready\n");
1005 return -EAGAIN;
1006 }
1007 buf = kzalloc(bufsz, GFP_KERNEL);
1008 if (!buf)
1009 return -ENOMEM;
1010
1011 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
1012 txq = &priv->txq[cnt];
1013 q = &txq->q;
1014 pos += scnprintf(buf + pos, bufsz - pos,
1015 "hwq %.2d: read=%u write=%u stop=%d"
1016 " swq_id=%#.2x (ac %d/hwq %d)\n",
1017 cnt, q->read_ptr, q->write_ptr,
1018 !!test_bit(cnt, priv->queue_stopped),
1019 txq->swq_id,
1020 txq->swq_id & 0x80 ? txq->swq_id & 3 :
1021 txq->swq_id,
1022 txq->swq_id & 0x80 ? (txq->swq_id >> 2) &
1023 0x1f : txq->swq_id);
1024 if (cnt >= 4)
1025 continue;
1026 /* for the ACs, display the stop count too */
1027 pos += scnprintf(buf + pos, bufsz - pos,
1028 " stop-count: %d\n",
1029 atomic_read(&priv->queue_stop_count[cnt]));
1030 }
1031 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1032 kfree(buf);
1033 return ret;
1034 }
1035
1036 static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1037 char __user *user_buf,
1038 size_t count, loff_t *ppos) {
1039
1040 struct iwl_priv *priv = file->private_data;
1041 struct iwl_rx_queue *rxq = &priv->rxq;
1042 char buf[256];
1043 int pos = 0;
1044 const size_t bufsz = sizeof(buf);
1045
1046 pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n",
1047 rxq->read);
1048 pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n",
1049 rxq->write);
1050 pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n",
1051 rxq->free_count);
1052 pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n",
1053 le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF);
1054 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1055 }
1056
1057 static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1058 char __user *user_buf,
1059 size_t count, loff_t *ppos)
1060 {
1061 struct iwl_priv *priv = file->private_data;
1062 return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file,
1063 user_buf, count, ppos);
1064 }
1065
1066 static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1067 char __user *user_buf,
1068 size_t count, loff_t *ppos)
1069 {
1070 struct iwl_priv *priv = file->private_data;
1071 return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file,
1072 user_buf, count, ppos);
1073 }
1074
1075 static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1076 char __user *user_buf,
1077 size_t count, loff_t *ppos)
1078 {
1079 struct iwl_priv *priv = file->private_data;
1080 return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file,
1081 user_buf, count, ppos);
1082 }
1083
1084 static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1085 char __user *user_buf,
1086 size_t count, loff_t *ppos) {
1087
1088 struct iwl_priv *priv = file->private_data;
1089 int pos = 0;
1090 int cnt = 0;
1091 char *buf;
1092 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1093 ssize_t ret;
1094 struct iwl_sensitivity_data *data;
1095
1096 data = &priv->sensitivity_data;
1097 buf = kzalloc(bufsz, GFP_KERNEL);
1098 if (!buf) {
1099 IWL_ERR(priv, "Can not allocate Buffer\n");
1100 return -ENOMEM;
1101 }
1102
1103 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1104 data->auto_corr_ofdm);
1105 pos += scnprintf(buf + pos, bufsz - pos,
1106 "auto_corr_ofdm_mrc:\t\t %u\n",
1107 data->auto_corr_ofdm_mrc);
1108 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1109 data->auto_corr_ofdm_x1);
1110 pos += scnprintf(buf + pos, bufsz - pos,
1111 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1112 data->auto_corr_ofdm_mrc_x1);
1113 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1114 data->auto_corr_cck);
1115 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1116 data->auto_corr_cck_mrc);
1117 pos += scnprintf(buf + pos, bufsz - pos,
1118 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1119 data->last_bad_plcp_cnt_ofdm);
1120 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1121 data->last_fa_cnt_ofdm);
1122 pos += scnprintf(buf + pos, bufsz - pos,
1123 "last_bad_plcp_cnt_cck:\t\t %u\n",
1124 data->last_bad_plcp_cnt_cck);
1125 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1126 data->last_fa_cnt_cck);
1127 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1128 data->nrg_curr_state);
1129 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1130 data->nrg_prev_state);
1131 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1132 for (cnt = 0; cnt < 10; cnt++) {
1133 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1134 data->nrg_value[cnt]);
1135 }
1136 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1137 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1138 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1139 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1140 data->nrg_silence_rssi[cnt]);
1141 }
1142 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1143 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1144 data->nrg_silence_ref);
1145 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1146 data->nrg_energy_idx);
1147 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1148 data->nrg_silence_idx);
1149 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1150 data->nrg_th_cck);
1151 pos += scnprintf(buf + pos, bufsz - pos,
1152 "nrg_auto_corr_silence_diff:\t %u\n",
1153 data->nrg_auto_corr_silence_diff);
1154 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1155 data->num_in_cck_no_fa);
1156 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1157 data->nrg_th_ofdm);
1158
1159 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1160 kfree(buf);
1161 return ret;
1162 }
1163
1164
1165 static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1166 char __user *user_buf,
1167 size_t count, loff_t *ppos) {
1168
1169 struct iwl_priv *priv = file->private_data;
1170 int pos = 0;
1171 int cnt = 0;
1172 char *buf;
1173 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1174 ssize_t ret;
1175 struct iwl_chain_noise_data *data;
1176
1177 data = &priv->chain_noise_data;
1178 buf = kzalloc(bufsz, GFP_KERNEL);
1179 if (!buf) {
1180 IWL_ERR(priv, "Can not allocate Buffer\n");
1181 return -ENOMEM;
1182 }
1183
1184 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1185 data->active_chains);
1186 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1187 data->chain_noise_a);
1188 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1189 data->chain_noise_b);
1190 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1191 data->chain_noise_c);
1192 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1193 data->chain_signal_a);
1194 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1195 data->chain_signal_b);
1196 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1197 data->chain_signal_c);
1198 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1199 data->beacon_count);
1200
1201 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1202 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1203 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1204 data->disconn_array[cnt]);
1205 }
1206 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1207 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1208 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1209 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1210 data->delta_gain_code[cnt]);
1211 }
1212 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1213 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1214 data->radio_write);
1215 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1216 data->state);
1217
1218 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1219 kfree(buf);
1220 return ret;
1221 }
1222
1223 static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1224 char __user *user_buf,
1225 size_t count, loff_t *ppos) {
1226
1227 struct iwl_priv *priv = file->private_data;
1228 char buf[128];
1229 int pos = 0;
1230 const size_t bufsz = sizeof(buf);
1231 struct statistics_tx *tx;
1232
1233 if (!iwl_is_alive(priv))
1234 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1235 else {
1236 tx = &priv->statistics.tx;
1237 if (tx->tx_power.ant_a ||
1238 tx->tx_power.ant_b ||
1239 tx->tx_power.ant_c) {
1240 pos += scnprintf(buf + pos, bufsz - pos,
1241 "tx power: (1/2 dB step)\n");
1242 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1243 tx->tx_power.ant_a)
1244 pos += scnprintf(buf + pos, bufsz - pos,
1245 "\tantenna A: 0x%X\n",
1246 tx->tx_power.ant_a);
1247 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1248 tx->tx_power.ant_b)
1249 pos += scnprintf(buf + pos, bufsz - pos,
1250 "\tantenna B: 0x%X\n",
1251 tx->tx_power.ant_b);
1252 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1253 tx->tx_power.ant_c)
1254 pos += scnprintf(buf + pos, bufsz - pos,
1255 "\tantenna C: 0x%X\n",
1256 tx->tx_power.ant_c);
1257 } else
1258 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1259 }
1260 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1261 }
1262
1263 static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1264 char __user *user_buf,
1265 size_t count, loff_t *ppos)
1266 {
1267 struct iwl_priv *priv = file->private_data;
1268 char buf[60];
1269 int pos = 0;
1270 const size_t bufsz = sizeof(buf);
1271 u32 pwrsave_status;
1272
1273 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
1274 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1275
1276 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1277 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1278 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1279 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1280 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1281 "error");
1282
1283 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1284 }
1285
1286 static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
1287 const char __user *user_buf,
1288 size_t count, loff_t *ppos)
1289 {
1290 struct iwl_priv *priv = file->private_data;
1291 char buf[8];
1292 int buf_size;
1293 int clear;
1294
1295 memset(buf, 0, sizeof(buf));
1296 buf_size = min(count, sizeof(buf) - 1);
1297 if (copy_from_user(buf, user_buf, buf_size))
1298 return -EFAULT;
1299 if (sscanf(buf, "%d", &clear) != 1)
1300 return -EFAULT;
1301
1302 /* make request to uCode to retrieve statistics information */
1303 mutex_lock(&priv->mutex);
1304 iwl_send_statistics_request(priv, CMD_SYNC, true);
1305 mutex_unlock(&priv->mutex);
1306
1307 return count;
1308 }
1309
1310 static ssize_t iwl_dbgfs_csr_write(struct file *file,
1311 const char __user *user_buf,
1312 size_t count, loff_t *ppos)
1313 {
1314 struct iwl_priv *priv = file->private_data;
1315 char buf[8];
1316 int buf_size;
1317 int csr;
1318
1319 memset(buf, 0, sizeof(buf));
1320 buf_size = min(count, sizeof(buf) - 1);
1321 if (copy_from_user(buf, user_buf, buf_size))
1322 return -EFAULT;
1323 if (sscanf(buf, "%d", &csr) != 1)
1324 return -EFAULT;
1325
1326 if (priv->cfg->ops->lib->dump_csr)
1327 priv->cfg->ops->lib->dump_csr(priv);
1328
1329 return count;
1330 }
1331
1332 static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1333 char __user *user_buf,
1334 size_t count, loff_t *ppos) {
1335
1336 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1337 int pos = 0;
1338 char buf[128];
1339 const size_t bufsz = sizeof(buf);
1340
1341 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1342 priv->event_log.ucode_trace ? "On" : "Off");
1343 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1344 priv->event_log.non_wraps_count);
1345 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1346 priv->event_log.wraps_once_count);
1347 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1348 priv->event_log.wraps_more_count);
1349
1350 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1351 }
1352
1353 static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
1354 const char __user *user_buf,
1355 size_t count, loff_t *ppos)
1356 {
1357 struct iwl_priv *priv = file->private_data;
1358 char buf[8];
1359 int buf_size;
1360 int trace;
1361
1362 memset(buf, 0, sizeof(buf));
1363 buf_size = min(count, sizeof(buf) - 1);
1364 if (copy_from_user(buf, user_buf, buf_size))
1365 return -EFAULT;
1366 if (sscanf(buf, "%d", &trace) != 1)
1367 return -EFAULT;
1368
1369 if (trace) {
1370 priv->event_log.ucode_trace = true;
1371 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
1372 mod_timer(&priv->ucode_trace,
1373 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
1374 } else {
1375 priv->event_log.ucode_trace = false;
1376 del_timer_sync(&priv->ucode_trace);
1377 }
1378
1379 return count;
1380 }
1381
1382 static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1383 char __user *user_buf,
1384 size_t count, loff_t *ppos) {
1385
1386 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1387 int len = 0;
1388 char buf[20];
1389
1390 len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags));
1391 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1392 }
1393
1394 static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1395 char __user *user_buf,
1396 size_t count, loff_t *ppos) {
1397
1398 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1399 int len = 0;
1400 char buf[20];
1401
1402 len = sprintf(buf, "0x%04X\n",
1403 le32_to_cpu(priv->active_rxon.filter_flags));
1404 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1405 }
1406
1407 static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
1408 char __user *user_buf,
1409 size_t count, loff_t *ppos)
1410 {
1411 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1412 char *buf;
1413 int pos = 0;
1414 ssize_t ret = -EFAULT;
1415
1416 if (priv->cfg->ops->lib->dump_fh) {
1417 ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true);
1418 if (buf) {
1419 ret = simple_read_from_buffer(user_buf,
1420 count, ppos, buf, pos);
1421 kfree(buf);
1422 }
1423 }
1424
1425 return ret;
1426 }
1427
1428 static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
1429 char __user *user_buf,
1430 size_t count, loff_t *ppos) {
1431
1432 struct iwl_priv *priv = file->private_data;
1433 int pos = 0;
1434 char buf[12];
1435 const size_t bufsz = sizeof(buf);
1436
1437 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
1438 priv->missed_beacon_threshold);
1439
1440 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1441 }
1442
1443 static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
1444 const char __user *user_buf,
1445 size_t count, loff_t *ppos)
1446 {
1447 struct iwl_priv *priv = file->private_data;
1448 char buf[8];
1449 int buf_size;
1450 int missed;
1451
1452 memset(buf, 0, sizeof(buf));
1453 buf_size = min(count, sizeof(buf) - 1);
1454 if (copy_from_user(buf, user_buf, buf_size))
1455 return -EFAULT;
1456 if (sscanf(buf, "%d", &missed) != 1)
1457 return -EINVAL;
1458
1459 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
1460 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
1461 priv->missed_beacon_threshold =
1462 IWL_MISSED_BEACON_THRESHOLD_DEF;
1463 else
1464 priv->missed_beacon_threshold = missed;
1465
1466 return count;
1467 }
1468
1469 static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
1470 char __user *user_buf,
1471 size_t count, loff_t *ppos) {
1472
1473 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1474 int pos = 0;
1475 char buf[12];
1476 const size_t bufsz = sizeof(buf);
1477
1478 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
1479 priv->cfg->plcp_delta_threshold);
1480
1481 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1482 }
1483
1484 static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
1485 const char __user *user_buf,
1486 size_t count, loff_t *ppos) {
1487
1488 struct iwl_priv *priv = file->private_data;
1489 char buf[8];
1490 int buf_size;
1491 int plcp;
1492
1493 memset(buf, 0, sizeof(buf));
1494 buf_size = min(count, sizeof(buf) - 1);
1495 if (copy_from_user(buf, user_buf, buf_size))
1496 return -EFAULT;
1497 if (sscanf(buf, "%d", &plcp) != 1)
1498 return -EINVAL;
1499 if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
1500 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
1501 priv->cfg->plcp_delta_threshold =
1502 IWL_MAX_PLCP_ERR_THRESHOLD_DEF;
1503 else
1504 priv->cfg->plcp_delta_threshold = plcp;
1505 return count;
1506 }
1507
1508 static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
1509 char __user *user_buf,
1510 size_t count, loff_t *ppos) {
1511
1512 struct iwl_priv *priv = file->private_data;
1513 int i, pos = 0;
1514 char buf[300];
1515 const size_t bufsz = sizeof(buf);
1516 struct iwl_force_reset *force_reset;
1517
1518 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
1519 force_reset = &priv->force_reset[i];
1520 pos += scnprintf(buf + pos, bufsz - pos,
1521 "Force reset method %d\n", i);
1522 pos += scnprintf(buf + pos, bufsz - pos,
1523 "\tnumber of reset request: %d\n",
1524 force_reset->reset_request_count);
1525 pos += scnprintf(buf + pos, bufsz - pos,
1526 "\tnumber of reset request success: %d\n",
1527 force_reset->reset_success_count);
1528 pos += scnprintf(buf + pos, bufsz - pos,
1529 "\tnumber of reset request reject: %d\n",
1530 force_reset->reset_reject_count);
1531 pos += scnprintf(buf + pos, bufsz - pos,
1532 "\treset duration: %lu\n",
1533 force_reset->reset_duration);
1534 }
1535 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1536 }
1537
1538 static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
1539 const char __user *user_buf,
1540 size_t count, loff_t *ppos) {
1541
1542 struct iwl_priv *priv = file->private_data;
1543 char buf[8];
1544 int buf_size;
1545 int reset, ret;
1546
1547 memset(buf, 0, sizeof(buf));
1548 buf_size = min(count, sizeof(buf) - 1);
1549 if (copy_from_user(buf, user_buf, buf_size))
1550 return -EFAULT;
1551 if (sscanf(buf, "%d", &reset) != 1)
1552 return -EINVAL;
1553 switch (reset) {
1554 case IWL_RF_RESET:
1555 case IWL_FW_RESET:
1556 ret = iwl_force_reset(priv, reset);
1557 break;
1558 default:
1559 return -EINVAL;
1560 }
1561 return ret ? ret : count;
1562 }
1563
1564 DEBUGFS_READ_FILE_OPS(rx_statistics);
1565 DEBUGFS_READ_FILE_OPS(tx_statistics);
1566 DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
1567 DEBUGFS_READ_FILE_OPS(rx_queue);
1568 DEBUGFS_READ_FILE_OPS(tx_queue);
1569 DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
1570 DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
1571 DEBUGFS_READ_FILE_OPS(ucode_general_stats);
1572 DEBUGFS_READ_FILE_OPS(sensitivity);
1573 DEBUGFS_READ_FILE_OPS(chain_noise);
1574 DEBUGFS_READ_FILE_OPS(tx_power);
1575 DEBUGFS_READ_FILE_OPS(power_save_status);
1576 DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
1577 DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
1578 DEBUGFS_WRITE_FILE_OPS(csr);
1579 DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
1580 DEBUGFS_READ_FILE_OPS(fh_reg);
1581 DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
1582 DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
1583 DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
1584 DEBUGFS_READ_FILE_OPS(rxon_flags);
1585 DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
1586
1587 /*
1588 * Create the debugfs files and directories
1589 *
1590 */
1591 int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1592 {
1593 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
1594 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
1595
1596 dir_drv = debugfs_create_dir(name, phyd);
1597 if (!dir_drv)
1598 return -ENOMEM;
1599
1600 priv->debugfs_dir = dir_drv;
1601
1602 dir_data = debugfs_create_dir("data", dir_drv);
1603 if (!dir_data)
1604 goto err;
1605 dir_rf = debugfs_create_dir("rf", dir_drv);
1606 if (!dir_rf)
1607 goto err;
1608 dir_debug = debugfs_create_dir("debug", dir_drv);
1609 if (!dir_debug)
1610 goto err;
1611
1612 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
1613 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
1614 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
1615 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
1616 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
1617 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
1618 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
1619 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
1620 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
1621 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
1622 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
1623 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
1624 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
1625 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
1626 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
1627 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
1628 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
1629 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
1630 DEBUGFS_ADD_FILE(tx_power, dir_debug, S_IRUSR);
1631 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
1632 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
1633 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
1634 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
1635 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
1636 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
1637 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
1638 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
1639 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
1640 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
1641 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1642
1643 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
1644 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
1645 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
1646 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1647 }
1648 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1649 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
1650 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal);
1651 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
1652 &priv->disable_chain_noise_cal);
1653 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
1654 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
1655 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf,
1656 &priv->disable_tx_power_cal);
1657 return 0;
1658
1659 err:
1660 IWL_ERR(priv, "Can't create the debugfs directory\n");
1661 iwl_dbgfs_unregister(priv);
1662 return -ENOMEM;
1663 }
1664 EXPORT_SYMBOL(iwl_dbgfs_register);
1665
1666 /**
1667 * Remove the debugfs files and directories
1668 *
1669 */
1670 void iwl_dbgfs_unregister(struct iwl_priv *priv)
1671 {
1672 if (!priv->debugfs_dir)
1673 return;
1674
1675 debugfs_remove_recursive(priv->debugfs_dir);
1676 priv->debugfs_dir = NULL;
1677 }
1678 EXPORT_SYMBOL(iwl_dbgfs_unregister);
1679
1680
1681
This page took 0.072177 seconds and 6 git commands to generate.