1 /******************************************************************************
5 * Copyright(c) 2008 - 2010 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>
34 #include <linux/ieee80211.h>
35 #include <net/mac80211.h>
39 #include "iwl-debug.h"
42 #include "iwl-calib.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)) \
51 #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
52 struct dentry *__tmp; \
53 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
55 if (IS_ERR(__tmp) || !__tmp) \
59 #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
60 struct dentry *__tmp; \
61 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
63 if (IS_ERR(__tmp) || !__tmp) \
68 #define DEBUGFS_READ_FUNC(name) \
69 static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
70 char __user *user_buf, \
71 size_t count, loff_t *ppos);
73 #define DEBUGFS_WRITE_FUNC(name) \
74 static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
75 const char __user *user_buf, \
76 size_t count, loff_t *ppos);
79 static int iwl_dbgfs_open_file_generic(struct inode
*inode
, struct file
*file
)
81 file
->private_data
= inode
->i_private
;
85 #define DEBUGFS_READ_FILE_OPS(name) \
86 DEBUGFS_READ_FUNC(name); \
87 static const struct file_operations iwl_dbgfs_##name##_ops = { \
88 .read = iwl_dbgfs_##name##_read, \
89 .open = iwl_dbgfs_open_file_generic, \
92 #define DEBUGFS_WRITE_FILE_OPS(name) \
93 DEBUGFS_WRITE_FUNC(name); \
94 static const struct file_operations iwl_dbgfs_##name##_ops = { \
95 .write = iwl_dbgfs_##name##_write, \
96 .open = iwl_dbgfs_open_file_generic, \
100 #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
101 DEBUGFS_READ_FUNC(name); \
102 DEBUGFS_WRITE_FUNC(name); \
103 static const struct file_operations iwl_dbgfs_##name##_ops = { \
104 .write = iwl_dbgfs_##name##_write, \
105 .read = iwl_dbgfs_##name##_read, \
106 .open = iwl_dbgfs_open_file_generic, \
110 static ssize_t
iwl_dbgfs_tx_statistics_read(struct file
*file
,
111 char __user
*user_buf
,
112 size_t count
, loff_t
*ppos
) {
114 struct iwl_priv
*priv
= file
->private_data
;
120 const size_t bufsz
= 100 +
121 sizeof(char) * 50 * (MANAGEMENT_MAX
+ CONTROL_MAX
);
122 buf
= kzalloc(bufsz
, GFP_KERNEL
);
125 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Management:\n");
126 for (cnt
= 0; cnt
< MANAGEMENT_MAX
; cnt
++) {
127 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
129 get_mgmt_string(cnt
),
130 priv
->tx_stats
.mgmt
[cnt
]);
132 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Control\n");
133 for (cnt
= 0; cnt
< CONTROL_MAX
; cnt
++) {
134 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
136 get_ctrl_string(cnt
),
137 priv
->tx_stats
.ctrl
[cnt
]);
139 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Data:\n");
140 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\tcnt: %u\n",
141 priv
->tx_stats
.data_cnt
);
142 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\tbytes: %llu\n",
143 priv
->tx_stats
.data_bytes
);
144 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
149 static ssize_t
iwl_dbgfs_clear_traffic_statistics_write(struct file
*file
,
150 const char __user
*user_buf
,
151 size_t count
, loff_t
*ppos
)
153 struct iwl_priv
*priv
= file
->private_data
;
158 memset(buf
, 0, sizeof(buf
));
159 buf_size
= min(count
, sizeof(buf
) - 1);
160 if (copy_from_user(buf
, user_buf
, buf_size
))
162 if (sscanf(buf
, "%x", &clear_flag
) != 1)
164 iwl_clear_traffic_stats(priv
);
169 static ssize_t
iwl_dbgfs_rx_statistics_read(struct file
*file
,
170 char __user
*user_buf
,
171 size_t count
, loff_t
*ppos
) {
173 struct iwl_priv
*priv
= file
->private_data
;
178 const size_t bufsz
= 100 +
179 sizeof(char) * 50 * (MANAGEMENT_MAX
+ CONTROL_MAX
);
180 buf
= kzalloc(bufsz
, GFP_KERNEL
);
184 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Management:\n");
185 for (cnt
= 0; cnt
< MANAGEMENT_MAX
; cnt
++) {
186 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
188 get_mgmt_string(cnt
),
189 priv
->rx_stats
.mgmt
[cnt
]);
191 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Control:\n");
192 for (cnt
= 0; cnt
< CONTROL_MAX
; cnt
++) {
193 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
195 get_ctrl_string(cnt
),
196 priv
->rx_stats
.ctrl
[cnt
]);
198 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Data:\n");
199 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\tcnt: %u\n",
200 priv
->rx_stats
.data_cnt
);
201 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\tbytes: %llu\n",
202 priv
->rx_stats
.data_bytes
);
204 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
209 #define BYTE1_MASK 0x000000ff;
210 #define BYTE2_MASK 0x0000ffff;
211 #define BYTE3_MASK 0x00ffffff;
212 static ssize_t
iwl_dbgfs_sram_read(struct file
*file
,
213 char __user
*user_buf
,
214 size_t count
, loff_t
*ppos
)
221 struct iwl_priv
*priv
= file
->private_data
;
224 /* default is to dump the entire data segment */
225 if (!priv
->dbgfs_sram_offset
&& !priv
->dbgfs_sram_len
) {
226 priv
->dbgfs_sram_offset
= 0x800000;
227 if (priv
->ucode_type
== UCODE_INIT
)
228 priv
->dbgfs_sram_len
= priv
->ucode_init_data
.len
;
230 priv
->dbgfs_sram_len
= priv
->ucode_data
.len
;
232 bufsz
= 30 + priv
->dbgfs_sram_len
* sizeof(char) * 10;
233 buf
= kmalloc(bufsz
, GFP_KERNEL
);
236 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_len: 0x%x\n",
237 priv
->dbgfs_sram_len
);
238 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_offset: 0x%x\n",
239 priv
->dbgfs_sram_offset
);
240 for (i
= priv
->dbgfs_sram_len
; i
> 0; i
-= 4) {
241 val
= iwl_read_targ_mem(priv
, priv
->dbgfs_sram_offset
+ \
242 priv
->dbgfs_sram_len
- i
);
257 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
258 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "0x%08x ", val
);
260 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
262 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
267 static ssize_t
iwl_dbgfs_sram_write(struct file
*file
,
268 const char __user
*user_buf
,
269 size_t count
, loff_t
*ppos
)
271 struct iwl_priv
*priv
= file
->private_data
;
276 memset(buf
, 0, sizeof(buf
));
277 buf_size
= min(count
, sizeof(buf
) - 1);
278 if (copy_from_user(buf
, user_buf
, buf_size
))
281 if (sscanf(buf
, "%x,%x", &offset
, &len
) == 2) {
282 priv
->dbgfs_sram_offset
= offset
;
283 priv
->dbgfs_sram_len
= len
;
285 priv
->dbgfs_sram_offset
= 0;
286 priv
->dbgfs_sram_len
= 0;
292 static ssize_t
iwl_dbgfs_stations_read(struct file
*file
, char __user
*user_buf
,
293 size_t count
, loff_t
*ppos
)
295 struct iwl_priv
*priv
= file
->private_data
;
296 struct iwl_station_entry
*station
;
297 int max_sta
= priv
->hw_params
.max_stations
;
301 /* Add 30 for initial string */
302 const size_t bufsz
= 30 + sizeof(char) * 500 * (priv
->num_stations
);
304 buf
= kmalloc(bufsz
, GFP_KERNEL
);
308 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "num of stations: %d\n\n",
311 for (i
= 0; i
< max_sta
; i
++) {
312 station
= &priv
->stations
[i
];
314 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
315 "station %d:\ngeneral data:\n", i
+1);
316 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "id: %u\n",
317 station
->sta
.sta
.sta_id
);
318 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "mode: %u\n",
320 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
322 station
->sta
.station_flags_msk
);
323 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "tid data:\n");
324 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
325 "seq_num\t\ttxq_id");
326 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
327 "\tframe_count\twait_for_ba\t");
328 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
329 "start_idx\tbitmap0\t");
330 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
331 "bitmap1\trate_n_flags");
332 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
334 for (j
= 0; j
< MAX_TID_COUNT
; j
++) {
335 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
337 station
->tid
[j
].seq_number
);
338 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
339 "\t%u\t\t%u\t\t%u\t\t",
340 station
->tid
[j
].agg
.txq_id
,
341 station
->tid
[j
].agg
.frame_count
,
342 station
->tid
[j
].agg
.wait_for_ba
);
343 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
345 station
->tid
[j
].agg
.start_idx
,
346 (unsigned long long)station
->tid
[j
].agg
.bitmap
,
347 station
->tid
[j
].agg
.rate_n_flags
);
348 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
350 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
354 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
359 static ssize_t
iwl_dbgfs_nvm_read(struct file
*file
,
360 char __user
*user_buf
,
365 struct iwl_priv
*priv
= file
->private_data
;
366 int pos
= 0, ofs
= 0, buf_size
= 0;
370 size_t eeprom_len
= priv
->cfg
->eeprom_size
;
371 buf_size
= 4 * eeprom_len
+ 256;
373 if (eeprom_len
% 16) {
374 IWL_ERR(priv
, "NVM size is not multiple of 16.\n");
380 IWL_ERR(priv
, "Invalid EEPROM/OTP memory\n");
384 /* 4 characters for byte 0xYY */
385 buf
= kzalloc(buf_size
, GFP_KERNEL
);
387 IWL_ERR(priv
, "Can not allocate Buffer\n");
390 eeprom_ver
= iwl_eeprom_query16(priv
, EEPROM_VERSION
);
391 pos
+= scnprintf(buf
+ pos
, buf_size
- pos
, "NVM Type: %s, "
393 (priv
->nvm_device_type
== NVM_DEVICE_TYPE_OTP
)
394 ? "OTP" : "EEPROM", eeprom_ver
);
395 for (ofs
= 0 ; ofs
< eeprom_len
; ofs
+= 16) {
396 pos
+= scnprintf(buf
+ pos
, buf_size
- pos
, "0x%.4x ", ofs
);
397 hex_dump_to_buffer(ptr
+ ofs
, 16 , 16, 2, buf
+ pos
,
399 pos
+= strlen(buf
+ pos
);
400 if (buf_size
- pos
> 0)
404 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
409 static ssize_t
iwl_dbgfs_log_event_read(struct file
*file
,
410 char __user
*user_buf
,
411 size_t count
, loff_t
*ppos
)
413 struct iwl_priv
*priv
= file
->private_data
;
416 ssize_t ret
= -ENOMEM
;
418 ret
= pos
= priv
->cfg
->ops
->lib
->dump_nic_event_log(
419 priv
, true, &buf
, true);
421 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
427 static ssize_t
iwl_dbgfs_log_event_write(struct file
*file
,
428 const char __user
*user_buf
,
429 size_t count
, loff_t
*ppos
)
431 struct iwl_priv
*priv
= file
->private_data
;
436 memset(buf
, 0, sizeof(buf
));
437 buf_size
= min(count
, sizeof(buf
) - 1);
438 if (copy_from_user(buf
, user_buf
, buf_size
))
440 if (sscanf(buf
, "%d", &event_log_flag
) != 1)
442 if (event_log_flag
== 1)
443 priv
->cfg
->ops
->lib
->dump_nic_event_log(priv
, true,
451 static ssize_t
iwl_dbgfs_channels_read(struct file
*file
, char __user
*user_buf
,
452 size_t count
, loff_t
*ppos
)
454 struct iwl_priv
*priv
= file
->private_data
;
455 struct ieee80211_channel
*channels
= NULL
;
456 const struct ieee80211_supported_band
*supp_band
= NULL
;
457 int pos
= 0, i
, bufsz
= PAGE_SIZE
;
461 if (!test_bit(STATUS_GEO_CONFIGURED
, &priv
->status
))
464 buf
= kzalloc(bufsz
, GFP_KERNEL
);
466 IWL_ERR(priv
, "Can not allocate Buffer\n");
470 supp_band
= iwl_get_hw_mode(priv
, IEEE80211_BAND_2GHZ
);
472 channels
= supp_band
->channels
;
474 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
475 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
476 supp_band
->n_channels
);
478 for (i
= 0; i
< supp_band
->n_channels
; i
++)
479 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
480 "%d: %ddBm: BSS%s%s, %s.\n",
481 ieee80211_frequency_to_channel(
482 channels
[i
].center_freq
),
483 channels
[i
].max_power
,
484 channels
[i
].flags
& IEEE80211_CHAN_RADAR
?
485 " (IEEE 802.11h required)" : "",
486 ((channels
[i
].flags
& IEEE80211_CHAN_NO_IBSS
)
487 || (channels
[i
].flags
&
488 IEEE80211_CHAN_RADAR
)) ? "" :
491 IEEE80211_CHAN_PASSIVE_SCAN
?
492 "passive only" : "active/passive");
494 supp_band
= iwl_get_hw_mode(priv
, IEEE80211_BAND_5GHZ
);
496 channels
= supp_band
->channels
;
498 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
499 "Displaying %d channels in 5.2GHz band (802.11a)\n",
500 supp_band
->n_channels
);
502 for (i
= 0; i
< supp_band
->n_channels
; i
++)
503 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
504 "%d: %ddBm: BSS%s%s, %s.\n",
505 ieee80211_frequency_to_channel(
506 channels
[i
].center_freq
),
507 channels
[i
].max_power
,
508 channels
[i
].flags
& IEEE80211_CHAN_RADAR
?
509 " (IEEE 802.11h required)" : "",
510 ((channels
[i
].flags
& IEEE80211_CHAN_NO_IBSS
)
511 || (channels
[i
].flags
&
512 IEEE80211_CHAN_RADAR
)) ? "" :
515 IEEE80211_CHAN_PASSIVE_SCAN
?
516 "passive only" : "active/passive");
518 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
523 static ssize_t
iwl_dbgfs_status_read(struct file
*file
,
524 char __user
*user_buf
,
525 size_t count
, loff_t
*ppos
) {
527 struct iwl_priv
*priv
= file
->private_data
;
530 const size_t bufsz
= sizeof(buf
);
532 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_HCMD_ACTIVE:\t %d\n",
533 test_bit(STATUS_HCMD_ACTIVE
, &priv
->status
));
534 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_INT_ENABLED:\t %d\n",
535 test_bit(STATUS_INT_ENABLED
, &priv
->status
));
536 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_RF_KILL_HW:\t %d\n",
537 test_bit(STATUS_RF_KILL_HW
, &priv
->status
));
538 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_CT_KILL:\t\t %d\n",
539 test_bit(STATUS_CT_KILL
, &priv
->status
));
540 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_INIT:\t\t %d\n",
541 test_bit(STATUS_INIT
, &priv
->status
));
542 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_ALIVE:\t\t %d\n",
543 test_bit(STATUS_ALIVE
, &priv
->status
));
544 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_READY:\t\t %d\n",
545 test_bit(STATUS_READY
, &priv
->status
));
546 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_TEMPERATURE:\t %d\n",
547 test_bit(STATUS_TEMPERATURE
, &priv
->status
));
548 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_GEO_CONFIGURED:\t %d\n",
549 test_bit(STATUS_GEO_CONFIGURED
, &priv
->status
));
550 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_EXIT_PENDING:\t %d\n",
551 test_bit(STATUS_EXIT_PENDING
, &priv
->status
));
552 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_STATISTICS:\t %d\n",
553 test_bit(STATUS_STATISTICS
, &priv
->status
));
554 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_SCANNING:\t %d\n",
555 test_bit(STATUS_SCANNING
, &priv
->status
));
556 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_SCAN_ABORTING:\t %d\n",
557 test_bit(STATUS_SCAN_ABORTING
, &priv
->status
));
558 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_SCAN_HW:\t\t %d\n",
559 test_bit(STATUS_SCAN_HW
, &priv
->status
));
560 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_POWER_PMI:\t %d\n",
561 test_bit(STATUS_POWER_PMI
, &priv
->status
));
562 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_FW_ERROR:\t %d\n",
563 test_bit(STATUS_FW_ERROR
, &priv
->status
));
564 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "STATUS_MODE_PENDING:\t %d\n",
565 test_bit(STATUS_MODE_PENDING
, &priv
->status
));
566 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
569 static ssize_t
iwl_dbgfs_interrupt_read(struct file
*file
,
570 char __user
*user_buf
,
571 size_t count
, loff_t
*ppos
) {
573 struct iwl_priv
*priv
= file
->private_data
;
577 int bufsz
= 24 * 64; /* 24 items * 64 char per item */
580 buf
= kzalloc(bufsz
, GFP_KERNEL
);
582 IWL_ERR(priv
, "Can not allocate Buffer\n");
586 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
587 "Interrupt Statistics Report:\n");
589 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "HW Error:\t\t\t %u\n",
591 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "SW Error:\t\t\t %u\n",
593 if (priv
->isr_stats
.sw
> 0) {
594 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
595 "\tLast Restarting Code: 0x%X\n",
596 priv
->isr_stats
.sw_err
);
598 #ifdef CONFIG_IWLWIFI_DEBUG
599 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Frame transmitted:\t\t %u\n",
600 priv
->isr_stats
.sch
);
601 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Alive interrupt:\t\t %u\n",
602 priv
->isr_stats
.alive
);
604 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
605 "HW RF KILL switch toggled:\t %u\n",
606 priv
->isr_stats
.rfkill
);
608 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "CT KILL:\t\t\t %u\n",
609 priv
->isr_stats
.ctkill
);
611 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Wakeup Interrupt:\t\t %u\n",
612 priv
->isr_stats
.wakeup
);
614 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
615 "Rx command responses:\t\t %u\n",
617 for (cnt
= 0; cnt
< REPLY_MAX
; cnt
++) {
618 if (priv
->isr_stats
.rx_handlers
[cnt
] > 0)
619 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
620 "\tRx handler[%36s]:\t\t %u\n",
622 priv
->isr_stats
.rx_handlers
[cnt
]);
625 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Tx/FH interrupt:\t\t %u\n",
628 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Unexpected INTA:\t\t %u\n",
629 priv
->isr_stats
.unhandled
);
631 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
636 static ssize_t
iwl_dbgfs_interrupt_write(struct file
*file
,
637 const char __user
*user_buf
,
638 size_t count
, loff_t
*ppos
)
640 struct iwl_priv
*priv
= file
->private_data
;
645 memset(buf
, 0, sizeof(buf
));
646 buf_size
= min(count
, sizeof(buf
) - 1);
647 if (copy_from_user(buf
, user_buf
, buf_size
))
649 if (sscanf(buf
, "%x", &reset_flag
) != 1)
652 iwl_clear_isr_stats(priv
);
657 static ssize_t
iwl_dbgfs_qos_read(struct file
*file
, char __user
*user_buf
,
658 size_t count
, loff_t
*ppos
)
660 struct iwl_priv
*priv
= file
->private_data
;
663 const size_t bufsz
= sizeof(buf
);
666 for (i
= 0; i
< AC_NUM
; i
++) {
667 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
668 "\tcw_min\tcw_max\taifsn\ttxop\n");
669 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
670 "AC[%d]\t%u\t%u\t%u\t%u\n", i
,
671 priv
->qos_data
.def_qos_parm
.ac
[i
].cw_min
,
672 priv
->qos_data
.def_qos_parm
.ac
[i
].cw_max
,
673 priv
->qos_data
.def_qos_parm
.ac
[i
].aifsn
,
674 priv
->qos_data
.def_qos_parm
.ac
[i
].edca_txop
);
676 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
680 static ssize_t
iwl_dbgfs_led_read(struct file
*file
, char __user
*user_buf
,
681 size_t count
, loff_t
*ppos
)
683 struct iwl_priv
*priv
= file
->private_data
;
686 const size_t bufsz
= sizeof(buf
);
689 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
690 "allow blinking: %s\n",
691 (priv
->allow_blinking
) ? "True" : "False");
692 if (priv
->allow_blinking
) {
693 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
694 "Led blinking rate: %u\n",
695 priv
->last_blink_rate
);
696 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
697 "Last blink time: %lu\n",
698 priv
->last_blink_time
);
701 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
705 static ssize_t
iwl_dbgfs_thermal_throttling_read(struct file
*file
,
706 char __user
*user_buf
,
707 size_t count
, loff_t
*ppos
)
709 struct iwl_priv
*priv
= file
->private_data
;
710 struct iwl_tt_mgmt
*tt
= &priv
->thermal_throttle
;
711 struct iwl_tt_restriction
*restriction
;
714 const size_t bufsz
= sizeof(buf
);
717 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
718 "Thermal Throttling Mode: %s\n",
719 tt
->advanced_tt
? "Advance" : "Legacy");
720 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
721 "Thermal Throttling State: %d\n",
723 if (tt
->advanced_tt
) {
724 restriction
= tt
->restriction
+ tt
->state
;
725 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
727 restriction
->tx_stream
);
728 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
730 restriction
->rx_stream
);
731 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
735 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
739 static ssize_t
iwl_dbgfs_disable_ht40_write(struct file
*file
,
740 const char __user
*user_buf
,
741 size_t count
, loff_t
*ppos
)
743 struct iwl_priv
*priv
= file
->private_data
;
748 memset(buf
, 0, sizeof(buf
));
749 buf_size
= min(count
, sizeof(buf
) - 1);
750 if (copy_from_user(buf
, user_buf
, buf_size
))
752 if (sscanf(buf
, "%d", &ht40
) != 1)
754 if (!iwl_is_associated(priv
))
755 priv
->disable_ht40
= ht40
? true : false;
757 IWL_ERR(priv
, "Sta associated with AP - "
758 "Change to 40MHz channel support is not allowed\n");
765 static ssize_t
iwl_dbgfs_disable_ht40_read(struct file
*file
,
766 char __user
*user_buf
,
767 size_t count
, loff_t
*ppos
)
769 struct iwl_priv
*priv
= file
->private_data
;
772 const size_t bufsz
= sizeof(buf
);
775 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
776 "11n 40MHz Mode: %s\n",
777 priv
->disable_ht40
? "Disabled" : "Enabled");
778 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
782 static ssize_t
iwl_dbgfs_sleep_level_override_write(struct file
*file
,
783 const char __user
*user_buf
,
784 size_t count
, loff_t
*ppos
)
786 struct iwl_priv
*priv
= file
->private_data
;
791 memset(buf
, 0, sizeof(buf
));
792 buf_size
= min(count
, sizeof(buf
) - 1);
793 if (copy_from_user(buf
, user_buf
, buf_size
))
796 if (sscanf(buf
, "%d", &value
) != 1)
800 * Our users expect 0 to be "CAM", but 0 isn't actually
801 * valid here. However, let's not confuse them and present
802 * IWL_POWER_INDEX_1 as "1", not "0".
809 if (value
!= -1 && (value
< 0 || value
>= IWL_POWER_NUM
))
812 if (!iwl_is_ready_rf(priv
))
815 priv
->power_data
.debug_sleep_level_override
= value
;
817 mutex_lock(&priv
->mutex
);
818 iwl_power_update_mode(priv
, true);
819 mutex_unlock(&priv
->mutex
);
824 static ssize_t
iwl_dbgfs_sleep_level_override_read(struct file
*file
,
825 char __user
*user_buf
,
826 size_t count
, loff_t
*ppos
)
828 struct iwl_priv
*priv
= file
->private_data
;
831 const size_t bufsz
= sizeof(buf
);
833 /* see the write function */
834 value
= priv
->power_data
.debug_sleep_level_override
;
838 pos
= scnprintf(buf
, bufsz
, "%d\n", value
);
839 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
842 static ssize_t
iwl_dbgfs_current_sleep_command_read(struct file
*file
,
843 char __user
*user_buf
,
844 size_t count
, loff_t
*ppos
)
846 struct iwl_priv
*priv
= file
->private_data
;
849 const size_t bufsz
= sizeof(buf
);
850 struct iwl_powertable_cmd
*cmd
= &priv
->power_data
.sleep_cmd
;
852 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
853 "flags: %#.2x\n", le16_to_cpu(cmd
->flags
));
854 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
855 "RX/TX timeout: %d/%d usec\n",
856 le32_to_cpu(cmd
->rx_data_timeout
),
857 le32_to_cpu(cmd
->tx_data_timeout
));
858 for (i
= 0; i
< IWL_POWER_VEC_SIZE
; i
++)
859 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
860 "sleep_interval[%d]: %d\n", i
,
861 le32_to_cpu(cmd
->sleep_interval
[i
]));
863 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
866 DEBUGFS_READ_WRITE_FILE_OPS(sram
);
867 DEBUGFS_READ_WRITE_FILE_OPS(log_event
);
868 DEBUGFS_READ_FILE_OPS(nvm
);
869 DEBUGFS_READ_FILE_OPS(stations
);
870 DEBUGFS_READ_FILE_OPS(channels
);
871 DEBUGFS_READ_FILE_OPS(status
);
872 DEBUGFS_READ_WRITE_FILE_OPS(interrupt
);
873 DEBUGFS_READ_FILE_OPS(qos
);
874 DEBUGFS_READ_FILE_OPS(led
);
875 DEBUGFS_READ_FILE_OPS(thermal_throttling
);
876 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40
);
877 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override
);
878 DEBUGFS_READ_FILE_OPS(current_sleep_command
);
880 static ssize_t
iwl_dbgfs_traffic_log_read(struct file
*file
,
881 char __user
*user_buf
,
882 size_t count
, loff_t
*ppos
)
884 struct iwl_priv
*priv
= file
->private_data
;
885 int pos
= 0, ofs
= 0;
887 struct iwl_tx_queue
*txq
;
889 struct iwl_rx_queue
*rxq
= &priv
->rxq
;
891 int bufsz
= ((IWL_TRAFFIC_ENTRIES
* IWL_TRAFFIC_ENTRY_SIZE
* 64) * 2) +
892 (priv
->cfg
->num_of_queues
* 32 * 8) + 400;
897 IWL_ERR(priv
, "txq not ready\n");
900 buf
= kzalloc(bufsz
, GFP_KERNEL
);
902 IWL_ERR(priv
, "Can not allocate buffer\n");
905 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Tx Queue\n");
906 for (cnt
= 0; cnt
< priv
->hw_params
.max_txq_num
; cnt
++) {
907 txq
= &priv
->txq
[cnt
];
909 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
910 "q[%d]: read_ptr: %u, write_ptr: %u\n",
911 cnt
, q
->read_ptr
, q
->write_ptr
);
913 if (priv
->tx_traffic
&& (iwl_debug_level
& IWL_DL_TX
)) {
914 ptr
= priv
->tx_traffic
;
915 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
916 "Tx Traffic idx: %u\n", priv
->tx_traffic_idx
);
917 for (cnt
= 0, ofs
= 0; cnt
< IWL_TRAFFIC_ENTRIES
; cnt
++) {
918 for (entry
= 0; entry
< IWL_TRAFFIC_ENTRY_SIZE
/ 16;
919 entry
++, ofs
+= 16) {
920 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
922 hex_dump_to_buffer(ptr
+ ofs
, 16, 16, 2,
923 buf
+ pos
, bufsz
- pos
, 0);
924 pos
+= strlen(buf
+ pos
);
931 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Rx Queue\n");
932 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
933 "read: %u, write: %u\n",
934 rxq
->read
, rxq
->write
);
936 if (priv
->rx_traffic
&& (iwl_debug_level
& IWL_DL_RX
)) {
937 ptr
= priv
->rx_traffic
;
938 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
939 "Rx Traffic idx: %u\n", priv
->rx_traffic_idx
);
940 for (cnt
= 0, ofs
= 0; cnt
< IWL_TRAFFIC_ENTRIES
; cnt
++) {
941 for (entry
= 0; entry
< IWL_TRAFFIC_ENTRY_SIZE
/ 16;
942 entry
++, ofs
+= 16) {
943 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
945 hex_dump_to_buffer(ptr
+ ofs
, 16, 16, 2,
946 buf
+ pos
, bufsz
- pos
, 0);
947 pos
+= strlen(buf
+ pos
);
954 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
959 static ssize_t
iwl_dbgfs_traffic_log_write(struct file
*file
,
960 const char __user
*user_buf
,
961 size_t count
, loff_t
*ppos
)
963 struct iwl_priv
*priv
= file
->private_data
;
968 memset(buf
, 0, sizeof(buf
));
969 buf_size
= min(count
, sizeof(buf
) - 1);
970 if (copy_from_user(buf
, user_buf
, buf_size
))
972 if (sscanf(buf
, "%d", &traffic_log
) != 1)
974 if (traffic_log
== 0)
975 iwl_reset_traffic_log(priv
);
980 static ssize_t
iwl_dbgfs_tx_queue_read(struct file
*file
,
981 char __user
*user_buf
,
982 size_t count
, loff_t
*ppos
) {
984 struct iwl_priv
*priv
= file
->private_data
;
985 struct iwl_tx_queue
*txq
;
991 const size_t bufsz
= sizeof(char) * 64 * priv
->cfg
->num_of_queues
;
994 IWL_ERR(priv
, "txq not ready\n");
997 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1001 for (cnt
= 0; cnt
< priv
->hw_params
.max_txq_num
; cnt
++) {
1002 txq
= &priv
->txq
[cnt
];
1004 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1005 "hwq %.2d: read=%u write=%u stop=%d"
1006 " swq_id=%#.2x (ac %d/hwq %d)\n",
1007 cnt
, q
->read_ptr
, q
->write_ptr
,
1008 !!test_bit(cnt
, priv
->queue_stopped
),
1010 txq
->swq_id
& 0x80 ? txq
->swq_id
& 3 :
1012 txq
->swq_id
& 0x80 ? (txq
->swq_id
>> 2) &
1013 0x1f : txq
->swq_id
);
1016 /* for the ACs, display the stop count too */
1017 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1018 " stop-count: %d\n",
1019 atomic_read(&priv
->queue_stop_count
[cnt
]));
1021 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1026 static ssize_t
iwl_dbgfs_rx_queue_read(struct file
*file
,
1027 char __user
*user_buf
,
1028 size_t count
, loff_t
*ppos
) {
1030 struct iwl_priv
*priv
= file
->private_data
;
1031 struct iwl_rx_queue
*rxq
= &priv
->rxq
;
1034 const size_t bufsz
= sizeof(buf
);
1036 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "read: %u\n",
1038 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "write: %u\n",
1040 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "free_count: %u\n",
1042 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "closed_rb_num: %u\n",
1043 le16_to_cpu(rxq
->rb_stts
->closed_rb_num
) & 0x0FFF);
1044 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1047 static int iwl_dbgfs_statistics_flag(struct iwl_priv
*priv
, char *buf
,
1052 p
+= scnprintf(buf
+ p
, bufsz
- p
,
1053 "Statistics Flag(0x%X):\n",
1054 le32_to_cpu(priv
->statistics
.flag
));
1055 if (le32_to_cpu(priv
->statistics
.flag
) & UCODE_STATISTICS_CLEAR_MSK
)
1056 p
+= scnprintf(buf
+ p
, bufsz
- p
,
1057 "\tStatistics have been cleared\n");
1058 p
+= scnprintf(buf
+ p
, bufsz
- p
,
1059 "\tOperational Frequency: %s\n",
1060 (le32_to_cpu(priv
->statistics
.flag
) &
1061 UCODE_STATISTICS_FREQUENCY_MSK
)
1062 ? "2.4 GHz" : "5.2 GHz");
1063 p
+= scnprintf(buf
+ p
, bufsz
- p
,
1064 "\tTGj Narrow Band: %s\n",
1065 (le32_to_cpu(priv
->statistics
.flag
) &
1066 UCODE_STATISTICS_NARROW_BAND_MSK
)
1067 ? "enabled" : "disabled");
1071 static const char ucode_stats_header
[] =
1072 "%-32s current acumulative delta max\n";
1073 static const char ucode_stats_short_format
[] =
1075 static const char ucode_stats_format
[] =
1076 " %-30s %10u %10u %10u %10u\n";
1078 static ssize_t
iwl_dbgfs_ucode_rx_stats_read(struct file
*file
,
1079 char __user
*user_buf
,
1080 size_t count
, loff_t
*ppos
)
1082 struct iwl_priv
*priv
= file
->private_data
;
1085 int bufsz
= sizeof(struct statistics_rx_phy
) * 40 +
1086 sizeof(struct statistics_rx_non_phy
) * 40 +
1087 sizeof(struct statistics_rx_ht_phy
) * 40 + 400;
1089 struct statistics_rx_phy
*ofdm
, *accum_ofdm
, *delta_ofdm
, *max_ofdm
;
1090 struct statistics_rx_phy
*cck
, *accum_cck
, *delta_cck
, *max_cck
;
1091 struct statistics_rx_non_phy
*general
, *accum_general
;
1092 struct statistics_rx_non_phy
*delta_general
, *max_general
;
1093 struct statistics_rx_ht_phy
*ht
, *accum_ht
, *delta_ht
, *max_ht
;
1095 if (!iwl_is_alive(priv
))
1098 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1100 IWL_ERR(priv
, "Can not allocate Buffer\n");
1104 /* the statistic information display here is based on
1105 * the last statistics notification from uCode
1106 * might not reflect the current uCode activity
1108 ofdm
= &priv
->statistics
.rx
.ofdm
;
1109 cck
= &priv
->statistics
.rx
.cck
;
1110 general
= &priv
->statistics
.rx
.general
;
1111 ht
= &priv
->statistics
.rx
.ofdm_ht
;
1112 accum_ofdm
= &priv
->accum_statistics
.rx
.ofdm
;
1113 accum_cck
= &priv
->accum_statistics
.rx
.cck
;
1114 accum_general
= &priv
->accum_statistics
.rx
.general
;
1115 accum_ht
= &priv
->accum_statistics
.rx
.ofdm_ht
;
1116 delta_ofdm
= &priv
->delta_statistics
.rx
.ofdm
;
1117 delta_cck
= &priv
->delta_statistics
.rx
.cck
;
1118 delta_general
= &priv
->delta_statistics
.rx
.general
;
1119 delta_ht
= &priv
->delta_statistics
.rx
.ofdm_ht
;
1120 max_ofdm
= &priv
->max_delta
.rx
.ofdm
;
1121 max_cck
= &priv
->max_delta
.rx
.cck
;
1122 max_general
= &priv
->max_delta
.rx
.general
;
1123 max_ht
= &priv
->max_delta
.rx
.ofdm_ht
;
1125 pos
+= iwl_dbgfs_statistics_flag(priv
, buf
, bufsz
);
1126 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_header
,
1127 "Statistics_Rx - OFDM:");
1128 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1129 "ina_cnt:", le32_to_cpu(ofdm
->ina_cnt
),
1130 accum_ofdm
->ina_cnt
,
1131 delta_ofdm
->ina_cnt
, max_ofdm
->ina_cnt
);
1132 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1134 le32_to_cpu(ofdm
->fina_cnt
), accum_ofdm
->fina_cnt
,
1135 delta_ofdm
->fina_cnt
, max_ofdm
->fina_cnt
);
1136 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1138 le32_to_cpu(ofdm
->plcp_err
), accum_ofdm
->plcp_err
,
1139 delta_ofdm
->plcp_err
, max_ofdm
->plcp_err
);
1140 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1142 le32_to_cpu(ofdm
->crc32_err
), accum_ofdm
->crc32_err
,
1143 delta_ofdm
->crc32_err
, max_ofdm
->crc32_err
);
1144 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1146 le32_to_cpu(ofdm
->overrun_err
),
1147 accum_ofdm
->overrun_err
,
1148 delta_ofdm
->overrun_err
, max_ofdm
->overrun_err
);
1149 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1150 "early_overrun_err:",
1151 le32_to_cpu(ofdm
->early_overrun_err
),
1152 accum_ofdm
->early_overrun_err
,
1153 delta_ofdm
->early_overrun_err
,
1154 max_ofdm
->early_overrun_err
);
1155 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1157 le32_to_cpu(ofdm
->crc32_good
),
1158 accum_ofdm
->crc32_good
,
1159 delta_ofdm
->crc32_good
, max_ofdm
->crc32_good
);
1160 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1162 le32_to_cpu(ofdm
->false_alarm_cnt
),
1163 accum_ofdm
->false_alarm_cnt
,
1164 delta_ofdm
->false_alarm_cnt
,
1165 max_ofdm
->false_alarm_cnt
);
1166 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1167 "fina_sync_err_cnt:",
1168 le32_to_cpu(ofdm
->fina_sync_err_cnt
),
1169 accum_ofdm
->fina_sync_err_cnt
,
1170 delta_ofdm
->fina_sync_err_cnt
,
1171 max_ofdm
->fina_sync_err_cnt
);
1172 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1174 le32_to_cpu(ofdm
->sfd_timeout
),
1175 accum_ofdm
->sfd_timeout
,
1176 delta_ofdm
->sfd_timeout
,
1177 max_ofdm
->sfd_timeout
);
1178 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1180 le32_to_cpu(ofdm
->fina_timeout
),
1181 accum_ofdm
->fina_timeout
,
1182 delta_ofdm
->fina_timeout
,
1183 max_ofdm
->fina_timeout
);
1184 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1186 le32_to_cpu(ofdm
->unresponded_rts
),
1187 accum_ofdm
->unresponded_rts
,
1188 delta_ofdm
->unresponded_rts
,
1189 max_ofdm
->unresponded_rts
);
1190 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1191 "rxe_frame_lmt_ovrun:",
1192 le32_to_cpu(ofdm
->rxe_frame_limit_overrun
),
1193 accum_ofdm
->rxe_frame_limit_overrun
,
1194 delta_ofdm
->rxe_frame_limit_overrun
,
1195 max_ofdm
->rxe_frame_limit_overrun
);
1196 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1198 le32_to_cpu(ofdm
->sent_ack_cnt
),
1199 accum_ofdm
->sent_ack_cnt
,
1200 delta_ofdm
->sent_ack_cnt
,
1201 max_ofdm
->sent_ack_cnt
);
1202 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1204 le32_to_cpu(ofdm
->sent_cts_cnt
),
1205 accum_ofdm
->sent_cts_cnt
,
1206 delta_ofdm
->sent_cts_cnt
, max_ofdm
->sent_cts_cnt
);
1207 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1209 le32_to_cpu(ofdm
->sent_ba_rsp_cnt
),
1210 accum_ofdm
->sent_ba_rsp_cnt
,
1211 delta_ofdm
->sent_ba_rsp_cnt
,
1212 max_ofdm
->sent_ba_rsp_cnt
);
1213 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1215 le32_to_cpu(ofdm
->dsp_self_kill
),
1216 accum_ofdm
->dsp_self_kill
,
1217 delta_ofdm
->dsp_self_kill
,
1218 max_ofdm
->dsp_self_kill
);
1219 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1221 le32_to_cpu(ofdm
->mh_format_err
),
1222 accum_ofdm
->mh_format_err
,
1223 delta_ofdm
->mh_format_err
,
1224 max_ofdm
->mh_format_err
);
1225 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1226 "re_acq_main_rssi_sum:",
1227 le32_to_cpu(ofdm
->re_acq_main_rssi_sum
),
1228 accum_ofdm
->re_acq_main_rssi_sum
,
1229 delta_ofdm
->re_acq_main_rssi_sum
,
1230 max_ofdm
->re_acq_main_rssi_sum
);
1232 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_header
,
1233 "Statistics_Rx - CCK:");
1234 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1236 le32_to_cpu(cck
->ina_cnt
), accum_cck
->ina_cnt
,
1237 delta_cck
->ina_cnt
, max_cck
->ina_cnt
);
1238 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1240 le32_to_cpu(cck
->fina_cnt
), accum_cck
->fina_cnt
,
1241 delta_cck
->fina_cnt
, max_cck
->fina_cnt
);
1242 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1244 le32_to_cpu(cck
->plcp_err
), accum_cck
->plcp_err
,
1245 delta_cck
->plcp_err
, max_cck
->plcp_err
);
1246 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1248 le32_to_cpu(cck
->crc32_err
), accum_cck
->crc32_err
,
1249 delta_cck
->crc32_err
, max_cck
->crc32_err
);
1250 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1252 le32_to_cpu(cck
->overrun_err
),
1253 accum_cck
->overrun_err
,
1254 delta_cck
->overrun_err
, max_cck
->overrun_err
);
1255 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1256 "early_overrun_err:",
1257 le32_to_cpu(cck
->early_overrun_err
),
1258 accum_cck
->early_overrun_err
,
1259 delta_cck
->early_overrun_err
,
1260 max_cck
->early_overrun_err
);
1261 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1263 le32_to_cpu(cck
->crc32_good
), accum_cck
->crc32_good
,
1264 delta_cck
->crc32_good
,
1265 max_cck
->crc32_good
);
1266 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1268 le32_to_cpu(cck
->false_alarm_cnt
),
1269 accum_cck
->false_alarm_cnt
,
1270 delta_cck
->false_alarm_cnt
, max_cck
->false_alarm_cnt
);
1271 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1272 "fina_sync_err_cnt:",
1273 le32_to_cpu(cck
->fina_sync_err_cnt
),
1274 accum_cck
->fina_sync_err_cnt
,
1275 delta_cck
->fina_sync_err_cnt
,
1276 max_cck
->fina_sync_err_cnt
);
1277 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1279 le32_to_cpu(cck
->sfd_timeout
),
1280 accum_cck
->sfd_timeout
,
1281 delta_cck
->sfd_timeout
, max_cck
->sfd_timeout
);
1282 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1284 le32_to_cpu(cck
->fina_timeout
),
1285 accum_cck
->fina_timeout
,
1286 delta_cck
->fina_timeout
, max_cck
->fina_timeout
);
1287 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1289 le32_to_cpu(cck
->unresponded_rts
),
1290 accum_cck
->unresponded_rts
,
1291 delta_cck
->unresponded_rts
,
1292 max_cck
->unresponded_rts
);
1293 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1294 "rxe_frame_lmt_ovrun:",
1295 le32_to_cpu(cck
->rxe_frame_limit_overrun
),
1296 accum_cck
->rxe_frame_limit_overrun
,
1297 delta_cck
->rxe_frame_limit_overrun
,
1298 max_cck
->rxe_frame_limit_overrun
);
1299 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1301 le32_to_cpu(cck
->sent_ack_cnt
),
1302 accum_cck
->sent_ack_cnt
,
1303 delta_cck
->sent_ack_cnt
,
1304 max_cck
->sent_ack_cnt
);
1305 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1307 le32_to_cpu(cck
->sent_cts_cnt
),
1308 accum_cck
->sent_cts_cnt
,
1309 delta_cck
->sent_cts_cnt
,
1310 max_cck
->sent_cts_cnt
);
1311 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1313 le32_to_cpu(cck
->sent_ba_rsp_cnt
),
1314 accum_cck
->sent_ba_rsp_cnt
,
1315 delta_cck
->sent_ba_rsp_cnt
,
1316 max_cck
->sent_ba_rsp_cnt
);
1317 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1319 le32_to_cpu(cck
->dsp_self_kill
),
1320 accum_cck
->dsp_self_kill
,
1321 delta_cck
->dsp_self_kill
,
1322 max_cck
->dsp_self_kill
);
1323 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1325 le32_to_cpu(cck
->mh_format_err
),
1326 accum_cck
->mh_format_err
,
1327 delta_cck
->mh_format_err
, max_cck
->mh_format_err
);
1328 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1329 "re_acq_main_rssi_sum:",
1330 le32_to_cpu(cck
->re_acq_main_rssi_sum
),
1331 accum_cck
->re_acq_main_rssi_sum
,
1332 delta_cck
->re_acq_main_rssi_sum
,
1333 max_cck
->re_acq_main_rssi_sum
);
1335 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_header
,
1336 "Statistics_Rx - GENERAL:");
1337 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1339 le32_to_cpu(general
->bogus_cts
),
1340 accum_general
->bogus_cts
,
1341 delta_general
->bogus_cts
, max_general
->bogus_cts
);
1342 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1344 le32_to_cpu(general
->bogus_ack
),
1345 accum_general
->bogus_ack
,
1346 delta_general
->bogus_ack
, max_general
->bogus_ack
);
1347 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1348 "non_bssid_frames:",
1349 le32_to_cpu(general
->non_bssid_frames
),
1350 accum_general
->non_bssid_frames
,
1351 delta_general
->non_bssid_frames
,
1352 max_general
->non_bssid_frames
);
1353 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1355 le32_to_cpu(general
->filtered_frames
),
1356 accum_general
->filtered_frames
,
1357 delta_general
->filtered_frames
,
1358 max_general
->filtered_frames
);
1359 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1360 "non_channel_beacons:",
1361 le32_to_cpu(general
->non_channel_beacons
),
1362 accum_general
->non_channel_beacons
,
1363 delta_general
->non_channel_beacons
,
1364 max_general
->non_channel_beacons
);
1365 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1367 le32_to_cpu(general
->channel_beacons
),
1368 accum_general
->channel_beacons
,
1369 delta_general
->channel_beacons
,
1370 max_general
->channel_beacons
);
1371 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1373 le32_to_cpu(general
->num_missed_bcon
),
1374 accum_general
->num_missed_bcon
,
1375 delta_general
->num_missed_bcon
,
1376 max_general
->num_missed_bcon
);
1377 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1378 "adc_rx_saturation_time:",
1379 le32_to_cpu(general
->adc_rx_saturation_time
),
1380 accum_general
->adc_rx_saturation_time
,
1381 delta_general
->adc_rx_saturation_time
,
1382 max_general
->adc_rx_saturation_time
);
1383 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1384 "ina_detect_search_tm:",
1385 le32_to_cpu(general
->ina_detection_search_time
),
1386 accum_general
->ina_detection_search_time
,
1387 delta_general
->ina_detection_search_time
,
1388 max_general
->ina_detection_search_time
);
1389 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1390 "beacon_silence_rssi_a:",
1391 le32_to_cpu(general
->beacon_silence_rssi_a
),
1392 accum_general
->beacon_silence_rssi_a
,
1393 delta_general
->beacon_silence_rssi_a
,
1394 max_general
->beacon_silence_rssi_a
);
1395 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1396 "beacon_silence_rssi_b:",
1397 le32_to_cpu(general
->beacon_silence_rssi_b
),
1398 accum_general
->beacon_silence_rssi_b
,
1399 delta_general
->beacon_silence_rssi_b
,
1400 max_general
->beacon_silence_rssi_b
);
1401 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1402 "beacon_silence_rssi_c:",
1403 le32_to_cpu(general
->beacon_silence_rssi_c
),
1404 accum_general
->beacon_silence_rssi_c
,
1405 delta_general
->beacon_silence_rssi_c
,
1406 max_general
->beacon_silence_rssi_c
);
1407 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1408 "interference_data_flag:",
1409 le32_to_cpu(general
->interference_data_flag
),
1410 accum_general
->interference_data_flag
,
1411 delta_general
->interference_data_flag
,
1412 max_general
->interference_data_flag
);
1413 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1415 le32_to_cpu(general
->channel_load
),
1416 accum_general
->channel_load
,
1417 delta_general
->channel_load
,
1418 max_general
->channel_load
);
1419 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1420 "dsp_false_alarms:",
1421 le32_to_cpu(general
->dsp_false_alarms
),
1422 accum_general
->dsp_false_alarms
,
1423 delta_general
->dsp_false_alarms
,
1424 max_general
->dsp_false_alarms
);
1425 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1427 le32_to_cpu(general
->beacon_rssi_a
),
1428 accum_general
->beacon_rssi_a
,
1429 delta_general
->beacon_rssi_a
,
1430 max_general
->beacon_rssi_a
);
1431 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1433 le32_to_cpu(general
->beacon_rssi_b
),
1434 accum_general
->beacon_rssi_b
,
1435 delta_general
->beacon_rssi_b
,
1436 max_general
->beacon_rssi_b
);
1437 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1439 le32_to_cpu(general
->beacon_rssi_c
),
1440 accum_general
->beacon_rssi_c
,
1441 delta_general
->beacon_rssi_c
,
1442 max_general
->beacon_rssi_c
);
1443 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1445 le32_to_cpu(general
->beacon_energy_a
),
1446 accum_general
->beacon_energy_a
,
1447 delta_general
->beacon_energy_a
,
1448 max_general
->beacon_energy_a
);
1449 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1451 le32_to_cpu(general
->beacon_energy_b
),
1452 accum_general
->beacon_energy_b
,
1453 delta_general
->beacon_energy_b
,
1454 max_general
->beacon_energy_b
);
1455 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1457 le32_to_cpu(general
->beacon_energy_c
),
1458 accum_general
->beacon_energy_c
,
1459 delta_general
->beacon_energy_c
,
1460 max_general
->beacon_energy_c
);
1462 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Statistics_Rx - OFDM_HT:\n");
1463 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_header
,
1464 "Statistics_Rx - OFDM_HT:");
1465 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1467 le32_to_cpu(ht
->plcp_err
), accum_ht
->plcp_err
,
1468 delta_ht
->plcp_err
, max_ht
->plcp_err
);
1469 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1471 le32_to_cpu(ht
->overrun_err
), accum_ht
->overrun_err
,
1472 delta_ht
->overrun_err
, max_ht
->overrun_err
);
1473 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1474 "early_overrun_err:",
1475 le32_to_cpu(ht
->early_overrun_err
),
1476 accum_ht
->early_overrun_err
,
1477 delta_ht
->early_overrun_err
,
1478 max_ht
->early_overrun_err
);
1479 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1481 le32_to_cpu(ht
->crc32_good
), accum_ht
->crc32_good
,
1482 delta_ht
->crc32_good
, max_ht
->crc32_good
);
1483 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1485 le32_to_cpu(ht
->crc32_err
), accum_ht
->crc32_err
,
1486 delta_ht
->crc32_err
, max_ht
->crc32_err
);
1487 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1489 le32_to_cpu(ht
->mh_format_err
),
1490 accum_ht
->mh_format_err
,
1491 delta_ht
->mh_format_err
, max_ht
->mh_format_err
);
1492 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1494 le32_to_cpu(ht
->agg_crc32_good
),
1495 accum_ht
->agg_crc32_good
,
1496 delta_ht
->agg_crc32_good
, max_ht
->agg_crc32_good
);
1497 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1499 le32_to_cpu(ht
->agg_mpdu_cnt
),
1500 accum_ht
->agg_mpdu_cnt
,
1501 delta_ht
->agg_mpdu_cnt
, max_ht
->agg_mpdu_cnt
);
1502 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1504 le32_to_cpu(ht
->agg_cnt
), accum_ht
->agg_cnt
,
1505 delta_ht
->agg_cnt
, max_ht
->agg_cnt
);
1506 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1508 le32_to_cpu(ht
->unsupport_mcs
),
1509 accum_ht
->unsupport_mcs
,
1510 delta_ht
->unsupport_mcs
, max_ht
->unsupport_mcs
);
1512 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1517 static ssize_t
iwl_dbgfs_ucode_tx_stats_read(struct file
*file
,
1518 char __user
*user_buf
,
1519 size_t count
, loff_t
*ppos
)
1521 struct iwl_priv
*priv
= file
->private_data
;
1524 int bufsz
= (sizeof(struct statistics_tx
) * 48) + 250;
1526 struct statistics_tx
*tx
, *accum_tx
, *delta_tx
, *max_tx
;
1528 if (!iwl_is_alive(priv
))
1531 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1533 IWL_ERR(priv
, "Can not allocate Buffer\n");
1537 /* the statistic information display here is based on
1538 * the last statistics notification from uCode
1539 * might not reflect the current uCode activity
1541 tx
= &priv
->statistics
.tx
;
1542 accum_tx
= &priv
->accum_statistics
.tx
;
1543 delta_tx
= &priv
->delta_statistics
.tx
;
1544 max_tx
= &priv
->max_delta
.tx
;
1545 pos
+= iwl_dbgfs_statistics_flag(priv
, buf
, bufsz
);
1546 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_header
,
1548 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1550 le32_to_cpu(tx
->preamble_cnt
),
1551 accum_tx
->preamble_cnt
,
1552 delta_tx
->preamble_cnt
, max_tx
->preamble_cnt
);
1553 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1555 le32_to_cpu(tx
->rx_detected_cnt
),
1556 accum_tx
->rx_detected_cnt
,
1557 delta_tx
->rx_detected_cnt
, max_tx
->rx_detected_cnt
);
1558 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1559 "bt_prio_defer_cnt:",
1560 le32_to_cpu(tx
->bt_prio_defer_cnt
),
1561 accum_tx
->bt_prio_defer_cnt
,
1562 delta_tx
->bt_prio_defer_cnt
,
1563 max_tx
->bt_prio_defer_cnt
);
1564 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1565 "bt_prio_kill_cnt:",
1566 le32_to_cpu(tx
->bt_prio_kill_cnt
),
1567 accum_tx
->bt_prio_kill_cnt
,
1568 delta_tx
->bt_prio_kill_cnt
,
1569 max_tx
->bt_prio_kill_cnt
);
1570 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1572 le32_to_cpu(tx
->few_bytes_cnt
),
1573 accum_tx
->few_bytes_cnt
,
1574 delta_tx
->few_bytes_cnt
, max_tx
->few_bytes_cnt
);
1575 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1577 le32_to_cpu(tx
->cts_timeout
), accum_tx
->cts_timeout
,
1578 delta_tx
->cts_timeout
, max_tx
->cts_timeout
);
1579 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1581 le32_to_cpu(tx
->ack_timeout
),
1582 accum_tx
->ack_timeout
,
1583 delta_tx
->ack_timeout
, max_tx
->ack_timeout
);
1584 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1585 "expected_ack_cnt:",
1586 le32_to_cpu(tx
->expected_ack_cnt
),
1587 accum_tx
->expected_ack_cnt
,
1588 delta_tx
->expected_ack_cnt
,
1589 max_tx
->expected_ack_cnt
);
1590 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1592 le32_to_cpu(tx
->actual_ack_cnt
),
1593 accum_tx
->actual_ack_cnt
,
1594 delta_tx
->actual_ack_cnt
,
1595 max_tx
->actual_ack_cnt
);
1596 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1598 le32_to_cpu(tx
->dump_msdu_cnt
),
1599 accum_tx
->dump_msdu_cnt
,
1600 delta_tx
->dump_msdu_cnt
,
1601 max_tx
->dump_msdu_cnt
);
1602 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1603 "abort_nxt_frame_mismatch:",
1604 le32_to_cpu(tx
->burst_abort_next_frame_mismatch_cnt
),
1605 accum_tx
->burst_abort_next_frame_mismatch_cnt
,
1606 delta_tx
->burst_abort_next_frame_mismatch_cnt
,
1607 max_tx
->burst_abort_next_frame_mismatch_cnt
);
1608 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1609 "abort_missing_nxt_frame:",
1610 le32_to_cpu(tx
->burst_abort_missing_next_frame_cnt
),
1611 accum_tx
->burst_abort_missing_next_frame_cnt
,
1612 delta_tx
->burst_abort_missing_next_frame_cnt
,
1613 max_tx
->burst_abort_missing_next_frame_cnt
);
1614 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1615 "cts_timeout_collision:",
1616 le32_to_cpu(tx
->cts_timeout_collision
),
1617 accum_tx
->cts_timeout_collision
,
1618 delta_tx
->cts_timeout_collision
,
1619 max_tx
->cts_timeout_collision
);
1620 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1621 "ack_ba_timeout_collision:",
1622 le32_to_cpu(tx
->ack_or_ba_timeout_collision
),
1623 accum_tx
->ack_or_ba_timeout_collision
,
1624 delta_tx
->ack_or_ba_timeout_collision
,
1625 max_tx
->ack_or_ba_timeout_collision
);
1626 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1628 le32_to_cpu(tx
->agg
.ba_timeout
),
1629 accum_tx
->agg
.ba_timeout
,
1630 delta_tx
->agg
.ba_timeout
,
1631 max_tx
->agg
.ba_timeout
);
1632 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1633 "agg ba_resched_frames:",
1634 le32_to_cpu(tx
->agg
.ba_reschedule_frames
),
1635 accum_tx
->agg
.ba_reschedule_frames
,
1636 delta_tx
->agg
.ba_reschedule_frames
,
1637 max_tx
->agg
.ba_reschedule_frames
);
1638 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1639 "agg scd_query_agg_frame:",
1640 le32_to_cpu(tx
->agg
.scd_query_agg_frame_cnt
),
1641 accum_tx
->agg
.scd_query_agg_frame_cnt
,
1642 delta_tx
->agg
.scd_query_agg_frame_cnt
,
1643 max_tx
->agg
.scd_query_agg_frame_cnt
);
1644 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1645 "agg scd_query_no_agg:",
1646 le32_to_cpu(tx
->agg
.scd_query_no_agg
),
1647 accum_tx
->agg
.scd_query_no_agg
,
1648 delta_tx
->agg
.scd_query_no_agg
,
1649 max_tx
->agg
.scd_query_no_agg
);
1650 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1651 "agg scd_query_agg:",
1652 le32_to_cpu(tx
->agg
.scd_query_agg
),
1653 accum_tx
->agg
.scd_query_agg
,
1654 delta_tx
->agg
.scd_query_agg
,
1655 max_tx
->agg
.scd_query_agg
);
1656 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1657 "agg scd_query_mismatch:",
1658 le32_to_cpu(tx
->agg
.scd_query_mismatch
),
1659 accum_tx
->agg
.scd_query_mismatch
,
1660 delta_tx
->agg
.scd_query_mismatch
,
1661 max_tx
->agg
.scd_query_mismatch
);
1662 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1663 "agg frame_not_ready:",
1664 le32_to_cpu(tx
->agg
.frame_not_ready
),
1665 accum_tx
->agg
.frame_not_ready
,
1666 delta_tx
->agg
.frame_not_ready
,
1667 max_tx
->agg
.frame_not_ready
);
1668 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1670 le32_to_cpu(tx
->agg
.underrun
),
1671 accum_tx
->agg
.underrun
,
1672 delta_tx
->agg
.underrun
, max_tx
->agg
.underrun
);
1673 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1674 "agg bt_prio_kill:",
1675 le32_to_cpu(tx
->agg
.bt_prio_kill
),
1676 accum_tx
->agg
.bt_prio_kill
,
1677 delta_tx
->agg
.bt_prio_kill
,
1678 max_tx
->agg
.bt_prio_kill
);
1679 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1680 "agg rx_ba_rsp_cnt:",
1681 le32_to_cpu(tx
->agg
.rx_ba_rsp_cnt
),
1682 accum_tx
->agg
.rx_ba_rsp_cnt
,
1683 delta_tx
->agg
.rx_ba_rsp_cnt
,
1684 max_tx
->agg
.rx_ba_rsp_cnt
);
1686 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1691 static ssize_t
iwl_dbgfs_ucode_general_stats_read(struct file
*file
,
1692 char __user
*user_buf
,
1693 size_t count
, loff_t
*ppos
)
1695 struct iwl_priv
*priv
= file
->private_data
;
1698 int bufsz
= sizeof(struct statistics_general
) * 10 + 300;
1700 struct statistics_general
*general
, *accum_general
;
1701 struct statistics_general
*delta_general
, *max_general
;
1702 struct statistics_dbg
*dbg
, *accum_dbg
, *delta_dbg
, *max_dbg
;
1703 struct statistics_div
*div
, *accum_div
, *delta_div
, *max_div
;
1705 if (!iwl_is_alive(priv
))
1708 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1710 IWL_ERR(priv
, "Can not allocate Buffer\n");
1714 /* the statistic information display here is based on
1715 * the last statistics notification from uCode
1716 * might not reflect the current uCode activity
1718 general
= &priv
->statistics
.general
;
1719 dbg
= &priv
->statistics
.general
.dbg
;
1720 div
= &priv
->statistics
.general
.div
;
1721 accum_general
= &priv
->accum_statistics
.general
;
1722 delta_general
= &priv
->delta_statistics
.general
;
1723 max_general
= &priv
->max_delta
.general
;
1724 accum_dbg
= &priv
->accum_statistics
.general
.dbg
;
1725 delta_dbg
= &priv
->delta_statistics
.general
.dbg
;
1726 max_dbg
= &priv
->max_delta
.general
.dbg
;
1727 accum_div
= &priv
->accum_statistics
.general
.div
;
1728 delta_div
= &priv
->delta_statistics
.general
.div
;
1729 max_div
= &priv
->max_delta
.general
.div
;
1730 pos
+= iwl_dbgfs_statistics_flag(priv
, buf
, bufsz
);
1731 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_header
,
1732 "Statistics_General:");
1733 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_short_format
,
1735 le32_to_cpu(general
->temperature
));
1736 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_short_format
,
1738 le32_to_cpu(general
->temperature_m
));
1739 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1741 le32_to_cpu(dbg
->burst_check
),
1742 accum_dbg
->burst_check
,
1743 delta_dbg
->burst_check
, max_dbg
->burst_check
);
1744 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1746 le32_to_cpu(dbg
->burst_count
),
1747 accum_dbg
->burst_count
,
1748 delta_dbg
->burst_count
, max_dbg
->burst_count
);
1749 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1751 le32_to_cpu(general
->sleep_time
),
1752 accum_general
->sleep_time
,
1753 delta_general
->sleep_time
, max_general
->sleep_time
);
1754 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1756 le32_to_cpu(general
->slots_out
),
1757 accum_general
->slots_out
,
1758 delta_general
->slots_out
, max_general
->slots_out
);
1759 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1761 le32_to_cpu(general
->slots_idle
),
1762 accum_general
->slots_idle
,
1763 delta_general
->slots_idle
, max_general
->slots_idle
);
1764 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "ttl_timestamp:\t\t\t%u\n",
1765 le32_to_cpu(general
->ttl_timestamp
));
1766 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1768 le32_to_cpu(div
->tx_on_a
), accum_div
->tx_on_a
,
1769 delta_div
->tx_on_a
, max_div
->tx_on_a
);
1770 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1772 le32_to_cpu(div
->tx_on_b
), accum_div
->tx_on_b
,
1773 delta_div
->tx_on_b
, max_div
->tx_on_b
);
1774 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1776 le32_to_cpu(div
->exec_time
), accum_div
->exec_time
,
1777 delta_div
->exec_time
, max_div
->exec_time
);
1778 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1780 le32_to_cpu(div
->probe_time
), accum_div
->probe_time
,
1781 delta_div
->probe_time
, max_div
->probe_time
);
1782 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1783 "rx_enable_counter:",
1784 le32_to_cpu(general
->rx_enable_counter
),
1785 accum_general
->rx_enable_counter
,
1786 delta_general
->rx_enable_counter
,
1787 max_general
->rx_enable_counter
);
1788 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, ucode_stats_format
,
1789 "num_of_sos_states:",
1790 le32_to_cpu(general
->num_of_sos_states
),
1791 accum_general
->num_of_sos_states
,
1792 delta_general
->num_of_sos_states
,
1793 max_general
->num_of_sos_states
);
1794 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1799 static ssize_t
iwl_dbgfs_sensitivity_read(struct file
*file
,
1800 char __user
*user_buf
,
1801 size_t count
, loff_t
*ppos
) {
1803 struct iwl_priv
*priv
= file
->private_data
;
1807 int bufsz
= sizeof(struct iwl_sensitivity_data
) * 4 + 100;
1809 struct iwl_sensitivity_data
*data
;
1811 data
= &priv
->sensitivity_data
;
1812 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1814 IWL_ERR(priv
, "Can not allocate Buffer\n");
1818 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_ofdm:\t\t\t %u\n",
1819 data
->auto_corr_ofdm
);
1820 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1821 "auto_corr_ofdm_mrc:\t\t %u\n",
1822 data
->auto_corr_ofdm_mrc
);
1823 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_ofdm_x1:\t\t %u\n",
1824 data
->auto_corr_ofdm_x1
);
1825 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1826 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1827 data
->auto_corr_ofdm_mrc_x1
);
1828 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_cck:\t\t\t %u\n",
1829 data
->auto_corr_cck
);
1830 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "auto_corr_cck_mrc:\t\t %u\n",
1831 data
->auto_corr_cck_mrc
);
1832 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1833 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1834 data
->last_bad_plcp_cnt_ofdm
);
1835 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "last_fa_cnt_ofdm:\t\t %u\n",
1836 data
->last_fa_cnt_ofdm
);
1837 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1838 "last_bad_plcp_cnt_cck:\t\t %u\n",
1839 data
->last_bad_plcp_cnt_cck
);
1840 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "last_fa_cnt_cck:\t\t %u\n",
1841 data
->last_fa_cnt_cck
);
1842 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_curr_state:\t\t\t %u\n",
1843 data
->nrg_curr_state
);
1844 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_prev_state:\t\t\t %u\n",
1845 data
->nrg_prev_state
);
1846 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_value:\t\t\t");
1847 for (cnt
= 0; cnt
< 10; cnt
++) {
1848 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1849 data
->nrg_value
[cnt
]);
1851 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1852 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_silence_rssi:\t\t");
1853 for (cnt
= 0; cnt
< NRG_NUM_PREV_STAT_L
; cnt
++) {
1854 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1855 data
->nrg_silence_rssi
[cnt
]);
1857 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1858 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_silence_ref:\t\t %u\n",
1859 data
->nrg_silence_ref
);
1860 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_energy_idx:\t\t\t %u\n",
1861 data
->nrg_energy_idx
);
1862 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_silence_idx:\t\t %u\n",
1863 data
->nrg_silence_idx
);
1864 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_th_cck:\t\t\t %u\n",
1866 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1867 "nrg_auto_corr_silence_diff:\t %u\n",
1868 data
->nrg_auto_corr_silence_diff
);
1869 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "num_in_cck_no_fa:\t\t %u\n",
1870 data
->num_in_cck_no_fa
);
1871 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "nrg_th_ofdm:\t\t\t %u\n",
1874 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1880 static ssize_t
iwl_dbgfs_chain_noise_read(struct file
*file
,
1881 char __user
*user_buf
,
1882 size_t count
, loff_t
*ppos
) {
1884 struct iwl_priv
*priv
= file
->private_data
;
1888 int bufsz
= sizeof(struct iwl_chain_noise_data
) * 4 + 100;
1890 struct iwl_chain_noise_data
*data
;
1892 data
= &priv
->chain_noise_data
;
1893 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1895 IWL_ERR(priv
, "Can not allocate Buffer\n");
1899 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "active_chains:\t\t\t %u\n",
1900 data
->active_chains
);
1901 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_noise_a:\t\t\t %u\n",
1902 data
->chain_noise_a
);
1903 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_noise_b:\t\t\t %u\n",
1904 data
->chain_noise_b
);
1905 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_noise_c:\t\t\t %u\n",
1906 data
->chain_noise_c
);
1907 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_signal_a:\t\t\t %u\n",
1908 data
->chain_signal_a
);
1909 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_signal_b:\t\t\t %u\n",
1910 data
->chain_signal_b
);
1911 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "chain_signal_c:\t\t\t %u\n",
1912 data
->chain_signal_c
);
1913 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "beacon_count:\t\t\t %u\n",
1914 data
->beacon_count
);
1916 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "disconn_array:\t\t\t");
1917 for (cnt
= 0; cnt
< NUM_RX_CHAINS
; cnt
++) {
1918 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1919 data
->disconn_array
[cnt
]);
1921 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1922 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "delta_gain_code:\t\t");
1923 for (cnt
= 0; cnt
< NUM_RX_CHAINS
; cnt
++) {
1924 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " %u",
1925 data
->delta_gain_code
[cnt
]);
1927 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "\n");
1928 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "radio_write:\t\t\t %u\n",
1930 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "state:\t\t\t\t %u\n",
1933 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1938 static ssize_t
iwl_dbgfs_tx_power_read(struct file
*file
,
1939 char __user
*user_buf
,
1940 size_t count
, loff_t
*ppos
) {
1942 struct iwl_priv
*priv
= file
->private_data
;
1945 const size_t bufsz
= sizeof(buf
);
1946 struct statistics_tx
*tx
;
1948 if (!iwl_is_alive(priv
))
1949 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "N/A\n");
1951 tx
= &priv
->statistics
.tx
;
1952 if (tx
->tx_power
.ant_a
||
1953 tx
->tx_power
.ant_b
||
1954 tx
->tx_power
.ant_c
) {
1955 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1956 "tx power: (1/2 dB step)\n");
1957 if ((priv
->cfg
->valid_tx_ant
& ANT_A
) &&
1959 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1960 "\tantenna A: 0x%X\n",
1961 tx
->tx_power
.ant_a
);
1962 if ((priv
->cfg
->valid_tx_ant
& ANT_B
) &&
1964 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1965 "\tantenna B: 0x%X\n",
1966 tx
->tx_power
.ant_b
);
1967 if ((priv
->cfg
->valid_tx_ant
& ANT_C
) &&
1969 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1970 "\tantenna C: 0x%X\n",
1971 tx
->tx_power
.ant_c
);
1973 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "N/A\n");
1975 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1978 static ssize_t
iwl_dbgfs_power_save_status_read(struct file
*file
,
1979 char __user
*user_buf
,
1980 size_t count
, loff_t
*ppos
)
1982 struct iwl_priv
*priv
= file
->private_data
;
1985 const size_t bufsz
= sizeof(buf
);
1988 pwrsave_status
= iwl_read32(priv
, CSR_GP_CNTRL
) &
1989 CSR_GP_REG_POWER_SAVE_STATUS_MSK
;
1991 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Power Save Status: ");
1992 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%s\n",
1993 (pwrsave_status
== CSR_GP_REG_NO_POWER_SAVE
) ? "none" :
1994 (pwrsave_status
== CSR_GP_REG_MAC_POWER_SAVE
) ? "MAC" :
1995 (pwrsave_status
== CSR_GP_REG_PHY_POWER_SAVE
) ? "PHY" :
1998 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2001 static ssize_t
iwl_dbgfs_clear_ucode_statistics_write(struct file
*file
,
2002 const char __user
*user_buf
,
2003 size_t count
, loff_t
*ppos
)
2005 struct iwl_priv
*priv
= file
->private_data
;
2010 memset(buf
, 0, sizeof(buf
));
2011 buf_size
= min(count
, sizeof(buf
) - 1);
2012 if (copy_from_user(buf
, user_buf
, buf_size
))
2014 if (sscanf(buf
, "%d", &clear
) != 1)
2017 /* make request to uCode to retrieve statistics information */
2018 mutex_lock(&priv
->mutex
);
2019 iwl_send_statistics_request(priv
, CMD_SYNC
, true);
2020 mutex_unlock(&priv
->mutex
);
2025 static ssize_t
iwl_dbgfs_csr_write(struct file
*file
,
2026 const char __user
*user_buf
,
2027 size_t count
, loff_t
*ppos
)
2029 struct iwl_priv
*priv
= file
->private_data
;
2034 memset(buf
, 0, sizeof(buf
));
2035 buf_size
= min(count
, sizeof(buf
) - 1);
2036 if (copy_from_user(buf
, user_buf
, buf_size
))
2038 if (sscanf(buf
, "%d", &csr
) != 1)
2041 if (priv
->cfg
->ops
->lib
->dump_csr
)
2042 priv
->cfg
->ops
->lib
->dump_csr(priv
);
2047 static ssize_t
iwl_dbgfs_ucode_tracing_read(struct file
*file
,
2048 char __user
*user_buf
,
2049 size_t count
, loff_t
*ppos
) {
2051 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
2054 const size_t bufsz
= sizeof(buf
);
2057 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "ucode trace timer is %s\n",
2058 priv
->event_log
.ucode_trace
? "On" : "Off");
2059 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "non_wraps_count:\t\t %u\n",
2060 priv
->event_log
.non_wraps_count
);
2061 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "wraps_once_count:\t\t %u\n",
2062 priv
->event_log
.wraps_once_count
);
2063 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "wraps_more_count:\t\t %u\n",
2064 priv
->event_log
.wraps_more_count
);
2066 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2070 static ssize_t
iwl_dbgfs_ucode_tracing_write(struct file
*file
,
2071 const char __user
*user_buf
,
2072 size_t count
, loff_t
*ppos
)
2074 struct iwl_priv
*priv
= file
->private_data
;
2079 memset(buf
, 0, sizeof(buf
));
2080 buf_size
= min(count
, sizeof(buf
) - 1);
2081 if (copy_from_user(buf
, user_buf
, buf_size
))
2083 if (sscanf(buf
, "%d", &trace
) != 1)
2087 priv
->event_log
.ucode_trace
= true;
2088 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2089 mod_timer(&priv
->ucode_trace
,
2090 jiffies
+ msecs_to_jiffies(UCODE_TRACE_PERIOD
));
2092 priv
->event_log
.ucode_trace
= false;
2093 del_timer_sync(&priv
->ucode_trace
);
2099 static ssize_t
iwl_dbgfs_fh_reg_read(struct file
*file
,
2100 char __user
*user_buf
,
2101 size_t count
, loff_t
*ppos
)
2103 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
2106 ssize_t ret
= -EFAULT
;
2108 if (priv
->cfg
->ops
->lib
->dump_fh
) {
2109 ret
= pos
= priv
->cfg
->ops
->lib
->dump_fh(priv
, &buf
, true);
2111 ret
= simple_read_from_buffer(user_buf
,
2112 count
, ppos
, buf
, pos
);
2120 static ssize_t
iwl_dbgfs_missed_beacon_read(struct file
*file
,
2121 char __user
*user_buf
,
2122 size_t count
, loff_t
*ppos
) {
2124 struct iwl_priv
*priv
= file
->private_data
;
2127 const size_t bufsz
= sizeof(buf
);
2130 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%d\n",
2131 priv
->missed_beacon_threshold
);
2133 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2137 static ssize_t
iwl_dbgfs_missed_beacon_write(struct file
*file
,
2138 const char __user
*user_buf
,
2139 size_t count
, loff_t
*ppos
)
2141 struct iwl_priv
*priv
= file
->private_data
;
2146 memset(buf
, 0, sizeof(buf
));
2147 buf_size
= min(count
, sizeof(buf
) - 1);
2148 if (copy_from_user(buf
, user_buf
, buf_size
))
2150 if (sscanf(buf
, "%d", &missed
) != 1)
2153 if (missed
< IWL_MISSED_BEACON_THRESHOLD_MIN
||
2154 missed
> IWL_MISSED_BEACON_THRESHOLD_MAX
)
2155 priv
->missed_beacon_threshold
=
2156 IWL_MISSED_BEACON_THRESHOLD_DEF
;
2158 priv
->missed_beacon_threshold
= missed
;
2163 static ssize_t
iwl_dbgfs_internal_scan_write(struct file
*file
,
2164 const char __user
*user_buf
,
2165 size_t count
, loff_t
*ppos
)
2167 struct iwl_priv
*priv
= file
->private_data
;
2172 memset(buf
, 0, sizeof(buf
));
2173 buf_size
= min(count
, sizeof(buf
) - 1);
2174 if (copy_from_user(buf
, user_buf
, buf_size
))
2176 if (sscanf(buf
, "%d", &scan
) != 1)
2179 iwl_internal_short_hw_scan(priv
);
2184 static ssize_t
iwl_dbgfs_plcp_delta_read(struct file
*file
,
2185 char __user
*user_buf
,
2186 size_t count
, loff_t
*ppos
) {
2188 struct iwl_priv
*priv
= (struct iwl_priv
*)file
->private_data
;
2191 const size_t bufsz
= sizeof(buf
);
2194 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%u\n",
2195 priv
->cfg
->plcp_delta_threshold
);
2197 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2201 static ssize_t
iwl_dbgfs_plcp_delta_write(struct file
*file
,
2202 const char __user
*user_buf
,
2203 size_t count
, loff_t
*ppos
) {
2205 struct iwl_priv
*priv
= file
->private_data
;
2210 memset(buf
, 0, sizeof(buf
));
2211 buf_size
= min(count
, sizeof(buf
) - 1);
2212 if (copy_from_user(buf
, user_buf
, buf_size
))
2214 if (sscanf(buf
, "%d", &plcp
) != 1)
2216 if ((plcp
<= IWL_MAX_PLCP_ERR_THRESHOLD_MIN
) ||
2217 (plcp
> IWL_MAX_PLCP_ERR_THRESHOLD_MAX
))
2218 priv
->cfg
->plcp_delta_threshold
=
2219 IWL_MAX_PLCP_ERR_THRESHOLD_DEF
;
2221 priv
->cfg
->plcp_delta_threshold
= plcp
;
2225 static ssize_t
iwl_dbgfs_force_reset_read(struct file
*file
,
2226 char __user
*user_buf
,
2227 size_t count
, loff_t
*ppos
) {
2229 struct iwl_priv
*priv
= file
->private_data
;
2232 const size_t bufsz
= sizeof(buf
);
2233 struct iwl_force_reset
*force_reset
;
2235 for (i
= 0; i
< IWL_MAX_FORCE_RESET
; i
++) {
2236 force_reset
= &priv
->force_reset
[i
];
2237 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2238 "Force reset method %d\n", i
);
2239 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2240 "\tnumber of reset request: %d\n",
2241 force_reset
->reset_request_count
);
2242 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2243 "\tnumber of reset request success: %d\n",
2244 force_reset
->reset_success_count
);
2245 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2246 "\tnumber of reset request reject: %d\n",
2247 force_reset
->reset_reject_count
);
2248 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
2249 "\treset duration: %lu\n",
2250 force_reset
->reset_duration
);
2252 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
2255 static ssize_t
iwl_dbgfs_force_reset_write(struct file
*file
,
2256 const char __user
*user_buf
,
2257 size_t count
, loff_t
*ppos
) {
2259 struct iwl_priv
*priv
= file
->private_data
;
2264 memset(buf
, 0, sizeof(buf
));
2265 buf_size
= min(count
, sizeof(buf
) - 1);
2266 if (copy_from_user(buf
, user_buf
, buf_size
))
2268 if (sscanf(buf
, "%d", &reset
) != 1)
2273 ret
= iwl_force_reset(priv
, reset
);
2278 return ret
? ret
: count
;
2281 DEBUGFS_READ_FILE_OPS(rx_statistics
);
2282 DEBUGFS_READ_FILE_OPS(tx_statistics
);
2283 DEBUGFS_READ_WRITE_FILE_OPS(traffic_log
);
2284 DEBUGFS_READ_FILE_OPS(rx_queue
);
2285 DEBUGFS_READ_FILE_OPS(tx_queue
);
2286 DEBUGFS_READ_FILE_OPS(ucode_rx_stats
);
2287 DEBUGFS_READ_FILE_OPS(ucode_tx_stats
);
2288 DEBUGFS_READ_FILE_OPS(ucode_general_stats
);
2289 DEBUGFS_READ_FILE_OPS(sensitivity
);
2290 DEBUGFS_READ_FILE_OPS(chain_noise
);
2291 DEBUGFS_READ_FILE_OPS(tx_power
);
2292 DEBUGFS_READ_FILE_OPS(power_save_status
);
2293 DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics
);
2294 DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics
);
2295 DEBUGFS_WRITE_FILE_OPS(csr
);
2296 DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing
);
2297 DEBUGFS_READ_FILE_OPS(fh_reg
);
2298 DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon
);
2299 DEBUGFS_WRITE_FILE_OPS(internal_scan
);
2300 DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta
);
2301 DEBUGFS_READ_WRITE_FILE_OPS(force_reset
);
2304 * Create the debugfs files and directories
2307 int iwl_dbgfs_register(struct iwl_priv
*priv
, const char *name
)
2309 struct dentry
*phyd
= priv
->hw
->wiphy
->debugfsdir
;
2310 struct dentry
*dir_drv
, *dir_data
, *dir_rf
, *dir_debug
;
2312 dir_drv
= debugfs_create_dir(name
, phyd
);
2316 priv
->debugfs_dir
= dir_drv
;
2318 dir_data
= debugfs_create_dir("data", dir_drv
);
2321 dir_rf
= debugfs_create_dir("rf", dir_drv
);
2324 dir_debug
= debugfs_create_dir("debug", dir_drv
);
2328 DEBUGFS_ADD_FILE(nvm
, dir_data
, S_IRUSR
);
2329 DEBUGFS_ADD_FILE(sram
, dir_data
, S_IWUSR
| S_IRUSR
);
2330 DEBUGFS_ADD_FILE(log_event
, dir_data
, S_IWUSR
| S_IRUSR
);
2331 DEBUGFS_ADD_FILE(stations
, dir_data
, S_IRUSR
);
2332 DEBUGFS_ADD_FILE(channels
, dir_data
, S_IRUSR
);
2333 DEBUGFS_ADD_FILE(status
, dir_data
, S_IRUSR
);
2334 DEBUGFS_ADD_FILE(interrupt
, dir_data
, S_IWUSR
| S_IRUSR
);
2335 DEBUGFS_ADD_FILE(qos
, dir_data
, S_IRUSR
);
2336 DEBUGFS_ADD_FILE(led
, dir_data
, S_IRUSR
);
2337 DEBUGFS_ADD_FILE(sleep_level_override
, dir_data
, S_IWUSR
| S_IRUSR
);
2338 DEBUGFS_ADD_FILE(current_sleep_command
, dir_data
, S_IRUSR
);
2339 DEBUGFS_ADD_FILE(thermal_throttling
, dir_data
, S_IRUSR
);
2340 DEBUGFS_ADD_FILE(disable_ht40
, dir_data
, S_IWUSR
| S_IRUSR
);
2341 DEBUGFS_ADD_FILE(rx_statistics
, dir_debug
, S_IRUSR
);
2342 DEBUGFS_ADD_FILE(tx_statistics
, dir_debug
, S_IRUSR
);
2343 DEBUGFS_ADD_FILE(traffic_log
, dir_debug
, S_IWUSR
| S_IRUSR
);
2344 DEBUGFS_ADD_FILE(rx_queue
, dir_debug
, S_IRUSR
);
2345 DEBUGFS_ADD_FILE(tx_queue
, dir_debug
, S_IRUSR
);
2346 DEBUGFS_ADD_FILE(tx_power
, dir_debug
, S_IRUSR
);
2347 DEBUGFS_ADD_FILE(power_save_status
, dir_debug
, S_IRUSR
);
2348 DEBUGFS_ADD_FILE(clear_ucode_statistics
, dir_debug
, S_IWUSR
);
2349 DEBUGFS_ADD_FILE(clear_traffic_statistics
, dir_debug
, S_IWUSR
);
2350 DEBUGFS_ADD_FILE(csr
, dir_debug
, S_IWUSR
);
2351 DEBUGFS_ADD_FILE(fh_reg
, dir_debug
, S_IRUSR
);
2352 DEBUGFS_ADD_FILE(missed_beacon
, dir_debug
, S_IWUSR
);
2353 DEBUGFS_ADD_FILE(internal_scan
, dir_debug
, S_IWUSR
);
2354 DEBUGFS_ADD_FILE(plcp_delta
, dir_debug
, S_IWUSR
| S_IRUSR
);
2355 DEBUGFS_ADD_FILE(force_reset
, dir_debug
, S_IWUSR
| S_IRUSR
);
2356 if ((priv
->hw_rev
& CSR_HW_REV_TYPE_MSK
) != CSR_HW_REV_TYPE_3945
) {
2357 DEBUGFS_ADD_FILE(ucode_rx_stats
, dir_debug
, S_IRUSR
);
2358 DEBUGFS_ADD_FILE(ucode_tx_stats
, dir_debug
, S_IRUSR
);
2359 DEBUGFS_ADD_FILE(ucode_general_stats
, dir_debug
, S_IRUSR
);
2360 DEBUGFS_ADD_FILE(sensitivity
, dir_debug
, S_IRUSR
);
2361 DEBUGFS_ADD_FILE(chain_noise
, dir_debug
, S_IRUSR
);
2362 DEBUGFS_ADD_FILE(ucode_tracing
, dir_debug
, S_IWUSR
| S_IRUSR
);
2364 DEBUGFS_ADD_BOOL(disable_sensitivity
, dir_rf
, &priv
->disable_sens_cal
);
2365 DEBUGFS_ADD_BOOL(disable_chain_noise
, dir_rf
,
2366 &priv
->disable_chain_noise_cal
);
2367 if (((priv
->hw_rev
& CSR_HW_REV_TYPE_MSK
) == CSR_HW_REV_TYPE_4965
) ||
2368 ((priv
->hw_rev
& CSR_HW_REV_TYPE_MSK
) == CSR_HW_REV_TYPE_3945
))
2369 DEBUGFS_ADD_BOOL(disable_tx_power
, dir_rf
,
2370 &priv
->disable_tx_power_cal
);
2374 IWL_ERR(priv
, "Can't create the debugfs directory\n");
2375 iwl_dbgfs_unregister(priv
);
2378 EXPORT_SYMBOL(iwl_dbgfs_register
);
2381 * Remove the debugfs files and directories
2384 void iwl_dbgfs_unregister(struct iwl_priv
*priv
)
2386 if (!priv
->debugfs_dir
)
2389 debugfs_remove_recursive(priv
->debugfs_dir
);
2390 priv
->debugfs_dir
= NULL
;
2392 EXPORT_SYMBOL(iwl_dbgfs_unregister
);