1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 *****************************************************************************/
67 struct iwl_dbgfs_mvm_ctx
{
69 struct ieee80211_vif
*vif
;
72 static ssize_t
iwl_dbgfs_tx_flush_write(struct file
*file
,
73 const char __user
*user_buf
,
74 size_t count
, loff_t
*ppos
)
76 struct iwl_mvm
*mvm
= file
->private_data
;
82 if (!mvm
->ucode_loaded
|| mvm
->cur_ucode
!= IWL_UCODE_REGULAR
)
85 memset(buf
, 0, sizeof(buf
));
86 buf_size
= min(count
, sizeof(buf
) - 1);
87 if (copy_from_user(buf
, user_buf
, buf_size
))
90 if (sscanf(buf
, "%x", &scd_q_msk
) != 1)
93 IWL_ERR(mvm
, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk
);
95 mutex_lock(&mvm
->mutex
);
96 ret
= iwl_mvm_flush_tx_path(mvm
, scd_q_msk
, true) ? : count
;
97 mutex_unlock(&mvm
->mutex
);
102 static ssize_t
iwl_dbgfs_sta_drain_write(struct file
*file
,
103 const char __user
*user_buf
,
104 size_t count
, loff_t
*ppos
)
106 struct iwl_mvm
*mvm
= file
->private_data
;
107 struct ieee80211_sta
*sta
;
110 int buf_size
, sta_id
, drain
, ret
;
112 if (!mvm
->ucode_loaded
|| mvm
->cur_ucode
!= IWL_UCODE_REGULAR
)
115 memset(buf
, 0, sizeof(buf
));
116 buf_size
= min(count
, sizeof(buf
) - 1);
117 if (copy_from_user(buf
, user_buf
, buf_size
))
120 if (sscanf(buf
, "%d %d", &sta_id
, &drain
) != 2)
122 if (sta_id
< 0 || sta_id
>= IWL_MVM_STATION_COUNT
)
124 if (drain
< 0 || drain
> 1)
127 mutex_lock(&mvm
->mutex
);
129 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[sta_id
],
130 lockdep_is_held(&mvm
->mutex
));
131 if (IS_ERR_OR_NULL(sta
))
134 ret
= iwl_mvm_drain_sta(mvm
, (void *)sta
->drv_priv
, drain
) ? :
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 int ofs
, len
, pos
= 0;
152 if (!mvm
->ucode_loaded
)
155 /* default is to dump the entire data segment */
156 if (!mvm
->dbgfs_sram_offset
&& !mvm
->dbgfs_sram_len
) {
157 img
= &mvm
->fw
->img
[mvm
->cur_ucode
];
158 ofs
= img
->sec
[IWL_UCODE_SECTION_DATA
].offset
;
159 len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
161 ofs
= mvm
->dbgfs_sram_offset
;
162 len
= mvm
->dbgfs_sram_len
;
165 bufsz
= len
* 4 + 256;
166 buf
= kzalloc(bufsz
, GFP_KERNEL
);
170 ptr
= kzalloc(len
, GFP_KERNEL
);
176 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_len: 0x%x\n", len
);
177 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_offset: 0x%x\n", ofs
);
179 iwl_trans_read_mem_bytes(mvm
->trans
, ofs
, ptr
, len
);
180 for (ofs
= 0; ofs
< len
; ofs
+= 16) {
181 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "0x%.4x ", ofs
);
182 hex_dump_to_buffer(ptr
+ ofs
, 16, 16, 1, buf
+ pos
,
184 pos
+= strlen(buf
+ pos
);
189 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
197 static ssize_t
iwl_dbgfs_sram_write(struct file
*file
,
198 const char __user
*user_buf
, size_t count
,
201 struct iwl_mvm
*mvm
= file
->private_data
;
206 memset(buf
, 0, sizeof(buf
));
207 buf_size
= min(count
, sizeof(buf
) - 1);
208 if (copy_from_user(buf
, user_buf
, buf_size
))
211 if (sscanf(buf
, "%x,%x", &offset
, &len
) == 2) {
212 if ((offset
& 0x3) || (len
& 0x3))
214 mvm
->dbgfs_sram_offset
= offset
;
215 mvm
->dbgfs_sram_len
= len
;
217 mvm
->dbgfs_sram_offset
= 0;
218 mvm
->dbgfs_sram_len
= 0;
224 static ssize_t
iwl_dbgfs_stations_read(struct file
*file
, char __user
*user_buf
,
225 size_t count
, loff_t
*ppos
)
227 struct iwl_mvm
*mvm
= file
->private_data
;
228 struct ieee80211_sta
*sta
;
230 int i
, pos
= 0, bufsz
= sizeof(buf
);
232 mutex_lock(&mvm
->mutex
);
234 for (i
= 0; i
< IWL_MVM_STATION_COUNT
; i
++) {
235 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%.2d: ", i
);
236 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[i
],
237 lockdep_is_held(&mvm
->mutex
));
239 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "N/A\n");
240 else if (IS_ERR(sta
))
241 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%ld\n",
244 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%pM\n",
248 mutex_unlock(&mvm
->mutex
);
250 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
253 static ssize_t
iwl_dbgfs_power_down_allow_write(struct file
*file
,
254 const char __user
*user_buf
,
255 size_t count
, loff_t
*ppos
)
257 struct iwl_mvm
*mvm
= file
->private_data
;
261 if (!mvm
->ucode_loaded
)
264 if (copy_from_user(buf
, user_buf
, sizeof(buf
)))
267 if (sscanf(buf
, "%d", &allow
) != 1)
270 IWL_DEBUG_POWER(mvm
, "%s device power down\n",
271 allow
? "allow" : "prevent");
274 * TODO: Send REPLY_DEBUG_CMD (0xf0) when FW support it
280 static ssize_t
iwl_dbgfs_power_down_d3_allow_write(struct file
*file
,
281 const char __user
*user_buf
,
282 size_t count
, loff_t
*ppos
)
284 struct iwl_mvm
*mvm
= file
->private_data
;
288 if (copy_from_user(buf
, user_buf
, sizeof(buf
)))
291 if (sscanf(buf
, "%d", &allow
) != 1)
294 IWL_DEBUG_POWER(mvm
, "%s device power down in d3\n",
295 allow
? "allow" : "prevent");
298 * TODO: When WoWLAN FW alive notification happens, driver will send
299 * REPLY_DEBUG_CMD setting power_down_allow flag according to
300 * mvm->prevent_power_down_d3
302 mvm
->prevent_power_down_d3
= !allow
;
307 static void iwl_dbgfs_update_pm(struct iwl_mvm
*mvm
,
308 struct ieee80211_vif
*vif
,
309 enum iwl_dbgfs_pm_mask param
, int val
)
311 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
312 struct iwl_dbgfs_pm
*dbgfs_pm
= &mvmvif
->dbgfs_pm
;
314 dbgfs_pm
->mask
|= param
;
317 case MVM_DEBUGFS_PM_KEEP_ALIVE
: {
318 struct ieee80211_hw
*hw
= mvm
->hw
;
319 int dtimper
= hw
->conf
.ps_dtim_period
?: 1;
320 int dtimper_msec
= dtimper
* vif
->bss_conf
.beacon_int
;
322 IWL_DEBUG_POWER(mvm
, "debugfs: set keep_alive= %d sec\n", val
);
323 if (val
* MSEC_PER_SEC
< 3 * dtimper_msec
) {
325 "debugfs: keep alive period (%ld msec) is less than minimum required (%d msec)\n",
326 val
* MSEC_PER_SEC
, 3 * dtimper_msec
);
328 dbgfs_pm
->keep_alive_seconds
= val
;
331 case MVM_DEBUGFS_PM_SKIP_OVER_DTIM
:
332 IWL_DEBUG_POWER(mvm
, "skip_over_dtim %s\n",
333 val
? "enabled" : "disabled");
334 dbgfs_pm
->skip_over_dtim
= val
;
336 case MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS
:
337 IWL_DEBUG_POWER(mvm
, "skip_dtim_periods=%d\n", val
);
338 dbgfs_pm
->skip_dtim_periods
= val
;
340 case MVM_DEBUGFS_PM_RX_DATA_TIMEOUT
:
341 IWL_DEBUG_POWER(mvm
, "rx_data_timeout=%d\n", val
);
342 dbgfs_pm
->rx_data_timeout
= val
;
344 case MVM_DEBUGFS_PM_TX_DATA_TIMEOUT
:
345 IWL_DEBUG_POWER(mvm
, "tx_data_timeout=%d\n", val
);
346 dbgfs_pm
->tx_data_timeout
= val
;
348 case MVM_DEBUGFS_PM_DISABLE_POWER_OFF
:
349 IWL_DEBUG_POWER(mvm
, "disable_power_off=%d\n", val
);
350 dbgfs_pm
->disable_power_off
= val
;
351 case MVM_DEBUGFS_PM_LPRX_ENA
:
352 IWL_DEBUG_POWER(mvm
, "lprx %s\n", val
? "enabled" : "disabled");
353 dbgfs_pm
->lprx_ena
= val
;
355 case MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD
:
356 IWL_DEBUG_POWER(mvm
, "lprx_rssi_threshold=%d\n", val
);
357 dbgfs_pm
->lprx_rssi_threshold
= val
;
359 case MVM_DEBUGFS_PM_SNOOZE_ENABLE
:
360 IWL_DEBUG_POWER(mvm
, "snooze_enable=%d\n", val
);
361 dbgfs_pm
->snooze_ena
= val
;
366 static ssize_t
iwl_dbgfs_pm_params_write(struct file
*file
,
367 const char __user
*user_buf
,
368 size_t count
, loff_t
*ppos
)
370 struct ieee80211_vif
*vif
= file
->private_data
;
371 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
372 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
373 enum iwl_dbgfs_pm_mask param
;
378 if (copy_from_user(buf
, user_buf
, sizeof(buf
)))
381 if (!strncmp("keep_alive=", buf
, 11)) {
382 if (sscanf(buf
+ 11, "%d", &val
) != 1)
384 param
= MVM_DEBUGFS_PM_KEEP_ALIVE
;
385 } else if (!strncmp("skip_over_dtim=", buf
, 15)) {
386 if (sscanf(buf
+ 15, "%d", &val
) != 1)
388 param
= MVM_DEBUGFS_PM_SKIP_OVER_DTIM
;
389 } else if (!strncmp("skip_dtim_periods=", buf
, 18)) {
390 if (sscanf(buf
+ 18, "%d", &val
) != 1)
392 param
= MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS
;
393 } else if (!strncmp("rx_data_timeout=", buf
, 16)) {
394 if (sscanf(buf
+ 16, "%d", &val
) != 1)
396 param
= MVM_DEBUGFS_PM_RX_DATA_TIMEOUT
;
397 } else if (!strncmp("tx_data_timeout=", buf
, 16)) {
398 if (sscanf(buf
+ 16, "%d", &val
) != 1)
400 param
= MVM_DEBUGFS_PM_TX_DATA_TIMEOUT
;
401 } else if (!strncmp("disable_power_off=", buf
, 18)) {
402 if (sscanf(buf
+ 18, "%d", &val
) != 1)
404 param
= MVM_DEBUGFS_PM_DISABLE_POWER_OFF
;
405 } else if (!strncmp("lprx=", buf
, 5)) {
406 if (sscanf(buf
+ 5, "%d", &val
) != 1)
408 param
= MVM_DEBUGFS_PM_LPRX_ENA
;
409 } else if (!strncmp("lprx_rssi_threshold=", buf
, 20)) {
410 if (sscanf(buf
+ 20, "%d", &val
) != 1)
412 if (val
> POWER_LPRX_RSSI_THRESHOLD_MAX
|| val
<
413 POWER_LPRX_RSSI_THRESHOLD_MIN
)
415 param
= MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD
;
416 } else if (!strncmp("snooze_enable=", buf
, 14)) {
417 if (sscanf(buf
+ 14, "%d", &val
) != 1)
419 param
= MVM_DEBUGFS_PM_SNOOZE_ENABLE
;
424 mutex_lock(&mvm
->mutex
);
425 iwl_dbgfs_update_pm(mvm
, vif
, param
, val
);
426 ret
= iwl_mvm_power_update_mode(mvm
, vif
);
427 mutex_unlock(&mvm
->mutex
);
432 static ssize_t
iwl_dbgfs_pm_params_read(struct file
*file
,
433 char __user
*user_buf
,
434 size_t count
, loff_t
*ppos
)
436 struct ieee80211_vif
*vif
= file
->private_data
;
437 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
438 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
440 int bufsz
= sizeof(buf
);
443 pos
= iwl_mvm_power_dbgfs_read(mvm
, vif
, buf
, bufsz
);
445 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
448 static ssize_t
iwl_dbgfs_mac_params_read(struct file
*file
,
449 char __user
*user_buf
,
450 size_t count
, loff_t
*ppos
)
452 struct ieee80211_vif
*vif
= file
->private_data
;
453 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
454 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
456 struct ieee80211_chanctx_conf
*chanctx_conf
;
458 int bufsz
= sizeof(buf
);
462 mutex_lock(&mvm
->mutex
);
464 ap_sta_id
= mvmvif
->ap_sta_id
;
466 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "mac id/color: %d / %d\n",
467 mvmvif
->id
, mvmvif
->color
);
468 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bssid: %pM\n",
469 vif
->bss_conf
.bssid
);
470 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "QoS:\n");
471 for (i
= 0; i
< ARRAY_SIZE(mvmvif
->queue_params
); i
++) {
472 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
473 "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
474 i
, mvmvif
->queue_params
[i
].txop
,
475 mvmvif
->queue_params
[i
].cw_min
,
476 mvmvif
->queue_params
[i
].cw_max
,
477 mvmvif
->queue_params
[i
].aifs
,
478 mvmvif
->queue_params
[i
].uapsd
);
481 if (vif
->type
== NL80211_IFTYPE_STATION
&&
482 ap_sta_id
!= IWL_MVM_STATION_COUNT
) {
483 struct ieee80211_sta
*sta
;
484 struct iwl_mvm_sta
*mvm_sta
;
486 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[ap_sta_id
],
487 lockdep_is_held(&mvm
->mutex
));
488 mvm_sta
= (void *)sta
->drv_priv
;
489 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
490 "ap_sta_id %d - reduced Tx power %d\n",
491 ap_sta_id
, mvm_sta
->bt_reduced_txpower
);
495 chanctx_conf
= rcu_dereference(vif
->chanctx_conf
);
497 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
498 "idle rx chains %d, active rx chains: %d\n",
499 chanctx_conf
->rx_chains_static
,
500 chanctx_conf
->rx_chains_dynamic
);
504 mutex_unlock(&mvm
->mutex
);
506 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
509 #define BT_MBOX_MSG(_notif, _num, _field) \
510 ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
511 >> BT_MBOX##_num##_##_field##_POS)
514 #define BT_MBOX_PRINT(_num, _field, _end) \
515 pos += scnprintf(buf + pos, bufsz - pos, \
518 BT_MBOX_MSG(notif, _num, _field), \
521 static ssize_t
iwl_dbgfs_bt_notif_read(struct file
*file
, char __user
*user_buf
,
522 size_t count
, loff_t
*ppos
)
524 struct iwl_mvm
*mvm
= file
->private_data
;
525 struct iwl_bt_coex_profile_notif
*notif
= &mvm
->last_bt_notif
;
527 int ret
, pos
= 0, bufsz
= sizeof(char) * 1024;
529 buf
= kmalloc(bufsz
, GFP_KERNEL
);
533 mutex_lock(&mvm
->mutex
);
535 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw0:\n");
537 BT_MBOX_PRINT(0, LE_SLAVE_LAT
, false);
538 BT_MBOX_PRINT(0, LE_PROF1
, false);
539 BT_MBOX_PRINT(0, LE_PROF2
, false);
540 BT_MBOX_PRINT(0, LE_PROF_OTHER
, false);
541 BT_MBOX_PRINT(0, CHL_SEQ_N
, false);
542 BT_MBOX_PRINT(0, INBAND_S
, false);
543 BT_MBOX_PRINT(0, LE_MIN_RSSI
, false);
544 BT_MBOX_PRINT(0, LE_SCAN
, false);
545 BT_MBOX_PRINT(0, LE_ADV
, false);
546 BT_MBOX_PRINT(0, LE_MAX_TX_POWER
, false);
547 BT_MBOX_PRINT(0, OPEN_CON_1
, true);
549 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw1:\n");
551 BT_MBOX_PRINT(1, BR_MAX_TX_POWER
, false);
552 BT_MBOX_PRINT(1, IP_SR
, false);
553 BT_MBOX_PRINT(1, LE_MSTR
, false);
554 BT_MBOX_PRINT(1, AGGR_TRFC_LD
, false);
555 BT_MBOX_PRINT(1, MSG_TYPE
, false);
556 BT_MBOX_PRINT(1, SSN
, true);
558 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw2:\n");
560 BT_MBOX_PRINT(2, SNIFF_ACT
, false);
561 BT_MBOX_PRINT(2, PAG
, false);
562 BT_MBOX_PRINT(2, INQUIRY
, false);
563 BT_MBOX_PRINT(2, CONN
, false);
564 BT_MBOX_PRINT(2, SNIFF_INTERVAL
, false);
565 BT_MBOX_PRINT(2, DISC
, false);
566 BT_MBOX_PRINT(2, SCO_TX_ACT
, false);
567 BT_MBOX_PRINT(2, SCO_RX_ACT
, false);
568 BT_MBOX_PRINT(2, ESCO_RE_TX
, false);
569 BT_MBOX_PRINT(2, SCO_DURATION
, true);
571 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw3:\n");
573 BT_MBOX_PRINT(3, SCO_STATE
, false);
574 BT_MBOX_PRINT(3, SNIFF_STATE
, false);
575 BT_MBOX_PRINT(3, A2DP_STATE
, false);
576 BT_MBOX_PRINT(3, ACL_STATE
, false);
577 BT_MBOX_PRINT(3, MSTR_STATE
, false);
578 BT_MBOX_PRINT(3, OBX_STATE
, false);
579 BT_MBOX_PRINT(3, OPEN_CON_2
, false);
580 BT_MBOX_PRINT(3, TRAFFIC_LOAD
, false);
581 BT_MBOX_PRINT(3, CHL_SEQN_LSB
, false);
582 BT_MBOX_PRINT(3, INBAND_P
, false);
583 BT_MBOX_PRINT(3, MSG_TYPE_2
, false);
584 BT_MBOX_PRINT(3, SSN_2
, false);
585 BT_MBOX_PRINT(3, UPDATE_REQUEST
, true);
587 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_status = %d\n",
589 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_open_conn = %d\n",
590 notif
->bt_open_conn
);
591 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_traffic_load = %d\n",
592 notif
->bt_traffic_load
);
593 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_agg_traffic_load = %d\n",
594 notif
->bt_agg_traffic_load
);
595 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_ci_compliance = %d\n",
596 notif
->bt_ci_compliance
);
598 mutex_unlock(&mvm
->mutex
);
600 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
607 #define PRINT_STATS_LE32(_str, _val) \
608 pos += scnprintf(buf + pos, bufsz - pos, \
612 static ssize_t
iwl_dbgfs_fw_rx_stats_read(struct file
*file
,
613 char __user
*user_buf
, size_t count
,
616 struct iwl_mvm
*mvm
= file
->private_data
;
617 static const char *fmt_table
= "\t%-30s %10u\n";
618 static const char *fmt_header
= "%-32s\n";
622 int bufsz
= sizeof(struct mvm_statistics_rx_phy
) * 20 +
623 sizeof(struct mvm_statistics_rx_non_phy
) * 10 +
624 sizeof(struct mvm_statistics_rx_ht_phy
) * 10 + 200;
625 struct mvm_statistics_rx_phy
*ofdm
;
626 struct mvm_statistics_rx_phy
*cck
;
627 struct mvm_statistics_rx_non_phy
*general
;
628 struct mvm_statistics_rx_ht_phy
*ht
;
630 buf
= kzalloc(bufsz
, GFP_KERNEL
);
634 mutex_lock(&mvm
->mutex
);
636 ofdm
= &mvm
->rx_stats
.ofdm
;
637 cck
= &mvm
->rx_stats
.cck
;
638 general
= &mvm
->rx_stats
.general
;
639 ht
= &mvm
->rx_stats
.ofdm_ht
;
641 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
642 "Statistics_Rx - OFDM");
643 PRINT_STATS_LE32("ina_cnt", ofdm
->ina_cnt
);
644 PRINT_STATS_LE32("fina_cnt", ofdm
->fina_cnt
);
645 PRINT_STATS_LE32("plcp_err", ofdm
->plcp_err
);
646 PRINT_STATS_LE32("crc32_err", ofdm
->crc32_err
);
647 PRINT_STATS_LE32("overrun_err", ofdm
->overrun_err
);
648 PRINT_STATS_LE32("early_overrun_err", ofdm
->early_overrun_err
);
649 PRINT_STATS_LE32("crc32_good", ofdm
->crc32_good
);
650 PRINT_STATS_LE32("false_alarm_cnt", ofdm
->false_alarm_cnt
);
651 PRINT_STATS_LE32("fina_sync_err_cnt", ofdm
->fina_sync_err_cnt
);
652 PRINT_STATS_LE32("sfd_timeout", ofdm
->sfd_timeout
);
653 PRINT_STATS_LE32("fina_timeout", ofdm
->fina_timeout
);
654 PRINT_STATS_LE32("unresponded_rts", ofdm
->unresponded_rts
);
655 PRINT_STATS_LE32("rxe_frame_lmt_overrun",
656 ofdm
->rxe_frame_limit_overrun
);
657 PRINT_STATS_LE32("sent_ack_cnt", ofdm
->sent_ack_cnt
);
658 PRINT_STATS_LE32("sent_cts_cnt", ofdm
->sent_cts_cnt
);
659 PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm
->sent_ba_rsp_cnt
);
660 PRINT_STATS_LE32("dsp_self_kill", ofdm
->dsp_self_kill
);
661 PRINT_STATS_LE32("mh_format_err", ofdm
->mh_format_err
);
662 PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm
->re_acq_main_rssi_sum
);
663 PRINT_STATS_LE32("reserved", ofdm
->reserved
);
665 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
666 "Statistics_Rx - CCK");
667 PRINT_STATS_LE32("ina_cnt", cck
->ina_cnt
);
668 PRINT_STATS_LE32("fina_cnt", cck
->fina_cnt
);
669 PRINT_STATS_LE32("plcp_err", cck
->plcp_err
);
670 PRINT_STATS_LE32("crc32_err", cck
->crc32_err
);
671 PRINT_STATS_LE32("overrun_err", cck
->overrun_err
);
672 PRINT_STATS_LE32("early_overrun_err", cck
->early_overrun_err
);
673 PRINT_STATS_LE32("crc32_good", cck
->crc32_good
);
674 PRINT_STATS_LE32("false_alarm_cnt", cck
->false_alarm_cnt
);
675 PRINT_STATS_LE32("fina_sync_err_cnt", cck
->fina_sync_err_cnt
);
676 PRINT_STATS_LE32("sfd_timeout", cck
->sfd_timeout
);
677 PRINT_STATS_LE32("fina_timeout", cck
->fina_timeout
);
678 PRINT_STATS_LE32("unresponded_rts", cck
->unresponded_rts
);
679 PRINT_STATS_LE32("rxe_frame_lmt_overrun",
680 cck
->rxe_frame_limit_overrun
);
681 PRINT_STATS_LE32("sent_ack_cnt", cck
->sent_ack_cnt
);
682 PRINT_STATS_LE32("sent_cts_cnt", cck
->sent_cts_cnt
);
683 PRINT_STATS_LE32("sent_ba_rsp_cnt", cck
->sent_ba_rsp_cnt
);
684 PRINT_STATS_LE32("dsp_self_kill", cck
->dsp_self_kill
);
685 PRINT_STATS_LE32("mh_format_err", cck
->mh_format_err
);
686 PRINT_STATS_LE32("re_acq_main_rssi_sum", cck
->re_acq_main_rssi_sum
);
687 PRINT_STATS_LE32("reserved", cck
->reserved
);
689 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
690 "Statistics_Rx - GENERAL");
691 PRINT_STATS_LE32("bogus_cts", general
->bogus_cts
);
692 PRINT_STATS_LE32("bogus_ack", general
->bogus_ack
);
693 PRINT_STATS_LE32("non_bssid_frames", general
->non_bssid_frames
);
694 PRINT_STATS_LE32("filtered_frames", general
->filtered_frames
);
695 PRINT_STATS_LE32("non_channel_beacons", general
->non_channel_beacons
);
696 PRINT_STATS_LE32("channel_beacons", general
->channel_beacons
);
697 PRINT_STATS_LE32("num_missed_bcon", general
->num_missed_bcon
);
698 PRINT_STATS_LE32("adc_rx_saturation_time",
699 general
->adc_rx_saturation_time
);
700 PRINT_STATS_LE32("ina_detection_search_time",
701 general
->ina_detection_search_time
);
702 PRINT_STATS_LE32("beacon_silence_rssi_a",
703 general
->beacon_silence_rssi_a
);
704 PRINT_STATS_LE32("beacon_silence_rssi_b",
705 general
->beacon_silence_rssi_b
);
706 PRINT_STATS_LE32("beacon_silence_rssi_c",
707 general
->beacon_silence_rssi_c
);
708 PRINT_STATS_LE32("interference_data_flag",
709 general
->interference_data_flag
);
710 PRINT_STATS_LE32("channel_load", general
->channel_load
);
711 PRINT_STATS_LE32("dsp_false_alarms", general
->dsp_false_alarms
);
712 PRINT_STATS_LE32("beacon_rssi_a", general
->beacon_rssi_a
);
713 PRINT_STATS_LE32("beacon_rssi_b", general
->beacon_rssi_b
);
714 PRINT_STATS_LE32("beacon_rssi_c", general
->beacon_rssi_c
);
715 PRINT_STATS_LE32("beacon_energy_a", general
->beacon_energy_a
);
716 PRINT_STATS_LE32("beacon_energy_b", general
->beacon_energy_b
);
717 PRINT_STATS_LE32("beacon_energy_c", general
->beacon_energy_c
);
718 PRINT_STATS_LE32("num_bt_kills", general
->num_bt_kills
);
719 PRINT_STATS_LE32("directed_data_mpdu", general
->directed_data_mpdu
);
721 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
722 "Statistics_Rx - HT");
723 PRINT_STATS_LE32("plcp_err", ht
->plcp_err
);
724 PRINT_STATS_LE32("overrun_err", ht
->overrun_err
);
725 PRINT_STATS_LE32("early_overrun_err", ht
->early_overrun_err
);
726 PRINT_STATS_LE32("crc32_good", ht
->crc32_good
);
727 PRINT_STATS_LE32("crc32_err", ht
->crc32_err
);
728 PRINT_STATS_LE32("mh_format_err", ht
->mh_format_err
);
729 PRINT_STATS_LE32("agg_crc32_good", ht
->agg_crc32_good
);
730 PRINT_STATS_LE32("agg_mpdu_cnt", ht
->agg_mpdu_cnt
);
731 PRINT_STATS_LE32("agg_cnt", ht
->agg_cnt
);
732 PRINT_STATS_LE32("unsupport_mcs", ht
->unsupport_mcs
);
734 mutex_unlock(&mvm
->mutex
);
736 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
741 #undef PRINT_STAT_LE32
743 static ssize_t
iwl_dbgfs_fw_restart_write(struct file
*file
,
744 const char __user
*user_buf
,
745 size_t count
, loff_t
*ppos
)
747 struct iwl_mvm
*mvm
= file
->private_data
;
750 mutex_lock(&mvm
->mutex
);
752 /* allow one more restart that we're provoking here */
753 if (mvm
->restart_fw
>= 0)
756 /* take the return value to make compiler happy - it will fail anyway */
757 ret
= iwl_mvm_send_cmd_pdu(mvm
, REPLY_ERROR
, CMD_SYNC
, 0, NULL
);
759 mutex_unlock(&mvm
->mutex
);
764 static void iwl_dbgfs_update_bf(struct ieee80211_vif
*vif
,
765 enum iwl_dbgfs_bf_mask param
, int value
)
767 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
768 struct iwl_dbgfs_bf
*dbgfs_bf
= &mvmvif
->dbgfs_bf
;
770 dbgfs_bf
->mask
|= param
;
773 case MVM_DEBUGFS_BF_ENERGY_DELTA
:
774 dbgfs_bf
->bf_energy_delta
= value
;
776 case MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA
:
777 dbgfs_bf
->bf_roaming_energy_delta
= value
;
779 case MVM_DEBUGFS_BF_ROAMING_STATE
:
780 dbgfs_bf
->bf_roaming_state
= value
;
782 case MVM_DEBUGFS_BF_TEMP_THRESHOLD
:
783 dbgfs_bf
->bf_temp_threshold
= value
;
785 case MVM_DEBUGFS_BF_TEMP_FAST_FILTER
:
786 dbgfs_bf
->bf_temp_fast_filter
= value
;
788 case MVM_DEBUGFS_BF_TEMP_SLOW_FILTER
:
789 dbgfs_bf
->bf_temp_slow_filter
= value
;
791 case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
:
792 dbgfs_bf
->bf_enable_beacon_filter
= value
;
794 case MVM_DEBUGFS_BF_DEBUG_FLAG
:
795 dbgfs_bf
->bf_debug_flag
= value
;
797 case MVM_DEBUGFS_BF_ESCAPE_TIMER
:
798 dbgfs_bf
->bf_escape_timer
= value
;
800 case MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT
:
801 dbgfs_bf
->ba_enable_beacon_abort
= value
;
803 case MVM_DEBUGFS_BA_ESCAPE_TIMER
:
804 dbgfs_bf
->ba_escape_timer
= value
;
809 static ssize_t
iwl_dbgfs_bf_params_write(struct file
*file
,
810 const char __user
*user_buf
,
811 size_t count
, loff_t
*ppos
)
813 struct ieee80211_vif
*vif
= file
->private_data
;
814 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
815 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
816 enum iwl_dbgfs_bf_mask param
;
822 memset(buf
, 0, sizeof(buf
));
823 buf_size
= min(count
, sizeof(buf
) - 1);
824 if (copy_from_user(buf
, user_buf
, buf_size
))
827 if (!strncmp("bf_energy_delta=", buf
, 16)) {
828 if (sscanf(buf
+16, "%d", &value
) != 1)
830 if (value
< IWL_BF_ENERGY_DELTA_MIN
||
831 value
> IWL_BF_ENERGY_DELTA_MAX
)
833 param
= MVM_DEBUGFS_BF_ENERGY_DELTA
;
834 } else if (!strncmp("bf_roaming_energy_delta=", buf
, 24)) {
835 if (sscanf(buf
+24, "%d", &value
) != 1)
837 if (value
< IWL_BF_ROAMING_ENERGY_DELTA_MIN
||
838 value
> IWL_BF_ROAMING_ENERGY_DELTA_MAX
)
840 param
= MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA
;
841 } else if (!strncmp("bf_roaming_state=", buf
, 17)) {
842 if (sscanf(buf
+17, "%d", &value
) != 1)
844 if (value
< IWL_BF_ROAMING_STATE_MIN
||
845 value
> IWL_BF_ROAMING_STATE_MAX
)
847 param
= MVM_DEBUGFS_BF_ROAMING_STATE
;
848 } else if (!strncmp("bf_temp_threshold=", buf
, 18)) {
849 if (sscanf(buf
+18, "%d", &value
) != 1)
851 if (value
< IWL_BF_TEMP_THRESHOLD_MIN
||
852 value
> IWL_BF_TEMP_THRESHOLD_MAX
)
854 param
= MVM_DEBUGFS_BF_TEMP_THRESHOLD
;
855 } else if (!strncmp("bf_temp_fast_filter=", buf
, 20)) {
856 if (sscanf(buf
+20, "%d", &value
) != 1)
858 if (value
< IWL_BF_TEMP_FAST_FILTER_MIN
||
859 value
> IWL_BF_TEMP_FAST_FILTER_MAX
)
861 param
= MVM_DEBUGFS_BF_TEMP_FAST_FILTER
;
862 } else if (!strncmp("bf_temp_slow_filter=", buf
, 20)) {
863 if (sscanf(buf
+20, "%d", &value
) != 1)
865 if (value
< IWL_BF_TEMP_SLOW_FILTER_MIN
||
866 value
> IWL_BF_TEMP_SLOW_FILTER_MAX
)
868 param
= MVM_DEBUGFS_BF_TEMP_SLOW_FILTER
;
869 } else if (!strncmp("bf_enable_beacon_filter=", buf
, 24)) {
870 if (sscanf(buf
+24, "%d", &value
) != 1)
872 if (value
< 0 || value
> 1)
874 param
= MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
;
875 } else if (!strncmp("bf_debug_flag=", buf
, 14)) {
876 if (sscanf(buf
+14, "%d", &value
) != 1)
878 if (value
< 0 || value
> 1)
880 param
= MVM_DEBUGFS_BF_DEBUG_FLAG
;
881 } else if (!strncmp("bf_escape_timer=", buf
, 16)) {
882 if (sscanf(buf
+16, "%d", &value
) != 1)
884 if (value
< IWL_BF_ESCAPE_TIMER_MIN
||
885 value
> IWL_BF_ESCAPE_TIMER_MAX
)
887 param
= MVM_DEBUGFS_BF_ESCAPE_TIMER
;
888 } else if (!strncmp("ba_escape_timer=", buf
, 16)) {
889 if (sscanf(buf
+16, "%d", &value
) != 1)
891 if (value
< IWL_BA_ESCAPE_TIMER_MIN
||
892 value
> IWL_BA_ESCAPE_TIMER_MAX
)
894 param
= MVM_DEBUGFS_BA_ESCAPE_TIMER
;
895 } else if (!strncmp("ba_enable_beacon_abort=", buf
, 23)) {
896 if (sscanf(buf
+23, "%d", &value
) != 1)
898 if (value
< 0 || value
> 1)
900 param
= MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT
;
905 mutex_lock(&mvm
->mutex
);
906 iwl_dbgfs_update_bf(vif
, param
, value
);
907 if (param
== MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
&& !value
) {
908 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
);
910 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
);
912 mutex_unlock(&mvm
->mutex
);
917 static ssize_t
iwl_dbgfs_bf_params_read(struct file
*file
,
918 char __user
*user_buf
,
919 size_t count
, loff_t
*ppos
)
921 struct ieee80211_vif
*vif
= file
->private_data
;
922 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
925 const size_t bufsz
= sizeof(buf
);
926 struct iwl_beacon_filter_cmd cmd
= {
927 IWL_BF_CMD_CONFIG_DEFAULTS
,
928 .bf_enable_beacon_filter
=
929 cpu_to_le32(IWL_BF_ENABLE_BEACON_FILTER_DEFAULT
),
930 .ba_enable_beacon_abort
=
931 cpu_to_le32(IWL_BA_ENABLE_BEACON_ABORT_DEFAULT
),
934 iwl_mvm_beacon_filter_debugfs_parameters(vif
, &cmd
);
935 if (mvmvif
->bf_data
.bf_enabled
)
936 cmd
.bf_enable_beacon_filter
= cpu_to_le32(1);
938 cmd
.bf_enable_beacon_filter
= 0;
940 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_energy_delta = %d\n",
941 le32_to_cpu(cmd
.bf_energy_delta
));
942 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_roaming_energy_delta = %d\n",
943 le32_to_cpu(cmd
.bf_roaming_energy_delta
));
944 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_roaming_state = %d\n",
945 le32_to_cpu(cmd
.bf_roaming_state
));
946 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_temp_threshold = %d\n",
947 le32_to_cpu(cmd
.bf_temp_threshold
));
948 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_temp_fast_filter = %d\n",
949 le32_to_cpu(cmd
.bf_temp_fast_filter
));
950 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_temp_slow_filter = %d\n",
951 le32_to_cpu(cmd
.bf_temp_slow_filter
));
952 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_enable_beacon_filter = %d\n",
953 le32_to_cpu(cmd
.bf_enable_beacon_filter
));
954 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_debug_flag = %d\n",
955 le32_to_cpu(cmd
.bf_debug_flag
));
956 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_escape_timer = %d\n",
957 le32_to_cpu(cmd
.bf_escape_timer
));
958 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "ba_escape_timer = %d\n",
959 le32_to_cpu(cmd
.ba_escape_timer
));
960 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "ba_enable_beacon_abort = %d\n",
961 le32_to_cpu(cmd
.ba_enable_beacon_abort
));
963 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
966 #ifdef CONFIG_PM_SLEEP
967 static ssize_t
iwl_dbgfs_d3_sram_write(struct file
*file
,
968 const char __user
*user_buf
,
969 size_t count
, loff_t
*ppos
)
971 struct iwl_mvm
*mvm
= file
->private_data
;
975 if (copy_from_user(buf
, user_buf
, sizeof(buf
)))
978 if (sscanf(buf
, "%d", &store
) != 1)
981 mvm
->store_d3_resume_sram
= store
;
986 static ssize_t
iwl_dbgfs_d3_sram_read(struct file
*file
, char __user
*user_buf
,
987 size_t count
, loff_t
*ppos
)
989 struct iwl_mvm
*mvm
= file
->private_data
;
990 const struct fw_img
*img
;
991 int ofs
, len
, pos
= 0;
994 u8
*ptr
= mvm
->d3_resume_sram
;
996 img
= &mvm
->fw
->img
[IWL_UCODE_WOWLAN
];
997 len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
999 bufsz
= len
* 4 + 256;
1000 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1004 pos
+= scnprintf(buf
, bufsz
, "D3 SRAM capture: %sabled\n",
1005 mvm
->store_d3_resume_sram
? "en" : "dis");
1008 for (ofs
= 0; ofs
< len
; ofs
+= 16) {
1009 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1011 hex_dump_to_buffer(ptr
+ ofs
, 16, 16, 1, buf
+ pos
,
1012 bufsz
- pos
, false);
1013 pos
+= strlen(buf
+ pos
);
1014 if (bufsz
- pos
> 0)
1018 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1019 "(no data captured)\n");
1022 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1030 #define MVM_DEBUGFS_READ_FILE_OPS(name) \
1031 static const struct file_operations iwl_dbgfs_##name##_ops = { \
1032 .read = iwl_dbgfs_##name##_read, \
1033 .open = simple_open, \
1034 .llseek = generic_file_llseek, \
1037 #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name) \
1038 static const struct file_operations iwl_dbgfs_##name##_ops = { \
1039 .write = iwl_dbgfs_##name##_write, \
1040 .read = iwl_dbgfs_##name##_read, \
1041 .open = simple_open, \
1042 .llseek = generic_file_llseek, \
1045 #define MVM_DEBUGFS_WRITE_FILE_OPS(name) \
1046 static const struct file_operations iwl_dbgfs_##name##_ops = { \
1047 .write = iwl_dbgfs_##name##_write, \
1048 .open = simple_open, \
1049 .llseek = generic_file_llseek, \
1052 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) do { \
1053 if (!debugfs_create_file(#name, mode, parent, mvm, \
1054 &iwl_dbgfs_##name##_ops)) \
1058 #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
1059 if (!debugfs_create_file(#name, mode, parent, vif, \
1060 &iwl_dbgfs_##name##_ops)) \
1064 /* Device wide debugfs entries */
1065 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush
);
1066 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain
);
1067 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram
);
1068 MVM_DEBUGFS_READ_FILE_OPS(stations
);
1069 MVM_DEBUGFS_READ_FILE_OPS(bt_notif
);
1070 MVM_DEBUGFS_WRITE_FILE_OPS(power_down_allow
);
1071 MVM_DEBUGFS_WRITE_FILE_OPS(power_down_d3_allow
);
1072 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats
);
1073 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart
);
1074 #ifdef CONFIG_PM_SLEEP
1075 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram
);
1078 /* Interface specific debugfs entries */
1079 MVM_DEBUGFS_READ_FILE_OPS(mac_params
);
1080 MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params
);
1081 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params
);
1083 int iwl_mvm_dbgfs_register(struct iwl_mvm
*mvm
, struct dentry
*dbgfs_dir
)
1087 mvm
->debugfs_dir
= dbgfs_dir
;
1089 MVM_DEBUGFS_ADD_FILE(tx_flush
, mvm
->debugfs_dir
, S_IWUSR
);
1090 MVM_DEBUGFS_ADD_FILE(sta_drain
, mvm
->debugfs_dir
, S_IWUSR
);
1091 MVM_DEBUGFS_ADD_FILE(sram
, mvm
->debugfs_dir
, S_IWUSR
| S_IRUSR
);
1092 MVM_DEBUGFS_ADD_FILE(stations
, dbgfs_dir
, S_IRUSR
);
1093 MVM_DEBUGFS_ADD_FILE(bt_notif
, dbgfs_dir
, S_IRUSR
);
1094 MVM_DEBUGFS_ADD_FILE(power_down_allow
, mvm
->debugfs_dir
, S_IWUSR
);
1095 MVM_DEBUGFS_ADD_FILE(power_down_d3_allow
, mvm
->debugfs_dir
, S_IWUSR
);
1096 MVM_DEBUGFS_ADD_FILE(fw_rx_stats
, mvm
->debugfs_dir
, S_IRUSR
);
1097 MVM_DEBUGFS_ADD_FILE(fw_restart
, mvm
->debugfs_dir
, S_IWUSR
);
1098 #ifdef CONFIG_PM_SLEEP
1099 MVM_DEBUGFS_ADD_FILE(d3_sram
, mvm
->debugfs_dir
, S_IRUSR
| S_IWUSR
);
1100 MVM_DEBUGFS_ADD_FILE(d3_test
, mvm
->debugfs_dir
, S_IRUSR
);
1101 if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR
| S_IWUSR
,
1102 mvm
->debugfs_dir
, &mvm
->d3_wake_sysassert
))
1107 * Create a symlink with mac80211. It will be removed when mac80211
1108 * exists (before the opmode exists which removes the target.)
1110 snprintf(buf
, 100, "../../%s/%s",
1111 dbgfs_dir
->d_parent
->d_parent
->d_name
.name
,
1112 dbgfs_dir
->d_parent
->d_name
.name
);
1113 if (!debugfs_create_symlink("iwlwifi", mvm
->hw
->wiphy
->debugfsdir
, buf
))
1118 IWL_ERR(mvm
, "Can't create the mvm debugfs directory\n");
1122 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1124 struct dentry
*dbgfs_dir
= vif
->debugfs_dir
;
1125 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1129 * Check if debugfs directory already exist before creating it.
1130 * This may happen when, for example, resetting hw or suspend-resume
1132 if (!dbgfs_dir
|| mvmvif
->dbgfs_dir
)
1135 mvmvif
->dbgfs_dir
= debugfs_create_dir("iwlmvm", dbgfs_dir
);
1136 mvmvif
->dbgfs_data
= mvm
;
1138 if (!mvmvif
->dbgfs_dir
) {
1139 IWL_ERR(mvm
, "Failed to create debugfs directory under %s\n",
1140 dbgfs_dir
->d_name
.name
);
1144 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
&&
1145 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
)
1146 MVM_DEBUGFS_ADD_FILE_VIF(pm_params
, mvmvif
->dbgfs_dir
, S_IWUSR
|
1149 MVM_DEBUGFS_ADD_FILE_VIF(mac_params
, mvmvif
->dbgfs_dir
,
1152 if (vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
&&
1153 mvmvif
== mvm
->bf_allowed_vif
)
1154 MVM_DEBUGFS_ADD_FILE_VIF(bf_params
, mvmvif
->dbgfs_dir
,
1158 * Create symlink for convenience pointing to interface specific
1159 * debugfs entries for the driver. For example, under
1160 * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
1162 * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
1164 snprintf(buf
, 100, "../../../%s/%s/%s/%s",
1165 dbgfs_dir
->d_parent
->d_parent
->d_name
.name
,
1166 dbgfs_dir
->d_parent
->d_name
.name
,
1167 dbgfs_dir
->d_name
.name
,
1168 mvmvif
->dbgfs_dir
->d_name
.name
);
1170 mvmvif
->dbgfs_slink
= debugfs_create_symlink(dbgfs_dir
->d_name
.name
,
1171 mvm
->debugfs_dir
, buf
);
1172 if (!mvmvif
->dbgfs_slink
)
1173 IWL_ERR(mvm
, "Can't create debugfs symbolic link under %s\n",
1174 dbgfs_dir
->d_name
.name
);
1177 IWL_ERR(mvm
, "Can't create debugfs entity\n");
1180 void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1182 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1184 debugfs_remove(mvmvif
->dbgfs_slink
);
1185 mvmvif
->dbgfs_slink
= NULL
;
1187 debugfs_remove_recursive(mvmvif
->dbgfs_dir
);
1188 mvmvif
->dbgfs_dir
= NULL
;