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
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
26 * The full GNU General Public License is included in this distribution
27 * in the file called COPYING.
29 * Contact Information:
30 * Intel Linux Wireless <linuxwifi@intel.com>
31 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
35 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
36 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
37 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
38 * All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
44 * * Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * * Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in
48 * the documentation and/or other materials provided with the
50 * * Neither the name Intel Corporation nor the names of its
51 * contributors may be used to endorse or promote products derived
52 * from this software without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
60 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
61 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 *****************************************************************************/
67 #include <linux/vmalloc.h>
68 #include <linux/ieee80211.h>
69 #include <linux/netdevice.h>
75 #include "fw/error-dump.h"
77 static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
78 char __user *user_buf,
79 size_t count, loff_t *ppos)
81 struct iwl_mvm *mvm = file->private_data;
85 if (!iwl_mvm_is_ctdp_supported(mvm))
88 if (!iwl_mvm_firmware_running(mvm) ||
89 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
92 mutex_lock(&mvm->mutex);
93 budget = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_REPORT, 0);
94 mutex_unlock(&mvm->mutex);
99 pos = scnprintf(buf, sizeof(buf), "%d\n", budget);
101 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
104 static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
105 size_t count, loff_t *ppos)
109 if (!iwl_mvm_is_ctdp_supported(mvm))
112 if (!iwl_mvm_firmware_running(mvm) ||
113 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
116 mutex_lock(&mvm->mutex);
117 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_STOP, 0);
118 mutex_unlock(&mvm->mutex);
123 static ssize_t iwl_dbgfs_force_ctkill_write(struct iwl_mvm *mvm, char *buf,
124 size_t count, loff_t *ppos)
126 if (!iwl_mvm_firmware_running(mvm) ||
127 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
130 iwl_mvm_enter_ctkill(mvm);
135 static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
136 size_t count, loff_t *ppos)
141 if (!iwl_mvm_firmware_running(mvm) ||
142 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
145 if (kstrtou32(buf, 0, &flush_arg))
148 if (iwl_mvm_has_new_tx_api(mvm)) {
149 IWL_DEBUG_TX_QUEUES(mvm,
150 "FLUSHING all tids queues on sta_id = %d\n",
152 mutex_lock(&mvm->mutex);
153 ret = iwl_mvm_flush_sta_tids(mvm, flush_arg, 0xFF, 0) ? : count;
154 mutex_unlock(&mvm->mutex);
158 IWL_DEBUG_TX_QUEUES(mvm, "FLUSHING queues mask to flush = 0x%x\n",
161 mutex_lock(&mvm->mutex);
162 ret = iwl_mvm_flush_tx_path(mvm, flush_arg, 0) ? : count;
163 mutex_unlock(&mvm->mutex);
168 static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
169 size_t count, loff_t *ppos)
171 struct iwl_mvm_sta *mvmsta;
172 int sta_id, drain, ret;
174 if (!iwl_mvm_firmware_running(mvm) ||
175 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
178 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
180 if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
182 if (drain < 0 || drain > 1)
185 mutex_lock(&mvm->mutex);
187 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
192 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
194 mutex_unlock(&mvm->mutex);
199 static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
200 size_t count, loff_t *ppos)
202 struct iwl_mvm *mvm = file->private_data;
203 const struct fw_img *img;
204 unsigned int ofs, len;
208 if (!iwl_mvm_firmware_running(mvm))
211 /* default is to dump the entire data segment */
212 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
213 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
214 len = img->sec[IWL_UCODE_SECTION_DATA].len;
216 if (mvm->dbgfs_sram_len) {
217 ofs = mvm->dbgfs_sram_offset;
218 len = mvm->dbgfs_sram_len;
221 ptr = kzalloc(len, GFP_KERNEL);
225 iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
227 ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
234 static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
235 size_t count, loff_t *ppos)
237 const struct fw_img *img;
239 u32 img_offset, img_len;
241 if (!iwl_mvm_firmware_running(mvm))
244 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
245 img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
246 img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
248 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
249 if ((offset & 0x3) || (len & 0x3))
252 if (offset + len > img_offset + img_len)
255 mvm->dbgfs_sram_offset = offset;
256 mvm->dbgfs_sram_len = len;
258 mvm->dbgfs_sram_offset = 0;
259 mvm->dbgfs_sram_len = 0;
265 static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
266 char __user *user_buf,
267 size_t count, loff_t *ppos)
269 struct iwl_mvm *mvm = file->private_data;
273 if (!mvm->temperature_test)
274 pos = scnprintf(buf , sizeof(buf), "disabled\n");
276 pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
278 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
282 * Set NIC Temperature
283 * Cause the driver to ignore the actual NIC temperature reported by the FW
284 * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
285 * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
286 * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
288 static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
289 char *buf, size_t count,
294 if (!iwl_mvm_firmware_running(mvm) && !mvm->temperature_test)
297 if (kstrtoint(buf, 10, &temperature))
299 /* not a legal temperature */
300 if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
301 temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
302 temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
305 mutex_lock(&mvm->mutex);
306 if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
307 if (!mvm->temperature_test)
310 mvm->temperature_test = false;
311 /* Since we can't read the temp while awake, just set
312 * it to zero until we get the next RX stats from the
315 mvm->temperature = 0;
317 mvm->temperature_test = true;
318 mvm->temperature = temperature;
320 IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
321 mvm->temperature_test ? "En" : "Dis" ,
323 /* handle the temperature change */
324 iwl_mvm_tt_handler(mvm);
327 mutex_unlock(&mvm->mutex);
332 static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
333 char __user *user_buf,
334 size_t count, loff_t *ppos)
336 struct iwl_mvm *mvm = file->private_data;
341 if (!iwl_mvm_firmware_running(mvm))
344 mutex_lock(&mvm->mutex);
345 ret = iwl_mvm_get_temp(mvm, &temp);
346 mutex_unlock(&mvm->mutex);
351 pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
353 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
357 static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file,
358 char __user *user_buf,
359 size_t count, loff_t *ppos)
361 struct iwl_mvm *mvm = file->private_data;
364 int bufsz = sizeof(buf);
368 if (!iwl_mvm_firmware_running(mvm))
371 mutex_lock(&mvm->mutex);
372 tbl_idx = iwl_mvm_get_sar_geo_profile(mvm);
374 mutex_unlock(&mvm->mutex);
379 pos = scnprintf(buf, bufsz,
380 "SAR geographic profile disabled\n");
382 value = &mvm->geo_profiles[tbl_idx - 1].values[0];
384 pos += scnprintf(buf + pos, bufsz - pos,
385 "Use geographic profile %d\n", tbl_idx);
386 pos += scnprintf(buf + pos, bufsz - pos,
387 "2.4GHz:\n\tChain A offset: %hhd dBm\n\tChain B offset: %hhd dBm\n\tmax tx power: %hhd dBm\n",
388 value[1], value[2], value[0]);
389 pos += scnprintf(buf + pos, bufsz - pos,
390 "5.2GHz:\n\tChain A offset: %hhd dBm\n\tChain B offset: %hhd dBm\n\tmax tx power: %hhd dBm\n",
391 value[4], value[5], value[3]);
393 mutex_unlock(&mvm->mutex);
395 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
399 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
400 size_t count, loff_t *ppos)
402 struct iwl_mvm *mvm = file->private_data;
403 struct ieee80211_sta *sta;
405 int i, pos = 0, bufsz = sizeof(buf);
407 mutex_lock(&mvm->mutex);
409 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) {
410 pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
411 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
412 lockdep_is_held(&mvm->mutex));
414 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
415 else if (IS_ERR(sta))
416 pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
419 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
423 mutex_unlock(&mvm->mutex);
425 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
428 static ssize_t iwl_dbgfs_rs_data_read(struct file *file, char __user *user_buf,
429 size_t count, loff_t *ppos)
431 struct ieee80211_sta *sta = file->private_data;
432 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
433 struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->lq_sta.rs_fw;
434 struct iwl_mvm *mvm = lq_sta->pers.drv;
435 static const size_t bufsz = 2048;
440 buff = kmalloc(bufsz, GFP_KERNEL);
444 mutex_lock(&mvm->mutex);
446 desc += scnprintf(buff + desc, bufsz - desc, "sta_id %d\n",
447 lq_sta->pers.sta_id);
448 desc += scnprintf(buff + desc, bufsz - desc,
450 lq_sta->pers.dbg_fixed_rate);
451 desc += scnprintf(buff + desc, bufsz - desc,
452 "A-MPDU size limit %d\n",
453 lq_sta->pers.dbg_agg_frame_count_lim);
454 desc += scnprintf(buff + desc, bufsz - desc,
455 "valid_tx_ant %s%s%s\n",
456 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_A) ? "ANT_A," : "",
457 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_B) ? "ANT_B," : "",
458 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_C) ? "ANT_C" : "");
459 desc += scnprintf(buff + desc, bufsz - desc,
460 "last tx rate=0x%X ",
461 lq_sta->last_rate_n_flags);
463 desc += rs_pretty_print_rate(buff + desc, bufsz - desc,
464 lq_sta->last_rate_n_flags);
465 mutex_unlock(&mvm->mutex);
467 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
472 static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
473 char __user *user_buf,
474 size_t count, loff_t *ppos)
476 struct iwl_mvm *mvm = file->private_data;
478 int bufsz = sizeof(buf);
481 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
482 mvm->disable_power_off);
483 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
484 mvm->disable_power_off_d3);
486 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
489 static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
490 size_t count, loff_t *ppos)
494 if (!iwl_mvm_firmware_running(mvm))
497 if (!strncmp("disable_power_off_d0=", buf, 21)) {
498 if (sscanf(buf + 21, "%d", &val) != 1)
500 mvm->disable_power_off = val;
501 } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
502 if (sscanf(buf + 21, "%d", &val) != 1)
504 mvm->disable_power_off_d3 = val;
509 mutex_lock(&mvm->mutex);
510 ret = iwl_mvm_power_update_device(mvm);
511 mutex_unlock(&mvm->mutex);
517 int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
520 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
522 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
523 BT_MBOX_PRINT(0, LE_PROF1, false);
524 BT_MBOX_PRINT(0, LE_PROF2, false);
525 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
526 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
527 BT_MBOX_PRINT(0, INBAND_S, false);
528 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
529 BT_MBOX_PRINT(0, LE_SCAN, false);
530 BT_MBOX_PRINT(0, LE_ADV, false);
531 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
532 BT_MBOX_PRINT(0, OPEN_CON_1, true);
534 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
536 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
537 BT_MBOX_PRINT(1, IP_SR, false);
538 BT_MBOX_PRINT(1, LE_MSTR, false);
539 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
540 BT_MBOX_PRINT(1, MSG_TYPE, false);
541 BT_MBOX_PRINT(1, SSN, true);
543 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
545 BT_MBOX_PRINT(2, SNIFF_ACT, false);
546 BT_MBOX_PRINT(2, PAG, false);
547 BT_MBOX_PRINT(2, INQUIRY, false);
548 BT_MBOX_PRINT(2, CONN, false);
549 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
550 BT_MBOX_PRINT(2, DISC, false);
551 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
552 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
553 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
554 BT_MBOX_PRINT(2, SCO_DURATION, true);
556 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
558 BT_MBOX_PRINT(3, SCO_STATE, false);
559 BT_MBOX_PRINT(3, SNIFF_STATE, false);
560 BT_MBOX_PRINT(3, A2DP_STATE, false);
561 BT_MBOX_PRINT(3, A2DP_SRC, false);
562 BT_MBOX_PRINT(3, ACL_STATE, false);
563 BT_MBOX_PRINT(3, MSTR_STATE, false);
564 BT_MBOX_PRINT(3, OBX_STATE, false);
565 BT_MBOX_PRINT(3, OPEN_CON_2, false);
566 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
567 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
568 BT_MBOX_PRINT(3, INBAND_P, false);
569 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
570 BT_MBOX_PRINT(3, SSN_2, false);
571 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
576 static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
577 size_t count, loff_t *ppos)
579 struct iwl_mvm *mvm = file->private_data;
580 struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
582 int ret, pos = 0, bufsz = sizeof(char) * 1024;
584 buf = kmalloc(bufsz, GFP_KERNEL);
588 mutex_lock(&mvm->mutex);
590 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
592 pos += scnprintf(buf + pos, bufsz - pos, "bt_ci_compliance = %d\n",
593 notif->bt_ci_compliance);
594 pos += scnprintf(buf + pos, bufsz - pos, "primary_ch_lut = %d\n",
595 le32_to_cpu(notif->primary_ch_lut));
596 pos += scnprintf(buf + pos, bufsz - pos, "secondary_ch_lut = %d\n",
597 le32_to_cpu(notif->secondary_ch_lut));
598 pos += scnprintf(buf + pos,
599 bufsz - pos, "bt_activity_grading = %d\n",
600 le32_to_cpu(notif->bt_activity_grading));
601 pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n",
602 notif->rrc_status & 0xF);
603 pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n",
604 notif->ttc_status & 0xF);
606 pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n",
607 IWL_MVM_BT_COEX_SYNC2SCO);
608 pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n",
609 IWL_MVM_BT_COEX_MPLUT);
611 mutex_unlock(&mvm->mutex);
613 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
620 static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
621 size_t count, loff_t *ppos)
623 struct iwl_mvm *mvm = file->private_data;
624 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
626 int bufsz = sizeof(buf);
629 mutex_lock(&mvm->mutex);
631 pos += scnprintf(buf + pos, bufsz - pos, "Channel inhibition CMD\n");
632 pos += scnprintf(buf + pos, bufsz - pos,
633 "\tPrimary Channel Bitmap 0x%016llx\n",
634 le64_to_cpu(cmd->bt_primary_ci));
635 pos += scnprintf(buf + pos, bufsz - pos,
636 "\tSecondary Channel Bitmap 0x%016llx\n",
637 le64_to_cpu(cmd->bt_secondary_ci));
639 mutex_unlock(&mvm->mutex);
641 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
645 iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
646 size_t count, loff_t *ppos)
650 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
655 mvm->bt_tx_prio = bt_tx_prio;
661 iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
662 size_t count, loff_t *ppos)
664 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
665 [BT_FORCE_ANT_DIS] = "dis",
666 [BT_FORCE_ANT_AUTO] = "auto",
667 [BT_FORCE_ANT_BT] = "bt",
668 [BT_FORCE_ANT_WIFI] = "wifi",
670 int ret, bt_force_ant_mode;
672 for (bt_force_ant_mode = 0;
673 bt_force_ant_mode < ARRAY_SIZE(modes_str);
674 bt_force_ant_mode++) {
675 if (!strcmp(buf, modes_str[bt_force_ant_mode]))
679 if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
683 mutex_lock(&mvm->mutex);
684 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
687 mvm->bt_force_ant_mode = bt_force_ant_mode;
688 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
689 modes_str[mvm->bt_force_ant_mode]);
691 if (iwl_mvm_firmware_running(mvm))
692 ret = iwl_mvm_send_bt_init_conf(mvm);
697 mutex_unlock(&mvm->mutex);
701 static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
702 size_t count, loff_t *ppos)
704 struct iwl_mvm *mvm = file->private_data;
705 char *buff, *pos, *endpos;
706 static const size_t bufsz = 1024;
709 buff = kmalloc(bufsz, GFP_KERNEL);
714 endpos = pos + bufsz;
716 pos += scnprintf(pos, endpos - pos, "FW prefix: %s\n",
717 mvm->trans->cfg->fw_name_pre);
718 pos += scnprintf(pos, endpos - pos, "FW: %s\n",
719 mvm->fwrt.fw->human_readable);
720 pos += scnprintf(pos, endpos - pos, "Device: %s\n",
721 mvm->fwrt.trans->cfg->name);
722 pos += scnprintf(pos, endpos - pos, "Bus: %s\n",
723 mvm->fwrt.dev->bus->name);
725 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
731 #define PRINT_STATS_LE32(_struct, _memb) \
732 pos += scnprintf(buf + pos, bufsz - pos, \
734 le32_to_cpu(_struct->_memb))
736 static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
737 char __user *user_buf, size_t count,
740 struct iwl_mvm *mvm = file->private_data;
741 static const char *fmt_table = "\t%-30s %10u\n";
742 static const char *fmt_header = "%-32s\n";
748 if (iwl_mvm_has_new_rx_stats_api(mvm))
749 bufsz = ((sizeof(struct mvm_statistics_rx) /
750 sizeof(__le32)) * 43) + (4 * 33) + 1;
752 /* 43 = size of each data line; 33 = size of each header */
753 bufsz = ((sizeof(struct mvm_statistics_rx_v3) /
754 sizeof(__le32)) * 43) + (4 * 33) + 1;
756 buf = kzalloc(bufsz, GFP_KERNEL);
760 mutex_lock(&mvm->mutex);
762 if (iwl_mvm_firmware_running(mvm))
763 iwl_mvm_request_statistics(mvm, false);
765 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
766 "Statistics_Rx - OFDM");
767 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
768 struct mvm_statistics_rx_phy_v2 *ofdm = &mvm->rx_stats_v3.ofdm;
770 PRINT_STATS_LE32(ofdm, ina_cnt);
771 PRINT_STATS_LE32(ofdm, fina_cnt);
772 PRINT_STATS_LE32(ofdm, plcp_err);
773 PRINT_STATS_LE32(ofdm, crc32_err);
774 PRINT_STATS_LE32(ofdm, overrun_err);
775 PRINT_STATS_LE32(ofdm, early_overrun_err);
776 PRINT_STATS_LE32(ofdm, crc32_good);
777 PRINT_STATS_LE32(ofdm, false_alarm_cnt);
778 PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
779 PRINT_STATS_LE32(ofdm, sfd_timeout);
780 PRINT_STATS_LE32(ofdm, fina_timeout);
781 PRINT_STATS_LE32(ofdm, unresponded_rts);
782 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
783 PRINT_STATS_LE32(ofdm, sent_ack_cnt);
784 PRINT_STATS_LE32(ofdm, sent_cts_cnt);
785 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
786 PRINT_STATS_LE32(ofdm, dsp_self_kill);
787 PRINT_STATS_LE32(ofdm, mh_format_err);
788 PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
789 PRINT_STATS_LE32(ofdm, reserved);
791 struct mvm_statistics_rx_phy *ofdm = &mvm->rx_stats.ofdm;
793 PRINT_STATS_LE32(ofdm, unresponded_rts);
794 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
795 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
796 PRINT_STATS_LE32(ofdm, dsp_self_kill);
797 PRINT_STATS_LE32(ofdm, reserved);
800 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
801 "Statistics_Rx - CCK");
802 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
803 struct mvm_statistics_rx_phy_v2 *cck = &mvm->rx_stats_v3.cck;
805 PRINT_STATS_LE32(cck, ina_cnt);
806 PRINT_STATS_LE32(cck, fina_cnt);
807 PRINT_STATS_LE32(cck, plcp_err);
808 PRINT_STATS_LE32(cck, crc32_err);
809 PRINT_STATS_LE32(cck, overrun_err);
810 PRINT_STATS_LE32(cck, early_overrun_err);
811 PRINT_STATS_LE32(cck, crc32_good);
812 PRINT_STATS_LE32(cck, false_alarm_cnt);
813 PRINT_STATS_LE32(cck, fina_sync_err_cnt);
814 PRINT_STATS_LE32(cck, sfd_timeout);
815 PRINT_STATS_LE32(cck, fina_timeout);
816 PRINT_STATS_LE32(cck, unresponded_rts);
817 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
818 PRINT_STATS_LE32(cck, sent_ack_cnt);
819 PRINT_STATS_LE32(cck, sent_cts_cnt);
820 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
821 PRINT_STATS_LE32(cck, dsp_self_kill);
822 PRINT_STATS_LE32(cck, mh_format_err);
823 PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
824 PRINT_STATS_LE32(cck, reserved);
826 struct mvm_statistics_rx_phy *cck = &mvm->rx_stats.cck;
828 PRINT_STATS_LE32(cck, unresponded_rts);
829 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
830 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
831 PRINT_STATS_LE32(cck, dsp_self_kill);
832 PRINT_STATS_LE32(cck, reserved);
835 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
836 "Statistics_Rx - GENERAL");
837 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
838 struct mvm_statistics_rx_non_phy_v3 *general =
839 &mvm->rx_stats_v3.general;
841 PRINT_STATS_LE32(general, bogus_cts);
842 PRINT_STATS_LE32(general, bogus_ack);
843 PRINT_STATS_LE32(general, non_bssid_frames);
844 PRINT_STATS_LE32(general, filtered_frames);
845 PRINT_STATS_LE32(general, non_channel_beacons);
846 PRINT_STATS_LE32(general, channel_beacons);
847 PRINT_STATS_LE32(general, num_missed_bcon);
848 PRINT_STATS_LE32(general, adc_rx_saturation_time);
849 PRINT_STATS_LE32(general, ina_detection_search_time);
850 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
851 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
852 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
853 PRINT_STATS_LE32(general, interference_data_flag);
854 PRINT_STATS_LE32(general, channel_load);
855 PRINT_STATS_LE32(general, dsp_false_alarms);
856 PRINT_STATS_LE32(general, beacon_rssi_a);
857 PRINT_STATS_LE32(general, beacon_rssi_b);
858 PRINT_STATS_LE32(general, beacon_rssi_c);
859 PRINT_STATS_LE32(general, beacon_energy_a);
860 PRINT_STATS_LE32(general, beacon_energy_b);
861 PRINT_STATS_LE32(general, beacon_energy_c);
862 PRINT_STATS_LE32(general, num_bt_kills);
863 PRINT_STATS_LE32(general, mac_id);
864 PRINT_STATS_LE32(general, directed_data_mpdu);
866 struct mvm_statistics_rx_non_phy *general =
867 &mvm->rx_stats.general;
869 PRINT_STATS_LE32(general, bogus_cts);
870 PRINT_STATS_LE32(general, bogus_ack);
871 PRINT_STATS_LE32(general, non_channel_beacons);
872 PRINT_STATS_LE32(general, channel_beacons);
873 PRINT_STATS_LE32(general, num_missed_bcon);
874 PRINT_STATS_LE32(general, adc_rx_saturation_time);
875 PRINT_STATS_LE32(general, ina_detection_search_time);
876 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
877 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
878 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
879 PRINT_STATS_LE32(general, interference_data_flag);
880 PRINT_STATS_LE32(general, channel_load);
881 PRINT_STATS_LE32(general, beacon_rssi_a);
882 PRINT_STATS_LE32(general, beacon_rssi_b);
883 PRINT_STATS_LE32(general, beacon_rssi_c);
884 PRINT_STATS_LE32(general, beacon_energy_a);
885 PRINT_STATS_LE32(general, beacon_energy_b);
886 PRINT_STATS_LE32(general, beacon_energy_c);
887 PRINT_STATS_LE32(general, num_bt_kills);
888 PRINT_STATS_LE32(general, mac_id);
891 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
892 "Statistics_Rx - HT");
893 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
894 struct mvm_statistics_rx_ht_phy_v1 *ht =
895 &mvm->rx_stats_v3.ofdm_ht;
897 PRINT_STATS_LE32(ht, plcp_err);
898 PRINT_STATS_LE32(ht, overrun_err);
899 PRINT_STATS_LE32(ht, early_overrun_err);
900 PRINT_STATS_LE32(ht, crc32_good);
901 PRINT_STATS_LE32(ht, crc32_err);
902 PRINT_STATS_LE32(ht, mh_format_err);
903 PRINT_STATS_LE32(ht, agg_crc32_good);
904 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
905 PRINT_STATS_LE32(ht, agg_cnt);
906 PRINT_STATS_LE32(ht, unsupport_mcs);
908 struct mvm_statistics_rx_ht_phy *ht =
909 &mvm->rx_stats.ofdm_ht;
911 PRINT_STATS_LE32(ht, mh_format_err);
912 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
913 PRINT_STATS_LE32(ht, agg_cnt);
914 PRINT_STATS_LE32(ht, unsupport_mcs);
917 mutex_unlock(&mvm->mutex);
919 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
924 #undef PRINT_STAT_LE32
926 static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
927 char __user *user_buf, size_t count,
929 struct iwl_mvm_frame_stats *stats)
931 char *buff, *pos, *endpos;
934 static const size_t bufsz = 1024;
936 buff = kmalloc(bufsz, GFP_KERNEL);
940 spin_lock_bh(&mvm->drv_stats_lock);
943 endpos = pos + bufsz;
945 pos += scnprintf(pos, endpos - pos,
946 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
947 stats->legacy_frames,
950 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
953 stats->bw_80_frames);
954 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
957 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
959 stats->mimo2_frames);
960 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
962 stats->success_frames);
963 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
965 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
967 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
968 stats->ampdu_count > 0 ?
969 (stats->agg_frames / stats->ampdu_count) : 0);
971 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
973 idx = stats->last_frame_idx - 1;
974 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
975 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
976 if (stats->last_rates[idx] == 0)
978 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
979 (int)(ARRAY_SIZE(stats->last_rates) - i));
980 pos += rs_pretty_print_rate(pos, endpos - pos,
981 stats->last_rates[idx]);
983 spin_unlock_bh(&mvm->drv_stats_lock);
985 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
991 static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
992 char __user *user_buf, size_t count,
995 struct iwl_mvm *mvm = file->private_data;
997 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
1001 static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
1002 size_t count, loff_t *ppos)
1004 int __maybe_unused ret;
1006 if (!iwl_mvm_firmware_running(mvm))
1009 mutex_lock(&mvm->mutex);
1011 /* allow one more restart that we're provoking here */
1012 if (mvm->fw_restart >= 0)
1015 /* take the return value to make compiler happy - it will fail anyway */
1016 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
1018 mutex_unlock(&mvm->mutex);
1023 static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
1024 size_t count, loff_t *ppos)
1028 if (!iwl_mvm_firmware_running(mvm))
1031 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
1035 iwl_force_nmi(mvm->trans);
1037 iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
1043 iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
1044 char __user *user_buf,
1045 size_t count, loff_t *ppos)
1047 struct iwl_mvm *mvm = file->private_data;
1050 const size_t bufsz = sizeof(buf);
1052 /* print which antennas were set for the scan command by the user */
1053 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
1054 if (mvm->scan_rx_ant & ANT_A)
1055 pos += scnprintf(buf + pos, bufsz - pos, "A");
1056 if (mvm->scan_rx_ant & ANT_B)
1057 pos += scnprintf(buf + pos, bufsz - pos, "B");
1058 if (mvm->scan_rx_ant & ANT_C)
1059 pos += scnprintf(buf + pos, bufsz - pos, "C");
1060 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
1062 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1066 iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
1067 size_t count, loff_t *ppos)
1071 if (!iwl_mvm_firmware_running(mvm))
1074 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
1076 if (scan_rx_ant > ANT_ABC)
1078 if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
1081 if (mvm->scan_rx_ant != scan_rx_ant) {
1082 mvm->scan_rx_ant = scan_rx_ant;
1083 if (fw_has_capa(&mvm->fw->ucode_capa,
1084 IWL_UCODE_TLV_CAPA_UMAC_SCAN))
1085 iwl_mvm_config_scan(mvm);
1091 static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
1092 char *buf, size_t count,
1095 struct iwl_rss_config_cmd cmd = {
1096 .flags = cpu_to_le32(IWL_RSS_ENABLE),
1097 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
1098 IWL_RSS_HASH_TYPE_IPV4_UDP |
1099 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
1100 IWL_RSS_HASH_TYPE_IPV6_TCP |
1101 IWL_RSS_HASH_TYPE_IPV6_UDP |
1102 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
1104 int ret, i, num_repeats, nbytes = count / 2;
1106 ret = hex2bin(cmd.indirection_table, buf, nbytes);
1111 * The input is the redirection table, partial or full.
1112 * Repeat the pattern if needed.
1113 * For example, input of 01020F will be repeated 42 times,
1114 * indirecting RSS hash results to queues 1, 2, 15 (skipping
1117 num_repeats = ARRAY_SIZE(cmd.indirection_table) / nbytes;
1118 for (i = 1; i < num_repeats; i++)
1119 memcpy(&cmd.indirection_table[i * nbytes],
1120 cmd.indirection_table, nbytes);
1121 /* handle cut in the middle pattern for the last places */
1122 memcpy(&cmd.indirection_table[i * nbytes], cmd.indirection_table,
1123 ARRAY_SIZE(cmd.indirection_table) % nbytes);
1125 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
1127 mutex_lock(&mvm->mutex);
1128 if (iwl_mvm_firmware_running(mvm))
1129 ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0,
1133 mutex_unlock(&mvm->mutex);
1135 return ret ?: count;
1138 static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
1139 char *buf, size_t count,
1142 struct iwl_rx_cmd_buffer rxb = {
1143 ._rx_page_order = 0,
1144 .truesize = 0, /* not used */
1147 struct iwl_rx_packet *pkt;
1148 struct iwl_rx_mpdu_desc *desc;
1149 int bin_len = count / 2;
1152 if (!iwl_mvm_firmware_running(mvm))
1155 /* supporting only 9000 descriptor */
1156 if (!mvm->trans->cfg->mq_rx_supported)
1159 rxb._page = alloc_pages(GFP_ATOMIC, 0);
1162 pkt = rxb_addr(&rxb);
1164 ret = hex2bin(page_address(rxb._page), buf, bin_len);
1168 /* avoid invalid memory access */
1169 if (bin_len < sizeof(*pkt) + sizeof(*desc))
1172 /* check this is RX packet */
1173 if (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd) !=
1174 WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))
1177 /* check the length in metadata matches actual received length */
1178 desc = (void *)pkt->data;
1179 if (le16_to_cpu(desc->mpdu_len) !=
1180 (bin_len - sizeof(*desc) - sizeof(*pkt)))
1184 iwl_mvm_rx_mpdu_mq(mvm, NULL, &rxb, 0);
1191 return ret ?: count;
1194 static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
1195 char __user *user_buf,
1196 size_t count, loff_t *ppos)
1198 struct iwl_mvm *mvm = file->private_data;
1201 const size_t bufsz = sizeof(buf);
1204 mutex_lock(&mvm->mutex);
1205 conf = mvm->fwrt.dump.conf;
1206 mutex_unlock(&mvm->mutex);
1208 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
1210 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1214 * Enable / Disable continuous recording.
1215 * Cause the FW to start continuous recording, by sending the relevant hcmd.
1216 * Enable: input of every integer larger than 0, ENABLE_CONT_RECORDING.
1217 * Disable: for 0 as input, DISABLE_CONT_RECORDING.
1219 static ssize_t iwl_dbgfs_cont_recording_write(struct iwl_mvm *mvm,
1220 char *buf, size_t count,
1223 struct iwl_trans *trans = mvm->trans;
1224 const struct iwl_fw_dbg_dest_tlv_v1 *dest = trans->dbg_dest_tlv;
1225 struct iwl_continuous_record_cmd cont_rec = {};
1228 if (!iwl_mvm_firmware_running(mvm))
1234 if (dest->monitor_mode != SMEM_MODE ||
1235 trans->cfg->device_family < IWL_DEVICE_FAMILY_8000)
1238 ret = kstrtoint(buf, 0, &rec_mode);
1242 cont_rec.record_mode.enable_recording = rec_mode ?
1243 cpu_to_le16(ENABLE_CONT_RECORDING) :
1244 cpu_to_le16(DISABLE_CONT_RECORDING);
1246 mutex_lock(&mvm->mutex);
1247 ret = iwl_mvm_send_cmd_pdu(mvm, LDBG_CONFIG_CMD, 0,
1248 sizeof(cont_rec), &cont_rec);
1249 mutex_unlock(&mvm->mutex);
1251 return ret ?: count;
1254 static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
1255 char *buf, size_t count,
1258 unsigned int conf_id;
1261 if (!iwl_mvm_firmware_running(mvm))
1264 ret = kstrtouint(buf, 0, &conf_id);
1268 if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
1271 mutex_lock(&mvm->mutex);
1272 ret = iwl_fw_start_dbg_conf(&mvm->fwrt, conf_id);
1273 mutex_unlock(&mvm->mutex);
1275 return ret ?: count;
1278 static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
1279 char *buf, size_t count,
1284 if (!iwl_mvm_firmware_running(mvm))
1287 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1293 iwl_fw_dbg_collect(&mvm->fwrt, FW_DBG_TRIGGER_USER, buf,
1296 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
1301 static ssize_t iwl_dbgfs_max_amsdu_len_write(struct iwl_mvm *mvm,
1302 char *buf, size_t count,
1305 unsigned int max_amsdu_len;
1308 ret = kstrtouint(buf, 0, &max_amsdu_len);
1312 if (max_amsdu_len > IEEE80211_MAX_MPDU_LEN_VHT_11454)
1314 mvm->max_amsdu_len = max_amsdu_len;
1319 #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
1320 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1321 static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
1322 char __user *user_buf,
1323 size_t count, loff_t *ppos)
1325 struct iwl_mvm *mvm = file->private_data;
1326 struct iwl_bcast_filter_cmd cmd;
1327 const struct iwl_fw_bcast_filter *filter;
1333 buf = kzalloc(bufsz, GFP_KERNEL);
1337 mutex_lock(&mvm->mutex);
1338 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1340 mutex_unlock(&mvm->mutex);
1343 mutex_unlock(&mvm->mutex);
1345 for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
1346 filter = &cmd.filters[i];
1348 ADD_TEXT("Filter [%d]:\n", i);
1349 ADD_TEXT("\tDiscard=%d\n", filter->discard);
1350 ADD_TEXT("\tFrame Type: %s\n",
1351 filter->frame_type ? "IPv4" : "Generic");
1353 for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
1354 const struct iwl_fw_bcast_filter_attr *attr;
1356 attr = &filter->attrs[j];
1360 ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
1362 attr->offset_type ? "IP End" :
1364 be32_to_cpu(attr->mask),
1365 be32_to_cpu(attr->val),
1366 le16_to_cpu(attr->reserved1));
1370 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1375 static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
1376 size_t count, loff_t *ppos)
1379 struct iwl_fw_bcast_filter filter = {};
1380 struct iwl_bcast_filter_cmd cmd;
1381 u32 filter_id, attr_id, mask, value;
1384 if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
1385 &filter.frame_type, &pos) != 3)
1388 if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
1389 filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
1392 for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
1394 struct iwl_fw_bcast_filter_attr *attr =
1395 &filter.attrs[attr_id];
1400 if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
1401 &attr->offset, &attr->offset_type,
1402 &mask, &value, &next_pos) != 4)
1405 attr->mask = cpu_to_be32(mask);
1406 attr->val = cpu_to_be32(value);
1413 mutex_lock(&mvm->mutex);
1414 memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
1415 &filter, sizeof(filter));
1417 /* send updated bcast filtering configuration */
1418 if (iwl_mvm_firmware_running(mvm) &&
1419 mvm->dbgfs_bcast_filtering.override &&
1420 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
1421 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
1423 mutex_unlock(&mvm->mutex);
1425 return err ?: count;
1428 static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
1429 char __user *user_buf,
1430 size_t count, loff_t *ppos)
1432 struct iwl_mvm *mvm = file->private_data;
1433 struct iwl_bcast_filter_cmd cmd;
1439 buf = kzalloc(bufsz, GFP_KERNEL);
1443 mutex_lock(&mvm->mutex);
1444 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1446 mutex_unlock(&mvm->mutex);
1449 mutex_unlock(&mvm->mutex);
1451 for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
1452 const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
1454 ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
1455 i, mac->default_discard, mac->attached_filters);
1458 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1463 static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
1464 char *buf, size_t count,
1467 struct iwl_bcast_filter_cmd cmd;
1468 struct iwl_fw_bcast_mac mac = {};
1469 u32 mac_id, attached_filters;
1472 if (!mvm->bcast_filters)
1475 if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
1476 &attached_filters) != 3)
1479 if (mac_id >= ARRAY_SIZE(cmd.macs) ||
1480 mac.default_discard > 1 ||
1481 attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
1484 mac.attached_filters = cpu_to_le16(attached_filters);
1486 mutex_lock(&mvm->mutex);
1487 memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
1490 /* send updated bcast filtering configuration */
1491 if (iwl_mvm_firmware_running(mvm) &&
1492 mvm->dbgfs_bcast_filtering.override &&
1493 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
1494 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
1496 mutex_unlock(&mvm->mutex);
1498 return err ?: count;
1502 #ifdef CONFIG_PM_SLEEP
1503 static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
1504 size_t count, loff_t *ppos)
1508 if (sscanf(buf, "%d", &store) != 1)
1511 mvm->store_d3_resume_sram = store;
1516 static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
1517 size_t count, loff_t *ppos)
1519 struct iwl_mvm *mvm = file->private_data;
1520 const struct fw_img *img;
1521 int ofs, len, pos = 0;
1524 u8 *ptr = mvm->d3_resume_sram;
1526 img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1527 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1529 bufsz = len * 4 + 256;
1530 buf = kzalloc(bufsz, GFP_KERNEL);
1534 pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
1535 mvm->store_d3_resume_sram ? "en" : "dis");
1538 for (ofs = 0; ofs < len; ofs += 16) {
1539 pos += scnprintf(buf + pos, bufsz - pos,
1540 "0x%.4x %16ph\n", ofs, ptr + ofs);
1543 pos += scnprintf(buf + pos, bufsz - pos,
1544 "(no data captured)\n");
1547 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1555 #define PRINT_MVM_REF(ref) do { \
1556 if (mvm->refs[ref]) \
1557 pos += scnprintf(buf + pos, bufsz - pos, \
1558 "\t(0x%lx): %d %s\n", \
1559 BIT(ref), mvm->refs[ref], #ref); \
1562 static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
1563 char __user *user_buf,
1564 size_t count, loff_t *ppos)
1566 struct iwl_mvm *mvm = file->private_data;
1569 const size_t bufsz = sizeof(buf);
1572 for (i = 0; i < IWL_MVM_REF_COUNT; i++)
1576 pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
1579 PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
1580 PRINT_MVM_REF(IWL_MVM_REF_SCAN);
1581 PRINT_MVM_REF(IWL_MVM_REF_ROC);
1582 PRINT_MVM_REF(IWL_MVM_REF_ROC_AUX);
1583 PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
1584 PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
1585 PRINT_MVM_REF(IWL_MVM_REF_USER);
1586 PRINT_MVM_REF(IWL_MVM_REF_TX);
1587 PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
1588 PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
1589 PRINT_MVM_REF(IWL_MVM_REF_START_AP);
1590 PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
1591 PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
1592 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
1593 PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
1594 PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
1595 PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
1596 PRINT_MVM_REF(IWL_MVM_REF_NMI);
1597 PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
1598 PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
1599 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA);
1600 PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT);
1601 PRINT_MVM_REF(IWL_MVM_REF_INIT_UCODE);
1602 PRINT_MVM_REF(IWL_MVM_REF_SENDING_CMD);
1603 PRINT_MVM_REF(IWL_MVM_REF_RX);
1605 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1608 static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
1609 size_t count, loff_t *ppos)
1611 unsigned long value;
1615 ret = kstrtoul(buf, 10, &value);
1619 mutex_lock(&mvm->mutex);
1621 taken = mvm->refs[IWL_MVM_REF_USER];
1622 if (value == 1 && !taken)
1623 iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
1624 else if (value == 0 && taken)
1625 iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
1629 mutex_unlock(&mvm->mutex);
1636 #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1637 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1638 #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1639 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1640 #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1641 if (!debugfs_create_file(alias, mode, parent, mvm, \
1642 &iwl_dbgfs_##name##_ops)) \
1645 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1646 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
1648 #define MVM_DEBUGFS_WRITE_STA_FILE_OPS(name, bufsz) \
1649 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1650 #define MVM_DEBUGFS_READ_WRITE_STA_FILE_OPS(name, bufsz) \
1651 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1653 #define MVM_DEBUGFS_ADD_STA_FILE_ALIAS(alias, name, parent, mode) do { \
1654 if (!debugfs_create_file(alias, mode, parent, sta, \
1655 &iwl_dbgfs_##name##_ops)) \
1658 #define MVM_DEBUGFS_ADD_STA_FILE(name, parent, mode) \
1659 MVM_DEBUGFS_ADD_STA_FILE_ALIAS(#name, name, parent, mode)
1662 iwl_dbgfs_prph_reg_read(struct file *file,
1663 char __user *user_buf,
1664 size_t count, loff_t *ppos)
1666 struct iwl_mvm *mvm = file->private_data;
1669 const size_t bufsz = sizeof(buf);
1672 if (!mvm->dbgfs_prph_reg_addr)
1675 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
1679 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1680 mvm->dbgfs_prph_reg_addr,
1681 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1683 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
1685 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1689 iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1690 size_t count, loff_t *ppos)
1696 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1697 /* if we only want to set the reg address - nothing more to do */
1701 /* otherwise, make sure we have both address and value */
1705 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1709 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
1711 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
1717 iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1718 size_t count, loff_t *ppos)
1722 if (!iwl_mvm_firmware_running(mvm))
1725 mutex_lock(&mvm->mutex);
1726 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
1727 mutex_unlock(&mvm->mutex);
1729 return ret ?: count;
1732 MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1734 /* Device wide debugfs entries */
1735 MVM_DEBUGFS_READ_FILE_OPS(ctdp_budget);
1736 MVM_DEBUGFS_WRITE_FILE_OPS(stop_ctdp, 8);
1737 MVM_DEBUGFS_WRITE_FILE_OPS(force_ctkill, 8);
1738 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1739 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
1740 MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
1741 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
1742 MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
1743 MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
1744 MVM_DEBUGFS_READ_FILE_OPS(stations);
1745 MVM_DEBUGFS_READ_FILE_OPS(rs_data);
1746 MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
1747 MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
1748 MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
1749 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
1750 MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
1751 MVM_DEBUGFS_READ_FILE_OPS(fw_ver);
1752 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1753 MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
1754 MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
1755 MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
1756 MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
1757 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
1758 MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
1759 MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64);
1760 MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8);
1761 MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8);
1762 MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1763 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
1764 MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512);
1766 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1767 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
1768 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
1771 #ifdef CONFIG_PM_SLEEP
1772 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
1775 MVM_DEBUGFS_READ_FILE_OPS(sar_geo_profile);
1778 static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
1779 size_t count, loff_t *ppos)
1781 struct iwl_mvm *mvm = file->private_data;
1782 struct iwl_dbg_mem_access_cmd cmd = {};
1783 struct iwl_dbg_mem_access_rsp *rsp;
1784 struct iwl_host_cmd hcmd = {
1785 .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1787 .len = { sizeof(cmd) },
1792 if (!iwl_mvm_firmware_running(mvm))
1795 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1797 cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
1799 /* Take care of alignment of both the position and the length */
1800 delta = *ppos & 0x3;
1801 cmd.addr = cpu_to_le32(*ppos - delta);
1802 cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
1803 (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
1805 mutex_lock(&mvm->mutex);
1806 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1807 mutex_unlock(&mvm->mutex);
1812 rsp = (void *)hcmd.resp_pkt->data;
1813 if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) {
1818 len = min((size_t)le32_to_cpu(rsp->len) << 2,
1819 iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp));
1820 len = min(len - delta, count);
1826 ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len);
1830 iwl_free_resp(&hcmd);
1834 static ssize_t iwl_dbgfs_mem_write(struct file *file,
1835 const char __user *user_buf, size_t count,
1838 struct iwl_mvm *mvm = file->private_data;
1839 struct iwl_dbg_mem_access_cmd *cmd;
1840 struct iwl_dbg_mem_access_rsp *rsp;
1841 struct iwl_host_cmd hcmd = {};
1847 if (!iwl_mvm_firmware_running(mvm))
1850 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1853 if (*ppos & 0x3 || count < 4) {
1854 op = DEBUG_MEM_OP_WRITE_BYTES;
1855 len = min(count, (size_t)(4 - (*ppos & 0x3)));
1858 op = DEBUG_MEM_OP_WRITE;
1859 len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS);
1860 data_size = len << 2;
1863 cmd_size = sizeof(*cmd) + ALIGN(data_size, 4);
1864 cmd = kzalloc(cmd_size, GFP_KERNEL);
1868 cmd->op = cpu_to_le32(op);
1869 cmd->len = cpu_to_le32(len);
1870 cmd->addr = cpu_to_le32(*ppos);
1871 if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
1876 hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1877 hcmd.data[0] = (void *)cmd;
1878 hcmd.len[0] = cmd_size;
1880 mutex_lock(&mvm->mutex);
1881 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1882 mutex_unlock(&mvm->mutex);
1889 rsp = (void *)hcmd.resp_pkt->data;
1890 if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) {
1899 iwl_free_resp(&hcmd);
1903 static const struct file_operations iwl_dbgfs_mem_ops = {
1904 .read = iwl_dbgfs_mem_read,
1905 .write = iwl_dbgfs_mem_write,
1906 .open = simple_open,
1907 .llseek = default_llseek,
1910 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
1911 struct ieee80211_vif *vif,
1912 struct ieee80211_sta *sta,
1915 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1917 if (iwl_mvm_has_tlc_offload(mvm))
1918 MVM_DEBUGFS_ADD_STA_FILE(rs_data, dir, S_IRUSR);
1922 IWL_ERR(mvm, "Can't create the mvm station debugfs entry\n");
1925 int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1927 struct dentry *bcast_dir __maybe_unused;
1930 spin_lock_init(&mvm->drv_stats_lock);
1932 mvm->debugfs_dir = dbgfs_dir;
1934 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
1935 MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
1936 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
1937 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir,
1939 MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR);
1940 MVM_DEBUGFS_ADD_FILE(ctdp_budget, dbgfs_dir, S_IRUSR);
1941 MVM_DEBUGFS_ADD_FILE(stop_ctdp, dbgfs_dir, S_IWUSR);
1942 MVM_DEBUGFS_ADD_FILE(force_ctkill, dbgfs_dir, S_IWUSR);
1943 MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
1944 MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
1945 MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR);
1946 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir,
1948 MVM_DEBUGFS_ADD_FILE(fw_ver, mvm->debugfs_dir, S_IRUSR);
1949 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR);
1950 MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR);
1951 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
1952 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
1953 MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR);
1954 MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR);
1955 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
1957 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
1958 MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
1959 MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
1960 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, S_IWUSR);
1961 MVM_DEBUGFS_ADD_FILE(max_amsdu_len, mvm->debugfs_dir, S_IWUSR);
1962 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR);
1963 MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR);
1964 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR);
1965 MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, S_IWUSR);
1967 MVM_DEBUGFS_ADD_FILE(sar_geo_profile, dbgfs_dir, S_IRUSR);
1970 if (!debugfs_create_bool("enable_scan_iteration_notif",
1973 &mvm->scan_iter_notif_enabled))
1975 if (!debugfs_create_bool("drop_bcn_ap_mode", S_IRUSR | S_IWUSR,
1976 mvm->debugfs_dir, &mvm->drop_bcn_ap_mode))
1979 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1980 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
1981 bcast_dir = debugfs_create_dir("bcast_filtering",
1986 if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR,
1988 &mvm->dbgfs_bcast_filtering.override))
1991 MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
1992 bcast_dir, S_IWUSR | S_IRUSR);
1993 MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
1994 bcast_dir, S_IWUSR | S_IRUSR);
1998 #ifdef CONFIG_PM_SLEEP
1999 MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
2000 MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
2001 if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
2002 mvm->debugfs_dir, &mvm->d3_wake_sysassert))
2004 if (!debugfs_create_u32("last_netdetect_scans", S_IRUSR,
2005 mvm->debugfs_dir, &mvm->last_netdetect_scans))
2009 if (!debugfs_create_u8("ps_disabled", S_IRUSR,
2010 mvm->debugfs_dir, &mvm->ps_disabled))
2012 if (!debugfs_create_blob("nvm_hw", S_IRUSR,
2013 mvm->debugfs_dir, &mvm->nvm_hw_blob))
2015 if (!debugfs_create_blob("nvm_sw", S_IRUSR,
2016 mvm->debugfs_dir, &mvm->nvm_sw_blob))
2018 if (!debugfs_create_blob("nvm_calib", S_IRUSR,
2019 mvm->debugfs_dir, &mvm->nvm_calib_blob))
2021 if (!debugfs_create_blob("nvm_prod", S_IRUSR,
2022 mvm->debugfs_dir, &mvm->nvm_prod_blob))
2024 if (!debugfs_create_blob("nvm_phy_sku", S_IRUSR,
2025 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
2028 debugfs_create_file("mem", S_IRUSR | S_IWUSR, dbgfs_dir, mvm,
2029 &iwl_dbgfs_mem_ops);
2032 * Create a symlink with mac80211. It will be removed when mac80211
2033 * exists (before the opmode exists which removes the target.)
2035 snprintf(buf, 100, "../../%pd2", dbgfs_dir->d_parent);
2036 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
2041 IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");