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)
123 mutex_lock(&mvm
->mutex
);
125 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[sta_id
],
126 lockdep_is_held(&mvm
->mutex
));
127 if (IS_ERR_OR_NULL(sta
))
130 ret
= iwl_mvm_drain_sta(mvm
, (void *)sta
->drv_priv
, drain
) ? :
133 mutex_unlock(&mvm
->mutex
);
138 static ssize_t
iwl_dbgfs_sram_read(struct file
*file
, char __user
*user_buf
,
139 size_t count
, loff_t
*ppos
)
141 struct iwl_mvm
*mvm
= file
->private_data
;
142 const struct fw_img
*img
;
143 int ofs
, len
, pos
= 0;
148 if (!mvm
->ucode_loaded
)
151 /* default is to dump the entire data segment */
152 if (!mvm
->dbgfs_sram_offset
&& !mvm
->dbgfs_sram_len
) {
153 img
= &mvm
->fw
->img
[mvm
->cur_ucode
];
154 ofs
= img
->sec
[IWL_UCODE_SECTION_DATA
].offset
;
155 len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
157 ofs
= mvm
->dbgfs_sram_offset
;
158 len
= mvm
->dbgfs_sram_len
;
161 bufsz
= len
* 4 + 256;
162 buf
= kzalloc(bufsz
, GFP_KERNEL
);
166 ptr
= kzalloc(len
, GFP_KERNEL
);
172 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_len: 0x%x\n", len
);
173 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "sram_offset: 0x%x\n", ofs
);
175 iwl_trans_read_mem_bytes(mvm
->trans
, ofs
, ptr
, len
);
176 for (ofs
= 0; ofs
< len
; ofs
+= 16) {
177 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "0x%.4x ", ofs
);
178 hex_dump_to_buffer(ptr
+ ofs
, 16, 16, 1, buf
+ pos
,
180 pos
+= strlen(buf
+ pos
);
185 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
193 static ssize_t
iwl_dbgfs_sram_write(struct file
*file
,
194 const char __user
*user_buf
, size_t count
,
197 struct iwl_mvm
*mvm
= file
->private_data
;
202 memset(buf
, 0, sizeof(buf
));
203 buf_size
= min(count
, sizeof(buf
) - 1);
204 if (copy_from_user(buf
, user_buf
, buf_size
))
207 if (sscanf(buf
, "%x,%x", &offset
, &len
) == 2) {
208 if ((offset
& 0x3) || (len
& 0x3))
210 mvm
->dbgfs_sram_offset
= offset
;
211 mvm
->dbgfs_sram_len
= len
;
213 mvm
->dbgfs_sram_offset
= 0;
214 mvm
->dbgfs_sram_len
= 0;
220 static ssize_t
iwl_dbgfs_stations_read(struct file
*file
, char __user
*user_buf
,
221 size_t count
, loff_t
*ppos
)
223 struct iwl_mvm
*mvm
= file
->private_data
;
224 struct ieee80211_sta
*sta
;
226 int i
, pos
= 0, bufsz
= sizeof(buf
);
228 mutex_lock(&mvm
->mutex
);
230 for (i
= 0; i
< IWL_MVM_STATION_COUNT
; i
++) {
231 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%.2d: ", i
);
232 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[i
],
233 lockdep_is_held(&mvm
->mutex
));
235 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "N/A\n");
236 else if (IS_ERR(sta
))
237 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%ld\n",
240 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "%pM\n",
244 mutex_unlock(&mvm
->mutex
);
246 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
249 static ssize_t
iwl_dbgfs_disable_power_off_read(struct file
*file
,
250 char __user
*user_buf
,
251 size_t count
, loff_t
*ppos
)
253 struct iwl_mvm
*mvm
= file
->private_data
;
255 int bufsz
= sizeof(buf
);
258 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "disable_power_off_d0=%d\n",
259 mvm
->disable_power_off
);
260 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "disable_power_off_d3=%d\n",
261 mvm
->disable_power_off_d3
);
263 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
266 static ssize_t
iwl_dbgfs_disable_power_off_write(struct file
*file
,
267 const char __user
*user_buf
,
268 size_t count
, loff_t
*ppos
)
270 struct iwl_mvm
*mvm
= file
->private_data
;
275 if (!mvm
->ucode_loaded
)
278 count
= min_t(size_t, count
, sizeof(buf
) - 1);
279 if (copy_from_user(buf
, user_buf
, count
))
282 if (!strncmp("disable_power_off_d0=", buf
, 21)) {
283 if (sscanf(buf
+ 21, "%d", &val
) != 1)
285 mvm
->disable_power_off
= val
;
286 } else if (!strncmp("disable_power_off_d3=", buf
, 21)) {
287 if (sscanf(buf
+ 21, "%d", &val
) != 1)
289 mvm
->disable_power_off_d3
= val
;
294 mutex_lock(&mvm
->mutex
);
295 ret
= iwl_mvm_power_update_device_mode(mvm
);
296 mutex_unlock(&mvm
->mutex
);
301 static void iwl_dbgfs_update_pm(struct iwl_mvm
*mvm
,
302 struct ieee80211_vif
*vif
,
303 enum iwl_dbgfs_pm_mask param
, int val
)
305 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
306 struct iwl_dbgfs_pm
*dbgfs_pm
= &mvmvif
->dbgfs_pm
;
308 dbgfs_pm
->mask
|= param
;
311 case MVM_DEBUGFS_PM_KEEP_ALIVE
: {
312 struct ieee80211_hw
*hw
= mvm
->hw
;
313 int dtimper
= hw
->conf
.ps_dtim_period
?: 1;
314 int dtimper_msec
= dtimper
* vif
->bss_conf
.beacon_int
;
316 IWL_DEBUG_POWER(mvm
, "debugfs: set keep_alive= %d sec\n", val
);
317 if (val
* MSEC_PER_SEC
< 3 * dtimper_msec
) {
319 "debugfs: keep alive period (%ld msec) is less than minimum required (%d msec)\n",
320 val
* MSEC_PER_SEC
, 3 * dtimper_msec
);
322 dbgfs_pm
->keep_alive_seconds
= val
;
325 case MVM_DEBUGFS_PM_SKIP_OVER_DTIM
:
326 IWL_DEBUG_POWER(mvm
, "skip_over_dtim %s\n",
327 val
? "enabled" : "disabled");
328 dbgfs_pm
->skip_over_dtim
= val
;
330 case MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS
:
331 IWL_DEBUG_POWER(mvm
, "skip_dtim_periods=%d\n", val
);
332 dbgfs_pm
->skip_dtim_periods
= val
;
334 case MVM_DEBUGFS_PM_RX_DATA_TIMEOUT
:
335 IWL_DEBUG_POWER(mvm
, "rx_data_timeout=%d\n", val
);
336 dbgfs_pm
->rx_data_timeout
= val
;
338 case MVM_DEBUGFS_PM_TX_DATA_TIMEOUT
:
339 IWL_DEBUG_POWER(mvm
, "tx_data_timeout=%d\n", val
);
340 dbgfs_pm
->tx_data_timeout
= val
;
342 case MVM_DEBUGFS_PM_DISABLE_POWER_OFF
:
343 IWL_DEBUG_POWER(mvm
, "disable_power_off=%d\n", val
);
344 dbgfs_pm
->disable_power_off
= val
;
346 case MVM_DEBUGFS_PM_LPRX_ENA
:
347 IWL_DEBUG_POWER(mvm
, "lprx %s\n", val
? "enabled" : "disabled");
348 dbgfs_pm
->lprx_ena
= val
;
350 case MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD
:
351 IWL_DEBUG_POWER(mvm
, "lprx_rssi_threshold=%d\n", val
);
352 dbgfs_pm
->lprx_rssi_threshold
= val
;
354 case MVM_DEBUGFS_PM_SNOOZE_ENABLE
:
355 IWL_DEBUG_POWER(mvm
, "snooze_enable=%d\n", val
);
356 dbgfs_pm
->snooze_ena
= val
;
361 static ssize_t
iwl_dbgfs_pm_params_write(struct file
*file
,
362 const char __user
*user_buf
,
363 size_t count
, loff_t
*ppos
)
365 struct ieee80211_vif
*vif
= file
->private_data
;
366 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
367 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
368 enum iwl_dbgfs_pm_mask param
;
373 count
= min_t(size_t, count
, sizeof(buf
) - 1);
374 if (copy_from_user(buf
, user_buf
, count
))
377 if (!strncmp("keep_alive=", buf
, 11)) {
378 if (sscanf(buf
+ 11, "%d", &val
) != 1)
380 param
= MVM_DEBUGFS_PM_KEEP_ALIVE
;
381 } else if (!strncmp("skip_over_dtim=", buf
, 15)) {
382 if (sscanf(buf
+ 15, "%d", &val
) != 1)
384 param
= MVM_DEBUGFS_PM_SKIP_OVER_DTIM
;
385 } else if (!strncmp("skip_dtim_periods=", buf
, 18)) {
386 if (sscanf(buf
+ 18, "%d", &val
) != 1)
388 param
= MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS
;
389 } else if (!strncmp("rx_data_timeout=", buf
, 16)) {
390 if (sscanf(buf
+ 16, "%d", &val
) != 1)
392 param
= MVM_DEBUGFS_PM_RX_DATA_TIMEOUT
;
393 } else if (!strncmp("tx_data_timeout=", buf
, 16)) {
394 if (sscanf(buf
+ 16, "%d", &val
) != 1)
396 param
= MVM_DEBUGFS_PM_TX_DATA_TIMEOUT
;
397 } else if (!strncmp("disable_power_off=", buf
, 18) &&
398 !(mvm
->fw
->ucode_capa
.flags
&
399 IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD
)) {
400 if (sscanf(buf
+ 18, "%d", &val
) != 1)
402 param
= MVM_DEBUGFS_PM_DISABLE_POWER_OFF
;
403 } else if (!strncmp("lprx=", buf
, 5)) {
404 if (sscanf(buf
+ 5, "%d", &val
) != 1)
406 param
= MVM_DEBUGFS_PM_LPRX_ENA
;
407 } else if (!strncmp("lprx_rssi_threshold=", buf
, 20)) {
408 if (sscanf(buf
+ 20, "%d", &val
) != 1)
410 if (val
> POWER_LPRX_RSSI_THRESHOLD_MAX
|| val
<
411 POWER_LPRX_RSSI_THRESHOLD_MIN
)
413 param
= MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD
;
414 } else if (!strncmp("snooze_enable=", buf
, 14)) {
415 if (sscanf(buf
+ 14, "%d", &val
) != 1)
417 param
= MVM_DEBUGFS_PM_SNOOZE_ENABLE
;
422 mutex_lock(&mvm
->mutex
);
423 iwl_dbgfs_update_pm(mvm
, vif
, param
, val
);
424 ret
= iwl_mvm_power_update_mode(mvm
, vif
);
425 mutex_unlock(&mvm
->mutex
);
430 static ssize_t
iwl_dbgfs_pm_params_read(struct file
*file
,
431 char __user
*user_buf
,
432 size_t count
, loff_t
*ppos
)
434 struct ieee80211_vif
*vif
= file
->private_data
;
435 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
436 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
438 int bufsz
= sizeof(buf
);
441 pos
= iwl_mvm_power_dbgfs_read(mvm
, vif
, buf
, bufsz
);
443 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
446 static ssize_t
iwl_dbgfs_mac_params_read(struct file
*file
,
447 char __user
*user_buf
,
448 size_t count
, loff_t
*ppos
)
450 struct ieee80211_vif
*vif
= file
->private_data
;
451 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
452 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
454 struct ieee80211_chanctx_conf
*chanctx_conf
;
456 int bufsz
= sizeof(buf
);
460 mutex_lock(&mvm
->mutex
);
462 ap_sta_id
= mvmvif
->ap_sta_id
;
464 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "mac id/color: %d / %d\n",
465 mvmvif
->id
, mvmvif
->color
);
466 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bssid: %pM\n",
467 vif
->bss_conf
.bssid
);
468 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "QoS:\n");
469 for (i
= 0; i
< ARRAY_SIZE(mvmvif
->queue_params
); i
++) {
470 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
471 "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
472 i
, mvmvif
->queue_params
[i
].txop
,
473 mvmvif
->queue_params
[i
].cw_min
,
474 mvmvif
->queue_params
[i
].cw_max
,
475 mvmvif
->queue_params
[i
].aifs
,
476 mvmvif
->queue_params
[i
].uapsd
);
479 if (vif
->type
== NL80211_IFTYPE_STATION
&&
480 ap_sta_id
!= IWL_MVM_STATION_COUNT
) {
481 struct ieee80211_sta
*sta
;
482 struct iwl_mvm_sta
*mvm_sta
;
484 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[ap_sta_id
],
485 lockdep_is_held(&mvm
->mutex
));
486 mvm_sta
= (void *)sta
->drv_priv
;
487 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
488 "ap_sta_id %d - reduced Tx power %d\n",
489 ap_sta_id
, mvm_sta
->bt_reduced_txpower
);
493 chanctx_conf
= rcu_dereference(vif
->chanctx_conf
);
495 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
496 "idle rx chains %d, active rx chains: %d\n",
497 chanctx_conf
->rx_chains_static
,
498 chanctx_conf
->rx_chains_dynamic
);
502 mutex_unlock(&mvm
->mutex
);
504 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
507 #define BT_MBOX_MSG(_notif, _num, _field) \
508 ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
509 >> BT_MBOX##_num##_##_field##_POS)
512 #define BT_MBOX_PRINT(_num, _field, _end) \
513 pos += scnprintf(buf + pos, bufsz - pos, \
516 BT_MBOX_MSG(notif, _num, _field), \
519 static ssize_t
iwl_dbgfs_bt_notif_read(struct file
*file
, char __user
*user_buf
,
520 size_t count
, loff_t
*ppos
)
522 struct iwl_mvm
*mvm
= file
->private_data
;
523 struct iwl_bt_coex_profile_notif
*notif
= &mvm
->last_bt_notif
;
525 int ret
, pos
= 0, bufsz
= sizeof(char) * 1024;
527 buf
= kmalloc(bufsz
, GFP_KERNEL
);
531 mutex_lock(&mvm
->mutex
);
533 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw0:\n");
535 BT_MBOX_PRINT(0, LE_SLAVE_LAT
, false);
536 BT_MBOX_PRINT(0, LE_PROF1
, false);
537 BT_MBOX_PRINT(0, LE_PROF2
, false);
538 BT_MBOX_PRINT(0, LE_PROF_OTHER
, false);
539 BT_MBOX_PRINT(0, CHL_SEQ_N
, false);
540 BT_MBOX_PRINT(0, INBAND_S
, false);
541 BT_MBOX_PRINT(0, LE_MIN_RSSI
, false);
542 BT_MBOX_PRINT(0, LE_SCAN
, false);
543 BT_MBOX_PRINT(0, LE_ADV
, false);
544 BT_MBOX_PRINT(0, LE_MAX_TX_POWER
, false);
545 BT_MBOX_PRINT(0, OPEN_CON_1
, true);
547 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw1:\n");
549 BT_MBOX_PRINT(1, BR_MAX_TX_POWER
, false);
550 BT_MBOX_PRINT(1, IP_SR
, false);
551 BT_MBOX_PRINT(1, LE_MSTR
, false);
552 BT_MBOX_PRINT(1, AGGR_TRFC_LD
, false);
553 BT_MBOX_PRINT(1, MSG_TYPE
, false);
554 BT_MBOX_PRINT(1, SSN
, true);
556 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw2:\n");
558 BT_MBOX_PRINT(2, SNIFF_ACT
, false);
559 BT_MBOX_PRINT(2, PAG
, false);
560 BT_MBOX_PRINT(2, INQUIRY
, false);
561 BT_MBOX_PRINT(2, CONN
, false);
562 BT_MBOX_PRINT(2, SNIFF_INTERVAL
, false);
563 BT_MBOX_PRINT(2, DISC
, false);
564 BT_MBOX_PRINT(2, SCO_TX_ACT
, false);
565 BT_MBOX_PRINT(2, SCO_RX_ACT
, false);
566 BT_MBOX_PRINT(2, ESCO_RE_TX
, false);
567 BT_MBOX_PRINT(2, SCO_DURATION
, true);
569 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "MBOX dw3:\n");
571 BT_MBOX_PRINT(3, SCO_STATE
, false);
572 BT_MBOX_PRINT(3, SNIFF_STATE
, false);
573 BT_MBOX_PRINT(3, A2DP_STATE
, false);
574 BT_MBOX_PRINT(3, ACL_STATE
, false);
575 BT_MBOX_PRINT(3, MSTR_STATE
, false);
576 BT_MBOX_PRINT(3, OBX_STATE
, false);
577 BT_MBOX_PRINT(3, OPEN_CON_2
, false);
578 BT_MBOX_PRINT(3, TRAFFIC_LOAD
, false);
579 BT_MBOX_PRINT(3, CHL_SEQN_LSB
, false);
580 BT_MBOX_PRINT(3, INBAND_P
, false);
581 BT_MBOX_PRINT(3, MSG_TYPE_2
, false);
582 BT_MBOX_PRINT(3, SSN_2
, false);
583 BT_MBOX_PRINT(3, UPDATE_REQUEST
, true);
585 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_status = %d\n",
587 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_open_conn = %d\n",
588 notif
->bt_open_conn
);
589 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_traffic_load = %d\n",
590 notif
->bt_traffic_load
);
591 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_agg_traffic_load = %d\n",
592 notif
->bt_agg_traffic_load
);
593 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_ci_compliance = %d\n",
594 notif
->bt_ci_compliance
);
595 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "primary_ch_lut = %d\n",
596 le32_to_cpu(notif
->primary_ch_lut
));
597 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "secondary_ch_lut = %d\n",
598 le32_to_cpu(notif
->secondary_ch_lut
));
599 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bt_activity_grading = %d\n",
600 le32_to_cpu(notif
->bt_activity_grading
));
602 mutex_unlock(&mvm
->mutex
);
604 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
611 static ssize_t
iwl_dbgfs_bt_cmd_read(struct file
*file
, char __user
*user_buf
,
612 size_t count
, loff_t
*ppos
)
614 struct iwl_mvm
*mvm
= file
->private_data
;
615 struct iwl_bt_coex_ci_cmd
*cmd
= &mvm
->last_bt_ci_cmd
;
617 int bufsz
= sizeof(buf
);
620 mutex_lock(&mvm
->mutex
);
622 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "Channel inhibition CMD\n");
623 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
624 "\tPrimary Channel Bitmap 0x%016llx Fat: %d\n",
625 le64_to_cpu(cmd
->bt_primary_ci
),
626 !!cmd
->co_run_bw_primary
);
627 pos
+= scnprintf(buf
+pos
, bufsz
-pos
,
628 "\tSecondary Channel Bitmap 0x%016llx Fat: %d\n",
629 le64_to_cpu(cmd
->bt_secondary_ci
),
630 !!cmd
->co_run_bw_secondary
);
632 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "BT Configuration CMD\n");
633 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "\tACK Kill Mask 0x%08x\n",
634 iwl_bt_ack_kill_msk
[mvm
->bt_kill_msk
]);
635 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "\tCTS Kill Mask 0x%08x\n",
636 iwl_bt_cts_kill_msk
[mvm
->bt_kill_msk
]);
638 mutex_unlock(&mvm
->mutex
);
640 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
643 #define PRINT_STATS_LE32(_str, _val) \
644 pos += scnprintf(buf + pos, bufsz - pos, \
648 static ssize_t
iwl_dbgfs_fw_rx_stats_read(struct file
*file
,
649 char __user
*user_buf
, size_t count
,
652 struct iwl_mvm
*mvm
= file
->private_data
;
653 static const char *fmt_table
= "\t%-30s %10u\n";
654 static const char *fmt_header
= "%-32s\n";
658 /* 43 is the size of each data line, 33 is the size of each header */
660 ((sizeof(struct mvm_statistics_rx
) / sizeof(__le32
)) * 43) +
663 struct mvm_statistics_rx_phy
*ofdm
;
664 struct mvm_statistics_rx_phy
*cck
;
665 struct mvm_statistics_rx_non_phy
*general
;
666 struct mvm_statistics_rx_ht_phy
*ht
;
668 buf
= kzalloc(bufsz
, GFP_KERNEL
);
672 mutex_lock(&mvm
->mutex
);
674 ofdm
= &mvm
->rx_stats
.ofdm
;
675 cck
= &mvm
->rx_stats
.cck
;
676 general
= &mvm
->rx_stats
.general
;
677 ht
= &mvm
->rx_stats
.ofdm_ht
;
679 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
680 "Statistics_Rx - OFDM");
681 PRINT_STATS_LE32("ina_cnt", ofdm
->ina_cnt
);
682 PRINT_STATS_LE32("fina_cnt", ofdm
->fina_cnt
);
683 PRINT_STATS_LE32("plcp_err", ofdm
->plcp_err
);
684 PRINT_STATS_LE32("crc32_err", ofdm
->crc32_err
);
685 PRINT_STATS_LE32("overrun_err", ofdm
->overrun_err
);
686 PRINT_STATS_LE32("early_overrun_err", ofdm
->early_overrun_err
);
687 PRINT_STATS_LE32("crc32_good", ofdm
->crc32_good
);
688 PRINT_STATS_LE32("false_alarm_cnt", ofdm
->false_alarm_cnt
);
689 PRINT_STATS_LE32("fina_sync_err_cnt", ofdm
->fina_sync_err_cnt
);
690 PRINT_STATS_LE32("sfd_timeout", ofdm
->sfd_timeout
);
691 PRINT_STATS_LE32("fina_timeout", ofdm
->fina_timeout
);
692 PRINT_STATS_LE32("unresponded_rts", ofdm
->unresponded_rts
);
693 PRINT_STATS_LE32("rxe_frame_lmt_overrun",
694 ofdm
->rxe_frame_limit_overrun
);
695 PRINT_STATS_LE32("sent_ack_cnt", ofdm
->sent_ack_cnt
);
696 PRINT_STATS_LE32("sent_cts_cnt", ofdm
->sent_cts_cnt
);
697 PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm
->sent_ba_rsp_cnt
);
698 PRINT_STATS_LE32("dsp_self_kill", ofdm
->dsp_self_kill
);
699 PRINT_STATS_LE32("mh_format_err", ofdm
->mh_format_err
);
700 PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm
->re_acq_main_rssi_sum
);
701 PRINT_STATS_LE32("reserved", ofdm
->reserved
);
703 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
704 "Statistics_Rx - CCK");
705 PRINT_STATS_LE32("ina_cnt", cck
->ina_cnt
);
706 PRINT_STATS_LE32("fina_cnt", cck
->fina_cnt
);
707 PRINT_STATS_LE32("plcp_err", cck
->plcp_err
);
708 PRINT_STATS_LE32("crc32_err", cck
->crc32_err
);
709 PRINT_STATS_LE32("overrun_err", cck
->overrun_err
);
710 PRINT_STATS_LE32("early_overrun_err", cck
->early_overrun_err
);
711 PRINT_STATS_LE32("crc32_good", cck
->crc32_good
);
712 PRINT_STATS_LE32("false_alarm_cnt", cck
->false_alarm_cnt
);
713 PRINT_STATS_LE32("fina_sync_err_cnt", cck
->fina_sync_err_cnt
);
714 PRINT_STATS_LE32("sfd_timeout", cck
->sfd_timeout
);
715 PRINT_STATS_LE32("fina_timeout", cck
->fina_timeout
);
716 PRINT_STATS_LE32("unresponded_rts", cck
->unresponded_rts
);
717 PRINT_STATS_LE32("rxe_frame_lmt_overrun",
718 cck
->rxe_frame_limit_overrun
);
719 PRINT_STATS_LE32("sent_ack_cnt", cck
->sent_ack_cnt
);
720 PRINT_STATS_LE32("sent_cts_cnt", cck
->sent_cts_cnt
);
721 PRINT_STATS_LE32("sent_ba_rsp_cnt", cck
->sent_ba_rsp_cnt
);
722 PRINT_STATS_LE32("dsp_self_kill", cck
->dsp_self_kill
);
723 PRINT_STATS_LE32("mh_format_err", cck
->mh_format_err
);
724 PRINT_STATS_LE32("re_acq_main_rssi_sum", cck
->re_acq_main_rssi_sum
);
725 PRINT_STATS_LE32("reserved", cck
->reserved
);
727 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
728 "Statistics_Rx - GENERAL");
729 PRINT_STATS_LE32("bogus_cts", general
->bogus_cts
);
730 PRINT_STATS_LE32("bogus_ack", general
->bogus_ack
);
731 PRINT_STATS_LE32("non_bssid_frames", general
->non_bssid_frames
);
732 PRINT_STATS_LE32("filtered_frames", general
->filtered_frames
);
733 PRINT_STATS_LE32("non_channel_beacons", general
->non_channel_beacons
);
734 PRINT_STATS_LE32("channel_beacons", general
->channel_beacons
);
735 PRINT_STATS_LE32("num_missed_bcon", general
->num_missed_bcon
);
736 PRINT_STATS_LE32("adc_rx_saturation_time",
737 general
->adc_rx_saturation_time
);
738 PRINT_STATS_LE32("ina_detection_search_time",
739 general
->ina_detection_search_time
);
740 PRINT_STATS_LE32("beacon_silence_rssi_a",
741 general
->beacon_silence_rssi_a
);
742 PRINT_STATS_LE32("beacon_silence_rssi_b",
743 general
->beacon_silence_rssi_b
);
744 PRINT_STATS_LE32("beacon_silence_rssi_c",
745 general
->beacon_silence_rssi_c
);
746 PRINT_STATS_LE32("interference_data_flag",
747 general
->interference_data_flag
);
748 PRINT_STATS_LE32("channel_load", general
->channel_load
);
749 PRINT_STATS_LE32("dsp_false_alarms", general
->dsp_false_alarms
);
750 PRINT_STATS_LE32("beacon_rssi_a", general
->beacon_rssi_a
);
751 PRINT_STATS_LE32("beacon_rssi_b", general
->beacon_rssi_b
);
752 PRINT_STATS_LE32("beacon_rssi_c", general
->beacon_rssi_c
);
753 PRINT_STATS_LE32("beacon_energy_a", general
->beacon_energy_a
);
754 PRINT_STATS_LE32("beacon_energy_b", general
->beacon_energy_b
);
755 PRINT_STATS_LE32("beacon_energy_c", general
->beacon_energy_c
);
756 PRINT_STATS_LE32("num_bt_kills", general
->num_bt_kills
);
757 PRINT_STATS_LE32("mac_id", general
->mac_id
);
758 PRINT_STATS_LE32("directed_data_mpdu", general
->directed_data_mpdu
);
760 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, fmt_header
,
761 "Statistics_Rx - HT");
762 PRINT_STATS_LE32("plcp_err", ht
->plcp_err
);
763 PRINT_STATS_LE32("overrun_err", ht
->overrun_err
);
764 PRINT_STATS_LE32("early_overrun_err", ht
->early_overrun_err
);
765 PRINT_STATS_LE32("crc32_good", ht
->crc32_good
);
766 PRINT_STATS_LE32("crc32_err", ht
->crc32_err
);
767 PRINT_STATS_LE32("mh_format_err", ht
->mh_format_err
);
768 PRINT_STATS_LE32("agg_crc32_good", ht
->agg_crc32_good
);
769 PRINT_STATS_LE32("agg_mpdu_cnt", ht
->agg_mpdu_cnt
);
770 PRINT_STATS_LE32("agg_cnt", ht
->agg_cnt
);
771 PRINT_STATS_LE32("unsupport_mcs", ht
->unsupport_mcs
);
773 mutex_unlock(&mvm
->mutex
);
775 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
780 #undef PRINT_STAT_LE32
782 static ssize_t
iwl_dbgfs_fw_restart_write(struct file
*file
,
783 const char __user
*user_buf
,
784 size_t count
, loff_t
*ppos
)
786 struct iwl_mvm
*mvm
= file
->private_data
;
789 mutex_lock(&mvm
->mutex
);
791 /* allow one more restart that we're provoking here */
792 if (mvm
->restart_fw
>= 0)
795 /* take the return value to make compiler happy - it will fail anyway */
796 ret
= iwl_mvm_send_cmd_pdu(mvm
, REPLY_ERROR
, CMD_SYNC
, 0, NULL
);
798 mutex_unlock(&mvm
->mutex
);
804 iwl_dbgfs_scan_ant_rxchain_read(struct file
*file
,
805 char __user
*user_buf
,
806 size_t count
, loff_t
*ppos
)
808 struct iwl_mvm
*mvm
= file
->private_data
;
811 const size_t bufsz
= sizeof(buf
);
813 /* print which antennas were set for the scan command by the user */
814 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "Antennas for scan: ");
815 if (mvm
->scan_rx_ant
& ANT_A
)
816 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "A");
817 if (mvm
->scan_rx_ant
& ANT_B
)
818 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "B");
819 if (mvm
->scan_rx_ant
& ANT_C
)
820 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, "C");
821 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
, " (%hhx)\n", mvm
->scan_rx_ant
);
823 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
827 iwl_dbgfs_scan_ant_rxchain_write(struct file
*file
,
828 const char __user
*user_buf
,
829 size_t count
, loff_t
*ppos
)
831 struct iwl_mvm
*mvm
= file
->private_data
;
836 memset(buf
, 0, sizeof(buf
));
837 buf_size
= min(count
, sizeof(buf
) - 1);
839 /* get the argument from the user and check if it is valid */
840 if (copy_from_user(buf
, user_buf
, buf_size
))
842 if (sscanf(buf
, "%hhx", &scan_rx_ant
) != 1)
844 if (scan_rx_ant
> ANT_ABC
)
846 if (scan_rx_ant
& ~iwl_fw_valid_rx_ant(mvm
->fw
))
849 /* change the rx antennas for scan command */
850 mvm
->scan_rx_ant
= scan_rx_ant
;
856 static void iwl_dbgfs_update_bf(struct ieee80211_vif
*vif
,
857 enum iwl_dbgfs_bf_mask param
, int value
)
859 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
860 struct iwl_dbgfs_bf
*dbgfs_bf
= &mvmvif
->dbgfs_bf
;
862 dbgfs_bf
->mask
|= param
;
865 case MVM_DEBUGFS_BF_ENERGY_DELTA
:
866 dbgfs_bf
->bf_energy_delta
= value
;
868 case MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA
:
869 dbgfs_bf
->bf_roaming_energy_delta
= value
;
871 case MVM_DEBUGFS_BF_ROAMING_STATE
:
872 dbgfs_bf
->bf_roaming_state
= value
;
874 case MVM_DEBUGFS_BF_TEMP_THRESHOLD
:
875 dbgfs_bf
->bf_temp_threshold
= value
;
877 case MVM_DEBUGFS_BF_TEMP_FAST_FILTER
:
878 dbgfs_bf
->bf_temp_fast_filter
= value
;
880 case MVM_DEBUGFS_BF_TEMP_SLOW_FILTER
:
881 dbgfs_bf
->bf_temp_slow_filter
= value
;
883 case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
:
884 dbgfs_bf
->bf_enable_beacon_filter
= value
;
886 case MVM_DEBUGFS_BF_DEBUG_FLAG
:
887 dbgfs_bf
->bf_debug_flag
= value
;
889 case MVM_DEBUGFS_BF_ESCAPE_TIMER
:
890 dbgfs_bf
->bf_escape_timer
= value
;
892 case MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT
:
893 dbgfs_bf
->ba_enable_beacon_abort
= value
;
895 case MVM_DEBUGFS_BA_ESCAPE_TIMER
:
896 dbgfs_bf
->ba_escape_timer
= value
;
901 static ssize_t
iwl_dbgfs_bf_params_write(struct file
*file
,
902 const char __user
*user_buf
,
903 size_t count
, loff_t
*ppos
)
905 struct ieee80211_vif
*vif
= file
->private_data
;
906 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
907 struct iwl_mvm
*mvm
= mvmvif
->dbgfs_data
;
908 enum iwl_dbgfs_bf_mask param
;
914 memset(buf
, 0, sizeof(buf
));
915 buf_size
= min(count
, sizeof(buf
) - 1);
916 if (copy_from_user(buf
, user_buf
, buf_size
))
919 if (!strncmp("bf_energy_delta=", buf
, 16)) {
920 if (sscanf(buf
+16, "%d", &value
) != 1)
922 if (value
< IWL_BF_ENERGY_DELTA_MIN
||
923 value
> IWL_BF_ENERGY_DELTA_MAX
)
925 param
= MVM_DEBUGFS_BF_ENERGY_DELTA
;
926 } else if (!strncmp("bf_roaming_energy_delta=", buf
, 24)) {
927 if (sscanf(buf
+24, "%d", &value
) != 1)
929 if (value
< IWL_BF_ROAMING_ENERGY_DELTA_MIN
||
930 value
> IWL_BF_ROAMING_ENERGY_DELTA_MAX
)
932 param
= MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA
;
933 } else if (!strncmp("bf_roaming_state=", buf
, 17)) {
934 if (sscanf(buf
+17, "%d", &value
) != 1)
936 if (value
< IWL_BF_ROAMING_STATE_MIN
||
937 value
> IWL_BF_ROAMING_STATE_MAX
)
939 param
= MVM_DEBUGFS_BF_ROAMING_STATE
;
940 } else if (!strncmp("bf_temp_threshold=", buf
, 18)) {
941 if (sscanf(buf
+18, "%d", &value
) != 1)
943 if (value
< IWL_BF_TEMP_THRESHOLD_MIN
||
944 value
> IWL_BF_TEMP_THRESHOLD_MAX
)
946 param
= MVM_DEBUGFS_BF_TEMP_THRESHOLD
;
947 } else if (!strncmp("bf_temp_fast_filter=", buf
, 20)) {
948 if (sscanf(buf
+20, "%d", &value
) != 1)
950 if (value
< IWL_BF_TEMP_FAST_FILTER_MIN
||
951 value
> IWL_BF_TEMP_FAST_FILTER_MAX
)
953 param
= MVM_DEBUGFS_BF_TEMP_FAST_FILTER
;
954 } else if (!strncmp("bf_temp_slow_filter=", buf
, 20)) {
955 if (sscanf(buf
+20, "%d", &value
) != 1)
957 if (value
< IWL_BF_TEMP_SLOW_FILTER_MIN
||
958 value
> IWL_BF_TEMP_SLOW_FILTER_MAX
)
960 param
= MVM_DEBUGFS_BF_TEMP_SLOW_FILTER
;
961 } else if (!strncmp("bf_enable_beacon_filter=", buf
, 24)) {
962 if (sscanf(buf
+24, "%d", &value
) != 1)
964 if (value
< 0 || value
> 1)
966 param
= MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
;
967 } else if (!strncmp("bf_debug_flag=", buf
, 14)) {
968 if (sscanf(buf
+14, "%d", &value
) != 1)
970 if (value
< 0 || value
> 1)
972 param
= MVM_DEBUGFS_BF_DEBUG_FLAG
;
973 } else if (!strncmp("bf_escape_timer=", buf
, 16)) {
974 if (sscanf(buf
+16, "%d", &value
) != 1)
976 if (value
< IWL_BF_ESCAPE_TIMER_MIN
||
977 value
> IWL_BF_ESCAPE_TIMER_MAX
)
979 param
= MVM_DEBUGFS_BF_ESCAPE_TIMER
;
980 } else if (!strncmp("ba_escape_timer=", buf
, 16)) {
981 if (sscanf(buf
+16, "%d", &value
) != 1)
983 if (value
< IWL_BA_ESCAPE_TIMER_MIN
||
984 value
> IWL_BA_ESCAPE_TIMER_MAX
)
986 param
= MVM_DEBUGFS_BA_ESCAPE_TIMER
;
987 } else if (!strncmp("ba_enable_beacon_abort=", buf
, 23)) {
988 if (sscanf(buf
+23, "%d", &value
) != 1)
990 if (value
< 0 || value
> 1)
992 param
= MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT
;
997 mutex_lock(&mvm
->mutex
);
998 iwl_dbgfs_update_bf(vif
, param
, value
);
999 if (param
== MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER
&& !value
) {
1000 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
);
1002 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
);
1004 mutex_unlock(&mvm
->mutex
);
1006 return ret
?: count
;
1009 static ssize_t
iwl_dbgfs_bf_params_read(struct file
*file
,
1010 char __user
*user_buf
,
1011 size_t count
, loff_t
*ppos
)
1013 struct ieee80211_vif
*vif
= file
->private_data
;
1014 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1017 const size_t bufsz
= sizeof(buf
);
1018 struct iwl_beacon_filter_cmd cmd
= {
1019 IWL_BF_CMD_CONFIG_DEFAULTS
,
1020 .bf_enable_beacon_filter
=
1021 cpu_to_le32(IWL_BF_ENABLE_BEACON_FILTER_DEFAULT
),
1022 .ba_enable_beacon_abort
=
1023 cpu_to_le32(IWL_BA_ENABLE_BEACON_ABORT_DEFAULT
),
1026 iwl_mvm_beacon_filter_debugfs_parameters(vif
, &cmd
);
1027 if (mvmvif
->bf_data
.bf_enabled
)
1028 cmd
.bf_enable_beacon_filter
= cpu_to_le32(1);
1030 cmd
.bf_enable_beacon_filter
= 0;
1032 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_energy_delta = %d\n",
1033 le32_to_cpu(cmd
.bf_energy_delta
));
1034 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_roaming_energy_delta = %d\n",
1035 le32_to_cpu(cmd
.bf_roaming_energy_delta
));
1036 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_roaming_state = %d\n",
1037 le32_to_cpu(cmd
.bf_roaming_state
));
1038 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_temp_threshold = %d\n",
1039 le32_to_cpu(cmd
.bf_temp_threshold
));
1040 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_temp_fast_filter = %d\n",
1041 le32_to_cpu(cmd
.bf_temp_fast_filter
));
1042 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_temp_slow_filter = %d\n",
1043 le32_to_cpu(cmd
.bf_temp_slow_filter
));
1044 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_enable_beacon_filter = %d\n",
1045 le32_to_cpu(cmd
.bf_enable_beacon_filter
));
1046 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_debug_flag = %d\n",
1047 le32_to_cpu(cmd
.bf_debug_flag
));
1048 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "bf_escape_timer = %d\n",
1049 le32_to_cpu(cmd
.bf_escape_timer
));
1050 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "ba_escape_timer = %d\n",
1051 le32_to_cpu(cmd
.ba_escape_timer
));
1052 pos
+= scnprintf(buf
+pos
, bufsz
-pos
, "ba_enable_beacon_abort = %d\n",
1053 le32_to_cpu(cmd
.ba_enable_beacon_abort
));
1055 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1058 #ifdef CONFIG_PM_SLEEP
1059 static ssize_t
iwl_dbgfs_d3_sram_write(struct file
*file
,
1060 const char __user
*user_buf
,
1061 size_t count
, loff_t
*ppos
)
1063 struct iwl_mvm
*mvm
= file
->private_data
;
1067 count
= min_t(size_t, count
, sizeof(buf
) - 1);
1068 if (copy_from_user(buf
, user_buf
, count
))
1071 if (sscanf(buf
, "%d", &store
) != 1)
1074 mvm
->store_d3_resume_sram
= store
;
1079 static ssize_t
iwl_dbgfs_d3_sram_read(struct file
*file
, char __user
*user_buf
,
1080 size_t count
, loff_t
*ppos
)
1082 struct iwl_mvm
*mvm
= file
->private_data
;
1083 const struct fw_img
*img
;
1084 int ofs
, len
, pos
= 0;
1087 u8
*ptr
= mvm
->d3_resume_sram
;
1089 img
= &mvm
->fw
->img
[IWL_UCODE_WOWLAN
];
1090 len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
1092 bufsz
= len
* 4 + 256;
1093 buf
= kzalloc(bufsz
, GFP_KERNEL
);
1097 pos
+= scnprintf(buf
, bufsz
, "D3 SRAM capture: %sabled\n",
1098 mvm
->store_d3_resume_sram
? "en" : "dis");
1101 for (ofs
= 0; ofs
< len
; ofs
+= 16) {
1102 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1104 hex_dump_to_buffer(ptr
+ ofs
, 16, 16, 1, buf
+ pos
,
1105 bufsz
- pos
, false);
1106 pos
+= strlen(buf
+ pos
);
1107 if (bufsz
- pos
> 0)
1111 pos
+= scnprintf(buf
+ pos
, bufsz
- pos
,
1112 "(no data captured)\n");
1115 ret
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, pos
);
1123 #define MVM_DEBUGFS_READ_FILE_OPS(name) \
1124 static const struct file_operations iwl_dbgfs_##name##_ops = { \
1125 .read = iwl_dbgfs_##name##_read, \
1126 .open = simple_open, \
1127 .llseek = generic_file_llseek, \
1130 #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name) \
1131 static const struct file_operations iwl_dbgfs_##name##_ops = { \
1132 .write = iwl_dbgfs_##name##_write, \
1133 .read = iwl_dbgfs_##name##_read, \
1134 .open = simple_open, \
1135 .llseek = generic_file_llseek, \
1138 #define MVM_DEBUGFS_WRITE_FILE_OPS(name) \
1139 static const struct file_operations iwl_dbgfs_##name##_ops = { \
1140 .write = iwl_dbgfs_##name##_write, \
1141 .open = simple_open, \
1142 .llseek = generic_file_llseek, \
1145 #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) do { \
1146 if (!debugfs_create_file(#name, mode, parent, mvm, \
1147 &iwl_dbgfs_##name##_ops)) \
1151 #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
1152 if (!debugfs_create_file(#name, mode, parent, vif, \
1153 &iwl_dbgfs_##name##_ops)) \
1157 /* Device wide debugfs entries */
1158 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush
);
1159 MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain
);
1160 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram
);
1161 MVM_DEBUGFS_READ_FILE_OPS(stations
);
1162 MVM_DEBUGFS_READ_FILE_OPS(bt_notif
);
1163 MVM_DEBUGFS_READ_FILE_OPS(bt_cmd
);
1164 MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off
);
1165 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats
);
1166 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart
);
1167 MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain
);
1169 #ifdef CONFIG_PM_SLEEP
1170 MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram
);
1173 /* Interface specific debugfs entries */
1174 MVM_DEBUGFS_READ_FILE_OPS(mac_params
);
1175 MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params
);
1176 MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params
);
1178 int iwl_mvm_dbgfs_register(struct iwl_mvm
*mvm
, struct dentry
*dbgfs_dir
)
1182 mvm
->debugfs_dir
= dbgfs_dir
;
1184 MVM_DEBUGFS_ADD_FILE(tx_flush
, mvm
->debugfs_dir
, S_IWUSR
);
1185 MVM_DEBUGFS_ADD_FILE(sta_drain
, mvm
->debugfs_dir
, S_IWUSR
);
1186 MVM_DEBUGFS_ADD_FILE(sram
, mvm
->debugfs_dir
, S_IWUSR
| S_IRUSR
);
1187 MVM_DEBUGFS_ADD_FILE(stations
, dbgfs_dir
, S_IRUSR
);
1188 MVM_DEBUGFS_ADD_FILE(bt_notif
, dbgfs_dir
, S_IRUSR
);
1189 MVM_DEBUGFS_ADD_FILE(bt_cmd
, dbgfs_dir
, S_IRUSR
);
1190 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD
)
1191 MVM_DEBUGFS_ADD_FILE(disable_power_off
, mvm
->debugfs_dir
,
1193 MVM_DEBUGFS_ADD_FILE(fw_rx_stats
, mvm
->debugfs_dir
, S_IRUSR
);
1194 MVM_DEBUGFS_ADD_FILE(fw_restart
, mvm
->debugfs_dir
, S_IWUSR
);
1195 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain
, mvm
->debugfs_dir
,
1197 #ifdef CONFIG_PM_SLEEP
1198 MVM_DEBUGFS_ADD_FILE(d3_sram
, mvm
->debugfs_dir
, S_IRUSR
| S_IWUSR
);
1199 MVM_DEBUGFS_ADD_FILE(d3_test
, mvm
->debugfs_dir
, S_IRUSR
);
1200 if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR
| S_IWUSR
,
1201 mvm
->debugfs_dir
, &mvm
->d3_wake_sysassert
))
1206 * Create a symlink with mac80211. It will be removed when mac80211
1207 * exists (before the opmode exists which removes the target.)
1209 snprintf(buf
, 100, "../../%s/%s",
1210 dbgfs_dir
->d_parent
->d_parent
->d_name
.name
,
1211 dbgfs_dir
->d_parent
->d_name
.name
);
1212 if (!debugfs_create_symlink("iwlwifi", mvm
->hw
->wiphy
->debugfsdir
, buf
))
1217 IWL_ERR(mvm
, "Can't create the mvm debugfs directory\n");
1221 void iwl_mvm_vif_dbgfs_register(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1223 struct dentry
*dbgfs_dir
= vif
->debugfs_dir
;
1224 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1228 * Check if debugfs directory already exist before creating it.
1229 * This may happen when, for example, resetting hw or suspend-resume
1231 if (!dbgfs_dir
|| mvmvif
->dbgfs_dir
)
1234 mvmvif
->dbgfs_dir
= debugfs_create_dir("iwlmvm", dbgfs_dir
);
1235 mvmvif
->dbgfs_data
= mvm
;
1237 if (!mvmvif
->dbgfs_dir
) {
1238 IWL_ERR(mvm
, "Failed to create debugfs directory under %s\n",
1239 dbgfs_dir
->d_name
.name
);
1243 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
&&
1244 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
)
1245 MVM_DEBUGFS_ADD_FILE_VIF(pm_params
, mvmvif
->dbgfs_dir
, S_IWUSR
|
1248 MVM_DEBUGFS_ADD_FILE_VIF(mac_params
, mvmvif
->dbgfs_dir
,
1251 if (vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
&&
1252 mvmvif
== mvm
->bf_allowed_vif
)
1253 MVM_DEBUGFS_ADD_FILE_VIF(bf_params
, mvmvif
->dbgfs_dir
,
1257 * Create symlink for convenience pointing to interface specific
1258 * debugfs entries for the driver. For example, under
1259 * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
1261 * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
1263 snprintf(buf
, 100, "../../../%s/%s/%s/%s",
1264 dbgfs_dir
->d_parent
->d_parent
->d_name
.name
,
1265 dbgfs_dir
->d_parent
->d_name
.name
,
1266 dbgfs_dir
->d_name
.name
,
1267 mvmvif
->dbgfs_dir
->d_name
.name
);
1269 mvmvif
->dbgfs_slink
= debugfs_create_symlink(dbgfs_dir
->d_name
.name
,
1270 mvm
->debugfs_dir
, buf
);
1271 if (!mvmvif
->dbgfs_slink
)
1272 IWL_ERR(mvm
, "Can't create debugfs symbolic link under %s\n",
1273 dbgfs_dir
->d_name
.name
);
1276 IWL_ERR(mvm
, "Can't create debugfs entity\n");
1279 void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
1281 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1283 debugfs_remove(mvmvif
->dbgfs_slink
);
1284 mvmvif
->dbgfs_slink
= NULL
;
1286 debugfs_remove_recursive(mvmvif
->dbgfs_dir
);
1287 mvmvif
->dbgfs_dir
= NULL
;