29 #include <linux/export.h>
55 if (ieee80211_is_mgmt(fc)) {
94 }
else if (ieee80211_is_ctl(fc)) {
124 stats->data_bytes += len;
130 #define DEBUGFS_ADD_FILE(name, parent, mode) do { \
131 if (!debugfs_create_file(#name, mode, parent, il, \
132 &il_dbgfs_##name##_ops)) \
136 #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
137 struct dentry *__tmp; \
138 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
140 if (IS_ERR(__tmp) || !__tmp) \
144 #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
145 struct dentry *__tmp; \
146 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
148 if (IS_ERR(__tmp) || !__tmp) \
153 #define DEBUGFS_READ_FUNC(name) \
154 static ssize_t il_dbgfs_##name##_read(struct file *file, \
155 char __user *user_buf, \
156 size_t count, loff_t *ppos);
158 #define DEBUGFS_WRITE_FUNC(name) \
159 static ssize_t il_dbgfs_##name##_write(struct file *file, \
160 const char __user *user_buf, \
161 size_t count, loff_t *ppos);
164 #define DEBUGFS_READ_FILE_OPS(name) \
165 DEBUGFS_READ_FUNC(name); \
166 static const struct file_operations il_dbgfs_##name##_ops = { \
167 .read = il_dbgfs_##name##_read, \
168 .open = simple_open, \
169 .llseek = generic_file_llseek, \
172 #define DEBUGFS_WRITE_FILE_OPS(name) \
173 DEBUGFS_WRITE_FUNC(name); \
174 static const struct file_operations il_dbgfs_##name##_ops = { \
175 .write = il_dbgfs_##name##_write, \
176 .open = simple_open, \
177 .llseek = generic_file_llseek, \
180 #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
181 DEBUGFS_READ_FUNC(name); \
182 DEBUGFS_WRITE_FUNC(name); \
183 static const struct file_operations il_dbgfs_##name##_ops = { \
184 .write = il_dbgfs_##name##_write, \
185 .read = il_dbgfs_##name##_read, \
186 .open = simple_open, \
187 .llseek = generic_file_llseek, \
191 il_get_mgmt_string(
int cmd)
213 il_get_ctrl_string(
int cmd)
231 il_dbgfs_tx_stats_read(
struct file *
file,
char __user *user_buf,
size_t count,
246 pos +=
scnprintf(buf + pos, bufsz - pos,
"Management:\n");
249 scnprintf(buf + pos, bufsz - pos,
"\t%25s\t\t: %u\n",
250 il_get_mgmt_string(cnt), il->
tx_stats.mgmt[cnt]);
252 pos +=
scnprintf(buf + pos, bufsz - pos,
"Control\n");
255 scnprintf(buf + pos, bufsz - pos,
"\t%25s\t\t: %u\n",
256 il_get_ctrl_string(cnt), il->
tx_stats.ctrl[cnt]);
258 pos +=
scnprintf(buf + pos, bufsz - pos,
"Data:\n");
260 scnprintf(buf + pos, bufsz - pos,
"\tcnt: %u\n",
263 scnprintf(buf + pos, bufsz - pos,
"\tbytes: %llu\n",
271 il_dbgfs_clear_traffic_stats_write(
struct file *file,
272 const char __user *user_buf,
size_t count,
280 memset(buf, 0,
sizeof(buf));
281 buf_size =
min(count,
sizeof(buf) - 1);
284 if (
sscanf(buf,
"%x", &clear_flag) != 1)
292 il_dbgfs_rx_stats_read(
struct file *file,
char __user *user_buf,
size_t count,
302 100 +
sizeof(
char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
307 pos +=
scnprintf(buf + pos, bufsz - pos,
"Management:\n");
310 scnprintf(buf + pos, bufsz - pos,
"\t%25s\t\t: %u\n",
311 il_get_mgmt_string(cnt), il->
rx_stats.mgmt[cnt]);
313 pos +=
scnprintf(buf + pos, bufsz - pos,
"Control:\n");
316 scnprintf(buf + pos, bufsz - pos,
"\t%25s\t\t: %u\n",
317 il_get_ctrl_string(cnt), il->
rx_stats.ctrl[cnt]);
319 pos +=
scnprintf(buf + pos, bufsz - pos,
"Data:\n");
321 scnprintf(buf + pos, bufsz - pos,
"\tcnt: %u\n",
324 scnprintf(buf + pos, bufsz - pos,
"\tbytes: %llu\n",
332 #define BYTE1_MASK 0x000000ff;
333 #define BYTE2_MASK 0x0000ffff;
334 #define BYTE3_MASK 0x00ffffff;
336 il_dbgfs_sram_read(
struct file *file,
char __user *user_buf,
size_t count,
348 if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) {
349 il->dbgfs_sram_offset = 0x800000;
355 bufsz = 30 + il->dbgfs_sram_len *
sizeof(
char) * 10;
360 scnprintf(buf + pos, bufsz - pos,
"sram_len: 0x%x\n",
363 scnprintf(buf + pos, bufsz - pos,
"sram_offset: 0x%x\n",
364 il->dbgfs_sram_offset);
365 for (i = il->dbgfs_sram_len; i > 0; i -= 4) {
368 il->dbgfs_sram_offset +
369 il->dbgfs_sram_len - i);
384 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
385 pos +=
scnprintf(buf + pos, bufsz - pos,
"0x%08x ", val);
387 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
395 il_dbgfs_sram_write(
struct file *file,
const char __user *user_buf,
396 size_t count, loff_t *ppos)
403 memset(buf, 0,
sizeof(buf));
404 buf_size =
min(count,
sizeof(buf) - 1);
408 if (
sscanf(buf,
"%x,%x", &offset, &len) == 2) {
409 il->dbgfs_sram_offset =
offset;
410 il->dbgfs_sram_len = len;
412 il->dbgfs_sram_offset = 0;
413 il->dbgfs_sram_len = 0;
420 il_dbgfs_stations_read(
struct file *file,
char __user *user_buf,
size_t count,
425 int max_sta = il->
hw_params.max_stations;
437 scnprintf(buf + pos, bufsz - pos,
"num of stations: %d\n\n",
440 for (i = 0; i < max_sta; i++) {
446 "station %d - addr: %pM, flags: %#x\n", i,
447 station->
sta.sta.addr,
448 station->
sta.station_flags_msk);
451 "TID\tseq_num\ttxq_id\tframes\ttfds\t");
454 "start_idx\tbitmap\t\t\trate_n_flags\n");
459 "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x",
460 j, station->
tid[j].seq_number,
461 station->
tid[j].agg.txq_id,
462 station->
tid[j].agg.frame_count,
463 station->
tid[j].tfds_in_queue,
464 station->
tid[j].agg.start_idx,
465 station->
tid[j].agg.bitmap,
466 station->
tid[j].agg.rate_n_flags);
468 if (station->
tid[j].agg.wait_for_ba)
472 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
475 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
484 il_dbgfs_nvm_read(
struct file *file,
char __user *user_buf,
size_t count,
489 int pos = 0, ofs = 0, buf_size = 0;
493 size_t eeprom_len = il->
cfg->eeprom_size;
494 buf_size = 4 * eeprom_len + 256;
496 if (eeprom_len % 16) {
497 IL_ERR(
"NVM size is not multiple of 16.\n");
503 IL_ERR(
"Invalid EEPROM memory\n");
510 IL_ERR(
"Can not allocate Buffer\n");
515 scnprintf(buf + pos, buf_size - pos,
"EEPROM " "version: 0x%x\n",
517 for (ofs = 0; ofs < eeprom_len; ofs += 16) {
518 pos +=
scnprintf(buf + pos, buf_size - pos,
"0x%.4x ", ofs);
522 if (buf_size - pos > 0)
532 il_dbgfs_channels_read(
struct file *file,
char __user *user_buf,
size_t count,
547 IL_ERR(
"Can not allocate Buffer\n");
557 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
563 "%d: %ddBm: BSS%s%s, %s.\n",
564 channels[i].hw_value,
568 " (IEEE 802.11h required)" :
"",
572 flags & IEEE80211_CHAN_RADAR)) ?
"" :
576 "passive only" :
"active/passive");
584 "Displaying %d channels in 5.2GHz band (802.11a)\n",
590 "%d: %ddBm: BSS%s%s, %s.\n",
591 channels[i].hw_value,
592 channels[i].max_power,
594 flags & IEEE80211_CHAN_RADAR ?
595 " (IEEE 802.11h required)" :
"",
597 flags & IEEE80211_CHAN_NO_IBSS) ||
599 flags & IEEE80211_CHAN_RADAR)) ?
"" :
603 "passive only" :
"active/passive");
611 il_dbgfs_status_read(
struct file *file,
char __user *user_buf,
size_t count,
618 const size_t bufsz =
sizeof(
buf);
621 scnprintf(buf + pos, bufsz - pos,
"S_HCMD_ACTIVE:\t %d\n",
624 scnprintf(buf + pos, bufsz - pos,
"S_INT_ENABLED:\t %d\n",
627 scnprintf(buf + pos, bufsz - pos,
"S_RFKILL:\t %d\n",
630 scnprintf(buf + pos, bufsz - pos,
"S_CT_KILL:\t\t %d\n",
633 scnprintf(buf + pos, bufsz - pos,
"S_INIT:\t\t %d\n",
636 scnprintf(buf + pos, bufsz - pos,
"S_ALIVE:\t\t %d\n",
639 scnprintf(buf + pos, bufsz - pos,
"S_READY:\t\t %d\n",
642 scnprintf(buf + pos, bufsz - pos,
"S_TEMPERATURE:\t %d\n",
645 scnprintf(buf + pos, bufsz - pos,
"S_GEO_CONFIGURED:\t %d\n",
648 scnprintf(buf + pos, bufsz - pos,
"S_EXIT_PENDING:\t %d\n",
651 scnprintf(buf + pos, bufsz - pos,
"S_STATS:\t %d\n",
654 scnprintf(buf + pos, bufsz - pos,
"S_SCANNING:\t %d\n",
657 scnprintf(buf + pos, bufsz - pos,
"S_SCAN_ABORTING:\t %d\n",
660 scnprintf(buf + pos, bufsz - pos,
"S_SCAN_HW:\t\t %d\n",
663 scnprintf(buf + pos, bufsz - pos,
"S_POWER_PMI:\t %d\n",
666 scnprintf(buf + pos, bufsz - pos,
"S_FW_ERROR:\t %d\n",
672 il_dbgfs_interrupt_read(
struct file *file,
char __user *user_buf,
size_t count,
685 IL_ERR(
"Can not allocate Buffer\n");
690 scnprintf(buf + pos, bufsz - pos,
"Interrupt Statistics Report:\n");
693 scnprintf(buf + pos, bufsz - pos,
"HW Error:\t\t\t %u\n",
696 scnprintf(buf + pos, bufsz - pos,
"SW Error:\t\t\t %u\n",
701 "\tLast Restarting Code: 0x%X\n",
704 #ifdef CONFIG_IWLEGACY_DEBUG
706 scnprintf(buf + pos, bufsz - pos,
"Frame transmitted:\t\t %u\n",
709 scnprintf(buf + pos, bufsz - pos,
"Alive interrupt:\t\t %u\n",
714 "HW RF KILL switch toggled:\t %u\n",
718 scnprintf(buf + pos, bufsz - pos,
"CT KILL:\t\t\t %u\n",
722 scnprintf(buf + pos, bufsz - pos,
"Wakeup Interrupt:\t\t %u\n",
726 scnprintf(buf + pos, bufsz - pos,
"Rx command responses:\t\t %u\n",
732 "\tRx handler[%36s]:\t\t %u\n",
738 scnprintf(buf + pos, bufsz - pos,
"Tx/FH interrupt:\t\t %u\n",
742 scnprintf(buf + pos, bufsz - pos,
"Unexpected INTA:\t\t %u\n",
751 il_dbgfs_interrupt_write(
struct file *file,
const char __user *user_buf,
752 size_t count, loff_t *ppos)
759 memset(buf, 0,
sizeof(buf));
760 buf_size =
min(count,
sizeof(buf) - 1);
763 if (
sscanf(buf,
"%x", &reset_flag) != 1)
772 il_dbgfs_qos_read(
struct file *file,
char __user *user_buf,
size_t count,
778 const size_t bufsz =
sizeof(
buf);
780 for (i = 0; i <
AC_NUM; i++) {
783 "\tcw_min\tcw_max\taifsn\ttxop\n");
786 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
787 il->
qos_data.def_qos_parm.ac[i].cw_min,
788 il->
qos_data.def_qos_parm.ac[i].cw_max,
789 il->
qos_data.def_qos_parm.ac[i].aifsn,
790 il->
qos_data.def_qos_parm.ac[i].edca_txop);
797 il_dbgfs_disable_ht40_write(
struct file *file,
const char __user *user_buf,
798 size_t count, loff_t *ppos)
805 memset(buf, 0,
sizeof(buf));
806 buf_size =
min(count,
sizeof(buf) - 1);
809 if (
sscanf(buf,
"%d", &ht40) != 1)
811 if (!il_is_any_associated(il))
812 il->disable_ht40 = ht40 ?
true :
false;
814 IL_ERR(
"Sta associated with AP - "
815 "Change to 40MHz channel support is not allowed\n");
823 il_dbgfs_disable_ht40_read(
struct file *file,
char __user *user_buf,
824 size_t count, loff_t *ppos)
829 const size_t bufsz =
sizeof(
buf);
832 scnprintf(buf + pos, bufsz - pos,
"11n 40MHz Mode: %s\n",
833 il->disable_ht40 ?
"Disabled" :
"Enabled");
847 il_dbgfs_tx_queue_read(
struct file *file,
char __user *user_buf,
size_t count,
859 sizeof(
char) * 64 * il->
cfg->num_of_queues;
862 IL_ERR(
"txq not ready\n");
869 for (cnt = 0; cnt < il->
hw_params.max_txq_num; cnt++) {
874 "hwq %.2d: read=%u write=%u stop=%d"
875 " swq_id=%#.2x (ac %d/hwq %d)\n", cnt,
879 (txq->
swq_id >> 2) & 0x1f);
894 il_dbgfs_rx_queue_read(
struct file *file,
char __user *user_buf,
size_t count,
902 const size_t bufsz =
sizeof(
buf);
904 pos +=
scnprintf(buf + pos, bufsz - pos,
"read: %u\n", rxq->
read);
905 pos +=
scnprintf(buf + pos, bufsz - pos,
"write: %u\n", rxq->
write);
907 scnprintf(buf + pos, bufsz - pos,
"free_count: %u\n",
911 scnprintf(buf + pos, bufsz - pos,
"closed_rb_num: %u\n",
913 closed_rb_num) & 0x0FFF);
917 "closed_rb_num: Not Allocated\n");
923 il_dbgfs_ucode_rx_stats_read(
struct file *file,
char __user *user_buf,
924 size_t count, loff_t *ppos)
928 return il->debugfs_ops->rx_stats_read(file, user_buf, count, ppos);
932 il_dbgfs_ucode_tx_stats_read(
struct file *file,
char __user *user_buf,
933 size_t count, loff_t *ppos)
937 return il->debugfs_ops->tx_stats_read(file, user_buf, count, ppos);
941 il_dbgfs_ucode_general_stats_read(
struct file *file,
char __user *user_buf,
942 size_t count, loff_t *ppos)
946 return il->debugfs_ops->general_stats_read(file, user_buf, count, ppos);
950 il_dbgfs_sensitivity_read(
struct file *file,
char __user *user_buf,
951 size_t count, loff_t *ppos)
965 IL_ERR(
"Can not allocate Buffer\n");
970 scnprintf(buf + pos, bufsz - pos,
"auto_corr_ofdm:\t\t\t %u\n",
973 scnprintf(buf + pos, bufsz - pos,
"auto_corr_ofdm_mrc:\t\t %u\n",
976 scnprintf(buf + pos, bufsz - pos,
"auto_corr_ofdm_x1:\t\t %u\n",
979 scnprintf(buf + pos, bufsz - pos,
"auto_corr_ofdm_mrc_x1:\t\t %u\n",
982 scnprintf(buf + pos, bufsz - pos,
"auto_corr_cck:\t\t\t %u\n",
985 scnprintf(buf + pos, bufsz - pos,
"auto_corr_cck_mrc:\t\t %u\n",
989 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
992 scnprintf(buf + pos, bufsz - pos,
"last_fa_cnt_ofdm:\t\t %u\n",
995 scnprintf(buf + pos, bufsz - pos,
"last_bad_plcp_cnt_cck:\t\t %u\n",
998 scnprintf(buf + pos, bufsz - pos,
"last_fa_cnt_cck:\t\t %u\n",
1001 scnprintf(buf + pos, bufsz - pos,
"nrg_curr_state:\t\t\t %u\n",
1004 scnprintf(buf + pos, bufsz - pos,
"nrg_prev_state:\t\t\t %u\n",
1006 pos +=
scnprintf(buf + pos, bufsz - pos,
"nrg_value:\t\t\t");
1007 for (cnt = 0; cnt < 10; cnt++) {
1009 scnprintf(buf + pos, bufsz - pos,
" %u",
1012 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
1013 pos +=
scnprintf(buf + pos, bufsz - pos,
"nrg_silence_rssi:\t\t");
1016 scnprintf(buf + pos, bufsz - pos,
" %u",
1019 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
1021 scnprintf(buf + pos, bufsz - pos,
"nrg_silence_ref:\t\t %u\n",
1024 scnprintf(buf + pos, bufsz - pos,
"nrg_energy_idx:\t\t\t %u\n",
1027 scnprintf(buf + pos, bufsz - pos,
"nrg_silence_idx:\t\t %u\n",
1030 scnprintf(buf + pos, bufsz - pos,
"nrg_th_cck:\t\t\t %u\n",
1034 "nrg_auto_corr_silence_diff:\t %u\n",
1037 scnprintf(buf + pos, bufsz - pos,
"num_in_cck_no_fa:\t\t %u\n",
1040 scnprintf(buf + pos, bufsz - pos,
"nrg_th_ofdm:\t\t\t %u\n",
1049 il_dbgfs_chain_noise_read(
struct file *file,
char __user *user_buf,
1050 size_t count, loff_t *ppos)
1064 IL_ERR(
"Can not allocate Buffer\n");
1069 scnprintf(buf + pos, bufsz - pos,
"active_chains:\t\t\t %u\n",
1072 scnprintf(buf + pos, bufsz - pos,
"chain_noise_a:\t\t\t %u\n",
1075 scnprintf(buf + pos, bufsz - pos,
"chain_noise_b:\t\t\t %u\n",
1078 scnprintf(buf + pos, bufsz - pos,
"chain_noise_c:\t\t\t %u\n",
1081 scnprintf(buf + pos, bufsz - pos,
"chain_signal_a:\t\t\t %u\n",
1084 scnprintf(buf + pos, bufsz - pos,
"chain_signal_b:\t\t\t %u\n",
1087 scnprintf(buf + pos, bufsz - pos,
"chain_signal_c:\t\t\t %u\n",
1090 scnprintf(buf + pos, bufsz - pos,
"beacon_count:\t\t\t %u\n",
1093 pos +=
scnprintf(buf + pos, bufsz - pos,
"disconn_array:\t\t\t");
1096 scnprintf(buf + pos, bufsz - pos,
" %u",
1099 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
1100 pos +=
scnprintf(buf + pos, bufsz - pos,
"delta_gain_code:\t\t");
1103 scnprintf(buf + pos, bufsz - pos,
" %u",
1106 pos +=
scnprintf(buf + pos, bufsz - pos,
"\n");
1108 scnprintf(buf + pos, bufsz - pos,
"radio_write:\t\t\t %u\n",
1111 scnprintf(buf + pos, bufsz - pos,
"state:\t\t\t\t %u\n",
1120 il_dbgfs_power_save_status_read(
struct file *file,
char __user *user_buf,
1121 size_t count, loff_t *ppos)
1126 const size_t bufsz =
sizeof(
buf);
1132 pos +=
scnprintf(buf + pos, bufsz - pos,
"Power Save Status: ");
1134 scnprintf(buf + pos, bufsz - pos,
"%s\n",
1144 il_dbgfs_clear_ucode_stats_write(
struct file *file,
1145 const char __user *user_buf,
size_t count,
1153 memset(buf, 0,
sizeof(buf));
1154 buf_size =
min(count,
sizeof(buf) - 1);
1157 if (
sscanf(buf,
"%d", &clear) != 1)
1169 il_dbgfs_rxon_flags_read(
struct file *file,
char __user *user_buf,
1170 size_t count, loff_t *ppos)
1182 il_dbgfs_rxon_filter_flags_read(
struct file *file,
char __user *user_buf,
1183 size_t count, loff_t *ppos)
1196 il_dbgfs_fh_reg_read(
struct file *file,
char __user *user_buf,
size_t count,
1204 if (il->
ops->dump_fh) {
1205 ret = pos = il->
ops->dump_fh(il, &buf,
true);
1218 il_dbgfs_missed_beacon_read(
struct file *file,
char __user *user_buf,
1219 size_t count, loff_t *ppos)
1225 const size_t bufsz =
sizeof(
buf);
1228 scnprintf(buf + pos, bufsz - pos,
"%d\n",
1235 il_dbgfs_missed_beacon_write(
struct file *file,
const char __user *user_buf,
1236 size_t count, loff_t *ppos)
1243 memset(buf, 0,
sizeof(buf));
1244 buf_size =
min(count,
sizeof(buf) - 1);
1247 if (
sscanf(buf,
"%d", &missed) != 1)
1260 il_dbgfs_force_reset_read(
struct file *file,
char __user *user_buf,
1261 size_t count, loff_t *ppos)
1267 const size_t bufsz =
sizeof(
buf);
1273 scnprintf(buf + pos, bufsz - pos,
"\tnumber of reset request: %d\n",
1277 "\tnumber of reset request success: %d\n",
1281 "\tnumber of reset request reject: %d\n",
1284 scnprintf(buf + pos, bufsz - pos,
"\treset duration: %lu\n",
1291 il_dbgfs_force_reset_write(
struct file *file,
const char __user *user_buf,
1292 size_t count, loff_t *ppos)
1300 return ret ? ret :
count;
1304 il_dbgfs_wd_timeout_write(
struct file *file,
const char __user *user_buf,
1305 size_t count, loff_t *ppos)
1313 memset(buf, 0,
sizeof(buf));
1314 buf_size =
min(count,
sizeof(buf) - 1);
1317 if (
sscanf(buf,
"%d", &timeout) != 1)
1322 il->
cfg->wd_timeout = timeout;
1353 struct dentry *phyd = il->
hw->wiphy->debugfsdir;
1354 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
1360 il->debugfs_dir = dir_drv;
1394 if (il->
cfg->sensitivity_calib_by_driver)
1396 if (il->
cfg->chain_noise_calib_by_driver)
1401 if (il->
cfg->sensitivity_calib_by_driver)
1404 if (il->
cfg->chain_noise_calib_by_driver)
1411 IL_ERR(
"Can't create the debugfs directory\n");
1424 if (!il->debugfs_dir)
1428 il->debugfs_dir =
NULL;