blob: a43b3921c4c15e612aff154b86ece64db5a9117e [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
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 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Eliad Pellerc7792732015-04-19 11:41:04 +03009 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
Sara Sharon43413a92015-12-31 11:49:18 +020010 * Copyright(c) 2016 Intel Deutschland GmbH
Johannes Berg8ca151b2013-01-24 14:25:36 +010011 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24 * USA
25 *
26 * The full GNU General Public License is included in this distribution
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020027 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010028 *
29 * Contact Information:
Emmanuel Grumbachcb2f8272015-11-17 15:39:56 +020030 * Intel Linux Wireless <linuxwifi@intel.com>
Johannes Berg8ca151b2013-01-24 14:25:36 +010031 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
32 *
33 * BSD LICENSE
34 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020035 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Eliad Pellerc7792732015-04-19 11:41:04 +030036 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
Johannes Berg8ca151b2013-01-24 14:25:36 +010037 * All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 *
43 * * Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * * Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in
47 * the documentation and/or other materials provided with the
48 * distribution.
49 * * Neither the name Intel Corporation nor the names of its
50 * contributors may be used to endorse or promote products derived
51 * from this software without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *
65 *****************************************************************************/
Emmanuel Grumbach192c80a2014-03-19 08:25:05 +020066#include <linux/vmalloc.h>
Emmanuel Grumbach9e7dce22015-10-26 16:14:06 +020067#include <linux/ieee80211.h>
Emmanuel Grumbach192c80a2014-03-19 08:25:05 +020068
Johannes Berg8ca151b2013-01-24 14:25:36 +010069#include "mvm.h"
Golan Ben-Ami2f89a5d2015-10-27 19:17:14 +020070#include "fw-dbg.h"
Johannes Berg8ca151b2013-01-24 14:25:36 +010071#include "sta.h"
72#include "iwl-io.h"
Johannes Berg820a1a52013-11-12 16:58:41 +010073#include "debugfs.h"
Johannes Berg4d075002014-04-24 10:41:31 +020074#include "iwl-fw-error-dump.h"
Johannes Berg8ca151b2013-01-24 14:25:36 +010075
Chaya Rachel Ivgi00f481b2016-02-24 12:19:22 +020076static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
77 char __user *user_buf,
78 size_t count, loff_t *ppos)
79{
80 struct iwl_mvm *mvm = file->private_data;
81 char buf[16];
82 int pos, budget;
83
84 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
85 return -EIO;
86
87 mutex_lock(&mvm->mutex);
88 budget = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_REPORT, 0);
89 mutex_unlock(&mvm->mutex);
90
91 if (budget < 0)
92 return budget;
93
94 pos = scnprintf(buf, sizeof(buf), "%d\n", budget);
95
96 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
97}
98
99static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
100 size_t count, loff_t *ppos)
101{
102 int ret;
103
104 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
105 return -EIO;
106
107 mutex_lock(&mvm->mutex);
108 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_STOP, 0);
109 mutex_unlock(&mvm->mutex);
110
111 return ret ?: count;
112}
113
Johannes Berg1fa3f572013-11-13 09:10:21 +0100114static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100115 size_t count, loff_t *ppos)
116{
Johannes Berg8a0bd162013-11-12 16:48:03 +0100117 int ret;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100118 u32 scd_q_msk;
119
120 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
121 return -EIO;
122
Johannes Berg8ca151b2013-01-24 14:25:36 +0100123 if (sscanf(buf, "%x", &scd_q_msk) != 1)
124 return -EINVAL;
125
126 IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk);
127
128 mutex_lock(&mvm->mutex);
Luca Coelho5888a402015-10-06 09:54:57 +0300129 ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, 0) ? : count;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100130 mutex_unlock(&mvm->mutex);
131
132 return ret;
133}
134
Johannes Berg1fa3f572013-11-13 09:10:21 +0100135static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100136 size_t count, loff_t *ppos)
137{
Emmanuel Grumbachf327b042014-01-14 08:30:32 +0200138 struct iwl_mvm_sta *mvmsta;
Johannes Berg8a0bd162013-11-12 16:48:03 +0100139 int sta_id, drain, ret;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100140
141 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
142 return -EIO;
143
Johannes Berg8ca151b2013-01-24 14:25:36 +0100144 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
145 return -EINVAL;
Johannes Berg60765a42013-10-25 13:06:06 +0200146 if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
147 return -EINVAL;
148 if (drain < 0 || drain > 1)
149 return -EINVAL;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100150
151 mutex_lock(&mvm->mutex);
152
Emmanuel Grumbachf327b042014-01-14 08:30:32 +0200153 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
154
155 if (!mvmsta)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100156 ret = -ENOENT;
157 else
Emmanuel Grumbachf327b042014-01-14 08:30:32 +0200158 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100159
160 mutex_unlock(&mvm->mutex);
161
162 return ret;
163}
164
165static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
166 size_t count, loff_t *ppos)
167{
168 struct iwl_mvm *mvm = file->private_data;
169 const struct fw_img *img;
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200170 unsigned int ofs, len;
171 size_t ret;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100172 u8 *ptr;
173
Johannes Berg60191d92013-05-15 13:08:51 +0200174 if (!mvm->ucode_loaded)
175 return -EINVAL;
176
Johannes Berg8ca151b2013-01-24 14:25:36 +0100177 /* default is to dump the entire data segment */
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200178 img = &mvm->fw->img[mvm->cur_ucode];
179 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
180 len = img->sec[IWL_UCODE_SECTION_DATA].len;
181
Emmanuel Grumbach01e0efe2014-01-06 09:05:54 +0200182 if (mvm->dbgfs_sram_len) {
Johannes Berg60191d92013-05-15 13:08:51 +0200183 ofs = mvm->dbgfs_sram_offset;
184 len = mvm->dbgfs_sram_len;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100185 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100186
Johannes Berg8ca151b2013-01-24 14:25:36 +0100187 ptr = kzalloc(len, GFP_KERNEL);
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200188 if (!ptr)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100189 return -ENOMEM;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100190
Johannes Berg60191d92013-05-15 13:08:51 +0200191 iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100192
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200193 ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100194
Johannes Berg8ca151b2013-01-24 14:25:36 +0100195 kfree(ptr);
196
197 return ret;
198}
199
Johannes Berg1fa3f572013-11-13 09:10:21 +0100200static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
201 size_t count, loff_t *ppos)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100202{
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200203 const struct fw_img *img;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100204 u32 offset, len;
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200205 u32 img_offset, img_len;
206
207 if (!mvm->ucode_loaded)
208 return -EINVAL;
209
210 img = &mvm->fw->img[mvm->cur_ucode];
211 img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
212 img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100213
Johannes Berg8ca151b2013-01-24 14:25:36 +0100214 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
215 if ((offset & 0x3) || (len & 0x3))
216 return -EINVAL;
Emmanuel Grumbachd5103422013-12-24 14:58:29 +0200217
218 if (offset + len > img_offset + img_len)
219 return -EINVAL;
220
Johannes Berg8ca151b2013-01-24 14:25:36 +0100221 mvm->dbgfs_sram_offset = offset;
222 mvm->dbgfs_sram_len = len;
223 } else {
224 mvm->dbgfs_sram_offset = 0;
225 mvm->dbgfs_sram_len = 0;
226 }
227
228 return count;
229}
230
Matti Gottlieb7280d1f2014-07-17 16:41:14 +0300231static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
232 char __user *user_buf,
233 size_t count, loff_t *ppos)
234{
235 struct iwl_mvm *mvm = file->private_data;
236 char buf[16];
237 int pos;
238
239 if (!mvm->temperature_test)
240 pos = scnprintf(buf , sizeof(buf), "disabled\n");
241 else
242 pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
243
244 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
245}
246
247/*
248 * Set NIC Temperature
249 * Cause the driver to ignore the actual NIC temperature reported by the FW
250 * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
251 * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
252 * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
253 */
254static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
255 char *buf, size_t count,
256 loff_t *ppos)
257{
258 int temperature;
259
Luciano Coelhoa26d4e72014-08-20 10:21:07 +0300260 if (!mvm->ucode_loaded && !mvm->temperature_test)
261 return -EIO;
262
Matti Gottlieb7280d1f2014-07-17 16:41:14 +0300263 if (kstrtoint(buf, 10, &temperature))
264 return -EINVAL;
265 /* not a legal temperature */
266 if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
267 temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
268 temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
269 return -EINVAL;
270
271 mutex_lock(&mvm->mutex);
272 if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
Luciano Coelhob689fa72014-08-20 17:26:58 +0300273 if (!mvm->temperature_test)
274 goto out;
275
Matti Gottlieb7280d1f2014-07-17 16:41:14 +0300276 mvm->temperature_test = false;
Luciano Coelhob689fa72014-08-20 17:26:58 +0300277 /* Since we can't read the temp while awake, just set
278 * it to zero until we get the next RX stats from the
279 * firmware.
280 */
281 mvm->temperature = 0;
Matti Gottlieb7280d1f2014-07-17 16:41:14 +0300282 } else {
283 mvm->temperature_test = true;
284 mvm->temperature = temperature;
285 }
286 IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
287 mvm->temperature_test ? "En" : "Dis" ,
288 mvm->temperature);
289 /* handle the temperature change */
290 iwl_mvm_tt_handler(mvm);
Luciano Coelhob689fa72014-08-20 17:26:58 +0300291
292out:
Matti Gottlieb7280d1f2014-07-17 16:41:14 +0300293 mutex_unlock(&mvm->mutex);
294
295 return count;
296}
297
Luciano Coelhoc549e392014-09-04 15:58:47 +0300298static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
299 char __user *user_buf,
300 size_t count, loff_t *ppos)
301{
302 struct iwl_mvm *mvm = file->private_data;
303 char buf[16];
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200304 int pos, ret;
305 s32 temp;
Luciano Coelhoc549e392014-09-04 15:58:47 +0300306
307 if (!mvm->ucode_loaded)
308 return -EIO;
309
310 mutex_lock(&mvm->mutex);
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200311 ret = iwl_mvm_get_temp(mvm, &temp);
Luciano Coelhoc549e392014-09-04 15:58:47 +0300312 mutex_unlock(&mvm->mutex);
313
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200314 if (ret)
315 return -EIO;
Luciano Coelhoc549e392014-09-04 15:58:47 +0300316
317 pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
318
319 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
320}
321
Johannes Berg8ca151b2013-01-24 14:25:36 +0100322static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
323 size_t count, loff_t *ppos)
324{
325 struct iwl_mvm *mvm = file->private_data;
326 struct ieee80211_sta *sta;
327 char buf[400];
328 int i, pos = 0, bufsz = sizeof(buf);
329
330 mutex_lock(&mvm->mutex);
331
332 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
333 pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
334 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
335 lockdep_is_held(&mvm->mutex));
336 if (!sta)
337 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
338 else if (IS_ERR(sta))
339 pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
340 PTR_ERR(sta));
341 else
342 pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
343 sta->addr);
344 }
345
346 mutex_unlock(&mvm->mutex);
347
348 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
349}
350
Alexander Bondar64b928c2013-09-03 14:18:03 +0300351static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
352 char __user *user_buf,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100353 size_t count, loff_t *ppos)
354{
355 struct iwl_mvm *mvm = file->private_data;
Alexander Bondar64b928c2013-09-03 14:18:03 +0300356 char buf[64];
357 int bufsz = sizeof(buf);
358 int pos = 0;
359
360 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
361 mvm->disable_power_off);
362 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
363 mvm->disable_power_off_d3);
364
365 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
366}
367
Johannes Berg1fa3f572013-11-13 09:10:21 +0100368static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
Alexander Bondar64b928c2013-09-03 14:18:03 +0300369 size_t count, loff_t *ppos)
370{
Johannes Berg1fa3f572013-11-13 09:10:21 +0100371 int ret, val;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100372
373 if (!mvm->ucode_loaded)
374 return -EIO;
375
Alexander Bondar64b928c2013-09-03 14:18:03 +0300376 if (!strncmp("disable_power_off_d0=", buf, 21)) {
377 if (sscanf(buf + 21, "%d", &val) != 1)
378 return -EINVAL;
379 mvm->disable_power_off = val;
380 } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
381 if (sscanf(buf + 21, "%d", &val) != 1)
382 return -EINVAL;
383 mvm->disable_power_off_d3 = val;
384 } else {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100385 return -EINVAL;
Alexander Bondar64b928c2013-09-03 14:18:03 +0300386 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100387
Alexander Bondar64b928c2013-09-03 14:18:03 +0300388 mutex_lock(&mvm->mutex);
Emmanuel Grumbachc1cb92f2014-01-28 10:17:18 +0200389 ret = iwl_mvm_power_update_device(mvm);
Alexander Bondar64b928c2013-09-03 14:18:03 +0300390 mutex_unlock(&mvm->mutex);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100391
Alexander Bondar64b928c2013-09-03 14:18:03 +0300392 return ret ?: count;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100393}
394
Emmanuel Grumbach10942342013-02-19 11:02:36 +0200395#define BT_MBOX_MSG(_notif, _num, _field) \
396 ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
397 >> BT_MBOX##_num##_##_field##_POS)
398
399
400#define BT_MBOX_PRINT(_num, _field, _end) \
401 pos += scnprintf(buf + pos, bufsz - pos, \
402 "\t%s: %d%s", \
403 #_field, \
404 BT_MBOX_MSG(notif, _num, _field), \
405 true ? "\n" : ", ");
406
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300407static
408int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
409 int pos, int bufsz)
Emmanuel Grumbach10942342013-02-19 11:02:36 +0200410{
Emmanuel Grumbach10942342013-02-19 11:02:36 +0200411 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
412
413 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
414 BT_MBOX_PRINT(0, LE_PROF1, false);
415 BT_MBOX_PRINT(0, LE_PROF2, false);
416 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
417 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
418 BT_MBOX_PRINT(0, INBAND_S, false);
419 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
420 BT_MBOX_PRINT(0, LE_SCAN, false);
421 BT_MBOX_PRINT(0, LE_ADV, false);
422 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
423 BT_MBOX_PRINT(0, OPEN_CON_1, true);
424
425 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
426
427 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
428 BT_MBOX_PRINT(1, IP_SR, false);
429 BT_MBOX_PRINT(1, LE_MSTR, false);
430 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
431 BT_MBOX_PRINT(1, MSG_TYPE, false);
432 BT_MBOX_PRINT(1, SSN, true);
433
434 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
435
436 BT_MBOX_PRINT(2, SNIFF_ACT, false);
437 BT_MBOX_PRINT(2, PAG, false);
438 BT_MBOX_PRINT(2, INQUIRY, false);
439 BT_MBOX_PRINT(2, CONN, false);
440 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
441 BT_MBOX_PRINT(2, DISC, false);
442 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
443 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
444 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
445 BT_MBOX_PRINT(2, SCO_DURATION, true);
446
447 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
448
449 BT_MBOX_PRINT(3, SCO_STATE, false);
450 BT_MBOX_PRINT(3, SNIFF_STATE, false);
451 BT_MBOX_PRINT(3, A2DP_STATE, false);
452 BT_MBOX_PRINT(3, ACL_STATE, false);
453 BT_MBOX_PRINT(3, MSTR_STATE, false);
454 BT_MBOX_PRINT(3, OBX_STATE, false);
455 BT_MBOX_PRINT(3, OPEN_CON_2, false);
456 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
457 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
458 BT_MBOX_PRINT(3, INBAND_P, false);
459 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
460 BT_MBOX_PRINT(3, SSN_2, false);
461 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
462
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300463 return pos;
464}
465
466static
467int iwl_mvm_coex_dump_mbox_old(struct iwl_bt_coex_profile_notif_old *notif,
468 char *buf, int pos, int bufsz)
469{
470 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
471
472 BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
473 BT_MBOX_PRINT(0, LE_PROF1, false);
474 BT_MBOX_PRINT(0, LE_PROF2, false);
475 BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
476 BT_MBOX_PRINT(0, CHL_SEQ_N, false);
477 BT_MBOX_PRINT(0, INBAND_S, false);
478 BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
479 BT_MBOX_PRINT(0, LE_SCAN, false);
480 BT_MBOX_PRINT(0, LE_ADV, false);
481 BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
482 BT_MBOX_PRINT(0, OPEN_CON_1, true);
483
484 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
485
486 BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
487 BT_MBOX_PRINT(1, IP_SR, false);
488 BT_MBOX_PRINT(1, LE_MSTR, false);
489 BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
490 BT_MBOX_PRINT(1, MSG_TYPE, false);
491 BT_MBOX_PRINT(1, SSN, true);
492
493 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
494
495 BT_MBOX_PRINT(2, SNIFF_ACT, false);
496 BT_MBOX_PRINT(2, PAG, false);
497 BT_MBOX_PRINT(2, INQUIRY, false);
498 BT_MBOX_PRINT(2, CONN, false);
499 BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
500 BT_MBOX_PRINT(2, DISC, false);
501 BT_MBOX_PRINT(2, SCO_TX_ACT, false);
502 BT_MBOX_PRINT(2, SCO_RX_ACT, false);
503 BT_MBOX_PRINT(2, ESCO_RE_TX, false);
504 BT_MBOX_PRINT(2, SCO_DURATION, true);
505
506 pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
507
508 BT_MBOX_PRINT(3, SCO_STATE, false);
509 BT_MBOX_PRINT(3, SNIFF_STATE, false);
510 BT_MBOX_PRINT(3, A2DP_STATE, false);
511 BT_MBOX_PRINT(3, ACL_STATE, false);
512 BT_MBOX_PRINT(3, MSTR_STATE, false);
513 BT_MBOX_PRINT(3, OBX_STATE, false);
514 BT_MBOX_PRINT(3, OPEN_CON_2, false);
515 BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
516 BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
517 BT_MBOX_PRINT(3, INBAND_P, false);
518 BT_MBOX_PRINT(3, MSG_TYPE_2, false);
519 BT_MBOX_PRINT(3, SSN_2, false);
520 BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
521
522 return pos;
523}
524
525static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
526 size_t count, loff_t *ppos)
527{
528 struct iwl_mvm *mvm = file->private_data;
529 char *buf;
530 int ret, pos = 0, bufsz = sizeof(char) * 1024;
531
532 buf = kmalloc(bufsz, GFP_KERNEL);
533 if (!buf)
534 return -ENOMEM;
535
536 mutex_lock(&mvm->mutex);
537
Johannes Berg859d9142015-06-01 17:11:11 +0200538 if (!fw_has_api(&mvm->fw->ucode_capa,
539 IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300540 struct iwl_bt_coex_profile_notif_old *notif =
541 &mvm->last_bt_notif_old;
542
543 pos += iwl_mvm_coex_dump_mbox_old(notif, buf, pos, bufsz);
544
545 pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
546 notif->bt_ci_compliance);
547 pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
548 le32_to_cpu(notif->primary_ch_lut));
549 pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
550 le32_to_cpu(notif->secondary_ch_lut));
551 pos += scnprintf(buf+pos,
552 bufsz-pos, "bt_activity_grading = %d\n",
553 le32_to_cpu(notif->bt_activity_grading));
554 pos += scnprintf(buf+pos, bufsz-pos,
555 "antenna isolation = %d CORUN LUT index = %d\n",
556 mvm->last_ant_isol, mvm->last_corun_lut);
Moshe Harel48f0a032015-10-26 11:33:49 +0200557 pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n",
558 notif->rrc_enabled);
559 pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n",
560 notif->ttc_enabled);
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300561 } else {
562 struct iwl_bt_coex_profile_notif *notif =
563 &mvm->last_bt_notif;
564
565 pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
566
567 pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
568 notif->bt_ci_compliance);
569 pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
570 le32_to_cpu(notif->primary_ch_lut));
571 pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
572 le32_to_cpu(notif->secondary_ch_lut));
573 pos += scnprintf(buf+pos,
574 bufsz-pos, "bt_activity_grading = %d\n",
575 le32_to_cpu(notif->bt_activity_grading));
576 pos += scnprintf(buf+pos, bufsz-pos,
577 "antenna isolation = %d CORUN LUT index = %d\n",
578 mvm->last_ant_isol, mvm->last_corun_lut);
Moshe Harel48f0a032015-10-26 11:33:49 +0200579 pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n",
580 (notif->ttc_rrc_status >> 4) & 0xF);
581 pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n",
582 notif->ttc_rrc_status & 0xF);
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300583 }
Emmanuel Grumbach10942342013-02-19 11:02:36 +0200584
Moshe Harelc725a462015-10-27 14:04:12 +0200585 pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n",
586 IWL_MVM_BT_COEX_SYNC2SCO);
587 pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n",
588 IWL_MVM_BT_COEX_MPLUT);
589 pos += scnprintf(buf + pos, bufsz - pos, "corunning = %d\n",
590 IWL_MVM_BT_COEX_CORUNNING);
591
Emmanuel Grumbach10942342013-02-19 11:02:36 +0200592 mutex_unlock(&mvm->mutex);
593
594 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
595 kfree(buf);
596
597 return ret;
598}
599#undef BT_MBOX_PRINT
600
Emmanuel Grumbach2de13ca2013-06-30 07:43:28 +0300601static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
602 size_t count, loff_t *ppos)
603{
604 struct iwl_mvm *mvm = file->private_data;
Emmanuel Grumbach2de13ca2013-06-30 07:43:28 +0300605 char buf[256];
606 int bufsz = sizeof(buf);
607 int pos = 0;
608
609 mutex_lock(&mvm->mutex);
610
Johannes Berg859d9142015-06-01 17:11:11 +0200611 if (!fw_has_api(&mvm->fw->ucode_capa,
612 IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300613 struct iwl_bt_coex_ci_cmd_old *cmd = &mvm->last_bt_ci_cmd_old;
Emmanuel Grumbach2de13ca2013-06-30 07:43:28 +0300614
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300615 pos += scnprintf(buf+pos, bufsz-pos,
616 "Channel inhibition CMD\n");
617 pos += scnprintf(buf+pos, bufsz-pos,
618 "\tPrimary Channel Bitmap 0x%016llx\n",
619 le64_to_cpu(cmd->bt_primary_ci));
620 pos += scnprintf(buf+pos, bufsz-pos,
621 "\tSecondary Channel Bitmap 0x%016llx\n",
622 le64_to_cpu(cmd->bt_secondary_ci));
623
Emmanuel Grumbachaee8bf52015-02-19 15:00:18 +0200624 pos += scnprintf(buf+pos, bufsz-pos,
625 "BT Configuration CMD - 0=default, 1=never, 2=always\n");
626 pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill msk idx %d\n",
627 mvm->bt_ack_kill_msk[0]);
628 pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill msk idx %d\n",
629 mvm->bt_cts_kill_msk[0]);
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300630
631 } else {
632 struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
633
634 pos += scnprintf(buf+pos, bufsz-pos,
635 "Channel inhibition CMD\n");
636 pos += scnprintf(buf+pos, bufsz-pos,
637 "\tPrimary Channel Bitmap 0x%016llx\n",
638 le64_to_cpu(cmd->bt_primary_ci));
639 pos += scnprintf(buf+pos, bufsz-pos,
640 "\tSecondary Channel Bitmap 0x%016llx\n",
641 le64_to_cpu(cmd->bt_secondary_ci));
Emmanuel Grumbach160be572014-07-02 17:33:52 +0300642 }
Emmanuel Grumbach2de13ca2013-06-30 07:43:28 +0300643
644 mutex_unlock(&mvm->mutex);
645
646 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
647}
648
Emmanuel Grumbachcdb00562014-03-16 21:55:43 +0200649static ssize_t
650iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
651 size_t count, loff_t *ppos)
652{
653 u32 bt_tx_prio;
654
655 if (sscanf(buf, "%u", &bt_tx_prio) != 1)
656 return -EINVAL;
657 if (bt_tx_prio > 4)
658 return -EINVAL;
659
660 mvm->bt_tx_prio = bt_tx_prio;
661
662 return count;
663}
664
Emmanuel Grumbacha39979a2014-05-28 12:06:41 +0300665static ssize_t
666iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
667 size_t count, loff_t *ppos)
668{
669 static const char * const modes_str[BT_FORCE_ANT_MAX] = {
670 [BT_FORCE_ANT_DIS] = "dis",
671 [BT_FORCE_ANT_AUTO] = "auto",
672 [BT_FORCE_ANT_BT] = "bt",
673 [BT_FORCE_ANT_WIFI] = "wifi",
674 };
675 int ret, bt_force_ant_mode;
676
677 for (bt_force_ant_mode = 0;
678 bt_force_ant_mode < ARRAY_SIZE(modes_str);
679 bt_force_ant_mode++) {
680 if (!strcmp(buf, modes_str[bt_force_ant_mode]))
681 break;
682 }
683
684 if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
685 return -EINVAL;
686
687 ret = 0;
688 mutex_lock(&mvm->mutex);
689 if (mvm->bt_force_ant_mode == bt_force_ant_mode)
690 goto out;
691
692 mvm->bt_force_ant_mode = bt_force_ant_mode;
693 IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
694 modes_str[mvm->bt_force_ant_mode]);
695 ret = iwl_send_bt_init_conf(mvm);
696
697out:
698 mutex_unlock(&mvm->mutex);
699 return ret ?: count;
700}
701
Johannes Berg93d17cc2015-01-15 12:59:26 +0100702#define PRINT_STATS_LE32(_struct, _memb) \
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300703 pos += scnprintf(buf + pos, bufsz - pos, \
Johannes Berg93d17cc2015-01-15 12:59:26 +0100704 fmt_table, #_memb, \
705 le32_to_cpu(_struct->_memb))
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300706
707static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
708 char __user *user_buf, size_t count,
709 loff_t *ppos)
710{
711 struct iwl_mvm *mvm = file->private_data;
712 static const char *fmt_table = "\t%-30s %10u\n";
713 static const char *fmt_header = "%-32s\n";
714 int pos = 0;
715 char *buf;
716 int ret;
Luciano Coelho3f617282013-10-14 13:18:41 +0300717 /* 43 is the size of each data line, 33 is the size of each header */
718 size_t bufsz =
719 ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) +
720 (4 * 33) + 1;
721
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300722 struct mvm_statistics_rx_phy *ofdm;
723 struct mvm_statistics_rx_phy *cck;
724 struct mvm_statistics_rx_non_phy *general;
725 struct mvm_statistics_rx_ht_phy *ht;
726
727 buf = kzalloc(bufsz, GFP_KERNEL);
728 if (!buf)
729 return -ENOMEM;
730
731 mutex_lock(&mvm->mutex);
732
733 ofdm = &mvm->rx_stats.ofdm;
734 cck = &mvm->rx_stats.cck;
735 general = &mvm->rx_stats.general;
736 ht = &mvm->rx_stats.ofdm_ht;
737
738 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
739 "Statistics_Rx - OFDM");
Johannes Berg93d17cc2015-01-15 12:59:26 +0100740 PRINT_STATS_LE32(ofdm, ina_cnt);
741 PRINT_STATS_LE32(ofdm, fina_cnt);
742 PRINT_STATS_LE32(ofdm, plcp_err);
743 PRINT_STATS_LE32(ofdm, crc32_err);
744 PRINT_STATS_LE32(ofdm, overrun_err);
745 PRINT_STATS_LE32(ofdm, early_overrun_err);
746 PRINT_STATS_LE32(ofdm, crc32_good);
747 PRINT_STATS_LE32(ofdm, false_alarm_cnt);
748 PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
749 PRINT_STATS_LE32(ofdm, sfd_timeout);
750 PRINT_STATS_LE32(ofdm, fina_timeout);
751 PRINT_STATS_LE32(ofdm, unresponded_rts);
752 PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
753 PRINT_STATS_LE32(ofdm, sent_ack_cnt);
754 PRINT_STATS_LE32(ofdm, sent_cts_cnt);
755 PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
756 PRINT_STATS_LE32(ofdm, dsp_self_kill);
757 PRINT_STATS_LE32(ofdm, mh_format_err);
758 PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
759 PRINT_STATS_LE32(ofdm, reserved);
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300760
761 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
762 "Statistics_Rx - CCK");
Johannes Berg93d17cc2015-01-15 12:59:26 +0100763 PRINT_STATS_LE32(cck, ina_cnt);
764 PRINT_STATS_LE32(cck, fina_cnt);
765 PRINT_STATS_LE32(cck, plcp_err);
766 PRINT_STATS_LE32(cck, crc32_err);
767 PRINT_STATS_LE32(cck, overrun_err);
768 PRINT_STATS_LE32(cck, early_overrun_err);
769 PRINT_STATS_LE32(cck, crc32_good);
770 PRINT_STATS_LE32(cck, false_alarm_cnt);
771 PRINT_STATS_LE32(cck, fina_sync_err_cnt);
772 PRINT_STATS_LE32(cck, sfd_timeout);
773 PRINT_STATS_LE32(cck, fina_timeout);
774 PRINT_STATS_LE32(cck, unresponded_rts);
775 PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
776 PRINT_STATS_LE32(cck, sent_ack_cnt);
777 PRINT_STATS_LE32(cck, sent_cts_cnt);
778 PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
779 PRINT_STATS_LE32(cck, dsp_self_kill);
780 PRINT_STATS_LE32(cck, mh_format_err);
781 PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
782 PRINT_STATS_LE32(cck, reserved);
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300783
784 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
785 "Statistics_Rx - GENERAL");
Johannes Berg93d17cc2015-01-15 12:59:26 +0100786 PRINT_STATS_LE32(general, bogus_cts);
787 PRINT_STATS_LE32(general, bogus_ack);
788 PRINT_STATS_LE32(general, non_bssid_frames);
789 PRINT_STATS_LE32(general, filtered_frames);
790 PRINT_STATS_LE32(general, non_channel_beacons);
791 PRINT_STATS_LE32(general, channel_beacons);
792 PRINT_STATS_LE32(general, num_missed_bcon);
793 PRINT_STATS_LE32(general, adc_rx_saturation_time);
794 PRINT_STATS_LE32(general, ina_detection_search_time);
795 PRINT_STATS_LE32(general, beacon_silence_rssi_a);
796 PRINT_STATS_LE32(general, beacon_silence_rssi_b);
797 PRINT_STATS_LE32(general, beacon_silence_rssi_c);
798 PRINT_STATS_LE32(general, interference_data_flag);
799 PRINT_STATS_LE32(general, channel_load);
800 PRINT_STATS_LE32(general, dsp_false_alarms);
801 PRINT_STATS_LE32(general, beacon_rssi_a);
802 PRINT_STATS_LE32(general, beacon_rssi_b);
803 PRINT_STATS_LE32(general, beacon_rssi_c);
804 PRINT_STATS_LE32(general, beacon_energy_a);
805 PRINT_STATS_LE32(general, beacon_energy_b);
806 PRINT_STATS_LE32(general, beacon_energy_c);
807 PRINT_STATS_LE32(general, num_bt_kills);
808 PRINT_STATS_LE32(general, mac_id);
809 PRINT_STATS_LE32(general, directed_data_mpdu);
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300810
811 pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
812 "Statistics_Rx - HT");
Johannes Berg93d17cc2015-01-15 12:59:26 +0100813 PRINT_STATS_LE32(ht, plcp_err);
814 PRINT_STATS_LE32(ht, overrun_err);
815 PRINT_STATS_LE32(ht, early_overrun_err);
816 PRINT_STATS_LE32(ht, crc32_good);
817 PRINT_STATS_LE32(ht, crc32_err);
818 PRINT_STATS_LE32(ht, mh_format_err);
819 PRINT_STATS_LE32(ht, agg_crc32_good);
820 PRINT_STATS_LE32(ht, agg_mpdu_cnt);
821 PRINT_STATS_LE32(ht, agg_cnt);
822 PRINT_STATS_LE32(ht, unsupport_mcs);
Matti Gottlieb3848ab62013-07-30 15:29:37 +0300823
824 mutex_unlock(&mvm->mutex);
825
826 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
827 kfree(buf);
828
829 return ret;
830}
831#undef PRINT_STAT_LE32
832
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200833static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
834 char __user *user_buf, size_t count,
835 loff_t *ppos,
836 struct iwl_mvm_frame_stats *stats)
837{
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200838 char *buff, *pos, *endpos;
839 int idx, i;
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200840 int ret;
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200841 static const size_t bufsz = 1024;
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200842
843 buff = kmalloc(bufsz, GFP_KERNEL);
844 if (!buff)
845 return -ENOMEM;
846
847 spin_lock_bh(&mvm->drv_stats_lock);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200848
849 pos = buff;
850 endpos = pos + bufsz;
851
852 pos += scnprintf(pos, endpos - pos,
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200853 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
854 stats->legacy_frames,
855 stats->ht_frames,
856 stats->vht_frames);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200857 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200858 stats->bw_20_frames,
859 stats->bw_40_frames,
860 stats->bw_80_frames);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200861 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200862 stats->ngi_frames,
863 stats->sgi_frames);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200864 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200865 stats->siso_frames,
866 stats->mimo2_frames);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200867 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200868 stats->fail_frames,
869 stats->success_frames);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200870 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200871 stats->agg_frames);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200872 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200873 stats->ampdu_count);
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200874 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200875 stats->ampdu_count > 0 ?
876 (stats->agg_frames / stats->ampdu_count) : 0);
877
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200878 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200879
880 idx = stats->last_frame_idx - 1;
881 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
882 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
883 if (stats->last_rates[idx] == 0)
884 continue;
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200885 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200886 (int)(ARRAY_SIZE(stats->last_rates) - i));
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200887 pos += rs_pretty_print_rate(pos, stats->last_rates[idx]);
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200888 }
889 spin_unlock_bh(&mvm->drv_stats_lock);
890
Eyal Shapiraf754b5c2014-02-24 10:24:34 +0200891 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
Eyal Shapira5fc0f762014-01-28 01:35:32 +0200892 kfree(buff);
893
894 return ret;
895}
896
897static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
898 char __user *user_buf, size_t count,
899 loff_t *ppos)
900{
901 struct iwl_mvm *mvm = file->private_data;
902
903 return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
904 &mvm->drv_rx_stats);
905}
906
Johannes Berg1fa3f572013-11-13 09:10:21 +0100907static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
Emmanuel Grumbach490953a2013-03-04 08:53:07 +0200908 size_t count, loff_t *ppos)
909{
Emmanuel Grumbach490953a2013-03-04 08:53:07 +0200910 int ret;
911
Emmanuel Grumbach490953a2013-03-04 08:53:07 +0200912 mutex_lock(&mvm->mutex);
913
Eran Harary291aa7c2013-07-03 11:00:06 +0300914 /* allow one more restart that we're provoking here */
915 if (mvm->restart_fw >= 0)
916 mvm->restart_fw++;
917
Emmanuel Grumbach490953a2013-03-04 08:53:07 +0200918 /* take the return value to make compiler happy - it will fail anyway */
Emmanuel Grumbacha1022922014-05-12 11:36:41 +0300919 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
Emmanuel Grumbach490953a2013-03-04 08:53:07 +0200920
921 mutex_unlock(&mvm->mutex);
922
Emmanuel Grumbach490953a2013-03-04 08:53:07 +0200923 return count;
924}
925
Johannes Berg1fa3f572013-11-13 09:10:21 +0100926static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
Alexander Bondar119663c2013-10-17 14:26:50 +0200927 size_t count, loff_t *ppos)
928{
Eliad Peller576eeee2014-07-01 18:38:38 +0300929 int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
930 if (ret)
931 return ret;
932
Liad Kaufman4c9706d2014-04-27 16:46:09 +0300933 iwl_force_nmi(mvm->trans);
Alexander Bondar119663c2013-10-17 14:26:50 +0200934
Eliad Peller576eeee2014-07-01 18:38:38 +0300935 iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
936
Alexander Bondar119663c2013-10-17 14:26:50 +0200937 return count;
938}
939
Oren Givon91b05d12013-08-19 08:36:48 +0300940static ssize_t
941iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
942 char __user *user_buf,
943 size_t count, loff_t *ppos)
944{
945 struct iwl_mvm *mvm = file->private_data;
946 int pos = 0;
947 char buf[32];
948 const size_t bufsz = sizeof(buf);
949
950 /* print which antennas were set for the scan command by the user */
951 pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
952 if (mvm->scan_rx_ant & ANT_A)
953 pos += scnprintf(buf + pos, bufsz - pos, "A");
954 if (mvm->scan_rx_ant & ANT_B)
955 pos += scnprintf(buf + pos, bufsz - pos, "B");
956 if (mvm->scan_rx_ant & ANT_C)
957 pos += scnprintf(buf + pos, bufsz - pos, "C");
958 pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
959
960 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
961}
962
963static ssize_t
Johannes Berg1fa3f572013-11-13 09:10:21 +0100964iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
Oren Givon91b05d12013-08-19 08:36:48 +0300965 size_t count, loff_t *ppos)
966{
Oren Givon91b05d12013-08-19 08:36:48 +0300967 u8 scan_rx_ant;
968
Oren Givon91b05d12013-08-19 08:36:48 +0300969 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
970 return -EINVAL;
971 if (scan_rx_ant > ANT_ABC)
972 return -EINVAL;
Moshe Harela0544272014-12-08 21:13:14 +0200973 if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
Oren Givon91b05d12013-08-19 08:36:48 +0300974 return -EINVAL;
975
David Spinadeld2496222014-05-20 12:46:37 +0300976 if (mvm->scan_rx_ant != scan_rx_ant) {
977 mvm->scan_rx_ant = scan_rx_ant;
Johannes Berg859d9142015-06-01 17:11:11 +0200978 if (fw_has_capa(&mvm->fw->ucode_capa,
979 IWL_UCODE_TLV_CAPA_UMAC_SCAN))
David Spinadeld2496222014-05-20 12:46:37 +0300980 iwl_mvm_config_scan(mvm);
981 }
Oren Givon91b05d12013-08-19 08:36:48 +0300982
983 return count;
984}
985
Sara Sharon43413a92015-12-31 11:49:18 +0200986static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm,
987 char *buf, size_t count,
988 loff_t *ppos)
989{
990 struct iwl_rss_config_cmd cmd = {
991 .flags = cpu_to_le32(IWL_RSS_ENABLE),
992 .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
993 IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
994 IWL_RSS_HASH_TYPE_IPV6_TCP |
995 IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
996 };
997 int ret, i, num_repeats, nbytes = count / 2;
998
999 ret = hex2bin(cmd.indirection_table, buf, nbytes);
1000 if (ret)
1001 return ret;
1002
1003 /*
1004 * The input is the redirection table, partial or full.
1005 * Repeat the pattern if needed.
1006 * For example, input of 01020F will be repeated 42 times,
1007 * indirecting RSS hash results to queues 1, 2, 15 (skipping
1008 * queues 3 - 14).
1009 */
1010 num_repeats = ARRAY_SIZE(cmd.indirection_table) / nbytes;
1011 for (i = 1; i < num_repeats; i++)
1012 memcpy(&cmd.indirection_table[i * nbytes],
1013 cmd.indirection_table, nbytes);
1014 /* handle cut in the middle pattern for the last places */
1015 memcpy(&cmd.indirection_table[i * nbytes], cmd.indirection_table,
1016 ARRAY_SIZE(cmd.indirection_table) % nbytes);
1017
Sara Sharondd4d3162016-02-07 12:50:35 +02001018 memcpy(cmd.secret_key, mvm->secret_key, sizeof(cmd.secret_key));
Sara Sharon43413a92015-12-31 11:49:18 +02001019
1020 mutex_lock(&mvm->mutex);
1021 ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, sizeof(cmd), &cmd);
1022 mutex_unlock(&mvm->mutex);
1023
1024 return ret ?: count;
1025}
1026
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001027static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
1028 char __user *user_buf,
1029 size_t count, loff_t *ppos)
1030{
1031 struct iwl_mvm *mvm = file->private_data;
Emmanuel Grumbachd2709ad2015-01-29 14:58:06 +02001032 int conf;
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001033 char buf[8];
1034 const size_t bufsz = sizeof(buf);
1035 int pos = 0;
1036
1037 mutex_lock(&mvm->mutex);
1038 conf = mvm->fw_dbg_conf;
1039 mutex_unlock(&mvm->mutex);
1040
1041 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
1042
1043 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1044}
1045
Golan Ben Ami321c2102015-07-27 17:02:35 +03001046/*
1047 * Enable / Disable continuous recording.
1048 * Cause the FW to start continuous recording, by sending the relevant hcmd.
1049 * Enable: input of every integer larger than 0, ENABLE_CONT_RECORDING.
1050 * Disable: for 0 as input, DISABLE_CONT_RECORDING.
1051 */
1052static ssize_t iwl_dbgfs_cont_recording_write(struct iwl_mvm *mvm,
1053 char *buf, size_t count,
1054 loff_t *ppos)
1055{
1056 struct iwl_trans *trans = mvm->trans;
1057 const struct iwl_fw_dbg_dest_tlv *dest = trans->dbg_dest_tlv;
1058 struct iwl_continuous_record_cmd cont_rec = {};
1059 int ret, rec_mode;
1060
1061 if (!dest)
1062 return -EOPNOTSUPP;
1063
1064 if (dest->monitor_mode != SMEM_MODE ||
1065 trans->cfg->device_family != IWL_DEVICE_FAMILY_8000)
1066 return -EOPNOTSUPP;
1067
Johannes Berg27e070d2016-01-14 10:55:22 +01001068 ret = kstrtoint(buf, 0, &rec_mode);
Golan Ben Ami321c2102015-07-27 17:02:35 +03001069 if (ret)
1070 return ret;
1071
1072 cont_rec.record_mode.enable_recording = rec_mode ?
1073 cpu_to_le16(ENABLE_CONT_RECORDING) :
1074 cpu_to_le16(DISABLE_CONT_RECORDING);
1075
1076 mutex_lock(&mvm->mutex);
1077 ret = iwl_mvm_send_cmd_pdu(mvm, LDBG_CONFIG_CMD, 0,
1078 sizeof(cont_rec), &cont_rec);
1079 mutex_unlock(&mvm->mutex);
1080
1081 return ret ?: count;
1082}
1083
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001084static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
1085 char *buf, size_t count,
1086 loff_t *ppos)
1087{
Dan Carpenter8e8114d2015-08-21 11:48:21 +03001088 unsigned int conf_id;
1089 int ret;
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001090
Dan Carpenter8e8114d2015-08-21 11:48:21 +03001091 ret = kstrtouint(buf, 0, &conf_id);
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001092 if (ret)
1093 return ret;
1094
Emmanuel Grumbachd2709ad2015-01-29 14:58:06 +02001095 if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001096 return -EINVAL;
1097
1098 mutex_lock(&mvm->mutex);
1099 ret = iwl_mvm_start_fw_dbg_conf(mvm, conf_id);
1100 mutex_unlock(&mvm->mutex);
1101
1102 return ret ?: count;
1103}
1104
1105static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
1106 char *buf, size_t count,
1107 loff_t *ppos)
1108{
Liad Kaufmane93475a2015-01-04 11:03:13 +02001109 int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1110
1111 if (ret)
1112 return ret;
1113
Golan Ben-Amic91b8652015-11-30 14:30:21 +02001114 iwl_mvm_fw_dbg_collect(mvm, FW_DBG_TRIGGER_USER, buf,
1115 (count - 1), NULL);
Liad Kaufmane93475a2015-01-04 11:03:13 +02001116
1117 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001118
1119 return count;
1120}
1121
Emmanuel Grumbach9e7dce22015-10-26 16:14:06 +02001122static ssize_t iwl_dbgfs_max_amsdu_len_write(struct iwl_mvm *mvm,
1123 char *buf, size_t count,
1124 loff_t *ppos)
1125{
1126 unsigned int max_amsdu_len;
1127 int ret;
1128
1129 ret = kstrtouint(buf, 0, &max_amsdu_len);
1130
1131 if (max_amsdu_len > IEEE80211_MAX_MPDU_LEN_VHT_11454)
1132 return -EINVAL;
1133 mvm->max_amsdu_len = max_amsdu_len;
1134
1135 return count;
1136}
1137
Eliad Pellerde06a592014-01-08 10:11:12 +02001138#define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
1139#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1140static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
1141 char __user *user_buf,
1142 size_t count, loff_t *ppos)
1143{
1144 struct iwl_mvm *mvm = file->private_data;
1145 struct iwl_bcast_filter_cmd cmd;
1146 const struct iwl_fw_bcast_filter *filter;
1147 char *buf;
1148 int bufsz = 1024;
1149 int i, j, pos = 0;
1150 ssize_t ret;
1151
1152 buf = kzalloc(bufsz, GFP_KERNEL);
1153 if (!buf)
1154 return -ENOMEM;
1155
1156 mutex_lock(&mvm->mutex);
1157 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1158 ADD_TEXT("None\n");
1159 mutex_unlock(&mvm->mutex);
1160 goto out;
1161 }
1162 mutex_unlock(&mvm->mutex);
1163
1164 for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
1165 filter = &cmd.filters[i];
1166
1167 ADD_TEXT("Filter [%d]:\n", i);
1168 ADD_TEXT("\tDiscard=%d\n", filter->discard);
1169 ADD_TEXT("\tFrame Type: %s\n",
1170 filter->frame_type ? "IPv4" : "Generic");
1171
1172 for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
1173 const struct iwl_fw_bcast_filter_attr *attr;
1174
1175 attr = &filter->attrs[j];
1176 if (!attr->mask)
1177 break;
1178
1179 ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
1180 j, attr->offset,
1181 attr->offset_type ? "IP End" :
1182 "Payload Start",
1183 be32_to_cpu(attr->mask),
1184 be32_to_cpu(attr->val),
1185 le16_to_cpu(attr->reserved1));
1186 }
1187 }
1188out:
1189 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1190 kfree(buf);
1191 return ret;
1192}
1193
1194static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
1195 size_t count, loff_t *ppos)
1196{
1197 int pos, next_pos;
1198 struct iwl_fw_bcast_filter filter = {};
1199 struct iwl_bcast_filter_cmd cmd;
1200 u32 filter_id, attr_id, mask, value;
1201 int err = 0;
1202
1203 if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
1204 &filter.frame_type, &pos) != 3)
1205 return -EINVAL;
1206
1207 if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
1208 filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
1209 return -EINVAL;
1210
1211 for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
1212 attr_id++) {
1213 struct iwl_fw_bcast_filter_attr *attr =
1214 &filter.attrs[attr_id];
1215
1216 if (pos >= count)
1217 break;
1218
1219 if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
1220 &attr->offset, &attr->offset_type,
1221 &mask, &value, &next_pos) != 4)
1222 return -EINVAL;
1223
1224 attr->mask = cpu_to_be32(mask);
1225 attr->val = cpu_to_be32(value);
1226 if (mask)
1227 filter.num_attrs++;
1228
1229 pos += next_pos;
1230 }
1231
1232 mutex_lock(&mvm->mutex);
1233 memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
1234 &filter, sizeof(filter));
1235
1236 /* send updated bcast filtering configuration */
1237 if (mvm->dbgfs_bcast_filtering.override &&
1238 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
Emmanuel Grumbacha1022922014-05-12 11:36:41 +03001239 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
Eliad Pellerde06a592014-01-08 10:11:12 +02001240 sizeof(cmd), &cmd);
1241 mutex_unlock(&mvm->mutex);
1242
1243 return err ?: count;
1244}
1245
1246static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
1247 char __user *user_buf,
1248 size_t count, loff_t *ppos)
1249{
1250 struct iwl_mvm *mvm = file->private_data;
1251 struct iwl_bcast_filter_cmd cmd;
1252 char *buf;
1253 int bufsz = 1024;
1254 int i, pos = 0;
1255 ssize_t ret;
1256
1257 buf = kzalloc(bufsz, GFP_KERNEL);
1258 if (!buf)
1259 return -ENOMEM;
1260
1261 mutex_lock(&mvm->mutex);
1262 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
1263 ADD_TEXT("None\n");
1264 mutex_unlock(&mvm->mutex);
1265 goto out;
1266 }
1267 mutex_unlock(&mvm->mutex);
1268
1269 for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
1270 const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
1271
1272 ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
1273 i, mac->default_discard, mac->attached_filters);
1274 }
1275out:
1276 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1277 kfree(buf);
1278 return ret;
1279}
1280
1281static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
1282 char *buf, size_t count,
1283 loff_t *ppos)
1284{
1285 struct iwl_bcast_filter_cmd cmd;
1286 struct iwl_fw_bcast_mac mac = {};
1287 u32 mac_id, attached_filters;
1288 int err = 0;
1289
1290 if (!mvm->bcast_filters)
1291 return -ENOENT;
1292
1293 if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
1294 &attached_filters) != 3)
1295 return -EINVAL;
1296
1297 if (mac_id >= ARRAY_SIZE(cmd.macs) ||
1298 mac.default_discard > 1 ||
1299 attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
1300 return -EINVAL;
1301
1302 mac.attached_filters = cpu_to_le16(attached_filters);
1303
1304 mutex_lock(&mvm->mutex);
1305 memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
1306 &mac, sizeof(mac));
1307
1308 /* send updated bcast filtering configuration */
1309 if (mvm->dbgfs_bcast_filtering.override &&
1310 iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
Emmanuel Grumbacha1022922014-05-12 11:36:41 +03001311 err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
Eliad Pellerde06a592014-01-08 10:11:12 +02001312 sizeof(cmd), &cmd);
1313 mutex_unlock(&mvm->mutex);
1314
1315 return err ?: count;
1316}
1317#endif
1318
Johannes Bergafc66bb2013-05-03 11:44:16 +02001319#ifdef CONFIG_PM_SLEEP
Johannes Berg1fa3f572013-11-13 09:10:21 +01001320static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
Johannes Bergafc66bb2013-05-03 11:44:16 +02001321 size_t count, loff_t *ppos)
1322{
Johannes Bergafc66bb2013-05-03 11:44:16 +02001323 int store;
1324
Johannes Bergafc66bb2013-05-03 11:44:16 +02001325 if (sscanf(buf, "%d", &store) != 1)
1326 return -EINVAL;
1327
1328 mvm->store_d3_resume_sram = store;
1329
1330 return count;
1331}
1332
1333static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
1334 size_t count, loff_t *ppos)
1335{
1336 struct iwl_mvm *mvm = file->private_data;
1337 const struct fw_img *img;
1338 int ofs, len, pos = 0;
1339 size_t bufsz, ret;
1340 char *buf;
1341 u8 *ptr = mvm->d3_resume_sram;
1342
1343 img = &mvm->fw->img[IWL_UCODE_WOWLAN];
1344 len = img->sec[IWL_UCODE_SECTION_DATA].len;
1345
1346 bufsz = len * 4 + 256;
1347 buf = kzalloc(bufsz, GFP_KERNEL);
1348 if (!buf)
1349 return -ENOMEM;
1350
1351 pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
1352 mvm->store_d3_resume_sram ? "en" : "dis");
1353
1354 if (ptr) {
1355 for (ofs = 0; ofs < len; ofs += 16) {
1356 pos += scnprintf(buf + pos, bufsz - pos,
Andy Shevchenko3cd6e2f2015-07-16 15:42:14 +03001357 "0x%.4x %16ph\n", ofs, ptr + ofs);
Johannes Bergafc66bb2013-05-03 11:44:16 +02001358 }
1359 } else {
1360 pos += scnprintf(buf + pos, bufsz - pos,
1361 "(no data captured)\n");
1362 }
1363
1364 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1365
1366 kfree(buf);
1367
1368 return ret;
1369}
1370#endif
1371
Eliad Peller576eeee2014-07-01 18:38:38 +03001372#define PRINT_MVM_REF(ref) do { \
1373 if (mvm->refs[ref]) \
1374 pos += scnprintf(buf + pos, bufsz - pos, \
1375 "\t(0x%lx): %d %s\n", \
1376 BIT(ref), mvm->refs[ref], #ref); \
Eliad Peller70d6bab2013-11-05 14:45:16 +02001377} while (0)
1378
1379static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
1380 char __user *user_buf,
1381 size_t count, loff_t *ppos)
1382{
1383 struct iwl_mvm *mvm = file->private_data;
Eliad Peller576eeee2014-07-01 18:38:38 +03001384 int i, pos = 0;
Eliad Peller70d6bab2013-11-05 14:45:16 +02001385 char buf[256];
1386 const size_t bufsz = sizeof(buf);
Eliad Peller576eeee2014-07-01 18:38:38 +03001387 u32 refs = 0;
Eliad Peller70d6bab2013-11-05 14:45:16 +02001388
Eliad Peller576eeee2014-07-01 18:38:38 +03001389 for (i = 0; i < IWL_MVM_REF_COUNT; i++)
1390 if (mvm->refs[i])
1391 refs |= BIT(i);
1392
1393 pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
1394 refs);
Eliad Peller70d6bab2013-11-05 14:45:16 +02001395
1396 PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
1397 PRINT_MVM_REF(IWL_MVM_REF_SCAN);
1398 PRINT_MVM_REF(IWL_MVM_REF_ROC);
Eliad Pellerc7792732015-04-19 11:41:04 +03001399 PRINT_MVM_REF(IWL_MVM_REF_ROC_AUX);
Eliad Peller70d6bab2013-11-05 14:45:16 +02001400 PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
1401 PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
Eliad Peller0eb83652013-11-11 18:56:35 +02001402 PRINT_MVM_REF(IWL_MVM_REF_USER);
Johannes Berg34e611e2014-09-12 10:28:01 +02001403 PRINT_MVM_REF(IWL_MVM_REF_TX);
1404 PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
1405 PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
1406 PRINT_MVM_REF(IWL_MVM_REF_START_AP);
1407 PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
1408 PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
1409 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
1410 PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
1411 PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
1412 PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
1413 PRINT_MVM_REF(IWL_MVM_REF_NMI);
1414 PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
Eliad Pellerd15a7472014-03-27 18:53:12 +02001415 PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
Eliad Peller160acc02014-11-25 12:34:45 +02001416 PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA);
Liad Kaufmanfb2380a2015-01-01 17:42:46 +02001417 PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT);
Eliad Peller08f0d232015-12-10 15:47:11 +02001418 PRINT_MVM_REF(IWL_MVM_REF_INIT_UCODE);
Eliad Peller70d6bab2013-11-05 14:45:16 +02001419
1420 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1421}
1422
Eliad Peller0eb83652013-11-11 18:56:35 +02001423static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
1424 size_t count, loff_t *ppos)
1425{
1426 unsigned long value;
1427 int ret;
1428 bool taken;
1429
1430 ret = kstrtoul(buf, 10, &value);
1431 if (ret < 0)
1432 return ret;
1433
1434 mutex_lock(&mvm->mutex);
1435
Eliad Peller576eeee2014-07-01 18:38:38 +03001436 taken = mvm->refs[IWL_MVM_REF_USER];
Eliad Peller0eb83652013-11-11 18:56:35 +02001437 if (value == 1 && !taken)
1438 iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
1439 else if (value == 0 && taken)
1440 iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
1441 else
1442 ret = -EINVAL;
1443
1444 mutex_unlock(&mvm->mutex);
1445
1446 if (ret < 0)
1447 return ret;
1448 return count;
1449}
1450
Johannes Berg1fa3f572013-11-13 09:10:21 +01001451#define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
1452 _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
1453#define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
1454 _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
Eliad Pellerde06a592014-01-08 10:11:12 +02001455#define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
1456 if (!debugfs_create_file(alias, mode, parent, mvm, \
Johannes Berg8ca151b2013-01-24 14:25:36 +01001457 &iwl_dbgfs_##name##_ops)) \
1458 goto err; \
1459 } while (0)
Eliad Pellerde06a592014-01-08 10:11:12 +02001460#define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
1461 MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001462
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001463static ssize_t
1464iwl_dbgfs_prph_reg_read(struct file *file,
1465 char __user *user_buf,
1466 size_t count, loff_t *ppos)
1467{
1468 struct iwl_mvm *mvm = file->private_data;
1469 int pos = 0;
1470 char buf[32];
1471 const size_t bufsz = sizeof(buf);
Eliad Peller576eeee2014-07-01 18:38:38 +03001472 int ret;
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001473
1474 if (!mvm->dbgfs_prph_reg_addr)
1475 return -EINVAL;
1476
Eliad Peller576eeee2014-07-01 18:38:38 +03001477 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
1478 if (ret)
1479 return ret;
1480
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001481 pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
1482 mvm->dbgfs_prph_reg_addr,
1483 iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
1484
Eliad Peller576eeee2014-07-01 18:38:38 +03001485 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
1486
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001487 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1488}
1489
1490static ssize_t
1491iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
1492 size_t count, loff_t *ppos)
1493{
1494 u8 args;
1495 u32 value;
Eliad Peller576eeee2014-07-01 18:38:38 +03001496 int ret;
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001497
1498 args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
1499 /* if we only want to set the reg address - nothing more to do */
1500 if (args == 1)
1501 goto out;
1502
1503 /* otherwise, make sure we have both address and value */
1504 if (args != 2)
1505 return -EINVAL;
1506
Eliad Peller576eeee2014-07-01 18:38:38 +03001507 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
1508 if (ret)
1509 return ret;
1510
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001511 iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
Eliad Peller576eeee2014-07-01 18:38:38 +03001512
1513 iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001514out:
1515 return count;
1516}
1517
Emmanuel Grumbache5046012015-08-17 10:45:50 +03001518static ssize_t
1519iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
1520 size_t count, loff_t *ppos)
1521{
1522 int ret;
1523
1524 mutex_lock(&mvm->mutex);
1525 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
1526 mutex_unlock(&mvm->mutex);
1527
1528 return ret ?: count;
1529}
1530
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001531MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
1532
Johannes Berg8ca151b2013-01-24 14:25:36 +01001533/* Device wide debugfs entries */
Chaya Rachel Ivgi00f481b2016-02-24 12:19:22 +02001534MVM_DEBUGFS_READ_FILE_OPS(ctdp_budget);
1535MVM_DEBUGFS_WRITE_FILE_OPS(stop_ctdp, 8);
Johannes Berg1fa3f572013-11-13 09:10:21 +01001536MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
1537MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
Emmanuel Grumbache5046012015-08-17 10:45:50 +03001538MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
Johannes Berg1fa3f572013-11-13 09:10:21 +01001539MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
Matti Gottlieb7280d1f2014-07-17 16:41:14 +03001540MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
Luciano Coelhoc549e392014-09-04 15:58:47 +03001541MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001542MVM_DEBUGFS_READ_FILE_OPS(stations);
Emmanuel Grumbach10942342013-02-19 11:02:36 +02001543MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
Emmanuel Grumbach2de13ca2013-06-30 07:43:28 +03001544MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
Johannes Berg1fa3f572013-11-13 09:10:21 +01001545MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
Matti Gottlieb3848ab62013-07-30 15:29:37 +03001546MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
Eyal Shapira5fc0f762014-01-28 01:35:32 +02001547MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
Johannes Berg1fa3f572013-11-13 09:10:21 +01001548MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
1549MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
Emmanuel Grumbachcdb00562014-03-16 21:55:43 +02001550MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
Emmanuel Grumbacha39979a2014-05-28 12:06:41 +03001551MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
Johannes Berg1fa3f572013-11-13 09:10:21 +01001552MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
Eliad Peller0eb83652013-11-11 18:56:35 +02001553MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001554MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
Golan Ben-Amic91b8652015-11-30 14:30:21 +02001555MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64);
Golan Ben Ami321c2102015-07-27 17:02:35 +03001556MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8);
Emmanuel Grumbach9e7dce22015-10-26 16:14:06 +02001557MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8);
Sara Sharondd4d3162016-02-07 12:50:35 +02001558MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl,
1559 (IWL_RSS_INDIRECTION_TABLE_SIZE * 2));
Oren Givon91b05d12013-08-19 08:36:48 +03001560
Eliad Pellerde06a592014-01-08 10:11:12 +02001561#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1562MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
1563MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
1564#endif
1565
Johannes Bergafc66bb2013-05-03 11:44:16 +02001566#ifdef CONFIG_PM_SLEEP
Johannes Berg1fa3f572013-11-13 09:10:21 +01001567MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
Johannes Bergafc66bb2013-05-03 11:44:16 +02001568#endif
Johannes Berg8ca151b2013-01-24 14:25:36 +01001569
1570int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1571{
Eliad Pellerde06a592014-01-08 10:11:12 +02001572 struct dentry *bcast_dir __maybe_unused;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001573 char buf[100];
1574
Johannes Bergd07913a2014-02-26 11:25:58 +01001575 spin_lock_init(&mvm->drv_stats_lock);
1576
Johannes Berg8ca151b2013-01-24 14:25:36 +01001577 mvm->debugfs_dir = dbgfs_dir;
1578
1579 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
1580 MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
1581 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
Matti Gottlieb7280d1f2014-07-17 16:41:14 +03001582 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir,
1583 S_IWUSR | S_IRUSR);
Luciano Coelhoc549e392014-09-04 15:58:47 +03001584 MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR);
Chaya Rachel Ivgi00f481b2016-02-24 12:19:22 +02001585 MVM_DEBUGFS_ADD_FILE(ctdp_budget, dbgfs_dir, S_IRUSR);
1586 MVM_DEBUGFS_ADD_FILE(stop_ctdp, dbgfs_dir, S_IWUSR);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001587 MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
Emmanuel Grumbach10942342013-02-19 11:02:36 +02001588 MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
Emmanuel Grumbach2de13ca2013-06-30 07:43:28 +03001589 MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR);
Emmanuel Grumbach639eaba2014-03-30 10:11:13 +03001590 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir,
1591 S_IRUSR | S_IWUSR);
Matti Gottlieb3848ab62013-07-30 15:29:37 +03001592 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR);
Eyal Shapira5fc0f762014-01-28 01:35:32 +02001593 MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR);
Emmanuel Grumbach490953a2013-03-04 08:53:07 +02001594 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
Alexander Bondar119663c2013-10-17 14:26:50 +02001595 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
Emmanuel Grumbachcdb00562014-03-16 21:55:43 +02001596 MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR);
Emmanuel Grumbacha39979a2014-05-28 12:06:41 +03001597 MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR);
Oren Givon91b05d12013-08-19 08:36:48 +03001598 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
1599 S_IWUSR | S_IRUSR);
Eliad Pellerf3c221f2014-01-09 13:12:54 +02001600 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
Eliad Peller0eb83652013-11-11 18:56:35 +02001601 MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
Emmanuel Grumbach8c23f952014-12-04 10:07:47 +02001602 MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
1603 MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, S_IWUSR);
Emmanuel Grumbach9e7dce22015-10-26 16:14:06 +02001604 MVM_DEBUGFS_ADD_FILE(max_amsdu_len, mvm->debugfs_dir, S_IWUSR);
Emmanuel Grumbache5046012015-08-17 10:45:50 +03001605 MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR);
Golan Ben Ami321c2102015-07-27 17:02:35 +03001606 MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR);
Sara Sharon43413a92015-12-31 11:49:18 +02001607 MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR);
Luciano Coelhocb2513b2015-02-27 16:26:57 +02001608 if (!debugfs_create_bool("enable_scan_iteration_notif",
1609 S_IRUSR | S_IWUSR,
1610 mvm->debugfs_dir,
1611 &mvm->scan_iter_notif_enabled))
1612 goto err;
Andrei Otcheretianskic89e3332016-01-26 18:12:28 +02001613 if (!debugfs_create_bool("drop_bcn_ap_mode", S_IRUSR | S_IWUSR,
1614 mvm->debugfs_dir, &mvm->drop_bcn_ap_mode))
1615 goto err;
Eliad Pellerde06a592014-01-08 10:11:12 +02001616
1617#ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1618 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
1619 bcast_dir = debugfs_create_dir("bcast_filtering",
1620 mvm->debugfs_dir);
1621 if (!bcast_dir)
1622 goto err;
1623
1624 if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR,
1625 bcast_dir,
1626 &mvm->dbgfs_bcast_filtering.override))
1627 goto err;
1628
1629 MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
1630 bcast_dir, S_IWUSR | S_IRUSR);
1631 MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
1632 bcast_dir, S_IWUSR | S_IRUSR);
1633 }
1634#endif
1635
Johannes Bergafc66bb2013-05-03 11:44:16 +02001636#ifdef CONFIG_PM_SLEEP
1637 MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
Johannes Bergdebff612013-05-14 13:53:45 +02001638 MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
Johannes Bergb0114712013-06-12 14:55:40 +02001639 if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
1640 mvm->debugfs_dir, &mvm->d3_wake_sysassert))
1641 goto err;
Luciano Coelho484b3d12015-03-30 20:46:32 +03001642 if (!debugfs_create_u32("last_netdetect_scans", S_IRUSR,
1643 mvm->debugfs_dir, &mvm->last_netdetect_scans))
1644 goto err;
Johannes Bergafc66bb2013-05-03 11:44:16 +02001645#endif
Johannes Berg8ca151b2013-01-24 14:25:36 +01001646
Luciano Coelhobdd54832014-08-07 18:08:56 +03001647 if (!debugfs_create_u8("ps_disabled", S_IRUSR,
1648 mvm->debugfs_dir, &mvm->ps_disabled))
1649 goto err;
Emmanuel Grumbach086f7362013-11-18 17:00:03 +02001650 if (!debugfs_create_blob("nvm_hw", S_IRUSR,
1651 mvm->debugfs_dir, &mvm->nvm_hw_blob))
1652 goto err;
1653 if (!debugfs_create_blob("nvm_sw", S_IRUSR,
1654 mvm->debugfs_dir, &mvm->nvm_sw_blob))
1655 goto err;
1656 if (!debugfs_create_blob("nvm_calib", S_IRUSR,
1657 mvm->debugfs_dir, &mvm->nvm_calib_blob))
1658 goto err;
1659 if (!debugfs_create_blob("nvm_prod", S_IRUSR,
1660 mvm->debugfs_dir, &mvm->nvm_prod_blob))
1661 goto err;
Moshe Harel91fac942015-09-02 12:45:12 +03001662 if (!debugfs_create_blob("nvm_phy_sku", S_IRUSR,
1663 mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
1664 goto err;
Emmanuel Grumbach086f7362013-11-18 17:00:03 +02001665
Johannes Berg8ca151b2013-01-24 14:25:36 +01001666 /*
1667 * Create a symlink with mac80211. It will be removed when mac80211
1668 * exists (before the opmode exists which removes the target.)
1669 */
1670 snprintf(buf, 100, "../../%s/%s",
1671 dbgfs_dir->d_parent->d_parent->d_name.name,
1672 dbgfs_dir->d_parent->d_name.name);
1673 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
1674 goto err;
1675
1676 return 0;
1677err:
1678 IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
1679 return -ENOMEM;
1680}