1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * Copyright(c) 2018 Intel Corporation
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as
15 * published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
27 * The full GNU General Public License is included in this distribution
28 * in the file called COPYING.
30 * Contact Information:
31 * Intel Linux Wireless <linuxwifi@intel.com>
32 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
36 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
37 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
38 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
39 * Copyright(c) 2018 Intel Corporation
40 * All rights reserved.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
46 * * Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * * Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in
50 * the documentation and/or other materials provided with the
52 * * Neither the name Intel Corporation nor the names of its
53 * contributors may be used to endorse or promote products derived
54 * from this software without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
57 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
58 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
59 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
60 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
62 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
66 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 *****************************************************************************/
69 #include <linux/vmalloc.h>
70 #include <linux/ieee80211.h>
71 #include <linux/netdevice.h>
77 #include "fw/error-dump.h"
79 static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
80 char __user *user_buf,
81 size_t count, loff_t *ppos)
83 struct iwl_mvm *mvm = file->private_data;
87 if (!iwl_mvm_is_ctdp_supported(mvm))
90 if (!iwl_mvm_firmware_running(mvm) ||
91 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
94 mutex_lock(&mvm->mutex);
95 budget = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_REPORT, 0);
96 mutex_unlock(&mvm->mutex);
101 pos = scnprintf(buf, sizeof(buf), "%d\n", budget);
103 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
106 static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
107 size_t count, loff_t *ppos)
111 if (!iwl_mvm_is_ctdp_supported(mvm))
114 if (!iwl_mvm_firmware_running(mvm) ||
115 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
118 mutex_lock(&mvm->mutex);
119 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_STOP, 0);
120 mutex_unlock(&mvm->mutex);
125 static ssize_t iwl_dbgfs_force_ctkill_write(struct iwl_mvm *mvm, char *buf,
126 size_t count, loff_t *ppos)
128 if (!iwl_mvm_firmware_running(mvm) ||
129 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
132 iwl_mvm_enter_ctkill(mvm);
137 static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
138 size_t count, loff_t *ppos)
143 if (!iwl_mvm_firmware_running(mvm) ||
144 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
147 if (kstrtou32(buf, 0, &flush_arg))
150 if (iwl_mvm_has_new_tx_api(mvm)) {
151 IWL_DEBUG_TX_QUEUES(mvm,
152 "FLUSHING all tids queues on sta_id = %d\n",
154 mutex_lock(&mvm->mutex);
155 ret = iwl_mvm_flush_sta_tids(mvm, flush_arg, 0xFF, 0) ? : count;
156 mutex_unlock(&mvm->mutex);
160 IWL_DEBUG_TX_QUEUES(mvm, "FLUSHING queues mask to flush = 0x%x\n",
163 mutex_lock(&mvm->mutex);
164 ret = iwl_mvm_flush_tx_path(mvm, flush_arg, 0) ? : count;
165 mutex_unlock(&mvm->mutex);
170 static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
171 size_t count, loff_t *ppos)
173 struct iwl_mvm_sta *mvmsta;
174 int sta_id, drain, ret;
176 if (!iwl_mvm_firmware_running(mvm) ||
177 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
180 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
182 if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
184 if (drain < 0 || drain > 1)
187 mutex_lock(&mvm->mutex);
189 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
194 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
196 mutex_unlock(&mvm->mutex);
201 static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
202 size_t count, loff_t *ppos)
204 struct iwl_mvm *mvm = file->private_data;
205 const struct fw_img *img;
206 unsigned int ofs, len;
210 if (!iwl_mvm_firmware_running(mvm))
213 /* default is to dump the entire data segment */
214 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
215 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
216 len = img->sec[IWL_UCODE_SECTION_DATA].len;
218 if (mvm->dbgfs_sram_len) {
219 ofs = mvm->dbgfs_sram_offset;
220 len = mvm->dbgfs_sram_len;
223 ptr = kzalloc(len, GFP_KERNEL);
227 iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
229 ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
236 static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
237 size_t count, loff_t *ppos)
239 const struct fw_img *img;
241 u32 img_offset, img_len;
243 if (!iwl_mvm_firmware_running(mvm))
246 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
247 img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
248 img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
250 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
251 if ((offset & 0x3) || (len & 0x3))
254 if (offset + len > img_offset + img_len)
257 mvm->dbgfs_sram_offset = offset;
258 mvm->dbgfs_sram_len = len;
260 mvm->dbgfs_sram_offset = 0;
261 mvm->dbgfs_sram_len = 0;
267 static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
268 char __user *user_buf,
269 size_t count, loff_t *ppos)
271 struct iwl_mvm *mvm = file->private_data;
275 if (!mvm->temperature_test)
276 pos = scnprintf(buf , sizeof(buf), "disabled\n");
278 pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
280 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
284 * Set NIC Temperature
285 * Cause the driver to ignore the actual NIC temperature reported by the FW
286 * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
287 * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
288 * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
290 static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
291 char *buf, size_t count,
296 if (!iwl_mvm_firmware_running(mvm) && !mvm->temperature_test)
299 if (kstrtoint(buf, 10, &temperature))
301 /* not a legal temperature */
302 if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
303 temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
304 temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
307 mutex_lock(&mvm->mutex);
308 if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
309 if (!mvm->temperature_test)
312 mvm->temperature_test = false;
313 /* Since we can't read the temp while awake, just set
314 * it to zero until we get the next RX stats from the
317 mvm->temperature = 0;
319 mvm->temperature_test = true;
320 mvm->temperature = temperature;
322 IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
323 mvm->temperature_test ? "En" : "Dis" ,
325 /* handle the temperature change */
326 iwl_mvm_tt_handler(mvm);
329 mutex_unlock(&mvm->mutex);
334 static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
335 char __user *user_buf,
336 size_t count, loff_t *ppos)
338 struct iwl_mvm *mvm = file->private_data;
343 if (!iwl_mvm_firmware_running(mvm))
346 mutex_lock(&mvm->mutex);
347 ret = iwl_mvm_get_temp(mvm, &temp);
348 mutex_unlock(&mvm->mutex);
353 pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
355 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
359 static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file,
360 char __user *user_buf,
361 size_t count, loff_t *ppos)
363 struct iwl_mvm *mvm = file->private_data;
366 int bufsz = sizeof(buf);
370 if (!iwl_mvm_firmware_running(mvm))
373 mutex_lock(&mvm->mutex);
374 tbl_idx = iwl_mvm_get_sar_geo_profile(mvm);
376 mutex_unlock(&mvm->mutex);
381 pos = scnprintf(buf, bufsz,
382 "SAR geographic profile disabled\n");
384 value = &mvm->geo_profiles[tbl_idx - 1].values[0];
386 pos += scnprintf(buf + pos, bufsz - pos,
387 "Use geographic profile %d\n", tbl_idx);
388 pos += scnprintf(buf + pos, bufsz - pos,
389 "2.4GHz:\n\tChain A offset: %hhd dBm\n\tChain B offset: %hhd dBm\n\tmax tx power: %hhd dBm\n",
390 value[1], value[2], value[0]);
391 pos += scnprintf(buf + pos, bufsz - pos,
392 "5.2GHz:\n\tChain A offset: %hhd dBm\n\tChain B offset: %hhd dBm\n\tmax tx power: %hhd dBm\n",
393 value[4], value[5], value[3]);
395 mutex_unlock(&mvm->mutex);
397 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
401 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
402 size_t count, loff_t *ppos)
404 struct iwl_mvm *mvm = file->private_data;
405 struct ieee80211_sta *sta;
407 int i, pos = 0, bufsz = sizeof(buf);
409 mutex_lock(&mvm->mutex);
411 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) {
412 pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
413 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
414 lockdep_is_held(&mvm->mutex));
416 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
417 else if (IS_ERR(sta))
418 pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
421 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
425 mutex_unlock(&mvm->mutex);
427 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
430 static ssize_t iwl_dbgfs_rs_data_read(struct file *file, char __user *user_buf,
431 size_t count, loff_t *ppos)
433 struct ieee80211_sta *sta = file->private_data;
434 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
435 struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->lq_sta.rs_fw;
436 struct iwl_mvm *mvm = lq_sta->pers.drv;
437 static const size_t bufsz = 2048;
442 buff = kmalloc(bufsz, GFP_KERNEL);
446 mutex_lock(&mvm->mutex);
448 desc += scnprintf(buff + desc, bufsz - desc, "sta_id %d\n",
449 lq_sta->pers.sta_id);
450 desc += scnprintf(buff + desc, bufsz - desc,
452 lq_sta->pers.dbg_fixed_rate);
453 desc += scnprintf(buff + desc, bufsz - desc,
454 "A-MPDU size limit %d\n",
455 lq_sta->pers.dbg_agg_frame_count_lim);
456 desc += scnprintf(buff + desc, bufsz - desc,
457 "valid_tx_ant %s%s%s\n",
458 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_A) ? "ANT_A," : "",
459 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_B) ? "ANT_B," : "",
460 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_C) ? "ANT_C" : "");
461 desc += scnprintf(buff + desc, bufsz - desc,
462 "last tx rate=0x%X ",
463 lq_sta->last_rate_n_flags);
465 desc += rs_pretty_print_rate(buff + desc, bufsz - desc,
466 lq_sta->last_rate_n_flags);
467 mutex_unlock(&mvm->mutex);
469 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
474 static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
475 char __user *user_buf,
476 size_t count, loff_t *ppos)
478 struct iwl_mvm *mvm = file->private_data;
480 int bufsz = sizeof(buf);
483 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
484 mvm->disable_power_off);
485 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
486 mvm->disable_power_off_d3);
488 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
491 static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
492 size_t count, loff_t *ppos)
496 if (!iwl_mvm_firmware_running(mvm))
499 if (!strncmp("disable_power_off_d0=", buf, 21)) {
500 if (sscanf(buf + 21, "%d", &val) != 1)
502 mvm->disable_power_off = val;
503 } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
504 if (sscanf(buf + 21, "%d", &val) != 1)
506 mvm->disable_power_off_d3 = val;
511 mutex_lock(&mvm->mutex);
512 ret = iwl_mvm_power_update_device(mvm);
513 mutex_unlock(&mvm->mutex);
519 int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
522 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
524 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
525 BT_MBOX_PRINT(0, LE_PROF1, false);
526 BT_MBOX_PRINT(0, LE_PROF2, false);
527 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
528 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
529 BT_MBOX_PRINT(0, INBAND_S, false);
530 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
531 BT_MBOX_PRINT(0, LE_SCAN, false);
532 BT_MBOX_PRINT(0, LE_ADV, false);
533 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
534 BT_MBOX_PRINT(0, OPEN_CON_1, true);
536 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
538 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
539 BT_MBOX_PRINT(1, IP_SR, false);
540 BT_MBOX_PRINT(1, LE_MSTR, false);
541 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
542 BT_MBOX_PRINT(1, MSG_TYPE, false);
543 BT_MBOX_PRINT(1, SSN, true);
545 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
547 BT_MBOX_PRINT(2, SNIFF_ACT, false);
548 BT_MBOX_PRINT(2, PAG, false);
549 BT_MBOX_PRINT(2, INQUIRY, false);
550 BT_MBOX_PRINT(2, CONN, false);
551 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
552 BT_MBOX_PRINT(2, DISC, false);
553 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
554 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
555 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
556 BT_MBOX_PRINT(2, SCO_DURATION, true);
558 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
560 BT_MBOX_PRINT(3, SCO_STATE, false);
561 BT_MBOX_PRINT(3, SNIFF_STATE, false);
562 BT_MBOX_PRINT(3, A2DP_STATE, false);
563 BT_MBOX_PRINT(3, A2DP_SRC, false);
564 BT_MBOX_PRINT(3, ACL_STATE, false);
565 BT_MBOX_PRINT(3, MSTR_STATE, false);
566 BT_MBOX_PRINT(3, OBX_STATE, false);
567 BT_MBOX_PRINT(3, OPEN_CON_2, false);
568 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
569 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
570 BT_MBOX_PRINT(3, INBAND_P, false);
571 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
572 BT_MBOX_PRINT(3, SSN_2, false);
573 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
578 static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
579 size_t count, loff_t *ppos)
581 struct iwl_mvm *mvm = file->private_data;
582 struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
584 int ret, pos = 0, bufsz = sizeof(char) * 1024;
586 buf = kmalloc(bufsz, GFP_KERNEL);
590 mutex_lock(&mvm->mutex);
592 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
594 pos += scnprintf(buf + pos, bufsz - pos, "bt_ci_compliance = %d\n",
595 notif->bt_ci_compliance);
596 pos += scnprintf(buf + pos, bufsz - pos, "primary_ch_lut = %d\n",
597 le32_to_cpu(notif->primary_ch_lut));
598 pos += scnprintf(buf + pos, bufsz - pos, "secondary_ch_lut = %d\n",
599 le32_to_cpu(notif->secondary_ch_lut));
600 pos += scnprintf(buf + pos,
601 bufsz - pos, "bt_activity_grading = %d\n",
602 le32_to_cpu(notif->bt_activity_grading));
603 pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n",
604 notif->rrc_status & 0xF);
605 pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n",
606 notif->ttc_status & 0xF);
608 pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n",
609 IWL_MVM_BT_COEX_SYNC2SCO);
610 pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n",
611 IWL_MVM_BT_COEX_MPLUT);
613 mutex_unlock(&mvm->mutex);
615 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
622 static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
623 size_t count, loff_t *ppos)
625 struct iwl_mvm *mvm = file->private_data;
626 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
628 int bufsz = sizeof(buf);
631 mutex_lock(&mvm->mutex);
633 pos += scnprintf(buf + pos, bufsz - pos, "Channel inhibition CMD\n");
634 pos += scnprintf(buf + pos, bufsz - pos,
635 "\tPrimary Channel Bitmap 0x%016llx\n",
636 le64_to_cpu(cmd->bt_primary_ci));
637 pos += scnprintf(buf + pos, bufsz - pos,
638 "\tSecondary Channel Bitmap 0x%016llx\n",
639 le64_to_cpu(cmd->bt_secondary_ci));
641 mutex_unlock(&mvm->mutex);
643 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
647 iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
648 size_t count, loff_t *ppos)
652 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
657 mvm->bt_tx_prio = bt_tx_prio;
663 iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
664 size_t count, loff_t *ppos)
666 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
667 [BT_FORCE_ANT_DIS] = "dis",
668 [BT_FORCE_ANT_AUTO] = "auto",
669 [BT_FORCE_ANT_BT] = "bt",
670 [BT_FORCE_ANT_WIFI] = "wifi",
672 int ret, bt_force_ant_mode;
674 for (bt_force_ant_mode = 0;
675 bt_force_ant_mode < ARRAY_SIZE(modes_str);
676 bt_force_ant_mode++) {
677 if (!strcmp(buf, modes_str[bt_force_ant_mode]))
681 if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
685 mutex_lock(&mvm->mutex);
686 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
689 mvm->bt_force_ant_mode = bt_force_ant_mode;
690 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
691 modes_str[mvm->bt_force_ant_mode]);
693 if (iwl_mvm_firmware_running(mvm))
694 ret = iwl_mvm_send_bt_init_conf(mvm);
699 mutex_unlock(&mvm->mutex);
703 static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
704 size_t count, loff_t *ppos)
706 struct iwl_mvm *mvm = file->private_data;
707 char *buff, *pos, *endpos;
708 static const size_t bufsz = 1024;
711 buff = kmalloc(bufsz, GFP_KERNEL);
716 endpos = pos + bufsz;
718 pos += scnprintf(pos, endpos - pos, "FW prefix: %s\n",
719 mvm->trans->cfg->fw_name_pre);
720 pos += scnprintf(pos, endpos - pos, "FW: %s\n",
721 mvm->fwrt.fw->human_readable);
722 pos += scnprintf(pos, endpos - pos, "Device: %s\n",
723 mvm->fwrt.trans->cfg->name);
724 pos += scnprintf(pos, endpos - pos, "Bus: %s\n",
725 mvm->fwrt.dev->bus->name);
727 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
733 #define PRINT_STATS_LE32(_struct, _memb) \
734 pos += scnprintf(buf + pos, bufsz - pos, \
736 le32_to_cpu(_struct->_memb))
738 static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
739 char __user *user_buf, size_t count,
742 struct iwl_mvm *mvm = file->private_data;
743 static const char *fmt_table = "\t%-30s %10u\n";
744 static const char *fmt_header = "%-32s\n";
750 if (iwl_mvm_has_new_rx_stats_api(mvm))
751 bufsz = ((sizeof(struct mvm_statistics_rx) /
752 sizeof(__le32)) * 43) + (4 * 33) + 1;
754 /* 43 = size of each data line; 33 = size of each header */
755 bufsz = ((sizeof(struct mvm_statistics_rx_v3) /
756 sizeof(__le32)) * 43) + (4 * 33) + 1;
758 buf = kzalloc(bufsz, GFP_KERNEL);
762 mutex_lock(&mvm->mutex);
764 if (iwl_mvm_firmware_running(mvm))
765 iwl_mvm_request_statistics(mvm, false);
767 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
768 "Statistics_Rx - OFDM");
769 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
770 struct mvm_statistics_rx_phy_v2 *ofdm = &mvm->rx_stats_v3.ofdm;
772 PRINT_STATS_LE32(ofdm, ina_cnt);
773 PRINT_STATS_LE32(ofdm, fina_cnt);
774 PRINT_STATS_LE32(ofdm, plcp_err);
775 PRINT_STATS_LE32(ofdm, crc32_err);
776 PRINT_STATS_LE32(ofdm, overrun_err);
777 PRINT_STATS_LE32(ofdm, early_overrun_err);
778 PRINT_STATS_LE32(ofdm, crc32_good);
779 PRINT_STATS_LE32(ofdm, false_alarm_cnt);
780 PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
781 PRINT_STATS_LE32(ofdm, sfd_timeout);
782 PRINT_STATS_LE32(ofdm, fina_timeout);
783 PRINT_STATS_LE32(ofdm, unresponded_rts);
784 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
785 PRINT_STATS_LE32(ofdm, sent_ack_cnt);
786 PRINT_STATS_LE32(ofdm, sent_cts_cnt);
787 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
788 PRINT_STATS_LE32(ofdm, dsp_self_kill);
789 PRINT_STATS_LE32(ofdm, mh_format_err);
790 PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
791 PRINT_STATS_LE32(ofdm, reserved);
793 struct mvm_statistics_rx_phy *ofdm = &mvm->rx_stats.ofdm;
795 PRINT_STATS_LE32(ofdm, unresponded_rts);
796 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
797 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
798 PRINT_STATS_LE32(ofdm, dsp_self_kill);
799 PRINT_STATS_LE32(ofdm, reserved);
802 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
803 "Statistics_Rx - CCK");
804 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
805 struct mvm_statistics_rx_phy_v2 *cck = &mvm->rx_stats_v3.cck;
807 PRINT_STATS_LE32(cck, ina_cnt);
808 PRINT_STATS_LE32(cck, fina_cnt);
809 PRINT_STATS_LE32(cck, plcp_err);
810 PRINT_STATS_LE32(cck, crc32_err);
811 PRINT_STATS_LE32(cck, overrun_err);
812 PRINT_STATS_LE32(cck, early_overrun_err);
813 PRINT_STATS_LE32(cck, crc32_good);
814 PRINT_STATS_LE32(cck, false_alarm_cnt);
815 PRINT_STATS_LE32(cck, fina_sync_err_cnt);
816 PRINT_STATS_LE32(cck, sfd_timeout);
817 PRINT_STATS_LE32(cck, fina_timeout);
818 PRINT_STATS_LE32(cck, unresponded_rts);
819 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
820 PRINT_STATS_LE32(cck, sent_ack_cnt);
821 PRINT_STATS_LE32(cck, sent_cts_cnt);
822 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
823 PRINT_STATS_LE32(cck, dsp_self_kill);
824 PRINT_STATS_LE32(cck, mh_format_err);
825 PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
826 PRINT_STATS_LE32(cck, reserved);
828 struct mvm_statistics_rx_phy *cck = &mvm->rx_stats.cck;
830 PRINT_STATS_LE32(cck, unresponded_rts);
831 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
832 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
833 PRINT_STATS_LE32(cck, dsp_self_kill);
834 PRINT_STATS_LE32(cck, reserved);
837 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
838 "Statistics_Rx - GENERAL");
839 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
840 struct mvm_statistics_rx_non_phy_v3 *general =
841 &mvm->rx_stats_v3.general;
843 PRINT_STATS_LE32(general, bogus_cts);
844 PRINT_STATS_LE32(general, bogus_ack);
845 PRINT_STATS_LE32(general, non_bssid_frames);
846 PRINT_STATS_LE32(general, filtered_frames);
847 PRINT_STATS_LE32(general, non_channel_beacons);
848 PRINT_STATS_LE32(general, channel_beacons);
849 PRINT_STATS_LE32(general, num_missed_bcon);
850 PRINT_STATS_LE32(general, adc_rx_saturation_time);
851 PRINT_STATS_LE32(general, ina_detection_search_time);
852 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
853 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
854 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
855 PRINT_STATS_LE32(general, interference_data_flag);
856 PRINT_STATS_LE32(general, channel_load);
857 PRINT_STATS_LE32(general, dsp_false_alarms);
858 PRINT_STATS_LE32(general, beacon_rssi_a);
859 PRINT_STATS_LE32(general, beacon_rssi_b);
860 PRINT_STATS_LE32(general, beacon_rssi_c);
861 PRINT_STATS_LE32(general, beacon_energy_a);
862 PRINT_STATS_LE32(general, beacon_energy_b);
863 PRINT_STATS_LE32(general, beacon_energy_c);
864 PRINT_STATS_LE32(general, num_bt_kills);
865 PRINT_STATS_LE32(general, mac_id);
866 PRINT_STATS_LE32(general, directed_data_mpdu);
868 struct mvm_statistics_rx_non_phy *general =
869 &mvm->rx_stats.general;
871 PRINT_STATS_LE32(general, bogus_cts);
872 PRINT_STATS_LE32(general, bogus_ack);
873 PRINT_STATS_LE32(general, non_channel_beacons);
874 PRINT_STATS_LE32(general, channel_beacons);
875 PRINT_STATS_LE32(general, num_missed_bcon);
876 PRINT_STATS_LE32(general, adc_rx_saturation_time);
877 PRINT_STATS_LE32(general, ina_detection_search_time);
878 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
879 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
880 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
881 PRINT_STATS_LE32(general, interference_data_flag);
882 PRINT_STATS_LE32(general, channel_load);
883 PRINT_STATS_LE32(general, beacon_rssi_a);
884 PRINT_STATS_LE32(general, beacon_rssi_b);
885 PRINT_STATS_LE32(general, beacon_rssi_c);
886 PRINT_STATS_LE32(general, beacon_energy_a);
887 PRINT_STATS_LE32(general, beacon_energy_b);
888 PRINT_STATS_LE32(general, beacon_energy_c);
889 PRINT_STATS_LE32(general, num_bt_kills);
890 PRINT_STATS_LE32(general, mac_id);
893 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
894 "Statistics_Rx - HT");
895 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
896 struct mvm_statistics_rx_ht_phy_v1 *ht =
897 &mvm->rx_stats_v3.ofdm_ht;
899 PRINT_STATS_LE32(ht, plcp_err);
900 PRINT_STATS_LE32(ht, overrun_err);
901 PRINT_STATS_LE32(ht, early_overrun_err);
902 PRINT_STATS_LE32(ht, crc32_good);
903 PRINT_STATS_LE32(ht, crc32_err);
904 PRINT_STATS_LE32(ht, mh_format_err);
905 PRINT_STATS_LE32(ht, agg_crc32_good);
906 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
907 PRINT_STATS_LE32(ht, agg_cnt);
908 PRINT_STATS_LE32(ht, unsupport_mcs);
910 struct mvm_statistics_rx_ht_phy *ht =
911 &mvm->rx_stats.ofdm_ht;
913 PRINT_STATS_LE32(ht, mh_format_err);
914 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
915 PRINT_STATS_LE32(ht, agg_cnt);
916 PRINT_STATS_LE32(ht, unsupport_mcs);
919 mutex_unlock(&mvm->mutex);
921 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
926 #undef PRINT_STAT_LE32
928 static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
929 char __user *user_buf, size_t count,
931 struct iwl_mvm_frame_stats *stats)
933 char *buff, *pos, *endpos;
936 static const size_t bufsz = 1024;
938 buff = kmalloc(bufsz, GFP_KERNEL);
942 spin_lock_bh(&mvm->drv_stats_lock);
945 endpos = pos + bufsz;
947 pos += scnprintf(pos, endpos - pos,
948 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
949 stats->legacy_frames,
952 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
955 stats->bw_80_frames);
956 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
959 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
961 stats->mimo2_frames);
962 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
964 stats->success_frames);
965 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
967 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
969 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
970 stats->ampdu_count > 0 ?
971 (stats->agg_frames / stats->ampdu_count) : 0);
973 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
975 idx = stats->last_frame_idx - 1;
976 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
977 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
978 if (stats->last_rates[idx] == 0)
980 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
981 (int)(ARRAY_SIZE(stats->last_rates) - i));
982 pos += rs_pretty_print_rate(pos, endpos - pos,
983 stats->last_rates[idx]);
985 spin_unlock_bh(&mvm->drv_stats_lock);
987 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
993 static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
994 char __user *user_buf, size_t count,
997 struct iwl_mvm *mvm = file->private_data;
999 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
1000 &mvm->drv_rx_stats);
1003 static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
1004 size_t count, loff_t *ppos)
1006 int __maybe_unused ret;
1008 if (!iwl_mvm_firmware_running(mvm))
1011 mutex_lock(&mvm->mutex);
1013 /* allow one more restart that we're provoking here */
1014 if (mvm->fw_restart >= 0)
1017 /* take the return value to make compiler happy - it will fail anyway */
1018 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
1020 mutex_unlock(&mvm->mutex);
1025 static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
1026 size_t count, loff_t *ppos)
1030 if (!iwl_mvm_firmware_running(mvm))
1033 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
1037 iwl_force_nmi(mvm->trans);
1039 iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
1045 iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
1046 char __user *user_buf,
1047 size_t count, loff_t *ppos)
1049 struct iwl_mvm *mvm = file->private_data;
1052 const size_t bufsz = sizeof(buf);
1054 /* print which antennas were set for the scan command by the user */
1055 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
1056 if (mvm->scan_rx_ant & ANT_A)
1057 pos += scnprintf(buf + pos, bufsz - pos, "A");
1058 if (mvm->scan_rx_ant & ANT_B)
1059 pos += scnprintf(buf + pos, bufsz - pos, "B");
1060 if (mvm->scan_rx_ant & ANT_C)
1061 pos += scnprintf(buf + pos, bufsz - pos, "C");
1062 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
1064 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1068 iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
1069 size_t count, loff_t *ppos)
1073 if (!iwl_mvm_firmware_running(mvm))
1076 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
1078 if (scan_rx_ant > ANT_ABC)
1080 if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
1083 if (mvm->scan_rx_ant != scan_rx_ant) {
1084 mvm->scan_rx_ant = scan_rx_ant;
1085 if (fw_has_capa(&mvm->fw->ucode_capa,
1086 IWL_UCODE_TLV_CAPA_UMAC_SCAN))
1087 iwl_mvm_config_scan(mvm);
1093 static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
1094 char *buf, size_t count,
1097 struct iwl_rss_config_cmd cmd = {
1098 .flags = cpu_to_le32(IWL_RSS_ENABLE),
1099 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
1100 IWL_RSS_HASH_TYPE_IPV4_UDP |
1101 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
1102 IWL_RSS_HASH_TYPE_IPV6_TCP |
1103 IWL_RSS_HASH_TYPE_IPV6_UDP |
1104 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
1106 int ret, i, num_repeats, nbytes = count / 2;
1108 ret = hex2bin(cmd.indirection_table, buf, nbytes);
1113 * The input is the redirection table, partial or full.
1114 * Repeat the pattern if needed.
1115 * For example, input of 01020F will be repeated 42 times,
1116 * indirecting RSS hash results to queues 1, 2, 15 (skipping
1119 num_repeats = ARRAY_SIZE(cmd.indirection_table) / nbytes;
1120 for (i = 1; i < num_repeats; i++)
1121 memcpy(&cmd.indirection_table[i * nbytes],
1122 cmd.indirection_table, nbytes);
1123 /* handle cut in the middle pattern for the last places */
1124 memcpy(&cmd.indirection_table[i * nbytes], cmd.indirection_table,
1125 ARRAY_SIZE(cmd.indirection_table) % nbytes);
1127 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
1129 mutex_lock(&mvm->mutex);
1130 if (iwl_mvm_firmware_running(mvm))
1131 ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0,
1135 mutex_unlock(&mvm->mutex);
1137 return ret ?: count;
1140 static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
1141 char *buf, size_t count,
1144 struct iwl_rx_cmd_buffer rxb = {
1145 ._rx_page_order = 0,
1146 .truesize = 0, /* not used */
1149 struct iwl_rx_packet *pkt;
1150 struct iwl_rx_mpdu_desc *desc;
1151 int bin_len = count / 2;
1153 size_t mpdu_cmd_hdr_size =
1154 (mvm->trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560) ?
1155 sizeof(struct iwl_rx_mpdu_desc) :
1156 IWL_RX_DESC_SIZE_V1;
1158 if (!iwl_mvm_firmware_running(mvm))
1161 /* supporting only 9000 descriptor */
1162 if (!mvm->trans->cfg->mq_rx_supported)
1165 rxb._page = alloc_pages(GFP_ATOMIC, 0);
1168 pkt = rxb_addr(&rxb);
1170 ret = hex2bin(page_address(rxb._page), buf, bin_len);
1174 /* avoid invalid memory access */
1175 if (bin_len < sizeof(*pkt) + mpdu_cmd_hdr_size)
1178 /* check this is RX packet */
1179 if (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd) !=
1180 WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))
1183 /* check the length in metadata matches actual received length */
1184 desc = (void *)pkt->data;
1185 if (le16_to_cpu(desc->mpdu_len) !=
1186 (bin_len - mpdu_cmd_hdr_size - sizeof(*pkt)))
1190 iwl_mvm_rx_mpdu_mq(mvm, NULL, &rxb, 0);
1197 return ret ?: count;
1200 static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
1201 char __user *user_buf,
1202 size_t count, loff_t *ppos)
1204 struct iwl_mvm *mvm = file->private_data;
1207 const size_t bufsz = sizeof(buf);
1210 mutex_lock(&mvm->mutex);
1211 conf = mvm->fwrt.dump.conf;
1212 mutex_unlock(&mvm->mutex);
1214 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
1216 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1220 * Enable / Disable continuous recording.
1221 * Cause the FW to start continuous recording, by sending the relevant hcmd.
1222 * Enable: input of every integer larger than 0, ENABLE_CONT_RECORDING.
1223 * Disable: for 0 as input, DISABLE_CONT_RECORDING.
1225 static ssize_t iwl_dbgfs_cont_recording_write(struct iwl_mvm *mvm,
1226 char *buf, size_t count,
1229 struct iwl_trans *trans = mvm->trans;
1230 const struct iwl_fw_dbg_dest_tlv_v1 *dest = trans->dbg_dest_tlv;
1231 struct iwl_continuous_record_cmd cont_rec = {};
1234 if (!iwl_mvm_firmware_running(mvm))
1240 if (dest->monitor_mode != SMEM_MODE ||
1241 trans->cfg->device_family < IWL_DEVICE_FAMILY_8000)
1244 ret = kstrtoint(buf, 0, &rec_mode);
1248 cont_rec.record_mode.enable_recording = rec_mode ?
1249 cpu_to_le16(ENABLE_CONT_RECORDING) :
1250 cpu_to_le16(DISABLE_CONT_RECORDING);
1252 mutex_lock(&mvm->mutex);
1253 ret = iwl_mvm_send_cmd_pdu(mvm, LDBG_CONFIG_CMD, 0,
1254 sizeof(cont_rec), &cont_rec);
1255 mutex_unlock(&mvm->mutex);
1257 return ret ?: count;
1260 static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
1261 char *buf, size_t count,
1264 unsigned int conf_id;
1267 if (!iwl_mvm_firmware_running(mvm))
1270 ret = kstrtouint(buf, 0, &conf_id);
1274 if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
1277 mutex_lock(&mvm->mutex);
1278 ret = iwl_fw_start_dbg_conf(&mvm->fwrt, conf_id);
1279 mutex_unlock(&mvm->mutex);
1281 return ret ?: count;
1284 static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
1285 char *buf, size_t count,
1290 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1296 iwl_fw_dbg_collect(&mvm->fwrt, FW_DBG_TRIGGER_USER, buf,
1299 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
1304 static ssize_t iwl_dbgfs_max_amsdu_len_write(struct iwl_mvm *mvm,
1305 char *buf, size_t count,
1308 unsigned int max_amsdu_len;
1311 ret = kstrtouint(buf, 0, &max_amsdu_len);
1315 if (max_amsdu_len > IEEE80211_MAX_MPDU_LEN_VHT_11454)
1317 mvm->max_amsdu_len = max_amsdu_len;
1322 #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
1323 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1324 static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
1325 char __user *user_buf,
1326 size_t count, loff_t *ppos)
1328 struct iwl_mvm *mvm = file->private_data;
1329 struct iwl_bcast_filter_cmd cmd;
1330 const struct iwl_fw_bcast_filter *filter;
1336 buf = kzalloc(bufsz, GFP_KERNEL);
1340 mutex_lock(&mvm->mutex);
1341 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1343 mutex_unlock(&mvm->mutex);
1346 mutex_unlock(&mvm->mutex);
1348 for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
1349 filter = &cmd.filters[i];
1351 ADD_TEXT("Filter [%d]:\n", i);
1352 ADD_TEXT("\tDiscard=%d\n", filter->discard);
1353 ADD_TEXT("\tFrame Type: %s\n",
1354 filter->frame_type ? "IPv4" : "Generic");
1356 for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
1357 const struct iwl_fw_bcast_filter_attr *attr;
1359 attr = &filter->attrs[j];
1363 ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
1365 attr->offset_type ? "IP End" :
1367 be32_to_cpu(attr->mask),
1368 be32_to_cpu(attr->val),
1369 le16_to_cpu(attr->reserved1));
1373 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1378 static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
1379 size_t count, loff_t *ppos)
1382 struct iwl_fw_bcast_filter filter = {};
1383 struct iwl_bcast_filter_cmd cmd;
1384 u32 filter_id, attr_id, mask, value;
1387 if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
1388 &filter.frame_type, &pos) != 3)
1391 if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
1392 filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
1395 for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
1397 struct iwl_fw_bcast_filter_attr *attr =
1398 &filter.attrs[attr_id];
1403 if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
1404 &attr->offset, &attr->offset_type,
1405 &mask, &value, &next_pos) != 4)
1408 attr->mask = cpu_to_be32(mask);
1409 attr->val = cpu_to_be32(value);
1416 mutex_lock(&mvm->mutex);
1417 memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
1418 &filter, sizeof(filter));
1420 /* send updated bcast filtering configuration */
1421 if (iwl_mvm_firmware_running(mvm) &&
1422 mvm->dbgfs_bcast_filtering.override &&
1423 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
1424 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
1426 mutex_unlock(&mvm->mutex);
1428 return err ?: count;
1431 static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
1432 char __user *user_buf,
1433 size_t count, loff_t *ppos)
1435 struct iwl_mvm *mvm = file->private_data;
1436 struct iwl_bcast_filter_cmd cmd;
1442 buf = kzalloc(bufsz, GFP_KERNEL);
1446 mutex_lock(&mvm->mutex);
1447 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1449 mutex_unlock(&mvm->mutex);
1452 mutex_unlock(&mvm->mutex);
1454 for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
1455 const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
1457 ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
1458 i, mac->default_discard, mac->attached_filters);
1461 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1466 static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
1467 char *buf, size_t count,
1470 struct iwl_bcast_filter_cmd cmd;
1471 struct iwl_fw_bcast_mac mac = {};
1472 u32 mac_id, attached_filters;
1475 if (!mvm->bcast_filters)
1478 if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
1479 &attached_filters) != 3)
1482 if (mac_id >= ARRAY_SIZE(cmd.macs) ||
1483 mac.default_discard > 1 ||
1484 attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
1487 mac.attached_filters = cpu_to_le16(attached_filters);
1489 mutex_lock(&mvm->mutex);
1490 memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
1493 /* send updated bcast filtering configuration */
1494 if (iwl_mvm_firmware_running(mvm) &&
1495 mvm->dbgfs_bcast_filtering.override &&
1496 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
1497 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
1499 mutex_unlock(&mvm->mutex);
1501 return err ?: count;
1505 #ifdef CONFIG_PM_SLEEP
1506 static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
1507 size_t count, loff_t *ppos)
1511 if (sscanf(buf, "%d", &store) != 1)
1514 mvm->store_d3_resume_sram = store;
1519 static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
1520 size_t count, loff_t *ppos)
1522 struct iwl_mvm *mvm = file->private_data;
1523 const struct fw_img *img;
1524 int ofs, len, pos = 0;
1527 u8 *ptr = mvm->d3_resume_sram;
1529 img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1530 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1532 bufsz = len * 4 + 256;
1533 buf = kzalloc(bufsz, GFP_KERNEL);
1537 pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
1538 mvm->store_d3_resume_sram ? "en" : "dis");
1541 for (ofs = 0; ofs < len; ofs += 16) {
1542 pos += scnprintf(buf + pos, bufsz - pos,
1543 "0x%.4x %16ph\n", ofs, ptr + ofs);
1546 pos += scnprintf(buf + pos, bufsz - pos,
1547 "(no data captured)\n");
1550 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1558 #define PRINT_MVM_REF(ref) do { \
1559 if (mvm->refs[ref]) \
1560 pos += scnprintf(buf + pos, bufsz - pos, \
1561 "\t(0x%lx): %d %s\n", \
1562 BIT(ref), mvm->refs[ref], #ref); \
1565 static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
1566 char __user *user_buf,
1567 size_t count, loff_t *ppos)
1569 struct iwl_mvm *mvm = file->private_data;
1572 const size_t bufsz = sizeof(buf);
1575 for (i = 0; i < IWL_MVM_REF_COUNT; i++)
1579 pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
1582 PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
1583 PRINT_MVM_REF(IWL_MVM_REF_SCAN);
1584 PRINT_MVM_REF(IWL_MVM_REF_ROC);
1585 PRINT_MVM_REF(IWL_MVM_REF_ROC_AUX);
1586 PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
1587 PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
1588 PRINT_MVM_REF(IWL_MVM_REF_USER);
1589 PRINT_MVM_REF(IWL_MVM_REF_TX);
1590 PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
1591 PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
1592 PRINT_MVM_REF(IWL_MVM_REF_START_AP);
1593 PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
1594 PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
1595 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
1596 PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
1597 PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
1598 PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
1599 PRINT_MVM_REF(IWL_MVM_REF_NMI);
1600 PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
1601 PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
1602 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA);
1603 PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT);
1604 PRINT_MVM_REF(IWL_MVM_REF_INIT_UCODE);
1605 PRINT_MVM_REF(IWL_MVM_REF_SENDING_CMD);
1606 PRINT_MVM_REF(IWL_MVM_REF_RX);
1608 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1611 static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
1612 size_t count, loff_t *ppos)
1614 unsigned long value;
1618 ret = kstrtoul(buf, 10, &value);
1622 mutex_lock(&mvm->mutex);
1624 taken = mvm->refs[IWL_MVM_REF_USER];
1625 if (value == 1 && !taken)
1626 iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
1627 else if (value == 0 && taken)
1628 iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
1632 mutex_unlock(&mvm->mutex);
1639 #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1640 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1641 #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1642 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1643 #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1644 if (!debugfs_create_file(alias, mode, parent, mvm, \
1645 &iwl_dbgfs_##name##_ops)) \
1648 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1649 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
1651 #define MVM_DEBUGFS_WRITE_STA_FILE_OPS(name, bufsz) \
1652 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1653 #define MVM_DEBUGFS_READ_WRITE_STA_FILE_OPS(name, bufsz) \
1654 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1656 #define MVM_DEBUGFS_ADD_STA_FILE_ALIAS(alias, name, parent, mode) do { \
1657 if (!debugfs_create_file(alias, mode, parent, sta, \
1658 &iwl_dbgfs_##name##_ops)) \
1661 #define MVM_DEBUGFS_ADD_STA_FILE(name, parent, mode) \
1662 MVM_DEBUGFS_ADD_STA_FILE_ALIAS(#name, name, parent, mode)
1665 iwl_dbgfs_prph_reg_read(struct file *file,
1666 char __user *user_buf,
1667 size_t count, loff_t *ppos)
1669 struct iwl_mvm *mvm = file->private_data;
1672 const size_t bufsz = sizeof(buf);
1675 if (!mvm->dbgfs_prph_reg_addr)
1678 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
1682 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1683 mvm->dbgfs_prph_reg_addr,
1684 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1686 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
1688 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1692 iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1693 size_t count, loff_t *ppos)
1699 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1700 /* if we only want to set the reg address - nothing more to do */
1704 /* otherwise, make sure we have both address and value */
1708 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1712 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
1714 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
1720 iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1721 size_t count, loff_t *ppos)
1725 if (!iwl_mvm_firmware_running(mvm))
1728 mutex_lock(&mvm->mutex);
1729 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
1730 mutex_unlock(&mvm->mutex);
1732 return ret ?: count;
1736 iwl_dbgfs_uapsd_noagg_bssids_read(struct file *file, char __user *user_buf,
1737 size_t count, loff_t *ppos)
1739 struct iwl_mvm *mvm = file->private_data;
1740 u8 buf[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM * ETH_ALEN * 3 + 1];
1741 unsigned int pos = 0;
1742 size_t bufsz = sizeof(buf);
1745 mutex_lock(&mvm->mutex);
1747 for (i = 0; i < IWL_MVM_UAPSD_NOAGG_LIST_LEN; i++)
1748 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
1749 mvm->uapsd_noagg_bssids[i].addr);
1751 mutex_unlock(&mvm->mutex);
1753 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1756 MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1758 /* Device wide debugfs entries */
1759 MVM_DEBUGFS_READ_FILE_OPS(ctdp_budget);
1760 MVM_DEBUGFS_WRITE_FILE_OPS(stop_ctdp, 8);
1761 MVM_DEBUGFS_WRITE_FILE_OPS(force_ctkill, 8);
1762 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1763 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
1764 MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
1765 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
1766 MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
1767 MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
1768 MVM_DEBUGFS_READ_FILE_OPS(stations);
1769 MVM_DEBUGFS_READ_FILE_OPS(rs_data);
1770 MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
1771 MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
1772 MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
1773 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
1774 MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
1775 MVM_DEBUGFS_READ_FILE_OPS(fw_ver);
1776 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1777 MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
1778 MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
1779 MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
1780 MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
1781 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
1782 MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
1783 MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64);
1784 MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8);
1785 MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8);
1786 MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1787 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
1788 MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512);
1790 MVM_DEBUGFS_READ_FILE_OPS(uapsd_noagg_bssids);
1792 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1793 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
1794 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
1797 #ifdef CONFIG_PM_SLEEP
1798 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
1801 MVM_DEBUGFS_READ_FILE_OPS(sar_geo_profile);
1804 static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
1805 size_t count, loff_t *ppos)
1807 struct iwl_mvm *mvm = file->private_data;
1808 struct iwl_dbg_mem_access_cmd cmd = {};
1809 struct iwl_dbg_mem_access_rsp *rsp;
1810 struct iwl_host_cmd hcmd = {
1811 .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1813 .len = { sizeof(cmd) },
1818 if (!iwl_mvm_firmware_running(mvm))
1821 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1823 cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
1825 /* Take care of alignment of both the position and the length */
1826 delta = *ppos & 0x3;
1827 cmd.addr = cpu_to_le32(*ppos - delta);
1828 cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
1829 (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
1831 mutex_lock(&mvm->mutex);
1832 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1833 mutex_unlock(&mvm->mutex);
1838 rsp = (void *)hcmd.resp_pkt->data;
1839 if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) {
1844 len = min((size_t)le32_to_cpu(rsp->len) << 2,
1845 iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp));
1846 len = min(len - delta, count);
1852 ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len);
1856 iwl_free_resp(&hcmd);
1860 static ssize_t iwl_dbgfs_mem_write(struct file *file,
1861 const char __user *user_buf, size_t count,
1864 struct iwl_mvm *mvm = file->private_data;
1865 struct iwl_dbg_mem_access_cmd *cmd;
1866 struct iwl_dbg_mem_access_rsp *rsp;
1867 struct iwl_host_cmd hcmd = {};
1873 if (!iwl_mvm_firmware_running(mvm))
1876 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1879 if (*ppos & 0x3 || count < 4) {
1880 op = DEBUG_MEM_OP_WRITE_BYTES;
1881 len = min(count, (size_t)(4 - (*ppos & 0x3)));
1884 op = DEBUG_MEM_OP_WRITE;
1885 len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS);
1886 data_size = len << 2;
1889 cmd_size = sizeof(*cmd) + ALIGN(data_size, 4);
1890 cmd = kzalloc(cmd_size, GFP_KERNEL);
1894 cmd->op = cpu_to_le32(op);
1895 cmd->len = cpu_to_le32(len);
1896 cmd->addr = cpu_to_le32(*ppos);
1897 if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
1902 hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1903 hcmd.data[0] = (void *)cmd;
1904 hcmd.len[0] = cmd_size;
1906 mutex_lock(&mvm->mutex);
1907 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1908 mutex_unlock(&mvm->mutex);
1915 rsp = (void *)hcmd.resp_pkt->data;
1916 if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) {
1925 iwl_free_resp(&hcmd);
1929 static const struct file_operations iwl_dbgfs_mem_ops = {
1930 .read = iwl_dbgfs_mem_read,
1931 .write = iwl_dbgfs_mem_write,
1932 .open = simple_open,
1933 .llseek = default_llseek,
1936 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
1937 struct ieee80211_vif *vif,
1938 struct ieee80211_sta *sta,
1941 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1943 if (iwl_mvm_has_tlc_offload(mvm))
1944 MVM_DEBUGFS_ADD_STA_FILE(rs_data, dir, 0400);
1948 IWL_ERR(mvm, "Can't create the mvm station debugfs entry\n");
1951 int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1953 struct dentry *bcast_dir __maybe_unused;
1956 spin_lock_init(&mvm->drv_stats_lock);
1958 mvm->debugfs_dir = dbgfs_dir;
1960 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, 0200);
1961 MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, 0200);
1962 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, 0600);
1963 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir, 0600);
1964 MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, 0400);
1965 MVM_DEBUGFS_ADD_FILE(ctdp_budget, dbgfs_dir, 0400);
1966 MVM_DEBUGFS_ADD_FILE(stop_ctdp, dbgfs_dir, 0200);
1967 MVM_DEBUGFS_ADD_FILE(force_ctkill, dbgfs_dir, 0200);
1968 MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, 0400);
1969 MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, 0400);
1970 MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, 0400);
1971 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir, 0600);
1972 MVM_DEBUGFS_ADD_FILE(fw_ver, mvm->debugfs_dir, 0400);
1973 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, 0400);
1974 MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, 0400);
1975 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, 0200);
1976 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, 0200);
1977 MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, 0200);
1978 MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, 0200);
1979 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir, 0600);
1980 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, 0600);
1981 MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, 0600);
1982 MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, 0600);
1983 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, 0200);
1984 MVM_DEBUGFS_ADD_FILE(max_amsdu_len, mvm->debugfs_dir, 0200);
1985 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, 0200);
1986 MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, 0200);
1987 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, 0200);
1988 MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, 0200);
1990 MVM_DEBUGFS_ADD_FILE(sar_geo_profile, dbgfs_dir, 0400);
1993 if (!debugfs_create_bool("enable_scan_iteration_notif",
1996 &mvm->scan_iter_notif_enabled))
1998 if (!debugfs_create_bool("drop_bcn_ap_mode", 0600,
1999 mvm->debugfs_dir, &mvm->drop_bcn_ap_mode))
2002 MVM_DEBUGFS_ADD_FILE(uapsd_noagg_bssids, mvm->debugfs_dir, S_IRUSR);
2004 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
2005 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
2006 bcast_dir = debugfs_create_dir("bcast_filtering",
2011 if (!debugfs_create_bool("override", 0600,
2013 &mvm->dbgfs_bcast_filtering.override))
2016 MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
2018 MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
2023 #ifdef CONFIG_PM_SLEEP
2024 MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, 0600);
2025 MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, 0400);
2026 if (!debugfs_create_bool("d3_wake_sysassert", 0600,
2027 mvm->debugfs_dir, &mvm->d3_wake_sysassert))
2029 if (!debugfs_create_u32("last_netdetect_scans", 0400,
2030 mvm->debugfs_dir, &mvm->last_netdetect_scans))
2034 if (!debugfs_create_u8("ps_disabled", 0400,
2035 mvm->debugfs_dir, &mvm->ps_disabled))
2037 if (!debugfs_create_blob("nvm_hw", 0400,
2038 mvm->debugfs_dir, &mvm->nvm_hw_blob))
2040 if (!debugfs_create_blob("nvm_sw", 0400,
2041 mvm->debugfs_dir, &mvm->nvm_sw_blob))
2043 if (!debugfs_create_blob("nvm_calib", 0400,
2044 mvm->debugfs_dir, &mvm->nvm_calib_blob))
2046 if (!debugfs_create_blob("nvm_prod", 0400,
2047 mvm->debugfs_dir, &mvm->nvm_prod_blob))
2049 if (!debugfs_create_blob("nvm_phy_sku", 0400,
2050 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
2053 debugfs_create_file("mem", 0600, dbgfs_dir, mvm, &iwl_dbgfs_mem_ops);
2056 * Create a symlink with mac80211. It will be removed when mac80211
2057 * exists (before the opmode exists which removes the target.)
2059 snprintf(buf, 100, "../../%pd2", dbgfs_dir->d_parent);
2060 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
2065 IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");