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