iwlwifi: mvm: add bt settings to debugfs
[deliverable/linux.git] / drivers / net / wireless / intel / iwlwifi / mvm / debugfs.c
CommitLineData
8ca151b5
JB
1/******************************************************************************
2 *
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.
5 *
6 * GPL LICENSE SUMMARY
7 *
51368bf7 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
c779273b 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
8ca151b5
JB
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23 * USA
24 *
25 * The full GNU General Public License is included in this distribution
410dc5aa 26 * in the file called COPYING.
8ca151b5
JB
27 *
28 * Contact Information:
29 * Intel Linux Wireless <ilw@linux.intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
51368bf7 34 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
c779273b 35 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
8ca151b5
JB
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 *
42 * * Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in
46 * the documentation and/or other materials provided with the
47 * distribution.
48 * * Neither the name Intel Corporation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 *
64 *****************************************************************************/
192c80a2
EG
65#include <linux/vmalloc.h>
66
8ca151b5
JB
67#include "mvm.h"
68#include "sta.h"
69#include "iwl-io.h"
820a1a50 70#include "debugfs.h"
4d075007 71#include "iwl-fw-error-dump.h"
8ca151b5 72
1fa3f57a 73static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
8ca151b5
JB
74 size_t count, loff_t *ppos)
75{
8a0bd168 76 int ret;
8ca151b5
JB
77 u32 scd_q_msk;
78
79 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
80 return -EIO;
81
8ca151b5
JB
82 if (sscanf(buf, "%x", &scd_q_msk) != 1)
83 return -EINVAL;
84
85 IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk);
86
87 mutex_lock(&mvm->mutex);
5888a40c 88 ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, 0) ? : count;
8ca151b5
JB
89 mutex_unlock(&mvm->mutex);
90
91 return ret;
92}
93
1fa3f57a 94static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
8ca151b5
JB
95 size_t count, loff_t *ppos)
96{
f327b04c 97 struct iwl_mvm_sta *mvmsta;
8a0bd168 98 int sta_id, drain, ret;
8ca151b5
JB
99
100 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
101 return -EIO;
102
8ca151b5
JB
103 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
104 return -EINVAL;
60765a47
JB
105 if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
106 return -EINVAL;
107 if (drain < 0 || drain > 1)
108 return -EINVAL;
8ca151b5
JB
109
110 mutex_lock(&mvm->mutex);
111
f327b04c
EG
112 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
113
114 if (!mvmsta)
8ca151b5
JB
115 ret = -ENOENT;
116 else
f327b04c 117 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
8ca151b5
JB
118
119 mutex_unlock(&mvm->mutex);
120
121 return ret;
122}
123
124static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
125 size_t count, loff_t *ppos)
126{
127 struct iwl_mvm *mvm = file->private_data;
128 const struct fw_img *img;
d510342f
EG
129 unsigned int ofs, len;
130 size_t ret;
8ca151b5
JB
131 u8 *ptr;
132
60191d99
JB
133 if (!mvm->ucode_loaded)
134 return -EINVAL;
135
8ca151b5 136 /* default is to dump the entire data segment */
d510342f
EG
137 img = &mvm->fw->img[mvm->cur_ucode];
138 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
139 len = img->sec[IWL_UCODE_SECTION_DATA].len;
140
01e0efe3 141 if (mvm->dbgfs_sram_len) {
60191d99
JB
142 ofs = mvm->dbgfs_sram_offset;
143 len = mvm->dbgfs_sram_len;
8ca151b5 144 }
8ca151b5 145
8ca151b5 146 ptr = kzalloc(len, GFP_KERNEL);
d510342f 147 if (!ptr)
8ca151b5 148 return -ENOMEM;
8ca151b5 149
60191d99 150 iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
8ca151b5 151
d510342f 152 ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
8ca151b5 153
8ca151b5
JB
154 kfree(ptr);
155
156 return ret;
157}
158
1fa3f57a
JB
159static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
160 size_t count, loff_t *ppos)
8ca151b5 161{
d510342f 162 const struct fw_img *img;
8ca151b5 163 u32 offset, len;
d510342f
EG
164 u32 img_offset, img_len;
165
166 if (!mvm->ucode_loaded)
167 return -EINVAL;
168
169 img = &mvm->fw->img[mvm->cur_ucode];
170 img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
171 img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
8ca151b5 172
8ca151b5
JB
173 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
174 if ((offset & 0x3) || (len & 0x3))
175 return -EINVAL;
d510342f
EG
176
177 if (offset + len > img_offset + img_len)
178 return -EINVAL;
179
8ca151b5
JB
180 mvm->dbgfs_sram_offset = offset;
181 mvm->dbgfs_sram_len = len;
182 } else {
183 mvm->dbgfs_sram_offset = 0;
184 mvm->dbgfs_sram_len = 0;
185 }
186
187 return count;
188}
189
7280d1f0
MG
190static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
191 char __user *user_buf,
192 size_t count, loff_t *ppos)
193{
194 struct iwl_mvm *mvm = file->private_data;
195 char buf[16];
196 int pos;
197
198 if (!mvm->temperature_test)
199 pos = scnprintf(buf , sizeof(buf), "disabled\n");
200 else
201 pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
202
203 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
204}
205
206/*
207 * Set NIC Temperature
208 * Cause the driver to ignore the actual NIC temperature reported by the FW
209 * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
210 * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
211 * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
212 */
213static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
214 char *buf, size_t count,
215 loff_t *ppos)
216{
217 int temperature;
218
a26d4e7b
LC
219 if (!mvm->ucode_loaded && !mvm->temperature_test)
220 return -EIO;
221
7280d1f0
MG
222 if (kstrtoint(buf, 10, &temperature))
223 return -EINVAL;
224 /* not a legal temperature */
225 if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
226 temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
227 temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
228 return -EINVAL;
229
230 mutex_lock(&mvm->mutex);
231 if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
b689fa79
LC
232 if (!mvm->temperature_test)
233 goto out;
234
7280d1f0 235 mvm->temperature_test = false;
b689fa79
LC
236 /* Since we can't read the temp while awake, just set
237 * it to zero until we get the next RX stats from the
238 * firmware.
239 */
240 mvm->temperature = 0;
7280d1f0
MG
241 } else {
242 mvm->temperature_test = true;
243 mvm->temperature = temperature;
244 }
245 IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
246 mvm->temperature_test ? "En" : "Dis" ,
247 mvm->temperature);
248 /* handle the temperature change */
249 iwl_mvm_tt_handler(mvm);
b689fa79
LC
250
251out:
7280d1f0
MG
252 mutex_unlock(&mvm->mutex);
253
254 return count;
255}
256
c549e390
LC
257static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
258 char __user *user_buf,
259 size_t count, loff_t *ppos)
260{
261 struct iwl_mvm *mvm = file->private_data;
262 char buf[16];
263 int pos, temp;
264
265 if (!mvm->ucode_loaded)
266 return -EIO;
267
268 mutex_lock(&mvm->mutex);
269 temp = iwl_mvm_get_temp(mvm);
270 mutex_unlock(&mvm->mutex);
271
272 if (temp < 0)
273 return temp;
274
275 pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
276
277 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
278}
279
8ca151b5
JB
280static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
281 size_t count, loff_t *ppos)
282{
283 struct iwl_mvm *mvm = file->private_data;
284 struct ieee80211_sta *sta;
285 char buf[400];
286 int i, pos = 0, bufsz = sizeof(buf);
287
288 mutex_lock(&mvm->mutex);
289
290 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
291 pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
292 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
293 lockdep_is_held(&mvm->mutex));
294 if (!sta)
295 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
296 else if (IS_ERR(sta))
297 pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
298 PTR_ERR(sta));
299 else
300 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
301 sta->addr);
302 }
303
304 mutex_unlock(&mvm->mutex);
305
306 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
307}
308
64b928c4
AB
309static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
310 char __user *user_buf,
8ca151b5
JB
311 size_t count, loff_t *ppos)
312{
313 struct iwl_mvm *mvm = file->private_data;
64b928c4
AB
314 char buf[64];
315 int bufsz = sizeof(buf);
316 int pos = 0;
8ca151b5 317
64b928c4
AB
318 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
319 mvm->disable_power_off);
320 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
321 mvm->disable_power_off_d3);
8ca151b5 322
64b928c4 323 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
8ca151b5
JB
324}
325
1fa3f57a 326static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
64b928c4 327 size_t count, loff_t *ppos)
8ca151b5 328{
1fa3f57a 329 int ret, val;
64b928c4
AB
330
331 if (!mvm->ucode_loaded)
332 return -EIO;
8ca151b5 333
64b928c4
AB
334 if (!strncmp("disable_power_off_d0=", buf, 21)) {
335 if (sscanf(buf + 21, "%d", &val) != 1)
336 return -EINVAL;
337 mvm->disable_power_off = val;
338 } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
339 if (sscanf(buf + 21, "%d", &val) != 1)
340 return -EINVAL;
341 mvm->disable_power_off_d3 = val;
342 } else {
8ca151b5 343 return -EINVAL;
64b928c4 344 }
8ca151b5 345
64b928c4 346 mutex_lock(&mvm->mutex);
c1cb92fc 347 ret = iwl_mvm_power_update_device(mvm);
64b928c4 348 mutex_unlock(&mvm->mutex);
8ca151b5 349
64b928c4 350 return ret ?: count;
8ca151b5
JB
351}
352
10942342
EG
353#define BT_MBOX_MSG(_notif, _num, _field) \
354 ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
355 >> BT_MBOX##_num##_##_field##_POS)
356
357
358#define BT_MBOX_PRINT(_num, _field, _end) \
359 pos += scnprintf(buf + pos, bufsz - pos, \
360 "\t%s: %d%s", \
361 #_field, \
362 BT_MBOX_MSG(notif, _num, _field), \
363 true ? "\n" : ", ");
364
160be571
EG
365static
366int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
367 int pos, int bufsz)
10942342 368{
160be571 369 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
10942342 370
160be571
EG
371 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
372 BT_MBOX_PRINT(0, LE_PROF1, false);
373 BT_MBOX_PRINT(0, LE_PROF2, false);
374 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
375 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
376 BT_MBOX_PRINT(0, INBAND_S, false);
377 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
378 BT_MBOX_PRINT(0, LE_SCAN, false);
379 BT_MBOX_PRINT(0, LE_ADV, false);
380 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
381 BT_MBOX_PRINT(0, OPEN_CON_1, true);
10942342 382
160be571
EG
383 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
384
385 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
386 BT_MBOX_PRINT(1, IP_SR, false);
387 BT_MBOX_PRINT(1, LE_MSTR, false);
388 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
389 BT_MBOX_PRINT(1, MSG_TYPE, false);
390 BT_MBOX_PRINT(1, SSN, true);
391
392 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
393
394 BT_MBOX_PRINT(2, SNIFF_ACT, false);
395 BT_MBOX_PRINT(2, PAG, false);
396 BT_MBOX_PRINT(2, INQUIRY, false);
397 BT_MBOX_PRINT(2, CONN, false);
398 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
399 BT_MBOX_PRINT(2, DISC, false);
400 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
401 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
402 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
403 BT_MBOX_PRINT(2, SCO_DURATION, true);
10942342 404
160be571
EG
405 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
406
407 BT_MBOX_PRINT(3, SCO_STATE, false);
408 BT_MBOX_PRINT(3, SNIFF_STATE, false);
409 BT_MBOX_PRINT(3, A2DP_STATE, false);
410 BT_MBOX_PRINT(3, ACL_STATE, false);
411 BT_MBOX_PRINT(3, MSTR_STATE, false);
412 BT_MBOX_PRINT(3, OBX_STATE, false);
413 BT_MBOX_PRINT(3, OPEN_CON_2, false);
414 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
415 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
416 BT_MBOX_PRINT(3, INBAND_P, false);
417 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
418 BT_MBOX_PRINT(3, SSN_2, false);
419 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
420
421 return pos;
422}
423
424static
425int iwl_mvm_coex_dump_mbox_old(struct iwl_bt_coex_profile_notif_old *notif,
426 char *buf, int pos, int bufsz)
427{
10942342
EG
428 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
429
430 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
431 BT_MBOX_PRINT(0, LE_PROF1, false);
432 BT_MBOX_PRINT(0, LE_PROF2, false);
433 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
434 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
435 BT_MBOX_PRINT(0, INBAND_S, false);
436 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
437 BT_MBOX_PRINT(0, LE_SCAN, false);
438 BT_MBOX_PRINT(0, LE_ADV, false);
439 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
440 BT_MBOX_PRINT(0, OPEN_CON_1, true);
441
442 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
443
444 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
445 BT_MBOX_PRINT(1, IP_SR, false);
446 BT_MBOX_PRINT(1, LE_MSTR, false);
447 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
448 BT_MBOX_PRINT(1, MSG_TYPE, false);
449 BT_MBOX_PRINT(1, SSN, true);
450
451 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
452
453 BT_MBOX_PRINT(2, SNIFF_ACT, false);
454 BT_MBOX_PRINT(2, PAG, false);
455 BT_MBOX_PRINT(2, INQUIRY, false);
456 BT_MBOX_PRINT(2, CONN, false);
457 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
458 BT_MBOX_PRINT(2, DISC, false);
459 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
460 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
461 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
462 BT_MBOX_PRINT(2, SCO_DURATION, true);
463
464 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
465
466 BT_MBOX_PRINT(3, SCO_STATE, false);
467 BT_MBOX_PRINT(3, SNIFF_STATE, false);
468 BT_MBOX_PRINT(3, A2DP_STATE, false);
469 BT_MBOX_PRINT(3, ACL_STATE, false);
470 BT_MBOX_PRINT(3, MSTR_STATE, false);
471 BT_MBOX_PRINT(3, OBX_STATE, false);
472 BT_MBOX_PRINT(3, OPEN_CON_2, false);
473 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
474 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
475 BT_MBOX_PRINT(3, INBAND_P, false);
476 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
477 BT_MBOX_PRINT(3, SSN_2, false);
478 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
479
160be571
EG
480 return pos;
481}
482
483static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
484 size_t count, loff_t *ppos)
485{
486 struct iwl_mvm *mvm = file->private_data;
487 char *buf;
488 int ret, pos = 0, bufsz = sizeof(char) * 1024;
489
490 buf = kmalloc(bufsz, GFP_KERNEL);
491 if (!buf)
492 return -ENOMEM;
493
494 mutex_lock(&mvm->mutex);
495
859d914c
JB
496 if (!fw_has_api(&mvm->fw->ucode_capa,
497 IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
160be571
EG
498 struct iwl_bt_coex_profile_notif_old *notif =
499 &mvm->last_bt_notif_old;
500
501 pos += iwl_mvm_coex_dump_mbox_old(notif, buf, pos, bufsz);
502
503 pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
504 notif->bt_ci_compliance);
505 pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
506 le32_to_cpu(notif->primary_ch_lut));
507 pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
508 le32_to_cpu(notif->secondary_ch_lut));
509 pos += scnprintf(buf+pos,
510 bufsz-pos, "bt_activity_grading = %d\n",
511 le32_to_cpu(notif->bt_activity_grading));
512 pos += scnprintf(buf+pos, bufsz-pos,
513 "antenna isolation = %d CORUN LUT index = %d\n",
514 mvm->last_ant_isol, mvm->last_corun_lut);
515 } else {
516 struct iwl_bt_coex_profile_notif *notif =
517 &mvm->last_bt_notif;
518
519 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
520
521 pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
522 notif->bt_ci_compliance);
523 pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
524 le32_to_cpu(notif->primary_ch_lut));
525 pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
526 le32_to_cpu(notif->secondary_ch_lut));
527 pos += scnprintf(buf+pos,
528 bufsz-pos, "bt_activity_grading = %d\n",
529 le32_to_cpu(notif->bt_activity_grading));
530 pos += scnprintf(buf+pos, bufsz-pos,
531 "antenna isolation = %d CORUN LUT index = %d\n",
532 mvm->last_ant_isol, mvm->last_corun_lut);
533 }
10942342 534
c725a46b
MH
535 pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n",
536 IWL_MVM_BT_COEX_SYNC2SCO);
537 pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n",
538 IWL_MVM_BT_COEX_MPLUT);
539 pos += scnprintf(buf + pos, bufsz - pos, "corunning = %d\n",
540 IWL_MVM_BT_COEX_CORUNNING);
541
10942342
EG
542 mutex_unlock(&mvm->mutex);
543
544 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
545 kfree(buf);
546
547 return ret;
548}
549#undef BT_MBOX_PRINT
550
2de13cae
EG
551static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
552 size_t count, loff_t *ppos)
553{
554 struct iwl_mvm *mvm = file->private_data;
2de13cae
EG
555 char buf[256];
556 int bufsz = sizeof(buf);
557 int pos = 0;
558
559 mutex_lock(&mvm->mutex);
560
859d914c
JB
561 if (!fw_has_api(&mvm->fw->ucode_capa,
562 IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
160be571
EG
563 struct iwl_bt_coex_ci_cmd_old *cmd = &mvm->last_bt_ci_cmd_old;
564
565 pos += scnprintf(buf+pos, bufsz-pos,
566 "Channel inhibition CMD\n");
567 pos += scnprintf(buf+pos, bufsz-pos,
568 "\tPrimary Channel Bitmap 0x%016llx\n",
569 le64_to_cpu(cmd->bt_primary_ci));
570 pos += scnprintf(buf+pos, bufsz-pos,
571 "\tSecondary Channel Bitmap 0x%016llx\n",
572 le64_to_cpu(cmd->bt_secondary_ci));
573
aee8bf5d
EG
574 pos += scnprintf(buf+pos, bufsz-pos,
575 "BT Configuration CMD - 0=default, 1=never, 2=always\n");
576 pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill msk idx %d\n",
577 mvm->bt_ack_kill_msk[0]);
578 pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill msk idx %d\n",
579 mvm->bt_cts_kill_msk[0]);
160be571
EG
580
581 } else {
582 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
583
584 pos += scnprintf(buf+pos, bufsz-pos,
585 "Channel inhibition CMD\n");
586 pos += scnprintf(buf+pos, bufsz-pos,
587 "\tPrimary Channel Bitmap 0x%016llx\n",
588 le64_to_cpu(cmd->bt_primary_ci));
589 pos += scnprintf(buf+pos, bufsz-pos,
590 "\tSecondary Channel Bitmap 0x%016llx\n",
591 le64_to_cpu(cmd->bt_secondary_ci));
160be571 592 }
2de13cae
EG
593
594 mutex_unlock(&mvm->mutex);
595
596 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
597}
598
cdb00563
EG
599static ssize_t
600iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
601 size_t count, loff_t *ppos)
602{
603 u32 bt_tx_prio;
604
605 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
606 return -EINVAL;
607 if (bt_tx_prio > 4)
608 return -EINVAL;
609
610 mvm->bt_tx_prio = bt_tx_prio;
611
612 return count;
613}
614
a39979a8
EG
615static ssize_t
616iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
617 size_t count, loff_t *ppos)
618{
619 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
620 [BT_FORCE_ANT_DIS] = "dis",
621 [BT_FORCE_ANT_AUTO] = "auto",
622 [BT_FORCE_ANT_BT] = "bt",
623 [BT_FORCE_ANT_WIFI] = "wifi",
624 };
625 int ret, bt_force_ant_mode;
626
627 for (bt_force_ant_mode = 0;
628 bt_force_ant_mode < ARRAY_SIZE(modes_str);
629 bt_force_ant_mode++) {
630 if (!strcmp(buf, modes_str[bt_force_ant_mode]))
631 break;
632 }
633
634 if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
635 return -EINVAL;
636
637 ret = 0;
638 mutex_lock(&mvm->mutex);
639 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
640 goto out;
641
642 mvm->bt_force_ant_mode = bt_force_ant_mode;
643 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
644 modes_str[mvm->bt_force_ant_mode]);
645 ret = iwl_send_bt_init_conf(mvm);
646
647out:
648 mutex_unlock(&mvm->mutex);
649 return ret ?: count;
650}
651
93d17cce 652#define PRINT_STATS_LE32(_struct, _memb) \
3848ab66 653 pos += scnprintf(buf + pos, bufsz - pos, \
93d17cce
JB
654 fmt_table, #_memb, \
655 le32_to_cpu(_struct->_memb))
3848ab66
MG
656
657static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
658 char __user *user_buf, size_t count,
659 loff_t *ppos)
660{
661 struct iwl_mvm *mvm = file->private_data;
662 static const char *fmt_table = "\t%-30s %10u\n";
663 static const char *fmt_header = "%-32s\n";
664 int pos = 0;
665 char *buf;
666 int ret;
3f617281
LC
667 /* 43 is the size of each data line, 33 is the size of each header */
668 size_t bufsz =
669 ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) +
670 (4 * 33) + 1;
671
3848ab66
MG
672 struct mvm_statistics_rx_phy *ofdm;
673 struct mvm_statistics_rx_phy *cck;
674 struct mvm_statistics_rx_non_phy *general;
675 struct mvm_statistics_rx_ht_phy *ht;
676
677 buf = kzalloc(bufsz, GFP_KERNEL);
678 if (!buf)
679 return -ENOMEM;
680
681 mutex_lock(&mvm->mutex);
682
683 ofdm = &mvm->rx_stats.ofdm;
684 cck = &mvm->rx_stats.cck;
685 general = &mvm->rx_stats.general;
686 ht = &mvm->rx_stats.ofdm_ht;
687
688 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
689 "Statistics_Rx - OFDM");
93d17cce
JB
690 PRINT_STATS_LE32(ofdm, ina_cnt);
691 PRINT_STATS_LE32(ofdm, fina_cnt);
692 PRINT_STATS_LE32(ofdm, plcp_err);
693 PRINT_STATS_LE32(ofdm, crc32_err);
694 PRINT_STATS_LE32(ofdm, overrun_err);
695 PRINT_STATS_LE32(ofdm, early_overrun_err);
696 PRINT_STATS_LE32(ofdm, crc32_good);
697 PRINT_STATS_LE32(ofdm, false_alarm_cnt);
698 PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
699 PRINT_STATS_LE32(ofdm, sfd_timeout);
700 PRINT_STATS_LE32(ofdm, fina_timeout);
701 PRINT_STATS_LE32(ofdm, unresponded_rts);
702 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
703 PRINT_STATS_LE32(ofdm, sent_ack_cnt);
704 PRINT_STATS_LE32(ofdm, sent_cts_cnt);
705 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
706 PRINT_STATS_LE32(ofdm, dsp_self_kill);
707 PRINT_STATS_LE32(ofdm, mh_format_err);
708 PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
709 PRINT_STATS_LE32(ofdm, reserved);
3848ab66
MG
710
711 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
712 "Statistics_Rx - CCK");
93d17cce
JB
713 PRINT_STATS_LE32(cck, ina_cnt);
714 PRINT_STATS_LE32(cck, fina_cnt);
715 PRINT_STATS_LE32(cck, plcp_err);
716 PRINT_STATS_LE32(cck, crc32_err);
717 PRINT_STATS_LE32(cck, overrun_err);
718 PRINT_STATS_LE32(cck, early_overrun_err);
719 PRINT_STATS_LE32(cck, crc32_good);
720 PRINT_STATS_LE32(cck, false_alarm_cnt);
721 PRINT_STATS_LE32(cck, fina_sync_err_cnt);
722 PRINT_STATS_LE32(cck, sfd_timeout);
723 PRINT_STATS_LE32(cck, fina_timeout);
724 PRINT_STATS_LE32(cck, unresponded_rts);
725 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
726 PRINT_STATS_LE32(cck, sent_ack_cnt);
727 PRINT_STATS_LE32(cck, sent_cts_cnt);
728 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
729 PRINT_STATS_LE32(cck, dsp_self_kill);
730 PRINT_STATS_LE32(cck, mh_format_err);
731 PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
732 PRINT_STATS_LE32(cck, reserved);
3848ab66
MG
733
734 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
735 "Statistics_Rx - GENERAL");
93d17cce
JB
736 PRINT_STATS_LE32(general, bogus_cts);
737 PRINT_STATS_LE32(general, bogus_ack);
738 PRINT_STATS_LE32(general, non_bssid_frames);
739 PRINT_STATS_LE32(general, filtered_frames);
740 PRINT_STATS_LE32(general, non_channel_beacons);
741 PRINT_STATS_LE32(general, channel_beacons);
742 PRINT_STATS_LE32(general, num_missed_bcon);
743 PRINT_STATS_LE32(general, adc_rx_saturation_time);
744 PRINT_STATS_LE32(general, ina_detection_search_time);
745 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
746 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
747 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
748 PRINT_STATS_LE32(general, interference_data_flag);
749 PRINT_STATS_LE32(general, channel_load);
750 PRINT_STATS_LE32(general, dsp_false_alarms);
751 PRINT_STATS_LE32(general, beacon_rssi_a);
752 PRINT_STATS_LE32(general, beacon_rssi_b);
753 PRINT_STATS_LE32(general, beacon_rssi_c);
754 PRINT_STATS_LE32(general, beacon_energy_a);
755 PRINT_STATS_LE32(general, beacon_energy_b);
756 PRINT_STATS_LE32(general, beacon_energy_c);
757 PRINT_STATS_LE32(general, num_bt_kills);
758 PRINT_STATS_LE32(general, mac_id);
759 PRINT_STATS_LE32(general, directed_data_mpdu);
3848ab66
MG
760
761 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
762 "Statistics_Rx - HT");
93d17cce
JB
763 PRINT_STATS_LE32(ht, plcp_err);
764 PRINT_STATS_LE32(ht, overrun_err);
765 PRINT_STATS_LE32(ht, early_overrun_err);
766 PRINT_STATS_LE32(ht, crc32_good);
767 PRINT_STATS_LE32(ht, crc32_err);
768 PRINT_STATS_LE32(ht, mh_format_err);
769 PRINT_STATS_LE32(ht, agg_crc32_good);
770 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
771 PRINT_STATS_LE32(ht, agg_cnt);
772 PRINT_STATS_LE32(ht, unsupport_mcs);
3848ab66
MG
773
774 mutex_unlock(&mvm->mutex);
775
776 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
777 kfree(buf);
778
779 return ret;
780}
781#undef PRINT_STAT_LE32
782
5fc0f76c
ES
783static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
784 char __user *user_buf, size_t count,
785 loff_t *ppos,
786 struct iwl_mvm_frame_stats *stats)
787{
f754b5ca
ES
788 char *buff, *pos, *endpos;
789 int idx, i;
5fc0f76c 790 int ret;
f754b5ca 791 static const size_t bufsz = 1024;
5fc0f76c
ES
792
793 buff = kmalloc(bufsz, GFP_KERNEL);
794 if (!buff)
795 return -ENOMEM;
796
797 spin_lock_bh(&mvm->drv_stats_lock);
f754b5ca
ES
798
799 pos = buff;
800 endpos = pos + bufsz;
801
802 pos += scnprintf(pos, endpos - pos,
5fc0f76c
ES
803 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
804 stats->legacy_frames,
805 stats->ht_frames,
806 stats->vht_frames);
f754b5ca 807 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
5fc0f76c
ES
808 stats->bw_20_frames,
809 stats->bw_40_frames,
810 stats->bw_80_frames);
f754b5ca 811 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
5fc0f76c
ES
812 stats->ngi_frames,
813 stats->sgi_frames);
f754b5ca 814 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
5fc0f76c
ES
815 stats->siso_frames,
816 stats->mimo2_frames);
f754b5ca 817 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
5fc0f76c
ES
818 stats->fail_frames,
819 stats->success_frames);
f754b5ca 820 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
5fc0f76c 821 stats->agg_frames);
f754b5ca 822 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
5fc0f76c 823 stats->ampdu_count);
f754b5ca 824 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
5fc0f76c
ES
825 stats->ampdu_count > 0 ?
826 (stats->agg_frames / stats->ampdu_count) : 0);
827
f754b5ca 828 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
5fc0f76c
ES
829
830 idx = stats->last_frame_idx - 1;
831 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
832 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
833 if (stats->last_rates[idx] == 0)
834 continue;
f754b5ca 835 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
5fc0f76c 836 (int)(ARRAY_SIZE(stats->last_rates) - i));
f754b5ca 837 pos += rs_pretty_print_rate(pos, stats->last_rates[idx]);
5fc0f76c
ES
838 }
839 spin_unlock_bh(&mvm->drv_stats_lock);
840
f754b5ca 841 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
5fc0f76c
ES
842 kfree(buff);
843
844 return ret;
845}
846
847static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
848 char __user *user_buf, size_t count,
849 loff_t *ppos)
850{
851 struct iwl_mvm *mvm = file->private_data;
852
853 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
854 &mvm->drv_rx_stats);
855}
856
1fa3f57a 857static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
490953ac
EG
858 size_t count, loff_t *ppos)
859{
490953ac
EG
860 int ret;
861
490953ac
EG
862 mutex_lock(&mvm->mutex);
863
291aa7c4
EH
864 /* allow one more restart that we're provoking here */
865 if (mvm->restart_fw >= 0)
866 mvm->restart_fw++;
867
490953ac 868 /* take the return value to make compiler happy - it will fail anyway */
a1022927 869 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
490953ac
EG
870
871 mutex_unlock(&mvm->mutex);
872
490953ac
EG
873 return count;
874}
875
1fa3f57a 876static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
119663c3
AB
877 size_t count, loff_t *ppos)
878{
576eeee9
EP
879 int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
880 if (ret)
881 return ret;
882
4c9706dc 883 iwl_force_nmi(mvm->trans);
119663c3 884
576eeee9
EP
885 iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
886
119663c3
AB
887 return count;
888}
889
91b05d10
OG
890static ssize_t
891iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
892 char __user *user_buf,
893 size_t count, loff_t *ppos)
894{
895 struct iwl_mvm *mvm = file->private_data;
896 int pos = 0;
897 char buf[32];
898 const size_t bufsz = sizeof(buf);
899
900 /* print which antennas were set for the scan command by the user */
901 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
902 if (mvm->scan_rx_ant & ANT_A)
903 pos += scnprintf(buf + pos, bufsz - pos, "A");
904 if (mvm->scan_rx_ant & ANT_B)
905 pos += scnprintf(buf + pos, bufsz - pos, "B");
906 if (mvm->scan_rx_ant & ANT_C)
907 pos += scnprintf(buf + pos, bufsz - pos, "C");
908 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
909
910 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
911}
912
913static ssize_t
1fa3f57a 914iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
91b05d10
OG
915 size_t count, loff_t *ppos)
916{
91b05d10
OG
917 u8 scan_rx_ant;
918
91b05d10
OG
919 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
920 return -EINVAL;
921 if (scan_rx_ant > ANT_ABC)
922 return -EINVAL;
a0544272 923 if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
91b05d10
OG
924 return -EINVAL;
925
d2496221
DS
926 if (mvm->scan_rx_ant != scan_rx_ant) {
927 mvm->scan_rx_ant = scan_rx_ant;
859d914c
JB
928 if (fw_has_capa(&mvm->fw->ucode_capa,
929 IWL_UCODE_TLV_CAPA_UMAC_SCAN))
d2496221
DS
930 iwl_mvm_config_scan(mvm);
931 }
91b05d10
OG
932
933 return count;
934}
935
8c23f95c
EG
936static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
937 char __user *user_buf,
938 size_t count, loff_t *ppos)
939{
940 struct iwl_mvm *mvm = file->private_data;
d2709ad7 941 int conf;
8c23f95c
EG
942 char buf[8];
943 const size_t bufsz = sizeof(buf);
944 int pos = 0;
945
946 mutex_lock(&mvm->mutex);
947 conf = mvm->fw_dbg_conf;
948 mutex_unlock(&mvm->mutex);
949
950 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
951
952 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
953}
954
955static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
956 char *buf, size_t count,
957 loff_t *ppos)
958{
8e8114de
DC
959 unsigned int conf_id;
960 int ret;
8c23f95c 961
8e8114de 962 ret = kstrtouint(buf, 0, &conf_id);
8c23f95c
EG
963 if (ret)
964 return ret;
965
d2709ad7 966 if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
8c23f95c
EG
967 return -EINVAL;
968
969 mutex_lock(&mvm->mutex);
970 ret = iwl_mvm_start_fw_dbg_conf(mvm, conf_id);
971 mutex_unlock(&mvm->mutex);
972
973 return ret ?: count;
974}
975
976static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
977 char *buf, size_t count,
978 loff_t *ppos)
979{
e93475a0
LK
980 int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
981
982 if (ret)
983 return ret;
984
36fb9017 985 iwl_mvm_fw_dbg_collect(mvm, FW_DBG_TRIGGER_USER, NULL, 0, NULL);
e93475a0
LK
986
987 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
8c23f95c
EG
988
989 return count;
990}
991
de06a59e
EP
992#define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
993#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
994static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
995 char __user *user_buf,
996 size_t count, loff_t *ppos)
997{
998 struct iwl_mvm *mvm = file->private_data;
999 struct iwl_bcast_filter_cmd cmd;
1000 const struct iwl_fw_bcast_filter *filter;
1001 char *buf;
1002 int bufsz = 1024;
1003 int i, j, pos = 0;
1004 ssize_t ret;
1005
1006 buf = kzalloc(bufsz, GFP_KERNEL);
1007 if (!buf)
1008 return -ENOMEM;
1009
1010 mutex_lock(&mvm->mutex);
1011 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1012 ADD_TEXT("None\n");
1013 mutex_unlock(&mvm->mutex);
1014 goto out;
1015 }
1016 mutex_unlock(&mvm->mutex);
1017
1018 for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
1019 filter = &cmd.filters[i];
1020
1021 ADD_TEXT("Filter [%d]:\n", i);
1022 ADD_TEXT("\tDiscard=%d\n", filter->discard);
1023 ADD_TEXT("\tFrame Type: %s\n",
1024 filter->frame_type ? "IPv4" : "Generic");
1025
1026 for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
1027 const struct iwl_fw_bcast_filter_attr *attr;
1028
1029 attr = &filter->attrs[j];
1030 if (!attr->mask)
1031 break;
1032
1033 ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
1034 j, attr->offset,
1035 attr->offset_type ? "IP End" :
1036 "Payload Start",
1037 be32_to_cpu(attr->mask),
1038 be32_to_cpu(attr->val),
1039 le16_to_cpu(attr->reserved1));
1040 }
1041 }
1042out:
1043 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1044 kfree(buf);
1045 return ret;
1046}
1047
1048static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
1049 size_t count, loff_t *ppos)
1050{
1051 int pos, next_pos;
1052 struct iwl_fw_bcast_filter filter = {};
1053 struct iwl_bcast_filter_cmd cmd;
1054 u32 filter_id, attr_id, mask, value;
1055 int err = 0;
1056
1057 if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
1058 &filter.frame_type, &pos) != 3)
1059 return -EINVAL;
1060
1061 if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
1062 filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
1063 return -EINVAL;
1064
1065 for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
1066 attr_id++) {
1067 struct iwl_fw_bcast_filter_attr *attr =
1068 &filter.attrs[attr_id];
1069
1070 if (pos >= count)
1071 break;
1072
1073 if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
1074 &attr->offset, &attr->offset_type,
1075 &mask, &value, &next_pos) != 4)
1076 return -EINVAL;
1077
1078 attr->mask = cpu_to_be32(mask);
1079 attr->val = cpu_to_be32(value);
1080 if (mask)
1081 filter.num_attrs++;
1082
1083 pos += next_pos;
1084 }
1085
1086 mutex_lock(&mvm->mutex);
1087 memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
1088 &filter, sizeof(filter));
1089
1090 /* send updated bcast filtering configuration */
1091 if (mvm->dbgfs_bcast_filtering.override &&
1092 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
a1022927 1093 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
de06a59e
EP
1094 sizeof(cmd), &cmd);
1095 mutex_unlock(&mvm->mutex);
1096
1097 return err ?: count;
1098}
1099
1100static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
1101 char __user *user_buf,
1102 size_t count, loff_t *ppos)
1103{
1104 struct iwl_mvm *mvm = file->private_data;
1105 struct iwl_bcast_filter_cmd cmd;
1106 char *buf;
1107 int bufsz = 1024;
1108 int i, pos = 0;
1109 ssize_t ret;
1110
1111 buf = kzalloc(bufsz, GFP_KERNEL);
1112 if (!buf)
1113 return -ENOMEM;
1114
1115 mutex_lock(&mvm->mutex);
1116 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1117 ADD_TEXT("None\n");
1118 mutex_unlock(&mvm->mutex);
1119 goto out;
1120 }
1121 mutex_unlock(&mvm->mutex);
1122
1123 for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
1124 const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
1125
1126 ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
1127 i, mac->default_discard, mac->attached_filters);
1128 }
1129out:
1130 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1131 kfree(buf);
1132 return ret;
1133}
1134
1135static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
1136 char *buf, size_t count,
1137 loff_t *ppos)
1138{
1139 struct iwl_bcast_filter_cmd cmd;
1140 struct iwl_fw_bcast_mac mac = {};
1141 u32 mac_id, attached_filters;
1142 int err = 0;
1143
1144 if (!mvm->bcast_filters)
1145 return -ENOENT;
1146
1147 if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
1148 &attached_filters) != 3)
1149 return -EINVAL;
1150
1151 if (mac_id >= ARRAY_SIZE(cmd.macs) ||
1152 mac.default_discard > 1 ||
1153 attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
1154 return -EINVAL;
1155
1156 mac.attached_filters = cpu_to_le16(attached_filters);
1157
1158 mutex_lock(&mvm->mutex);
1159 memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
1160 &mac, sizeof(mac));
1161
1162 /* send updated bcast filtering configuration */
1163 if (mvm->dbgfs_bcast_filtering.override &&
1164 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
a1022927 1165 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
de06a59e
EP
1166 sizeof(cmd), &cmd);
1167 mutex_unlock(&mvm->mutex);
1168
1169 return err ?: count;
1170}
1171#endif
1172
afc66bb7 1173#ifdef CONFIG_PM_SLEEP
1fa3f57a 1174static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
afc66bb7
JB
1175 size_t count, loff_t *ppos)
1176{
afc66bb7
JB
1177 int store;
1178
afc66bb7
JB
1179 if (sscanf(buf, "%d", &store) != 1)
1180 return -EINVAL;
1181
1182 mvm->store_d3_resume_sram = store;
1183
1184 return count;
1185}
1186
1187static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
1188 size_t count, loff_t *ppos)
1189{
1190 struct iwl_mvm *mvm = file->private_data;
1191 const struct fw_img *img;
1192 int ofs, len, pos = 0;
1193 size_t bufsz, ret;
1194 char *buf;
1195 u8 *ptr = mvm->d3_resume_sram;
1196
1197 img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1198 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1199
1200 bufsz = len * 4 + 256;
1201 buf = kzalloc(bufsz, GFP_KERNEL);
1202 if (!buf)
1203 return -ENOMEM;
1204
1205 pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
1206 mvm->store_d3_resume_sram ? "en" : "dis");
1207
1208 if (ptr) {
1209 for (ofs = 0; ofs < len; ofs += 16) {
1210 pos += scnprintf(buf + pos, bufsz - pos,
3cd6e2f7 1211 "0x%.4x %16ph\n", ofs, ptr + ofs);
afc66bb7
JB
1212 }
1213 } else {
1214 pos += scnprintf(buf + pos, bufsz - pos,
1215 "(no data captured)\n");
1216 }
1217
1218 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1219
1220 kfree(buf);
1221
1222 return ret;
1223}
1224#endif
1225
576eeee9
EP
1226#define PRINT_MVM_REF(ref) do { \
1227 if (mvm->refs[ref]) \
1228 pos += scnprintf(buf + pos, bufsz - pos, \
1229 "\t(0x%lx): %d %s\n", \
1230 BIT(ref), mvm->refs[ref], #ref); \
70d6babb
EP
1231} while (0)
1232
1233static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
1234 char __user *user_buf,
1235 size_t count, loff_t *ppos)
1236{
1237 struct iwl_mvm *mvm = file->private_data;
576eeee9 1238 int i, pos = 0;
70d6babb
EP
1239 char buf[256];
1240 const size_t bufsz = sizeof(buf);
576eeee9
EP
1241 u32 refs = 0;
1242
1243 for (i = 0; i < IWL_MVM_REF_COUNT; i++)
1244 if (mvm->refs[i])
1245 refs |= BIT(i);
70d6babb 1246
576eeee9
EP
1247 pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
1248 refs);
70d6babb
EP
1249
1250 PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
1251 PRINT_MVM_REF(IWL_MVM_REF_SCAN);
1252 PRINT_MVM_REF(IWL_MVM_REF_ROC);
c779273b 1253 PRINT_MVM_REF(IWL_MVM_REF_ROC_AUX);
70d6babb
EP
1254 PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
1255 PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
0eb83653 1256 PRINT_MVM_REF(IWL_MVM_REF_USER);
34e611ea
JB
1257 PRINT_MVM_REF(IWL_MVM_REF_TX);
1258 PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
1259 PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
1260 PRINT_MVM_REF(IWL_MVM_REF_START_AP);
1261 PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
1262 PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
1263 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
1264 PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
1265 PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
1266 PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
1267 PRINT_MVM_REF(IWL_MVM_REF_NMI);
1268 PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
d15a747f 1269 PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
160acc0e 1270 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA);
fb2380a2 1271 PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT);
70d6babb
EP
1272
1273 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1274}
1275
0eb83653
EP
1276static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
1277 size_t count, loff_t *ppos)
1278{
1279 unsigned long value;
1280 int ret;
1281 bool taken;
1282
1283 ret = kstrtoul(buf, 10, &value);
1284 if (ret < 0)
1285 return ret;
1286
1287 mutex_lock(&mvm->mutex);
1288
576eeee9 1289 taken = mvm->refs[IWL_MVM_REF_USER];
0eb83653
EP
1290 if (value == 1 && !taken)
1291 iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
1292 else if (value == 0 && taken)
1293 iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
1294 else
1295 ret = -EINVAL;
1296
1297 mutex_unlock(&mvm->mutex);
1298
1299 if (ret < 0)
1300 return ret;
1301 return count;
1302}
1303
1fa3f57a
JB
1304#define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1305 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1306#define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1307 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
de06a59e
EP
1308#define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1309 if (!debugfs_create_file(alias, mode, parent, mvm, \
8ca151b5
JB
1310 &iwl_dbgfs_##name##_ops)) \
1311 goto err; \
1312 } while (0)
de06a59e
EP
1313#define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1314 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
8ca151b5 1315
f3c221f6
EP
1316static ssize_t
1317iwl_dbgfs_prph_reg_read(struct file *file,
1318 char __user *user_buf,
1319 size_t count, loff_t *ppos)
1320{
1321 struct iwl_mvm *mvm = file->private_data;
1322 int pos = 0;
1323 char buf[32];
1324 const size_t bufsz = sizeof(buf);
576eeee9 1325 int ret;
f3c221f6
EP
1326
1327 if (!mvm->dbgfs_prph_reg_addr)
1328 return -EINVAL;
1329
576eeee9
EP
1330 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
1331 if (ret)
1332 return ret;
1333
f3c221f6
EP
1334 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1335 mvm->dbgfs_prph_reg_addr,
1336 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1337
576eeee9
EP
1338 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
1339
f3c221f6
EP
1340 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1341}
1342
1343static ssize_t
1344iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1345 size_t count, loff_t *ppos)
1346{
1347 u8 args;
1348 u32 value;
576eeee9 1349 int ret;
f3c221f6
EP
1350
1351 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1352 /* if we only want to set the reg address - nothing more to do */
1353 if (args == 1)
1354 goto out;
1355
1356 /* otherwise, make sure we have both address and value */
1357 if (args != 2)
1358 return -EINVAL;
1359
576eeee9
EP
1360 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1361 if (ret)
1362 return ret;
1363
f3c221f6 1364 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
576eeee9
EP
1365
1366 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
f3c221f6
EP
1367out:
1368 return count;
1369}
1370
e5046019
EG
1371static ssize_t
1372iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1373 size_t count, loff_t *ppos)
1374{
1375 int ret;
1376
1377 mutex_lock(&mvm->mutex);
1378 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
1379 mutex_unlock(&mvm->mutex);
1380
1381 return ret ?: count;
1382}
1383
f3c221f6
EP
1384MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1385
8ca151b5 1386/* Device wide debugfs entries */
1fa3f57a
JB
1387MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1388MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
e5046019 1389MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
1fa3f57a 1390MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
7280d1f0 1391MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
c549e390 1392MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
8ca151b5 1393MVM_DEBUGFS_READ_FILE_OPS(stations);
10942342 1394MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
2de13cae 1395MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
1fa3f57a 1396MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
3848ab66 1397MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
5fc0f76c 1398MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
1fa3f57a
JB
1399MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1400MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
cdb00563 1401MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
a39979a8 1402MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
1fa3f57a 1403MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
0eb83653 1404MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
8c23f95c
EG
1405MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
1406MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 8);
91b05d10 1407
de06a59e
EP
1408#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1409MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
1410MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
1411#endif
1412
afc66bb7 1413#ifdef CONFIG_PM_SLEEP
1fa3f57a 1414MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
afc66bb7 1415#endif
8ca151b5
JB
1416
1417int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1418{
de06a59e 1419 struct dentry *bcast_dir __maybe_unused;
8ca151b5
JB
1420 char buf[100];
1421
d07913aa
JB
1422 spin_lock_init(&mvm->drv_stats_lock);
1423
8ca151b5
JB
1424 mvm->debugfs_dir = dbgfs_dir;
1425
1426 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
1427 MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
1428 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
7280d1f0
MG
1429 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir,
1430 S_IWUSR | S_IRUSR);
c549e390 1431 MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR);
8ca151b5 1432 MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
10942342 1433 MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
2de13cae 1434 MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR);
639eabad
EG
1435 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir,
1436 S_IRUSR | S_IWUSR);
3848ab66 1437 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR);
5fc0f76c 1438 MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR);
490953ac 1439 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
119663c3 1440 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
cdb00563 1441 MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR);
a39979a8 1442 MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR);
91b05d10
OG
1443 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
1444 S_IWUSR | S_IRUSR);
f3c221f6 1445 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
0eb83653 1446 MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
8c23f95c
EG
1447 MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
1448 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, S_IWUSR);
e5046019 1449 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR);
cb2513bb
LC
1450 if (!debugfs_create_bool("enable_scan_iteration_notif",
1451 S_IRUSR | S_IWUSR,
1452 mvm->debugfs_dir,
1453 &mvm->scan_iter_notif_enabled))
1454 goto err;
de06a59e
EP
1455
1456#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1457 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
1458 bcast_dir = debugfs_create_dir("bcast_filtering",
1459 mvm->debugfs_dir);
1460 if (!bcast_dir)
1461 goto err;
1462
1463 if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR,
1464 bcast_dir,
1465 &mvm->dbgfs_bcast_filtering.override))
1466 goto err;
1467
1468 MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
1469 bcast_dir, S_IWUSR | S_IRUSR);
1470 MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
1471 bcast_dir, S_IWUSR | S_IRUSR);
1472 }
1473#endif
1474
afc66bb7
JB
1475#ifdef CONFIG_PM_SLEEP
1476 MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
debff618 1477 MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
b0114714
JB
1478 if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
1479 mvm->debugfs_dir, &mvm->d3_wake_sysassert))
1480 goto err;
484b3d13
LC
1481 if (!debugfs_create_u32("last_netdetect_scans", S_IRUSR,
1482 mvm->debugfs_dir, &mvm->last_netdetect_scans))
1483 goto err;
afc66bb7 1484#endif
8ca151b5 1485
9ecd051e
ES
1486 if (!debugfs_create_u8("low_latency_agg_frame_limit", S_IRUSR | S_IWUSR,
1487 mvm->debugfs_dir,
1488 &mvm->low_latency_agg_frame_limit))
1489 goto err;
bdd54839
LC
1490 if (!debugfs_create_u8("ps_disabled", S_IRUSR,
1491 mvm->debugfs_dir, &mvm->ps_disabled))
1492 goto err;
086f7368
EG
1493 if (!debugfs_create_blob("nvm_hw", S_IRUSR,
1494 mvm->debugfs_dir, &mvm->nvm_hw_blob))
1495 goto err;
1496 if (!debugfs_create_blob("nvm_sw", S_IRUSR,
1497 mvm->debugfs_dir, &mvm->nvm_sw_blob))
1498 goto err;
1499 if (!debugfs_create_blob("nvm_calib", S_IRUSR,
1500 mvm->debugfs_dir, &mvm->nvm_calib_blob))
1501 goto err;
1502 if (!debugfs_create_blob("nvm_prod", S_IRUSR,
1503 mvm->debugfs_dir, &mvm->nvm_prod_blob))
1504 goto err;
91fac940
MH
1505 if (!debugfs_create_blob("nvm_phy_sku", S_IRUSR,
1506 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
1507 goto err;
086f7368 1508
8ca151b5
JB
1509 /*
1510 * Create a symlink with mac80211. It will be removed when mac80211
1511 * exists (before the opmode exists which removes the target.)
1512 */
1513 snprintf(buf, 100, "../../%s/%s",
1514 dbgfs_dir->d_parent->d_parent->d_name.name,
1515 dbgfs_dir->d_parent->d_name.name);
1516 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
1517 goto err;
1518
1519 return 0;
1520err:
1521 IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
1522 return -ENOMEM;
1523}
This page took 0.376523 seconds and 5 git commands to generate.