iwlagn: move sysfs files to debugfs
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / wireless / iwlwifi / iwl-debugfs.c
blobbf2a678970a9a08ada4efe209a53d491fece370b
1 /******************************************************************************
3 * GPL LICENSE SUMMARY
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
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 *****************************************************************************/
29 #include <linux/slab.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/debugfs.h>
34 #include <linux/ieee80211.h>
35 #include <net/mac80211.h>
38 #include "iwl-dev.h"
39 #include "iwl-debug.h"
40 #include "iwl-core.h"
41 #include "iwl-io.h"
42 #include "iwl-agn.h"
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)
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)
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)
67 #define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \
68 struct dentry *__tmp; \
69 __tmp = debugfs_create_u32(#name, mode, \
70 parent, ptr); \
71 if (IS_ERR(__tmp) || !__tmp) \
72 goto err; \
73 } while (0)
75 /* file operation */
76 #define DEBUGFS_READ_FUNC(name) \
77 static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
78 char __user *user_buf, \
79 size_t count, loff_t *ppos);
81 #define DEBUGFS_WRITE_FUNC(name) \
82 static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
83 const char __user *user_buf, \
84 size_t count, loff_t *ppos);
87 static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
89 file->private_data = inode->i_private;
90 return 0;
93 #define DEBUGFS_READ_FILE_OPS(name) \
94 DEBUGFS_READ_FUNC(name); \
95 static const struct file_operations iwl_dbgfs_##name##_ops = { \
96 .read = iwl_dbgfs_##name##_read, \
97 .open = iwl_dbgfs_open_file_generic, \
98 .llseek = generic_file_llseek, \
101 #define DEBUGFS_WRITE_FILE_OPS(name) \
102 DEBUGFS_WRITE_FUNC(name); \
103 static const struct file_operations iwl_dbgfs_##name##_ops = { \
104 .write = iwl_dbgfs_##name##_write, \
105 .open = iwl_dbgfs_open_file_generic, \
106 .llseek = generic_file_llseek, \
110 #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
111 DEBUGFS_READ_FUNC(name); \
112 DEBUGFS_WRITE_FUNC(name); \
113 static const struct file_operations iwl_dbgfs_##name##_ops = { \
114 .write = iwl_dbgfs_##name##_write, \
115 .read = iwl_dbgfs_##name##_read, \
116 .open = iwl_dbgfs_open_file_generic, \
117 .llseek = generic_file_llseek, \
120 static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
121 char __user *user_buf,
122 size_t count, loff_t *ppos) {
124 struct iwl_priv *priv = file->private_data;
125 char *buf;
126 int pos = 0;
128 int cnt;
129 ssize_t ret;
130 const size_t bufsz = 100 +
131 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
132 buf = kzalloc(bufsz, GFP_KERNEL);
133 if (!buf)
134 return -ENOMEM;
135 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
136 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
137 pos += scnprintf(buf + pos, bufsz - pos,
138 "\t%25s\t\t: %u\n",
139 get_mgmt_string(cnt),
140 priv->tx_stats.mgmt[cnt]);
142 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
143 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
144 pos += scnprintf(buf + pos, bufsz - pos,
145 "\t%25s\t\t: %u\n",
146 get_ctrl_string(cnt),
147 priv->tx_stats.ctrl[cnt]);
149 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
150 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
151 priv->tx_stats.data_cnt);
152 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
153 priv->tx_stats.data_bytes);
154 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
155 kfree(buf);
156 return ret;
159 static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
160 const char __user *user_buf,
161 size_t count, loff_t *ppos)
163 struct iwl_priv *priv = file->private_data;
164 u32 clear_flag;
165 char buf[8];
166 int buf_size;
168 memset(buf, 0, sizeof(buf));
169 buf_size = min(count, sizeof(buf) - 1);
170 if (copy_from_user(buf, user_buf, buf_size))
171 return -EFAULT;
172 if (sscanf(buf, "%x", &clear_flag) != 1)
173 return -EFAULT;
174 iwl_clear_traffic_stats(priv);
176 return count;
179 static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
180 char __user *user_buf,
181 size_t count, loff_t *ppos) {
183 struct iwl_priv *priv = file->private_data;
184 char *buf;
185 int pos = 0;
186 int cnt;
187 ssize_t ret;
188 const size_t bufsz = 100 +
189 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
190 buf = kzalloc(bufsz, GFP_KERNEL);
191 if (!buf)
192 return -ENOMEM;
194 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
195 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
196 pos += scnprintf(buf + pos, bufsz - pos,
197 "\t%25s\t\t: %u\n",
198 get_mgmt_string(cnt),
199 priv->rx_stats.mgmt[cnt]);
201 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
202 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
203 pos += scnprintf(buf + pos, bufsz - pos,
204 "\t%25s\t\t: %u\n",
205 get_ctrl_string(cnt),
206 priv->rx_stats.ctrl[cnt]);
208 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
209 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
210 priv->rx_stats.data_cnt);
211 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
212 priv->rx_stats.data_bytes);
214 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
215 kfree(buf);
216 return ret;
219 static ssize_t iwl_dbgfs_sram_read(struct file *file,
220 char __user *user_buf,
221 size_t count, loff_t *ppos)
223 u32 val = 0;
224 char *buf;
225 ssize_t ret;
226 int i = 0;
227 bool device_format = false;
228 int offset = 0;
229 int len = 0;
230 int pos = 0;
231 int sram;
232 struct iwl_priv *priv = file->private_data;
233 size_t bufsz;
235 /* default is to dump the entire data segment */
236 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
237 priv->dbgfs_sram_offset = 0x800000;
238 if (priv->ucode_type == IWL_UCODE_INIT)
239 priv->dbgfs_sram_len = priv->ucode_init.data.len;
240 else
241 priv->dbgfs_sram_len = priv->ucode_rt.data.len;
243 len = priv->dbgfs_sram_len;
245 if (len == -4) {
246 device_format = true;
247 len = 4;
250 bufsz = 50 + len * 4;
251 buf = kmalloc(bufsz, GFP_KERNEL);
252 if (!buf)
253 return -ENOMEM;
255 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
256 len);
257 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
258 priv->dbgfs_sram_offset);
260 /* adjust sram address since reads are only on even u32 boundaries */
261 offset = priv->dbgfs_sram_offset & 0x3;
262 sram = priv->dbgfs_sram_offset & ~0x3;
264 /* read the first u32 from sram */
265 val = iwl_read_targ_mem(bus(priv), sram);
267 for (; len; len--) {
268 /* put the address at the start of every line */
269 if (i == 0)
270 pos += scnprintf(buf + pos, bufsz - pos,
271 "%08X: ", sram + offset);
273 if (device_format)
274 pos += scnprintf(buf + pos, bufsz - pos,
275 "%02x", (val >> (8 * (3 - offset))) & 0xff);
276 else
277 pos += scnprintf(buf + pos, bufsz - pos,
278 "%02x ", (val >> (8 * offset)) & 0xff);
280 /* if all bytes processed, read the next u32 from sram */
281 if (++offset == 4) {
282 sram += 4;
283 offset = 0;
284 val = iwl_read_targ_mem(bus(priv), sram);
287 /* put in extra spaces and split lines for human readability */
288 if (++i == 16) {
289 i = 0;
290 pos += scnprintf(buf + pos, bufsz - pos, "\n");
291 } else if (!(i & 7)) {
292 pos += scnprintf(buf + pos, bufsz - pos, " ");
293 } else if (!(i & 3)) {
294 pos += scnprintf(buf + pos, bufsz - pos, " ");
297 if (i)
298 pos += scnprintf(buf + pos, bufsz - pos, "\n");
300 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
301 kfree(buf);
302 return ret;
305 static ssize_t iwl_dbgfs_sram_write(struct file *file,
306 const char __user *user_buf,
307 size_t count, loff_t *ppos)
309 struct iwl_priv *priv = file->private_data;
310 char buf[64];
311 int buf_size;
312 u32 offset, len;
314 memset(buf, 0, sizeof(buf));
315 buf_size = min(count, sizeof(buf) - 1);
316 if (copy_from_user(buf, user_buf, buf_size))
317 return -EFAULT;
319 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
320 priv->dbgfs_sram_offset = offset;
321 priv->dbgfs_sram_len = len;
322 } else if (sscanf(buf, "%x", &offset) == 1) {
323 priv->dbgfs_sram_offset = offset;
324 priv->dbgfs_sram_len = -4;
325 } else {
326 priv->dbgfs_sram_offset = 0;
327 priv->dbgfs_sram_len = 0;
330 return count;
333 static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
334 char __user *user_buf,
335 size_t count, loff_t *ppos)
337 struct iwl_priv *priv = file->private_data;
339 if (!priv->wowlan_sram)
340 return -ENODATA;
342 return simple_read_from_buffer(user_buf, count, ppos,
343 priv->wowlan_sram,
344 priv->ucode_wowlan.data.len);
346 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
347 size_t count, loff_t *ppos)
349 struct iwl_priv *priv = file->private_data;
350 struct iwl_station_entry *station;
351 struct iwl_tid_data *tid_data;
352 int max_sta = hw_params(priv).max_stations;
353 char *buf;
354 int i, j, pos = 0;
355 ssize_t ret;
356 /* Add 30 for initial string */
357 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
359 buf = kmalloc(bufsz, GFP_KERNEL);
360 if (!buf)
361 return -ENOMEM;
363 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
364 priv->num_stations);
366 for (i = 0; i < max_sta; i++) {
367 station = &priv->stations[i];
368 if (!station->used)
369 continue;
370 pos += scnprintf(buf + pos, bufsz - pos,
371 "station %d - addr: %pM, flags: %#x\n",
372 i, station->sta.sta.addr,
373 station->sta.station_flags_msk);
374 pos += scnprintf(buf + pos, bufsz - pos,
375 "TID\tseq_num\ttxq_id\ttfds\trate_n_flags\n");
377 for (j = 0; j < IWL_MAX_TID_COUNT; j++) {
378 tid_data = &priv->shrd->tid_data[i][j];
379 pos += scnprintf(buf + pos, bufsz - pos,
380 "%d:\t%#x\t%#x\t%u\t%#x",
381 j, tid_data->seq_number,
382 tid_data->agg.txq_id,
383 tid_data->tfds_in_queue,
384 tid_data->agg.rate_n_flags);
386 if (tid_data->agg.wait_for_ba)
387 pos += scnprintf(buf + pos, bufsz - pos,
388 " - waitforba");
389 pos += scnprintf(buf + pos, bufsz - pos, "\n");
392 pos += scnprintf(buf + pos, bufsz - pos, "\n");
395 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
396 kfree(buf);
397 return ret;
400 static ssize_t iwl_dbgfs_nvm_read(struct file *file,
401 char __user *user_buf,
402 size_t count,
403 loff_t *ppos)
405 ssize_t ret;
406 struct iwl_priv *priv = file->private_data;
407 int pos = 0, ofs = 0, buf_size = 0;
408 const u8 *ptr;
409 char *buf;
410 u16 eeprom_ver;
411 size_t eeprom_len = priv->cfg->base_params->eeprom_size;
412 buf_size = 4 * eeprom_len + 256;
414 if (eeprom_len % 16) {
415 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
416 return -ENODATA;
419 ptr = priv->eeprom;
420 if (!ptr) {
421 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
422 return -ENOMEM;
425 /* 4 characters for byte 0xYY */
426 buf = kzalloc(buf_size, GFP_KERNEL);
427 if (!buf) {
428 IWL_ERR(priv, "Can not allocate Buffer\n");
429 return -ENOMEM;
431 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
432 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
433 "version: 0x%x\n",
434 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
435 ? "OTP" : "EEPROM", eeprom_ver);
436 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
437 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
438 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
439 buf_size - pos, 0);
440 pos += strlen(buf + pos);
441 if (buf_size - pos > 0)
442 buf[pos++] = '\n';
445 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
446 kfree(buf);
447 return ret;
450 static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
451 size_t count, loff_t *ppos)
453 struct iwl_priv *priv = file->private_data;
454 struct ieee80211_channel *channels = NULL;
455 const struct ieee80211_supported_band *supp_band = NULL;
456 int pos = 0, i, bufsz = PAGE_SIZE;
457 char *buf;
458 ssize_t ret;
460 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status))
461 return -EAGAIN;
463 buf = kzalloc(bufsz, GFP_KERNEL);
464 if (!buf) {
465 IWL_ERR(priv, "Can not allocate Buffer\n");
466 return -ENOMEM;
469 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
470 if (supp_band) {
471 channels = supp_band->channels;
473 pos += scnprintf(buf + pos, bufsz - pos,
474 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
475 supp_band->n_channels);
477 for (i = 0; i < supp_band->n_channels; i++)
478 pos += scnprintf(buf + pos, bufsz - pos,
479 "%d: %ddBm: BSS%s%s, %s.\n",
480 channels[i].hw_value,
481 channels[i].max_power,
482 channels[i].flags & IEEE80211_CHAN_RADAR ?
483 " (IEEE 802.11h required)" : "",
484 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
485 || (channels[i].flags &
486 IEEE80211_CHAN_RADAR)) ? "" :
487 ", IBSS",
488 channels[i].flags &
489 IEEE80211_CHAN_PASSIVE_SCAN ?
490 "passive only" : "active/passive");
492 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
493 if (supp_band) {
494 channels = supp_band->channels;
496 pos += scnprintf(buf + pos, bufsz - pos,
497 "Displaying %d channels in 5.2GHz band (802.11a)\n",
498 supp_band->n_channels);
500 for (i = 0; i < supp_band->n_channels; i++)
501 pos += scnprintf(buf + pos, bufsz - pos,
502 "%d: %ddBm: BSS%s%s, %s.\n",
503 channels[i].hw_value,
504 channels[i].max_power,
505 channels[i].flags & IEEE80211_CHAN_RADAR ?
506 " (IEEE 802.11h required)" : "",
507 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
508 || (channels[i].flags &
509 IEEE80211_CHAN_RADAR)) ? "" :
510 ", IBSS",
511 channels[i].flags &
512 IEEE80211_CHAN_PASSIVE_SCAN ?
513 "passive only" : "active/passive");
515 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
516 kfree(buf);
517 return ret;
520 static ssize_t iwl_dbgfs_status_read(struct file *file,
521 char __user *user_buf,
522 size_t count, loff_t *ppos) {
524 struct iwl_priv *priv = file->private_data;
525 char buf[512];
526 int pos = 0;
527 const size_t bufsz = sizeof(buf);
529 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
530 test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status));
531 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
532 test_bit(STATUS_INT_ENABLED, &priv->shrd->status));
533 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
534 test_bit(STATUS_RF_KILL_HW, &priv->shrd->status));
535 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
536 test_bit(STATUS_CT_KILL, &priv->shrd->status));
537 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
538 test_bit(STATUS_INIT, &priv->shrd->status));
539 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
540 test_bit(STATUS_ALIVE, &priv->shrd->status));
541 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
542 test_bit(STATUS_READY, &priv->shrd->status));
543 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
544 test_bit(STATUS_TEMPERATURE, &priv->shrd->status));
545 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
546 test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status));
547 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
548 test_bit(STATUS_EXIT_PENDING, &priv->shrd->status));
549 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
550 test_bit(STATUS_STATISTICS, &priv->shrd->status));
551 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
552 test_bit(STATUS_SCANNING, &priv->shrd->status));
553 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
554 test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status));
555 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
556 test_bit(STATUS_SCAN_HW, &priv->shrd->status));
557 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
558 test_bit(STATUS_POWER_PMI, &priv->shrd->status));
559 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
560 test_bit(STATUS_FW_ERROR, &priv->shrd->status));
561 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
564 static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
565 char __user *user_buf,
566 size_t count, loff_t *ppos) {
568 struct iwl_priv *priv = file->private_data;
570 int pos = 0;
571 int cnt = 0;
572 char *buf;
573 int bufsz = 24 * 64; /* 24 items * 64 char per item */
574 ssize_t ret;
576 buf = kzalloc(bufsz, GFP_KERNEL);
577 if (!buf) {
578 IWL_ERR(priv, "Can not allocate Buffer\n");
579 return -ENOMEM;
582 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
583 if (priv->rx_handlers_stats[cnt] > 0)
584 pos += scnprintf(buf + pos, bufsz - pos,
585 "\tRx handler[%36s]:\t\t %u\n",
586 get_cmd_string(cnt),
587 priv->rx_handlers_stats[cnt]);
590 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
591 kfree(buf);
592 return ret;
595 static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
596 const char __user *user_buf,
597 size_t count, loff_t *ppos)
599 struct iwl_priv *priv = file->private_data;
601 char buf[8];
602 int buf_size;
603 u32 reset_flag;
605 memset(buf, 0, sizeof(buf));
606 buf_size = min(count, sizeof(buf) - 1);
607 if (copy_from_user(buf, user_buf, buf_size))
608 return -EFAULT;
609 if (sscanf(buf, "%x", &reset_flag) != 1)
610 return -EFAULT;
611 if (reset_flag == 0)
612 memset(&priv->rx_handlers_stats[0], 0,
613 sizeof(priv->rx_handlers_stats));
615 return count;
618 static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
619 size_t count, loff_t *ppos)
621 struct iwl_priv *priv = file->private_data;
622 struct iwl_rxon_context *ctx;
623 int pos = 0, i;
624 char buf[256 * NUM_IWL_RXON_CTX];
625 const size_t bufsz = sizeof(buf);
627 for_each_context(priv, ctx) {
628 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
629 ctx->ctxid);
630 for (i = 0; i < AC_NUM; i++) {
631 pos += scnprintf(buf + pos, bufsz - pos,
632 "\tcw_min\tcw_max\taifsn\ttxop\n");
633 pos += scnprintf(buf + pos, bufsz - pos,
634 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
635 ctx->qos_data.def_qos_parm.ac[i].cw_min,
636 ctx->qos_data.def_qos_parm.ac[i].cw_max,
637 ctx->qos_data.def_qos_parm.ac[i].aifsn,
638 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
640 pos += scnprintf(buf + pos, bufsz - pos, "\n");
642 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
645 static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
646 char __user *user_buf,
647 size_t count, loff_t *ppos)
649 struct iwl_priv *priv = file->private_data;
650 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
651 struct iwl_tt_restriction *restriction;
652 char buf[100];
653 int pos = 0;
654 const size_t bufsz = sizeof(buf);
656 pos += scnprintf(buf + pos, bufsz - pos,
657 "Thermal Throttling Mode: %s\n",
658 tt->advanced_tt ? "Advance" : "Legacy");
659 pos += scnprintf(buf + pos, bufsz - pos,
660 "Thermal Throttling State: %d\n",
661 tt->state);
662 if (tt->advanced_tt) {
663 restriction = tt->restriction + tt->state;
664 pos += scnprintf(buf + pos, bufsz - pos,
665 "Tx mode: %d\n",
666 restriction->tx_stream);
667 pos += scnprintf(buf + pos, bufsz - pos,
668 "Rx mode: %d\n",
669 restriction->rx_stream);
670 pos += scnprintf(buf + pos, bufsz - pos,
671 "HT mode: %d\n",
672 restriction->is_ht);
674 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
677 static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
678 const char __user *user_buf,
679 size_t count, loff_t *ppos)
681 struct iwl_priv *priv = file->private_data;
682 char buf[8];
683 int buf_size;
684 int ht40;
686 memset(buf, 0, sizeof(buf));
687 buf_size = min(count, sizeof(buf) - 1);
688 if (copy_from_user(buf, user_buf, buf_size))
689 return -EFAULT;
690 if (sscanf(buf, "%d", &ht40) != 1)
691 return -EFAULT;
692 if (!iwl_is_any_associated(priv))
693 priv->disable_ht40 = ht40 ? true : false;
694 else {
695 IWL_ERR(priv, "Sta associated with AP - "
696 "Change to 40MHz channel support is not allowed\n");
697 return -EINVAL;
700 return count;
703 static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
704 char __user *user_buf,
705 size_t count, loff_t *ppos)
707 struct iwl_priv *priv = file->private_data;
708 char buf[100];
709 int pos = 0;
710 const size_t bufsz = sizeof(buf);
712 pos += scnprintf(buf + pos, bufsz - pos,
713 "11n 40MHz Mode: %s\n",
714 priv->disable_ht40 ? "Disabled" : "Enabled");
715 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
718 static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
719 const char __user *user_buf,
720 size_t count, loff_t *ppos)
722 struct iwl_priv *priv = file->private_data;
723 char buf[8];
724 int buf_size;
725 int value;
727 memset(buf, 0, sizeof(buf));
728 buf_size = min(count, sizeof(buf) - 1);
729 if (copy_from_user(buf, user_buf, buf_size))
730 return -EFAULT;
732 if (sscanf(buf, "%d", &value) != 1)
733 return -EINVAL;
736 * Our users expect 0 to be "CAM", but 0 isn't actually
737 * valid here. However, let's not confuse them and present
738 * IWL_POWER_INDEX_1 as "1", not "0".
740 if (value == 0)
741 return -EINVAL;
742 else if (value > 0)
743 value -= 1;
745 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
746 return -EINVAL;
748 if (!iwl_is_ready_rf(priv->shrd))
749 return -EAGAIN;
751 priv->power_data.debug_sleep_level_override = value;
753 mutex_lock(&priv->shrd->mutex);
754 iwl_power_update_mode(priv, true);
755 mutex_unlock(&priv->shrd->mutex);
757 return count;
760 static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
761 char __user *user_buf,
762 size_t count, loff_t *ppos)
764 struct iwl_priv *priv = file->private_data;
765 char buf[10];
766 int pos, value;
767 const size_t bufsz = sizeof(buf);
769 /* see the write function */
770 value = priv->power_data.debug_sleep_level_override;
771 if (value >= 0)
772 value += 1;
774 pos = scnprintf(buf, bufsz, "%d\n", value);
775 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
778 static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
779 char __user *user_buf,
780 size_t count, loff_t *ppos)
782 struct iwl_priv *priv = file->private_data;
783 char buf[200];
784 int pos = 0, i;
785 const size_t bufsz = sizeof(buf);
786 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
788 pos += scnprintf(buf + pos, bufsz - pos,
789 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
790 pos += scnprintf(buf + pos, bufsz - pos,
791 "RX/TX timeout: %d/%d usec\n",
792 le32_to_cpu(cmd->rx_data_timeout),
793 le32_to_cpu(cmd->tx_data_timeout));
794 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
795 pos += scnprintf(buf + pos, bufsz - pos,
796 "sleep_interval[%d]: %d\n", i,
797 le32_to_cpu(cmd->sleep_interval[i]));
799 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
802 DEBUGFS_READ_WRITE_FILE_OPS(sram);
803 DEBUGFS_READ_FILE_OPS(wowlan_sram);
804 DEBUGFS_READ_FILE_OPS(nvm);
805 DEBUGFS_READ_FILE_OPS(stations);
806 DEBUGFS_READ_FILE_OPS(channels);
807 DEBUGFS_READ_FILE_OPS(status);
808 DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
809 DEBUGFS_READ_FILE_OPS(qos);
810 DEBUGFS_READ_FILE_OPS(thermal_throttling);
811 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
812 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
813 DEBUGFS_READ_FILE_OPS(current_sleep_command);
815 static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
816 char __user *user_buf,
817 size_t count, loff_t *ppos)
819 struct iwl_priv *priv = file->private_data;
820 int pos = 0, ofs = 0;
821 int cnt = 0, entry;
823 char *buf;
824 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
825 (hw_params(priv).max_txq_num * 32 * 8) + 400;
826 const u8 *ptr;
827 ssize_t ret;
829 buf = kzalloc(bufsz, GFP_KERNEL);
830 if (!buf) {
831 IWL_ERR(priv, "Can not allocate buffer\n");
832 return -ENOMEM;
834 if (priv->tx_traffic &&
835 (iwl_get_debug_level(priv->shrd) & IWL_DL_TX)) {
836 ptr = priv->tx_traffic;
837 pos += scnprintf(buf + pos, bufsz - pos,
838 "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
839 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
840 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
841 entry++, ofs += 16) {
842 pos += scnprintf(buf + pos, bufsz - pos,
843 "0x%.4x ", ofs);
844 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
845 buf + pos, bufsz - pos, 0);
846 pos += strlen(buf + pos);
847 if (bufsz - pos > 0)
848 buf[pos++] = '\n';
853 if (priv->rx_traffic &&
854 (iwl_get_debug_level(priv->shrd) & IWL_DL_RX)) {
855 ptr = priv->rx_traffic;
856 pos += scnprintf(buf + pos, bufsz - pos,
857 "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
858 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
859 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
860 entry++, ofs += 16) {
861 pos += scnprintf(buf + pos, bufsz - pos,
862 "0x%.4x ", ofs);
863 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
864 buf + pos, bufsz - pos, 0);
865 pos += strlen(buf + pos);
866 if (bufsz - pos > 0)
867 buf[pos++] = '\n';
872 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
873 kfree(buf);
874 return ret;
877 static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
878 const char __user *user_buf,
879 size_t count, loff_t *ppos)
881 struct iwl_priv *priv = file->private_data;
882 char buf[8];
883 int buf_size;
884 int traffic_log;
886 memset(buf, 0, sizeof(buf));
887 buf_size = min(count, sizeof(buf) - 1);
888 if (copy_from_user(buf, user_buf, buf_size))
889 return -EFAULT;
890 if (sscanf(buf, "%d", &traffic_log) != 1)
891 return -EFAULT;
892 if (traffic_log == 0)
893 iwl_reset_traffic_log(priv);
895 return count;
898 static const char *fmt_value = " %-30s %10u\n";
899 static const char *fmt_hex = " %-30s 0x%02X\n";
900 static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
901 static const char *fmt_header =
902 "%-32s current cumulative delta max\n";
904 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
906 int p = 0;
907 u32 flag;
909 flag = le32_to_cpu(priv->statistics.flag);
911 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
912 if (flag & UCODE_STATISTICS_CLEAR_MSK)
913 p += scnprintf(buf + p, bufsz - p,
914 "\tStatistics have been cleared\n");
915 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
916 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
917 ? "2.4 GHz" : "5.2 GHz");
918 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
919 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
920 ? "enabled" : "disabled");
922 return p;
925 static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
926 char __user *user_buf,
927 size_t count, loff_t *ppos)
929 struct iwl_priv *priv = file->private_data;
930 int pos = 0;
931 char *buf;
932 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
933 sizeof(struct statistics_rx_non_phy) * 40 +
934 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
935 ssize_t ret;
936 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
937 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
938 struct statistics_rx_non_phy *general, *accum_general;
939 struct statistics_rx_non_phy *delta_general, *max_general;
940 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
942 if (!iwl_is_alive(priv->shrd))
943 return -EAGAIN;
945 buf = kzalloc(bufsz, GFP_KERNEL);
946 if (!buf) {
947 IWL_ERR(priv, "Can not allocate Buffer\n");
948 return -ENOMEM;
952 * the statistic information display here is based on
953 * the last statistics notification from uCode
954 * might not reflect the current uCode activity
956 ofdm = &priv->statistics.rx_ofdm;
957 cck = &priv->statistics.rx_cck;
958 general = &priv->statistics.rx_non_phy;
959 ht = &priv->statistics.rx_ofdm_ht;
960 accum_ofdm = &priv->accum_stats.rx_ofdm;
961 accum_cck = &priv->accum_stats.rx_cck;
962 accum_general = &priv->accum_stats.rx_non_phy;
963 accum_ht = &priv->accum_stats.rx_ofdm_ht;
964 delta_ofdm = &priv->delta_stats.rx_ofdm;
965 delta_cck = &priv->delta_stats.rx_cck;
966 delta_general = &priv->delta_stats.rx_non_phy;
967 delta_ht = &priv->delta_stats.rx_ofdm_ht;
968 max_ofdm = &priv->max_delta_stats.rx_ofdm;
969 max_cck = &priv->max_delta_stats.rx_cck;
970 max_general = &priv->max_delta_stats.rx_non_phy;
971 max_ht = &priv->max_delta_stats.rx_ofdm_ht;
973 pos += iwl_statistics_flag(priv, buf, bufsz);
974 pos += scnprintf(buf + pos, bufsz - pos,
975 fmt_header, "Statistics_Rx - OFDM:");
976 pos += scnprintf(buf + pos, bufsz - pos,
977 fmt_table, "ina_cnt:",
978 le32_to_cpu(ofdm->ina_cnt),
979 accum_ofdm->ina_cnt,
980 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
981 pos += scnprintf(buf + pos, bufsz - pos,
982 fmt_table, "fina_cnt:",
983 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
984 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
985 pos += scnprintf(buf + pos, bufsz - pos,
986 fmt_table, "plcp_err:",
987 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
988 delta_ofdm->plcp_err, max_ofdm->plcp_err);
989 pos += scnprintf(buf + pos, bufsz - pos,
990 fmt_table, "crc32_err:",
991 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
992 delta_ofdm->crc32_err, max_ofdm->crc32_err);
993 pos += scnprintf(buf + pos, bufsz - pos,
994 fmt_table, "overrun_err:",
995 le32_to_cpu(ofdm->overrun_err),
996 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
997 max_ofdm->overrun_err);
998 pos += scnprintf(buf + pos, bufsz - pos,
999 fmt_table, "early_overrun_err:",
1000 le32_to_cpu(ofdm->early_overrun_err),
1001 accum_ofdm->early_overrun_err,
1002 delta_ofdm->early_overrun_err,
1003 max_ofdm->early_overrun_err);
1004 pos += scnprintf(buf + pos, bufsz - pos,
1005 fmt_table, "crc32_good:",
1006 le32_to_cpu(ofdm->crc32_good),
1007 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
1008 max_ofdm->crc32_good);
1009 pos += scnprintf(buf + pos, bufsz - pos,
1010 fmt_table, "false_alarm_cnt:",
1011 le32_to_cpu(ofdm->false_alarm_cnt),
1012 accum_ofdm->false_alarm_cnt,
1013 delta_ofdm->false_alarm_cnt,
1014 max_ofdm->false_alarm_cnt);
1015 pos += scnprintf(buf + pos, bufsz - pos,
1016 fmt_table, "fina_sync_err_cnt:",
1017 le32_to_cpu(ofdm->fina_sync_err_cnt),
1018 accum_ofdm->fina_sync_err_cnt,
1019 delta_ofdm->fina_sync_err_cnt,
1020 max_ofdm->fina_sync_err_cnt);
1021 pos += scnprintf(buf + pos, bufsz - pos,
1022 fmt_table, "sfd_timeout:",
1023 le32_to_cpu(ofdm->sfd_timeout),
1024 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
1025 max_ofdm->sfd_timeout);
1026 pos += scnprintf(buf + pos, bufsz - pos,
1027 fmt_table, "fina_timeout:",
1028 le32_to_cpu(ofdm->fina_timeout),
1029 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
1030 max_ofdm->fina_timeout);
1031 pos += scnprintf(buf + pos, bufsz - pos,
1032 fmt_table, "unresponded_rts:",
1033 le32_to_cpu(ofdm->unresponded_rts),
1034 accum_ofdm->unresponded_rts,
1035 delta_ofdm->unresponded_rts,
1036 max_ofdm->unresponded_rts);
1037 pos += scnprintf(buf + pos, bufsz - pos,
1038 fmt_table, "rxe_frame_lmt_ovrun:",
1039 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
1040 accum_ofdm->rxe_frame_limit_overrun,
1041 delta_ofdm->rxe_frame_limit_overrun,
1042 max_ofdm->rxe_frame_limit_overrun);
1043 pos += scnprintf(buf + pos, bufsz - pos,
1044 fmt_table, "sent_ack_cnt:",
1045 le32_to_cpu(ofdm->sent_ack_cnt),
1046 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
1047 max_ofdm->sent_ack_cnt);
1048 pos += scnprintf(buf + pos, bufsz - pos,
1049 fmt_table, "sent_cts_cnt:",
1050 le32_to_cpu(ofdm->sent_cts_cnt),
1051 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
1052 max_ofdm->sent_cts_cnt);
1053 pos += scnprintf(buf + pos, bufsz - pos,
1054 fmt_table, "sent_ba_rsp_cnt:",
1055 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
1056 accum_ofdm->sent_ba_rsp_cnt,
1057 delta_ofdm->sent_ba_rsp_cnt,
1058 max_ofdm->sent_ba_rsp_cnt);
1059 pos += scnprintf(buf + pos, bufsz - pos,
1060 fmt_table, "dsp_self_kill:",
1061 le32_to_cpu(ofdm->dsp_self_kill),
1062 accum_ofdm->dsp_self_kill,
1063 delta_ofdm->dsp_self_kill,
1064 max_ofdm->dsp_self_kill);
1065 pos += scnprintf(buf + pos, bufsz - pos,
1066 fmt_table, "mh_format_err:",
1067 le32_to_cpu(ofdm->mh_format_err),
1068 accum_ofdm->mh_format_err,
1069 delta_ofdm->mh_format_err,
1070 max_ofdm->mh_format_err);
1071 pos += scnprintf(buf + pos, bufsz - pos,
1072 fmt_table, "re_acq_main_rssi_sum:",
1073 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
1074 accum_ofdm->re_acq_main_rssi_sum,
1075 delta_ofdm->re_acq_main_rssi_sum,
1076 max_ofdm->re_acq_main_rssi_sum);
1078 pos += scnprintf(buf + pos, bufsz - pos,
1079 fmt_header, "Statistics_Rx - CCK:");
1080 pos += scnprintf(buf + pos, bufsz - pos,
1081 fmt_table, "ina_cnt:",
1082 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
1083 delta_cck->ina_cnt, max_cck->ina_cnt);
1084 pos += scnprintf(buf + pos, bufsz - pos,
1085 fmt_table, "fina_cnt:",
1086 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
1087 delta_cck->fina_cnt, max_cck->fina_cnt);
1088 pos += scnprintf(buf + pos, bufsz - pos,
1089 fmt_table, "plcp_err:",
1090 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1091 delta_cck->plcp_err, max_cck->plcp_err);
1092 pos += scnprintf(buf + pos, bufsz - pos,
1093 fmt_table, "crc32_err:",
1094 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1095 delta_cck->crc32_err, max_cck->crc32_err);
1096 pos += scnprintf(buf + pos, bufsz - pos,
1097 fmt_table, "overrun_err:",
1098 le32_to_cpu(cck->overrun_err),
1099 accum_cck->overrun_err, delta_cck->overrun_err,
1100 max_cck->overrun_err);
1101 pos += scnprintf(buf + pos, bufsz - pos,
1102 fmt_table, "early_overrun_err:",
1103 le32_to_cpu(cck->early_overrun_err),
1104 accum_cck->early_overrun_err,
1105 delta_cck->early_overrun_err,
1106 max_cck->early_overrun_err);
1107 pos += scnprintf(buf + pos, bufsz - pos,
1108 fmt_table, "crc32_good:",
1109 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1110 delta_cck->crc32_good, max_cck->crc32_good);
1111 pos += scnprintf(buf + pos, bufsz - pos,
1112 fmt_table, "false_alarm_cnt:",
1113 le32_to_cpu(cck->false_alarm_cnt),
1114 accum_cck->false_alarm_cnt,
1115 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1116 pos += scnprintf(buf + pos, bufsz - pos,
1117 fmt_table, "fina_sync_err_cnt:",
1118 le32_to_cpu(cck->fina_sync_err_cnt),
1119 accum_cck->fina_sync_err_cnt,
1120 delta_cck->fina_sync_err_cnt,
1121 max_cck->fina_sync_err_cnt);
1122 pos += scnprintf(buf + pos, bufsz - pos,
1123 fmt_table, "sfd_timeout:",
1124 le32_to_cpu(cck->sfd_timeout),
1125 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
1126 max_cck->sfd_timeout);
1127 pos += scnprintf(buf + pos, bufsz - pos,
1128 fmt_table, "fina_timeout:",
1129 le32_to_cpu(cck->fina_timeout),
1130 accum_cck->fina_timeout, delta_cck->fina_timeout,
1131 max_cck->fina_timeout);
1132 pos += scnprintf(buf + pos, bufsz - pos,
1133 fmt_table, "unresponded_rts:",
1134 le32_to_cpu(cck->unresponded_rts),
1135 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
1136 max_cck->unresponded_rts);
1137 pos += scnprintf(buf + pos, bufsz - pos,
1138 fmt_table, "rxe_frame_lmt_ovrun:",
1139 le32_to_cpu(cck->rxe_frame_limit_overrun),
1140 accum_cck->rxe_frame_limit_overrun,
1141 delta_cck->rxe_frame_limit_overrun,
1142 max_cck->rxe_frame_limit_overrun);
1143 pos += scnprintf(buf + pos, bufsz - pos,
1144 fmt_table, "sent_ack_cnt:",
1145 le32_to_cpu(cck->sent_ack_cnt),
1146 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
1147 max_cck->sent_ack_cnt);
1148 pos += scnprintf(buf + pos, bufsz - pos,
1149 fmt_table, "sent_cts_cnt:",
1150 le32_to_cpu(cck->sent_cts_cnt),
1151 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
1152 max_cck->sent_cts_cnt);
1153 pos += scnprintf(buf + pos, bufsz - pos,
1154 fmt_table, "sent_ba_rsp_cnt:",
1155 le32_to_cpu(cck->sent_ba_rsp_cnt),
1156 accum_cck->sent_ba_rsp_cnt,
1157 delta_cck->sent_ba_rsp_cnt,
1158 max_cck->sent_ba_rsp_cnt);
1159 pos += scnprintf(buf + pos, bufsz - pos,
1160 fmt_table, "dsp_self_kill:",
1161 le32_to_cpu(cck->dsp_self_kill),
1162 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
1163 max_cck->dsp_self_kill);
1164 pos += scnprintf(buf + pos, bufsz - pos,
1165 fmt_table, "mh_format_err:",
1166 le32_to_cpu(cck->mh_format_err),
1167 accum_cck->mh_format_err, delta_cck->mh_format_err,
1168 max_cck->mh_format_err);
1169 pos += scnprintf(buf + pos, bufsz - pos,
1170 fmt_table, "re_acq_main_rssi_sum:",
1171 le32_to_cpu(cck->re_acq_main_rssi_sum),
1172 accum_cck->re_acq_main_rssi_sum,
1173 delta_cck->re_acq_main_rssi_sum,
1174 max_cck->re_acq_main_rssi_sum);
1176 pos += scnprintf(buf + pos, bufsz - pos,
1177 fmt_header, "Statistics_Rx - GENERAL:");
1178 pos += scnprintf(buf + pos, bufsz - pos,
1179 fmt_table, "bogus_cts:",
1180 le32_to_cpu(general->bogus_cts),
1181 accum_general->bogus_cts, delta_general->bogus_cts,
1182 max_general->bogus_cts);
1183 pos += scnprintf(buf + pos, bufsz - pos,
1184 fmt_table, "bogus_ack:",
1185 le32_to_cpu(general->bogus_ack),
1186 accum_general->bogus_ack, delta_general->bogus_ack,
1187 max_general->bogus_ack);
1188 pos += scnprintf(buf + pos, bufsz - pos,
1189 fmt_table, "non_bssid_frames:",
1190 le32_to_cpu(general->non_bssid_frames),
1191 accum_general->non_bssid_frames,
1192 delta_general->non_bssid_frames,
1193 max_general->non_bssid_frames);
1194 pos += scnprintf(buf + pos, bufsz - pos,
1195 fmt_table, "filtered_frames:",
1196 le32_to_cpu(general->filtered_frames),
1197 accum_general->filtered_frames,
1198 delta_general->filtered_frames,
1199 max_general->filtered_frames);
1200 pos += scnprintf(buf + pos, bufsz - pos,
1201 fmt_table, "non_channel_beacons:",
1202 le32_to_cpu(general->non_channel_beacons),
1203 accum_general->non_channel_beacons,
1204 delta_general->non_channel_beacons,
1205 max_general->non_channel_beacons);
1206 pos += scnprintf(buf + pos, bufsz - pos,
1207 fmt_table, "channel_beacons:",
1208 le32_to_cpu(general->channel_beacons),
1209 accum_general->channel_beacons,
1210 delta_general->channel_beacons,
1211 max_general->channel_beacons);
1212 pos += scnprintf(buf + pos, bufsz - pos,
1213 fmt_table, "num_missed_bcon:",
1214 le32_to_cpu(general->num_missed_bcon),
1215 accum_general->num_missed_bcon,
1216 delta_general->num_missed_bcon,
1217 max_general->num_missed_bcon);
1218 pos += scnprintf(buf + pos, bufsz - pos,
1219 fmt_table, "adc_rx_saturation_time:",
1220 le32_to_cpu(general->adc_rx_saturation_time),
1221 accum_general->adc_rx_saturation_time,
1222 delta_general->adc_rx_saturation_time,
1223 max_general->adc_rx_saturation_time);
1224 pos += scnprintf(buf + pos, bufsz - pos,
1225 fmt_table, "ina_detect_search_tm:",
1226 le32_to_cpu(general->ina_detection_search_time),
1227 accum_general->ina_detection_search_time,
1228 delta_general->ina_detection_search_time,
1229 max_general->ina_detection_search_time);
1230 pos += scnprintf(buf + pos, bufsz - pos,
1231 fmt_table, "beacon_silence_rssi_a:",
1232 le32_to_cpu(general->beacon_silence_rssi_a),
1233 accum_general->beacon_silence_rssi_a,
1234 delta_general->beacon_silence_rssi_a,
1235 max_general->beacon_silence_rssi_a);
1236 pos += scnprintf(buf + pos, bufsz - pos,
1237 fmt_table, "beacon_silence_rssi_b:",
1238 le32_to_cpu(general->beacon_silence_rssi_b),
1239 accum_general->beacon_silence_rssi_b,
1240 delta_general->beacon_silence_rssi_b,
1241 max_general->beacon_silence_rssi_b);
1242 pos += scnprintf(buf + pos, bufsz - pos,
1243 fmt_table, "beacon_silence_rssi_c:",
1244 le32_to_cpu(general->beacon_silence_rssi_c),
1245 accum_general->beacon_silence_rssi_c,
1246 delta_general->beacon_silence_rssi_c,
1247 max_general->beacon_silence_rssi_c);
1248 pos += scnprintf(buf + pos, bufsz - pos,
1249 fmt_table, "interference_data_flag:",
1250 le32_to_cpu(general->interference_data_flag),
1251 accum_general->interference_data_flag,
1252 delta_general->interference_data_flag,
1253 max_general->interference_data_flag);
1254 pos += scnprintf(buf + pos, bufsz - pos,
1255 fmt_table, "channel_load:",
1256 le32_to_cpu(general->channel_load),
1257 accum_general->channel_load,
1258 delta_general->channel_load,
1259 max_general->channel_load);
1260 pos += scnprintf(buf + pos, bufsz - pos,
1261 fmt_table, "dsp_false_alarms:",
1262 le32_to_cpu(general->dsp_false_alarms),
1263 accum_general->dsp_false_alarms,
1264 delta_general->dsp_false_alarms,
1265 max_general->dsp_false_alarms);
1266 pos += scnprintf(buf + pos, bufsz - pos,
1267 fmt_table, "beacon_rssi_a:",
1268 le32_to_cpu(general->beacon_rssi_a),
1269 accum_general->beacon_rssi_a,
1270 delta_general->beacon_rssi_a,
1271 max_general->beacon_rssi_a);
1272 pos += scnprintf(buf + pos, bufsz - pos,
1273 fmt_table, "beacon_rssi_b:",
1274 le32_to_cpu(general->beacon_rssi_b),
1275 accum_general->beacon_rssi_b,
1276 delta_general->beacon_rssi_b,
1277 max_general->beacon_rssi_b);
1278 pos += scnprintf(buf + pos, bufsz - pos,
1279 fmt_table, "beacon_rssi_c:",
1280 le32_to_cpu(general->beacon_rssi_c),
1281 accum_general->beacon_rssi_c,
1282 delta_general->beacon_rssi_c,
1283 max_general->beacon_rssi_c);
1284 pos += scnprintf(buf + pos, bufsz - pos,
1285 fmt_table, "beacon_energy_a:",
1286 le32_to_cpu(general->beacon_energy_a),
1287 accum_general->beacon_energy_a,
1288 delta_general->beacon_energy_a,
1289 max_general->beacon_energy_a);
1290 pos += scnprintf(buf + pos, bufsz - pos,
1291 fmt_table, "beacon_energy_b:",
1292 le32_to_cpu(general->beacon_energy_b),
1293 accum_general->beacon_energy_b,
1294 delta_general->beacon_energy_b,
1295 max_general->beacon_energy_b);
1296 pos += scnprintf(buf + pos, bufsz - pos,
1297 fmt_table, "beacon_energy_c:",
1298 le32_to_cpu(general->beacon_energy_c),
1299 accum_general->beacon_energy_c,
1300 delta_general->beacon_energy_c,
1301 max_general->beacon_energy_c);
1303 pos += scnprintf(buf + pos, bufsz - pos,
1304 fmt_header, "Statistics_Rx - OFDM_HT:");
1305 pos += scnprintf(buf + pos, bufsz - pos,
1306 fmt_table, "plcp_err:",
1307 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1308 delta_ht->plcp_err, max_ht->plcp_err);
1309 pos += scnprintf(buf + pos, bufsz - pos,
1310 fmt_table, "overrun_err:",
1311 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1312 delta_ht->overrun_err, max_ht->overrun_err);
1313 pos += scnprintf(buf + pos, bufsz - pos,
1314 fmt_table, "early_overrun_err:",
1315 le32_to_cpu(ht->early_overrun_err),
1316 accum_ht->early_overrun_err,
1317 delta_ht->early_overrun_err,
1318 max_ht->early_overrun_err);
1319 pos += scnprintf(buf + pos, bufsz - pos,
1320 fmt_table, "crc32_good:",
1321 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1322 delta_ht->crc32_good, max_ht->crc32_good);
1323 pos += scnprintf(buf + pos, bufsz - pos,
1324 fmt_table, "crc32_err:",
1325 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1326 delta_ht->crc32_err, max_ht->crc32_err);
1327 pos += scnprintf(buf + pos, bufsz - pos,
1328 fmt_table, "mh_format_err:",
1329 le32_to_cpu(ht->mh_format_err),
1330 accum_ht->mh_format_err,
1331 delta_ht->mh_format_err, max_ht->mh_format_err);
1332 pos += scnprintf(buf + pos, bufsz - pos,
1333 fmt_table, "agg_crc32_good:",
1334 le32_to_cpu(ht->agg_crc32_good),
1335 accum_ht->agg_crc32_good,
1336 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1337 pos += scnprintf(buf + pos, bufsz - pos,
1338 fmt_table, "agg_mpdu_cnt:",
1339 le32_to_cpu(ht->agg_mpdu_cnt),
1340 accum_ht->agg_mpdu_cnt,
1341 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1342 pos += scnprintf(buf + pos, bufsz - pos,
1343 fmt_table, "agg_cnt:",
1344 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1345 delta_ht->agg_cnt, max_ht->agg_cnt);
1346 pos += scnprintf(buf + pos, bufsz - pos,
1347 fmt_table, "unsupport_mcs:",
1348 le32_to_cpu(ht->unsupport_mcs),
1349 accum_ht->unsupport_mcs,
1350 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1352 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1353 kfree(buf);
1354 return ret;
1357 static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1358 char __user *user_buf,
1359 size_t count, loff_t *ppos)
1361 struct iwl_priv *priv = file->private_data;
1362 int pos = 0;
1363 char *buf;
1364 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1365 ssize_t ret;
1366 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1368 if (!iwl_is_alive(priv->shrd))
1369 return -EAGAIN;
1371 buf = kzalloc(bufsz, GFP_KERNEL);
1372 if (!buf) {
1373 IWL_ERR(priv, "Can not allocate Buffer\n");
1374 return -ENOMEM;
1377 /* the statistic information display here is based on
1378 * the last statistics notification from uCode
1379 * might not reflect the current uCode activity
1381 tx = &priv->statistics.tx;
1382 accum_tx = &priv->accum_stats.tx;
1383 delta_tx = &priv->delta_stats.tx;
1384 max_tx = &priv->max_delta_stats.tx;
1386 pos += iwl_statistics_flag(priv, buf, bufsz);
1387 pos += scnprintf(buf + pos, bufsz - pos,
1388 fmt_header, "Statistics_Tx:");
1389 pos += scnprintf(buf + pos, bufsz - pos,
1390 fmt_table, "preamble:",
1391 le32_to_cpu(tx->preamble_cnt),
1392 accum_tx->preamble_cnt,
1393 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1394 pos += scnprintf(buf + pos, bufsz - pos,
1395 fmt_table, "rx_detected_cnt:",
1396 le32_to_cpu(tx->rx_detected_cnt),
1397 accum_tx->rx_detected_cnt,
1398 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1399 pos += scnprintf(buf + pos, bufsz - pos,
1400 fmt_table, "bt_prio_defer_cnt:",
1401 le32_to_cpu(tx->bt_prio_defer_cnt),
1402 accum_tx->bt_prio_defer_cnt,
1403 delta_tx->bt_prio_defer_cnt,
1404 max_tx->bt_prio_defer_cnt);
1405 pos += scnprintf(buf + pos, bufsz - pos,
1406 fmt_table, "bt_prio_kill_cnt:",
1407 le32_to_cpu(tx->bt_prio_kill_cnt),
1408 accum_tx->bt_prio_kill_cnt,
1409 delta_tx->bt_prio_kill_cnt,
1410 max_tx->bt_prio_kill_cnt);
1411 pos += scnprintf(buf + pos, bufsz - pos,
1412 fmt_table, "few_bytes_cnt:",
1413 le32_to_cpu(tx->few_bytes_cnt),
1414 accum_tx->few_bytes_cnt,
1415 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1416 pos += scnprintf(buf + pos, bufsz - pos,
1417 fmt_table, "cts_timeout:",
1418 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1419 delta_tx->cts_timeout, max_tx->cts_timeout);
1420 pos += scnprintf(buf + pos, bufsz - pos,
1421 fmt_table, "ack_timeout:",
1422 le32_to_cpu(tx->ack_timeout),
1423 accum_tx->ack_timeout,
1424 delta_tx->ack_timeout, max_tx->ack_timeout);
1425 pos += scnprintf(buf + pos, bufsz - pos,
1426 fmt_table, "expected_ack_cnt:",
1427 le32_to_cpu(tx->expected_ack_cnt),
1428 accum_tx->expected_ack_cnt,
1429 delta_tx->expected_ack_cnt,
1430 max_tx->expected_ack_cnt);
1431 pos += scnprintf(buf + pos, bufsz - pos,
1432 fmt_table, "actual_ack_cnt:",
1433 le32_to_cpu(tx->actual_ack_cnt),
1434 accum_tx->actual_ack_cnt,
1435 delta_tx->actual_ack_cnt,
1436 max_tx->actual_ack_cnt);
1437 pos += scnprintf(buf + pos, bufsz - pos,
1438 fmt_table, "dump_msdu_cnt:",
1439 le32_to_cpu(tx->dump_msdu_cnt),
1440 accum_tx->dump_msdu_cnt,
1441 delta_tx->dump_msdu_cnt,
1442 max_tx->dump_msdu_cnt);
1443 pos += scnprintf(buf + pos, bufsz - pos,
1444 fmt_table, "abort_nxt_frame_mismatch:",
1445 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1446 accum_tx->burst_abort_next_frame_mismatch_cnt,
1447 delta_tx->burst_abort_next_frame_mismatch_cnt,
1448 max_tx->burst_abort_next_frame_mismatch_cnt);
1449 pos += scnprintf(buf + pos, bufsz - pos,
1450 fmt_table, "abort_missing_nxt_frame:",
1451 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1452 accum_tx->burst_abort_missing_next_frame_cnt,
1453 delta_tx->burst_abort_missing_next_frame_cnt,
1454 max_tx->burst_abort_missing_next_frame_cnt);
1455 pos += scnprintf(buf + pos, bufsz - pos,
1456 fmt_table, "cts_timeout_collision:",
1457 le32_to_cpu(tx->cts_timeout_collision),
1458 accum_tx->cts_timeout_collision,
1459 delta_tx->cts_timeout_collision,
1460 max_tx->cts_timeout_collision);
1461 pos += scnprintf(buf + pos, bufsz - pos,
1462 fmt_table, "ack_ba_timeout_collision:",
1463 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1464 accum_tx->ack_or_ba_timeout_collision,
1465 delta_tx->ack_or_ba_timeout_collision,
1466 max_tx->ack_or_ba_timeout_collision);
1467 pos += scnprintf(buf + pos, bufsz - pos,
1468 fmt_table, "agg ba_timeout:",
1469 le32_to_cpu(tx->agg.ba_timeout),
1470 accum_tx->agg.ba_timeout,
1471 delta_tx->agg.ba_timeout,
1472 max_tx->agg.ba_timeout);
1473 pos += scnprintf(buf + pos, bufsz - pos,
1474 fmt_table, "agg ba_resched_frames:",
1475 le32_to_cpu(tx->agg.ba_reschedule_frames),
1476 accum_tx->agg.ba_reschedule_frames,
1477 delta_tx->agg.ba_reschedule_frames,
1478 max_tx->agg.ba_reschedule_frames);
1479 pos += scnprintf(buf + pos, bufsz - pos,
1480 fmt_table, "agg scd_query_agg_frame:",
1481 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1482 accum_tx->agg.scd_query_agg_frame_cnt,
1483 delta_tx->agg.scd_query_agg_frame_cnt,
1484 max_tx->agg.scd_query_agg_frame_cnt);
1485 pos += scnprintf(buf + pos, bufsz - pos,
1486 fmt_table, "agg scd_query_no_agg:",
1487 le32_to_cpu(tx->agg.scd_query_no_agg),
1488 accum_tx->agg.scd_query_no_agg,
1489 delta_tx->agg.scd_query_no_agg,
1490 max_tx->agg.scd_query_no_agg);
1491 pos += scnprintf(buf + pos, bufsz - pos,
1492 fmt_table, "agg scd_query_agg:",
1493 le32_to_cpu(tx->agg.scd_query_agg),
1494 accum_tx->agg.scd_query_agg,
1495 delta_tx->agg.scd_query_agg,
1496 max_tx->agg.scd_query_agg);
1497 pos += scnprintf(buf + pos, bufsz - pos,
1498 fmt_table, "agg scd_query_mismatch:",
1499 le32_to_cpu(tx->agg.scd_query_mismatch),
1500 accum_tx->agg.scd_query_mismatch,
1501 delta_tx->agg.scd_query_mismatch,
1502 max_tx->agg.scd_query_mismatch);
1503 pos += scnprintf(buf + pos, bufsz - pos,
1504 fmt_table, "agg frame_not_ready:",
1505 le32_to_cpu(tx->agg.frame_not_ready),
1506 accum_tx->agg.frame_not_ready,
1507 delta_tx->agg.frame_not_ready,
1508 max_tx->agg.frame_not_ready);
1509 pos += scnprintf(buf + pos, bufsz - pos,
1510 fmt_table, "agg underrun:",
1511 le32_to_cpu(tx->agg.underrun),
1512 accum_tx->agg.underrun,
1513 delta_tx->agg.underrun, max_tx->agg.underrun);
1514 pos += scnprintf(buf + pos, bufsz - pos,
1515 fmt_table, "agg bt_prio_kill:",
1516 le32_to_cpu(tx->agg.bt_prio_kill),
1517 accum_tx->agg.bt_prio_kill,
1518 delta_tx->agg.bt_prio_kill,
1519 max_tx->agg.bt_prio_kill);
1520 pos += scnprintf(buf + pos, bufsz - pos,
1521 fmt_table, "agg rx_ba_rsp_cnt:",
1522 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1523 accum_tx->agg.rx_ba_rsp_cnt,
1524 delta_tx->agg.rx_ba_rsp_cnt,
1525 max_tx->agg.rx_ba_rsp_cnt);
1527 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
1528 pos += scnprintf(buf + pos, bufsz - pos,
1529 "tx power: (1/2 dB step)\n");
1530 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
1531 pos += scnprintf(buf + pos, bufsz - pos,
1532 fmt_hex, "antenna A:",
1533 tx->tx_power.ant_a);
1534 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
1535 pos += scnprintf(buf + pos, bufsz - pos,
1536 fmt_hex, "antenna B:",
1537 tx->tx_power.ant_b);
1538 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
1539 pos += scnprintf(buf + pos, bufsz - pos,
1540 fmt_hex, "antenna C:",
1541 tx->tx_power.ant_c);
1543 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1544 kfree(buf);
1545 return ret;
1548 static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1549 char __user *user_buf,
1550 size_t count, loff_t *ppos)
1552 struct iwl_priv *priv = file->private_data;
1553 int pos = 0;
1554 char *buf;
1555 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1556 ssize_t ret;
1557 struct statistics_general_common *general, *accum_general;
1558 struct statistics_general_common *delta_general, *max_general;
1559 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1560 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1562 if (!iwl_is_alive(priv->shrd))
1563 return -EAGAIN;
1565 buf = kzalloc(bufsz, GFP_KERNEL);
1566 if (!buf) {
1567 IWL_ERR(priv, "Can not allocate Buffer\n");
1568 return -ENOMEM;
1571 /* the statistic information display here is based on
1572 * the last statistics notification from uCode
1573 * might not reflect the current uCode activity
1575 general = &priv->statistics.common;
1576 dbg = &priv->statistics.common.dbg;
1577 div = &priv->statistics.common.div;
1578 accum_general = &priv->accum_stats.common;
1579 accum_dbg = &priv->accum_stats.common.dbg;
1580 accum_div = &priv->accum_stats.common.div;
1581 delta_general = &priv->delta_stats.common;
1582 max_general = &priv->max_delta_stats.common;
1583 delta_dbg = &priv->delta_stats.common.dbg;
1584 max_dbg = &priv->max_delta_stats.common.dbg;
1585 delta_div = &priv->delta_stats.common.div;
1586 max_div = &priv->max_delta_stats.common.div;
1588 pos += iwl_statistics_flag(priv, buf, bufsz);
1589 pos += scnprintf(buf + pos, bufsz - pos,
1590 fmt_header, "Statistics_General:");
1591 pos += scnprintf(buf + pos, bufsz - pos,
1592 fmt_value, "temperature:",
1593 le32_to_cpu(general->temperature));
1594 pos += scnprintf(buf + pos, bufsz - pos,
1595 fmt_value, "temperature_m:",
1596 le32_to_cpu(general->temperature_m));
1597 pos += scnprintf(buf + pos, bufsz - pos,
1598 fmt_value, "ttl_timestamp:",
1599 le32_to_cpu(general->ttl_timestamp));
1600 pos += scnprintf(buf + pos, bufsz - pos,
1601 fmt_table, "burst_check:",
1602 le32_to_cpu(dbg->burst_check),
1603 accum_dbg->burst_check,
1604 delta_dbg->burst_check, max_dbg->burst_check);
1605 pos += scnprintf(buf + pos, bufsz - pos,
1606 fmt_table, "burst_count:",
1607 le32_to_cpu(dbg->burst_count),
1608 accum_dbg->burst_count,
1609 delta_dbg->burst_count, max_dbg->burst_count);
1610 pos += scnprintf(buf + pos, bufsz - pos,
1611 fmt_table, "wait_for_silence_timeout_count:",
1612 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
1613 accum_dbg->wait_for_silence_timeout_cnt,
1614 delta_dbg->wait_for_silence_timeout_cnt,
1615 max_dbg->wait_for_silence_timeout_cnt);
1616 pos += scnprintf(buf + pos, bufsz - pos,
1617 fmt_table, "sleep_time:",
1618 le32_to_cpu(general->sleep_time),
1619 accum_general->sleep_time,
1620 delta_general->sleep_time, max_general->sleep_time);
1621 pos += scnprintf(buf + pos, bufsz - pos,
1622 fmt_table, "slots_out:",
1623 le32_to_cpu(general->slots_out),
1624 accum_general->slots_out,
1625 delta_general->slots_out, max_general->slots_out);
1626 pos += scnprintf(buf + pos, bufsz - pos,
1627 fmt_table, "slots_idle:",
1628 le32_to_cpu(general->slots_idle),
1629 accum_general->slots_idle,
1630 delta_general->slots_idle, max_general->slots_idle);
1631 pos += scnprintf(buf + pos, bufsz - pos,
1632 fmt_table, "tx_on_a:",
1633 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1634 delta_div->tx_on_a, max_div->tx_on_a);
1635 pos += scnprintf(buf + pos, bufsz - pos,
1636 fmt_table, "tx_on_b:",
1637 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1638 delta_div->tx_on_b, max_div->tx_on_b);
1639 pos += scnprintf(buf + pos, bufsz - pos,
1640 fmt_table, "exec_time:",
1641 le32_to_cpu(div->exec_time), accum_div->exec_time,
1642 delta_div->exec_time, max_div->exec_time);
1643 pos += scnprintf(buf + pos, bufsz - pos,
1644 fmt_table, "probe_time:",
1645 le32_to_cpu(div->probe_time), accum_div->probe_time,
1646 delta_div->probe_time, max_div->probe_time);
1647 pos += scnprintf(buf + pos, bufsz - pos,
1648 fmt_table, "rx_enable_counter:",
1649 le32_to_cpu(general->rx_enable_counter),
1650 accum_general->rx_enable_counter,
1651 delta_general->rx_enable_counter,
1652 max_general->rx_enable_counter);
1653 pos += scnprintf(buf + pos, bufsz - pos,
1654 fmt_table, "num_of_sos_states:",
1655 le32_to_cpu(general->num_of_sos_states),
1656 accum_general->num_of_sos_states,
1657 delta_general->num_of_sos_states,
1658 max_general->num_of_sos_states);
1659 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1660 kfree(buf);
1661 return ret;
1664 static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1665 char __user *user_buf,
1666 size_t count, loff_t *ppos)
1668 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1669 int pos = 0;
1670 char *buf;
1671 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
1672 ssize_t ret;
1673 struct statistics_bt_activity *bt, *accum_bt;
1675 if (!iwl_is_alive(priv->shrd))
1676 return -EAGAIN;
1678 if (!priv->bt_enable_flag)
1679 return -EINVAL;
1681 /* make request to uCode to retrieve statistics information */
1682 mutex_lock(&priv->shrd->mutex);
1683 ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
1684 mutex_unlock(&priv->shrd->mutex);
1686 if (ret) {
1687 IWL_ERR(priv,
1688 "Error sending statistics request: %zd\n", ret);
1689 return -EAGAIN;
1691 buf = kzalloc(bufsz, GFP_KERNEL);
1692 if (!buf) {
1693 IWL_ERR(priv, "Can not allocate Buffer\n");
1694 return -ENOMEM;
1698 * the statistic information display here is based on
1699 * the last statistics notification from uCode
1700 * might not reflect the current uCode activity
1702 bt = &priv->statistics.bt_activity;
1703 accum_bt = &priv->accum_stats.bt_activity;
1705 pos += iwl_statistics_flag(priv, buf, bufsz);
1706 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
1707 pos += scnprintf(buf + pos, bufsz - pos,
1708 "\t\t\tcurrent\t\t\taccumulative\n");
1709 pos += scnprintf(buf + pos, bufsz - pos,
1710 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1711 le32_to_cpu(bt->hi_priority_tx_req_cnt),
1712 accum_bt->hi_priority_tx_req_cnt);
1713 pos += scnprintf(buf + pos, bufsz - pos,
1714 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1715 le32_to_cpu(bt->hi_priority_tx_denied_cnt),
1716 accum_bt->hi_priority_tx_denied_cnt);
1717 pos += scnprintf(buf + pos, bufsz - pos,
1718 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1719 le32_to_cpu(bt->lo_priority_tx_req_cnt),
1720 accum_bt->lo_priority_tx_req_cnt);
1721 pos += scnprintf(buf + pos, bufsz - pos,
1722 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1723 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
1724 accum_bt->lo_priority_tx_denied_cnt);
1725 pos += scnprintf(buf + pos, bufsz - pos,
1726 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1727 le32_to_cpu(bt->hi_priority_rx_req_cnt),
1728 accum_bt->hi_priority_rx_req_cnt);
1729 pos += scnprintf(buf + pos, bufsz - pos,
1730 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1731 le32_to_cpu(bt->hi_priority_rx_denied_cnt),
1732 accum_bt->hi_priority_rx_denied_cnt);
1733 pos += scnprintf(buf + pos, bufsz - pos,
1734 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1735 le32_to_cpu(bt->lo_priority_rx_req_cnt),
1736 accum_bt->lo_priority_rx_req_cnt);
1737 pos += scnprintf(buf + pos, bufsz - pos,
1738 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1739 le32_to_cpu(bt->lo_priority_rx_denied_cnt),
1740 accum_bt->lo_priority_rx_denied_cnt);
1742 pos += scnprintf(buf + pos, bufsz - pos,
1743 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1744 le32_to_cpu(priv->statistics.num_bt_kills),
1745 priv->statistics.accum_num_bt_kills);
1747 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1748 kfree(buf);
1749 return ret;
1752 static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1753 char __user *user_buf,
1754 size_t count, loff_t *ppos)
1756 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1757 int pos = 0;
1758 char *buf;
1759 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
1760 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
1761 ssize_t ret;
1763 if (!iwl_is_alive(priv->shrd))
1764 return -EAGAIN;
1766 buf = kzalloc(bufsz, GFP_KERNEL);
1767 if (!buf) {
1768 IWL_ERR(priv, "Can not allocate Buffer\n");
1769 return -ENOMEM;
1772 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1773 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1774 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
1775 priv->reply_tx_stats.pp_delay);
1776 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1777 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
1778 priv->reply_tx_stats.pp_few_bytes);
1779 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1780 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
1781 priv->reply_tx_stats.pp_bt_prio);
1782 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1783 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
1784 priv->reply_tx_stats.pp_quiet_period);
1785 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1786 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
1787 priv->reply_tx_stats.pp_calc_ttak);
1788 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1789 iwl_get_tx_fail_reason(
1790 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
1791 priv->reply_tx_stats.int_crossed_retry);
1792 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1793 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
1794 priv->reply_tx_stats.short_limit);
1795 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1796 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
1797 priv->reply_tx_stats.long_limit);
1798 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1799 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
1800 priv->reply_tx_stats.fifo_underrun);
1801 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1802 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
1803 priv->reply_tx_stats.drain_flow);
1804 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1805 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
1806 priv->reply_tx_stats.rfkill_flush);
1807 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1808 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
1809 priv->reply_tx_stats.life_expire);
1810 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1811 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
1812 priv->reply_tx_stats.dest_ps);
1813 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1814 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
1815 priv->reply_tx_stats.host_abort);
1816 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1817 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
1818 priv->reply_tx_stats.pp_delay);
1819 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1820 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
1821 priv->reply_tx_stats.sta_invalid);
1822 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1823 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
1824 priv->reply_tx_stats.frag_drop);
1825 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1826 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
1827 priv->reply_tx_stats.tid_disable);
1828 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1829 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
1830 priv->reply_tx_stats.fifo_flush);
1831 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1832 iwl_get_tx_fail_reason(
1833 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
1834 priv->reply_tx_stats.insuff_cf_poll);
1835 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1836 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
1837 priv->reply_tx_stats.fail_hw_drop);
1838 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1839 iwl_get_tx_fail_reason(
1840 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
1841 priv->reply_tx_stats.sta_color_mismatch);
1842 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1843 priv->reply_tx_stats.unknown);
1845 pos += scnprintf(buf + pos, bufsz - pos,
1846 "\nStatistics_Agg_TX_Error:\n");
1848 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1849 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
1850 priv->reply_agg_tx_stats.underrun);
1851 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1852 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
1853 priv->reply_agg_tx_stats.bt_prio);
1854 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1855 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
1856 priv->reply_agg_tx_stats.few_bytes);
1857 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1858 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
1859 priv->reply_agg_tx_stats.abort);
1860 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1861 iwl_get_agg_tx_fail_reason(
1862 AGG_TX_STATE_LAST_SENT_TTL_MSK),
1863 priv->reply_agg_tx_stats.last_sent_ttl);
1864 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1865 iwl_get_agg_tx_fail_reason(
1866 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
1867 priv->reply_agg_tx_stats.last_sent_try);
1868 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1869 iwl_get_agg_tx_fail_reason(
1870 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
1871 priv->reply_agg_tx_stats.last_sent_bt_kill);
1872 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1873 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
1874 priv->reply_agg_tx_stats.scd_query);
1875 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1876 iwl_get_agg_tx_fail_reason(
1877 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
1878 priv->reply_agg_tx_stats.bad_crc32);
1879 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1880 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
1881 priv->reply_agg_tx_stats.response);
1882 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1883 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
1884 priv->reply_agg_tx_stats.dump_tx);
1885 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1886 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
1887 priv->reply_agg_tx_stats.delay_tx);
1888 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
1889 priv->reply_agg_tx_stats.unknown);
1891 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1892 kfree(buf);
1893 return ret;
1896 static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1897 char __user *user_buf,
1898 size_t count, loff_t *ppos) {
1900 struct iwl_priv *priv = file->private_data;
1901 int pos = 0;
1902 int cnt = 0;
1903 char *buf;
1904 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1905 ssize_t ret;
1906 struct iwl_sensitivity_data *data;
1908 data = &priv->sensitivity_data;
1909 buf = kzalloc(bufsz, GFP_KERNEL);
1910 if (!buf) {
1911 IWL_ERR(priv, "Can not allocate Buffer\n");
1912 return -ENOMEM;
1915 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1916 data->auto_corr_ofdm);
1917 pos += scnprintf(buf + pos, bufsz - pos,
1918 "auto_corr_ofdm_mrc:\t\t %u\n",
1919 data->auto_corr_ofdm_mrc);
1920 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1921 data->auto_corr_ofdm_x1);
1922 pos += scnprintf(buf + pos, bufsz - pos,
1923 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1924 data->auto_corr_ofdm_mrc_x1);
1925 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1926 data->auto_corr_cck);
1927 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1928 data->auto_corr_cck_mrc);
1929 pos += scnprintf(buf + pos, bufsz - pos,
1930 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1931 data->last_bad_plcp_cnt_ofdm);
1932 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1933 data->last_fa_cnt_ofdm);
1934 pos += scnprintf(buf + pos, bufsz - pos,
1935 "last_bad_plcp_cnt_cck:\t\t %u\n",
1936 data->last_bad_plcp_cnt_cck);
1937 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1938 data->last_fa_cnt_cck);
1939 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1940 data->nrg_curr_state);
1941 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1942 data->nrg_prev_state);
1943 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1944 for (cnt = 0; cnt < 10; cnt++) {
1945 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1946 data->nrg_value[cnt]);
1948 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1949 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1950 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1951 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1952 data->nrg_silence_rssi[cnt]);
1954 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1955 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1956 data->nrg_silence_ref);
1957 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1958 data->nrg_energy_idx);
1959 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1960 data->nrg_silence_idx);
1961 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1962 data->nrg_th_cck);
1963 pos += scnprintf(buf + pos, bufsz - pos,
1964 "nrg_auto_corr_silence_diff:\t %u\n",
1965 data->nrg_auto_corr_silence_diff);
1966 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1967 data->num_in_cck_no_fa);
1968 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1969 data->nrg_th_ofdm);
1971 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1972 kfree(buf);
1973 return ret;
1977 static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1978 char __user *user_buf,
1979 size_t count, loff_t *ppos) {
1981 struct iwl_priv *priv = file->private_data;
1982 int pos = 0;
1983 int cnt = 0;
1984 char *buf;
1985 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1986 ssize_t ret;
1987 struct iwl_chain_noise_data *data;
1989 data = &priv->chain_noise_data;
1990 buf = kzalloc(bufsz, GFP_KERNEL);
1991 if (!buf) {
1992 IWL_ERR(priv, "Can not allocate Buffer\n");
1993 return -ENOMEM;
1996 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1997 data->active_chains);
1998 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1999 data->chain_noise_a);
2000 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
2001 data->chain_noise_b);
2002 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
2003 data->chain_noise_c);
2004 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
2005 data->chain_signal_a);
2006 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
2007 data->chain_signal_b);
2008 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
2009 data->chain_signal_c);
2010 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
2011 data->beacon_count);
2013 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
2014 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
2015 pos += scnprintf(buf + pos, bufsz - pos, " %u",
2016 data->disconn_array[cnt]);
2018 pos += scnprintf(buf + pos, bufsz - pos, "\n");
2019 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
2020 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
2021 pos += scnprintf(buf + pos, bufsz - pos, " %u",
2022 data->delta_gain_code[cnt]);
2024 pos += scnprintf(buf + pos, bufsz - pos, "\n");
2025 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
2026 data->radio_write);
2027 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
2028 data->state);
2030 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2031 kfree(buf);
2032 return ret;
2035 static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
2036 char __user *user_buf,
2037 size_t count, loff_t *ppos)
2039 struct iwl_priv *priv = file->private_data;
2040 char buf[60];
2041 int pos = 0;
2042 const size_t bufsz = sizeof(buf);
2043 u32 pwrsave_status;
2045 pwrsave_status = iwl_read32(bus(priv), CSR_GP_CNTRL) &
2046 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
2048 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
2049 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
2050 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
2051 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
2052 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
2053 "error");
2055 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2058 static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
2059 const char __user *user_buf,
2060 size_t count, loff_t *ppos)
2062 struct iwl_priv *priv = file->private_data;
2063 char buf[8];
2064 int buf_size;
2065 int clear;
2067 memset(buf, 0, sizeof(buf));
2068 buf_size = min(count, sizeof(buf) - 1);
2069 if (copy_from_user(buf, user_buf, buf_size))
2070 return -EFAULT;
2071 if (sscanf(buf, "%d", &clear) != 1)
2072 return -EFAULT;
2074 /* make request to uCode to retrieve statistics information */
2075 mutex_lock(&priv->shrd->mutex);
2076 iwl_send_statistics_request(priv, CMD_SYNC, true);
2077 mutex_unlock(&priv->shrd->mutex);
2079 return count;
2082 static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2083 char __user *user_buf,
2084 size_t count, loff_t *ppos) {
2086 struct iwl_priv *priv = file->private_data;
2087 int pos = 0;
2088 char buf[128];
2089 const size_t bufsz = sizeof(buf);
2091 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2092 priv->event_log.ucode_trace ? "On" : "Off");
2093 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
2094 priv->event_log.non_wraps_count);
2095 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
2096 priv->event_log.wraps_once_count);
2097 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2098 priv->event_log.wraps_more_count);
2100 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2103 static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2104 const char __user *user_buf,
2105 size_t count, loff_t *ppos)
2107 struct iwl_priv *priv = file->private_data;
2108 char buf[8];
2109 int buf_size;
2110 int trace;
2112 memset(buf, 0, sizeof(buf));
2113 buf_size = min(count, sizeof(buf) - 1);
2114 if (copy_from_user(buf, user_buf, buf_size))
2115 return -EFAULT;
2116 if (sscanf(buf, "%d", &trace) != 1)
2117 return -EFAULT;
2119 if (trace) {
2120 priv->event_log.ucode_trace = true;
2121 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2122 mod_timer(&priv->ucode_trace,
2123 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
2124 } else {
2125 priv->event_log.ucode_trace = false;
2126 del_timer_sync(&priv->ucode_trace);
2129 return count;
2132 static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
2133 char __user *user_buf,
2134 size_t count, loff_t *ppos) {
2136 struct iwl_priv *priv = file->private_data;
2137 int len = 0;
2138 char buf[20];
2140 len = sprintf(buf, "0x%04X\n",
2141 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
2142 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2145 static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
2146 char __user *user_buf,
2147 size_t count, loff_t *ppos) {
2149 struct iwl_priv *priv = file->private_data;
2150 int len = 0;
2151 char buf[20];
2153 len = sprintf(buf, "0x%04X\n",
2154 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
2155 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2158 static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2159 char __user *user_buf,
2160 size_t count, loff_t *ppos) {
2162 struct iwl_priv *priv = file->private_data;
2163 int pos = 0;
2164 char buf[12];
2165 const size_t bufsz = sizeof(buf);
2167 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2168 priv->missed_beacon_threshold);
2170 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2173 static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2174 const char __user *user_buf,
2175 size_t count, loff_t *ppos)
2177 struct iwl_priv *priv = file->private_data;
2178 char buf[8];
2179 int buf_size;
2180 int missed;
2182 memset(buf, 0, sizeof(buf));
2183 buf_size = min(count, sizeof(buf) - 1);
2184 if (copy_from_user(buf, user_buf, buf_size))
2185 return -EFAULT;
2186 if (sscanf(buf, "%d", &missed) != 1)
2187 return -EINVAL;
2189 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2190 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2191 priv->missed_beacon_threshold =
2192 IWL_MISSED_BEACON_THRESHOLD_DEF;
2193 else
2194 priv->missed_beacon_threshold = missed;
2196 return count;
2199 static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2200 char __user *user_buf,
2201 size_t count, loff_t *ppos) {
2203 struct iwl_priv *priv = file->private_data;
2204 int pos = 0;
2205 char buf[12];
2206 const size_t bufsz = sizeof(buf);
2208 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
2209 priv->cfg->base_params->plcp_delta_threshold);
2211 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2214 static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2215 const char __user *user_buf,
2216 size_t count, loff_t *ppos) {
2218 struct iwl_priv *priv = file->private_data;
2219 char buf[8];
2220 int buf_size;
2221 int plcp;
2223 memset(buf, 0, sizeof(buf));
2224 buf_size = min(count, sizeof(buf) - 1);
2225 if (copy_from_user(buf, user_buf, buf_size))
2226 return -EFAULT;
2227 if (sscanf(buf, "%d", &plcp) != 1)
2228 return -EINVAL;
2229 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
2230 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
2231 priv->cfg->base_params->plcp_delta_threshold =
2232 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
2233 else
2234 priv->cfg->base_params->plcp_delta_threshold = plcp;
2235 return count;
2238 static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
2239 char __user *user_buf,
2240 size_t count, loff_t *ppos)
2242 struct iwl_priv *priv = file->private_data;
2243 int i, pos = 0;
2244 char buf[300];
2245 const size_t bufsz = sizeof(buf);
2246 struct iwl_force_reset *force_reset;
2248 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
2249 force_reset = &priv->force_reset[i];
2250 pos += scnprintf(buf + pos, bufsz - pos,
2251 "Force reset method %d\n", i);
2252 pos += scnprintf(buf + pos, bufsz - pos,
2253 "\tnumber of reset request: %d\n",
2254 force_reset->reset_request_count);
2255 pos += scnprintf(buf + pos, bufsz - pos,
2256 "\tnumber of reset request success: %d\n",
2257 force_reset->reset_success_count);
2258 pos += scnprintf(buf + pos, bufsz - pos,
2259 "\tnumber of reset request reject: %d\n",
2260 force_reset->reset_reject_count);
2261 pos += scnprintf(buf + pos, bufsz - pos,
2262 "\treset duration: %lu\n",
2263 force_reset->reset_duration);
2265 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2268 static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
2269 const char __user *user_buf,
2270 size_t count, loff_t *ppos) {
2272 struct iwl_priv *priv = file->private_data;
2273 char buf[8];
2274 int buf_size;
2275 int reset, ret;
2277 memset(buf, 0, sizeof(buf));
2278 buf_size = min(count, sizeof(buf) - 1);
2279 if (copy_from_user(buf, user_buf, buf_size))
2280 return -EFAULT;
2281 if (sscanf(buf, "%d", &reset) != 1)
2282 return -EINVAL;
2283 switch (reset) {
2284 case IWL_RF_RESET:
2285 case IWL_FW_RESET:
2286 ret = iwl_force_reset(priv, reset, true);
2287 break;
2288 default:
2289 return -EINVAL;
2291 return ret ? ret : count;
2294 static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
2295 const char __user *user_buf,
2296 size_t count, loff_t *ppos) {
2298 struct iwl_priv *priv = file->private_data;
2299 char buf[8];
2300 int buf_size;
2301 int flush;
2303 memset(buf, 0, sizeof(buf));
2304 buf_size = min(count, sizeof(buf) - 1);
2305 if (copy_from_user(buf, user_buf, buf_size))
2306 return -EFAULT;
2307 if (sscanf(buf, "%d", &flush) != 1)
2308 return -EINVAL;
2310 if (iwl_is_rfkill(priv->shrd))
2311 return -EFAULT;
2313 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
2315 return count;
2318 static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file,
2319 const char __user *user_buf,
2320 size_t count, loff_t *ppos)
2322 struct iwl_priv *priv = file->private_data;
2323 char buf[8];
2324 int buf_size;
2325 int timeout;
2327 memset(buf, 0, sizeof(buf));
2328 buf_size = min(count, sizeof(buf) - 1);
2329 if (copy_from_user(buf, user_buf, buf_size))
2330 return -EFAULT;
2331 if (sscanf(buf, "%d", &timeout) != 1)
2332 return -EINVAL;
2333 if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT)
2334 timeout = IWL_DEF_WD_TIMEOUT;
2336 priv->cfg->base_params->wd_timeout = timeout;
2337 iwl_setup_watchdog(priv);
2338 return count;
2341 static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
2342 char __user *user_buf,
2343 size_t count, loff_t *ppos) {
2345 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2346 int pos = 0;
2347 char buf[200];
2348 const size_t bufsz = sizeof(buf);
2350 if (!priv->bt_enable_flag) {
2351 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
2352 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2354 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
2355 priv->bt_enable_flag);
2356 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
2357 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
2358 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
2359 "last traffic notif: %d\n",
2360 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
2361 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
2362 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2363 priv->bt_ch_announce, priv->kill_ack_mask,
2364 priv->kill_cts_mask);
2366 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
2367 switch (priv->bt_traffic_load) {
2368 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
2369 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
2370 break;
2371 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
2372 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
2373 break;
2374 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
2375 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
2376 break;
2377 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
2378 default:
2379 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
2380 break;
2383 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2386 static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2387 char __user *user_buf,
2388 size_t count, loff_t *ppos)
2390 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2392 int pos = 0;
2393 char buf[40];
2394 const size_t bufsz = sizeof(buf);
2396 if (priv->cfg->ht_params)
2397 pos += scnprintf(buf + pos, bufsz - pos,
2398 "use %s for aggregation\n",
2399 (priv->cfg->ht_params->use_rts_for_aggregation) ?
2400 "rts/cts" : "cts-to-self");
2401 else
2402 pos += scnprintf(buf + pos, bufsz - pos, "N/A");
2404 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2407 static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2408 const char __user *user_buf,
2409 size_t count, loff_t *ppos) {
2411 struct iwl_priv *priv = file->private_data;
2412 char buf[8];
2413 int buf_size;
2414 int rts;
2416 if (!priv->cfg->ht_params)
2417 return -EINVAL;
2419 memset(buf, 0, sizeof(buf));
2420 buf_size = min(count, sizeof(buf) - 1);
2421 if (copy_from_user(buf, user_buf, buf_size))
2422 return -EFAULT;
2423 if (sscanf(buf, "%d", &rts) != 1)
2424 return -EINVAL;
2425 if (rts)
2426 priv->cfg->ht_params->use_rts_for_aggregation = true;
2427 else
2428 priv->cfg->ht_params->use_rts_for_aggregation = false;
2429 return count;
2432 DEBUGFS_READ_FILE_OPS(rx_statistics);
2433 DEBUGFS_READ_FILE_OPS(tx_statistics);
2434 DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
2435 DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2436 DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2437 DEBUGFS_READ_FILE_OPS(ucode_general_stats);
2438 DEBUGFS_READ_FILE_OPS(sensitivity);
2439 DEBUGFS_READ_FILE_OPS(chain_noise);
2440 DEBUGFS_READ_FILE_OPS(power_save_status);
2441 DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2442 DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
2443 DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
2444 DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
2445 DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
2446 DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
2447 DEBUGFS_READ_FILE_OPS(rxon_flags);
2448 DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
2449 DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
2450 DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
2451 DEBUGFS_WRITE_FILE_OPS(wd_timeout);
2452 DEBUGFS_READ_FILE_OPS(bt_traffic);
2453 DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
2454 DEBUGFS_READ_FILE_OPS(reply_tx_error);
2456 #ifdef CONFIG_IWLWIFI_DEBUG
2457 static ssize_t iwl_dbgfs_debug_level_read(struct file *file,
2458 char __user *user_buf,
2459 size_t count, loff_t *ppos)
2461 struct iwl_priv *priv = file->private_data;
2462 struct iwl_shared *shrd = priv->shrd;
2463 char buf[11];
2464 int len;
2466 len = scnprintf(buf, sizeof(buf), "0x%.8x",
2467 iwl_get_debug_level(shrd));
2469 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2472 static ssize_t iwl_dbgfs_debug_level_write(struct file *file,
2473 const char __user *user_buf,
2474 size_t count, loff_t *ppos)
2476 struct iwl_priv *priv = file->private_data;
2477 struct iwl_shared *shrd = priv->shrd;
2478 char buf[11];
2479 unsigned long val;
2480 int ret;
2482 if (count > sizeof(buf))
2483 return -EINVAL;
2485 memset(buf, 0, sizeof(buf));
2486 if (copy_from_user(buf, user_buf, count))
2487 return -EFAULT;
2489 ret = strict_strtoul(buf, 0, &val);
2490 if (ret)
2491 return ret;
2493 shrd->dbg_level_dev = val;
2494 if (iwl_alloc_traffic_mem(priv))
2495 IWL_ERR(priv, "Not enough memory to generate traffic log\n");
2497 return count;
2499 DEBUGFS_READ_WRITE_FILE_OPS(debug_level);
2500 #endif /* CONFIG_IWLWIFI_DEBUG */
2503 * Create the debugfs files and directories
2506 int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2508 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
2509 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
2511 dir_drv = debugfs_create_dir(name, phyd);
2512 if (!dir_drv)
2513 return -ENOMEM;
2515 priv->debugfs_dir = dir_drv;
2517 dir_data = debugfs_create_dir("data", dir_drv);
2518 if (!dir_data)
2519 goto err;
2520 dir_rf = debugfs_create_dir("rf", dir_drv);
2521 if (!dir_rf)
2522 goto err;
2523 dir_debug = debugfs_create_dir("debug", dir_drv);
2524 if (!dir_debug)
2525 goto err;
2527 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2528 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
2529 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
2530 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2531 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2532 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
2533 DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
2534 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
2535 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2536 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
2537 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2538 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
2539 DEBUGFS_ADD_U32(temperature, dir_data, &priv->temperature, S_IRUSR);
2541 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
2542 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
2543 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
2544 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2545 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
2546 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
2547 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2548 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
2549 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
2550 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2551 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2552 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
2553 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
2554 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
2555 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2556 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
2557 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
2558 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
2559 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
2560 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2561 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
2562 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
2563 if (iwl_advanced_bt_coexist(priv))
2564 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
2565 #ifdef CONFIG_IWLWIFI_DEBUG
2566 DEBUGFS_ADD_FILE(debug_level, dir_debug, S_IRUSR | S_IWUSR);
2567 #endif
2569 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
2570 &priv->disable_sens_cal);
2571 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
2572 &priv->disable_chain_noise_cal);
2574 if (iwl_trans_dbgfs_register(trans(priv), dir_debug))
2575 goto err;
2576 return 0;
2578 err:
2579 IWL_ERR(priv, "Can't create the debugfs directory\n");
2580 iwl_dbgfs_unregister(priv);
2581 return -ENOMEM;
2585 * Remove the debugfs files and directories
2588 void iwl_dbgfs_unregister(struct iwl_priv *priv)
2590 if (!priv->debugfs_dir)
2591 return;
2593 debugfs_remove_recursive(priv->debugfs_dir);
2594 priv->debugfs_dir = NULL;