1 /******************************************************************************
5 * Copyright(c) 2008 - 2012 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,
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>
33 #include <linux/ieee80211.h>
34 #include <net/mac80211.h>
35 #include "iwl-debug.h"
40 /* create and remove of files */
41 #define DEBUGFS_ADD_FILE(name, parent, mode) do { \
42 if (!debugfs_create_file(#name, mode, parent, priv, \
43 &iwl_dbgfs_##name##_ops)) \
47 #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
48 struct dentry *__tmp; \
49 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
51 if (IS_ERR(__tmp) || !__tmp) \
55 #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
56 struct dentry *__tmp; \
57 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
59 if (IS_ERR(__tmp) || !__tmp) \
63 #define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \
64 struct dentry *__tmp; \
65 __tmp = debugfs_create_u32(#name, mode, \
67 if (IS_ERR(__tmp) || !__tmp) \
72 #define DEBUGFS_READ_FUNC(name) \
73 static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
74 char __user *user_buf, \
75 size_t count, loff_t *ppos);
77 #define DEBUGFS_WRITE_FUNC(name) \
78 static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
79 const char __user *user_buf, \
80 size_t count, loff_t *ppos);
83 #define DEBUGFS_READ_FILE_OPS(name) \
84 DEBUGFS_READ_FUNC(name); \
85 static const struct file_operations iwl_dbgfs_##name##_ops = { \
86 .read = iwl_dbgfs_##name##_read, \
87 .open = simple_open, \
88 .llseek = generic_file_llseek, \
91 #define DEBUGFS_WRITE_FILE_OPS(name) \
92 DEBUGFS_WRITE_FUNC(name); \
93 static const struct file_operations iwl_dbgfs_##name##_ops = { \
94 .write = iwl_dbgfs_##name##_write, \
95 .open = simple_open, \
96 .llseek = generic_file_llseek, \
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 = simple_open, \
107 .llseek = generic_file_llseek, \
110 static ssize_t
iwl_dbgfs_sram_read(struct file
*file
,
111 char __user
*user_buf
,
112 size_t count
, loff_t
*ppos
)
118 bool device_format
= false;
123 struct iwl_priv
*priv
= file
->private_data
;
124 const struct fw_img
*img
;
127 /* default is to dump the entire data segment */
128 if (!priv
->dbgfs_sram_offset
&& !priv
->dbgfs_sram_len
) {
129 priv
->dbgfs_sram_offset
= 0x800000;
130 if (!priv
->ucode_loaded
)
132 img
= &priv
->fw
->img
[priv
->cur_ucode
];
133 priv
->dbgfs_sram_len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
135 len
= priv
->dbgfs_sram_len
;
138 device_format
= true;
142 bufsz
= 50 + len
* 4;
143 buf
= kmalloc(bufsz
, GFP_KERNEL
);
147 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_len: 0x%x\n",
149 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_offset: 0x%x\n",
150 priv
->dbgfs_sram_offset
);
152 /* adjust sram address since reads are only on even u32 boundaries */
153 offset
= priv
->dbgfs_sram_offset
& 0x3;
154 sram
= priv
->dbgfs_sram_offset
& ~0x3;
156 /* read the first u32 from sram */
157 val
= iwl_read_targ_mem(priv
->trans
, sram
);
160 /* put the address at the start of every line */
162 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
163 "%08X: ", sram
+ offset
);
166 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
167 "%02x", (val
>> (8 * (3 - offset
))) & 0xff);
169 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
170 "%02x ", (val
>> (8 * offset
)) & 0xff);
172 /* if all bytes processed, read the next u32 from sram */
176 val
= iwl_read_targ_mem(priv
->trans
, sram
);
179 /* put in extra spaces and split lines for human readability */
182 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
183 } else if (!(i
& 7)) {
184 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " ");
185 } else if (!(i
& 3)) {
186 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " ");
190 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
192 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
197 static ssize_t
iwl_dbgfs_sram_write(struct file
*file
,
198 const char __user
*user_buf
,
199 size_t count
, loff_t
*ppos
)
201 struct iwl_priv
*priv
= file
->private_data
;
206 memset(buf
, 0, sizeof(buf
));
207 buf_size
= min(count
, sizeof(buf
) - 1);
208 if (copy_from_user(buf
, user_buf
, buf_size
))
211 if (sscanf(buf
, "%x,%x", &offset
, &len
) == 2) {
212 priv
->dbgfs_sram_offset
= offset
;
213 priv
->dbgfs_sram_len
= len
;
214 } else if (sscanf(buf
, "%x", &offset
) == 1) {
215 priv
->dbgfs_sram_offset
= offset
;
216 priv
->dbgfs_sram_len
= -4;
218 priv
->dbgfs_sram_offset
= 0;
219 priv
->dbgfs_sram_len
= 0;
225 static ssize_t
iwl_dbgfs_wowlan_sram_read(struct file
*file
,
226 char __user
*user_buf
,
227 size_t count
, loff_t
*ppos
)
229 struct iwl_priv
*priv
= file
->private_data
;
230 const struct fw_img
*img
= &priv
->fw
->img
[IWL_UCODE_WOWLAN
];
232 if (!priv
->wowlan_sram
)
235 return simple_read_from_buffer(user_buf
, count
, ppos
,
237 img
->sec
[IWL_UCODE_SECTION_DATA
].len
);
239 static ssize_t
iwl_dbgfs_stations_read(struct file
*file
, char __user
*user_buf
,
240 size_t count
, loff_t
*ppos
)
242 struct iwl_priv
*priv
= file
->private_data
;
243 struct iwl_station_entry
*station
;
244 struct iwl_tid_data
*tid_data
;
248 /* Add 30 for initial string */
249 const size_t bufsz
= 30 + sizeof(char) * 500 * (priv
->num_stations
);
251 buf
= kmalloc(bufsz
, GFP_KERNEL
);
255 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "num of stations: %d\n\n",
258 for (i
= 0; i
< IWLAGN_STATION_COUNT
; i
++) {
259 station
= &priv
->stations
[i
];
262 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
263 "station %d - addr: %pM, flags: %#x\n",
264 i
, station
->sta
.sta
.addr
,
265 station
->sta
.station_flags_msk
);
266 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
267 "TID seqno next_rclmd "
268 "rate_n_flags state txq\n");
270 for (j
= 0; j
< IWL_MAX_TID_COUNT
; j
++) {
271 tid_data
= &priv
->tid_data
[i
][j
];
272 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
273 "%d: 0x%.4x 0x%.4x 0x%.8x "
275 j
, tid_data
->seq_number
,
276 tid_data
->next_reclaimed
,
277 tid_data
->agg
.rate_n_flags
,
279 tid_data
->agg
.txq_id
);
281 if (tid_data
->agg
.wait_for_ba
)
282 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
284 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
287 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
290 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
295 static ssize_t
iwl_dbgfs_nvm_read(struct file
*file
,
296 char __user
*user_buf
,
301 struct iwl_priv
*priv
= file
->private_data
;
302 int pos
= 0, ofs
= 0, buf_size
= 0;
306 size_t eeprom_len
= priv
->eeprom_blob_size
;
307 buf_size
= 4 * eeprom_len
+ 256;
312 ptr
= priv
->eeprom_blob
;
316 /* 4 characters for byte 0xYY */
317 buf
= kzalloc(buf_size
, GFP_KERNEL
);
321 eeprom_ver
= priv
->eeprom_data
->eeprom_version
;
322 pos
+= scnprintf(buf
+ pos
, buf_size
- pos
,
323 "NVM version: 0x%x\n", eeprom_ver
);
324 for (ofs
= 0 ; ofs
< eeprom_len
; ofs
+= 16) {
325 pos
+= scnprintf(buf
+ pos
, buf_size
- pos
, "0x%.4x ", ofs
);
326 hex_dump_to_buffer(ptr
+ ofs
, 16 , 16, 2, buf
+ pos
,
328 pos
+= strlen(buf
+ pos
);
329 if (buf_size
- pos
> 0)
333 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
338 static ssize_t
iwl_dbgfs_channels_read(struct file
*file
, char __user
*user_buf
,
339 size_t count
, loff_t
*ppos
)
341 struct iwl_priv
*priv
= file
->private_data
;
342 struct ieee80211_channel
*channels
= NULL
;
343 const struct ieee80211_supported_band
*supp_band
= NULL
;
344 int pos
= 0, i
, bufsz
= PAGE_SIZE
;
348 buf
= kzalloc(bufsz
, GFP_KERNEL
);
352 supp_band
= iwl_get_hw_mode(priv
, IEEE80211_BAND_2GHZ
);
354 channels
= supp_band
->channels
;
356 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
357 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
358 supp_band
->n_channels
);
360 for (i
= 0; i
< supp_band
->n_channels
; i
++)
361 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
362 "%d: %ddBm: BSS%s%s, %s.\n",
363 channels
[i
].hw_value
,
364 channels
[i
].max_power
,
365 channels
[i
].flags
& IEEE80211_CHAN_RADAR
?
366 " (IEEE 802.11h required)" : "",
367 ((channels
[i
].flags
& IEEE80211_CHAN_NO_IBSS
)
368 || (channels
[i
].flags
&
369 IEEE80211_CHAN_RADAR
)) ? "" :
372 IEEE80211_CHAN_PASSIVE_SCAN
?
373 "passive only" : "active/passive");
375 supp_band
= iwl_get_hw_mode(priv
, IEEE80211_BAND_5GHZ
);
377 channels
= supp_band
->channels
;
379 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
380 "Displaying %d channels in 5.2GHz band (802.11a)\n",
381 supp_band
->n_channels
);
383 for (i
= 0; i
< supp_band
->n_channels
; i
++)
384 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
385 "%d: %ddBm: BSS%s%s, %s.\n",
386 channels
[i
].hw_value
,
387 channels
[i
].max_power
,
388 channels
[i
].flags
& IEEE80211_CHAN_RADAR
?
389 " (IEEE 802.11h required)" : "",
390 ((channels
[i
].flags
& IEEE80211_CHAN_NO_IBSS
)
391 || (channels
[i
].flags
&
392 IEEE80211_CHAN_RADAR
)) ? "" :
395 IEEE80211_CHAN_PASSIVE_SCAN
?
396 "passive only" : "active/passive");
398 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
403 static ssize_t
iwl_dbgfs_status_read(struct file
*file
,
404 char __user
*user_buf
,
405 size_t count
, loff_t
*ppos
) {
407 struct iwl_priv
*priv
= file
->private_data
;
410 const size_t bufsz
= sizeof(buf
);
412 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_RF_KILL_HW:\t %d\n",
413 test_bit(STATUS_RF_KILL_HW
, &priv
->status
));
414 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_CT_KILL:\t\t %d\n",
415 test_bit(STATUS_CT_KILL
, &priv
->status
));
416 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_ALIVE:\t\t %d\n",
417 test_bit(STATUS_ALIVE
, &priv
->status
));
418 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_READY:\t\t %d\n",
419 test_bit(STATUS_READY
, &priv
->status
));
420 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_EXIT_PENDING:\t %d\n",
421 test_bit(STATUS_EXIT_PENDING
, &priv
->status
));
422 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_STATISTICS:\t %d\n",
423 test_bit(STATUS_STATISTICS
, &priv
->status
));
424 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_SCANNING:\t %d\n",
425 test_bit(STATUS_SCANNING
, &priv
->status
));
426 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_SCAN_ABORTING:\t %d\n",
427 test_bit(STATUS_SCAN_ABORTING
, &priv
->status
));
428 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_SCAN_HW:\t\t %d\n",
429 test_bit(STATUS_SCAN_HW
, &priv
->status
));
430 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_POWER_PMI:\t %d\n",
431 test_bit(STATUS_POWER_PMI
, &priv
->status
));
432 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_FW_ERROR:\t %d\n",
433 test_bit(STATUS_FW_ERROR
, &priv
->status
));
434 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
437 static ssize_t
iwl_dbgfs_rx_handlers_read(struct file
*file
,
438 char __user
*user_buf
,
439 size_t count
, loff_t
*ppos
) {
441 struct iwl_priv
*priv
= file
->private_data
;
446 int bufsz
= 24 * 64; /* 24 items * 64 char per item */
449 buf
= kzalloc(bufsz
, GFP_KERNEL
);
453 for (cnt
= 0; cnt
< REPLY_MAX
; cnt
++) {
454 if (priv
->rx_handlers_stats
[cnt
] > 0)
455 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
456 "\tRx handler[%36s]:\t\t %u\n",
457 iwl_dvm_get_cmd_string(cnt
),
458 priv
->rx_handlers_stats
[cnt
]);
461 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
466 static ssize_t
iwl_dbgfs_rx_handlers_write(struct file
*file
,
467 const char __user
*user_buf
,
468 size_t count
, loff_t
*ppos
)
470 struct iwl_priv
*priv
= file
->private_data
;
476 memset(buf
, 0, sizeof(buf
));
477 buf_size
= min(count
, sizeof(buf
) - 1);
478 if (copy_from_user(buf
, user_buf
, buf_size
))
480 if (sscanf(buf
, "%x", &reset_flag
) != 1)
483 memset(&priv
->rx_handlers_stats
[0], 0,
484 sizeof(priv
->rx_handlers_stats
));
489 static ssize_t
iwl_dbgfs_qos_read(struct file
*file
, char __user
*user_buf
,
490 size_t count
, loff_t
*ppos
)
492 struct iwl_priv
*priv
= file
->private_data
;
493 struct iwl_rxon_context
*ctx
;
495 char buf
[256 * NUM_IWL_RXON_CTX
];
496 const size_t bufsz
= sizeof(buf
);
498 for_each_context(priv
, ctx
) {
499 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "context %d:\n",
501 for (i
= 0; i
< AC_NUM
; i
++) {
502 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
503 "\tcw_min\tcw_max\taifsn\ttxop\n");
504 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
505 "AC[%d]\t%u\t%u\t%u\t%u\n", i
,
506 ctx
->qos_data
.def_qos_parm
.ac
[i
].cw_min
,
507 ctx
->qos_data
.def_qos_parm
.ac
[i
].cw_max
,
508 ctx
->qos_data
.def_qos_parm
.ac
[i
].aifsn
,
509 ctx
->qos_data
.def_qos_parm
.ac
[i
].edca_txop
);
511 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
513 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
516 static ssize_t
iwl_dbgfs_thermal_throttling_read(struct file
*file
,
517 char __user
*user_buf
,
518 size_t count
, loff_t
*ppos
)
520 struct iwl_priv
*priv
= file
->private_data
;
521 struct iwl_tt_mgmt
*tt
= &priv
->thermal_throttle
;
522 struct iwl_tt_restriction
*restriction
;
525 const size_t bufsz
= sizeof(buf
);
527 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
528 "Thermal Throttling Mode: %s\n",
529 tt
->advanced_tt
? "Advance" : "Legacy");
530 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
531 "Thermal Throttling State: %d\n",
533 if (tt
->advanced_tt
) {
534 restriction
= tt
->restriction
+ tt
->state
;
535 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
537 restriction
->tx_stream
);
538 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
540 restriction
->rx_stream
);
541 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
545 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
548 static ssize_t
iwl_dbgfs_disable_ht40_write(struct file
*file
,
549 const char __user
*user_buf
,
550 size_t count
, loff_t
*ppos
)
552 struct iwl_priv
*priv
= file
->private_data
;
557 memset(buf
, 0, sizeof(buf
));
558 buf_size
= min(count
, sizeof(buf
) - 1);
559 if (copy_from_user(buf
, user_buf
, buf_size
))
561 if (sscanf(buf
, "%d", &ht40
) != 1)
563 if (!iwl_is_any_associated(priv
))
564 priv
->disable_ht40
= ht40
? true : false;
571 static ssize_t
iwl_dbgfs_disable_ht40_read(struct file
*file
,
572 char __user
*user_buf
,
573 size_t count
, loff_t
*ppos
)
575 struct iwl_priv
*priv
= file
->private_data
;
578 const size_t bufsz
= sizeof(buf
);
580 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
581 "11n 40MHz Mode: %s\n",
582 priv
->disable_ht40
? "Disabled" : "Enabled");
583 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
586 static ssize_t
iwl_dbgfs_temperature_read(struct file
*file
,
587 char __user
*user_buf
,
588 size_t count
, loff_t
*ppos
)
590 struct iwl_priv
*priv
= file
->private_data
;
593 const size_t bufsz
= sizeof(buf
);
595 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%d\n", priv
->temperature
);
596 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
600 static ssize_t
iwl_dbgfs_sleep_level_override_write(struct file
*file
,
601 const char __user
*user_buf
,
602 size_t count
, loff_t
*ppos
)
604 struct iwl_priv
*priv
= file
->private_data
;
609 memset(buf
, 0, sizeof(buf
));
610 buf_size
= min(count
, sizeof(buf
) - 1);
611 if (copy_from_user(buf
, user_buf
, buf_size
))
614 if (sscanf(buf
, "%d", &value
) != 1)
618 * Our users expect 0 to be "CAM", but 0 isn't actually
619 * valid here. However, let's not confuse them and present
620 * IWL_POWER_INDEX_1 as "1", not "0".
627 if (value
!= -1 && (value
< 0 || value
>= IWL_POWER_NUM
))
630 if (!iwl_is_ready_rf(priv
))
633 priv
->power_data
.debug_sleep_level_override
= value
;
635 mutex_lock(&priv
->mutex
);
636 iwl_power_update_mode(priv
, true);
637 mutex_unlock(&priv
->mutex
);
642 static ssize_t
iwl_dbgfs_sleep_level_override_read(struct file
*file
,
643 char __user
*user_buf
,
644 size_t count
, loff_t
*ppos
)
646 struct iwl_priv
*priv
= file
->private_data
;
649 const size_t bufsz
= sizeof(buf
);
651 /* see the write function */
652 value
= priv
->power_data
.debug_sleep_level_override
;
656 pos
= scnprintf(buf
, bufsz
, "%d\n", value
);
657 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
660 static ssize_t
iwl_dbgfs_current_sleep_command_read(struct file
*file
,
661 char __user
*user_buf
,
662 size_t count
, loff_t
*ppos
)
664 struct iwl_priv
*priv
= file
->private_data
;
667 const size_t bufsz
= sizeof(buf
);
668 struct iwl_powertable_cmd
*cmd
= &priv
->power_data
.sleep_cmd
;
670 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
671 "flags: %#.2x\n", le16_to_cpu(cmd
->flags
));
672 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
673 "RX/TX timeout: %d/%d usec\n",
674 le32_to_cpu(cmd
->rx_data_timeout
),
675 le32_to_cpu(cmd
->tx_data_timeout
));
676 for (i
= 0; i
< IWL_POWER_VEC_SIZE
; i
++)
677 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
678 "sleep_interval[%d]: %d\n", i
,
679 le32_to_cpu(cmd
->sleep_interval
[i
]));
681 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
684 DEBUGFS_READ_WRITE_FILE_OPS(sram
);
685 DEBUGFS_READ_FILE_OPS(wowlan_sram
);
686 DEBUGFS_READ_FILE_OPS(nvm
);
687 DEBUGFS_READ_FILE_OPS(stations
);
688 DEBUGFS_READ_FILE_OPS(channels
);
689 DEBUGFS_READ_FILE_OPS(status
);
690 DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers
);
691 DEBUGFS_READ_FILE_OPS(qos
);
692 DEBUGFS_READ_FILE_OPS(thermal_throttling
);
693 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40
);
694 DEBUGFS_READ_FILE_OPS(temperature
);
695 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override
);
696 DEBUGFS_READ_FILE_OPS(current_sleep_command
);
698 static const char *fmt_value
= " %-30s %10u\n";
699 static const char *fmt_hex
= " %-30s 0x%02X\n";
700 static const char *fmt_table
= " %-30s %10u %10u %10u %10u\n";
701 static const char *fmt_header
=
702 "%-32s current cumulative delta max\n";
704 static int iwl_statistics_flag(struct iwl_priv
*priv
, char *buf
, int bufsz
)
709 lockdep_assert_held(&priv
->statistics
.lock
);
711 flag
= le32_to_cpu(priv
->statistics
.flag
);
713 p
+= scnprintf(buf
+ p
, bufsz
- p
, "Statistics Flag(0x%X):\n", flag
);
714 if (flag
& UCODE_STATISTICS_CLEAR_MSK
)
715 p
+= scnprintf(buf
+ p
, bufsz
- p
,
716 "\tStatistics have been cleared\n");
717 p
+= scnprintf(buf
+ p
, bufsz
- p
, "\tOperational Frequency: %s\n",
718 (flag
& UCODE_STATISTICS_FREQUENCY_MSK
)
719 ? "2.4 GHz" : "5.2 GHz");
720 p
+= scnprintf(buf
+ p
, bufsz
- p
, "\tTGj Narrow Band: %s\n",
721 (flag
& UCODE_STATISTICS_NARROW_BAND_MSK
)
722 ? "enabled" : "disabled");
727 static ssize_t
iwl_dbgfs_ucode_rx_stats_read(struct file
*file
,
728 char __user
*user_buf
,
729 size_t count
, loff_t
*ppos
)
731 struct iwl_priv
*priv
= file
->private_data
;
734 int bufsz
= sizeof(struct statistics_rx_phy
) * 40 +
735 sizeof(struct statistics_rx_non_phy
) * 40 +
736 sizeof(struct statistics_rx_ht_phy
) * 40 + 400;
738 struct statistics_rx_phy
*ofdm
, *accum_ofdm
, *delta_ofdm
, *max_ofdm
;
739 struct statistics_rx_phy
*cck
, *accum_cck
, *delta_cck
, *max_cck
;
740 struct statistics_rx_non_phy
*general
, *accum_general
;
741 struct statistics_rx_non_phy
*delta_general
, *max_general
;
742 struct statistics_rx_ht_phy
*ht
, *accum_ht
, *delta_ht
, *max_ht
;
744 if (!iwl_is_alive(priv
))
747 buf
= kzalloc(bufsz
, GFP_KERNEL
);
752 * the statistic information display here is based on
753 * the last statistics notification from uCode
754 * might not reflect the current uCode activity
756 spin_lock_bh(&priv
->statistics
.lock
);
757 ofdm
= &priv
->statistics
.rx_ofdm
;
758 cck
= &priv
->statistics
.rx_cck
;
759 general
= &priv
->statistics
.rx_non_phy
;
760 ht
= &priv
->statistics
.rx_ofdm_ht
;
761 accum_ofdm
= &priv
->accum_stats
.rx_ofdm
;
762 accum_cck
= &priv
->accum_stats
.rx_cck
;
763 accum_general
= &priv
->accum_stats
.rx_non_phy
;
764 accum_ht
= &priv
->accum_stats
.rx_ofdm_ht
;
765 delta_ofdm
= &priv
->delta_stats
.rx_ofdm
;
766 delta_cck
= &priv
->delta_stats
.rx_cck
;
767 delta_general
= &priv
->delta_stats
.rx_non_phy
;
768 delta_ht
= &priv
->delta_stats
.rx_ofdm_ht
;
769 max_ofdm
= &priv
->max_delta_stats
.rx_ofdm
;
770 max_cck
= &priv
->max_delta_stats
.rx_cck
;
771 max_general
= &priv
->max_delta_stats
.rx_non_phy
;
772 max_ht
= &priv
->max_delta_stats
.rx_ofdm_ht
;
774 pos
+= iwl_statistics_flag(priv
, buf
, bufsz
);
775 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
776 fmt_header
, "Statistics_Rx - OFDM:");
777 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
778 fmt_table
, "ina_cnt:",
779 le32_to_cpu(ofdm
->ina_cnt
),
781 delta_ofdm
->ina_cnt
, max_ofdm
->ina_cnt
);
782 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
783 fmt_table
, "fina_cnt:",
784 le32_to_cpu(ofdm
->fina_cnt
), accum_ofdm
->fina_cnt
,
785 delta_ofdm
->fina_cnt
, max_ofdm
->fina_cnt
);
786 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
787 fmt_table
, "plcp_err:",
788 le32_to_cpu(ofdm
->plcp_err
), accum_ofdm
->plcp_err
,
789 delta_ofdm
->plcp_err
, max_ofdm
->plcp_err
);
790 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
791 fmt_table
, "crc32_err:",
792 le32_to_cpu(ofdm
->crc32_err
), accum_ofdm
->crc32_err
,
793 delta_ofdm
->crc32_err
, max_ofdm
->crc32_err
);
794 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
795 fmt_table
, "overrun_err:",
796 le32_to_cpu(ofdm
->overrun_err
),
797 accum_ofdm
->overrun_err
, delta_ofdm
->overrun_err
,
798 max_ofdm
->overrun_err
);
799 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
800 fmt_table
, "early_overrun_err:",
801 le32_to_cpu(ofdm
->early_overrun_err
),
802 accum_ofdm
->early_overrun_err
,
803 delta_ofdm
->early_overrun_err
,
804 max_ofdm
->early_overrun_err
);
805 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
806 fmt_table
, "crc32_good:",
807 le32_to_cpu(ofdm
->crc32_good
),
808 accum_ofdm
->crc32_good
, delta_ofdm
->crc32_good
,
809 max_ofdm
->crc32_good
);
810 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
811 fmt_table
, "false_alarm_cnt:",
812 le32_to_cpu(ofdm
->false_alarm_cnt
),
813 accum_ofdm
->false_alarm_cnt
,
814 delta_ofdm
->false_alarm_cnt
,
815 max_ofdm
->false_alarm_cnt
);
816 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
817 fmt_table
, "fina_sync_err_cnt:",
818 le32_to_cpu(ofdm
->fina_sync_err_cnt
),
819 accum_ofdm
->fina_sync_err_cnt
,
820 delta_ofdm
->fina_sync_err_cnt
,
821 max_ofdm
->fina_sync_err_cnt
);
822 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
823 fmt_table
, "sfd_timeout:",
824 le32_to_cpu(ofdm
->sfd_timeout
),
825 accum_ofdm
->sfd_timeout
, delta_ofdm
->sfd_timeout
,
826 max_ofdm
->sfd_timeout
);
827 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
828 fmt_table
, "fina_timeout:",
829 le32_to_cpu(ofdm
->fina_timeout
),
830 accum_ofdm
->fina_timeout
, delta_ofdm
->fina_timeout
,
831 max_ofdm
->fina_timeout
);
832 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
833 fmt_table
, "unresponded_rts:",
834 le32_to_cpu(ofdm
->unresponded_rts
),
835 accum_ofdm
->unresponded_rts
,
836 delta_ofdm
->unresponded_rts
,
837 max_ofdm
->unresponded_rts
);
838 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
839 fmt_table
, "rxe_frame_lmt_ovrun:",
840 le32_to_cpu(ofdm
->rxe_frame_limit_overrun
),
841 accum_ofdm
->rxe_frame_limit_overrun
,
842 delta_ofdm
->rxe_frame_limit_overrun
,
843 max_ofdm
->rxe_frame_limit_overrun
);
844 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
845 fmt_table
, "sent_ack_cnt:",
846 le32_to_cpu(ofdm
->sent_ack_cnt
),
847 accum_ofdm
->sent_ack_cnt
, delta_ofdm
->sent_ack_cnt
,
848 max_ofdm
->sent_ack_cnt
);
849 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
850 fmt_table
, "sent_cts_cnt:",
851 le32_to_cpu(ofdm
->sent_cts_cnt
),
852 accum_ofdm
->sent_cts_cnt
, delta_ofdm
->sent_cts_cnt
,
853 max_ofdm
->sent_cts_cnt
);
854 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
855 fmt_table
, "sent_ba_rsp_cnt:",
856 le32_to_cpu(ofdm
->sent_ba_rsp_cnt
),
857 accum_ofdm
->sent_ba_rsp_cnt
,
858 delta_ofdm
->sent_ba_rsp_cnt
,
859 max_ofdm
->sent_ba_rsp_cnt
);
860 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
861 fmt_table
, "dsp_self_kill:",
862 le32_to_cpu(ofdm
->dsp_self_kill
),
863 accum_ofdm
->dsp_self_kill
,
864 delta_ofdm
->dsp_self_kill
,
865 max_ofdm
->dsp_self_kill
);
866 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
867 fmt_table
, "mh_format_err:",
868 le32_to_cpu(ofdm
->mh_format_err
),
869 accum_ofdm
->mh_format_err
,
870 delta_ofdm
->mh_format_err
,
871 max_ofdm
->mh_format_err
);
872 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
873 fmt_table
, "re_acq_main_rssi_sum:",
874 le32_to_cpu(ofdm
->re_acq_main_rssi_sum
),
875 accum_ofdm
->re_acq_main_rssi_sum
,
876 delta_ofdm
->re_acq_main_rssi_sum
,
877 max_ofdm
->re_acq_main_rssi_sum
);
879 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
880 fmt_header
, "Statistics_Rx - CCK:");
881 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
882 fmt_table
, "ina_cnt:",
883 le32_to_cpu(cck
->ina_cnt
), accum_cck
->ina_cnt
,
884 delta_cck
->ina_cnt
, max_cck
->ina_cnt
);
885 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
886 fmt_table
, "fina_cnt:",
887 le32_to_cpu(cck
->fina_cnt
), accum_cck
->fina_cnt
,
888 delta_cck
->fina_cnt
, max_cck
->fina_cnt
);
889 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
890 fmt_table
, "plcp_err:",
891 le32_to_cpu(cck
->plcp_err
), accum_cck
->plcp_err
,
892 delta_cck
->plcp_err
, max_cck
->plcp_err
);
893 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
894 fmt_table
, "crc32_err:",
895 le32_to_cpu(cck
->crc32_err
), accum_cck
->crc32_err
,
896 delta_cck
->crc32_err
, max_cck
->crc32_err
);
897 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
898 fmt_table
, "overrun_err:",
899 le32_to_cpu(cck
->overrun_err
),
900 accum_cck
->overrun_err
, delta_cck
->overrun_err
,
901 max_cck
->overrun_err
);
902 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
903 fmt_table
, "early_overrun_err:",
904 le32_to_cpu(cck
->early_overrun_err
),
905 accum_cck
->early_overrun_err
,
906 delta_cck
->early_overrun_err
,
907 max_cck
->early_overrun_err
);
908 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
909 fmt_table
, "crc32_good:",
910 le32_to_cpu(cck
->crc32_good
), accum_cck
->crc32_good
,
911 delta_cck
->crc32_good
, max_cck
->crc32_good
);
912 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
913 fmt_table
, "false_alarm_cnt:",
914 le32_to_cpu(cck
->false_alarm_cnt
),
915 accum_cck
->false_alarm_cnt
,
916 delta_cck
->false_alarm_cnt
, max_cck
->false_alarm_cnt
);
917 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
918 fmt_table
, "fina_sync_err_cnt:",
919 le32_to_cpu(cck
->fina_sync_err_cnt
),
920 accum_cck
->fina_sync_err_cnt
,
921 delta_cck
->fina_sync_err_cnt
,
922 max_cck
->fina_sync_err_cnt
);
923 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
924 fmt_table
, "sfd_timeout:",
925 le32_to_cpu(cck
->sfd_timeout
),
926 accum_cck
->sfd_timeout
, delta_cck
->sfd_timeout
,
927 max_cck
->sfd_timeout
);
928 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
929 fmt_table
, "fina_timeout:",
930 le32_to_cpu(cck
->fina_timeout
),
931 accum_cck
->fina_timeout
, delta_cck
->fina_timeout
,
932 max_cck
->fina_timeout
);
933 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
934 fmt_table
, "unresponded_rts:",
935 le32_to_cpu(cck
->unresponded_rts
),
936 accum_cck
->unresponded_rts
, delta_cck
->unresponded_rts
,
937 max_cck
->unresponded_rts
);
938 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
939 fmt_table
, "rxe_frame_lmt_ovrun:",
940 le32_to_cpu(cck
->rxe_frame_limit_overrun
),
941 accum_cck
->rxe_frame_limit_overrun
,
942 delta_cck
->rxe_frame_limit_overrun
,
943 max_cck
->rxe_frame_limit_overrun
);
944 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
945 fmt_table
, "sent_ack_cnt:",
946 le32_to_cpu(cck
->sent_ack_cnt
),
947 accum_cck
->sent_ack_cnt
, delta_cck
->sent_ack_cnt
,
948 max_cck
->sent_ack_cnt
);
949 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
950 fmt_table
, "sent_cts_cnt:",
951 le32_to_cpu(cck
->sent_cts_cnt
),
952 accum_cck
->sent_cts_cnt
, delta_cck
->sent_cts_cnt
,
953 max_cck
->sent_cts_cnt
);
954 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
955 fmt_table
, "sent_ba_rsp_cnt:",
956 le32_to_cpu(cck
->sent_ba_rsp_cnt
),
957 accum_cck
->sent_ba_rsp_cnt
,
958 delta_cck
->sent_ba_rsp_cnt
,
959 max_cck
->sent_ba_rsp_cnt
);
960 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
961 fmt_table
, "dsp_self_kill:",
962 le32_to_cpu(cck
->dsp_self_kill
),
963 accum_cck
->dsp_self_kill
, delta_cck
->dsp_self_kill
,
964 max_cck
->dsp_self_kill
);
965 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
966 fmt_table
, "mh_format_err:",
967 le32_to_cpu(cck
->mh_format_err
),
968 accum_cck
->mh_format_err
, delta_cck
->mh_format_err
,
969 max_cck
->mh_format_err
);
970 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
971 fmt_table
, "re_acq_main_rssi_sum:",
972 le32_to_cpu(cck
->re_acq_main_rssi_sum
),
973 accum_cck
->re_acq_main_rssi_sum
,
974 delta_cck
->re_acq_main_rssi_sum
,
975 max_cck
->re_acq_main_rssi_sum
);
977 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
978 fmt_header
, "Statistics_Rx - GENERAL:");
979 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
980 fmt_table
, "bogus_cts:",
981 le32_to_cpu(general
->bogus_cts
),
982 accum_general
->bogus_cts
, delta_general
->bogus_cts
,
983 max_general
->bogus_cts
);
984 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
985 fmt_table
, "bogus_ack:",
986 le32_to_cpu(general
->bogus_ack
),
987 accum_general
->bogus_ack
, delta_general
->bogus_ack
,
988 max_general
->bogus_ack
);
989 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
990 fmt_table
, "non_bssid_frames:",
991 le32_to_cpu(general
->non_bssid_frames
),
992 accum_general
->non_bssid_frames
,
993 delta_general
->non_bssid_frames
,
994 max_general
->non_bssid_frames
);
995 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
996 fmt_table
, "filtered_frames:",
997 le32_to_cpu(general
->filtered_frames
),
998 accum_general
->filtered_frames
,
999 delta_general
->filtered_frames
,
1000 max_general
->filtered_frames
);
1001 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1002 fmt_table
, "non_channel_beacons:",
1003 le32_to_cpu(general
->non_channel_beacons
),
1004 accum_general
->non_channel_beacons
,
1005 delta_general
->non_channel_beacons
,
1006 max_general
->non_channel_beacons
);
1007 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1008 fmt_table
, "channel_beacons:",
1009 le32_to_cpu(general
->channel_beacons
),
1010 accum_general
->channel_beacons
,
1011 delta_general
->channel_beacons
,
1012 max_general
->channel_beacons
);
1013 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1014 fmt_table
, "num_missed_bcon:",
1015 le32_to_cpu(general
->num_missed_bcon
),
1016 accum_general
->num_missed_bcon
,
1017 delta_general
->num_missed_bcon
,
1018 max_general
->num_missed_bcon
);
1019 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1020 fmt_table
, "adc_rx_saturation_time:",
1021 le32_to_cpu(general
->adc_rx_saturation_time
),
1022 accum_general
->adc_rx_saturation_time
,
1023 delta_general
->adc_rx_saturation_time
,
1024 max_general
->adc_rx_saturation_time
);
1025 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1026 fmt_table
, "ina_detect_search_tm:",
1027 le32_to_cpu(general
->ina_detection_search_time
),
1028 accum_general
->ina_detection_search_time
,
1029 delta_general
->ina_detection_search_time
,
1030 max_general
->ina_detection_search_time
);
1031 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1032 fmt_table
, "beacon_silence_rssi_a:",
1033 le32_to_cpu(general
->beacon_silence_rssi_a
),
1034 accum_general
->beacon_silence_rssi_a
,
1035 delta_general
->beacon_silence_rssi_a
,
1036 max_general
->beacon_silence_rssi_a
);
1037 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1038 fmt_table
, "beacon_silence_rssi_b:",
1039 le32_to_cpu(general
->beacon_silence_rssi_b
),
1040 accum_general
->beacon_silence_rssi_b
,
1041 delta_general
->beacon_silence_rssi_b
,
1042 max_general
->beacon_silence_rssi_b
);
1043 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1044 fmt_table
, "beacon_silence_rssi_c:",
1045 le32_to_cpu(general
->beacon_silence_rssi_c
),
1046 accum_general
->beacon_silence_rssi_c
,
1047 delta_general
->beacon_silence_rssi_c
,
1048 max_general
->beacon_silence_rssi_c
);
1049 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1050 fmt_table
, "interference_data_flag:",
1051 le32_to_cpu(general
->interference_data_flag
),
1052 accum_general
->interference_data_flag
,
1053 delta_general
->interference_data_flag
,
1054 max_general
->interference_data_flag
);
1055 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1056 fmt_table
, "channel_load:",
1057 le32_to_cpu(general
->channel_load
),
1058 accum_general
->channel_load
,
1059 delta_general
->channel_load
,
1060 max_general
->channel_load
);
1061 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1062 fmt_table
, "dsp_false_alarms:",
1063 le32_to_cpu(general
->dsp_false_alarms
),
1064 accum_general
->dsp_false_alarms
,
1065 delta_general
->dsp_false_alarms
,
1066 max_general
->dsp_false_alarms
);
1067 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1068 fmt_table
, "beacon_rssi_a:",
1069 le32_to_cpu(general
->beacon_rssi_a
),
1070 accum_general
->beacon_rssi_a
,
1071 delta_general
->beacon_rssi_a
,
1072 max_general
->beacon_rssi_a
);
1073 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1074 fmt_table
, "beacon_rssi_b:",
1075 le32_to_cpu(general
->beacon_rssi_b
),
1076 accum_general
->beacon_rssi_b
,
1077 delta_general
->beacon_rssi_b
,
1078 max_general
->beacon_rssi_b
);
1079 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1080 fmt_table
, "beacon_rssi_c:",
1081 le32_to_cpu(general
->beacon_rssi_c
),
1082 accum_general
->beacon_rssi_c
,
1083 delta_general
->beacon_rssi_c
,
1084 max_general
->beacon_rssi_c
);
1085 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1086 fmt_table
, "beacon_energy_a:",
1087 le32_to_cpu(general
->beacon_energy_a
),
1088 accum_general
->beacon_energy_a
,
1089 delta_general
->beacon_energy_a
,
1090 max_general
->beacon_energy_a
);
1091 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1092 fmt_table
, "beacon_energy_b:",
1093 le32_to_cpu(general
->beacon_energy_b
),
1094 accum_general
->beacon_energy_b
,
1095 delta_general
->beacon_energy_b
,
1096 max_general
->beacon_energy_b
);
1097 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1098 fmt_table
, "beacon_energy_c:",
1099 le32_to_cpu(general
->beacon_energy_c
),
1100 accum_general
->beacon_energy_c
,
1101 delta_general
->beacon_energy_c
,
1102 max_general
->beacon_energy_c
);
1104 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1105 fmt_header
, "Statistics_Rx - OFDM_HT:");
1106 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1107 fmt_table
, "plcp_err:",
1108 le32_to_cpu(ht
->plcp_err
), accum_ht
->plcp_err
,
1109 delta_ht
->plcp_err
, max_ht
->plcp_err
);
1110 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1111 fmt_table
, "overrun_err:",
1112 le32_to_cpu(ht
->overrun_err
), accum_ht
->overrun_err
,
1113 delta_ht
->overrun_err
, max_ht
->overrun_err
);
1114 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1115 fmt_table
, "early_overrun_err:",
1116 le32_to_cpu(ht
->early_overrun_err
),
1117 accum_ht
->early_overrun_err
,
1118 delta_ht
->early_overrun_err
,
1119 max_ht
->early_overrun_err
);
1120 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1121 fmt_table
, "crc32_good:",
1122 le32_to_cpu(ht
->crc32_good
), accum_ht
->crc32_good
,
1123 delta_ht
->crc32_good
, max_ht
->crc32_good
);
1124 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1125 fmt_table
, "crc32_err:",
1126 le32_to_cpu(ht
->crc32_err
), accum_ht
->crc32_err
,
1127 delta_ht
->crc32_err
, max_ht
->crc32_err
);
1128 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1129 fmt_table
, "mh_format_err:",
1130 le32_to_cpu(ht
->mh_format_err
),
1131 accum_ht
->mh_format_err
,
1132 delta_ht
->mh_format_err
, max_ht
->mh_format_err
);
1133 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1134 fmt_table
, "agg_crc32_good:",
1135 le32_to_cpu(ht
->agg_crc32_good
),
1136 accum_ht
->agg_crc32_good
,
1137 delta_ht
->agg_crc32_good
, max_ht
->agg_crc32_good
);
1138 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1139 fmt_table
, "agg_mpdu_cnt:",
1140 le32_to_cpu(ht
->agg_mpdu_cnt
),
1141 accum_ht
->agg_mpdu_cnt
,
1142 delta_ht
->agg_mpdu_cnt
, max_ht
->agg_mpdu_cnt
);
1143 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1144 fmt_table
, "agg_cnt:",
1145 le32_to_cpu(ht
->agg_cnt
), accum_ht
->agg_cnt
,
1146 delta_ht
->agg_cnt
, max_ht
->agg_cnt
);
1147 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1148 fmt_table
, "unsupport_mcs:",
1149 le32_to_cpu(ht
->unsupport_mcs
),
1150 accum_ht
->unsupport_mcs
,
1151 delta_ht
->unsupport_mcs
, max_ht
->unsupport_mcs
);
1153 spin_unlock_bh(&priv
->statistics
.lock
);
1155 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1160 static ssize_t
iwl_dbgfs_ucode_tx_stats_read(struct file
*file
,
1161 char __user
*user_buf
,
1162 size_t count
, loff_t
*ppos
)
1164 struct iwl_priv
*priv
= file
->private_data
;
1167 int bufsz
= (sizeof(struct statistics_tx
) * 48) + 250;
1169 struct statistics_tx
*tx
, *accum_tx
, *delta_tx
, *max_tx
;
1171 if (!iwl_is_alive(priv
))
1174 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1178 /* the statistic information display here is based on
1179 * the last statistics notification from uCode
1180 * might not reflect the current uCode activity
1182 spin_lock_bh(&priv
->statistics
.lock
);
1184 tx
= &priv
->statistics
.tx
;
1185 accum_tx
= &priv
->accum_stats
.tx
;
1186 delta_tx
= &priv
->delta_stats
.tx
;
1187 max_tx
= &priv
->max_delta_stats
.tx
;
1189 pos
+= iwl_statistics_flag(priv
, buf
, bufsz
);
1190 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1191 fmt_header
, "Statistics_Tx:");
1192 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1193 fmt_table
, "preamble:",
1194 le32_to_cpu(tx
->preamble_cnt
),
1195 accum_tx
->preamble_cnt
,
1196 delta_tx
->preamble_cnt
, max_tx
->preamble_cnt
);
1197 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1198 fmt_table
, "rx_detected_cnt:",
1199 le32_to_cpu(tx
->rx_detected_cnt
),
1200 accum_tx
->rx_detected_cnt
,
1201 delta_tx
->rx_detected_cnt
, max_tx
->rx_detected_cnt
);
1202 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1203 fmt_table
, "bt_prio_defer_cnt:",
1204 le32_to_cpu(tx
->bt_prio_defer_cnt
),
1205 accum_tx
->bt_prio_defer_cnt
,
1206 delta_tx
->bt_prio_defer_cnt
,
1207 max_tx
->bt_prio_defer_cnt
);
1208 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1209 fmt_table
, "bt_prio_kill_cnt:",
1210 le32_to_cpu(tx
->bt_prio_kill_cnt
),
1211 accum_tx
->bt_prio_kill_cnt
,
1212 delta_tx
->bt_prio_kill_cnt
,
1213 max_tx
->bt_prio_kill_cnt
);
1214 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1215 fmt_table
, "few_bytes_cnt:",
1216 le32_to_cpu(tx
->few_bytes_cnt
),
1217 accum_tx
->few_bytes_cnt
,
1218 delta_tx
->few_bytes_cnt
, max_tx
->few_bytes_cnt
);
1219 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1220 fmt_table
, "cts_timeout:",
1221 le32_to_cpu(tx
->cts_timeout
), accum_tx
->cts_timeout
,
1222 delta_tx
->cts_timeout
, max_tx
->cts_timeout
);
1223 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1224 fmt_table
, "ack_timeout:",
1225 le32_to_cpu(tx
->ack_timeout
),
1226 accum_tx
->ack_timeout
,
1227 delta_tx
->ack_timeout
, max_tx
->ack_timeout
);
1228 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1229 fmt_table
, "expected_ack_cnt:",
1230 le32_to_cpu(tx
->expected_ack_cnt
),
1231 accum_tx
->expected_ack_cnt
,
1232 delta_tx
->expected_ack_cnt
,
1233 max_tx
->expected_ack_cnt
);
1234 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1235 fmt_table
, "actual_ack_cnt:",
1236 le32_to_cpu(tx
->actual_ack_cnt
),
1237 accum_tx
->actual_ack_cnt
,
1238 delta_tx
->actual_ack_cnt
,
1239 max_tx
->actual_ack_cnt
);
1240 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1241 fmt_table
, "dump_msdu_cnt:",
1242 le32_to_cpu(tx
->dump_msdu_cnt
),
1243 accum_tx
->dump_msdu_cnt
,
1244 delta_tx
->dump_msdu_cnt
,
1245 max_tx
->dump_msdu_cnt
);
1246 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1247 fmt_table
, "abort_nxt_frame_mismatch:",
1248 le32_to_cpu(tx
->burst_abort_next_frame_mismatch_cnt
),
1249 accum_tx
->burst_abort_next_frame_mismatch_cnt
,
1250 delta_tx
->burst_abort_next_frame_mismatch_cnt
,
1251 max_tx
->burst_abort_next_frame_mismatch_cnt
);
1252 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1253 fmt_table
, "abort_missing_nxt_frame:",
1254 le32_to_cpu(tx
->burst_abort_missing_next_frame_cnt
),
1255 accum_tx
->burst_abort_missing_next_frame_cnt
,
1256 delta_tx
->burst_abort_missing_next_frame_cnt
,
1257 max_tx
->burst_abort_missing_next_frame_cnt
);
1258 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1259 fmt_table
, "cts_timeout_collision:",
1260 le32_to_cpu(tx
->cts_timeout_collision
),
1261 accum_tx
->cts_timeout_collision
,
1262 delta_tx
->cts_timeout_collision
,
1263 max_tx
->cts_timeout_collision
);
1264 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1265 fmt_table
, "ack_ba_timeout_collision:",
1266 le32_to_cpu(tx
->ack_or_ba_timeout_collision
),
1267 accum_tx
->ack_or_ba_timeout_collision
,
1268 delta_tx
->ack_or_ba_timeout_collision
,
1269 max_tx
->ack_or_ba_timeout_collision
);
1270 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1271 fmt_table
, "agg ba_timeout:",
1272 le32_to_cpu(tx
->agg
.ba_timeout
),
1273 accum_tx
->agg
.ba_timeout
,
1274 delta_tx
->agg
.ba_timeout
,
1275 max_tx
->agg
.ba_timeout
);
1276 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1277 fmt_table
, "agg ba_resched_frames:",
1278 le32_to_cpu(tx
->agg
.ba_reschedule_frames
),
1279 accum_tx
->agg
.ba_reschedule_frames
,
1280 delta_tx
->agg
.ba_reschedule_frames
,
1281 max_tx
->agg
.ba_reschedule_frames
);
1282 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1283 fmt_table
, "agg scd_query_agg_frame:",
1284 le32_to_cpu(tx
->agg
.scd_query_agg_frame_cnt
),
1285 accum_tx
->agg
.scd_query_agg_frame_cnt
,
1286 delta_tx
->agg
.scd_query_agg_frame_cnt
,
1287 max_tx
->agg
.scd_query_agg_frame_cnt
);
1288 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1289 fmt_table
, "agg scd_query_no_agg:",
1290 le32_to_cpu(tx
->agg
.scd_query_no_agg
),
1291 accum_tx
->agg
.scd_query_no_agg
,
1292 delta_tx
->agg
.scd_query_no_agg
,
1293 max_tx
->agg
.scd_query_no_agg
);
1294 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1295 fmt_table
, "agg scd_query_agg:",
1296 le32_to_cpu(tx
->agg
.scd_query_agg
),
1297 accum_tx
->agg
.scd_query_agg
,
1298 delta_tx
->agg
.scd_query_agg
,
1299 max_tx
->agg
.scd_query_agg
);
1300 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1301 fmt_table
, "agg scd_query_mismatch:",
1302 le32_to_cpu(tx
->agg
.scd_query_mismatch
),
1303 accum_tx
->agg
.scd_query_mismatch
,
1304 delta_tx
->agg
.scd_query_mismatch
,
1305 max_tx
->agg
.scd_query_mismatch
);
1306 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1307 fmt_table
, "agg frame_not_ready:",
1308 le32_to_cpu(tx
->agg
.frame_not_ready
),
1309 accum_tx
->agg
.frame_not_ready
,
1310 delta_tx
->agg
.frame_not_ready
,
1311 max_tx
->agg
.frame_not_ready
);
1312 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1313 fmt_table
, "agg underrun:",
1314 le32_to_cpu(tx
->agg
.underrun
),
1315 accum_tx
->agg
.underrun
,
1316 delta_tx
->agg
.underrun
, max_tx
->agg
.underrun
);
1317 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1318 fmt_table
, "agg bt_prio_kill:",
1319 le32_to_cpu(tx
->agg
.bt_prio_kill
),
1320 accum_tx
->agg
.bt_prio_kill
,
1321 delta_tx
->agg
.bt_prio_kill
,
1322 max_tx
->agg
.bt_prio_kill
);
1323 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1324 fmt_table
, "agg rx_ba_rsp_cnt:",
1325 le32_to_cpu(tx
->agg
.rx_ba_rsp_cnt
),
1326 accum_tx
->agg
.rx_ba_rsp_cnt
,
1327 delta_tx
->agg
.rx_ba_rsp_cnt
,
1328 max_tx
->agg
.rx_ba_rsp_cnt
);
1330 if (tx
->tx_power
.ant_a
|| tx
->tx_power
.ant_b
|| tx
->tx_power
.ant_c
) {
1331 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1332 "tx power: (1/2 dB step)\n");
1333 if ((priv
->eeprom_data
->valid_tx_ant
& ANT_A
) &&
1335 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1336 fmt_hex
, "antenna A:",
1337 tx
->tx_power
.ant_a
);
1338 if ((priv
->eeprom_data
->valid_tx_ant
& ANT_B
) &&
1340 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1341 fmt_hex
, "antenna B:",
1342 tx
->tx_power
.ant_b
);
1343 if ((priv
->eeprom_data
->valid_tx_ant
& ANT_C
) &&
1345 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1346 fmt_hex
, "antenna C:",
1347 tx
->tx_power
.ant_c
);
1350 spin_unlock_bh(&priv
->statistics
.lock
);
1352 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1357 static ssize_t
iwl_dbgfs_ucode_general_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
;
1364 int bufsz
= sizeof(struct statistics_general
) * 10 + 300;
1366 struct statistics_general_common
*general
, *accum_general
;
1367 struct statistics_general_common
*delta_general
, *max_general
;
1368 struct statistics_dbg
*dbg
, *accum_dbg
, *delta_dbg
, *max_dbg
;
1369 struct statistics_div
*div
, *accum_div
, *delta_div
, *max_div
;
1371 if (!iwl_is_alive(priv
))
1374 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1378 /* the statistic information display here is based on
1379 * the last statistics notification from uCode
1380 * might not reflect the current uCode activity
1383 spin_lock_bh(&priv
->statistics
.lock
);
1385 general
= &priv
->statistics
.common
;
1386 dbg
= &priv
->statistics
.common
.dbg
;
1387 div
= &priv
->statistics
.common
.div
;
1388 accum_general
= &priv
->accum_stats
.common
;
1389 accum_dbg
= &priv
->accum_stats
.common
.dbg
;
1390 accum_div
= &priv
->accum_stats
.common
.div
;
1391 delta_general
= &priv
->delta_stats
.common
;
1392 max_general
= &priv
->max_delta_stats
.common
;
1393 delta_dbg
= &priv
->delta_stats
.common
.dbg
;
1394 max_dbg
= &priv
->max_delta_stats
.common
.dbg
;
1395 delta_div
= &priv
->delta_stats
.common
.div
;
1396 max_div
= &priv
->max_delta_stats
.common
.div
;
1398 pos
+= iwl_statistics_flag(priv
, buf
, bufsz
);
1399 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1400 fmt_header
, "Statistics_General:");
1401 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1402 fmt_value
, "temperature:",
1403 le32_to_cpu(general
->temperature
));
1404 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1405 fmt_value
, "temperature_m:",
1406 le32_to_cpu(general
->temperature_m
));
1407 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1408 fmt_value
, "ttl_timestamp:",
1409 le32_to_cpu(general
->ttl_timestamp
));
1410 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1411 fmt_table
, "burst_check:",
1412 le32_to_cpu(dbg
->burst_check
),
1413 accum_dbg
->burst_check
,
1414 delta_dbg
->burst_check
, max_dbg
->burst_check
);
1415 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1416 fmt_table
, "burst_count:",
1417 le32_to_cpu(dbg
->burst_count
),
1418 accum_dbg
->burst_count
,
1419 delta_dbg
->burst_count
, max_dbg
->burst_count
);
1420 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1421 fmt_table
, "wait_for_silence_timeout_count:",
1422 le32_to_cpu(dbg
->wait_for_silence_timeout_cnt
),
1423 accum_dbg
->wait_for_silence_timeout_cnt
,
1424 delta_dbg
->wait_for_silence_timeout_cnt
,
1425 max_dbg
->wait_for_silence_timeout_cnt
);
1426 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1427 fmt_table
, "sleep_time:",
1428 le32_to_cpu(general
->sleep_time
),
1429 accum_general
->sleep_time
,
1430 delta_general
->sleep_time
, max_general
->sleep_time
);
1431 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1432 fmt_table
, "slots_out:",
1433 le32_to_cpu(general
->slots_out
),
1434 accum_general
->slots_out
,
1435 delta_general
->slots_out
, max_general
->slots_out
);
1436 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1437 fmt_table
, "slots_idle:",
1438 le32_to_cpu(general
->slots_idle
),
1439 accum_general
->slots_idle
,
1440 delta_general
->slots_idle
, max_general
->slots_idle
);
1441 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1442 fmt_table
, "tx_on_a:",
1443 le32_to_cpu(div
->tx_on_a
), accum_div
->tx_on_a
,
1444 delta_div
->tx_on_a
, max_div
->tx_on_a
);
1445 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1446 fmt_table
, "tx_on_b:",
1447 le32_to_cpu(div
->tx_on_b
), accum_div
->tx_on_b
,
1448 delta_div
->tx_on_b
, max_div
->tx_on_b
);
1449 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1450 fmt_table
, "exec_time:",
1451 le32_to_cpu(div
->exec_time
), accum_div
->exec_time
,
1452 delta_div
->exec_time
, max_div
->exec_time
);
1453 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1454 fmt_table
, "probe_time:",
1455 le32_to_cpu(div
->probe_time
), accum_div
->probe_time
,
1456 delta_div
->probe_time
, max_div
->probe_time
);
1457 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1458 fmt_table
, "rx_enable_counter:",
1459 le32_to_cpu(general
->rx_enable_counter
),
1460 accum_general
->rx_enable_counter
,
1461 delta_general
->rx_enable_counter
,
1462 max_general
->rx_enable_counter
);
1463 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1464 fmt_table
, "num_of_sos_states:",
1465 le32_to_cpu(general
->num_of_sos_states
),
1466 accum_general
->num_of_sos_states
,
1467 delta_general
->num_of_sos_states
,
1468 max_general
->num_of_sos_states
);
1470 spin_unlock_bh(&priv
->statistics
.lock
);
1472 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1477 static ssize_t
iwl_dbgfs_ucode_bt_stats_read(struct file
*file
,
1478 char __user
*user_buf
,
1479 size_t count
, loff_t
*ppos
)
1481 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
1484 int bufsz
= (sizeof(struct statistics_bt_activity
) * 24) + 200;
1486 struct statistics_bt_activity
*bt
, *accum_bt
;
1488 if (!iwl_is_alive(priv
))
1491 if (!priv
->bt_enable_flag
)
1494 /* make request to uCode to retrieve statistics information */
1495 mutex_lock(&priv
->mutex
);
1496 ret
= iwl_send_statistics_request(priv
, CMD_SYNC
, false);
1497 mutex_unlock(&priv
->mutex
);
1501 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1506 * the statistic information display here is based on
1507 * the last statistics notification from uCode
1508 * might not reflect the current uCode activity
1511 spin_lock_bh(&priv
->statistics
.lock
);
1513 bt
= &priv
->statistics
.bt_activity
;
1514 accum_bt
= &priv
->accum_stats
.bt_activity
;
1516 pos
+= iwl_statistics_flag(priv
, buf
, bufsz
);
1517 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Statistics_BT:\n");
1518 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1519 "\t\t\tcurrent\t\t\taccumulative\n");
1520 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1521 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1522 le32_to_cpu(bt
->hi_priority_tx_req_cnt
),
1523 accum_bt
->hi_priority_tx_req_cnt
);
1524 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1525 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1526 le32_to_cpu(bt
->hi_priority_tx_denied_cnt
),
1527 accum_bt
->hi_priority_tx_denied_cnt
);
1528 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1529 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1530 le32_to_cpu(bt
->lo_priority_tx_req_cnt
),
1531 accum_bt
->lo_priority_tx_req_cnt
);
1532 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1533 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1534 le32_to_cpu(bt
->lo_priority_tx_denied_cnt
),
1535 accum_bt
->lo_priority_tx_denied_cnt
);
1536 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1537 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1538 le32_to_cpu(bt
->hi_priority_rx_req_cnt
),
1539 accum_bt
->hi_priority_rx_req_cnt
);
1540 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1541 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1542 le32_to_cpu(bt
->hi_priority_rx_denied_cnt
),
1543 accum_bt
->hi_priority_rx_denied_cnt
);
1544 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1545 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1546 le32_to_cpu(bt
->lo_priority_rx_req_cnt
),
1547 accum_bt
->lo_priority_rx_req_cnt
);
1548 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1549 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1550 le32_to_cpu(bt
->lo_priority_rx_denied_cnt
),
1551 accum_bt
->lo_priority_rx_denied_cnt
);
1553 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1554 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1555 le32_to_cpu(priv
->statistics
.num_bt_kills
),
1556 priv
->statistics
.accum_num_bt_kills
);
1558 spin_unlock_bh(&priv
->statistics
.lock
);
1560 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1565 static ssize_t
iwl_dbgfs_reply_tx_error_read(struct file
*file
,
1566 char __user
*user_buf
,
1567 size_t count
, loff_t
*ppos
)
1569 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
1572 int bufsz
= (sizeof(struct reply_tx_error_statistics
) * 24) +
1573 (sizeof(struct reply_agg_tx_error_statistics
) * 24) + 200;
1576 if (!iwl_is_alive(priv
))
1579 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1583 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Statistics_TX_Error:\n");
1584 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t\t%u\n",
1585 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY
),
1586 priv
->reply_tx_stats
.pp_delay
);
1587 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1588 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES
),
1589 priv
->reply_tx_stats
.pp_few_bytes
);
1590 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1591 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO
),
1592 priv
->reply_tx_stats
.pp_bt_prio
);
1593 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1594 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD
),
1595 priv
->reply_tx_stats
.pp_quiet_period
);
1596 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1597 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK
),
1598 priv
->reply_tx_stats
.pp_calc_ttak
);
1599 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1600 iwl_get_tx_fail_reason(
1601 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY
),
1602 priv
->reply_tx_stats
.int_crossed_retry
);
1603 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1604 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT
),
1605 priv
->reply_tx_stats
.short_limit
);
1606 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1607 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT
),
1608 priv
->reply_tx_stats
.long_limit
);
1609 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1610 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN
),
1611 priv
->reply_tx_stats
.fifo_underrun
);
1612 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1613 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW
),
1614 priv
->reply_tx_stats
.drain_flow
);
1615 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1616 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH
),
1617 priv
->reply_tx_stats
.rfkill_flush
);
1618 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1619 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE
),
1620 priv
->reply_tx_stats
.life_expire
);
1621 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1622 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS
),
1623 priv
->reply_tx_stats
.dest_ps
);
1624 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1625 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED
),
1626 priv
->reply_tx_stats
.host_abort
);
1627 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1628 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY
),
1629 priv
->reply_tx_stats
.pp_delay
);
1630 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1631 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID
),
1632 priv
->reply_tx_stats
.sta_invalid
);
1633 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1634 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED
),
1635 priv
->reply_tx_stats
.frag_drop
);
1636 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1637 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE
),
1638 priv
->reply_tx_stats
.tid_disable
);
1639 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1640 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED
),
1641 priv
->reply_tx_stats
.fifo_flush
);
1642 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1643 iwl_get_tx_fail_reason(
1644 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL
),
1645 priv
->reply_tx_stats
.insuff_cf_poll
);
1646 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1647 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX
),
1648 priv
->reply_tx_stats
.fail_hw_drop
);
1649 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1650 iwl_get_tx_fail_reason(
1651 TX_STATUS_FAIL_NO_BEACON_ON_RADAR
),
1652 priv
->reply_tx_stats
.sta_color_mismatch
);
1653 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "UNKNOWN:\t\t\t%u\n",
1654 priv
->reply_tx_stats
.unknown
);
1656 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1657 "\nStatistics_Agg_TX_Error:\n");
1659 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1660 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK
),
1661 priv
->reply_agg_tx_stats
.underrun
);
1662 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1663 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK
),
1664 priv
->reply_agg_tx_stats
.bt_prio
);
1665 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1666 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK
),
1667 priv
->reply_agg_tx_stats
.few_bytes
);
1668 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1669 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK
),
1670 priv
->reply_agg_tx_stats
.abort
);
1671 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1672 iwl_get_agg_tx_fail_reason(
1673 AGG_TX_STATE_LAST_SENT_TTL_MSK
),
1674 priv
->reply_agg_tx_stats
.last_sent_ttl
);
1675 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1676 iwl_get_agg_tx_fail_reason(
1677 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK
),
1678 priv
->reply_agg_tx_stats
.last_sent_try
);
1679 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1680 iwl_get_agg_tx_fail_reason(
1681 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK
),
1682 priv
->reply_agg_tx_stats
.last_sent_bt_kill
);
1683 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1684 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK
),
1685 priv
->reply_agg_tx_stats
.scd_query
);
1686 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t%u\n",
1687 iwl_get_agg_tx_fail_reason(
1688 AGG_TX_STATE_TEST_BAD_CRC32_MSK
),
1689 priv
->reply_agg_tx_stats
.bad_crc32
);
1690 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1691 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK
),
1692 priv
->reply_agg_tx_stats
.response
);
1693 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1694 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK
),
1695 priv
->reply_agg_tx_stats
.dump_tx
);
1696 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s:\t\t\t%u\n",
1697 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK
),
1698 priv
->reply_agg_tx_stats
.delay_tx
);
1699 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "UNKNOWN:\t\t\t%u\n",
1700 priv
->reply_agg_tx_stats
.unknown
);
1702 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1707 static ssize_t
iwl_dbgfs_sensitivity_read(struct file
*file
,
1708 char __user
*user_buf
,
1709 size_t count
, loff_t
*ppos
) {
1711 struct iwl_priv
*priv
= file
->private_data
;
1715 int bufsz
= sizeof(struct iwl_sensitivity_data
) * 4 + 100;
1717 struct iwl_sensitivity_data
*data
;
1719 data
= &priv
->sensitivity_data
;
1720 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1724 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_ofdm:\t\t\t %u\n",
1725 data
->auto_corr_ofdm
);
1726 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1727 "auto_corr_ofdm_mrc:\t\t %u\n",
1728 data
->auto_corr_ofdm_mrc
);
1729 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_ofdm_x1:\t\t %u\n",
1730 data
->auto_corr_ofdm_x1
);
1731 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1732 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1733 data
->auto_corr_ofdm_mrc_x1
);
1734 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_cck:\t\t\t %u\n",
1735 data
->auto_corr_cck
);
1736 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_cck_mrc:\t\t %u\n",
1737 data
->auto_corr_cck_mrc
);
1738 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1739 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1740 data
->last_bad_plcp_cnt_ofdm
);
1741 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "last_fa_cnt_ofdm:\t\t %u\n",
1742 data
->last_fa_cnt_ofdm
);
1743 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1744 "last_bad_plcp_cnt_cck:\t\t %u\n",
1745 data
->last_bad_plcp_cnt_cck
);
1746 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "last_fa_cnt_cck:\t\t %u\n",
1747 data
->last_fa_cnt_cck
);
1748 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_curr_state:\t\t\t %u\n",
1749 data
->nrg_curr_state
);
1750 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_prev_state:\t\t\t %u\n",
1751 data
->nrg_prev_state
);
1752 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_value:\t\t\t");
1753 for (cnt
= 0; cnt
< 10; cnt
++) {
1754 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1755 data
->nrg_value
[cnt
]);
1757 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1758 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_silence_rssi:\t\t");
1759 for (cnt
= 0; cnt
< NRG_NUM_PREV_STAT_L
; cnt
++) {
1760 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1761 data
->nrg_silence_rssi
[cnt
]);
1763 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1764 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_silence_ref:\t\t %u\n",
1765 data
->nrg_silence_ref
);
1766 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_energy_idx:\t\t\t %u\n",
1767 data
->nrg_energy_idx
);
1768 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_silence_idx:\t\t %u\n",
1769 data
->nrg_silence_idx
);
1770 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_th_cck:\t\t\t %u\n",
1772 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1773 "nrg_auto_corr_silence_diff:\t %u\n",
1774 data
->nrg_auto_corr_silence_diff
);
1775 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "num_in_cck_no_fa:\t\t %u\n",
1776 data
->num_in_cck_no_fa
);
1777 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_th_ofdm:\t\t\t %u\n",
1780 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1786 static ssize_t
iwl_dbgfs_chain_noise_read(struct file
*file
,
1787 char __user
*user_buf
,
1788 size_t count
, loff_t
*ppos
) {
1790 struct iwl_priv
*priv
= file
->private_data
;
1794 int bufsz
= sizeof(struct iwl_chain_noise_data
) * 4 + 100;
1796 struct iwl_chain_noise_data
*data
;
1798 data
= &priv
->chain_noise_data
;
1799 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1803 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "active_chains:\t\t\t %u\n",
1804 data
->active_chains
);
1805 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_noise_a:\t\t\t %u\n",
1806 data
->chain_noise_a
);
1807 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_noise_b:\t\t\t %u\n",
1808 data
->chain_noise_b
);
1809 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_noise_c:\t\t\t %u\n",
1810 data
->chain_noise_c
);
1811 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_signal_a:\t\t\t %u\n",
1812 data
->chain_signal_a
);
1813 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_signal_b:\t\t\t %u\n",
1814 data
->chain_signal_b
);
1815 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_signal_c:\t\t\t %u\n",
1816 data
->chain_signal_c
);
1817 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "beacon_count:\t\t\t %u\n",
1818 data
->beacon_count
);
1820 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "disconn_array:\t\t\t");
1821 for (cnt
= 0; cnt
< NUM_RX_CHAINS
; cnt
++) {
1822 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1823 data
->disconn_array
[cnt
]);
1825 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1826 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "delta_gain_code:\t\t");
1827 for (cnt
= 0; cnt
< NUM_RX_CHAINS
; cnt
++) {
1828 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1829 data
->delta_gain_code
[cnt
]);
1831 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1832 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "radio_write:\t\t\t %u\n",
1834 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "state:\t\t\t\t %u\n",
1837 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1842 static ssize_t
iwl_dbgfs_power_save_status_read(struct file
*file
,
1843 char __user
*user_buf
,
1844 size_t count
, loff_t
*ppos
)
1846 struct iwl_priv
*priv
= file
->private_data
;
1849 const size_t bufsz
= sizeof(buf
);
1852 pwrsave_status
= iwl_read32(priv
->trans
, CSR_GP_CNTRL
) &
1853 CSR_GP_REG_POWER_SAVE_STATUS_MSK
;
1855 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Power Save Status: ");
1856 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s\n",
1857 (pwrsave_status
== CSR_GP_REG_NO_POWER_SAVE
) ? "none" :
1858 (pwrsave_status
== CSR_GP_REG_MAC_POWER_SAVE
) ? "MAC" :
1859 (pwrsave_status
== CSR_GP_REG_PHY_POWER_SAVE
) ? "PHY" :
1862 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1865 static ssize_t
iwl_dbgfs_clear_ucode_statistics_write(struct file
*file
,
1866 const char __user
*user_buf
,
1867 size_t count
, loff_t
*ppos
)
1869 struct iwl_priv
*priv
= file
->private_data
;
1874 memset(buf
, 0, sizeof(buf
));
1875 buf_size
= min(count
, sizeof(buf
) - 1);
1876 if (copy_from_user(buf
, user_buf
, buf_size
))
1878 if (sscanf(buf
, "%d", &clear
) != 1)
1881 /* make request to uCode to retrieve statistics information */
1882 mutex_lock(&priv
->mutex
);
1883 iwl_send_statistics_request(priv
, CMD_SYNC
, true);
1884 mutex_unlock(&priv
->mutex
);
1889 static ssize_t
iwl_dbgfs_ucode_tracing_read(struct file
*file
,
1890 char __user
*user_buf
,
1891 size_t count
, loff_t
*ppos
) {
1893 struct iwl_priv
*priv
= file
->private_data
;
1896 const size_t bufsz
= sizeof(buf
);
1898 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "ucode trace timer is %s\n",
1899 priv
->event_log
.ucode_trace
? "On" : "Off");
1900 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "non_wraps_count:\t\t %u\n",
1901 priv
->event_log
.non_wraps_count
);
1902 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "wraps_once_count:\t\t %u\n",
1903 priv
->event_log
.wraps_once_count
);
1904 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "wraps_more_count:\t\t %u\n",
1905 priv
->event_log
.wraps_more_count
);
1907 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1910 static ssize_t
iwl_dbgfs_ucode_tracing_write(struct file
*file
,
1911 const char __user
*user_buf
,
1912 size_t count
, loff_t
*ppos
)
1914 struct iwl_priv
*priv
= file
->private_data
;
1919 memset(buf
, 0, sizeof(buf
));
1920 buf_size
= min(count
, sizeof(buf
) - 1);
1921 if (copy_from_user(buf
, user_buf
, buf_size
))
1923 if (sscanf(buf
, "%d", &trace
) != 1)
1927 priv
->event_log
.ucode_trace
= true;
1928 if (iwl_is_alive(priv
)) {
1929 /* start collecting data now */
1930 mod_timer(&priv
->ucode_trace
, jiffies
);
1933 priv
->event_log
.ucode_trace
= false;
1934 del_timer_sync(&priv
->ucode_trace
);
1940 static ssize_t
iwl_dbgfs_rxon_flags_read(struct file
*file
,
1941 char __user
*user_buf
,
1942 size_t count
, loff_t
*ppos
) {
1944 struct iwl_priv
*priv
= file
->private_data
;
1948 len
= sprintf(buf
, "0x%04X\n",
1949 le32_to_cpu(priv
->contexts
[IWL_RXON_CTX_BSS
].active
.flags
));
1950 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1953 static ssize_t
iwl_dbgfs_rxon_filter_flags_read(struct file
*file
,
1954 char __user
*user_buf
,
1955 size_t count
, loff_t
*ppos
) {
1957 struct iwl_priv
*priv
= file
->private_data
;
1961 len
= sprintf(buf
, "0x%04X\n",
1962 le32_to_cpu(priv
->contexts
[IWL_RXON_CTX_BSS
].active
.filter_flags
));
1963 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
1966 static ssize_t
iwl_dbgfs_missed_beacon_read(struct file
*file
,
1967 char __user
*user_buf
,
1968 size_t count
, loff_t
*ppos
) {
1970 struct iwl_priv
*priv
= file
->private_data
;
1973 const size_t bufsz
= sizeof(buf
);
1975 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%d\n",
1976 priv
->missed_beacon_threshold
);
1978 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1981 static ssize_t
iwl_dbgfs_missed_beacon_write(struct file
*file
,
1982 const char __user
*user_buf
,
1983 size_t count
, loff_t
*ppos
)
1985 struct iwl_priv
*priv
= file
->private_data
;
1990 memset(buf
, 0, sizeof(buf
));
1991 buf_size
= min(count
, sizeof(buf
) - 1);
1992 if (copy_from_user(buf
, user_buf
, buf_size
))
1994 if (sscanf(buf
, "%d", &missed
) != 1)
1997 if (missed
< IWL_MISSED_BEACON_THRESHOLD_MIN
||
1998 missed
> IWL_MISSED_BEACON_THRESHOLD_MAX
)
1999 priv
->missed_beacon_threshold
=
2000 IWL_MISSED_BEACON_THRESHOLD_DEF
;
2002 priv
->missed_beacon_threshold
= missed
;
2007 static ssize_t
iwl_dbgfs_plcp_delta_read(struct file
*file
,
2008 char __user
*user_buf
,
2009 size_t count
, loff_t
*ppos
) {
2011 struct iwl_priv
*priv
= file
->private_data
;
2014 const size_t bufsz
= sizeof(buf
);
2016 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%u\n",
2017 priv
->plcp_delta_threshold
);
2019 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2022 static ssize_t
iwl_dbgfs_plcp_delta_write(struct file
*file
,
2023 const char __user
*user_buf
,
2024 size_t count
, loff_t
*ppos
) {
2026 struct iwl_priv
*priv
= file
->private_data
;
2031 memset(buf
, 0, sizeof(buf
));
2032 buf_size
= min(count
, sizeof(buf
) - 1);
2033 if (copy_from_user(buf
, user_buf
, buf_size
))
2035 if (sscanf(buf
, "%d", &plcp
) != 1)
2037 if ((plcp
< IWL_MAX_PLCP_ERR_THRESHOLD_MIN
) ||
2038 (plcp
> IWL_MAX_PLCP_ERR_THRESHOLD_MAX
))
2039 priv
->plcp_delta_threshold
=
2040 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE
;
2042 priv
->plcp_delta_threshold
= plcp
;
2046 static ssize_t
iwl_dbgfs_rf_reset_read(struct file
*file
,
2047 char __user
*user_buf
,
2048 size_t count
, loff_t
*ppos
)
2050 struct iwl_priv
*priv
= file
->private_data
;
2053 const size_t bufsz
= sizeof(buf
);
2054 struct iwl_rf_reset
*rf_reset
= &priv
->rf_reset
;
2056 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2057 "RF reset statistics\n");
2058 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2059 "\tnumber of reset request: %d\n",
2060 rf_reset
->reset_request_count
);
2061 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2062 "\tnumber of reset request success: %d\n",
2063 rf_reset
->reset_success_count
);
2064 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2065 "\tnumber of reset request reject: %d\n",
2066 rf_reset
->reset_reject_count
);
2068 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2071 static ssize_t
iwl_dbgfs_rf_reset_write(struct file
*file
,
2072 const char __user
*user_buf
,
2073 size_t count
, loff_t
*ppos
) {
2075 struct iwl_priv
*priv
= file
->private_data
;
2078 ret
= iwl_force_rf_reset(priv
, true);
2079 return ret
? ret
: count
;
2082 static ssize_t
iwl_dbgfs_txfifo_flush_write(struct file
*file
,
2083 const char __user
*user_buf
,
2084 size_t count
, loff_t
*ppos
) {
2086 struct iwl_priv
*priv
= file
->private_data
;
2091 memset(buf
, 0, sizeof(buf
));
2092 buf_size
= min(count
, sizeof(buf
) - 1);
2093 if (copy_from_user(buf
, user_buf
, buf_size
))
2095 if (sscanf(buf
, "%d", &flush
) != 1)
2098 if (iwl_is_rfkill(priv
))
2101 iwlagn_dev_txfifo_flush(priv
, IWL_DROP_ALL
);
2106 static ssize_t
iwl_dbgfs_bt_traffic_read(struct file
*file
,
2107 char __user
*user_buf
,
2108 size_t count
, loff_t
*ppos
) {
2110 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
2113 const size_t bufsz
= sizeof(buf
);
2115 if (!priv
->bt_enable_flag
) {
2116 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "BT coex disabled\n");
2117 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2119 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "BT enable flag: 0x%x\n",
2120 priv
->bt_enable_flag
);
2121 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "BT in %s mode\n",
2122 priv
->bt_full_concurrent
? "full concurrency" : "3-wire");
2123 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "BT status: %s, "
2124 "last traffic notif: %d\n",
2125 priv
->bt_status
? "On" : "Off", priv
->last_bt_traffic_load
);
2126 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "ch_announcement: %d, "
2127 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2128 priv
->bt_ch_announce
, priv
->kill_ack_mask
,
2129 priv
->kill_cts_mask
);
2131 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "bluetooth traffic load: ");
2132 switch (priv
->bt_traffic_load
) {
2133 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS
:
2134 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Continuous\n");
2136 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH
:
2137 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "High\n");
2139 case IWL_BT_COEX_TRAFFIC_LOAD_LOW
:
2140 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Low\n");
2142 case IWL_BT_COEX_TRAFFIC_LOAD_NONE
:
2144 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "None\n");
2148 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2151 static ssize_t
iwl_dbgfs_protection_mode_read(struct file
*file
,
2152 char __user
*user_buf
,
2153 size_t count
, loff_t
*ppos
)
2155 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
2159 const size_t bufsz
= sizeof(buf
);
2161 if (priv
->cfg
->ht_params
)
2162 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2163 "use %s for aggregation\n",
2164 (priv
->hw_params
.use_rts_for_aggregation
) ?
2165 "rts/cts" : "cts-to-self");
2167 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "N/A");
2169 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2172 static ssize_t
iwl_dbgfs_protection_mode_write(struct file
*file
,
2173 const char __user
*user_buf
,
2174 size_t count
, loff_t
*ppos
) {
2176 struct iwl_priv
*priv
= file
->private_data
;
2181 if (!priv
->cfg
->ht_params
)
2184 memset(buf
, 0, sizeof(buf
));
2185 buf_size
= min(count
, sizeof(buf
) - 1);
2186 if (copy_from_user(buf
, user_buf
, buf_size
))
2188 if (sscanf(buf
, "%d", &rts
) != 1)
2191 priv
->hw_params
.use_rts_for_aggregation
= true;
2193 priv
->hw_params
.use_rts_for_aggregation
= false;
2197 static int iwl_cmd_echo_test(struct iwl_priv
*priv
)
2200 struct iwl_host_cmd cmd
= {
2206 ret
= iwl_dvm_send_cmd(priv
, &cmd
);
2208 IWL_ERR(priv
, "echo testing fail: 0X%x\n", ret
);
2210 IWL_DEBUG_INFO(priv
, "echo testing pass\n");
2214 static ssize_t
iwl_dbgfs_echo_test_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
;
2222 memset(buf
, 0, sizeof(buf
));
2223 buf_size
= min(count
, sizeof(buf
) - 1);
2224 if (copy_from_user(buf
, user_buf
, buf_size
))
2227 iwl_cmd_echo_test(priv
);
2231 #ifdef CONFIG_IWLWIFI_DEBUG
2232 static ssize_t
iwl_dbgfs_log_event_read(struct file
*file
,
2233 char __user
*user_buf
,
2234 size_t count
, loff_t
*ppos
)
2236 struct iwl_priv
*priv
= file
->private_data
;
2239 ssize_t ret
= -ENOMEM
;
2241 ret
= pos
= iwl_dump_nic_event_log(priv
, true, &buf
, true);
2243 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2249 static ssize_t
iwl_dbgfs_log_event_write(struct file
*file
,
2250 const char __user
*user_buf
,
2251 size_t count
, loff_t
*ppos
)
2253 struct iwl_priv
*priv
= file
->private_data
;
2258 /* check that the interface is up */
2259 if (!iwl_is_ready(priv
))
2262 memset(buf
, 0, sizeof(buf
));
2263 buf_size
= min(count
, sizeof(buf
) - 1);
2264 if (copy_from_user(buf
, user_buf
, buf_size
))
2266 if (sscanf(buf
, "%d", &event_log_flag
) != 1)
2268 if (event_log_flag
== 1)
2269 iwl_dump_nic_event_log(priv
, true, NULL
, false);
2275 static ssize_t
iwl_dbgfs_calib_disabled_read(struct file
*file
,
2276 char __user
*user_buf
,
2277 size_t count
, loff_t
*ppos
)
2279 struct iwl_priv
*priv
= file
->private_data
;
2282 const size_t bufsz
= sizeof(buf
);
2284 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2285 "Sensitivity calibrations %s\n",
2286 (priv
->calib_disabled
&
2287 IWL_SENSITIVITY_CALIB_DISABLED
) ?
2288 "DISABLED" : "ENABLED");
2289 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2290 "Chain noise calibrations %s\n",
2291 (priv
->calib_disabled
&
2292 IWL_CHAIN_NOISE_CALIB_DISABLED
) ?
2293 "DISABLED" : "ENABLED");
2294 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2295 "Tx power calibrations %s\n",
2296 (priv
->calib_disabled
&
2297 IWL_TX_POWER_CALIB_DISABLED
) ?
2298 "DISABLED" : "ENABLED");
2300 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2303 static ssize_t
iwl_dbgfs_calib_disabled_write(struct file
*file
,
2304 const char __user
*user_buf
,
2305 size_t count
, loff_t
*ppos
)
2307 struct iwl_priv
*priv
= file
->private_data
;
2312 memset(buf
, 0, sizeof(buf
));
2313 buf_size
= min(count
, sizeof(buf
) - 1);
2314 if (copy_from_user(buf
, user_buf
, buf_size
))
2316 if (sscanf(buf
, "%x", &calib_disabled
) != 1)
2319 priv
->calib_disabled
= calib_disabled
;
2324 DEBUGFS_READ_FILE_OPS(ucode_rx_stats
);
2325 DEBUGFS_READ_FILE_OPS(ucode_tx_stats
);
2326 DEBUGFS_READ_FILE_OPS(ucode_general_stats
);
2327 DEBUGFS_READ_FILE_OPS(sensitivity
);
2328 DEBUGFS_READ_FILE_OPS(chain_noise
);
2329 DEBUGFS_READ_FILE_OPS(power_save_status
);
2330 DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics
);
2331 DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing
);
2332 DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon
);
2333 DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta
);
2334 DEBUGFS_READ_WRITE_FILE_OPS(rf_reset
);
2335 DEBUGFS_READ_FILE_OPS(rxon_flags
);
2336 DEBUGFS_READ_FILE_OPS(rxon_filter_flags
);
2337 DEBUGFS_WRITE_FILE_OPS(txfifo_flush
);
2338 DEBUGFS_READ_FILE_OPS(ucode_bt_stats
);
2339 DEBUGFS_READ_FILE_OPS(bt_traffic
);
2340 DEBUGFS_READ_WRITE_FILE_OPS(protection_mode
);
2341 DEBUGFS_READ_FILE_OPS(reply_tx_error
);
2342 DEBUGFS_WRITE_FILE_OPS(echo_test
);
2343 #ifdef CONFIG_IWLWIFI_DEBUG
2344 DEBUGFS_READ_WRITE_FILE_OPS(log_event
);
2346 DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled
);
2349 * Create the debugfs files and directories
2352 int iwl_dbgfs_register(struct iwl_priv
*priv
, const char *name
)
2354 struct dentry
*phyd
= priv
->hw
->wiphy
->debugfsdir
;
2355 struct dentry
*dir_drv
, *dir_data
, *dir_rf
, *dir_debug
;
2357 dir_drv
= debugfs_create_dir(name
, phyd
);
2361 priv
->debugfs_dir
= dir_drv
;
2363 dir_data
= debugfs_create_dir("data", dir_drv
);
2366 dir_rf
= debugfs_create_dir("rf", dir_drv
);
2369 dir_debug
= debugfs_create_dir("debug", dir_drv
);
2373 DEBUGFS_ADD_FILE(nvm
, dir_data
, S_IRUSR
);
2374 DEBUGFS_ADD_FILE(sram
, dir_data
, S_IWUSR
| S_IRUSR
);
2375 DEBUGFS_ADD_FILE(wowlan_sram
, dir_data
, S_IRUSR
);
2376 DEBUGFS_ADD_FILE(stations
, dir_data
, S_IRUSR
);
2377 DEBUGFS_ADD_FILE(channels
, dir_data
, S_IRUSR
);
2378 DEBUGFS_ADD_FILE(status
, dir_data
, S_IRUSR
);
2379 DEBUGFS_ADD_FILE(rx_handlers
, dir_data
, S_IWUSR
| S_IRUSR
);
2380 DEBUGFS_ADD_FILE(qos
, dir_data
, S_IRUSR
);
2381 DEBUGFS_ADD_FILE(sleep_level_override
, dir_data
, S_IWUSR
| S_IRUSR
);
2382 DEBUGFS_ADD_FILE(current_sleep_command
, dir_data
, S_IRUSR
);
2383 DEBUGFS_ADD_FILE(thermal_throttling
, dir_data
, S_IRUSR
);
2384 DEBUGFS_ADD_FILE(disable_ht40
, dir_data
, S_IWUSR
| S_IRUSR
);
2385 DEBUGFS_ADD_FILE(temperature
, dir_data
, S_IRUSR
);
2387 DEBUGFS_ADD_FILE(power_save_status
, dir_debug
, S_IRUSR
);
2388 DEBUGFS_ADD_FILE(clear_ucode_statistics
, dir_debug
, S_IWUSR
);
2389 DEBUGFS_ADD_FILE(missed_beacon
, dir_debug
, S_IWUSR
);
2390 DEBUGFS_ADD_FILE(plcp_delta
, dir_debug
, S_IWUSR
| S_IRUSR
);
2391 DEBUGFS_ADD_FILE(rf_reset
, dir_debug
, S_IWUSR
| S_IRUSR
);
2392 DEBUGFS_ADD_FILE(ucode_rx_stats
, dir_debug
, S_IRUSR
);
2393 DEBUGFS_ADD_FILE(ucode_tx_stats
, dir_debug
, S_IRUSR
);
2394 DEBUGFS_ADD_FILE(ucode_general_stats
, dir_debug
, S_IRUSR
);
2395 DEBUGFS_ADD_FILE(txfifo_flush
, dir_debug
, S_IWUSR
);
2396 DEBUGFS_ADD_FILE(protection_mode
, dir_debug
, S_IWUSR
| S_IRUSR
);
2397 DEBUGFS_ADD_FILE(sensitivity
, dir_debug
, S_IRUSR
);
2398 DEBUGFS_ADD_FILE(chain_noise
, dir_debug
, S_IRUSR
);
2399 DEBUGFS_ADD_FILE(ucode_tracing
, dir_debug
, S_IWUSR
| S_IRUSR
);
2400 DEBUGFS_ADD_FILE(ucode_bt_stats
, dir_debug
, S_IRUSR
);
2401 DEBUGFS_ADD_FILE(reply_tx_error
, dir_debug
, S_IRUSR
);
2402 DEBUGFS_ADD_FILE(rxon_flags
, dir_debug
, S_IWUSR
);
2403 DEBUGFS_ADD_FILE(rxon_filter_flags
, dir_debug
, S_IWUSR
);
2404 DEBUGFS_ADD_FILE(echo_test
, dir_debug
, S_IWUSR
);
2405 #ifdef CONFIG_IWLWIFI_DEBUG
2406 DEBUGFS_ADD_FILE(log_event
, dir_debug
, S_IWUSR
| S_IRUSR
);
2409 if (iwl_advanced_bt_coexist(priv
))
2410 DEBUGFS_ADD_FILE(bt_traffic
, dir_debug
, S_IRUSR
);
2412 /* Calibrations disabled/enabled status*/
2413 DEBUGFS_ADD_FILE(calib_disabled
, dir_rf
, S_IWUSR
| S_IRUSR
);
2415 if (iwl_trans_dbgfs_register(priv
->trans
, dir_debug
))
2420 IWL_ERR(priv
, "Can't create the debugfs directory\n");
2421 iwl_dbgfs_unregister(priv
);
2426 * Remove the debugfs files and directories
2429 void iwl_dbgfs_unregister(struct iwl_priv
*priv
)
2431 if (!priv
->debugfs_dir
)
2434 debugfs_remove_recursive(priv
->debugfs_dir
);
2435 priv
->debugfs_dir
= NULL
;