iwlwifi: mvm: BT Coex - change the MPLUT registers' value
[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
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
496 if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
497 struct iwl_bt_coex_profile_notif_old *notif =
498 &mvm->last_bt_notif_old;
499
500 pos += iwl_mvm_coex_dump_mbox_old(notif, buf, pos, bufsz);
501
502 pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
503 notif->bt_ci_compliance);
504 pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
505 le32_to_cpu(notif->primary_ch_lut));
506 pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
507 le32_to_cpu(notif->secondary_ch_lut));
508 pos += scnprintf(buf+pos,
509 bufsz-pos, "bt_activity_grading = %d\n",
510 le32_to_cpu(notif->bt_activity_grading));
511 pos += scnprintf(buf+pos, bufsz-pos,
512 "antenna isolation = %d CORUN LUT index = %d\n",
513 mvm->last_ant_isol, mvm->last_corun_lut);
514 } else {
515 struct iwl_bt_coex_profile_notif *notif =
516 &mvm->last_bt_notif;
517
518 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
519
520 pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
521 notif->bt_ci_compliance);
522 pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
523 le32_to_cpu(notif->primary_ch_lut));
524 pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
525 le32_to_cpu(notif->secondary_ch_lut));
526 pos += scnprintf(buf+pos,
527 bufsz-pos, "bt_activity_grading = %d\n",
528 le32_to_cpu(notif->bt_activity_grading));
529 pos += scnprintf(buf+pos, bufsz-pos,
530 "antenna isolation = %d CORUN LUT index = %d\n",
531 mvm->last_ant_isol, mvm->last_corun_lut);
532 }
10942342
EG
533
534 mutex_unlock(&mvm->mutex);
535
536 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
537 kfree(buf);
538
539 return ret;
540}
541#undef BT_MBOX_PRINT
542
2de13cae
EG
543static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
544 size_t count, loff_t *ppos)
545{
546 struct iwl_mvm *mvm = file->private_data;
2de13cae
EG
547 char buf[256];
548 int bufsz = sizeof(buf);
549 int pos = 0;
550
551 mutex_lock(&mvm->mutex);
552
160be571
EG
553 if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
554 struct iwl_bt_coex_ci_cmd_old *cmd = &mvm->last_bt_ci_cmd_old;
555
556 pos += scnprintf(buf+pos, bufsz-pos,
557 "Channel inhibition CMD\n");
558 pos += scnprintf(buf+pos, bufsz-pos,
559 "\tPrimary Channel Bitmap 0x%016llx\n",
560 le64_to_cpu(cmd->bt_primary_ci));
561 pos += scnprintf(buf+pos, bufsz-pos,
562 "\tSecondary Channel Bitmap 0x%016llx\n",
563 le64_to_cpu(cmd->bt_secondary_ci));
564
565 pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n");
566 pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill Mask 0x%08x\n",
1459f269 567 iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[0]]);
160be571 568 pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill Mask 0x%08x\n",
1459f269 569 iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[0]]);
160be571
EG
570
571 } else {
572 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
573
574 pos += scnprintf(buf+pos, bufsz-pos,
575 "Channel inhibition CMD\n");
576 pos += scnprintf(buf+pos, bufsz-pos,
577 "\tPrimary Channel Bitmap 0x%016llx\n",
578 le64_to_cpu(cmd->bt_primary_ci));
579 pos += scnprintf(buf+pos, bufsz-pos,
580 "\tSecondary Channel Bitmap 0x%016llx\n",
581 le64_to_cpu(cmd->bt_secondary_ci));
582
583 pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n");
1459f269
EG
584 pos += scnprintf(buf+pos, bufsz-pos,
585 "\tPrimary: ACK Kill Mask 0x%08x\n",
586 iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[0]]);
587 pos += scnprintf(buf+pos, bufsz-pos,
588 "\tPrimary: CTS Kill Mask 0x%08x\n",
589 iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[0]]);
590 pos += scnprintf(buf+pos, bufsz-pos,
591 "\tSecondary: ACK Kill Mask 0x%08x\n",
592 iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[1]]);
593 pos += scnprintf(buf+pos, bufsz-pos,
594 "\tSecondary: CTS Kill Mask 0x%08x\n",
595 iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[1]]);
596
160be571 597 }
2de13cae
EG
598
599 mutex_unlock(&mvm->mutex);
600
601 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
602}
603
cdb00563
EG
604static ssize_t
605iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
606 size_t count, loff_t *ppos)
607{
608 u32 bt_tx_prio;
609
610 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
611 return -EINVAL;
612 if (bt_tx_prio > 4)
613 return -EINVAL;
614
615 mvm->bt_tx_prio = bt_tx_prio;
616
617 return count;
618}
619
a39979a8
EG
620static ssize_t
621iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
622 size_t count, loff_t *ppos)
623{
624 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
625 [BT_FORCE_ANT_DIS] = "dis",
626 [BT_FORCE_ANT_AUTO] = "auto",
627 [BT_FORCE_ANT_BT] = "bt",
628 [BT_FORCE_ANT_WIFI] = "wifi",
629 };
630 int ret, bt_force_ant_mode;
631
632 for (bt_force_ant_mode = 0;
633 bt_force_ant_mode < ARRAY_SIZE(modes_str);
634 bt_force_ant_mode++) {
635 if (!strcmp(buf, modes_str[bt_force_ant_mode]))
636 break;
637 }
638
639 if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
640 return -EINVAL;
641
642 ret = 0;
643 mutex_lock(&mvm->mutex);
644 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
645 goto out;
646
647 mvm->bt_force_ant_mode = bt_force_ant_mode;
648 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
649 modes_str[mvm->bt_force_ant_mode]);
650 ret = iwl_send_bt_init_conf(mvm);
651
652out:
653 mutex_unlock(&mvm->mutex);
654 return ret ?: count;
655}
656
3848ab66
MG
657#define PRINT_STATS_LE32(_str, _val) \
658 pos += scnprintf(buf + pos, bufsz - pos, \
659 fmt_table, _str, \
660 le32_to_cpu(_val))
661
662static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
663 char __user *user_buf, size_t count,
664 loff_t *ppos)
665{
666 struct iwl_mvm *mvm = file->private_data;
667 static const char *fmt_table = "\t%-30s %10u\n";
668 static const char *fmt_header = "%-32s\n";
669 int pos = 0;
670 char *buf;
671 int ret;
3f617281
LC
672 /* 43 is the size of each data line, 33 is the size of each header */
673 size_t bufsz =
674 ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) +
675 (4 * 33) + 1;
676
3848ab66
MG
677 struct mvm_statistics_rx_phy *ofdm;
678 struct mvm_statistics_rx_phy *cck;
679 struct mvm_statistics_rx_non_phy *general;
680 struct mvm_statistics_rx_ht_phy *ht;
681
682 buf = kzalloc(bufsz, GFP_KERNEL);
683 if (!buf)
684 return -ENOMEM;
685
686 mutex_lock(&mvm->mutex);
687
688 ofdm = &mvm->rx_stats.ofdm;
689 cck = &mvm->rx_stats.cck;
690 general = &mvm->rx_stats.general;
691 ht = &mvm->rx_stats.ofdm_ht;
692
693 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
694 "Statistics_Rx - OFDM");
695 PRINT_STATS_LE32("ina_cnt", ofdm->ina_cnt);
696 PRINT_STATS_LE32("fina_cnt", ofdm->fina_cnt);
697 PRINT_STATS_LE32("plcp_err", ofdm->plcp_err);
698 PRINT_STATS_LE32("crc32_err", ofdm->crc32_err);
699 PRINT_STATS_LE32("overrun_err", ofdm->overrun_err);
700 PRINT_STATS_LE32("early_overrun_err", ofdm->early_overrun_err);
701 PRINT_STATS_LE32("crc32_good", ofdm->crc32_good);
702 PRINT_STATS_LE32("false_alarm_cnt", ofdm->false_alarm_cnt);
703 PRINT_STATS_LE32("fina_sync_err_cnt", ofdm->fina_sync_err_cnt);
704 PRINT_STATS_LE32("sfd_timeout", ofdm->sfd_timeout);
705 PRINT_STATS_LE32("fina_timeout", ofdm->fina_timeout);
706 PRINT_STATS_LE32("unresponded_rts", ofdm->unresponded_rts);
707 PRINT_STATS_LE32("rxe_frame_lmt_overrun",
708 ofdm->rxe_frame_limit_overrun);
709 PRINT_STATS_LE32("sent_ack_cnt", ofdm->sent_ack_cnt);
710 PRINT_STATS_LE32("sent_cts_cnt", ofdm->sent_cts_cnt);
711 PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm->sent_ba_rsp_cnt);
712 PRINT_STATS_LE32("dsp_self_kill", ofdm->dsp_self_kill);
713 PRINT_STATS_LE32("mh_format_err", ofdm->mh_format_err);
714 PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm->re_acq_main_rssi_sum);
715 PRINT_STATS_LE32("reserved", ofdm->reserved);
716
717 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
718 "Statistics_Rx - CCK");
719 PRINT_STATS_LE32("ina_cnt", cck->ina_cnt);
720 PRINT_STATS_LE32("fina_cnt", cck->fina_cnt);
721 PRINT_STATS_LE32("plcp_err", cck->plcp_err);
722 PRINT_STATS_LE32("crc32_err", cck->crc32_err);
723 PRINT_STATS_LE32("overrun_err", cck->overrun_err);
724 PRINT_STATS_LE32("early_overrun_err", cck->early_overrun_err);
725 PRINT_STATS_LE32("crc32_good", cck->crc32_good);
726 PRINT_STATS_LE32("false_alarm_cnt", cck->false_alarm_cnt);
727 PRINT_STATS_LE32("fina_sync_err_cnt", cck->fina_sync_err_cnt);
728 PRINT_STATS_LE32("sfd_timeout", cck->sfd_timeout);
729 PRINT_STATS_LE32("fina_timeout", cck->fina_timeout);
730 PRINT_STATS_LE32("unresponded_rts", cck->unresponded_rts);
731 PRINT_STATS_LE32("rxe_frame_lmt_overrun",
732 cck->rxe_frame_limit_overrun);
733 PRINT_STATS_LE32("sent_ack_cnt", cck->sent_ack_cnt);
734 PRINT_STATS_LE32("sent_cts_cnt", cck->sent_cts_cnt);
735 PRINT_STATS_LE32("sent_ba_rsp_cnt", cck->sent_ba_rsp_cnt);
736 PRINT_STATS_LE32("dsp_self_kill", cck->dsp_self_kill);
737 PRINT_STATS_LE32("mh_format_err", cck->mh_format_err);
738 PRINT_STATS_LE32("re_acq_main_rssi_sum", cck->re_acq_main_rssi_sum);
739 PRINT_STATS_LE32("reserved", cck->reserved);
740
741 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
742 "Statistics_Rx - GENERAL");
743 PRINT_STATS_LE32("bogus_cts", general->bogus_cts);
744 PRINT_STATS_LE32("bogus_ack", general->bogus_ack);
745 PRINT_STATS_LE32("non_bssid_frames", general->non_bssid_frames);
746 PRINT_STATS_LE32("filtered_frames", general->filtered_frames);
747 PRINT_STATS_LE32("non_channel_beacons", general->non_channel_beacons);
748 PRINT_STATS_LE32("channel_beacons", general->channel_beacons);
749 PRINT_STATS_LE32("num_missed_bcon", general->num_missed_bcon);
750 PRINT_STATS_LE32("adc_rx_saturation_time",
751 general->adc_rx_saturation_time);
752 PRINT_STATS_LE32("ina_detection_search_time",
753 general->ina_detection_search_time);
754 PRINT_STATS_LE32("beacon_silence_rssi_a",
755 general->beacon_silence_rssi_a);
756 PRINT_STATS_LE32("beacon_silence_rssi_b",
757 general->beacon_silence_rssi_b);
758 PRINT_STATS_LE32("beacon_silence_rssi_c",
759 general->beacon_silence_rssi_c);
760 PRINT_STATS_LE32("interference_data_flag",
761 general->interference_data_flag);
762 PRINT_STATS_LE32("channel_load", general->channel_load);
763 PRINT_STATS_LE32("dsp_false_alarms", general->dsp_false_alarms);
764 PRINT_STATS_LE32("beacon_rssi_a", general->beacon_rssi_a);
765 PRINT_STATS_LE32("beacon_rssi_b", general->beacon_rssi_b);
766 PRINT_STATS_LE32("beacon_rssi_c", general->beacon_rssi_c);
767 PRINT_STATS_LE32("beacon_energy_a", general->beacon_energy_a);
768 PRINT_STATS_LE32("beacon_energy_b", general->beacon_energy_b);
769 PRINT_STATS_LE32("beacon_energy_c", general->beacon_energy_c);
770 PRINT_STATS_LE32("num_bt_kills", general->num_bt_kills);
3f617281 771 PRINT_STATS_LE32("mac_id", general->mac_id);
3848ab66
MG
772 PRINT_STATS_LE32("directed_data_mpdu", general->directed_data_mpdu);
773
774 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
775 "Statistics_Rx - HT");
776 PRINT_STATS_LE32("plcp_err", ht->plcp_err);
777 PRINT_STATS_LE32("overrun_err", ht->overrun_err);
778 PRINT_STATS_LE32("early_overrun_err", ht->early_overrun_err);
779 PRINT_STATS_LE32("crc32_good", ht->crc32_good);
780 PRINT_STATS_LE32("crc32_err", ht->crc32_err);
781 PRINT_STATS_LE32("mh_format_err", ht->mh_format_err);
782 PRINT_STATS_LE32("agg_crc32_good", ht->agg_crc32_good);
783 PRINT_STATS_LE32("agg_mpdu_cnt", ht->agg_mpdu_cnt);
784 PRINT_STATS_LE32("agg_cnt", ht->agg_cnt);
785 PRINT_STATS_LE32("unsupport_mcs", ht->unsupport_mcs);
786
787 mutex_unlock(&mvm->mutex);
788
789 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
790 kfree(buf);
791
792 return ret;
793}
794#undef PRINT_STAT_LE32
795
5fc0f76c
ES
796static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
797 char __user *user_buf, size_t count,
798 loff_t *ppos,
799 struct iwl_mvm_frame_stats *stats)
800{
f754b5ca
ES
801 char *buff, *pos, *endpos;
802 int idx, i;
5fc0f76c 803 int ret;
f754b5ca 804 static const size_t bufsz = 1024;
5fc0f76c
ES
805
806 buff = kmalloc(bufsz, GFP_KERNEL);
807 if (!buff)
808 return -ENOMEM;
809
810 spin_lock_bh(&mvm->drv_stats_lock);
f754b5ca
ES
811
812 pos = buff;
813 endpos = pos + bufsz;
814
815 pos += scnprintf(pos, endpos - pos,
5fc0f76c
ES
816 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
817 stats->legacy_frames,
818 stats->ht_frames,
819 stats->vht_frames);
f754b5ca 820 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
5fc0f76c
ES
821 stats->bw_20_frames,
822 stats->bw_40_frames,
823 stats->bw_80_frames);
f754b5ca 824 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
5fc0f76c
ES
825 stats->ngi_frames,
826 stats->sgi_frames);
f754b5ca 827 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
5fc0f76c
ES
828 stats->siso_frames,
829 stats->mimo2_frames);
f754b5ca 830 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
5fc0f76c
ES
831 stats->fail_frames,
832 stats->success_frames);
f754b5ca 833 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
5fc0f76c 834 stats->agg_frames);
f754b5ca 835 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
5fc0f76c 836 stats->ampdu_count);
f754b5ca 837 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
5fc0f76c
ES
838 stats->ampdu_count > 0 ?
839 (stats->agg_frames / stats->ampdu_count) : 0);
840
f754b5ca 841 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
5fc0f76c
ES
842
843 idx = stats->last_frame_idx - 1;
844 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
845 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
846 if (stats->last_rates[idx] == 0)
847 continue;
f754b5ca 848 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
5fc0f76c 849 (int)(ARRAY_SIZE(stats->last_rates) - i));
f754b5ca 850 pos += rs_pretty_print_rate(pos, stats->last_rates[idx]);
5fc0f76c
ES
851 }
852 spin_unlock_bh(&mvm->drv_stats_lock);
853
f754b5ca 854 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
5fc0f76c
ES
855 kfree(buff);
856
857 return ret;
858}
859
860static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
861 char __user *user_buf, size_t count,
862 loff_t *ppos)
863{
864 struct iwl_mvm *mvm = file->private_data;
865
866 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
867 &mvm->drv_rx_stats);
868}
869
1fa3f57a 870static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
490953ac
EG
871 size_t count, loff_t *ppos)
872{
490953ac
EG
873 int ret;
874
490953ac
EG
875 mutex_lock(&mvm->mutex);
876
291aa7c4
EH
877 /* allow one more restart that we're provoking here */
878 if (mvm->restart_fw >= 0)
879 mvm->restart_fw++;
880
490953ac 881 /* take the return value to make compiler happy - it will fail anyway */
a1022927 882 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
490953ac
EG
883
884 mutex_unlock(&mvm->mutex);
885
490953ac
EG
886 return count;
887}
888
1fa3f57a 889static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
119663c3
AB
890 size_t count, loff_t *ppos)
891{
576eeee9
EP
892 int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
893 if (ret)
894 return ret;
895
4c9706dc 896 iwl_force_nmi(mvm->trans);
119663c3 897
576eeee9
EP
898 iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
899
119663c3
AB
900 return count;
901}
902
91b05d10
OG
903static ssize_t
904iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
905 char __user *user_buf,
906 size_t count, loff_t *ppos)
907{
908 struct iwl_mvm *mvm = file->private_data;
909 int pos = 0;
910 char buf[32];
911 const size_t bufsz = sizeof(buf);
912
913 /* print which antennas were set for the scan command by the user */
914 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
915 if (mvm->scan_rx_ant & ANT_A)
916 pos += scnprintf(buf + pos, bufsz - pos, "A");
917 if (mvm->scan_rx_ant & ANT_B)
918 pos += scnprintf(buf + pos, bufsz - pos, "B");
919 if (mvm->scan_rx_ant & ANT_C)
920 pos += scnprintf(buf + pos, bufsz - pos, "C");
921 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
922
923 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
924}
925
926static ssize_t
1fa3f57a 927iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
91b05d10
OG
928 size_t count, loff_t *ppos)
929{
91b05d10
OG
930 u8 scan_rx_ant;
931
91b05d10
OG
932 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
933 return -EINVAL;
934 if (scan_rx_ant > ANT_ABC)
935 return -EINVAL;
4ed735e7 936 if (scan_rx_ant & ~mvm->fw->valid_rx_ant)
91b05d10
OG
937 return -EINVAL;
938
d2496221
DS
939 if (mvm->scan_rx_ant != scan_rx_ant) {
940 mvm->scan_rx_ant = scan_rx_ant;
941 if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
942 iwl_mvm_config_scan(mvm);
943 }
91b05d10
OG
944
945 return count;
946}
947
de06a59e
EP
948#define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
949#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
950static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
951 char __user *user_buf,
952 size_t count, loff_t *ppos)
953{
954 struct iwl_mvm *mvm = file->private_data;
955 struct iwl_bcast_filter_cmd cmd;
956 const struct iwl_fw_bcast_filter *filter;
957 char *buf;
958 int bufsz = 1024;
959 int i, j, pos = 0;
960 ssize_t ret;
961
962 buf = kzalloc(bufsz, GFP_KERNEL);
963 if (!buf)
964 return -ENOMEM;
965
966 mutex_lock(&mvm->mutex);
967 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
968 ADD_TEXT("None\n");
969 mutex_unlock(&mvm->mutex);
970 goto out;
971 }
972 mutex_unlock(&mvm->mutex);
973
974 for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
975 filter = &cmd.filters[i];
976
977 ADD_TEXT("Filter [%d]:\n", i);
978 ADD_TEXT("\tDiscard=%d\n", filter->discard);
979 ADD_TEXT("\tFrame Type: %s\n",
980 filter->frame_type ? "IPv4" : "Generic");
981
982 for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
983 const struct iwl_fw_bcast_filter_attr *attr;
984
985 attr = &filter->attrs[j];
986 if (!attr->mask)
987 break;
988
989 ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
990 j, attr->offset,
991 attr->offset_type ? "IP End" :
992 "Payload Start",
993 be32_to_cpu(attr->mask),
994 be32_to_cpu(attr->val),
995 le16_to_cpu(attr->reserved1));
996 }
997 }
998out:
999 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1000 kfree(buf);
1001 return ret;
1002}
1003
1004static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
1005 size_t count, loff_t *ppos)
1006{
1007 int pos, next_pos;
1008 struct iwl_fw_bcast_filter filter = {};
1009 struct iwl_bcast_filter_cmd cmd;
1010 u32 filter_id, attr_id, mask, value;
1011 int err = 0;
1012
1013 if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
1014 &filter.frame_type, &pos) != 3)
1015 return -EINVAL;
1016
1017 if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
1018 filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
1019 return -EINVAL;
1020
1021 for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
1022 attr_id++) {
1023 struct iwl_fw_bcast_filter_attr *attr =
1024 &filter.attrs[attr_id];
1025
1026 if (pos >= count)
1027 break;
1028
1029 if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
1030 &attr->offset, &attr->offset_type,
1031 &mask, &value, &next_pos) != 4)
1032 return -EINVAL;
1033
1034 attr->mask = cpu_to_be32(mask);
1035 attr->val = cpu_to_be32(value);
1036 if (mask)
1037 filter.num_attrs++;
1038
1039 pos += next_pos;
1040 }
1041
1042 mutex_lock(&mvm->mutex);
1043 memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
1044 &filter, sizeof(filter));
1045
1046 /* send updated bcast filtering configuration */
1047 if (mvm->dbgfs_bcast_filtering.override &&
1048 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
a1022927 1049 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
de06a59e
EP
1050 sizeof(cmd), &cmd);
1051 mutex_unlock(&mvm->mutex);
1052
1053 return err ?: count;
1054}
1055
1056static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
1057 char __user *user_buf,
1058 size_t count, loff_t *ppos)
1059{
1060 struct iwl_mvm *mvm = file->private_data;
1061 struct iwl_bcast_filter_cmd cmd;
1062 char *buf;
1063 int bufsz = 1024;
1064 int i, pos = 0;
1065 ssize_t ret;
1066
1067 buf = kzalloc(bufsz, GFP_KERNEL);
1068 if (!buf)
1069 return -ENOMEM;
1070
1071 mutex_lock(&mvm->mutex);
1072 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1073 ADD_TEXT("None\n");
1074 mutex_unlock(&mvm->mutex);
1075 goto out;
1076 }
1077 mutex_unlock(&mvm->mutex);
1078
1079 for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
1080 const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
1081
1082 ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
1083 i, mac->default_discard, mac->attached_filters);
1084 }
1085out:
1086 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1087 kfree(buf);
1088 return ret;
1089}
1090
1091static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
1092 char *buf, size_t count,
1093 loff_t *ppos)
1094{
1095 struct iwl_bcast_filter_cmd cmd;
1096 struct iwl_fw_bcast_mac mac = {};
1097 u32 mac_id, attached_filters;
1098 int err = 0;
1099
1100 if (!mvm->bcast_filters)
1101 return -ENOENT;
1102
1103 if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
1104 &attached_filters) != 3)
1105 return -EINVAL;
1106
1107 if (mac_id >= ARRAY_SIZE(cmd.macs) ||
1108 mac.default_discard > 1 ||
1109 attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
1110 return -EINVAL;
1111
1112 mac.attached_filters = cpu_to_le16(attached_filters);
1113
1114 mutex_lock(&mvm->mutex);
1115 memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
1116 &mac, sizeof(mac));
1117
1118 /* send updated bcast filtering configuration */
1119 if (mvm->dbgfs_bcast_filtering.override &&
1120 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
a1022927 1121 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
de06a59e
EP
1122 sizeof(cmd), &cmd);
1123 mutex_unlock(&mvm->mutex);
1124
1125 return err ?: count;
1126}
1127#endif
1128
afc66bb7 1129#ifdef CONFIG_PM_SLEEP
1fa3f57a 1130static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
afc66bb7
JB
1131 size_t count, loff_t *ppos)
1132{
afc66bb7
JB
1133 int store;
1134
afc66bb7
JB
1135 if (sscanf(buf, "%d", &store) != 1)
1136 return -EINVAL;
1137
1138 mvm->store_d3_resume_sram = store;
1139
1140 return count;
1141}
1142
1143static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
1144 size_t count, loff_t *ppos)
1145{
1146 struct iwl_mvm *mvm = file->private_data;
1147 const struct fw_img *img;
1148 int ofs, len, pos = 0;
1149 size_t bufsz, ret;
1150 char *buf;
1151 u8 *ptr = mvm->d3_resume_sram;
1152
1153 img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1154 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1155
1156 bufsz = len * 4 + 256;
1157 buf = kzalloc(bufsz, GFP_KERNEL);
1158 if (!buf)
1159 return -ENOMEM;
1160
1161 pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
1162 mvm->store_d3_resume_sram ? "en" : "dis");
1163
1164 if (ptr) {
1165 for (ofs = 0; ofs < len; ofs += 16) {
1166 pos += scnprintf(buf + pos, bufsz - pos,
1167 "0x%.4x ", ofs);
1168 hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
1169 bufsz - pos, false);
1170 pos += strlen(buf + pos);
1171 if (bufsz - pos > 0)
1172 buf[pos++] = '\n';
1173 }
1174 } else {
1175 pos += scnprintf(buf + pos, bufsz - pos,
1176 "(no data captured)\n");
1177 }
1178
1179 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1180
1181 kfree(buf);
1182
1183 return ret;
1184}
3c2f3b20
LC
1185
1186#define MAX_NUM_ND_MATCHSETS 10
1187
1188static ssize_t iwl_dbgfs_netdetect_write(struct iwl_mvm *mvm, char *buf,
1189 size_t count, loff_t *ppos)
1190{
1191 const char *seps = ",\n";
1192 char *buf_ptr = buf;
1193 char *value_str = NULL;
1194 int ret, i;
1195
1196 /* TODO: don't free if write is being called several times in one go */
1197 if (mvm->nd_config) {
1198 kfree(mvm->nd_config->match_sets);
1199 kfree(mvm->nd_config);
1200 mvm->nd_config = NULL;
3c2f3b20
LC
1201 }
1202
3c2f3b20
LC
1203 mvm->nd_config = kzalloc(sizeof(*mvm->nd_config) +
1204 (11 * sizeof(struct ieee80211_channel *)),
1205 GFP_KERNEL);
1206 if (!mvm->nd_config) {
1207 ret = -ENOMEM;
1208 goto out_free;
1209 }
1210
1211 mvm->nd_config->n_channels = 11;
1212 mvm->nd_config->scan_width = NL80211_BSS_CHAN_WIDTH_20;
1213 mvm->nd_config->interval = 5;
1214 mvm->nd_config->min_rssi_thold = -80;
1215 for (i = 0; i < mvm->nd_config->n_channels; i++)
1216 mvm->nd_config->channels[i] = &mvm->nvm_data->channels[i];
1217
1218 mvm->nd_config->match_sets =
1219 kcalloc(MAX_NUM_ND_MATCHSETS,
1220 sizeof(*mvm->nd_config->match_sets),
1221 GFP_KERNEL);
1222 if (!mvm->nd_config->match_sets) {
1223 ret = -ENOMEM;
1224 goto out_free;
1225 }
1226
1227 while ((value_str = strsep(&buf_ptr, seps)) &&
1228 strlen(value_str)) {
1229 struct cfg80211_match_set *set;
1230
1231 if (mvm->nd_config->n_match_sets >= MAX_NUM_ND_MATCHSETS) {
1232 ret = -EINVAL;
1233 goto out_free;
1234 }
1235
1236 set = &mvm->nd_config->match_sets[mvm->nd_config->n_match_sets];
1237 set->ssid.ssid_len = strlen(value_str);
1238
1239 if (set->ssid.ssid_len > IEEE80211_MAX_SSID_LEN) {
1240 ret = -EINVAL;
1241 goto out_free;
1242 }
1243
1244 memcpy(set->ssid.ssid, value_str, set->ssid.ssid_len);
1245
1246 mvm->nd_config->n_match_sets++;
1247 }
1248
1249 ret = count;
1250
1251 if (mvm->nd_config->n_match_sets)
1252 goto out;
1253
1254out_free:
1255 if (mvm->nd_config)
1256 kfree(mvm->nd_config->match_sets);
1257 kfree(mvm->nd_config);
1258 mvm->nd_config = NULL;
3c2f3b20
LC
1259out:
1260 return ret;
1261}
1262
1263static ssize_t
1264iwl_dbgfs_netdetect_read(struct file *file, char __user *user_buf,
1265 size_t count, loff_t *ppos)
1266{
1267 struct iwl_mvm *mvm = file->private_data;
1268 size_t bufsz, ret;
1269 char *buf;
1270 int i, n_match_sets, pos = 0;
1271
1272 n_match_sets = mvm->nd_config ? mvm->nd_config->n_match_sets : 0;
1273
1274 bufsz = n_match_sets * (IEEE80211_MAX_SSID_LEN + 1) + 1;
1275 buf = kzalloc(bufsz, GFP_KERNEL);
1276 if (!buf)
1277 return -ENOMEM;
1278
1279 for (i = 0; i < n_match_sets; i++) {
1280 if (pos +
1281 mvm->nd_config->match_sets[i].ssid.ssid_len + 2 > bufsz) {
1282 ret = -EIO;
1283 goto out;
1284 }
1285
1286 memcpy(buf + pos, mvm->nd_config->match_sets[i].ssid.ssid,
1287 mvm->nd_config->match_sets[i].ssid.ssid_len);
1288 pos += mvm->nd_config->match_sets[i].ssid.ssid_len;
1289 buf[pos++] = '\n';
1290 }
1291
1292 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1293out:
1294 kfree(buf);
1295 return ret;
1296}
afc66bb7
JB
1297#endif
1298
576eeee9
EP
1299#define PRINT_MVM_REF(ref) do { \
1300 if (mvm->refs[ref]) \
1301 pos += scnprintf(buf + pos, bufsz - pos, \
1302 "\t(0x%lx): %d %s\n", \
1303 BIT(ref), mvm->refs[ref], #ref); \
70d6babb
EP
1304} while (0)
1305
1306static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
1307 char __user *user_buf,
1308 size_t count, loff_t *ppos)
1309{
1310 struct iwl_mvm *mvm = file->private_data;
576eeee9 1311 int i, pos = 0;
70d6babb
EP
1312 char buf[256];
1313 const size_t bufsz = sizeof(buf);
576eeee9
EP
1314 u32 refs = 0;
1315
1316 for (i = 0; i < IWL_MVM_REF_COUNT; i++)
1317 if (mvm->refs[i])
1318 refs |= BIT(i);
70d6babb 1319
576eeee9
EP
1320 pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
1321 refs);
70d6babb
EP
1322
1323 PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
1324 PRINT_MVM_REF(IWL_MVM_REF_SCAN);
1325 PRINT_MVM_REF(IWL_MVM_REF_ROC);
1326 PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
1327 PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
0eb83653 1328 PRINT_MVM_REF(IWL_MVM_REF_USER);
34e611ea
JB
1329 PRINT_MVM_REF(IWL_MVM_REF_TX);
1330 PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
1331 PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
1332 PRINT_MVM_REF(IWL_MVM_REF_START_AP);
1333 PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
1334 PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
1335 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
1336 PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
1337 PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
1338 PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
1339 PRINT_MVM_REF(IWL_MVM_REF_NMI);
1340 PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
d15a747f 1341 PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
70d6babb
EP
1342
1343 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1344}
1345
0eb83653
EP
1346static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
1347 size_t count, loff_t *ppos)
1348{
1349 unsigned long value;
1350 int ret;
1351 bool taken;
1352
1353 ret = kstrtoul(buf, 10, &value);
1354 if (ret < 0)
1355 return ret;
1356
1357 mutex_lock(&mvm->mutex);
1358
576eeee9 1359 taken = mvm->refs[IWL_MVM_REF_USER];
0eb83653
EP
1360 if (value == 1 && !taken)
1361 iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
1362 else if (value == 0 && taken)
1363 iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
1364 else
1365 ret = -EINVAL;
1366
1367 mutex_unlock(&mvm->mutex);
1368
1369 if (ret < 0)
1370 return ret;
1371 return count;
1372}
1373
1fa3f57a
JB
1374#define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1375 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1376#define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1377 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
de06a59e
EP
1378#define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1379 if (!debugfs_create_file(alias, mode, parent, mvm, \
8ca151b5
JB
1380 &iwl_dbgfs_##name##_ops)) \
1381 goto err; \
1382 } while (0)
de06a59e
EP
1383#define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1384 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
8ca151b5 1385
f3c221f6
EP
1386static ssize_t
1387iwl_dbgfs_prph_reg_read(struct file *file,
1388 char __user *user_buf,
1389 size_t count, loff_t *ppos)
1390{
1391 struct iwl_mvm *mvm = file->private_data;
1392 int pos = 0;
1393 char buf[32];
1394 const size_t bufsz = sizeof(buf);
576eeee9 1395 int ret;
f3c221f6
EP
1396
1397 if (!mvm->dbgfs_prph_reg_addr)
1398 return -EINVAL;
1399
576eeee9
EP
1400 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
1401 if (ret)
1402 return ret;
1403
f3c221f6
EP
1404 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1405 mvm->dbgfs_prph_reg_addr,
1406 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1407
576eeee9
EP
1408 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
1409
f3c221f6
EP
1410 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1411}
1412
1413static ssize_t
1414iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1415 size_t count, loff_t *ppos)
1416{
1417 u8 args;
1418 u32 value;
576eeee9 1419 int ret;
f3c221f6
EP
1420
1421 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1422 /* if we only want to set the reg address - nothing more to do */
1423 if (args == 1)
1424 goto out;
1425
1426 /* otherwise, make sure we have both address and value */
1427 if (args != 2)
1428 return -EINVAL;
1429
576eeee9
EP
1430 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1431 if (ret)
1432 return ret;
1433
f3c221f6 1434 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
576eeee9
EP
1435
1436 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
f3c221f6
EP
1437out:
1438 return count;
1439}
1440
1441MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1442
8ca151b5 1443/* Device wide debugfs entries */
1fa3f57a
JB
1444MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1445MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
1446MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
7280d1f0 1447MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
c549e390 1448MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
8ca151b5 1449MVM_DEBUGFS_READ_FILE_OPS(stations);
10942342 1450MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
2de13cae 1451MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
1fa3f57a 1452MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
3848ab66 1453MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
5fc0f76c 1454MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
1fa3f57a
JB
1455MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1456MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
cdb00563 1457MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
a39979a8 1458MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
1fa3f57a 1459MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
0eb83653 1460MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
91b05d10 1461
de06a59e
EP
1462#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1463MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
1464MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
1465#endif
1466
afc66bb7 1467#ifdef CONFIG_PM_SLEEP
1fa3f57a 1468MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
3c2f3b20 1469MVM_DEBUGFS_READ_WRITE_FILE_OPS(netdetect, 384);
afc66bb7 1470#endif
8ca151b5
JB
1471
1472int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1473{
de06a59e 1474 struct dentry *bcast_dir __maybe_unused;
8ca151b5
JB
1475 char buf[100];
1476
d07913aa
JB
1477 spin_lock_init(&mvm->drv_stats_lock);
1478
8ca151b5
JB
1479 mvm->debugfs_dir = dbgfs_dir;
1480
1481 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
1482 MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
1483 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
7280d1f0
MG
1484 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir,
1485 S_IWUSR | S_IRUSR);
c549e390 1486 MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR);
8ca151b5 1487 MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
10942342 1488 MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
2de13cae 1489 MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR);
639eabad
EG
1490 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir,
1491 S_IRUSR | S_IWUSR);
3848ab66 1492 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR);
5fc0f76c 1493 MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR);
490953ac 1494 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
119663c3 1495 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
cdb00563 1496 MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR);
a39979a8 1497 MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR);
91b05d10
OG
1498 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
1499 S_IWUSR | S_IRUSR);
f3c221f6 1500 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
0eb83653 1501 MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
de06a59e
EP
1502
1503#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1504 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
1505 bcast_dir = debugfs_create_dir("bcast_filtering",
1506 mvm->debugfs_dir);
1507 if (!bcast_dir)
1508 goto err;
1509
1510 if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR,
1511 bcast_dir,
1512 &mvm->dbgfs_bcast_filtering.override))
1513 goto err;
1514
1515 MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
1516 bcast_dir, S_IWUSR | S_IRUSR);
1517 MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
1518 bcast_dir, S_IWUSR | S_IRUSR);
1519 }
1520#endif
1521
afc66bb7
JB
1522#ifdef CONFIG_PM_SLEEP
1523 MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
debff618 1524 MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
b0114714
JB
1525 if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
1526 mvm->debugfs_dir, &mvm->d3_wake_sysassert))
1527 goto err;
3c2f3b20 1528 MVM_DEBUGFS_ADD_FILE(netdetect, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
afc66bb7 1529#endif
8ca151b5 1530
9ecd051e
ES
1531 if (!debugfs_create_u8("low_latency_agg_frame_limit", S_IRUSR | S_IWUSR,
1532 mvm->debugfs_dir,
1533 &mvm->low_latency_agg_frame_limit))
1534 goto err;
bdd54839
LC
1535 if (!debugfs_create_u8("ps_disabled", S_IRUSR,
1536 mvm->debugfs_dir, &mvm->ps_disabled))
1537 goto err;
086f7368
EG
1538 if (!debugfs_create_blob("nvm_hw", S_IRUSR,
1539 mvm->debugfs_dir, &mvm->nvm_hw_blob))
1540 goto err;
1541 if (!debugfs_create_blob("nvm_sw", S_IRUSR,
1542 mvm->debugfs_dir, &mvm->nvm_sw_blob))
1543 goto err;
1544 if (!debugfs_create_blob("nvm_calib", S_IRUSR,
1545 mvm->debugfs_dir, &mvm->nvm_calib_blob))
1546 goto err;
1547 if (!debugfs_create_blob("nvm_prod", S_IRUSR,
1548 mvm->debugfs_dir, &mvm->nvm_prod_blob))
1549 goto err;
1550
8ca151b5
JB
1551 /*
1552 * Create a symlink with mac80211. It will be removed when mac80211
1553 * exists (before the opmode exists which removes the target.)
1554 */
1555 snprintf(buf, 100, "../../%s/%s",
1556 dbgfs_dir->d_parent->d_parent->d_name.name,
1557 dbgfs_dir->d_parent->d_name.name);
1558 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
1559 goto err;
1560
1561 return 0;
1562err:
1563 IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
1564 return -ENOMEM;
1565}
This page took 0.210417 seconds and 5 git commands to generate.