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>
8 #include <linux/ieee80211.h>
9 #include <linux/netdevice.h>
15 #include "iwl-modparams.h"
16 #include "fw/error-dump.h"
18 static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
19 char __user *user_buf,
20 size_t count, loff_t *ppos)
22 struct iwl_mvm *mvm = file->private_data;
26 if (!iwl_mvm_is_ctdp_supported(mvm))
29 if (!iwl_mvm_firmware_running(mvm) ||
30 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
33 mutex_lock(&mvm->mutex);
34 budget = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_REPORT, 0);
35 mutex_unlock(&mvm->mutex);
40 pos = scnprintf(buf, sizeof(buf), "%d\n", budget);
42 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
45 static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
46 size_t count, loff_t *ppos)
50 if (!iwl_mvm_is_ctdp_supported(mvm))
53 if (!iwl_mvm_firmware_running(mvm) ||
54 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
57 mutex_lock(&mvm->mutex);
58 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_STOP, 0);
59 mutex_unlock(&mvm->mutex);
64 static ssize_t iwl_dbgfs_force_ctkill_write(struct iwl_mvm *mvm, char *buf,
65 size_t count, loff_t *ppos)
67 if (!iwl_mvm_firmware_running(mvm) ||
68 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
71 iwl_mvm_enter_ctkill(mvm);
76 static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
77 size_t count, loff_t *ppos)
82 if (!iwl_mvm_firmware_running(mvm) ||
83 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
86 if (kstrtou32(buf, 0, &flush_arg))
89 if (iwl_mvm_has_new_tx_api(mvm)) {
90 IWL_DEBUG_TX_QUEUES(mvm,
91 "FLUSHING all tids queues on sta_id = %d\n",
93 mutex_lock(&mvm->mutex);
94 ret = iwl_mvm_flush_sta_tids(mvm, flush_arg, 0xFFFF)
96 mutex_unlock(&mvm->mutex);
100 IWL_DEBUG_TX_QUEUES(mvm, "FLUSHING queues mask to flush = 0x%x\n",
103 mutex_lock(&mvm->mutex);
104 ret = iwl_mvm_flush_tx_path(mvm, flush_arg) ? : count;
105 mutex_unlock(&mvm->mutex);
110 static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
111 size_t count, loff_t *ppos)
113 struct iwl_mvm_sta *mvmsta;
114 int sta_id, drain, ret;
116 if (!iwl_mvm_firmware_running(mvm) ||
117 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
120 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
122 if (sta_id < 0 || sta_id >= mvm->fw->ucode_capa.num_stations)
124 if (drain < 0 || drain > 1)
127 mutex_lock(&mvm->mutex);
129 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
134 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
136 mutex_unlock(&mvm->mutex);
141 static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
142 size_t count, loff_t *ppos)
144 struct iwl_mvm *mvm = file->private_data;
145 const struct fw_img *img;
146 unsigned int ofs, len;
150 if (!iwl_mvm_firmware_running(mvm))
153 /* default is to dump the entire data segment */
154 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
155 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
156 len = img->sec[IWL_UCODE_SECTION_DATA].len;
158 if (mvm->dbgfs_sram_len) {
159 ofs = mvm->dbgfs_sram_offset;
160 len = mvm->dbgfs_sram_len;
163 ptr = kzalloc(len, GFP_KERNEL);
167 iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
169 ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
176 static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
177 size_t count, loff_t *ppos)
179 const struct fw_img *img;
181 u32 img_offset, img_len;
183 if (!iwl_mvm_firmware_running(mvm))
186 img = &mvm->fw->img[mvm->fwrt.cur_fw_img];
187 img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
188 img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
190 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
191 if ((offset & 0x3) || (len & 0x3))
194 if (offset + len > img_offset + img_len)
197 mvm->dbgfs_sram_offset = offset;
198 mvm->dbgfs_sram_len = len;
200 mvm->dbgfs_sram_offset = 0;
201 mvm->dbgfs_sram_len = 0;
207 static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
208 char __user *user_buf,
209 size_t count, loff_t *ppos)
211 struct iwl_mvm *mvm = file->private_data;
215 if (!mvm->temperature_test)
216 pos = scnprintf(buf , sizeof(buf), "disabled\n");
218 pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
220 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
224 * Set NIC Temperature
225 * Cause the driver to ignore the actual NIC temperature reported by the FW
226 * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
227 * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
228 * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
230 static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
231 char *buf, size_t count,
236 if (!iwl_mvm_firmware_running(mvm) && !mvm->temperature_test)
239 if (kstrtoint(buf, 10, &temperature))
241 /* not a legal temperature */
242 if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
243 temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
244 temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
247 mutex_lock(&mvm->mutex);
248 if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
249 if (!mvm->temperature_test)
252 mvm->temperature_test = false;
253 /* Since we can't read the temp while awake, just set
254 * it to zero until we get the next RX stats from the
257 mvm->temperature = 0;
259 mvm->temperature_test = true;
260 mvm->temperature = temperature;
262 IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
263 mvm->temperature_test ? "En" : "Dis" ,
265 /* handle the temperature change */
266 iwl_mvm_tt_handler(mvm);
269 mutex_unlock(&mvm->mutex);
274 static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
275 char __user *user_buf,
276 size_t count, loff_t *ppos)
278 struct iwl_mvm *mvm = file->private_data;
283 if (!iwl_mvm_firmware_running(mvm))
286 mutex_lock(&mvm->mutex);
287 ret = iwl_mvm_get_temp(mvm, &temp);
288 mutex_unlock(&mvm->mutex);
293 pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
295 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
299 static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file,
300 char __user *user_buf,
301 size_t count, loff_t *ppos)
303 struct iwl_mvm *mvm = file->private_data;
306 int bufsz = sizeof(buf);
309 if (!iwl_mvm_firmware_running(mvm))
312 mutex_lock(&mvm->mutex);
313 tbl_idx = iwl_mvm_get_sar_geo_profile(mvm);
315 mutex_unlock(&mvm->mutex);
320 pos = scnprintf(buf, bufsz,
321 "SAR geographic profile disabled\n");
323 pos += scnprintf(buf + pos, bufsz - pos,
324 "Use geographic profile %d\n", tbl_idx);
325 pos += scnprintf(buf + pos, bufsz - pos,
326 "2.4GHz:\n\tChain A offset: %hhu dBm\n\tChain B offset: %hhu dBm\n\tmax tx power: %hhu dBm\n",
327 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[0].chains[0],
328 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[0].chains[1],
329 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[0].max);
330 pos += scnprintf(buf + pos, bufsz - pos,
331 "5.2GHz:\n\tChain A offset: %hhu dBm\n\tChain B offset: %hhu dBm\n\tmax tx power: %hhu dBm\n",
332 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[1].chains[0],
333 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[1].chains[1],
334 mvm->fwrt.geo_profiles[tbl_idx - 1].bands[1].max);
336 mutex_unlock(&mvm->mutex);
338 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
342 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
343 size_t count, loff_t *ppos)
345 struct iwl_mvm *mvm = file->private_data;
346 struct ieee80211_sta *sta;
348 int i, pos = 0, bufsz = sizeof(buf);
350 mutex_lock(&mvm->mutex);
352 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
353 pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
354 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
355 lockdep_is_held(&mvm->mutex));
357 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
358 else if (IS_ERR(sta))
359 pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
362 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
366 mutex_unlock(&mvm->mutex);
368 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
371 static ssize_t iwl_dbgfs_rs_data_read(struct file *file, char __user *user_buf,
372 size_t count, loff_t *ppos)
374 struct ieee80211_sta *sta = file->private_data;
375 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
376 struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->lq_sta.rs_fw;
377 struct iwl_mvm *mvm = lq_sta->pers.drv;
378 static const size_t bufsz = 2048;
383 buff = kmalloc(bufsz, GFP_KERNEL);
387 mutex_lock(&mvm->mutex);
389 desc += scnprintf(buff + desc, bufsz - desc, "sta_id %d\n",
390 lq_sta->pers.sta_id);
391 desc += scnprintf(buff + desc, bufsz - desc,
393 lq_sta->pers.dbg_fixed_rate);
394 desc += scnprintf(buff + desc, bufsz - desc,
395 "A-MPDU size limit %d\n",
396 lq_sta->pers.dbg_agg_frame_count_lim);
397 desc += scnprintf(buff + desc, bufsz - desc,
398 "valid_tx_ant %s%s\n",
399 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_A) ? "ANT_A," : "",
400 (iwl_mvm_get_valid_tx_ant(mvm) & ANT_B) ? "ANT_B," : "");
401 desc += scnprintf(buff + desc, bufsz - desc,
402 "last tx rate=0x%X ",
403 lq_sta->last_rate_n_flags);
405 desc += rs_pretty_print_rate(buff + desc, bufsz - desc,
406 lq_sta->last_rate_n_flags);
407 if (desc < bufsz - 1)
409 mutex_unlock(&mvm->mutex);
411 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
416 static ssize_t iwl_dbgfs_amsdu_len_write(struct ieee80211_sta *sta,
417 char *buf, size_t count,
420 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
424 if (kstrtou16(buf, 0, &amsdu_len))
427 /* only change from debug set <-> debug unset */
428 if ((amsdu_len && mvmsta->orig_amsdu_len) ||
429 (!!amsdu_len && mvmsta->orig_amsdu_len))
433 mvmsta->orig_amsdu_len = sta->max_amsdu_len;
434 sta->max_amsdu_len = amsdu_len;
435 for (i = 0; i < ARRAY_SIZE(sta->max_tid_amsdu_len); i++)
436 sta->max_tid_amsdu_len[i] = amsdu_len;
438 sta->max_amsdu_len = mvmsta->orig_amsdu_len;
439 mvmsta->orig_amsdu_len = 0;
444 static ssize_t iwl_dbgfs_amsdu_len_read(struct file *file,
445 char __user *user_buf,
446 size_t count, loff_t *ppos)
448 struct ieee80211_sta *sta = file->private_data;
449 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
454 pos = scnprintf(buf, sizeof(buf), "current %d ", sta->max_amsdu_len);
455 pos += scnprintf(buf + pos, sizeof(buf) - pos, "stored %d\n",
456 mvmsta->orig_amsdu_len);
458 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
461 static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
462 char __user *user_buf,
463 size_t count, loff_t *ppos)
465 struct iwl_mvm *mvm = file->private_data;
467 int bufsz = sizeof(buf);
470 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
471 mvm->disable_power_off);
472 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
473 mvm->disable_power_off_d3);
475 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
478 static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
479 size_t count, loff_t *ppos)
483 if (!iwl_mvm_firmware_running(mvm))
486 if (!strncmp("disable_power_off_d0=", buf, 21)) {
487 if (sscanf(buf + 21, "%d", &val) != 1)
489 mvm->disable_power_off = val;
490 } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
491 if (sscanf(buf + 21, "%d", &val) != 1)
493 mvm->disable_power_off_d3 = val;
498 mutex_lock(&mvm->mutex);
499 ret = iwl_mvm_power_update_device(mvm);
500 mutex_unlock(&mvm->mutex);
506 int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
509 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
511 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
512 BT_MBOX_PRINT(0, LE_PROF1, false);
513 BT_MBOX_PRINT(0, LE_PROF2, false);
514 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
515 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
516 BT_MBOX_PRINT(0, INBAND_S, false);
517 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
518 BT_MBOX_PRINT(0, LE_SCAN, false);
519 BT_MBOX_PRINT(0, LE_ADV, false);
520 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
521 BT_MBOX_PRINT(0, OPEN_CON_1, true);
523 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
525 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
526 BT_MBOX_PRINT(1, IP_SR, false);
527 BT_MBOX_PRINT(1, LE_MSTR, false);
528 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
529 BT_MBOX_PRINT(1, MSG_TYPE, false);
530 BT_MBOX_PRINT(1, SSN, true);
532 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
534 BT_MBOX_PRINT(2, SNIFF_ACT, false);
535 BT_MBOX_PRINT(2, PAG, false);
536 BT_MBOX_PRINT(2, INQUIRY, false);
537 BT_MBOX_PRINT(2, CONN, false);
538 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
539 BT_MBOX_PRINT(2, DISC, false);
540 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
541 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
542 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
543 BT_MBOX_PRINT(2, SCO_DURATION, true);
545 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
547 BT_MBOX_PRINT(3, SCO_STATE, false);
548 BT_MBOX_PRINT(3, SNIFF_STATE, false);
549 BT_MBOX_PRINT(3, A2DP_STATE, false);
550 BT_MBOX_PRINT(3, A2DP_SRC, false);
551 BT_MBOX_PRINT(3, ACL_STATE, false);
552 BT_MBOX_PRINT(3, MSTR_STATE, false);
553 BT_MBOX_PRINT(3, OBX_STATE, false);
554 BT_MBOX_PRINT(3, OPEN_CON_2, false);
555 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
556 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
557 BT_MBOX_PRINT(3, INBAND_P, false);
558 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
559 BT_MBOX_PRINT(3, SSN_2, false);
560 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
565 static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
566 size_t count, loff_t *ppos)
568 struct iwl_mvm *mvm = file->private_data;
569 struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
571 int ret, pos = 0, bufsz = sizeof(char) * 1024;
573 buf = kmalloc(bufsz, GFP_KERNEL);
577 mutex_lock(&mvm->mutex);
579 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
581 pos += scnprintf(buf + pos, bufsz - pos, "bt_ci_compliance = %d\n",
582 notif->bt_ci_compliance);
583 pos += scnprintf(buf + pos, bufsz - pos, "primary_ch_lut = %d\n",
584 le32_to_cpu(notif->primary_ch_lut));
585 pos += scnprintf(buf + pos, bufsz - pos, "secondary_ch_lut = %d\n",
586 le32_to_cpu(notif->secondary_ch_lut));
587 pos += scnprintf(buf + pos,
588 bufsz - pos, "bt_activity_grading = %d\n",
589 le32_to_cpu(notif->bt_activity_grading));
590 pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n",
591 notif->rrc_status & 0xF);
592 pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n",
593 notif->ttc_status & 0xF);
595 pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n",
596 IWL_MVM_BT_COEX_SYNC2SCO);
597 pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n",
598 IWL_MVM_BT_COEX_MPLUT);
600 mutex_unlock(&mvm->mutex);
602 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
609 static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
610 size_t count, loff_t *ppos)
612 struct iwl_mvm *mvm = file->private_data;
613 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
615 int bufsz = sizeof(buf);
618 mutex_lock(&mvm->mutex);
620 pos += scnprintf(buf + pos, bufsz - pos, "Channel inhibition CMD\n");
621 pos += scnprintf(buf + pos, bufsz - pos,
622 "\tPrimary Channel Bitmap 0x%016llx\n",
623 le64_to_cpu(cmd->bt_primary_ci));
624 pos += scnprintf(buf + pos, bufsz - pos,
625 "\tSecondary Channel Bitmap 0x%016llx\n",
626 le64_to_cpu(cmd->bt_secondary_ci));
628 mutex_unlock(&mvm->mutex);
630 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
634 iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
635 size_t count, loff_t *ppos)
639 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
644 mvm->bt_tx_prio = bt_tx_prio;
650 iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
651 size_t count, loff_t *ppos)
653 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
654 [BT_FORCE_ANT_DIS] = "dis",
655 [BT_FORCE_ANT_AUTO] = "auto",
656 [BT_FORCE_ANT_BT] = "bt",
657 [BT_FORCE_ANT_WIFI] = "wifi",
659 int ret, bt_force_ant_mode;
661 ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf);
665 bt_force_ant_mode = ret;
667 mutex_lock(&mvm->mutex);
668 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
671 mvm->bt_force_ant_mode = bt_force_ant_mode;
672 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
673 modes_str[mvm->bt_force_ant_mode]);
675 if (iwl_mvm_firmware_running(mvm))
676 ret = iwl_mvm_send_bt_init_conf(mvm);
681 mutex_unlock(&mvm->mutex);
685 static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
686 size_t count, loff_t *ppos)
688 struct iwl_mvm *mvm = file->private_data;
689 char *buff, *pos, *endpos;
690 static const size_t bufsz = 1024;
693 buff = kmalloc(bufsz, GFP_KERNEL);
698 endpos = pos + bufsz;
700 pos += scnprintf(pos, endpos - pos, "FW prefix: %s\n",
701 mvm->trans->cfg->fw_name_pre);
702 pos += scnprintf(pos, endpos - pos, "FW: %s\n",
703 mvm->fwrt.fw->human_readable);
704 pos += scnprintf(pos, endpos - pos, "Device: %s\n",
705 mvm->fwrt.trans->name);
706 pos += scnprintf(pos, endpos - pos, "Bus: %s\n",
707 mvm->fwrt.dev->bus->name);
709 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
715 static ssize_t iwl_dbgfs_phy_integration_ver_read(struct file *file,
716 char __user *user_buf,
717 size_t count, loff_t *ppos)
719 struct iwl_mvm *mvm = file->private_data;
725 bufsz = mvm->fw->phy_integration_ver_len + 2;
726 buf = kmalloc(bufsz, GFP_KERNEL);
730 pos = scnprintf(buf, bufsz, "%.*s\n", mvm->fw->phy_integration_ver_len,
731 mvm->fw->phy_integration_ver);
733 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
739 #define PRINT_STATS_LE32(_struct, _memb) \
740 pos += scnprintf(buf + pos, bufsz - pos, \
742 le32_to_cpu(_struct->_memb))
744 static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
745 char __user *user_buf, size_t count,
748 struct iwl_mvm *mvm = file->private_data;
749 static const char *fmt_table = "\t%-30s %10u\n";
750 static const char *fmt_header = "%-32s\n";
756 if (iwl_mvm_has_new_rx_stats_api(mvm))
757 bufsz = ((sizeof(struct mvm_statistics_rx) /
758 sizeof(__le32)) * 43) + (4 * 33) + 1;
760 /* 43 = size of each data line; 33 = size of each header */
761 bufsz = ((sizeof(struct mvm_statistics_rx_v3) /
762 sizeof(__le32)) * 43) + (4 * 33) + 1;
764 buf = kzalloc(bufsz, GFP_KERNEL);
768 mutex_lock(&mvm->mutex);
770 if (iwl_mvm_firmware_running(mvm))
771 iwl_mvm_request_statistics(mvm, false);
773 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
774 "Statistics_Rx - OFDM");
775 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
776 struct mvm_statistics_rx_phy_v2 *ofdm = &mvm->rx_stats_v3.ofdm;
778 PRINT_STATS_LE32(ofdm, ina_cnt);
779 PRINT_STATS_LE32(ofdm, fina_cnt);
780 PRINT_STATS_LE32(ofdm, plcp_err);
781 PRINT_STATS_LE32(ofdm, crc32_err);
782 PRINT_STATS_LE32(ofdm, overrun_err);
783 PRINT_STATS_LE32(ofdm, early_overrun_err);
784 PRINT_STATS_LE32(ofdm, crc32_good);
785 PRINT_STATS_LE32(ofdm, false_alarm_cnt);
786 PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
787 PRINT_STATS_LE32(ofdm, sfd_timeout);
788 PRINT_STATS_LE32(ofdm, fina_timeout);
789 PRINT_STATS_LE32(ofdm, unresponded_rts);
790 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
791 PRINT_STATS_LE32(ofdm, sent_ack_cnt);
792 PRINT_STATS_LE32(ofdm, sent_cts_cnt);
793 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
794 PRINT_STATS_LE32(ofdm, dsp_self_kill);
795 PRINT_STATS_LE32(ofdm, mh_format_err);
796 PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
797 PRINT_STATS_LE32(ofdm, reserved);
799 struct mvm_statistics_rx_phy *ofdm = &mvm->rx_stats.ofdm;
801 PRINT_STATS_LE32(ofdm, unresponded_rts);
802 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
803 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
804 PRINT_STATS_LE32(ofdm, dsp_self_kill);
805 PRINT_STATS_LE32(ofdm, reserved);
808 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
809 "Statistics_Rx - CCK");
810 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
811 struct mvm_statistics_rx_phy_v2 *cck = &mvm->rx_stats_v3.cck;
813 PRINT_STATS_LE32(cck, ina_cnt);
814 PRINT_STATS_LE32(cck, fina_cnt);
815 PRINT_STATS_LE32(cck, plcp_err);
816 PRINT_STATS_LE32(cck, crc32_err);
817 PRINT_STATS_LE32(cck, overrun_err);
818 PRINT_STATS_LE32(cck, early_overrun_err);
819 PRINT_STATS_LE32(cck, crc32_good);
820 PRINT_STATS_LE32(cck, false_alarm_cnt);
821 PRINT_STATS_LE32(cck, fina_sync_err_cnt);
822 PRINT_STATS_LE32(cck, sfd_timeout);
823 PRINT_STATS_LE32(cck, fina_timeout);
824 PRINT_STATS_LE32(cck, unresponded_rts);
825 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
826 PRINT_STATS_LE32(cck, sent_ack_cnt);
827 PRINT_STATS_LE32(cck, sent_cts_cnt);
828 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
829 PRINT_STATS_LE32(cck, dsp_self_kill);
830 PRINT_STATS_LE32(cck, mh_format_err);
831 PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
832 PRINT_STATS_LE32(cck, reserved);
834 struct mvm_statistics_rx_phy *cck = &mvm->rx_stats.cck;
836 PRINT_STATS_LE32(cck, unresponded_rts);
837 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
838 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
839 PRINT_STATS_LE32(cck, dsp_self_kill);
840 PRINT_STATS_LE32(cck, reserved);
843 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
844 "Statistics_Rx - GENERAL");
845 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
846 struct mvm_statistics_rx_non_phy_v3 *general =
847 &mvm->rx_stats_v3.general;
849 PRINT_STATS_LE32(general, bogus_cts);
850 PRINT_STATS_LE32(general, bogus_ack);
851 PRINT_STATS_LE32(general, non_bssid_frames);
852 PRINT_STATS_LE32(general, filtered_frames);
853 PRINT_STATS_LE32(general, non_channel_beacons);
854 PRINT_STATS_LE32(general, channel_beacons);
855 PRINT_STATS_LE32(general, num_missed_bcon);
856 PRINT_STATS_LE32(general, adc_rx_saturation_time);
857 PRINT_STATS_LE32(general, ina_detection_search_time);
858 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
859 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
860 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
861 PRINT_STATS_LE32(general, interference_data_flag);
862 PRINT_STATS_LE32(general, channel_load);
863 PRINT_STATS_LE32(general, dsp_false_alarms);
864 PRINT_STATS_LE32(general, beacon_rssi_a);
865 PRINT_STATS_LE32(general, beacon_rssi_b);
866 PRINT_STATS_LE32(general, beacon_rssi_c);
867 PRINT_STATS_LE32(general, beacon_energy_a);
868 PRINT_STATS_LE32(general, beacon_energy_b);
869 PRINT_STATS_LE32(general, beacon_energy_c);
870 PRINT_STATS_LE32(general, num_bt_kills);
871 PRINT_STATS_LE32(general, mac_id);
872 PRINT_STATS_LE32(general, directed_data_mpdu);
874 struct mvm_statistics_rx_non_phy *general =
875 &mvm->rx_stats.general;
877 PRINT_STATS_LE32(general, bogus_cts);
878 PRINT_STATS_LE32(general, bogus_ack);
879 PRINT_STATS_LE32(general, non_channel_beacons);
880 PRINT_STATS_LE32(general, channel_beacons);
881 PRINT_STATS_LE32(general, num_missed_bcon);
882 PRINT_STATS_LE32(general, adc_rx_saturation_time);
883 PRINT_STATS_LE32(general, ina_detection_search_time);
884 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
885 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
886 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
887 PRINT_STATS_LE32(general, interference_data_flag);
888 PRINT_STATS_LE32(general, channel_load);
889 PRINT_STATS_LE32(general, beacon_rssi_a);
890 PRINT_STATS_LE32(general, beacon_rssi_b);
891 PRINT_STATS_LE32(general, beacon_rssi_c);
892 PRINT_STATS_LE32(general, beacon_energy_a);
893 PRINT_STATS_LE32(general, beacon_energy_b);
894 PRINT_STATS_LE32(general, beacon_energy_c);
895 PRINT_STATS_LE32(general, num_bt_kills);
896 PRINT_STATS_LE32(general, mac_id);
899 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
900 "Statistics_Rx - HT");
901 if (!iwl_mvm_has_new_rx_stats_api(mvm)) {
902 struct mvm_statistics_rx_ht_phy_v1 *ht =
903 &mvm->rx_stats_v3.ofdm_ht;
905 PRINT_STATS_LE32(ht, plcp_err);
906 PRINT_STATS_LE32(ht, overrun_err);
907 PRINT_STATS_LE32(ht, early_overrun_err);
908 PRINT_STATS_LE32(ht, crc32_good);
909 PRINT_STATS_LE32(ht, crc32_err);
910 PRINT_STATS_LE32(ht, mh_format_err);
911 PRINT_STATS_LE32(ht, agg_crc32_good);
912 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
913 PRINT_STATS_LE32(ht, agg_cnt);
914 PRINT_STATS_LE32(ht, unsupport_mcs);
916 struct mvm_statistics_rx_ht_phy *ht =
917 &mvm->rx_stats.ofdm_ht;
919 PRINT_STATS_LE32(ht, mh_format_err);
920 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
921 PRINT_STATS_LE32(ht, agg_cnt);
922 PRINT_STATS_LE32(ht, unsupport_mcs);
925 mutex_unlock(&mvm->mutex);
927 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
932 #undef PRINT_STAT_LE32
934 static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
935 char __user *user_buf, size_t count,
937 struct iwl_mvm_frame_stats *stats)
939 char *buff, *pos, *endpos;
942 static const size_t bufsz = 1024;
944 buff = kmalloc(bufsz, GFP_KERNEL);
948 spin_lock_bh(&mvm->drv_stats_lock);
951 endpos = pos + bufsz;
953 pos += scnprintf(pos, endpos - pos,
954 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
955 stats->legacy_frames,
958 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
961 stats->bw_80_frames);
962 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
965 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
967 stats->mimo2_frames);
968 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
970 stats->success_frames);
971 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
973 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
975 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
976 stats->ampdu_count > 0 ?
977 (stats->agg_frames / stats->ampdu_count) : 0);
979 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
981 idx = stats->last_frame_idx - 1;
982 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
983 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
984 if (stats->last_rates[idx] == 0)
986 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
987 (int)(ARRAY_SIZE(stats->last_rates) - i));
988 pos += rs_pretty_print_rate_v1(pos, endpos - pos,
989 stats->last_rates[idx]);
990 if (pos < endpos - 1)
993 spin_unlock_bh(&mvm->drv_stats_lock);
995 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
1001 static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
1002 char __user *user_buf, size_t count,
1005 struct iwl_mvm *mvm = file->private_data;
1007 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
1008 &mvm->drv_rx_stats);
1011 static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
1012 size_t count, loff_t *ppos)
1014 int __maybe_unused ret;
1016 if (!iwl_mvm_firmware_running(mvm))
1019 mutex_lock(&mvm->mutex);
1021 /* allow one more restart that we're provoking here */
1022 if (mvm->fw_restart >= 0)
1025 if (count == 6 && !strcmp(buf, "nolog\n")) {
1026 set_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE, &mvm->status);
1027 set_bit(STATUS_SUPPRESS_CMD_ERROR_ONCE, &mvm->trans->status);
1030 /* take the return value to make compiler happy - it will fail anyway */
1031 ret = iwl_mvm_send_cmd_pdu(mvm,
1032 WIDE_ID(LONG_GROUP, REPLY_ERROR),
1035 mutex_unlock(&mvm->mutex);
1040 static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
1041 size_t count, loff_t *ppos)
1043 if (!iwl_mvm_firmware_running(mvm))
1046 if (count == 6 && !strcmp(buf, "nolog\n"))
1047 set_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE, &mvm->status);
1049 iwl_force_nmi(mvm->trans);
1055 iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
1056 char __user *user_buf,
1057 size_t count, loff_t *ppos)
1059 struct iwl_mvm *mvm = file->private_data;
1062 const size_t bufsz = sizeof(buf);
1064 /* print which antennas were set for the scan command by the user */
1065 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
1066 if (mvm->scan_rx_ant & ANT_A)
1067 pos += scnprintf(buf + pos, bufsz - pos, "A");
1068 if (mvm->scan_rx_ant & ANT_B)
1069 pos += scnprintf(buf + pos, bufsz - pos, "B");
1070 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
1072 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1076 iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
1077 size_t count, loff_t *ppos)
1081 if (!iwl_mvm_firmware_running(mvm))
1084 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
1086 if (scan_rx_ant > ANT_ABC)
1088 if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
1091 if (mvm->scan_rx_ant != scan_rx_ant) {
1092 mvm->scan_rx_ant = scan_rx_ant;
1093 if (fw_has_capa(&mvm->fw->ucode_capa,
1094 IWL_UCODE_TLV_CAPA_UMAC_SCAN))
1095 iwl_mvm_config_scan(mvm);
1101 static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
1102 char *buf, size_t count,
1105 struct iwl_rss_config_cmd cmd = {
1106 .flags = cpu_to_le32(IWL_RSS_ENABLE),
1107 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
1108 IWL_RSS_HASH_TYPE_IPV4_UDP |
1109 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
1110 IWL_RSS_HASH_TYPE_IPV6_TCP |
1111 IWL_RSS_HASH_TYPE_IPV6_UDP |
1112 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
1114 int ret, i, num_repeats, nbytes = count / 2;
1116 ret = hex2bin(cmd.indirection_table, buf, nbytes);
1121 * The input is the redirection table, partial or full.
1122 * Repeat the pattern if needed.
1123 * For example, input of 01020F will be repeated 42 times,
1124 * indirecting RSS hash results to queues 1, 2, 15 (skipping
1127 num_repeats = ARRAY_SIZE(cmd.indirection_table) / nbytes;
1128 for (i = 1; i < num_repeats; i++)
1129 memcpy(&cmd.indirection_table[i * nbytes],
1130 cmd.indirection_table, nbytes);
1131 /* handle cut in the middle pattern for the last places */
1132 memcpy(&cmd.indirection_table[i * nbytes], cmd.indirection_table,
1133 ARRAY_SIZE(cmd.indirection_table) % nbytes);
1135 netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key));
1137 mutex_lock(&mvm->mutex);
1138 if (iwl_mvm_firmware_running(mvm))
1139 ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0,
1143 mutex_unlock(&mvm->mutex);
1145 return ret ?: count;
1148 static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
1149 char *buf, size_t count,
1152 struct iwl_op_mode *opmode = container_of((void *)mvm,
1155 struct iwl_rx_cmd_buffer rxb = {
1156 ._rx_page_order = 0,
1157 .truesize = 0, /* not used */
1160 struct iwl_rx_packet *pkt;
1161 int bin_len = count / 2;
1164 if (!iwl_mvm_firmware_running(mvm))
1167 /* supporting only MQ RX */
1168 if (!mvm->trans->trans_cfg->mq_rx_supported)
1171 rxb._page = alloc_pages(GFP_ATOMIC, 0);
1174 pkt = rxb_addr(&rxb);
1176 ret = hex2bin(page_address(rxb._page), buf, bin_len);
1180 /* avoid invalid memory access and malformed packet */
1181 if (bin_len < sizeof(*pkt) ||
1182 bin_len != sizeof(*pkt) + iwl_rx_packet_payload_len(pkt))
1186 iwl_mvm_rx_mq(opmode, NULL, &rxb);
1193 return ret ?: count;
1196 static int _iwl_dbgfs_inject_beacon_ie(struct iwl_mvm *mvm, char *bin, int len)
1198 struct ieee80211_vif *vif;
1199 struct iwl_mvm_vif *mvmvif;
1200 struct sk_buff *beacon;
1201 struct ieee80211_tx_info *info;
1202 struct iwl_mac_beacon_cmd beacon_cmd = {};
1208 /* Element len should be represented by u8 */
1212 if (!iwl_mvm_firmware_running(mvm))
1215 if (!iwl_mvm_has_new_tx_api(mvm) &&
1216 !fw_has_api(&mvm->fw->ucode_capa,
1217 IWL_UCODE_TLV_API_NEW_BEACON_TEMPLATE))
1220 mutex_lock(&mvm->mutex);
1222 for (i = 0; i < NUM_MAC_INDEX_DRIVER; i++) {
1223 vif = iwl_mvm_rcu_dereference_vif_id(mvm, i, false);
1227 if (vif->type == NL80211_IFTYPE_AP)
1231 if (i == NUM_MAC_INDEX_DRIVER || !vif)
1234 mvm->hw->extra_beacon_tailroom = len;
1236 beacon = ieee80211_beacon_get_template(mvm->hw, vif, NULL);
1240 if (len && hex2bin(skb_put_zero(beacon, len), bin, len)) {
1241 dev_kfree_skb(beacon);
1245 mvm->beacon_inject_active = true;
1247 mvmvif = iwl_mvm_vif_from_mac80211(vif);
1248 info = IEEE80211_SKB_CB(beacon);
1249 rate = iwl_mvm_mac_ctxt_get_lowest_rate(info, vif);
1252 cpu_to_le16(iwl_mvm_mac_ctxt_get_beacon_flags(mvm->fw, rate));
1253 beacon_cmd.byte_cnt = cpu_to_le16((u16)beacon->len);
1254 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id);
1256 iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd.tim_idx,
1257 &beacon_cmd.tim_size,
1258 beacon->data, beacon->len);
1260 iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
1261 sizeof(beacon_cmd));
1262 mutex_unlock(&mvm->mutex);
1264 dev_kfree_skb(beacon);
1269 mutex_unlock(&mvm->mutex);
1273 static ssize_t iwl_dbgfs_inject_beacon_ie_write(struct iwl_mvm *mvm,
1274 char *buf, size_t count,
1277 int ret = _iwl_dbgfs_inject_beacon_ie(mvm, buf, count);
1279 mvm->hw->extra_beacon_tailroom = 0;
1280 return ret ?: count;
1283 static ssize_t iwl_dbgfs_inject_beacon_ie_restore_write(struct iwl_mvm *mvm,
1288 int ret = _iwl_dbgfs_inject_beacon_ie(mvm, NULL, 0);
1290 mvm->hw->extra_beacon_tailroom = 0;
1291 mvm->beacon_inject_active = false;
1292 return ret ?: count;
1295 static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
1296 char __user *user_buf,
1297 size_t count, loff_t *ppos)
1299 struct iwl_mvm *mvm = file->private_data;
1302 const size_t bufsz = sizeof(buf);
1305 mutex_lock(&mvm->mutex);
1306 conf = mvm->fwrt.dump.conf;
1307 mutex_unlock(&mvm->mutex);
1309 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
1311 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1314 static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
1315 char *buf, size_t count,
1318 unsigned int conf_id;
1321 if (!iwl_mvm_firmware_running(mvm))
1324 ret = kstrtouint(buf, 0, &conf_id);
1328 if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
1331 mutex_lock(&mvm->mutex);
1332 ret = iwl_fw_start_dbg_conf(&mvm->fwrt, conf_id);
1333 mutex_unlock(&mvm->mutex);
1335 return ret ?: count;
1338 static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
1339 char *buf, size_t count,
1345 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_USER_TRIGGER,
1348 iwl_fw_dbg_collect(&mvm->fwrt, FW_DBG_TRIGGER_USER, buf,
1354 static ssize_t iwl_dbgfs_dbg_time_point_write(struct iwl_mvm *mvm,
1355 char *buf, size_t count,
1360 if (kstrtou32(buf, 0, &timepoint))
1363 if (timepoint == IWL_FW_INI_TIME_POINT_INVALID ||
1364 timepoint >= IWL_FW_INI_TIME_POINT_NUM)
1367 iwl_dbg_tlv_time_point(&mvm->fwrt, timepoint, NULL);
1372 #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1373 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1374 #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1375 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1376 #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1377 debugfs_create_file(alias, mode, parent, mvm, \
1378 &iwl_dbgfs_##name##_ops); \
1380 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1381 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
1383 #define MVM_DEBUGFS_WRITE_STA_FILE_OPS(name, bufsz) \
1384 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1385 #define MVM_DEBUGFS_READ_WRITE_STA_FILE_OPS(name, bufsz) \
1386 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct ieee80211_sta)
1388 #define MVM_DEBUGFS_ADD_STA_FILE_ALIAS(alias, name, parent, mode) do { \
1389 debugfs_create_file(alias, mode, parent, sta, \
1390 &iwl_dbgfs_##name##_ops); \
1392 #define MVM_DEBUGFS_ADD_STA_FILE(name, parent, mode) \
1393 MVM_DEBUGFS_ADD_STA_FILE_ALIAS(#name, name, parent, mode)
1396 iwl_dbgfs_prph_reg_read(struct file *file,
1397 char __user *user_buf,
1398 size_t count, loff_t *ppos)
1400 struct iwl_mvm *mvm = file->private_data;
1403 const size_t bufsz = sizeof(buf);
1405 if (!mvm->dbgfs_prph_reg_addr)
1408 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1409 mvm->dbgfs_prph_reg_addr,
1410 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1412 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1416 iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1417 size_t count, loff_t *ppos)
1422 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1423 /* if we only want to set the reg address - nothing more to do */
1427 /* otherwise, make sure we have both address and value */
1431 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
1438 iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1439 size_t count, loff_t *ppos)
1443 if (!iwl_mvm_firmware_running(mvm))
1446 mutex_lock(&mvm->mutex);
1447 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
1448 mutex_unlock(&mvm->mutex);
1450 return ret ?: count;
1453 struct iwl_mvm_sniffer_apply {
1454 struct iwl_mvm *mvm;
1459 static bool iwl_mvm_sniffer_apply(struct iwl_notif_wait_data *notif_data,
1460 struct iwl_rx_packet *pkt, void *data)
1462 struct iwl_mvm_sniffer_apply *apply = data;
1464 apply->mvm->cur_aid = cpu_to_le16(apply->aid);
1465 memcpy(apply->mvm->cur_bssid, apply->bssid,
1466 sizeof(apply->mvm->cur_bssid));
1472 iwl_dbgfs_he_sniffer_params_write(struct iwl_mvm *mvm, char *buf,
1473 size_t count, loff_t *ppos)
1475 struct iwl_notification_wait wait;
1476 struct iwl_he_monitor_cmd he_mon_cmd = {};
1477 struct iwl_mvm_sniffer_apply apply = {
1481 iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD, DATA_PATH_GROUP, 0),
1486 if (!iwl_mvm_firmware_running(mvm))
1489 ret = sscanf(buf, "%x %2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", &aid,
1490 &he_mon_cmd.bssid[0], &he_mon_cmd.bssid[1],
1491 &he_mon_cmd.bssid[2], &he_mon_cmd.bssid[3],
1492 &he_mon_cmd.bssid[4], &he_mon_cmd.bssid[5]);
1496 he_mon_cmd.aid = cpu_to_le16(aid);
1499 apply.bssid = (void *)he_mon_cmd.bssid;
1501 mutex_lock(&mvm->mutex);
1504 * Use the notification waiter to get our function triggered
1505 * in sequence with other RX. This ensures that frames we get
1506 * on the RX queue _before_ the new configuration is applied
1507 * still have mvm->cur_aid pointing to the old AID, and that
1508 * frames on the RX queue _after_ the firmware processed the
1509 * new configuration (and sent the response, synchronously)
1510 * get mvm->cur_aid correctly set to the new AID.
1512 iwl_init_notification_wait(&mvm->notif_wait, &wait,
1513 wait_cmds, ARRAY_SIZE(wait_cmds),
1514 iwl_mvm_sniffer_apply, &apply);
1516 ret = iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(HE_AIR_SNIFFER_CONFIG_CMD,
1517 DATA_PATH_GROUP, 0), 0,
1518 sizeof(he_mon_cmd), &he_mon_cmd);
1520 /* no need to really wait, we already did anyway */
1521 iwl_remove_notification(&mvm->notif_wait, &wait);
1523 mutex_unlock(&mvm->mutex);
1525 return ret ?: count;
1529 iwl_dbgfs_he_sniffer_params_read(struct file *file, char __user *user_buf,
1530 size_t count, loff_t *ppos)
1532 struct iwl_mvm *mvm = file->private_data;
1536 len = scnprintf(buf, sizeof(buf),
1537 "%d %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
1538 le16_to_cpu(mvm->cur_aid), mvm->cur_bssid[0],
1539 mvm->cur_bssid[1], mvm->cur_bssid[2], mvm->cur_bssid[3],
1540 mvm->cur_bssid[4], mvm->cur_bssid[5]);
1542 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1546 iwl_dbgfs_uapsd_noagg_bssids_read(struct file *file, char __user *user_buf,
1547 size_t count, loff_t *ppos)
1549 struct iwl_mvm *mvm = file->private_data;
1550 u8 buf[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM * ETH_ALEN * 3 + 1];
1551 unsigned int pos = 0;
1552 size_t bufsz = sizeof(buf);
1555 mutex_lock(&mvm->mutex);
1557 for (i = 0; i < IWL_MVM_UAPSD_NOAGG_LIST_LEN; i++)
1558 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
1559 mvm->uapsd_noagg_bssids[i].addr);
1561 mutex_unlock(&mvm->mutex);
1563 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1567 iwl_dbgfs_ltr_config_write(struct iwl_mvm *mvm,
1568 char *buf, size_t count, loff_t *ppos)
1571 struct iwl_ltr_config_cmd ltr_config = {0};
1573 if (!iwl_mvm_firmware_running(mvm))
1576 if (sscanf(buf, "%x,%x,%x,%x,%x,%x,%x",
1578 <r_config.static_long,
1579 <r_config.static_short,
1580 <r_config.ltr_cfg_values[0],
1581 <r_config.ltr_cfg_values[1],
1582 <r_config.ltr_cfg_values[2],
1583 <r_config.ltr_cfg_values[3]) != 7) {
1587 mutex_lock(&mvm->mutex);
1588 ret = iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0, sizeof(ltr_config),
1590 mutex_unlock(&mvm->mutex);
1593 IWL_ERR(mvm, "failed to send ltr configuration cmd\n");
1595 return ret ?: count;
1598 static ssize_t iwl_dbgfs_rfi_freq_table_write(struct iwl_mvm *mvm, char *buf,
1599 size_t count, loff_t *ppos)
1604 if (kstrtou16(buf, 10, &op_id))
1607 /* value zero triggers re-sending the default table to the device */
1609 mutex_lock(&mvm->mutex);
1610 ret = iwl_rfi_send_config_cmd(mvm, NULL);
1611 mutex_unlock(&mvm->mutex);
1613 ret = -EOPNOTSUPP; /* in the future a new table will be added */
1616 return ret ?: count;
1619 /* The size computation is as follows:
1620 * each number needs at most 3 characters, number of rows is the size of
1621 * the table; So, need 5 chars for the "freq: " part and each tuple afterwards
1622 * needs 6 characters for numbers and 5 for the punctuation around.
1624 #define IWL_RFI_BUF_SIZE (IWL_RFI_LUT_INSTALLED_SIZE *\
1625 (5 + IWL_RFI_LUT_ENTRY_CHANNELS_NUM * (6 + 5)))
1627 static ssize_t iwl_dbgfs_rfi_freq_table_read(struct file *file,
1628 char __user *user_buf,
1629 size_t count, loff_t *ppos)
1631 struct iwl_mvm *mvm = file->private_data;
1632 struct iwl_rfi_freq_table_resp_cmd *resp;
1634 char buf[IWL_RFI_BUF_SIZE];
1637 resp = iwl_rfi_get_freq_table(mvm);
1639 return PTR_ERR(resp);
1641 status = le32_to_cpu(resp->status);
1642 if (status != RFI_FREQ_TABLE_OK) {
1643 scnprintf(buf, IWL_RFI_BUF_SIZE, "status = %d\n", status);
1647 for (i = 0; i < ARRAY_SIZE(resp->table); i++) {
1648 pos += scnprintf(buf + pos, IWL_RFI_BUF_SIZE - pos, "%d: ",
1649 resp->table[i].freq);
1651 for (j = 0; j < ARRAY_SIZE(resp->table[i].channels); j++)
1652 pos += scnprintf(buf + pos, IWL_RFI_BUF_SIZE - pos,
1654 resp->table[i].channels[j],
1655 resp->table[i].bands[j]);
1656 pos += scnprintf(buf + pos, IWL_RFI_BUF_SIZE - pos, "\n");
1661 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1664 MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1666 /* Device wide debugfs entries */
1667 MVM_DEBUGFS_READ_FILE_OPS(ctdp_budget);
1668 MVM_DEBUGFS_WRITE_FILE_OPS(stop_ctdp, 8);
1669 MVM_DEBUGFS_WRITE_FILE_OPS(force_ctkill, 8);
1670 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1671 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
1672 MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
1673 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
1674 MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
1675 MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
1676 MVM_DEBUGFS_READ_FILE_OPS(stations);
1677 MVM_DEBUGFS_READ_FILE_OPS(rs_data);
1678 MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
1679 MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
1680 MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
1681 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
1682 MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
1683 MVM_DEBUGFS_READ_FILE_OPS(fw_ver);
1684 MVM_DEBUGFS_READ_FILE_OPS(phy_integration_ver);
1685 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1686 MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
1687 MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
1688 MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
1689 MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
1690 MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
1691 MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64);
1692 MVM_DEBUGFS_WRITE_FILE_OPS(dbg_time_point, 64);
1693 MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1694 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
1695 MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512);
1696 MVM_DEBUGFS_WRITE_FILE_OPS(inject_beacon_ie, 512);
1697 MVM_DEBUGFS_WRITE_FILE_OPS(inject_beacon_ie_restore, 512);
1699 MVM_DEBUGFS_READ_FILE_OPS(uapsd_noagg_bssids);
1702 MVM_DEBUGFS_READ_FILE_OPS(sar_geo_profile);
1705 MVM_DEBUGFS_READ_WRITE_STA_FILE_OPS(amsdu_len, 16);
1707 MVM_DEBUGFS_READ_WRITE_FILE_OPS(he_sniffer_params, 32);
1709 MVM_DEBUGFS_WRITE_FILE_OPS(ltr_config, 512);
1710 MVM_DEBUGFS_READ_WRITE_FILE_OPS(rfi_freq_table, 16);
1712 static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
1713 size_t count, loff_t *ppos)
1715 struct iwl_mvm *mvm = file->private_data;
1716 struct iwl_dbg_mem_access_cmd cmd = {};
1717 struct iwl_dbg_mem_access_rsp *rsp;
1718 struct iwl_host_cmd hcmd = {
1719 .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1721 .len = { sizeof(cmd) },
1726 if (!iwl_mvm_firmware_running(mvm))
1729 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1731 cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
1733 /* Take care of alignment of both the position and the length */
1734 delta = *ppos & 0x3;
1735 cmd.addr = cpu_to_le32(*ppos - delta);
1736 cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
1737 (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
1739 mutex_lock(&mvm->mutex);
1740 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1741 mutex_unlock(&mvm->mutex);
1746 rsp = (void *)hcmd.resp_pkt->data;
1747 if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) {
1752 len = min((size_t)le32_to_cpu(rsp->len) << 2,
1753 iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp));
1754 len = min(len - delta, count);
1760 ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len);
1764 iwl_free_resp(&hcmd);
1768 static ssize_t iwl_dbgfs_mem_write(struct file *file,
1769 const char __user *user_buf, size_t count,
1772 struct iwl_mvm *mvm = file->private_data;
1773 struct iwl_dbg_mem_access_cmd *cmd;
1774 struct iwl_dbg_mem_access_rsp *rsp;
1775 struct iwl_host_cmd hcmd = {};
1781 if (!iwl_mvm_firmware_running(mvm))
1784 hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR,
1787 if (*ppos & 0x3 || count < 4) {
1788 op = DEBUG_MEM_OP_WRITE_BYTES;
1789 len = min(count, (size_t)(4 - (*ppos & 0x3)));
1792 op = DEBUG_MEM_OP_WRITE;
1793 len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS);
1794 data_size = len << 2;
1797 cmd_size = sizeof(*cmd) + ALIGN(data_size, 4);
1798 cmd = kzalloc(cmd_size, GFP_KERNEL);
1802 cmd->op = cpu_to_le32(op);
1803 cmd->len = cpu_to_le32(len);
1804 cmd->addr = cpu_to_le32(*ppos);
1805 if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
1810 hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
1811 hcmd.data[0] = (void *)cmd;
1812 hcmd.len[0] = cmd_size;
1814 mutex_lock(&mvm->mutex);
1815 ret = iwl_mvm_send_cmd(mvm, &hcmd);
1816 mutex_unlock(&mvm->mutex);
1823 rsp = (void *)hcmd.resp_pkt->data;
1824 if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) {
1833 iwl_free_resp(&hcmd);
1837 static const struct file_operations iwl_dbgfs_mem_ops = {
1838 .read = iwl_dbgfs_mem_read,
1839 .write = iwl_dbgfs_mem_write,
1840 .open = simple_open,
1841 .llseek = default_llseek,
1844 void iwl_mvm_sta_add_debugfs(struct ieee80211_hw *hw,
1845 struct ieee80211_vif *vif,
1846 struct ieee80211_sta *sta,
1849 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1851 if (iwl_mvm_has_tlc_offload(mvm)) {
1852 MVM_DEBUGFS_ADD_STA_FILE(rs_data, dir, 0400);
1854 MVM_DEBUGFS_ADD_STA_FILE(amsdu_len, dir, 0600);
1857 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)
1859 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 snprintf(buf, 100, "../../%pd2", mvm->debugfs_dir->d_parent);
1943 debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf);