1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
7 #include <linux/vmalloc.h>
9 #include <linux/ieee80211.h>
10 #include <linux/netdevice.h>
16 #include "iwl-modparams.h"
17 #include "fw/error-dump.h"
19 static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
20 char __user *user_buf,
21 size_t count, loff_t *ppos)
23 struct iwl_mvm *mvm = file->private_data;
27 if (!iwl_mvm_is_ctdp_supported(mvm))
30 if (!iwl_mvm_firmware_running(mvm) ||
31 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
34 mutex_lock(&mvm->mutex);
35 budget = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_REPORT, 0);
36 mutex_unlock(&mvm->mutex);
41 pos = scnprintf(buf, sizeof(buf), "%d\n", budget);
43 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
46 static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
47 size_t count, loff_t *ppos)
51 if (!iwl_mvm_is_ctdp_supported(mvm))
54 if (!iwl_mvm_firmware_running(mvm) ||
55 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
58 mutex_lock(&mvm->mutex);
59 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_STOP, 0);
60 mutex_unlock(&mvm->mutex);
65 static ssize_t iwl_dbgfs_force_ctkill_write(struct iwl_mvm *mvm, char *buf,
66 size_t count, loff_t *ppos)
68 if (!iwl_mvm_firmware_running(mvm) ||
69 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
72 iwl_mvm_enter_ctkill(mvm);
77 static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
78 size_t count, loff_t *ppos)
83 if (!iwl_mvm_firmware_running(mvm) ||
84 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
87 if (kstrtou32(buf, 0, &flush_arg))
90 if (iwl_mvm_has_new_tx_api(mvm)) {
91 IWL_DEBUG_TX_QUEUES(mvm,
92 "FLUSHING all tids queues on sta_id = %d\n",
94 mutex_lock(&mvm->mutex);
95 ret = iwl_mvm_flush_sta_tids(mvm, flush_arg, 0xFFFF)
97 mutex_unlock(&mvm->mutex);
101 IWL_DEBUG_TX_QUEUES(mvm, "FLUSHING queues mask to flush = 0x%x\n",
104 mutex_lock(&mvm->mutex);
105 ret = iwl_mvm_flush_tx_path(mvm, flush_arg) ? : count;
106 mutex_unlock(&mvm->mutex);
111 static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
112 size_t count, loff_t *ppos)
114 struct iwl_mvm_sta *mvmsta;
115 int sta_id, drain, ret;
117 if (!iwl_mvm_firmware_running(mvm) ||
118 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
121 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
123 if (sta_id < 0 || sta_id >= mvm->fw->ucode_capa.num_stations)
125 if (drain < 0 || drain > 1)
128 mutex_lock(&mvm->mutex);
130 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
135 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
137 mutex_unlock(&mvm->mutex);
142 static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
143 size_t count, loff_t *ppos)
145 struct iwl_mvm *mvm = file->private_data;
146 const struct fw_img *img;
147 unsigned int ofs, len;
151 if (!iwl_mvm_firmware_running(mvm))
154 /* default is to dump the entire data segment */
155 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
156 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
157 len = img->sec[IWL_UCODE_SECTION_DATA].len;
159 if (mvm->dbgfs_sram_len) {
160 ofs = mvm->dbgfs_sram_offset;
161 len = mvm->dbgfs_sram_len;
164 ptr = kzalloc(len, GFP_KERNEL);
168 iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
170 ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
177 static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
178 size_t count, loff_t *ppos)
180 const struct fw_img *img;
182 u32 img_offset, img_len;
184 if (!iwl_mvm_firmware_running(mvm))
187 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
188 img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
189 img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
191 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
192 if ((offset & 0x3) || (len & 0x3))
195 if (offset + len > img_offset + img_len)
198 mvm->dbgfs_sram_offset = offset;
199 mvm->dbgfs_sram_len = len;
201 mvm->dbgfs_sram_offset = 0;
202 mvm->dbgfs_sram_len = 0;
208 static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
209 char __user *user_buf,
210 size_t count, loff_t *ppos)
212 struct iwl_mvm *mvm = file->private_data;
216 if (!mvm->temperature_test)
217 pos = scnprintf(buf , sizeof(buf), "disabled\n");
219 pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
221 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
225 * Set NIC Temperature
226 * Cause the driver to ignore the actual NIC temperature reported by the FW
227 * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
228 * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
229 * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
231 static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
232 char *buf, size_t count,
237 if (!iwl_mvm_firmware_running(mvm) && !mvm->temperature_test)
240 if (kstrtoint(buf, 10, &temperature))
242 /* not a legal temperature */
243 if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
244 temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
245 temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
248 mutex_lock(&mvm->mutex);
249 if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
250 if (!mvm->temperature_test)
253 mvm->temperature_test = false;
254 /* Since we can't read the temp while awake, just set
255 * it to zero until we get the next RX stats from the
258 mvm->temperature = 0;
260 mvm->temperature_test = true;
261 mvm->temperature = temperature;
263 IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
264 mvm->temperature_test ? "En" : "Dis" ,
266 /* handle the temperature change */
267 iwl_mvm_tt_handler(mvm);
270 mutex_unlock(&mvm->mutex);
275 static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
276 char __user *user_buf,
277 size_t count, loff_t *ppos)
279 struct iwl_mvm *mvm = file->private_data;
284 if (!iwl_mvm_firmware_running(mvm))
287 mutex_lock(&mvm->mutex);
288 ret = iwl_mvm_get_temp(mvm, &temp);
289 mutex_unlock(&mvm->mutex);
294 pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
296 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
300 static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file,
301 char __user *user_buf,
302 size_t count, loff_t *ppos)
304 struct iwl_mvm *mvm = file->private_data;
307 int bufsz = sizeof(buf);
310 if (!iwl_mvm_firmware_running(mvm))
313 mutex_lock(&mvm->mutex);
314 tbl_idx = iwl_mvm_get_sar_geo_profile(mvm);
316 mutex_unlock(&mvm->mutex);
321 pos = scnprintf(buf, bufsz,
322 "SAR geographic profile disabled\n");
324 pos += scnprintf(buf + pos, bufsz - pos,
325 "Use geographic profile %d\n", tbl_idx);
326 pos += scnprintf(buf + pos, bufsz - pos,
327 "2.4GHz:\n\tChain A offset: %hhu dBm\n\tChain B offset: %hhu dBm\n\tmax tx power: %hhu dBm\n",
328 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[0].chains[0],
329 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[0].chains[1],
330 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[0].max);
331 pos += scnprintf(buf + pos, bufsz - pos,
332 "5.2GHz:\n\tChain A offset: %hhu dBm\n\tChain B offset: %hhu dBm\n\tmax tx power: %hhu dBm\n",
333 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[1].chains[0],
334 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[1].chains[1],
335 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[1].max);
337 mutex_unlock(&mvm->mutex);
339 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
343 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
344 size_t count, loff_t *ppos)
346 struct iwl_mvm *mvm = file->private_data;
347 struct ieee80211_sta *sta;
349 int i, pos = 0, bufsz = sizeof(buf);
351 mutex_lock(&mvm->mutex);
353 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
354 pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
355 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
356 lockdep_is_held(&mvm->mutex));
358 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
359 else if (IS_ERR(sta))
360 pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
363 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
367 mutex_unlock(&mvm->mutex);
369 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
372 static ssize_t iwl_dbgfs_rs_data_read(struct file *file, char __user *user_buf,
373 size_t count, loff_t *ppos)
375 struct ieee80211_sta *sta = file->private_data;
376 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
377 struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->lq_sta.rs_fw;
378 struct iwl_mvm *mvm = lq_sta->pers.drv;
379 static const size_t bufsz = 2048;
384 buff = kmalloc(bufsz, GFP_KERNEL);
388 mutex_lock(&mvm->mutex);
390 desc += scnprintf(buff + desc, bufsz - desc, "sta_id %d\n",
391 lq_sta->pers.sta_id);
392 desc += scnprintf(buff + desc, bufsz - desc,
394 lq_sta->pers.dbg_fixed_rate);
395 desc += scnprintf(buff + desc, bufsz - desc,
396 "A-MPDU size limit %d\n",
397 lq_sta->pers.dbg_agg_frame_count_lim);
398 desc += scnprintf(buff + desc, bufsz - desc,
399 "valid_tx_ant %s%s\n",
400 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_A) ? "ANT_A," : "",
401 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_B) ? "ANT_B," : "");
402 desc += scnprintf(buff + desc, bufsz - desc,
403 "last tx rate=0x%X ",
404 lq_sta->last_rate_n_flags);
406 desc += rs_pretty_print_rate(buff + desc, bufsz - desc,
407 lq_sta->last_rate_n_flags);
408 if (desc < bufsz - 1)
410 mutex_unlock(&mvm->mutex);
412 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
417 static ssize_t iwl_dbgfs_amsdu_len_write(struct ieee80211_sta *sta,
418 char *buf, size_t count,
421 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
425 if (kstrtou16(buf, 0, &amsdu_len))
428 /* only change from debug set <-> debug unset */
429 if ((amsdu_len && mvmsta->orig_amsdu_len) ||
430 (!!amsdu_len && mvmsta->orig_amsdu_len))
434 mvmsta->orig_amsdu_len = sta->max_amsdu_len;
435 sta->max_amsdu_len = amsdu_len;
436 for (i = 0; i < ARRAY_SIZE(sta->max_tid_amsdu_len); i++)
437 sta->max_tid_amsdu_len[i] = amsdu_len;
439 sta->max_amsdu_len = mvmsta->orig_amsdu_len;
440 mvmsta->orig_amsdu_len = 0;
445 static ssize_t iwl_dbgfs_amsdu_len_read(struct file *file,
446 char __user *user_buf,
447 size_t count, loff_t *ppos)
449 struct ieee80211_sta *sta = file->private_data;
450 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
455 pos = scnprintf(buf, sizeof(buf), "current %d ", sta->max_amsdu_len);
456 pos += scnprintf(buf + pos, sizeof(buf) - pos, "stored %d\n",
457 mvmsta->orig_amsdu_len);
459 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
462 static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
463 char __user *user_buf,
464 size_t count, loff_t *ppos)
466 struct iwl_mvm *mvm = file->private_data;
468 int bufsz = sizeof(buf);
471 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
472 mvm->disable_power_off);
473 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
474 mvm->disable_power_off_d3);
476 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
479 static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
480 size_t count, loff_t *ppos)
484 if (!iwl_mvm_firmware_running(mvm))
487 if (!strncmp("disable_power_off_d0=", buf, 21)) {
488 if (sscanf(buf + 21, "%d", &val) != 1)
490 mvm->disable_power_off = val;
491 } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
492 if (sscanf(buf + 21, "%d", &val) != 1)
494 mvm->disable_power_off_d3 = val;
499 mutex_lock(&mvm->mutex);
500 ret = iwl_mvm_power_update_device(mvm);
501 mutex_unlock(&mvm->mutex);
507 int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
510 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
512 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
513 BT_MBOX_PRINT(0, LE_PROF1, false);
514 BT_MBOX_PRINT(0, LE_PROF2, false);
515 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
516 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
517 BT_MBOX_PRINT(0, INBAND_S, false);
518 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
519 BT_MBOX_PRINT(0, LE_SCAN, false);
520 BT_MBOX_PRINT(0, LE_ADV, false);
521 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
522 BT_MBOX_PRINT(0, OPEN_CON_1, true);
524 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
526 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
527 BT_MBOX_PRINT(1, IP_SR, false);
528 BT_MBOX_PRINT(1, LE_MSTR, false);
529 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
530 BT_MBOX_PRINT(1, MSG_TYPE, false);
531 BT_MBOX_PRINT(1, SSN, true);
533 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
535 BT_MBOX_PRINT(2, SNIFF_ACT, false);
536 BT_MBOX_PRINT(2, PAG, false);
537 BT_MBOX_PRINT(2, INQUIRY, false);
538 BT_MBOX_PRINT(2, CONN, false);
539 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
540 BT_MBOX_PRINT(2, DISC, false);
541 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
542 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
543 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
544 BT_MBOX_PRINT(2, SCO_DURATION, true);
546 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
548 BT_MBOX_PRINT(3, SCO_STATE, false);
549 BT_MBOX_PRINT(3, SNIFF_STATE, false);
550 BT_MBOX_PRINT(3, A2DP_STATE, false);
551 BT_MBOX_PRINT(3, A2DP_SRC, false);
552 BT_MBOX_PRINT(3, ACL_STATE, false);
553 BT_MBOX_PRINT(3, MSTR_STATE, false);
554 BT_MBOX_PRINT(3, OBX_STATE, false);
555 BT_MBOX_PRINT(3, OPEN_CON_2, false);
556 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
557 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
558 BT_MBOX_PRINT(3, INBAND_P, false);
559 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
560 BT_MBOX_PRINT(3, SSN_2, false);
561 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
566 static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
567 size_t count, loff_t *ppos)
569 struct iwl_mvm *mvm = file->private_data;
570 struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
572 int ret, pos = 0, bufsz = sizeof(char) * 1024;
574 buf = kmalloc(bufsz, GFP_KERNEL);
578 mutex_lock(&mvm->mutex);
580 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
582 pos += scnprintf(buf + pos, bufsz - pos, "bt_ci_compliance = %d\n",
583 notif->bt_ci_compliance);
584 pos += scnprintf(buf + pos, bufsz - pos, "primary_ch_lut = %d\n",
585 le32_to_cpu(notif->primary_ch_lut));
586 pos += scnprintf(buf + pos, bufsz - pos, "secondary_ch_lut = %d\n",
587 le32_to_cpu(notif->secondary_ch_lut));
588 pos += scnprintf(buf + pos,
589 bufsz - pos, "bt_activity_grading = %d\n",
590 le32_to_cpu(notif->bt_activity_grading));
591 pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n",
592 notif->rrc_status & 0xF);
593 pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n",
594 notif->ttc_status & 0xF);
596 pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n",
597 IWL_MVM_BT_COEX_SYNC2SCO);
598 pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n",
599 IWL_MVM_BT_COEX_MPLUT);
601 mutex_unlock(&mvm->mutex);
603 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
610 static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
611 size_t count, loff_t *ppos)
613 struct iwl_mvm *mvm = file->private_data;
614 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
616 int bufsz = sizeof(buf);
619 mutex_lock(&mvm->mutex);
621 pos += scnprintf(buf + pos, bufsz - pos, "Channel inhibition CMD\n");
622 pos += scnprintf(buf + pos, bufsz - pos,
623 "\tPrimary Channel Bitmap 0x%016llx\n",
624 le64_to_cpu(cmd->bt_primary_ci));
625 pos += scnprintf(buf + pos, bufsz - pos,
626 "\tSecondary Channel Bitmap 0x%016llx\n",
627 le64_to_cpu(cmd->bt_secondary_ci));
629 mutex_unlock(&mvm->mutex);
631 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
635 iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
636 size_t count, loff_t *ppos)
640 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
645 mvm->bt_tx_prio = bt_tx_prio;
651 iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
652 size_t count, loff_t *ppos)
654 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
655 [BT_FORCE_ANT_DIS] = "dis",
656 [BT_FORCE_ANT_AUTO] = "auto",
657 [BT_FORCE_ANT_BT] = "bt",
658 [BT_FORCE_ANT_WIFI] = "wifi",
660 int ret, bt_force_ant_mode;
662 ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf);
666 bt_force_ant_mode = ret;
668 mutex_lock(&mvm->mutex);
669 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
672 mvm->bt_force_ant_mode = bt_force_ant_mode;
673 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
674 modes_str[mvm->bt_force_ant_mode]);
676 if (iwl_mvm_firmware_running(mvm))
677 ret = iwl_mvm_send_bt_init_conf(mvm);
682 mutex_unlock(&mvm->mutex);
686 static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
687 size_t count, loff_t *ppos)
689 struct iwl_mvm *mvm = file->private_data;
690 char *buff, *pos, *endpos;
691 static const size_t bufsz = 1024;
694 buff = kmalloc(bufsz, GFP_KERNEL);
699 endpos = pos + bufsz;
701 pos += scnprintf(pos, endpos - pos, "FW prefix: %s\n",
702 mvm->trans->cfg->fw_name_pre);
703 pos += scnprintf(pos, endpos - pos, "FW: %s\n",
704 mvm->fwrt.fw->human_readable);
705 pos += scnprintf(pos, endpos - pos, "Device: %s\n",
706 mvm->fwrt.trans->name);
707 pos += scnprintf(pos, endpos - pos, "Bus: %s\n",
708 mvm->fwrt.dev->bus->name);
710 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
716 static ssize_t iwl_dbgfs_phy_integration_ver_read(struct file *file,
717 char __user *user_buf,
718 size_t count, loff_t *ppos)
720 struct iwl_mvm *mvm = file->private_data;
726 bufsz = mvm->fw->phy_integration_ver_len + 2;
727 buf = kmalloc(bufsz, GFP_KERNEL);
731 pos = scnprintf(buf, bufsz, "%.*s\n", mvm->fw->phy_integration_ver_len,
732 mvm->fw->phy_integration_ver);
734 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
740 #define PRINT_STATS_LE32(_struct, _memb) \
741 pos += scnprintf(buf + pos, bufsz - pos, \
743 le32_to_cpu(_struct->_memb))
745 static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
746 char __user *user_buf, size_t count,
749 struct iwl_mvm *mvm = file->private_data;
750 static const char *fmt_table = "\t%-30s %10u\n";
751 static const char *fmt_header = "%-32s\n";
757 if (iwl_mvm_has_new_rx_stats_api(mvm))
758 bufsz = ((sizeof(struct mvm_statistics_rx) /
759 sizeof(__le32)) * 43) + (4 * 33) + 1;
761 /* 43 = size of each data line; 33 = size of each header */
762 bufsz = ((sizeof(struct mvm_statistics_rx_v3) /
763 sizeof(__le32)) * 43) + (4 * 33) + 1;
765 buf = kzalloc(bufsz, GFP_KERNEL);
769 mutex_lock(&mvm->mutex);
771 if (iwl_mvm_firmware_running(mvm))
772 iwl_mvm_request_statistics(mvm, false);
774 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
775 "Statistics_Rx - OFDM");
776 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
777 struct mvm_statistics_rx_phy_v2 *ofdm = &mvm->rx_stats_v3.ofdm;
779 PRINT_STATS_LE32(ofdm, ina_cnt);
780 PRINT_STATS_LE32(ofdm, fina_cnt);
781 PRINT_STATS_LE32(ofdm, plcp_err);
782 PRINT_STATS_LE32(ofdm, crc32_err);
783 PRINT_STATS_LE32(ofdm, overrun_err);
784 PRINT_STATS_LE32(ofdm, early_overrun_err);
785 PRINT_STATS_LE32(ofdm, crc32_good);
786 PRINT_STATS_LE32(ofdm, false_alarm_cnt);
787 PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
788 PRINT_STATS_LE32(ofdm, sfd_timeout);
789 PRINT_STATS_LE32(ofdm, fina_timeout);
790 PRINT_STATS_LE32(ofdm, unresponded_rts);
791 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
792 PRINT_STATS_LE32(ofdm, sent_ack_cnt);
793 PRINT_STATS_LE32(ofdm, sent_cts_cnt);
794 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
795 PRINT_STATS_LE32(ofdm, dsp_self_kill);
796 PRINT_STATS_LE32(ofdm, mh_format_err);
797 PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
798 PRINT_STATS_LE32(ofdm, reserved);
800 struct mvm_statistics_rx_phy *ofdm = &mvm->rx_stats.ofdm;
802 PRINT_STATS_LE32(ofdm, unresponded_rts);
803 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
804 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
805 PRINT_STATS_LE32(ofdm, dsp_self_kill);
806 PRINT_STATS_LE32(ofdm, reserved);
809 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
810 "Statistics_Rx - CCK");
811 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
812 struct mvm_statistics_rx_phy_v2 *cck = &mvm->rx_stats_v3.cck;
814 PRINT_STATS_LE32(cck, ina_cnt);
815 PRINT_STATS_LE32(cck, fina_cnt);
816 PRINT_STATS_LE32(cck, plcp_err);
817 PRINT_STATS_LE32(cck, crc32_err);
818 PRINT_STATS_LE32(cck, overrun_err);
819 PRINT_STATS_LE32(cck, early_overrun_err);
820 PRINT_STATS_LE32(cck, crc32_good);
821 PRINT_STATS_LE32(cck, false_alarm_cnt);
822 PRINT_STATS_LE32(cck, fina_sync_err_cnt);
823 PRINT_STATS_LE32(cck, sfd_timeout);
824 PRINT_STATS_LE32(cck, fina_timeout);
825 PRINT_STATS_LE32(cck, unresponded_rts);
826 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
827 PRINT_STATS_LE32(cck, sent_ack_cnt);
828 PRINT_STATS_LE32(cck, sent_cts_cnt);
829 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
830 PRINT_STATS_LE32(cck, dsp_self_kill);
831 PRINT_STATS_LE32(cck, mh_format_err);
832 PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
833 PRINT_STATS_LE32(cck, reserved);
835 struct mvm_statistics_rx_phy *cck = &mvm->rx_stats.cck;
837 PRINT_STATS_LE32(cck, unresponded_rts);
838 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
839 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
840 PRINT_STATS_LE32(cck, dsp_self_kill);
841 PRINT_STATS_LE32(cck, reserved);
844 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
845 "Statistics_Rx - GENERAL");
846 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
847 struct mvm_statistics_rx_non_phy_v3 *general =
848 &mvm->rx_stats_v3.general;
850 PRINT_STATS_LE32(general, bogus_cts);
851 PRINT_STATS_LE32(general, bogus_ack);
852 PRINT_STATS_LE32(general, non_bssid_frames);
853 PRINT_STATS_LE32(general, filtered_frames);
854 PRINT_STATS_LE32(general, non_channel_beacons);
855 PRINT_STATS_LE32(general, channel_beacons);
856 PRINT_STATS_LE32(general, num_missed_bcon);
857 PRINT_STATS_LE32(general, adc_rx_saturation_time);
858 PRINT_STATS_LE32(general, ina_detection_search_time);
859 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
860 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
861 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
862 PRINT_STATS_LE32(general, interference_data_flag);
863 PRINT_STATS_LE32(general, channel_load);
864 PRINT_STATS_LE32(general, dsp_false_alarms);
865 PRINT_STATS_LE32(general, beacon_rssi_a);
866 PRINT_STATS_LE32(general, beacon_rssi_b);
867 PRINT_STATS_LE32(general, beacon_rssi_c);
868 PRINT_STATS_LE32(general, beacon_energy_a);
869 PRINT_STATS_LE32(general, beacon_energy_b);
870 PRINT_STATS_LE32(general, beacon_energy_c);
871 PRINT_STATS_LE32(general, num_bt_kills);
872 PRINT_STATS_LE32(general, mac_id);
873 PRINT_STATS_LE32(general, directed_data_mpdu);
875 struct mvm_statistics_rx_non_phy *general =
876 &mvm->rx_stats.general;
878 PRINT_STATS_LE32(general, bogus_cts);
879 PRINT_STATS_LE32(general, bogus_ack);
880 PRINT_STATS_LE32(general, non_channel_beacons);
881 PRINT_STATS_LE32(general, channel_beacons);
882 PRINT_STATS_LE32(general, num_missed_bcon);
883 PRINT_STATS_LE32(general, adc_rx_saturation_time);
884 PRINT_STATS_LE32(general, ina_detection_search_time);
885 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
886 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
887 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
888 PRINT_STATS_LE32(general, interference_data_flag);
889 PRINT_STATS_LE32(general, channel_load);
890 PRINT_STATS_LE32(general, beacon_rssi_a);
891 PRINT_STATS_LE32(general, beacon_rssi_b);
892 PRINT_STATS_LE32(general, beacon_rssi_c);
893 PRINT_STATS_LE32(general, beacon_energy_a);
894 PRINT_STATS_LE32(general, beacon_energy_b);
895 PRINT_STATS_LE32(general, beacon_energy_c);
896 PRINT_STATS_LE32(general, num_bt_kills);
897 PRINT_STATS_LE32(general, mac_id);
900 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
901 "Statistics_Rx - HT");
902 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
903 struct mvm_statistics_rx_ht_phy_v1 *ht =
904 &mvm->rx_stats_v3.ofdm_ht;
906 PRINT_STATS_LE32(ht, plcp_err);
907 PRINT_STATS_LE32(ht, overrun_err);
908 PRINT_STATS_LE32(ht, early_overrun_err);
909 PRINT_STATS_LE32(ht, crc32_good);
910 PRINT_STATS_LE32(ht, crc32_err);
911 PRINT_STATS_LE32(ht, mh_format_err);
912 PRINT_STATS_LE32(ht, agg_crc32_good);
913 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
914 PRINT_STATS_LE32(ht, agg_cnt);
915 PRINT_STATS_LE32(ht, unsupport_mcs);
917 struct mvm_statistics_rx_ht_phy *ht =
918 &mvm->rx_stats.ofdm_ht;
920 PRINT_STATS_LE32(ht, mh_format_err);
921 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
922 PRINT_STATS_LE32(ht, agg_cnt);
923 PRINT_STATS_LE32(ht, unsupport_mcs);
926 mutex_unlock(&mvm->mutex);
928 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
933 #undef PRINT_STAT_LE32
935 static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
936 char __user *user_buf, size_t count,
938 struct iwl_mvm_frame_stats *stats)
940 char *buff, *pos, *endpos;
943 static const size_t bufsz = 1024;
945 buff = kmalloc(bufsz, GFP_KERNEL);
949 spin_lock_bh(&mvm->drv_stats_lock);
952 endpos = pos + bufsz;
954 pos += scnprintf(pos, endpos - pos,
955 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
956 stats->legacy_frames,
959 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
962 stats->bw_80_frames);
963 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
966 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
968 stats->mimo2_frames);
969 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
971 stats->success_frames);
972 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
974 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
976 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
977 stats->ampdu_count > 0 ?
978 (stats->agg_frames / stats->ampdu_count) : 0);
980 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
982 idx = stats->last_frame_idx - 1;
983 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
984 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
985 if (stats->last_rates[idx] == 0)
987 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
988 (int)(ARRAY_SIZE(stats->last_rates) - i));
989 pos += rs_pretty_print_rate_v1(pos, endpos - pos,
990 stats->last_rates[idx]);
991 if (pos < endpos - 1)
994 spin_unlock_bh(&mvm->drv_stats_lock);
996 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
1002 static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
1003 char __user *user_buf, size_t count,
1006 struct iwl_mvm *mvm = file->private_data;
1008 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
1009 &mvm->drv_rx_stats);
1012 static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
1013 size_t count, loff_t *ppos)
1015 int __maybe_unused ret;
1017 if (!iwl_mvm_firmware_running(mvm))
1020 mutex_lock(&mvm->mutex);
1022 /* allow one more restart that we're provoking here */
1023 if (mvm->fw_restart >= 0)
1026 if (count == 6 && !strcmp(buf, "nolog\n")) {
1027 set_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE, &mvm->status);
1028 set_bit(STATUS_SUPPRESS_CMD_ERROR_ONCE, &mvm->trans->status);
1031 /* take the return value to make compiler happy - it will fail anyway */
1032 ret = iwl_mvm_send_cmd_pdu(mvm,
1033 WIDE_ID(LONG_GROUP, REPLY_ERROR),
1036 mutex_unlock(&mvm->mutex);
1041 static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
1042 size_t count, loff_t *ppos)
1044 if (!iwl_mvm_firmware_running(mvm))
1047 if (count == 6 && !strcmp(buf, "nolog\n"))
1048 set_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE, &mvm->status);
1050 iwl_force_nmi(mvm->trans);
1056 iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
1057 char __user *user_buf,
1058 size_t count, loff_t *ppos)
1060 struct iwl_mvm *mvm = file->private_data;
1063 const size_t bufsz = sizeof(buf);
1065 /* print which antennas were set for the scan command by the user */
1066 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
1067 if (mvm->scan_rx_ant & ANT_A)
1068 pos += scnprintf(buf + pos, bufsz - pos, "A");
1069 if (mvm->scan_rx_ant & ANT_B)
1070 pos += scnprintf(buf + pos, bufsz - pos, "B");
1071 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
1073 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1077 iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
1078 size_t count, loff_t *ppos)
1082 if (!iwl_mvm_firmware_running(mvm))
1085 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
1087 if (scan_rx_ant > ANT_ABC)
1089 if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
1092 if (mvm->scan_rx_ant != scan_rx_ant) {
1093 mvm->scan_rx_ant = scan_rx_ant;
1094 if (fw_has_capa(&mvm->fw->ucode_capa,
1095 IWL_UCODE_TLV_CAPA_UMAC_SCAN))
1096 iwl_mvm_config_scan(mvm);
1102 static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
1103 char *buf, size_t count,
1106 struct iwl_rss_config_cmd cmd = {
1107 .flags = cpu_to_le32(IWL_RSS_ENABLE),
1108 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
1109 IWL_RSS_HASH_TYPE_IPV4_UDP |
1110 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
1111 IWL_RSS_HASH_TYPE_IPV6_TCP |
1112 IWL_RSS_HASH_TYPE_IPV6_UDP |
1113 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
1115 int ret, i, num_repeats, nbytes = count / 2;
1117 ret = hex2bin(cmd.indirection_table, buf, nbytes);
1122 * The input is the redirection table, partial or full.
1123 * Repeat the pattern if needed.
1124 * For example, input of 01020F will be repeated 42 times,
1125 * indirecting RSS hash results to queues 1, 2, 15 (skipping
1128 num_repeats = ARRAY_SIZE(cmd.indirection_table) / nbytes;
1129 for (i = 1; i < num_repeats; i++)
1130 memcpy(&cmd.indirection_table[i * nbytes],
1131 cmd.indirection_table, nbytes);
1132 /* handle cut in the middle pattern for the last places */
1133 memcpy(&cmd.indirection_table[i * nbytes], cmd.indirection_table,
1134 ARRAY_SIZE(cmd.indirection_table) % nbytes);
1136 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
1138 mutex_lock(&mvm->mutex);
1139 if (iwl_mvm_firmware_running(mvm))
1140 ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0,
1144 mutex_unlock(&mvm->mutex);
1146 return ret ?: count;
1149 static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
1150 char *buf, size_t count,
1153 struct iwl_op_mode *opmode = container_of((void *)mvm,
1156 struct iwl_rx_cmd_buffer rxb = {
1157 ._rx_page_order = 0,
1158 .truesize = 0, /* not used */
1161 struct iwl_rx_packet *pkt;
1162 int bin_len = count / 2;
1165 if (!iwl_mvm_firmware_running(mvm))
1168 /* supporting only MQ RX */
1169 if (!mvm->trans->trans_cfg->mq_rx_supported)
1172 rxb._page = alloc_pages(GFP_ATOMIC, 0);
1175 pkt = rxb_addr(&rxb);
1177 ret = hex2bin(page_address(rxb._page), buf, bin_len);
1181 /* avoid invalid memory access and malformed packet */
1182 if (bin_len < sizeof(*pkt) ||
1183 bin_len != sizeof(*pkt) + iwl_rx_packet_payload_len(pkt))
1187 iwl_mvm_rx_mq(opmode, NULL, &rxb);
1194 return ret ?: count;
1197 static int _iwl_dbgfs_inject_beacon_ie(struct iwl_mvm *mvm, char *bin, int len)
1199 struct ieee80211_vif *vif;
1200 struct iwl_mvm_vif *mvmvif;
1201 struct sk_buff *beacon;
1202 struct ieee80211_tx_info *info;
1203 struct iwl_mac_beacon_cmd beacon_cmd = {};
1209 /* Element len should be represented by u8 */
1213 if (!iwl_mvm_firmware_running(mvm))
1216 if (!iwl_mvm_has_new_tx_api(mvm) &&
1217 !fw_has_api(&mvm->fw->ucode_capa,
1218 IWL_UCODE_TLV_API_NEW_BEACON_TEMPLATE))
1221 mutex_lock(&mvm->mutex);
1223 for (i = 0; i < NUM_MAC_INDEX_DRIVER; i++) {
1224 vif = iwl_mvm_rcu_dereference_vif_id(mvm, i, false);
1228 if (vif->type == NL80211_IFTYPE_AP)
1232 if (i == NUM_MAC_INDEX_DRIVER || !vif)
1235 mvm->hw->extra_beacon_tailroom = len;
1237 beacon = ieee80211_beacon_get_template(mvm->hw, vif, NULL);
1241 if (len && hex2bin(skb_put_zero(beacon, len), bin, len)) {
1242 dev_kfree_skb(beacon);
1246 mvm->beacon_inject_active = true;
1248 mvmvif = iwl_mvm_vif_from_mac80211(vif);
1249 info = IEEE80211_SKB_CB(beacon);
1250 rate = iwl_mvm_mac_ctxt_get_lowest_rate(info, vif);
1253 cpu_to_le16(iwl_mvm_mac_ctxt_get_beacon_flags(mvm->fw, rate));
1254 beacon_cmd.byte_cnt = cpu_to_le16((u16)beacon->len);
1255 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id);
1257 iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd.tim_idx,
1258 &beacon_cmd.tim_size,
1259 beacon->data, beacon->len);
1261 iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
1262 sizeof(beacon_cmd));
1263 mutex_unlock(&mvm->mutex);
1265 dev_kfree_skb(beacon);
1270 mutex_unlock(&mvm->mutex);
1274 static ssize_t iwl_dbgfs_inject_beacon_ie_write(struct iwl_mvm *mvm,
1275 char *buf, size_t count,
1278 int ret = _iwl_dbgfs_inject_beacon_ie(mvm, buf, count);
1280 mvm->hw->extra_beacon_tailroom = 0;
1281 return ret ?: count;
1284 static ssize_t iwl_dbgfs_inject_beacon_ie_restore_write(struct iwl_mvm *mvm,
1289 int ret = _iwl_dbgfs_inject_beacon_ie(mvm, NULL, 0);
1291 mvm->hw->extra_beacon_tailroom = 0;
1292 mvm->beacon_inject_active = false;
1293 return ret ?: count;
1296 static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
1297 char __user *user_buf,
1298 size_t count, loff_t *ppos)
1300 struct iwl_mvm *mvm = file->private_data;
1303 const size_t bufsz = sizeof(buf);
1306 mutex_lock(&mvm->mutex);
1307 conf = mvm->fwrt.dump.conf;
1308 mutex_unlock(&mvm->mutex);
1310 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
1312 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1315 static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
1316 char *buf, size_t count,
1319 unsigned int conf_id;
1322 if (!iwl_mvm_firmware_running(mvm))
1325 ret = kstrtouint(buf, 0, &conf_id);
1329 if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
1332 mutex_lock(&mvm->mutex);
1333 ret = iwl_fw_start_dbg_conf(&mvm->fwrt, conf_id);
1334 mutex_unlock(&mvm->mutex);
1336 return ret ?: count;
1339 static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
1340 char *buf, size_t count,
1346 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_USER_TRIGGER,
1349 iwl_fw_dbg_collect(&mvm->fwrt, FW_DBG_TRIGGER_USER, buf,
1355 static ssize_t iwl_dbgfs_dbg_time_point_write(struct iwl_mvm *mvm,
1356 char *buf, size_t count,
1361 if (kstrtou32(buf, 0, &timepoint))
1364 if (timepoint == IWL_FW_INI_TIME_POINT_INVALID ||
1365 timepoint >= IWL_FW_INI_TIME_POINT_NUM)
1368 iwl_dbg_tlv_time_point(&mvm->fwrt, timepoint, NULL);
1373 #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1374 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1375 #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1376 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1377 #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1378 debugfs_create_file(alias, mode, parent, mvm, \
1379 &iwl_dbgfs_##name##_ops); \
1381 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1382 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
1384 #define MVM_DEBUGFS_WRITE_STA_FILE_OPS(name, bufsz) \
1385 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1386 #define MVM_DEBUGFS_READ_WRITE_STA_FILE_OPS(name, bufsz) \
1387 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1389 #define MVM_DEBUGFS_ADD_STA_FILE_ALIAS(alias, name, parent, mode) do { \
1390 debugfs_create_file(alias, mode, parent, sta, \
1391 &iwl_dbgfs_##name##_ops); \
1393 #define MVM_DEBUGFS_ADD_STA_FILE(name, parent, mode) \
1394 MVM_DEBUGFS_ADD_STA_FILE_ALIAS(#name, name, parent, mode)
1397 iwl_dbgfs_prph_reg_read(struct file *file,
1398 char __user *user_buf,
1399 size_t count, loff_t *ppos)
1401 struct iwl_mvm *mvm = file->private_data;
1404 const size_t bufsz = sizeof(buf);
1406 if (!mvm->dbgfs_prph_reg_addr)
1409 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1410 mvm->dbgfs_prph_reg_addr,
1411 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1413 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1417 iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1418 size_t count, loff_t *ppos)
1423 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1424 /* if we only want to set the reg address - nothing more to do */
1428 /* otherwise, make sure we have both address and value */
1432 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
1439 iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1440 size_t count, loff_t *ppos)
1444 if (!iwl_mvm_firmware_running(mvm))
1447 mutex_lock(&mvm->mutex);
1448 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
1449 mutex_unlock(&mvm->mutex);
1451 return ret ?: count;
1454 struct iwl_mvm_sniffer_apply {
1455 struct iwl_mvm *mvm;
1460 static bool iwl_mvm_sniffer_apply(struct iwl_notif_wait_data *notif_data,
1461 struct iwl_rx_packet *pkt, void *data)
1463 struct iwl_mvm_sniffer_apply *apply = data;
1465 apply->mvm->cur_aid = cpu_to_le16(apply->aid);
1466 memcpy(apply->mvm->cur_bssid, apply->bssid,
1467 sizeof(apply->mvm->cur_bssid));
1473 iwl_dbgfs_he_sniffer_params_write(struct iwl_mvm *mvm, char *buf,
1474 size_t count, loff_t *ppos)
1476 struct iwl_notification_wait wait;
1477 struct iwl_he_monitor_cmd he_mon_cmd = {};
1478 struct iwl_mvm_sniffer_apply apply = {
1482 iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD, DATA_PATH_GROUP, 0),
1487 if (!iwl_mvm_firmware_running(mvm))
1490 ret = sscanf(buf, "%x %2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", &aid,
1491 &he_mon_cmd.bssid[0], &he_mon_cmd.bssid[1],
1492 &he_mon_cmd.bssid[2], &he_mon_cmd.bssid[3],
1493 &he_mon_cmd.bssid[4], &he_mon_cmd.bssid[5]);
1497 he_mon_cmd.aid = cpu_to_le16(aid);
1500 apply.bssid = (void *)he_mon_cmd.bssid;
1502 mutex_lock(&mvm->mutex);
1505 * Use the notification waiter to get our function triggered
1506 * in sequence with other RX. This ensures that frames we get
1507 * on the RX queue _before_ the new configuration is applied
1508 * still have mvm->cur_aid pointing to the old AID, and that
1509 * frames on the RX queue _after_ the firmware processed the
1510 * new configuration (and sent the response, synchronously)
1511 * get mvm->cur_aid correctly set to the new AID.
1513 iwl_init_notification_wait(&mvm->notif_wait, &wait,
1514 wait_cmds, ARRAY_SIZE(wait_cmds),
1515 iwl_mvm_sniffer_apply, &apply);
1517 ret = iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD,
1518 DATA_PATH_GROUP, 0), 0,
1519 sizeof(he_mon_cmd), &he_mon_cmd);
1521 /* no need to really wait, we already did anyway */
1522 iwl_remove_notification(&mvm->notif_wait, &wait);
1524 mutex_unlock(&mvm->mutex);
1526 return ret ?: count;
1530 iwl_dbgfs_he_sniffer_params_read(struct file *file, char __user *user_buf,
1531 size_t count, loff_t *ppos)
1533 struct iwl_mvm *mvm = file->private_data;
1537 len = scnprintf(buf, sizeof(buf),
1538 "%d %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
1539 le16_to_cpu(mvm->cur_aid), mvm->cur_bssid[0],
1540 mvm->cur_bssid[1], mvm->cur_bssid[2], mvm->cur_bssid[3],
1541 mvm->cur_bssid[4], mvm->cur_bssid[5]);
1543 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1547 iwl_dbgfs_uapsd_noagg_bssids_read(struct file *file, char __user *user_buf,
1548 size_t count, loff_t *ppos)
1550 struct iwl_mvm *mvm = file->private_data;
1551 u8 buf[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM * ETH_ALEN * 3 + 1];
1552 unsigned int pos = 0;
1553 size_t bufsz = sizeof(buf);
1556 mutex_lock(&mvm->mutex);
1558 for (i = 0; i < IWL_MVM_UAPSD_NOAGG_LIST_LEN; i++)
1559 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
1560 mvm->uapsd_noagg_bssids[i].addr);
1562 mutex_unlock(&mvm->mutex);
1564 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1568 iwl_dbgfs_ltr_config_write(struct iwl_mvm *mvm,
1569 char *buf, size_t count, loff_t *ppos)
1572 struct iwl_ltr_config_cmd ltr_config = {0};
1574 if (!iwl_mvm_firmware_running(mvm))
1577 if (sscanf(buf, "%x,%x,%x,%x,%x,%x,%x",
1579 <r_config.static_long,
1580 <r_config.static_short,
1581 <r_config.ltr_cfg_values[0],
1582 <r_config.ltr_cfg_values[1],
1583 <r_config.ltr_cfg_values[2],
1584 <r_config.ltr_cfg_values[3]) != 7) {
1588 mutex_lock(&mvm->mutex);
1589 ret = iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, sizeof(ltr_config),
1591 mutex_unlock(&mvm->mutex);
1594 IWL_ERR(mvm, "failed to send ltr configuration cmd\n");
1596 return ret ?: count;
1599 static ssize_t iwl_dbgfs_rfi_freq_table_write(struct iwl_mvm *mvm, char *buf,
1600 size_t count, loff_t *ppos)
1605 if (kstrtou16(buf, 10, &op_id))
1608 /* value zero triggers re-sending the default table to the device */
1610 mutex_lock(&mvm->mutex);
1611 ret = iwl_rfi_send_config_cmd(mvm, NULL);
1612 mutex_unlock(&mvm->mutex);
1614 ret = -EOPNOTSUPP; /* in the future a new table will be added */
1617 return ret ?: count;
1620 /* The size computation is as follows:
1621 * each number needs at most 3 characters, number of rows is the size of
1622 * the table; So, need 5 chars for the "freq: " part and each tuple afterwards
1623 * needs 6 characters for numbers and 5 for the punctuation around.
1625 #define IWL_RFI_BUF_SIZE (IWL_RFI_LUT_INSTALLED_SIZE *\
1626 (5 + IWL_RFI_LUT_ENTRY_CHANNELS_NUM * (6 + 5)))
1628 static ssize_t iwl_dbgfs_rfi_freq_table_read(struct file *file,
1629 char __user *user_buf,
1630 size_t count, loff_t *ppos)
1632 struct iwl_mvm *mvm = file->private_data;
1633 struct iwl_rfi_freq_table_resp_cmd *resp;
1635 char buf[IWL_RFI_BUF_SIZE];
1638 resp = iwl_rfi_get_freq_table(mvm);
1640 return PTR_ERR(resp);
1642 status = le32_to_cpu(resp->status);
1643 if (status != RFI_FREQ_TABLE_OK) {
1644 scnprintf(buf, IWL_RFI_BUF_SIZE, "status = %d\n", status);
1648 for (i = 0; i < ARRAY_SIZE(resp->table); i++) {
1649 pos += scnprintf(buf + pos, IWL_RFI_BUF_SIZE - pos, "%d: ",
1650 resp->table[i].freq);
1652 for (j = 0; j < ARRAY_SIZE(resp->table[i].channels); j++)
1653 pos += scnprintf(buf + pos, IWL_RFI_BUF_SIZE - pos,
1655 resp->table[i].channels[j],
1656 resp->table[i].bands[j]);
1657 pos += scnprintf(buf + pos, IWL_RFI_BUF_SIZE - pos, "\n");
1662 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1665 MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1667 /* Device wide debugfs entries */
1668 MVM_DEBUGFS_READ_FILE_OPS(ctdp_budget);
1669 MVM_DEBUGFS_WRITE_FILE_OPS(stop_ctdp, 8);
1670 MVM_DEBUGFS_WRITE_FILE_OPS(force_ctkill, 8);
1671 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1672 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
1673 MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
1674 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
1675 MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
1676 MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
1677 MVM_DEBUGFS_READ_FILE_OPS(stations);
1678 MVM_DEBUGFS_READ_FILE_OPS(rs_data);
1679 MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
1680 MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
1681 MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
1682 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
1683 MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
1684 MVM_DEBUGFS_READ_FILE_OPS(fw_ver);
1685 MVM_DEBUGFS_READ_FILE_OPS(phy_integration_ver);
1686 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1687 MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
1688 MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
1689 MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
1690 MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
1691 MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
1692 MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64);
1693 MVM_DEBUGFS_WRITE_FILE_OPS(dbg_time_point, 64);
1694 MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1695 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
1696 MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512);
1697 MVM_DEBUGFS_WRITE_FILE_OPS(inject_beacon_ie, 512);
1698 MVM_DEBUGFS_WRITE_FILE_OPS(inject_beacon_ie_restore, 512);
1700 MVM_DEBUGFS_READ_FILE_OPS(uapsd_noagg_bssids);
1703 MVM_DEBUGFS_READ_FILE_OPS(sar_geo_profile);
1706 MVM_DEBUGFS_READ_WRITE_STA_FILE_OPS(amsdu_len, 16);
1708 MVM_DEBUGFS_READ_WRITE_FILE_OPS(he_sniffer_params, 32);
1710 MVM_DEBUGFS_WRITE_FILE_OPS(ltr_config, 512);
1711 MVM_DEBUGFS_READ_WRITE_FILE_OPS(rfi_freq_table, 16);
1713 static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
1714 size_t count, loff_t *ppos)
1716 struct iwl_mvm *mvm = file->private_data;
1717 struct iwl_dbg_mem_access_cmd cmd = {};
1718 struct iwl_dbg_mem_access_rsp *rsp;
1719 struct iwl_host_cmd hcmd = {
1720 .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1722 .len = { sizeof(cmd) },
1727 if (!iwl_mvm_firmware_running(mvm))
1730 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1732 cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
1734 /* Take care of alignment of both the position and the length */
1735 delta = *ppos & 0x3;
1736 cmd.addr = cpu_to_le32(*ppos - delta);
1737 cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
1738 (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
1740 mutex_lock(&mvm->mutex);
1741 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1742 mutex_unlock(&mvm->mutex);
1747 rsp = (void *)hcmd.resp_pkt->data;
1748 if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) {
1753 len = min((size_t)le32_to_cpu(rsp->len) << 2,
1754 iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp));
1755 len = min(len - delta, count);
1761 ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len);
1765 iwl_free_resp(&hcmd);
1769 static ssize_t iwl_dbgfs_mem_write(struct file *file,
1770 const char __user *user_buf, size_t count,
1773 struct iwl_mvm *mvm = file->private_data;
1774 struct iwl_dbg_mem_access_cmd *cmd;
1775 struct iwl_dbg_mem_access_rsp *rsp;
1776 struct iwl_host_cmd hcmd = {};
1782 if (!iwl_mvm_firmware_running(mvm))
1785 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1788 if (*ppos & 0x3 || count < 4) {
1789 op = DEBUG_MEM_OP_WRITE_BYTES;
1790 len = min(count, (size_t)(4 - (*ppos & 0x3)));
1793 op = DEBUG_MEM_OP_WRITE;
1794 len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS);
1795 data_size = len << 2;
1798 cmd_size = sizeof(*cmd) + ALIGN(data_size, 4);
1799 cmd = kzalloc(cmd_size, GFP_KERNEL);
1803 cmd->op = cpu_to_le32(op);
1804 cmd->len = cpu_to_le32(len);
1805 cmd->addr = cpu_to_le32(*ppos);
1806 if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
1811 hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1812 hcmd.data[0] = (void *)cmd;
1813 hcmd.len[0] = cmd_size;
1815 mutex_lock(&mvm->mutex);
1816 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1817 mutex_unlock(&mvm->mutex);
1824 rsp = (void *)hcmd.resp_pkt->data;
1825 if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) {
1834 iwl_free_resp(&hcmd);
1838 static const struct file_operations iwl_dbgfs_mem_ops = {
1839 .read = iwl_dbgfs_mem_read,
1840 .write = iwl_dbgfs_mem_write,
1841 .open = simple_open,
1842 .llseek = default_llseek,
1845 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
1846 struct ieee80211_vif *vif,
1847 struct ieee80211_sta *sta,
1850 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1852 if (iwl_mvm_has_tlc_offload(mvm)) {
1853 MVM_DEBUGFS_ADD_STA_FILE(rs_data, dir, 0400);
1855 MVM_DEBUGFS_ADD_STA_FILE(amsdu_len, dir, 0600);
1858 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)
1860 struct dentry *bcast_dir __maybe_unused;
1862 spin_lock_init(&mvm->drv_stats_lock);
1864 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, 0200);
1865 MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, 0200);
1866 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, 0600);
1867 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir, 0600);
1868 MVM_DEBUGFS_ADD_FILE(nic_temp, mvm->debugfs_dir, 0400);
1869 MVM_DEBUGFS_ADD_FILE(ctdp_budget, mvm->debugfs_dir, 0400);
1870 MVM_DEBUGFS_ADD_FILE(stop_ctdp, mvm->debugfs_dir, 0200);
1871 MVM_DEBUGFS_ADD_FILE(force_ctkill, mvm->debugfs_dir, 0200);
1872 MVM_DEBUGFS_ADD_FILE(stations, mvm->debugfs_dir, 0400);
1873 MVM_DEBUGFS_ADD_FILE(bt_notif, mvm->debugfs_dir, 0400);
1874 MVM_DEBUGFS_ADD_FILE(bt_cmd, mvm->debugfs_dir, 0400);
1875 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir, 0600);
1876 MVM_DEBUGFS_ADD_FILE(fw_ver, mvm->debugfs_dir, 0400);
1877 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, 0400);
1878 MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, 0400);
1879 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, 0200);
1880 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, 0200);
1881 MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, 0200);
1882 MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, 0200);
1883 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir, 0600);
1884 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, 0600);
1885 MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, 0600);
1886 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, 0200);
1887 MVM_DEBUGFS_ADD_FILE(dbg_time_point, mvm->debugfs_dir, 0200);
1888 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, 0200);
1889 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, 0200);
1890 MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, 0200);
1891 MVM_DEBUGFS_ADD_FILE(inject_beacon_ie, mvm->debugfs_dir, 0200);
1892 MVM_DEBUGFS_ADD_FILE(inject_beacon_ie_restore, mvm->debugfs_dir, 0200);
1893 MVM_DEBUGFS_ADD_FILE(rfi_freq_table, mvm->debugfs_dir, 0600);
1895 if (mvm->fw->phy_integration_ver)
1896 MVM_DEBUGFS_ADD_FILE(phy_integration_ver, mvm->debugfs_dir, 0400);
1898 MVM_DEBUGFS_ADD_FILE(sar_geo_profile, mvm->debugfs_dir, 0400);
1900 MVM_DEBUGFS_ADD_FILE(he_sniffer_params, mvm->debugfs_dir, 0600);
1902 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_LTR_GEN2))
1903 MVM_DEBUGFS_ADD_FILE(ltr_config, mvm->debugfs_dir, 0200);
1905 debugfs_create_bool("enable_scan_iteration_notif", 0600,
1906 mvm->debugfs_dir, &mvm->scan_iter_notif_enabled);
1907 debugfs_create_bool("drop_bcn_ap_mode", 0600, mvm->debugfs_dir,
1908 &mvm->drop_bcn_ap_mode);
1910 MVM_DEBUGFS_ADD_FILE(uapsd_noagg_bssids, mvm->debugfs_dir, S_IRUSR);
1912 #ifdef CONFIG_PM_SLEEP
1913 MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, 0400);
1914 debugfs_create_bool("d3_wake_sysassert", 0600, mvm->debugfs_dir,
1915 &mvm->d3_wake_sysassert);
1916 debugfs_create_u32("last_netdetect_scans", 0400, mvm->debugfs_dir,
1917 &mvm->last_netdetect_scans);
1920 debugfs_create_u8("ps_disabled", 0400, mvm->debugfs_dir,
1922 debugfs_create_blob("nvm_hw", 0400, mvm->debugfs_dir,
1924 debugfs_create_blob("nvm_sw", 0400, mvm->debugfs_dir,
1926 debugfs_create_blob("nvm_calib", 0400, mvm->debugfs_dir,
1927 &mvm->nvm_calib_blob);
1928 debugfs_create_blob("nvm_prod", 0400, mvm->debugfs_dir,
1929 &mvm->nvm_prod_blob);
1930 debugfs_create_blob("nvm_phy_sku", 0400, mvm->debugfs_dir,
1931 &mvm->nvm_phy_sku_blob);
1932 debugfs_create_blob("nvm_reg", S_IRUSR,
1933 mvm->debugfs_dir, &mvm->nvm_reg_blob);
1935 debugfs_create_file("mem", 0600, mvm->debugfs_dir, mvm,
1936 &iwl_dbgfs_mem_ops);
1939 * Create a symlink with mac80211. It will be removed when mac80211
1940 * exists (before the opmode exists which removes the target.)
1942 if (!IS_ERR(mvm->debugfs_dir)) {
1945 snprintf(buf, 100, "../../%pd2", mvm->debugfs_dir->d_parent);
1946 debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir,