blob: b15e44f8d1bd7858939cd4379374dfd2aa37cd9c [file] [log] [blame]
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02005 * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
Tomas Winkler712b6cf2008-03-12 16:58:52 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020022 * in the file called COPYING.
Tomas Winkler712b6cf2008-03-12 16:58:52 -070023 *
24 * Contact Information:
Winkler, Tomas759ef892008-12-09 11:28:58 -080025 * Intel Linux Wireless <ilw@linux.intel.com>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070026 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070030#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/debugfs.h>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070033#include <linux/ieee80211.h>
34#include <net/mac80211.h>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070035#include "iwl-debug.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070036#include "iwl-io.h"
Johannes Berg1023fdc2012-05-15 12:16:34 +020037#include "dev.h"
38#include "agn.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070039
40/* create and remove of files */
Johannes Berg4c84a8f2010-01-22 14:22:54 -080041#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
42 if (!debugfs_create_file(#name, mode, parent, priv, \
43 &iwl_dbgfs_##name##_ops)) \
44 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070045} while (0)
46
Johannes Berg4c84a8f2010-01-22 14:22:54 -080047#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
48 struct dentry *__tmp; \
49 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
50 parent, ptr); \
51 if (IS_ERR(__tmp) || !__tmp) \
52 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070053} while (0)
54
Johannes Berg4c84a8f2010-01-22 14:22:54 -080055#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
56 struct dentry *__tmp; \
57 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
58 parent, ptr); \
59 if (IS_ERR(__tmp) || !__tmp) \
60 goto err; \
Tomas Winkler445c2df2008-05-15 13:54:16 +080061} while (0)
62
Johannes Bergca934b62011-09-15 11:46:48 -070063#define DEBUGFS_ADD_U32(name, parent, ptr, mode) do { \
64 struct dentry *__tmp; \
65 __tmp = debugfs_create_u32(#name, mode, \
66 parent, ptr); \
67 if (IS_ERR(__tmp) || !__tmp) \
68 goto err; \
69} while (0)
70
Tomas Winkler712b6cf2008-03-12 16:58:52 -070071/* file operation */
Tomas Winkler712b6cf2008-03-12 16:58:52 -070072#define DEBUGFS_READ_FILE_OPS(name) \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070073static const struct file_operations iwl_dbgfs_##name##_ops = { \
Richard A. Griffiths0ff1bd32012-06-28 13:14:11 -070074 .read = iwl_dbgfs_##name##_read, \
Stephen Boyd234e3402012-04-05 14:25:11 -070075 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020076 .llseek = generic_file_llseek, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070077};
78
Ester Kummer189a2b52008-05-15 13:54:18 +080079#define DEBUGFS_WRITE_FILE_OPS(name) \
Ester Kummer189a2b52008-05-15 13:54:18 +080080static const struct file_operations iwl_dbgfs_##name##_ops = { \
81 .write = iwl_dbgfs_##name##_write, \
Stephen Boyd234e3402012-04-05 14:25:11 -070082 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020083 .llseek = generic_file_llseek, \
Ester Kummer189a2b52008-05-15 13:54:18 +080084};
85
86
Tomas Winkler712b6cf2008-03-12 16:58:52 -070087#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070088static const struct file_operations iwl_dbgfs_##name##_ops = { \
89 .write = iwl_dbgfs_##name##_write, \
90 .read = iwl_dbgfs_##name##_read, \
Stephen Boyd234e3402012-04-05 14:25:11 -070091 .open = simple_open, \
Arnd Bergmann2b18ab362010-07-06 19:05:31 +020092 .llseek = generic_file_llseek, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070093};
94
Tomas Winkler712b6cf2008-03-12 16:58:52 -070095static ssize_t iwl_dbgfs_sram_read(struct file *file,
96 char __user *user_buf,
97 size_t count, loff_t *ppos)
98{
Jay Sternberg24834d22011-01-11 15:41:00 -080099 u32 val = 0;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800100 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700101 ssize_t ret;
Jay Sternberg24834d22011-01-11 15:41:00 -0800102 int i = 0;
103 bool device_format = false;
104 int offset = 0;
105 int len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700106 int pos = 0;
Jay Sternberg24834d22011-01-11 15:41:00 -0800107 int sram;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700108 struct iwl_priv *priv = file->private_data;
David Spinadel6dfa8d02012-03-10 13:00:14 -0800109 const struct fw_img *img;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800110 size_t bufsz;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700111
Johannes Berg4fc79db2012-08-21 18:57:11 +0200112 if (!iwl_is_ready_rf(priv))
113 return -EAGAIN;
114
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800115 /* default is to dump the entire data segment */
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800116 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
117 priv->dbgfs_sram_offset = 0x800000;
Johannes Bergf9e75442012-03-30 09:37:39 +0200118 if (!priv->ucode_loaded)
David Spinadel8f7ffbe2012-03-10 13:00:10 -0800119 return -EINVAL;
Meenakshi Venkataramana42506e2012-03-15 13:26:57 -0700120 img = &priv->fw->img[priv->cur_ucode];
David Spinadel6dfa8d02012-03-10 13:00:14 -0800121 priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800122 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800123 len = priv->dbgfs_sram_len;
124
125 if (len == -4) {
126 device_format = true;
127 len = 4;
128 }
129
130 bufsz = 50 + len * 4;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800131 buf = kmalloc(bufsz, GFP_KERNEL);
132 if (!buf)
133 return -ENOMEM;
Jay Sternberg24834d22011-01-11 15:41:00 -0800134
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800135 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
Jay Sternberg24834d22011-01-11 15:41:00 -0800136 len);
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800137 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800138 priv->dbgfs_sram_offset);
Jay Sternberg24834d22011-01-11 15:41:00 -0800139
140 /* adjust sram address since reads are only on even u32 boundaries */
141 offset = priv->dbgfs_sram_offset & 0x3;
142 sram = priv->dbgfs_sram_offset & ~0x3;
143
144 /* read the first u32 from sram */
Emmanuel Grumbach4fd442d2012-12-24 14:27:11 +0200145 val = iwl_trans_read_mem32(priv->trans, sram);
Jay Sternberg24834d22011-01-11 15:41:00 -0800146
147 for (; len; len--) {
148 /* put the address at the start of every line */
149 if (i == 0)
150 pos += scnprintf(buf + pos, bufsz - pos,
151 "%08X: ", sram + offset);
152
153 if (device_format)
154 pos += scnprintf(buf + pos, bufsz - pos,
155 "%02x", (val >> (8 * (3 - offset))) & 0xff);
156 else
157 pos += scnprintf(buf + pos, bufsz - pos,
158 "%02x ", (val >> (8 * offset)) & 0xff);
159
160 /* if all bytes processed, read the next u32 from sram */
161 if (++offset == 4) {
162 sram += 4;
163 offset = 0;
Emmanuel Grumbach4fd442d2012-12-24 14:27:11 +0200164 val = iwl_trans_read_mem32(priv->trans, sram);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700165 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800166
167 /* put in extra spaces and split lines for human readability */
168 if (++i == 16) {
169 i = 0;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800170 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Jay Sternberg24834d22011-01-11 15:41:00 -0800171 } else if (!(i & 7)) {
172 pos += scnprintf(buf + pos, bufsz - pos, " ");
173 } else if (!(i & 3)) {
174 pos += scnprintf(buf + pos, bufsz - pos, " ");
175 }
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700176 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800177 if (i)
178 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700179
180 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800181 kfree(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700182 return ret;
183}
184
185static ssize_t iwl_dbgfs_sram_write(struct file *file,
186 const char __user *user_buf,
187 size_t count, loff_t *ppos)
188{
189 struct iwl_priv *priv = file->private_data;
190 char buf[64];
191 int buf_size;
192 u32 offset, len;
193
194 memset(buf, 0, sizeof(buf));
195 buf_size = min(count, sizeof(buf) - 1);
196 if (copy_from_user(buf, user_buf, buf_size))
197 return -EFAULT;
198
199 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800200 priv->dbgfs_sram_offset = offset;
201 priv->dbgfs_sram_len = len;
Jay Sternberg24834d22011-01-11 15:41:00 -0800202 } else if (sscanf(buf, "%x", &offset) == 1) {
203 priv->dbgfs_sram_offset = offset;
204 priv->dbgfs_sram_len = -4;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700205 } else {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800206 priv->dbgfs_sram_offset = 0;
207 priv->dbgfs_sram_len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700208 }
209
210 return count;
211}
212
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700213static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
214 char __user *user_buf,
215 size_t count, loff_t *ppos)
216{
217 struct iwl_priv *priv = file->private_data;
David Spinadel6dfa8d02012-03-10 13:00:14 -0800218 const struct fw_img *img = &priv->fw->img[IWL_UCODE_WOWLAN];
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700219
220 if (!priv->wowlan_sram)
221 return -ENODATA;
222
223 return simple_read_from_buffer(user_buf, count, ppos,
224 priv->wowlan_sram,
David Spinadel6dfa8d02012-03-10 13:00:14 -0800225 img->sec[IWL_UCODE_SECTION_DATA].len);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700226}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700227static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
228 size_t count, loff_t *ppos)
229{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700230 struct iwl_priv *priv = file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800231 struct iwl_station_entry *station;
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700232 struct iwl_tid_data *tid_data;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700233 char *buf;
234 int i, j, pos = 0;
235 ssize_t ret;
236 /* Add 30 for initial string */
237 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700238
239 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300240 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700241 return -ENOMEM;
242
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700243 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700244 priv->num_stations);
245
Emmanuel Grumbach3eae4bb2011-10-10 07:26:55 -0700246 for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700247 station = &priv->stations[i];
Johannes Bergda735112010-05-03 01:25:24 -0700248 if (!station->used)
249 continue;
250 pos += scnprintf(buf + pos, bufsz - pos,
251 "station %d - addr: %pM, flags: %#x\n",
252 i, station->sta.sta.addr,
253 station->sta.station_flags_msk);
254 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Berg9eae88f2012-03-15 13:26:52 -0700255 "TID seqno next_rclmd "
256 "rate_n_flags state txq\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700257
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700258 for (j = 0; j < IWL_MAX_TID_COUNT; j++) {
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200259 tid_data = &priv->tid_data[i][j];
Johannes Bergda735112010-05-03 01:25:24 -0700260 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Berg9eae88f2012-03-15 13:26:52 -0700261 "%d: 0x%.4x 0x%.4x 0x%.8x "
262 "%d %.2d",
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700263 j, tid_data->seq_number,
Johannes Berg9eae88f2012-03-15 13:26:52 -0700264 tid_data->next_reclaimed,
265 tid_data->agg.rate_n_flags,
266 tid_data->agg.state,
267 tid_data->agg.txq_id);
Johannes Bergda735112010-05-03 01:25:24 -0700268
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700269 if (tid_data->agg.wait_for_ba)
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700270 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Bergda735112010-05-03 01:25:24 -0700271 " - waitforba");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700272 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700273 }
Johannes Bergda735112010-05-03 01:25:24 -0700274
275 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700276 }
277
278 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
279 kfree(buf);
280 return ret;
281}
282
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700283static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800284 char __user *user_buf,
285 size_t count,
286 loff_t *ppos)
287{
288 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700289 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800290 int pos = 0, ofs = 0, buf_size = 0;
291 const u8 *ptr;
292 char *buf;
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200293 u16 nvm_ver;
Johannes Berg26a7ca92012-05-21 11:55:54 +0200294 size_t eeprom_len = priv->eeprom_blob_size;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800295 buf_size = 4 * eeprom_len + 256;
296
Johannes Bergf9e75442012-03-30 09:37:39 +0200297 if (eeprom_len % 16)
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800298 return -ENODATA;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800299
Johannes Berg26a7ca92012-05-21 11:55:54 +0200300 ptr = priv->eeprom_blob;
Johannes Bergf9e75442012-03-30 09:37:39 +0200301 if (!ptr)
Julia Lawallc37457e2009-08-03 11:11:45 +0200302 return -ENOMEM;
Julia Lawallc37457e2009-08-03 11:11:45 +0200303
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800304 /* 4 characters for byte 0xYY */
305 buf = kzalloc(buf_size, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200306 if (!buf)
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800307 return -ENOMEM;
Johannes Bergf9e75442012-03-30 09:37:39 +0200308
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200309 nvm_ver = priv->nvm_data->nvm_version;
Johannes Berg26a7ca92012-05-21 11:55:54 +0200310 pos += scnprintf(buf + pos, buf_size - pos,
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200311 "NVM version: 0x%x\n", nvm_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800312 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
Andy Shevchenko3cd6e2f2015-07-16 15:42:14 +0300313 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x %16ph\n",
314 ofs, ptr + ofs);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800315 }
316
317 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
318 kfree(buf);
319 return ret;
320}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700321
Winkler, Tomasd366df52008-12-02 12:14:01 -0800322static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
323 size_t count, loff_t *ppos)
324{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700325 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800326 struct ieee80211_channel *channels = NULL;
327 const struct ieee80211_supported_band *supp_band = NULL;
328 int pos = 0, i, bufsz = PAGE_SIZE;
329 char *buf;
330 ssize_t ret;
331
Winkler, Tomasd366df52008-12-02 12:14:01 -0800332 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200333 if (!buf)
Winkler, Tomasd366df52008-12-02 12:14:01 -0800334 return -ENOMEM;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800335
336 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700337 if (supp_band) {
338 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800339
Winkler, Tomasd366df52008-12-02 12:14:01 -0800340 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700341 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
342 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800343
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700344 for (i = 0; i < supp_band->n_channels; i++)
345 pos += scnprintf(buf + pos, bufsz - pos,
346 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700347 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700348 channels[i].max_power,
349 channels[i].flags & IEEE80211_CHAN_RADAR ?
350 " (IEEE 802.11h required)" : "",
Luis R. Rodriguez8fe02e12013-10-21 19:22:25 +0200351 ((channels[i].flags & IEEE80211_CHAN_NO_IR)
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700352 || (channels[i].flags &
353 IEEE80211_CHAN_RADAR)) ? "" :
354 ", IBSS",
355 channels[i].flags &
Luis R. Rodriguez8fe02e12013-10-21 19:22:25 +0200356 IEEE80211_CHAN_NO_IR ?
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700357 "passive only" : "active/passive");
358 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800359 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700360 if (supp_band) {
361 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800362
Winkler, Tomasd366df52008-12-02 12:14:01 -0800363 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700364 "Displaying %d channels in 5.2GHz band (802.11a)\n",
365 supp_band->n_channels);
366
367 for (i = 0; i < supp_band->n_channels; i++)
368 pos += scnprintf(buf + pos, bufsz - pos,
369 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700370 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700371 channels[i].max_power,
372 channels[i].flags & IEEE80211_CHAN_RADAR ?
373 " (IEEE 802.11h required)" : "",
Luis R. Rodriguez8fe02e12013-10-21 19:22:25 +0200374 ((channels[i].flags & IEEE80211_CHAN_NO_IR)
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700375 || (channels[i].flags &
376 IEEE80211_CHAN_RADAR)) ? "" :
377 ", IBSS",
378 channels[i].flags &
Luis R. Rodriguez8fe02e12013-10-21 19:22:25 +0200379 IEEE80211_CHAN_NO_IR ?
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700380 "passive only" : "active/passive");
381 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800382 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
383 kfree(buf);
384 return ret;
385}
386
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700387static ssize_t iwl_dbgfs_status_read(struct file *file,
388 char __user *user_buf,
389 size_t count, loff_t *ppos) {
390
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700391 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700392 char buf[512];
393 int pos = 0;
394 const size_t bufsz = sizeof(buf);
395
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700396 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800397 test_bit(STATUS_RF_KILL_HW, &priv->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700398 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
Don Fry9a716862012-03-07 09:52:32 -0800399 test_bit(STATUS_CT_KILL, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700400 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800401 test_bit(STATUS_ALIVE, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700402 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800403 test_bit(STATUS_READY, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700404 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800405 test_bit(STATUS_EXIT_PENDING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700406 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800407 test_bit(STATUS_STATISTICS, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700408 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800409 test_bit(STATUS_SCANNING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700410 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800411 test_bit(STATUS_SCAN_ABORTING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700412 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
Don Fry83626402012-03-07 09:52:37 -0800413 test_bit(STATUS_SCAN_HW, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700414 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
Don Fry47107e82012-03-15 13:27:06 -0700415 test_bit(STATUS_POWER_PMI, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700416 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
Don Fry17acd0b2012-03-15 13:27:05 -0700417 test_bit(STATUS_FW_ERROR, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700418 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
419}
420
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700421static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700422 char __user *user_buf,
423 size_t count, loff_t *ppos) {
424
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700425 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700426
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700427 int pos = 0;
428 int cnt = 0;
429 char *buf;
430 int bufsz = 24 * 64; /* 24 items * 64 char per item */
431 ssize_t ret;
432
433 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200434 if (!buf)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700435 return -ENOMEM;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700436
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700437 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700438 if (priv->rx_handlers_stats[cnt] > 0)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700439 pos += scnprintf(buf + pos, bufsz - pos,
440 "\tRx handler[%36s]:\t\t %u\n",
Johannes Bergd9fb6462012-03-26 08:23:39 -0700441 iwl_dvm_get_cmd_string(cnt),
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700442 priv->rx_handlers_stats[cnt]);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700443 }
444
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700445 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
446 kfree(buf);
447 return ret;
448}
449
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700450static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700451 const char __user *user_buf,
452 size_t count, loff_t *ppos)
453{
454 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700455
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700456 char buf[8];
457 int buf_size;
458 u32 reset_flag;
459
460 memset(buf, 0, sizeof(buf));
461 buf_size = min(count, sizeof(buf) - 1);
462 if (copy_from_user(buf, user_buf, buf_size))
463 return -EFAULT;
464 if (sscanf(buf, "%x", &reset_flag) != 1)
465 return -EFAULT;
466 if (reset_flag == 0)
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700467 memset(&priv->rx_handlers_stats[0], 0,
468 sizeof(priv->rx_handlers_stats));
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700469
470 return count;
471}
472
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700473static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
474 size_t count, loff_t *ppos)
475{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700476 struct iwl_priv *priv = file->private_data;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200477 struct iwl_rxon_context *ctx;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700478 int pos = 0, i;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200479 char buf[256 * NUM_IWL_RXON_CTX];
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700480 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700481
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200482 for_each_context(priv, ctx) {
483 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
484 ctx->ctxid);
485 for (i = 0; i < AC_NUM; i++) {
486 pos += scnprintf(buf + pos, bufsz - pos,
487 "\tcw_min\tcw_max\taifsn\ttxop\n");
488 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700489 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200490 ctx->qos_data.def_qos_parm.ac[i].cw_min,
491 ctx->qos_data.def_qos_parm.ac[i].cw_max,
492 ctx->qos_data.def_qos_parm.ac[i].aifsn,
493 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
494 }
495 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700496 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800497 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700498}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700499
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700500static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
501 char __user *user_buf,
502 size_t count, loff_t *ppos)
503{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700504 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700505 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700506 struct iwl_tt_restriction *restriction;
507 char buf[100];
508 int pos = 0;
509 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700510
511 pos += scnprintf(buf + pos, bufsz - pos,
512 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700513 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700514 pos += scnprintf(buf + pos, bufsz - pos,
515 "Thermal Throttling State: %d\n",
516 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700517 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700518 restriction = tt->restriction + tt->state;
519 pos += scnprintf(buf + pos, bufsz - pos,
520 "Tx mode: %d\n",
521 restriction->tx_stream);
522 pos += scnprintf(buf + pos, bufsz - pos,
523 "Rx mode: %d\n",
524 restriction->rx_stream);
525 pos += scnprintf(buf + pos, bufsz - pos,
526 "HT mode: %d\n",
527 restriction->is_ht);
528 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800529 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700530}
531
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700532static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
533 const char __user *user_buf,
534 size_t count, loff_t *ppos)
535{
536 struct iwl_priv *priv = file->private_data;
537 char buf[8];
538 int buf_size;
539 int ht40;
540
541 memset(buf, 0, sizeof(buf));
542 buf_size = min(count, sizeof(buf) - 1);
543 if (copy_from_user(buf, user_buf, buf_size))
544 return -EFAULT;
545 if (sscanf(buf, "%d", &ht40) != 1)
546 return -EFAULT;
Johannes Berg246ed352010-08-23 10:46:32 +0200547 if (!iwl_is_any_associated(priv))
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700548 priv->disable_ht40 = ht40 ? true : false;
Johannes Bergf9e75442012-03-30 09:37:39 +0200549 else
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700550 return -EINVAL;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700551
552 return count;
553}
554
555static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
556 char __user *user_buf,
557 size_t count, loff_t *ppos)
558{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700559 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700560 char buf[100];
561 int pos = 0;
562 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700563
564 pos += scnprintf(buf + pos, bufsz - pos,
565 "11n 40MHz Mode: %s\n",
566 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800567 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700568}
569
Emmanuel Grumbach511afa32011-09-22 07:15:37 -0700570static ssize_t iwl_dbgfs_temperature_read(struct file *file,
571 char __user *user_buf,
572 size_t count, loff_t *ppos)
573{
574 struct iwl_priv *priv = file->private_data;
575 char buf[8];
576 int pos = 0;
577 const size_t bufsz = sizeof(buf);
578
579 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature);
580 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
581}
582
583
Johannes Berge312c242009-08-07 15:41:51 -0700584static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
585 const char __user *user_buf,
586 size_t count, loff_t *ppos)
587{
588 struct iwl_priv *priv = file->private_data;
589 char buf[8];
590 int buf_size;
591 int value;
592
593 memset(buf, 0, sizeof(buf));
594 buf_size = min(count, sizeof(buf) - 1);
595 if (copy_from_user(buf, user_buf, buf_size))
596 return -EFAULT;
597
598 if (sscanf(buf, "%d", &value) != 1)
599 return -EINVAL;
600
601 /*
602 * Our users expect 0 to be "CAM", but 0 isn't actually
603 * valid here. However, let's not confuse them and present
604 * IWL_POWER_INDEX_1 as "1", not "0".
605 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700606 if (value == 0)
607 return -EINVAL;
608 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700609 value -= 1;
610
611 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
612 return -EINVAL;
613
Don Fry83626402012-03-07 09:52:37 -0800614 if (!iwl_is_ready_rf(priv))
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700615 return -EAGAIN;
616
Johannes Berge312c242009-08-07 15:41:51 -0700617 priv->power_data.debug_sleep_level_override = value;
618
Johannes Bergb1eea292012-03-06 13:30:42 -0800619 mutex_lock(&priv->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700620 iwl_power_update_mode(priv, true);
Johannes Bergb1eea292012-03-06 13:30:42 -0800621 mutex_unlock(&priv->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700622
623 return count;
624}
625
626static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
627 char __user *user_buf,
628 size_t count, loff_t *ppos)
629{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700630 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700631 char buf[10];
632 int pos, value;
633 const size_t bufsz = sizeof(buf);
634
635 /* see the write function */
636 value = priv->power_data.debug_sleep_level_override;
637 if (value >= 0)
638 value += 1;
639
640 pos = scnprintf(buf, bufsz, "%d\n", value);
641 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
642}
643
644static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
645 char __user *user_buf,
646 size_t count, loff_t *ppos)
647{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700648 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700649 char buf[200];
650 int pos = 0, i;
651 const size_t bufsz = sizeof(buf);
652 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
653
654 pos += scnprintf(buf + pos, bufsz - pos,
655 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
656 pos += scnprintf(buf + pos, bufsz - pos,
657 "RX/TX timeout: %d/%d usec\n",
658 le32_to_cpu(cmd->rx_data_timeout),
659 le32_to_cpu(cmd->tx_data_timeout));
660 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
661 pos += scnprintf(buf + pos, bufsz - pos,
662 "sleep_interval[%d]: %d\n", i,
663 le32_to_cpu(cmd->sleep_interval[i]));
664
665 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
666}
667
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700668DEBUGFS_READ_WRITE_FILE_OPS(sram);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700669DEBUGFS_READ_FILE_OPS(wowlan_sram);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700670DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700671DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800672DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700673DEBUGFS_READ_FILE_OPS(status);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700674DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700675DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700676DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700677DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Emmanuel Grumbach511afa32011-09-22 07:15:37 -0700678DEBUGFS_READ_FILE_OPS(temperature);
Johannes Berge312c242009-08-07 15:41:51 -0700679DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
680DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700681
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700682static const char *fmt_value = " %-30s %10u\n";
683static const char *fmt_hex = " %-30s 0x%02X\n";
684static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
685static const char *fmt_header =
686 "%-32s current cumulative delta max\n";
687
688static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
689{
690 int p = 0;
691 u32 flag;
692
Johannes Berg4ff70fcd2012-03-05 11:24:26 -0800693 lockdep_assert_held(&priv->statistics.lock);
694
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700695 flag = le32_to_cpu(priv->statistics.flag);
696
697 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
698 if (flag & UCODE_STATISTICS_CLEAR_MSK)
699 p += scnprintf(buf + p, bufsz - p,
700 "\tStatistics have been cleared\n");
701 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
702 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
703 ? "2.4 GHz" : "5.2 GHz");
704 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
705 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
706 ? "enabled" : "disabled");
707
708 return p;
709}
710
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -0700711static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
712 char __user *user_buf,
713 size_t count, loff_t *ppos)
714{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700715 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700716 int pos = 0;
717 char *buf;
718 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
719 sizeof(struct statistics_rx_non_phy) * 40 +
720 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
721 ssize_t ret;
722 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
723 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
724 struct statistics_rx_non_phy *general, *accum_general;
725 struct statistics_rx_non_phy *delta_general, *max_general;
726 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
727
Don Fry83626402012-03-07 09:52:37 -0800728 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700729 return -EAGAIN;
730
731 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +0200732 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700733 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700734
735 /*
736 * the statistic information display here is based on
737 * the last statistics notification from uCode
738 * might not reflect the current uCode activity
739 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -0800740 spin_lock_bh(&priv->statistics.lock);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700741 ofdm = &priv->statistics.rx_ofdm;
742 cck = &priv->statistics.rx_cck;
743 general = &priv->statistics.rx_non_phy;
744 ht = &priv->statistics.rx_ofdm_ht;
745 accum_ofdm = &priv->accum_stats.rx_ofdm;
746 accum_cck = &priv->accum_stats.rx_cck;
747 accum_general = &priv->accum_stats.rx_non_phy;
748 accum_ht = &priv->accum_stats.rx_ofdm_ht;
749 delta_ofdm = &priv->delta_stats.rx_ofdm;
750 delta_cck = &priv->delta_stats.rx_cck;
751 delta_general = &priv->delta_stats.rx_non_phy;
752 delta_ht = &priv->delta_stats.rx_ofdm_ht;
753 max_ofdm = &priv->max_delta_stats.rx_ofdm;
754 max_cck = &priv->max_delta_stats.rx_cck;
755 max_general = &priv->max_delta_stats.rx_non_phy;
756 max_ht = &priv->max_delta_stats.rx_ofdm_ht;
757
758 pos += iwl_statistics_flag(priv, buf, bufsz);
759 pos += scnprintf(buf + pos, bufsz - pos,
760 fmt_header, "Statistics_Rx - OFDM:");
761 pos += scnprintf(buf + pos, bufsz - pos,
762 fmt_table, "ina_cnt:",
763 le32_to_cpu(ofdm->ina_cnt),
764 accum_ofdm->ina_cnt,
765 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
766 pos += scnprintf(buf + pos, bufsz - pos,
767 fmt_table, "fina_cnt:",
768 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
769 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
770 pos += scnprintf(buf + pos, bufsz - pos,
771 fmt_table, "plcp_err:",
772 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
773 delta_ofdm->plcp_err, max_ofdm->plcp_err);
774 pos += scnprintf(buf + pos, bufsz - pos,
775 fmt_table, "crc32_err:",
776 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
777 delta_ofdm->crc32_err, max_ofdm->crc32_err);
778 pos += scnprintf(buf + pos, bufsz - pos,
779 fmt_table, "overrun_err:",
780 le32_to_cpu(ofdm->overrun_err),
781 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
782 max_ofdm->overrun_err);
783 pos += scnprintf(buf + pos, bufsz - pos,
784 fmt_table, "early_overrun_err:",
785 le32_to_cpu(ofdm->early_overrun_err),
786 accum_ofdm->early_overrun_err,
787 delta_ofdm->early_overrun_err,
788 max_ofdm->early_overrun_err);
789 pos += scnprintf(buf + pos, bufsz - pos,
790 fmt_table, "crc32_good:",
791 le32_to_cpu(ofdm->crc32_good),
792 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
793 max_ofdm->crc32_good);
794 pos += scnprintf(buf + pos, bufsz - pos,
795 fmt_table, "false_alarm_cnt:",
796 le32_to_cpu(ofdm->false_alarm_cnt),
797 accum_ofdm->false_alarm_cnt,
798 delta_ofdm->false_alarm_cnt,
799 max_ofdm->false_alarm_cnt);
800 pos += scnprintf(buf + pos, bufsz - pos,
801 fmt_table, "fina_sync_err_cnt:",
802 le32_to_cpu(ofdm->fina_sync_err_cnt),
803 accum_ofdm->fina_sync_err_cnt,
804 delta_ofdm->fina_sync_err_cnt,
805 max_ofdm->fina_sync_err_cnt);
806 pos += scnprintf(buf + pos, bufsz - pos,
807 fmt_table, "sfd_timeout:",
808 le32_to_cpu(ofdm->sfd_timeout),
809 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
810 max_ofdm->sfd_timeout);
811 pos += scnprintf(buf + pos, bufsz - pos,
812 fmt_table, "fina_timeout:",
813 le32_to_cpu(ofdm->fina_timeout),
814 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
815 max_ofdm->fina_timeout);
816 pos += scnprintf(buf + pos, bufsz - pos,
817 fmt_table, "unresponded_rts:",
818 le32_to_cpu(ofdm->unresponded_rts),
819 accum_ofdm->unresponded_rts,
820 delta_ofdm->unresponded_rts,
821 max_ofdm->unresponded_rts);
822 pos += scnprintf(buf + pos, bufsz - pos,
823 fmt_table, "rxe_frame_lmt_ovrun:",
824 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
825 accum_ofdm->rxe_frame_limit_overrun,
826 delta_ofdm->rxe_frame_limit_overrun,
827 max_ofdm->rxe_frame_limit_overrun);
828 pos += scnprintf(buf + pos, bufsz - pos,
829 fmt_table, "sent_ack_cnt:",
830 le32_to_cpu(ofdm->sent_ack_cnt),
831 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
832 max_ofdm->sent_ack_cnt);
833 pos += scnprintf(buf + pos, bufsz - pos,
834 fmt_table, "sent_cts_cnt:",
835 le32_to_cpu(ofdm->sent_cts_cnt),
836 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
837 max_ofdm->sent_cts_cnt);
838 pos += scnprintf(buf + pos, bufsz - pos,
839 fmt_table, "sent_ba_rsp_cnt:",
840 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
841 accum_ofdm->sent_ba_rsp_cnt,
842 delta_ofdm->sent_ba_rsp_cnt,
843 max_ofdm->sent_ba_rsp_cnt);
844 pos += scnprintf(buf + pos, bufsz - pos,
845 fmt_table, "dsp_self_kill:",
846 le32_to_cpu(ofdm->dsp_self_kill),
847 accum_ofdm->dsp_self_kill,
848 delta_ofdm->dsp_self_kill,
849 max_ofdm->dsp_self_kill);
850 pos += scnprintf(buf + pos, bufsz - pos,
851 fmt_table, "mh_format_err:",
852 le32_to_cpu(ofdm->mh_format_err),
853 accum_ofdm->mh_format_err,
854 delta_ofdm->mh_format_err,
855 max_ofdm->mh_format_err);
856 pos += scnprintf(buf + pos, bufsz - pos,
857 fmt_table, "re_acq_main_rssi_sum:",
858 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
859 accum_ofdm->re_acq_main_rssi_sum,
860 delta_ofdm->re_acq_main_rssi_sum,
861 max_ofdm->re_acq_main_rssi_sum);
862
863 pos += scnprintf(buf + pos, bufsz - pos,
864 fmt_header, "Statistics_Rx - CCK:");
865 pos += scnprintf(buf + pos, bufsz - pos,
866 fmt_table, "ina_cnt:",
867 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
868 delta_cck->ina_cnt, max_cck->ina_cnt);
869 pos += scnprintf(buf + pos, bufsz - pos,
870 fmt_table, "fina_cnt:",
871 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
872 delta_cck->fina_cnt, max_cck->fina_cnt);
873 pos += scnprintf(buf + pos, bufsz - pos,
874 fmt_table, "plcp_err:",
875 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
876 delta_cck->plcp_err, max_cck->plcp_err);
877 pos += scnprintf(buf + pos, bufsz - pos,
878 fmt_table, "crc32_err:",
879 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
880 delta_cck->crc32_err, max_cck->crc32_err);
881 pos += scnprintf(buf + pos, bufsz - pos,
882 fmt_table, "overrun_err:",
883 le32_to_cpu(cck->overrun_err),
884 accum_cck->overrun_err, delta_cck->overrun_err,
885 max_cck->overrun_err);
886 pos += scnprintf(buf + pos, bufsz - pos,
887 fmt_table, "early_overrun_err:",
888 le32_to_cpu(cck->early_overrun_err),
889 accum_cck->early_overrun_err,
890 delta_cck->early_overrun_err,
891 max_cck->early_overrun_err);
892 pos += scnprintf(buf + pos, bufsz - pos,
893 fmt_table, "crc32_good:",
894 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
895 delta_cck->crc32_good, max_cck->crc32_good);
896 pos += scnprintf(buf + pos, bufsz - pos,
897 fmt_table, "false_alarm_cnt:",
898 le32_to_cpu(cck->false_alarm_cnt),
899 accum_cck->false_alarm_cnt,
900 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
901 pos += scnprintf(buf + pos, bufsz - pos,
902 fmt_table, "fina_sync_err_cnt:",
903 le32_to_cpu(cck->fina_sync_err_cnt),
904 accum_cck->fina_sync_err_cnt,
905 delta_cck->fina_sync_err_cnt,
906 max_cck->fina_sync_err_cnt);
907 pos += scnprintf(buf + pos, bufsz - pos,
908 fmt_table, "sfd_timeout:",
909 le32_to_cpu(cck->sfd_timeout),
910 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
911 max_cck->sfd_timeout);
912 pos += scnprintf(buf + pos, bufsz - pos,
913 fmt_table, "fina_timeout:",
914 le32_to_cpu(cck->fina_timeout),
915 accum_cck->fina_timeout, delta_cck->fina_timeout,
916 max_cck->fina_timeout);
917 pos += scnprintf(buf + pos, bufsz - pos,
918 fmt_table, "unresponded_rts:",
919 le32_to_cpu(cck->unresponded_rts),
920 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
921 max_cck->unresponded_rts);
922 pos += scnprintf(buf + pos, bufsz - pos,
923 fmt_table, "rxe_frame_lmt_ovrun:",
924 le32_to_cpu(cck->rxe_frame_limit_overrun),
925 accum_cck->rxe_frame_limit_overrun,
926 delta_cck->rxe_frame_limit_overrun,
927 max_cck->rxe_frame_limit_overrun);
928 pos += scnprintf(buf + pos, bufsz - pos,
929 fmt_table, "sent_ack_cnt:",
930 le32_to_cpu(cck->sent_ack_cnt),
931 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
932 max_cck->sent_ack_cnt);
933 pos += scnprintf(buf + pos, bufsz - pos,
934 fmt_table, "sent_cts_cnt:",
935 le32_to_cpu(cck->sent_cts_cnt),
936 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
937 max_cck->sent_cts_cnt);
938 pos += scnprintf(buf + pos, bufsz - pos,
939 fmt_table, "sent_ba_rsp_cnt:",
940 le32_to_cpu(cck->sent_ba_rsp_cnt),
941 accum_cck->sent_ba_rsp_cnt,
942 delta_cck->sent_ba_rsp_cnt,
943 max_cck->sent_ba_rsp_cnt);
944 pos += scnprintf(buf + pos, bufsz - pos,
945 fmt_table, "dsp_self_kill:",
946 le32_to_cpu(cck->dsp_self_kill),
947 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
948 max_cck->dsp_self_kill);
949 pos += scnprintf(buf + pos, bufsz - pos,
950 fmt_table, "mh_format_err:",
951 le32_to_cpu(cck->mh_format_err),
952 accum_cck->mh_format_err, delta_cck->mh_format_err,
953 max_cck->mh_format_err);
954 pos += scnprintf(buf + pos, bufsz - pos,
955 fmt_table, "re_acq_main_rssi_sum:",
956 le32_to_cpu(cck->re_acq_main_rssi_sum),
957 accum_cck->re_acq_main_rssi_sum,
958 delta_cck->re_acq_main_rssi_sum,
959 max_cck->re_acq_main_rssi_sum);
960
961 pos += scnprintf(buf + pos, bufsz - pos,
962 fmt_header, "Statistics_Rx - GENERAL:");
963 pos += scnprintf(buf + pos, bufsz - pos,
964 fmt_table, "bogus_cts:",
965 le32_to_cpu(general->bogus_cts),
966 accum_general->bogus_cts, delta_general->bogus_cts,
967 max_general->bogus_cts);
968 pos += scnprintf(buf + pos, bufsz - pos,
969 fmt_table, "bogus_ack:",
970 le32_to_cpu(general->bogus_ack),
971 accum_general->bogus_ack, delta_general->bogus_ack,
972 max_general->bogus_ack);
973 pos += scnprintf(buf + pos, bufsz - pos,
974 fmt_table, "non_bssid_frames:",
975 le32_to_cpu(general->non_bssid_frames),
976 accum_general->non_bssid_frames,
977 delta_general->non_bssid_frames,
978 max_general->non_bssid_frames);
979 pos += scnprintf(buf + pos, bufsz - pos,
980 fmt_table, "filtered_frames:",
981 le32_to_cpu(general->filtered_frames),
982 accum_general->filtered_frames,
983 delta_general->filtered_frames,
984 max_general->filtered_frames);
985 pos += scnprintf(buf + pos, bufsz - pos,
986 fmt_table, "non_channel_beacons:",
987 le32_to_cpu(general->non_channel_beacons),
988 accum_general->non_channel_beacons,
989 delta_general->non_channel_beacons,
990 max_general->non_channel_beacons);
991 pos += scnprintf(buf + pos, bufsz - pos,
992 fmt_table, "channel_beacons:",
993 le32_to_cpu(general->channel_beacons),
994 accum_general->channel_beacons,
995 delta_general->channel_beacons,
996 max_general->channel_beacons);
997 pos += scnprintf(buf + pos, bufsz - pos,
998 fmt_table, "num_missed_bcon:",
999 le32_to_cpu(general->num_missed_bcon),
1000 accum_general->num_missed_bcon,
1001 delta_general->num_missed_bcon,
1002 max_general->num_missed_bcon);
1003 pos += scnprintf(buf + pos, bufsz - pos,
1004 fmt_table, "adc_rx_saturation_time:",
1005 le32_to_cpu(general->adc_rx_saturation_time),
1006 accum_general->adc_rx_saturation_time,
1007 delta_general->adc_rx_saturation_time,
1008 max_general->adc_rx_saturation_time);
1009 pos += scnprintf(buf + pos, bufsz - pos,
1010 fmt_table, "ina_detect_search_tm:",
1011 le32_to_cpu(general->ina_detection_search_time),
1012 accum_general->ina_detection_search_time,
1013 delta_general->ina_detection_search_time,
1014 max_general->ina_detection_search_time);
1015 pos += scnprintf(buf + pos, bufsz - pos,
1016 fmt_table, "beacon_silence_rssi_a:",
1017 le32_to_cpu(general->beacon_silence_rssi_a),
1018 accum_general->beacon_silence_rssi_a,
1019 delta_general->beacon_silence_rssi_a,
1020 max_general->beacon_silence_rssi_a);
1021 pos += scnprintf(buf + pos, bufsz - pos,
1022 fmt_table, "beacon_silence_rssi_b:",
1023 le32_to_cpu(general->beacon_silence_rssi_b),
1024 accum_general->beacon_silence_rssi_b,
1025 delta_general->beacon_silence_rssi_b,
1026 max_general->beacon_silence_rssi_b);
1027 pos += scnprintf(buf + pos, bufsz - pos,
1028 fmt_table, "beacon_silence_rssi_c:",
1029 le32_to_cpu(general->beacon_silence_rssi_c),
1030 accum_general->beacon_silence_rssi_c,
1031 delta_general->beacon_silence_rssi_c,
1032 max_general->beacon_silence_rssi_c);
1033 pos += scnprintf(buf + pos, bufsz - pos,
1034 fmt_table, "interference_data_flag:",
1035 le32_to_cpu(general->interference_data_flag),
1036 accum_general->interference_data_flag,
1037 delta_general->interference_data_flag,
1038 max_general->interference_data_flag);
1039 pos += scnprintf(buf + pos, bufsz - pos,
1040 fmt_table, "channel_load:",
1041 le32_to_cpu(general->channel_load),
1042 accum_general->channel_load,
1043 delta_general->channel_load,
1044 max_general->channel_load);
1045 pos += scnprintf(buf + pos, bufsz - pos,
1046 fmt_table, "dsp_false_alarms:",
1047 le32_to_cpu(general->dsp_false_alarms),
1048 accum_general->dsp_false_alarms,
1049 delta_general->dsp_false_alarms,
1050 max_general->dsp_false_alarms);
1051 pos += scnprintf(buf + pos, bufsz - pos,
1052 fmt_table, "beacon_rssi_a:",
1053 le32_to_cpu(general->beacon_rssi_a),
1054 accum_general->beacon_rssi_a,
1055 delta_general->beacon_rssi_a,
1056 max_general->beacon_rssi_a);
1057 pos += scnprintf(buf + pos, bufsz - pos,
1058 fmt_table, "beacon_rssi_b:",
1059 le32_to_cpu(general->beacon_rssi_b),
1060 accum_general->beacon_rssi_b,
1061 delta_general->beacon_rssi_b,
1062 max_general->beacon_rssi_b);
1063 pos += scnprintf(buf + pos, bufsz - pos,
1064 fmt_table, "beacon_rssi_c:",
1065 le32_to_cpu(general->beacon_rssi_c),
1066 accum_general->beacon_rssi_c,
1067 delta_general->beacon_rssi_c,
1068 max_general->beacon_rssi_c);
1069 pos += scnprintf(buf + pos, bufsz - pos,
1070 fmt_table, "beacon_energy_a:",
1071 le32_to_cpu(general->beacon_energy_a),
1072 accum_general->beacon_energy_a,
1073 delta_general->beacon_energy_a,
1074 max_general->beacon_energy_a);
1075 pos += scnprintf(buf + pos, bufsz - pos,
1076 fmt_table, "beacon_energy_b:",
1077 le32_to_cpu(general->beacon_energy_b),
1078 accum_general->beacon_energy_b,
1079 delta_general->beacon_energy_b,
1080 max_general->beacon_energy_b);
1081 pos += scnprintf(buf + pos, bufsz - pos,
1082 fmt_table, "beacon_energy_c:",
1083 le32_to_cpu(general->beacon_energy_c),
1084 accum_general->beacon_energy_c,
1085 delta_general->beacon_energy_c,
1086 max_general->beacon_energy_c);
1087
1088 pos += scnprintf(buf + pos, bufsz - pos,
1089 fmt_header, "Statistics_Rx - OFDM_HT:");
1090 pos += scnprintf(buf + pos, bufsz - pos,
1091 fmt_table, "plcp_err:",
1092 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1093 delta_ht->plcp_err, max_ht->plcp_err);
1094 pos += scnprintf(buf + pos, bufsz - pos,
1095 fmt_table, "overrun_err:",
1096 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1097 delta_ht->overrun_err, max_ht->overrun_err);
1098 pos += scnprintf(buf + pos, bufsz - pos,
1099 fmt_table, "early_overrun_err:",
1100 le32_to_cpu(ht->early_overrun_err),
1101 accum_ht->early_overrun_err,
1102 delta_ht->early_overrun_err,
1103 max_ht->early_overrun_err);
1104 pos += scnprintf(buf + pos, bufsz - pos,
1105 fmt_table, "crc32_good:",
1106 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1107 delta_ht->crc32_good, max_ht->crc32_good);
1108 pos += scnprintf(buf + pos, bufsz - pos,
1109 fmt_table, "crc32_err:",
1110 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1111 delta_ht->crc32_err, max_ht->crc32_err);
1112 pos += scnprintf(buf + pos, bufsz - pos,
1113 fmt_table, "mh_format_err:",
1114 le32_to_cpu(ht->mh_format_err),
1115 accum_ht->mh_format_err,
1116 delta_ht->mh_format_err, max_ht->mh_format_err);
1117 pos += scnprintf(buf + pos, bufsz - pos,
1118 fmt_table, "agg_crc32_good:",
1119 le32_to_cpu(ht->agg_crc32_good),
1120 accum_ht->agg_crc32_good,
1121 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1122 pos += scnprintf(buf + pos, bufsz - pos,
1123 fmt_table, "agg_mpdu_cnt:",
1124 le32_to_cpu(ht->agg_mpdu_cnt),
1125 accum_ht->agg_mpdu_cnt,
1126 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1127 pos += scnprintf(buf + pos, bufsz - pos,
1128 fmt_table, "agg_cnt:",
1129 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1130 delta_ht->agg_cnt, max_ht->agg_cnt);
1131 pos += scnprintf(buf + pos, bufsz - pos,
1132 fmt_table, "unsupport_mcs:",
1133 le32_to_cpu(ht->unsupport_mcs),
1134 accum_ht->unsupport_mcs,
1135 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1136
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001137 spin_unlock_bh(&priv->statistics.lock);
1138
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001139 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1140 kfree(buf);
1141 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001142}
1143
1144static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1145 char __user *user_buf,
1146 size_t count, loff_t *ppos)
1147{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001148 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001149 int pos = 0;
1150 char *buf;
1151 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1152 ssize_t ret;
1153 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1154
Don Fry83626402012-03-07 09:52:37 -08001155 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001156 return -EAGAIN;
1157
1158 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001159 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001160 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001161
1162 /* the statistic information display here is based on
1163 * the last statistics notification from uCode
1164 * might not reflect the current uCode activity
1165 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001166 spin_lock_bh(&priv->statistics.lock);
1167
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001168 tx = &priv->statistics.tx;
1169 accum_tx = &priv->accum_stats.tx;
1170 delta_tx = &priv->delta_stats.tx;
1171 max_tx = &priv->max_delta_stats.tx;
1172
1173 pos += iwl_statistics_flag(priv, buf, bufsz);
1174 pos += scnprintf(buf + pos, bufsz - pos,
1175 fmt_header, "Statistics_Tx:");
1176 pos += scnprintf(buf + pos, bufsz - pos,
1177 fmt_table, "preamble:",
1178 le32_to_cpu(tx->preamble_cnt),
1179 accum_tx->preamble_cnt,
1180 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1181 pos += scnprintf(buf + pos, bufsz - pos,
1182 fmt_table, "rx_detected_cnt:",
1183 le32_to_cpu(tx->rx_detected_cnt),
1184 accum_tx->rx_detected_cnt,
1185 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1186 pos += scnprintf(buf + pos, bufsz - pos,
1187 fmt_table, "bt_prio_defer_cnt:",
1188 le32_to_cpu(tx->bt_prio_defer_cnt),
1189 accum_tx->bt_prio_defer_cnt,
1190 delta_tx->bt_prio_defer_cnt,
1191 max_tx->bt_prio_defer_cnt);
1192 pos += scnprintf(buf + pos, bufsz - pos,
1193 fmt_table, "bt_prio_kill_cnt:",
1194 le32_to_cpu(tx->bt_prio_kill_cnt),
1195 accum_tx->bt_prio_kill_cnt,
1196 delta_tx->bt_prio_kill_cnt,
1197 max_tx->bt_prio_kill_cnt);
1198 pos += scnprintf(buf + pos, bufsz - pos,
1199 fmt_table, "few_bytes_cnt:",
1200 le32_to_cpu(tx->few_bytes_cnt),
1201 accum_tx->few_bytes_cnt,
1202 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1203 pos += scnprintf(buf + pos, bufsz - pos,
1204 fmt_table, "cts_timeout:",
1205 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1206 delta_tx->cts_timeout, max_tx->cts_timeout);
1207 pos += scnprintf(buf + pos, bufsz - pos,
1208 fmt_table, "ack_timeout:",
1209 le32_to_cpu(tx->ack_timeout),
1210 accum_tx->ack_timeout,
1211 delta_tx->ack_timeout, max_tx->ack_timeout);
1212 pos += scnprintf(buf + pos, bufsz - pos,
1213 fmt_table, "expected_ack_cnt:",
1214 le32_to_cpu(tx->expected_ack_cnt),
1215 accum_tx->expected_ack_cnt,
1216 delta_tx->expected_ack_cnt,
1217 max_tx->expected_ack_cnt);
1218 pos += scnprintf(buf + pos, bufsz - pos,
1219 fmt_table, "actual_ack_cnt:",
1220 le32_to_cpu(tx->actual_ack_cnt),
1221 accum_tx->actual_ack_cnt,
1222 delta_tx->actual_ack_cnt,
1223 max_tx->actual_ack_cnt);
1224 pos += scnprintf(buf + pos, bufsz - pos,
1225 fmt_table, "dump_msdu_cnt:",
1226 le32_to_cpu(tx->dump_msdu_cnt),
1227 accum_tx->dump_msdu_cnt,
1228 delta_tx->dump_msdu_cnt,
1229 max_tx->dump_msdu_cnt);
1230 pos += scnprintf(buf + pos, bufsz - pos,
1231 fmt_table, "abort_nxt_frame_mismatch:",
1232 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1233 accum_tx->burst_abort_next_frame_mismatch_cnt,
1234 delta_tx->burst_abort_next_frame_mismatch_cnt,
1235 max_tx->burst_abort_next_frame_mismatch_cnt);
1236 pos += scnprintf(buf + pos, bufsz - pos,
1237 fmt_table, "abort_missing_nxt_frame:",
1238 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1239 accum_tx->burst_abort_missing_next_frame_cnt,
1240 delta_tx->burst_abort_missing_next_frame_cnt,
1241 max_tx->burst_abort_missing_next_frame_cnt);
1242 pos += scnprintf(buf + pos, bufsz - pos,
1243 fmt_table, "cts_timeout_collision:",
1244 le32_to_cpu(tx->cts_timeout_collision),
1245 accum_tx->cts_timeout_collision,
1246 delta_tx->cts_timeout_collision,
1247 max_tx->cts_timeout_collision);
1248 pos += scnprintf(buf + pos, bufsz - pos,
1249 fmt_table, "ack_ba_timeout_collision:",
1250 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1251 accum_tx->ack_or_ba_timeout_collision,
1252 delta_tx->ack_or_ba_timeout_collision,
1253 max_tx->ack_or_ba_timeout_collision);
1254 pos += scnprintf(buf + pos, bufsz - pos,
1255 fmt_table, "agg ba_timeout:",
1256 le32_to_cpu(tx->agg.ba_timeout),
1257 accum_tx->agg.ba_timeout,
1258 delta_tx->agg.ba_timeout,
1259 max_tx->agg.ba_timeout);
1260 pos += scnprintf(buf + pos, bufsz - pos,
1261 fmt_table, "agg ba_resched_frames:",
1262 le32_to_cpu(tx->agg.ba_reschedule_frames),
1263 accum_tx->agg.ba_reschedule_frames,
1264 delta_tx->agg.ba_reschedule_frames,
1265 max_tx->agg.ba_reschedule_frames);
1266 pos += scnprintf(buf + pos, bufsz - pos,
1267 fmt_table, "agg scd_query_agg_frame:",
1268 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1269 accum_tx->agg.scd_query_agg_frame_cnt,
1270 delta_tx->agg.scd_query_agg_frame_cnt,
1271 max_tx->agg.scd_query_agg_frame_cnt);
1272 pos += scnprintf(buf + pos, bufsz - pos,
1273 fmt_table, "agg scd_query_no_agg:",
1274 le32_to_cpu(tx->agg.scd_query_no_agg),
1275 accum_tx->agg.scd_query_no_agg,
1276 delta_tx->agg.scd_query_no_agg,
1277 max_tx->agg.scd_query_no_agg);
1278 pos += scnprintf(buf + pos, bufsz - pos,
1279 fmt_table, "agg scd_query_agg:",
1280 le32_to_cpu(tx->agg.scd_query_agg),
1281 accum_tx->agg.scd_query_agg,
1282 delta_tx->agg.scd_query_agg,
1283 max_tx->agg.scd_query_agg);
1284 pos += scnprintf(buf + pos, bufsz - pos,
1285 fmt_table, "agg scd_query_mismatch:",
1286 le32_to_cpu(tx->agg.scd_query_mismatch),
1287 accum_tx->agg.scd_query_mismatch,
1288 delta_tx->agg.scd_query_mismatch,
1289 max_tx->agg.scd_query_mismatch);
1290 pos += scnprintf(buf + pos, bufsz - pos,
1291 fmt_table, "agg frame_not_ready:",
1292 le32_to_cpu(tx->agg.frame_not_ready),
1293 accum_tx->agg.frame_not_ready,
1294 delta_tx->agg.frame_not_ready,
1295 max_tx->agg.frame_not_ready);
1296 pos += scnprintf(buf + pos, bufsz - pos,
1297 fmt_table, "agg underrun:",
1298 le32_to_cpu(tx->agg.underrun),
1299 accum_tx->agg.underrun,
1300 delta_tx->agg.underrun, max_tx->agg.underrun);
1301 pos += scnprintf(buf + pos, bufsz - pos,
1302 fmt_table, "agg bt_prio_kill:",
1303 le32_to_cpu(tx->agg.bt_prio_kill),
1304 accum_tx->agg.bt_prio_kill,
1305 delta_tx->agg.bt_prio_kill,
1306 max_tx->agg.bt_prio_kill);
1307 pos += scnprintf(buf + pos, bufsz - pos,
1308 fmt_table, "agg rx_ba_rsp_cnt:",
1309 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1310 accum_tx->agg.rx_ba_rsp_cnt,
1311 delta_tx->agg.rx_ba_rsp_cnt,
1312 max_tx->agg.rx_ba_rsp_cnt);
1313
1314 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
1315 pos += scnprintf(buf + pos, bufsz - pos,
1316 "tx power: (1/2 dB step)\n");
Eytan Lifshitzb7998c82012-12-01 20:59:49 +02001317 if ((priv->nvm_data->valid_tx_ant & ANT_A) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001318 tx->tx_power.ant_a)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001319 pos += scnprintf(buf + pos, bufsz - pos,
1320 fmt_hex, "antenna A:",
1321 tx->tx_power.ant_a);
Eytan Lifshitzb7998c82012-12-01 20:59:49 +02001322 if ((priv->nvm_data->valid_tx_ant & ANT_B) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001323 tx->tx_power.ant_b)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001324 pos += scnprintf(buf + pos, bufsz - pos,
1325 fmt_hex, "antenna B:",
1326 tx->tx_power.ant_b);
Eytan Lifshitzb7998c82012-12-01 20:59:49 +02001327 if ((priv->nvm_data->valid_tx_ant & ANT_C) &&
Johannes Berg7e79a392012-03-05 11:24:32 -08001328 tx->tx_power.ant_c)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001329 pos += scnprintf(buf + pos, bufsz - pos,
1330 fmt_hex, "antenna C:",
1331 tx->tx_power.ant_c);
1332 }
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001333
1334 spin_unlock_bh(&priv->statistics.lock);
1335
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001336 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1337 kfree(buf);
1338 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001339}
1340
1341static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1342 char __user *user_buf,
1343 size_t count, loff_t *ppos)
1344{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001345 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001346 int pos = 0;
1347 char *buf;
1348 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1349 ssize_t ret;
1350 struct statistics_general_common *general, *accum_general;
1351 struct statistics_general_common *delta_general, *max_general;
1352 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1353 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1354
Don Fry83626402012-03-07 09:52:37 -08001355 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001356 return -EAGAIN;
1357
1358 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001359 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001360 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001361
1362 /* the statistic information display here is based on
1363 * the last statistics notification from uCode
1364 * might not reflect the current uCode activity
1365 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001366
1367 spin_lock_bh(&priv->statistics.lock);
1368
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001369 general = &priv->statistics.common;
1370 dbg = &priv->statistics.common.dbg;
1371 div = &priv->statistics.common.div;
1372 accum_general = &priv->accum_stats.common;
1373 accum_dbg = &priv->accum_stats.common.dbg;
1374 accum_div = &priv->accum_stats.common.div;
1375 delta_general = &priv->delta_stats.common;
1376 max_general = &priv->max_delta_stats.common;
1377 delta_dbg = &priv->delta_stats.common.dbg;
1378 max_dbg = &priv->max_delta_stats.common.dbg;
1379 delta_div = &priv->delta_stats.common.div;
1380 max_div = &priv->max_delta_stats.common.div;
1381
1382 pos += iwl_statistics_flag(priv, buf, bufsz);
1383 pos += scnprintf(buf + pos, bufsz - pos,
1384 fmt_header, "Statistics_General:");
1385 pos += scnprintf(buf + pos, bufsz - pos,
1386 fmt_value, "temperature:",
1387 le32_to_cpu(general->temperature));
1388 pos += scnprintf(buf + pos, bufsz - pos,
1389 fmt_value, "temperature_m:",
1390 le32_to_cpu(general->temperature_m));
1391 pos += scnprintf(buf + pos, bufsz - pos,
1392 fmt_value, "ttl_timestamp:",
1393 le32_to_cpu(general->ttl_timestamp));
1394 pos += scnprintf(buf + pos, bufsz - pos,
1395 fmt_table, "burst_check:",
1396 le32_to_cpu(dbg->burst_check),
1397 accum_dbg->burst_check,
1398 delta_dbg->burst_check, max_dbg->burst_check);
1399 pos += scnprintf(buf + pos, bufsz - pos,
1400 fmt_table, "burst_count:",
1401 le32_to_cpu(dbg->burst_count),
1402 accum_dbg->burst_count,
1403 delta_dbg->burst_count, max_dbg->burst_count);
1404 pos += scnprintf(buf + pos, bufsz - pos,
1405 fmt_table, "wait_for_silence_timeout_count:",
1406 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
1407 accum_dbg->wait_for_silence_timeout_cnt,
1408 delta_dbg->wait_for_silence_timeout_cnt,
1409 max_dbg->wait_for_silence_timeout_cnt);
1410 pos += scnprintf(buf + pos, bufsz - pos,
1411 fmt_table, "sleep_time:",
1412 le32_to_cpu(general->sleep_time),
1413 accum_general->sleep_time,
1414 delta_general->sleep_time, max_general->sleep_time);
1415 pos += scnprintf(buf + pos, bufsz - pos,
1416 fmt_table, "slots_out:",
1417 le32_to_cpu(general->slots_out),
1418 accum_general->slots_out,
1419 delta_general->slots_out, max_general->slots_out);
1420 pos += scnprintf(buf + pos, bufsz - pos,
1421 fmt_table, "slots_idle:",
1422 le32_to_cpu(general->slots_idle),
1423 accum_general->slots_idle,
1424 delta_general->slots_idle, max_general->slots_idle);
1425 pos += scnprintf(buf + pos, bufsz - pos,
1426 fmt_table, "tx_on_a:",
1427 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1428 delta_div->tx_on_a, max_div->tx_on_a);
1429 pos += scnprintf(buf + pos, bufsz - pos,
1430 fmt_table, "tx_on_b:",
1431 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1432 delta_div->tx_on_b, max_div->tx_on_b);
1433 pos += scnprintf(buf + pos, bufsz - pos,
1434 fmt_table, "exec_time:",
1435 le32_to_cpu(div->exec_time), accum_div->exec_time,
1436 delta_div->exec_time, max_div->exec_time);
1437 pos += scnprintf(buf + pos, bufsz - pos,
1438 fmt_table, "probe_time:",
1439 le32_to_cpu(div->probe_time), accum_div->probe_time,
1440 delta_div->probe_time, max_div->probe_time);
1441 pos += scnprintf(buf + pos, bufsz - pos,
1442 fmt_table, "rx_enable_counter:",
1443 le32_to_cpu(general->rx_enable_counter),
1444 accum_general->rx_enable_counter,
1445 delta_general->rx_enable_counter,
1446 max_general->rx_enable_counter);
1447 pos += scnprintf(buf + pos, bufsz - pos,
1448 fmt_table, "num_of_sos_states:",
1449 le32_to_cpu(general->num_of_sos_states),
1450 accum_general->num_of_sos_states,
1451 delta_general->num_of_sos_states,
1452 max_general->num_of_sos_states);
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001453
1454 spin_unlock_bh(&priv->statistics.lock);
1455
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001456 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1457 kfree(buf);
1458 return ret;
1459}
1460
1461static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1462 char __user *user_buf,
1463 size_t count, loff_t *ppos)
1464{
1465 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1466 int pos = 0;
1467 char *buf;
1468 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
1469 ssize_t ret;
1470 struct statistics_bt_activity *bt, *accum_bt;
1471
Don Fry83626402012-03-07 09:52:37 -08001472 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001473 return -EAGAIN;
1474
1475 if (!priv->bt_enable_flag)
1476 return -EINVAL;
1477
1478 /* make request to uCode to retrieve statistics information */
Johannes Bergb1eea292012-03-06 13:30:42 -08001479 mutex_lock(&priv->mutex);
Emmanuel Grumbacha1022922014-05-12 11:36:41 +03001480 ret = iwl_send_statistics_request(priv, 0, false);
Johannes Bergb1eea292012-03-06 13:30:42 -08001481 mutex_unlock(&priv->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001482
Johannes Bergf9e75442012-03-30 09:37:39 +02001483 if (ret)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001484 return -EAGAIN;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001485 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001486 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001487 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001488
1489 /*
1490 * the statistic information display here is based on
1491 * the last statistics notification from uCode
1492 * might not reflect the current uCode activity
1493 */
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001494
1495 spin_lock_bh(&priv->statistics.lock);
1496
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001497 bt = &priv->statistics.bt_activity;
1498 accum_bt = &priv->accum_stats.bt_activity;
1499
1500 pos += iwl_statistics_flag(priv, buf, bufsz);
1501 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
1502 pos += scnprintf(buf + pos, bufsz - pos,
1503 "\t\t\tcurrent\t\t\taccumulative\n");
1504 pos += scnprintf(buf + pos, bufsz - pos,
1505 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1506 le32_to_cpu(bt->hi_priority_tx_req_cnt),
1507 accum_bt->hi_priority_tx_req_cnt);
1508 pos += scnprintf(buf + pos, bufsz - pos,
1509 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1510 le32_to_cpu(bt->hi_priority_tx_denied_cnt),
1511 accum_bt->hi_priority_tx_denied_cnt);
1512 pos += scnprintf(buf + pos, bufsz - pos,
1513 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1514 le32_to_cpu(bt->lo_priority_tx_req_cnt),
1515 accum_bt->lo_priority_tx_req_cnt);
1516 pos += scnprintf(buf + pos, bufsz - pos,
1517 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1518 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
1519 accum_bt->lo_priority_tx_denied_cnt);
1520 pos += scnprintf(buf + pos, bufsz - pos,
1521 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1522 le32_to_cpu(bt->hi_priority_rx_req_cnt),
1523 accum_bt->hi_priority_rx_req_cnt);
1524 pos += scnprintf(buf + pos, bufsz - pos,
1525 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1526 le32_to_cpu(bt->hi_priority_rx_denied_cnt),
1527 accum_bt->hi_priority_rx_denied_cnt);
1528 pos += scnprintf(buf + pos, bufsz - pos,
1529 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1530 le32_to_cpu(bt->lo_priority_rx_req_cnt),
1531 accum_bt->lo_priority_rx_req_cnt);
1532 pos += scnprintf(buf + pos, bufsz - pos,
1533 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1534 le32_to_cpu(bt->lo_priority_rx_denied_cnt),
1535 accum_bt->lo_priority_rx_denied_cnt);
1536
1537 pos += scnprintf(buf + pos, bufsz - pos,
1538 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1539 le32_to_cpu(priv->statistics.num_bt_kills),
1540 priv->statistics.accum_num_bt_kills);
1541
Johannes Berg4ff70fcd2012-03-05 11:24:26 -08001542 spin_unlock_bh(&priv->statistics.lock);
1543
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001544 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1545 kfree(buf);
1546 return ret;
1547}
1548
1549static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1550 char __user *user_buf,
1551 size_t count, loff_t *ppos)
1552{
1553 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1554 int pos = 0;
1555 char *buf;
1556 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
1557 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
1558 ssize_t ret;
1559
Don Fry83626402012-03-07 09:52:37 -08001560 if (!iwl_is_alive(priv))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001561 return -EAGAIN;
1562
1563 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001564 if (!buf)
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001565 return -ENOMEM;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001566
1567 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1568 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1569 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001570 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001571 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1572 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001573 priv->reply_tx_stats.pp_few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001574 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1575 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001576 priv->reply_tx_stats.pp_bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001577 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1578 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001579 priv->reply_tx_stats.pp_quiet_period);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001580 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1581 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001582 priv->reply_tx_stats.pp_calc_ttak);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001583 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1584 iwl_get_tx_fail_reason(
1585 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001586 priv->reply_tx_stats.int_crossed_retry);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001587 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1588 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001589 priv->reply_tx_stats.short_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001590 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1591 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001592 priv->reply_tx_stats.long_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001593 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1594 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001595 priv->reply_tx_stats.fifo_underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001596 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1597 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001598 priv->reply_tx_stats.drain_flow);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001599 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1600 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001601 priv->reply_tx_stats.rfkill_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001602 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1603 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001604 priv->reply_tx_stats.life_expire);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001605 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1606 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001607 priv->reply_tx_stats.dest_ps);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001608 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1609 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001610 priv->reply_tx_stats.host_abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001611 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1612 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001613 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001614 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1615 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001616 priv->reply_tx_stats.sta_invalid);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001617 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1618 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001619 priv->reply_tx_stats.frag_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001620 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1621 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001622 priv->reply_tx_stats.tid_disable);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001623 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1624 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001625 priv->reply_tx_stats.fifo_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001626 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1627 iwl_get_tx_fail_reason(
1628 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001629 priv->reply_tx_stats.insuff_cf_poll);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001630 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1631 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001632 priv->reply_tx_stats.fail_hw_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001633 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1634 iwl_get_tx_fail_reason(
1635 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001636 priv->reply_tx_stats.sta_color_mismatch);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001637 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001638 priv->reply_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001639
1640 pos += scnprintf(buf + pos, bufsz - pos,
1641 "\nStatistics_Agg_TX_Error:\n");
1642
1643 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1644 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001645 priv->reply_agg_tx_stats.underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001646 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1647 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001648 priv->reply_agg_tx_stats.bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001649 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1650 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001651 priv->reply_agg_tx_stats.few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001652 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1653 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001654 priv->reply_agg_tx_stats.abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001655 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1656 iwl_get_agg_tx_fail_reason(
1657 AGG_TX_STATE_LAST_SENT_TTL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001658 priv->reply_agg_tx_stats.last_sent_ttl);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001659 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1660 iwl_get_agg_tx_fail_reason(
1661 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001662 priv->reply_agg_tx_stats.last_sent_try);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001663 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1664 iwl_get_agg_tx_fail_reason(
1665 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001666 priv->reply_agg_tx_stats.last_sent_bt_kill);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001667 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1668 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001669 priv->reply_agg_tx_stats.scd_query);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001670 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1671 iwl_get_agg_tx_fail_reason(
1672 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001673 priv->reply_agg_tx_stats.bad_crc32);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001674 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1675 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001676 priv->reply_agg_tx_stats.response);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001677 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1678 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001679 priv->reply_agg_tx_stats.dump_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001680 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1681 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001682 priv->reply_agg_tx_stats.delay_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001683 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001684 priv->reply_agg_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001685
1686 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1687 kfree(buf);
1688 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001689}
1690
Wey-Yi Guy52259352009-08-07 15:41:43 -07001691static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1692 char __user *user_buf,
1693 size_t count, loff_t *ppos) {
1694
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001695 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001696 int pos = 0;
1697 int cnt = 0;
1698 char *buf;
1699 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1700 ssize_t ret;
1701 struct iwl_sensitivity_data *data;
1702
1703 data = &priv->sensitivity_data;
1704 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001705 if (!buf)
Wey-Yi Guy52259352009-08-07 15:41:43 -07001706 return -ENOMEM;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001707
1708 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1709 data->auto_corr_ofdm);
1710 pos += scnprintf(buf + pos, bufsz - pos,
1711 "auto_corr_ofdm_mrc:\t\t %u\n",
1712 data->auto_corr_ofdm_mrc);
1713 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1714 data->auto_corr_ofdm_x1);
1715 pos += scnprintf(buf + pos, bufsz - pos,
1716 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1717 data->auto_corr_ofdm_mrc_x1);
1718 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1719 data->auto_corr_cck);
1720 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1721 data->auto_corr_cck_mrc);
1722 pos += scnprintf(buf + pos, bufsz - pos,
1723 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1724 data->last_bad_plcp_cnt_ofdm);
1725 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1726 data->last_fa_cnt_ofdm);
1727 pos += scnprintf(buf + pos, bufsz - pos,
1728 "last_bad_plcp_cnt_cck:\t\t %u\n",
1729 data->last_bad_plcp_cnt_cck);
1730 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1731 data->last_fa_cnt_cck);
1732 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1733 data->nrg_curr_state);
1734 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1735 data->nrg_prev_state);
1736 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1737 for (cnt = 0; cnt < 10; cnt++) {
1738 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1739 data->nrg_value[cnt]);
1740 }
1741 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1742 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1743 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1744 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1745 data->nrg_silence_rssi[cnt]);
1746 }
1747 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1748 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1749 data->nrg_silence_ref);
1750 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1751 data->nrg_energy_idx);
1752 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1753 data->nrg_silence_idx);
1754 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1755 data->nrg_th_cck);
1756 pos += scnprintf(buf + pos, bufsz - pos,
1757 "nrg_auto_corr_silence_diff:\t %u\n",
1758 data->nrg_auto_corr_silence_diff);
1759 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1760 data->num_in_cck_no_fa);
1761 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1762 data->nrg_th_ofdm);
1763
1764 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1765 kfree(buf);
1766 return ret;
1767}
1768
1769
1770static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1771 char __user *user_buf,
1772 size_t count, loff_t *ppos) {
1773
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001774 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001775 int pos = 0;
1776 int cnt = 0;
1777 char *buf;
1778 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1779 ssize_t ret;
1780 struct iwl_chain_noise_data *data;
1781
1782 data = &priv->chain_noise_data;
1783 buf = kzalloc(bufsz, GFP_KERNEL);
Johannes Bergf9e75442012-03-30 09:37:39 +02001784 if (!buf)
Wey-Yi Guy52259352009-08-07 15:41:43 -07001785 return -ENOMEM;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001786
1787 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1788 data->active_chains);
1789 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1790 data->chain_noise_a);
1791 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1792 data->chain_noise_b);
1793 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1794 data->chain_noise_c);
1795 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1796 data->chain_signal_a);
1797 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1798 data->chain_signal_b);
1799 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1800 data->chain_signal_c);
1801 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1802 data->beacon_count);
1803
1804 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1805 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1806 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1807 data->disconn_array[cnt]);
1808 }
1809 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1810 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1811 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1812 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1813 data->delta_gain_code[cnt]);
1814 }
1815 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1816 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1817 data->radio_write);
1818 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1819 data->state);
1820
1821 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1822 kfree(buf);
1823 return ret;
1824}
1825
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001826static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1827 char __user *user_buf,
1828 size_t count, loff_t *ppos)
1829{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001830 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001831 char buf[60];
1832 int pos = 0;
1833 const size_t bufsz = sizeof(buf);
1834 u32 pwrsave_status;
1835
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -07001836 pwrsave_status = iwl_read32(priv->trans, CSR_GP_CNTRL) &
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001837 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1838
1839 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1840 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1841 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1842 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1843 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1844 "error");
1845
1846 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1847}
1848
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001849static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001850 const char __user *user_buf,
1851 size_t count, loff_t *ppos)
1852{
1853 struct iwl_priv *priv = file->private_data;
1854 char buf[8];
1855 int buf_size;
1856 int clear;
1857
1858 memset(buf, 0, sizeof(buf));
1859 buf_size = min(count, sizeof(buf) - 1);
1860 if (copy_from_user(buf, user_buf, buf_size))
1861 return -EFAULT;
1862 if (sscanf(buf, "%d", &clear) != 1)
1863 return -EFAULT;
1864
1865 /* make request to uCode to retrieve statistics information */
Johannes Bergb1eea292012-03-06 13:30:42 -08001866 mutex_lock(&priv->mutex);
Emmanuel Grumbacha1022922014-05-12 11:36:41 +03001867 iwl_send_statistics_request(priv, 0, true);
Johannes Bergb1eea292012-03-06 13:30:42 -08001868 mutex_unlock(&priv->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001869
1870 return count;
1871}
1872
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001873static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1874 char __user *user_buf,
1875 size_t count, loff_t *ppos) {
1876
Joe Perches57674302010-07-12 13:50:06 -07001877 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001878 int pos = 0;
1879 char buf[128];
1880 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001881
1882 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1883 priv->event_log.ucode_trace ? "On" : "Off");
1884 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1885 priv->event_log.non_wraps_count);
1886 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1887 priv->event_log.wraps_once_count);
1888 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1889 priv->event_log.wraps_more_count);
1890
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001891 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001892}
1893
1894static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
1895 const char __user *user_buf,
1896 size_t count, loff_t *ppos)
1897{
1898 struct iwl_priv *priv = file->private_data;
1899 char buf[8];
1900 int buf_size;
1901 int trace;
1902
1903 memset(buf, 0, sizeof(buf));
1904 buf_size = min(count, sizeof(buf) - 1);
1905 if (copy_from_user(buf, user_buf, buf_size))
1906 return -EFAULT;
1907 if (sscanf(buf, "%d", &trace) != 1)
1908 return -EFAULT;
1909
1910 if (trace) {
1911 priv->event_log.ucode_trace = true;
Don Fry83626402012-03-07 09:52:37 -08001912 if (iwl_is_alive(priv)) {
Johannes Berg98d4bf02012-01-13 11:56:11 +01001913 /* start collecting data now */
1914 mod_timer(&priv->ucode_trace, jiffies);
1915 }
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001916 } else {
1917 priv->event_log.ucode_trace = false;
1918 del_timer_sync(&priv->ucode_trace);
1919 }
1920
1921 return count;
1922}
1923
Johannes Berg60987202010-02-18 00:36:07 -08001924static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1925 char __user *user_buf,
1926 size_t count, loff_t *ppos) {
1927
Joe Perches57674302010-07-12 13:50:06 -07001928 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08001929 int len = 0;
1930 char buf[20];
1931
Johannes Berg246ed352010-08-23 10:46:32 +02001932 len = sprintf(buf, "0x%04X\n",
1933 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
Johannes Berg60987202010-02-18 00:36:07 -08001934 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1935}
1936
1937static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1938 char __user *user_buf,
1939 size_t count, loff_t *ppos) {
1940
Joe Perches57674302010-07-12 13:50:06 -07001941 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08001942 int len = 0;
1943 char buf[20];
1944
1945 len = sprintf(buf, "0x%04X\n",
Johannes Berg246ed352010-08-23 10:46:32 +02001946 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
Johannes Berg60987202010-02-18 00:36:07 -08001947 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1948}
1949
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001950static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
1951 char __user *user_buf,
1952 size_t count, loff_t *ppos) {
1953
1954 struct iwl_priv *priv = file->private_data;
1955 int pos = 0;
1956 char buf[12];
1957 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001958
1959 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
1960 priv->missed_beacon_threshold);
1961
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001962 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001963}
1964
1965static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
1966 const char __user *user_buf,
1967 size_t count, loff_t *ppos)
1968{
1969 struct iwl_priv *priv = file->private_data;
1970 char buf[8];
1971 int buf_size;
1972 int missed;
1973
1974 memset(buf, 0, sizeof(buf));
1975 buf_size = min(count, sizeof(buf) - 1);
1976 if (copy_from_user(buf, user_buf, buf_size))
1977 return -EFAULT;
1978 if (sscanf(buf, "%d", &missed) != 1)
1979 return -EINVAL;
1980
1981 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
1982 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
1983 priv->missed_beacon_threshold =
1984 IWL_MISSED_BEACON_THRESHOLD_DEF;
1985 else
1986 priv->missed_beacon_threshold = missed;
1987
1988 return count;
1989}
1990
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001991static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
1992 char __user *user_buf,
1993 size_t count, loff_t *ppos) {
1994
Joe Perches57674302010-07-12 13:50:06 -07001995 struct iwl_priv *priv = file->private_data;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001996 int pos = 0;
1997 char buf[12];
1998 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001999
2000 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
Johannes Bergab5c0f12012-03-06 13:30:53 -08002001 priv->plcp_delta_threshold);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002002
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002003 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002004}
2005
2006static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2007 const char __user *user_buf,
2008 size_t count, loff_t *ppos) {
2009
2010 struct iwl_priv *priv = file->private_data;
2011 char buf[8];
2012 int buf_size;
2013 int plcp;
2014
2015 memset(buf, 0, sizeof(buf));
2016 buf_size = min(count, sizeof(buf) - 1);
2017 if (copy_from_user(buf, user_buf, buf_size))
2018 return -EFAULT;
2019 if (sscanf(buf, "%d", &plcp) != 1)
2020 return -EINVAL;
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002021 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002022 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
Johannes Bergab5c0f12012-03-06 13:30:53 -08002023 priv->plcp_delta_threshold =
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002024 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002025 else
Johannes Bergab5c0f12012-03-06 13:30:53 -08002026 priv->plcp_delta_threshold = plcp;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002027 return count;
2028}
2029
Johannes Berg48dffd32012-04-09 17:46:57 -07002030static ssize_t iwl_dbgfs_rf_reset_read(struct file *file,
2031 char __user *user_buf,
2032 size_t count, loff_t *ppos)
Johannes Bergca934b62011-09-15 11:46:48 -07002033{
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002034 struct iwl_priv *priv = file->private_data;
Johannes Berg48dffd32012-04-09 17:46:57 -07002035 int pos = 0;
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002036 char buf[300];
2037 const size_t bufsz = sizeof(buf);
Johannes Berg48dffd32012-04-09 17:46:57 -07002038 struct iwl_rf_reset *rf_reset = &priv->rf_reset;
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002039
Johannes Berg48dffd32012-04-09 17:46:57 -07002040 pos += scnprintf(buf + pos, bufsz - pos,
2041 "RF reset statistics\n");
2042 pos += scnprintf(buf + pos, bufsz - pos,
2043 "\tnumber of reset request: %d\n",
2044 rf_reset->reset_request_count);
2045 pos += scnprintf(buf + pos, bufsz - pos,
2046 "\tnumber of reset request success: %d\n",
2047 rf_reset->reset_success_count);
2048 pos += scnprintf(buf + pos, bufsz - pos,
2049 "\tnumber of reset request reject: %d\n",
2050 rf_reset->reset_reject_count);
2051
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002052 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2053}
2054
Johannes Berg48dffd32012-04-09 17:46:57 -07002055static ssize_t iwl_dbgfs_rf_reset_write(struct file *file,
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002056 const char __user *user_buf,
2057 size_t count, loff_t *ppos) {
2058
2059 struct iwl_priv *priv = file->private_data;
Johannes Berg48dffd32012-04-09 17:46:57 -07002060 int ret;
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002061
Johannes Berg48dffd32012-04-09 17:46:57 -07002062 ret = iwl_force_rf_reset(priv, true);
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002063 return ret ? ret : count;
2064}
2065
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002066static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
2067 const char __user *user_buf,
2068 size_t count, loff_t *ppos) {
2069
2070 struct iwl_priv *priv = file->private_data;
2071 char buf[8];
2072 int buf_size;
2073 int flush;
2074
2075 memset(buf, 0, sizeof(buf));
2076 buf_size = min(count, sizeof(buf) - 1);
2077 if (copy_from_user(buf, user_buf, buf_size))
2078 return -EFAULT;
2079 if (sscanf(buf, "%d", &flush) != 1)
2080 return -EINVAL;
2081
Don Fry83626402012-03-07 09:52:37 -08002082 if (iwl_is_rfkill(priv))
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002083 return -EFAULT;
2084
Johannes Berga4dece92012-10-31 22:21:28 +01002085 iwlagn_dev_txfifo_flush(priv);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002086
2087 return count;
2088}
2089
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002090static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
2091 char __user *user_buf,
2092 size_t count, loff_t *ppos) {
2093
2094 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2095 int pos = 0;
2096 char buf[200];
2097 const size_t bufsz = sizeof(buf);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002098
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002099 if (!priv->bt_enable_flag) {
2100 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
Johannes Berg08960de2011-04-05 09:41:53 -07002101 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002102 }
2103 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
2104 priv->bt_enable_flag);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002105 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
2106 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
2107 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
2108 "last traffic notif: %d\n",
Wey-Yi Guy66e863a52010-11-08 14:54:37 -08002109 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002110 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
Wey-Yi Guy187bc4f2011-01-27 13:01:33 -08002111 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2112 priv->bt_ch_announce, priv->kill_ack_mask,
2113 priv->kill_cts_mask);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002114
2115 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
2116 switch (priv->bt_traffic_load) {
2117 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
2118 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
2119 break;
2120 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
2121 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
2122 break;
2123 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
2124 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
2125 break;
2126 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
2127 default:
2128 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
2129 break;
2130 }
2131
Johannes Berg08960de2011-04-05 09:41:53 -07002132 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002133}
2134
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002135static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2136 char __user *user_buf,
2137 size_t count, loff_t *ppos)
2138{
2139 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2140
2141 int pos = 0;
2142 char buf[40];
2143 const size_t bufsz = sizeof(buf);
2144
Emmanuel Grumbach21522682012-03-22 17:51:44 +02002145 if (priv->cfg->ht_params)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002146 pos += scnprintf(buf + pos, bufsz - pos,
2147 "use %s for aggregation\n",
Johannes Berg9e295112012-04-09 17:46:55 -07002148 (priv->hw_params.use_rts_for_aggregation) ?
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002149 "rts/cts" : "cts-to-self");
2150 else
2151 pos += scnprintf(buf + pos, bufsz - pos, "N/A");
2152
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002153 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2154}
2155
2156static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2157 const char __user *user_buf,
2158 size_t count, loff_t *ppos) {
2159
2160 struct iwl_priv *priv = file->private_data;
2161 char buf[8];
2162 int buf_size;
2163 int rts;
2164
Emmanuel Grumbach21522682012-03-22 17:51:44 +02002165 if (!priv->cfg->ht_params)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002166 return -EINVAL;
2167
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002168 memset(buf, 0, sizeof(buf));
2169 buf_size = min(count, sizeof(buf) - 1);
2170 if (copy_from_user(buf, user_buf, buf_size))
2171 return -EFAULT;
2172 if (sscanf(buf, "%d", &rts) != 1)
2173 return -EINVAL;
2174 if (rts)
Johannes Berg9e295112012-04-09 17:46:55 -07002175 priv->hw_params.use_rts_for_aggregation = true;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002176 else
Johannes Berg9e295112012-04-09 17:46:55 -07002177 priv->hw_params.use_rts_for_aggregation = false;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002178 return count;
2179}
2180
Johannes Bergc98c8d92012-04-02 15:15:58 +02002181static int iwl_cmd_echo_test(struct iwl_priv *priv)
2182{
2183 int ret;
2184 struct iwl_host_cmd cmd = {
2185 .id = REPLY_ECHO,
2186 .len = { 0 },
Johannes Bergc98c8d92012-04-02 15:15:58 +02002187 };
2188
2189 ret = iwl_dvm_send_cmd(priv, &cmd);
2190 if (ret)
2191 IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
2192 else
2193 IWL_DEBUG_INFO(priv, "echo testing pass\n");
2194 return ret;
2195}
2196
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002197static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
2198 const char __user *user_buf,
2199 size_t count, loff_t *ppos)
2200{
2201 struct iwl_priv *priv = file->private_data;
2202 char buf[8];
2203 int buf_size;
2204
2205 memset(buf, 0, sizeof(buf));
2206 buf_size = min(count, sizeof(buf) - 1);
2207 if (copy_from_user(buf, user_buf, buf_size))
2208 return -EFAULT;
2209
2210 iwl_cmd_echo_test(priv);
2211 return count;
2212}
2213
Johannes Berg882b7b72012-06-20 08:46:25 +02002214#ifdef CONFIG_IWLWIFI_DEBUG
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002215static ssize_t iwl_dbgfs_log_event_read(struct file *file,
2216 char __user *user_buf,
2217 size_t count, loff_t *ppos)
2218{
2219 struct iwl_priv *priv = file->private_data;
Stanislaw Gruszka3309ccf2013-04-16 15:38:29 +02002220 char *buf = NULL;
2221 ssize_t ret;
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002222
Stanislaw Gruszkaa6db0062013-04-16 15:40:54 +02002223 ret = iwl_dump_nic_event_log(priv, true, &buf);
Stanislaw Gruszkad5578942013-04-17 08:23:50 +02002224 if (ret > 0)
2225 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
Stanislaw Gruszka3309ccf2013-04-16 15:38:29 +02002226 kfree(buf);
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002227 return ret;
2228}
2229
2230static ssize_t iwl_dbgfs_log_event_write(struct file *file,
2231 const char __user *user_buf,
2232 size_t count, loff_t *ppos)
2233{
2234 struct iwl_priv *priv = file->private_data;
2235 u32 event_log_flag;
2236 char buf[8];
2237 int buf_size;
2238
Richard A. Griffiths0ff1bd32012-06-28 13:14:11 -07002239 /* check that the interface is up */
2240 if (!iwl_is_ready(priv))
2241 return -EAGAIN;
2242
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002243 memset(buf, 0, sizeof(buf));
2244 buf_size = min(count, sizeof(buf) - 1);
2245 if (copy_from_user(buf, user_buf, buf_size))
2246 return -EFAULT;
2247 if (sscanf(buf, "%d", &event_log_flag) != 1)
2248 return -EFAULT;
2249 if (event_log_flag == 1)
Stanislaw Gruszkaa6db0062013-04-16 15:40:54 +02002250 iwl_dump_nic_event_log(priv, true, NULL);
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002251
2252 return count;
2253}
Johannes Berg882b7b72012-06-20 08:46:25 +02002254#endif
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002255
Dor Shaishbfb45f52012-03-26 08:20:55 -07002256static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
2257 char __user *user_buf,
2258 size_t count, loff_t *ppos)
2259{
2260 struct iwl_priv *priv = file->private_data;
2261 char buf[120];
2262 int pos = 0;
2263 const size_t bufsz = sizeof(buf);
2264
2265 pos += scnprintf(buf + pos, bufsz - pos,
2266 "Sensitivity calibrations %s\n",
2267 (priv->calib_disabled &
2268 IWL_SENSITIVITY_CALIB_DISABLED) ?
2269 "DISABLED" : "ENABLED");
2270 pos += scnprintf(buf + pos, bufsz - pos,
2271 "Chain noise calibrations %s\n",
2272 (priv->calib_disabled &
2273 IWL_CHAIN_NOISE_CALIB_DISABLED) ?
2274 "DISABLED" : "ENABLED");
2275 pos += scnprintf(buf + pos, bufsz - pos,
2276 "Tx power calibrations %s\n",
2277 (priv->calib_disabled &
2278 IWL_TX_POWER_CALIB_DISABLED) ?
2279 "DISABLED" : "ENABLED");
2280
2281 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2282}
2283
David Spinadel647ad132012-03-31 08:31:05 -07002284static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
2285 const char __user *user_buf,
2286 size_t count, loff_t *ppos)
2287{
2288 struct iwl_priv *priv = file->private_data;
2289 char buf[8];
2290 u32 calib_disabled;
2291 int buf_size;
2292
2293 memset(buf, 0, sizeof(buf));
2294 buf_size = min(count, sizeof(buf) - 1);
2295 if (copy_from_user(buf, user_buf, buf_size))
2296 return -EFAULT;
2297 if (sscanf(buf, "%x", &calib_disabled) != 1)
2298 return -EFAULT;
2299
2300 priv->calib_disabled = calib_disabled;
2301
2302 return count;
2303}
2304
Emmanuel Grumbach490953a2013-03-04 08:53:07 +02002305static ssize_t iwl_dbgfs_fw_restart_write(struct file *file,
2306 const char __user *user_buf,
2307 size_t count, loff_t *ppos)
2308{
2309 struct iwl_priv *priv = file->private_data;
2310 bool restart_fw = iwlwifi_mod_params.restart_fw;
2311 int ret;
2312
2313 iwlwifi_mod_params.restart_fw = true;
2314
2315 mutex_lock(&priv->mutex);
2316
2317 /* take the return value to make compiler happy - it will fail anyway */
Emmanuel Grumbacha1022922014-05-12 11:36:41 +03002318 ret = iwl_dvm_send_cmd_pdu(priv, REPLY_ERROR, 0, 0, NULL);
Emmanuel Grumbach490953a2013-03-04 08:53:07 +02002319
2320 mutex_unlock(&priv->mutex);
2321
2322 iwlwifi_mod_params.restart_fw = restart_fw;
2323
2324 return count;
2325}
2326
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002327DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2328DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2329DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002330DEBUGFS_READ_FILE_OPS(sensitivity);
2331DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002332DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002333DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002334DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002335DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002336DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Johannes Berg48dffd32012-04-09 17:46:57 -07002337DEBUGFS_READ_WRITE_FILE_OPS(rf_reset);
Johannes Berg60987202010-02-18 00:36:07 -08002338DEBUGFS_READ_FILE_OPS(rxon_flags);
2339DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002340DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
Wey-Yi Guyffb7d892010-07-14 08:09:55 -07002341DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002342DEBUGFS_READ_FILE_OPS(bt_traffic);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002343DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002344DEBUGFS_READ_FILE_OPS(reply_tx_error);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002345DEBUGFS_WRITE_FILE_OPS(echo_test);
Emmanuel Grumbach490953a2013-03-04 08:53:07 +02002346DEBUGFS_WRITE_FILE_OPS(fw_restart);
Johannes Berg882b7b72012-06-20 08:46:25 +02002347#ifdef CONFIG_IWLWIFI_DEBUG
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002348DEBUGFS_READ_WRITE_FILE_OPS(log_event);
Johannes Berg882b7b72012-06-20 08:46:25 +02002349#endif
David Spinadel647ad132012-03-31 08:31:05 -07002350DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002351
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002352/*
2353 * Create the debugfs files and directories
2354 *
2355 */
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002356int iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002357{
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002358 struct dentry *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002359
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002360 priv->debugfs_dir = dbgfs_dir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002361
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002362 dir_data = debugfs_create_dir("data", dbgfs_dir);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002363 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002364 goto err;
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002365 dir_rf = debugfs_create_dir("rf", dbgfs_dir);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002366 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002367 goto err;
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002368 dir_debug = debugfs_create_dir("debug", dbgfs_dir);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002369 if (!dir_debug)
2370 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002371
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002372 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2373 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
Johannes Bergc8ac61c2011-07-15 13:23:45 -07002374 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002375 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2376 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2377 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -07002378 DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002379 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
Wey-Yi Guy23c0fcc2011-04-01 16:29:53 -07002380 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2381 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002382 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2383 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
Emmanuel Grumbach511afa32011-09-22 07:15:37 -07002384 DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR);
Johannes Bergca934b62011-09-15 11:46:48 -07002385
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002386 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2387 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002388 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002389 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg48dffd32012-04-09 17:46:57 -07002390 DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002391 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2392 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2393 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002394 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002395 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002396 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2397 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
Wey-Yi Guyb7af6a92011-04-06 15:55:25 -07002398 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg0da0e5b2011-04-08 08:14:56 -07002399 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002400 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
Johannes Berg60987202010-02-18 00:36:07 -08002401 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2402 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Wey-Yi Guy7e4005c2011-10-10 07:26:51 -07002403 DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR);
Emmanuel Grumbach490953a2013-03-04 08:53:07 +02002404 DEBUGFS_ADD_FILE(fw_restart, dir_debug, S_IWUSR);
Johannes Berg882b7b72012-06-20 08:46:25 +02002405#ifdef CONFIG_IWLWIFI_DEBUG
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002406 DEBUGFS_ADD_FILE(log_event, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg882b7b72012-06-20 08:46:25 +02002407#endif
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -07002408
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +01002409 if (iwl_advanced_bt_coexist(priv))
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002410 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
Johannes Bergca934b62011-09-15 11:46:48 -07002411
Dor Shaishbfb45f52012-03-26 08:20:55 -07002412 /* Calibrations disabled/enabled status*/
David Spinadel647ad132012-03-31 08:31:05 -07002413 DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IWUSR | S_IRUSR);
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002414
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002415 /*
2416 * Create a symlink with mac80211. This is not very robust, as it does
2417 * not remove the symlink created. The implicit assumption is that
2418 * when the opmode exits, mac80211 will also exit, and will remove
2419 * this symlink as part of its cleanup.
2420 */
2421 if (priv->mac80211_registered) {
2422 char buf[100];
2423 struct dentry *mac80211_dir, *dev_dir, *root_dir;
2424
2425 dev_dir = dbgfs_dir->d_parent;
2426 root_dir = dev_dir->d_parent;
2427 mac80211_dir = priv->hw->wiphy->debugfsdir;
2428
2429 snprintf(buf, 100, "../../%s/%s", root_dir->d_name.name,
2430 dev_dir->d_name.name);
2431
2432 if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf))
2433 goto err;
2434 }
2435
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002436 return 0;
2437
2438err:
Meenakshi Venkataraman9da987a2012-07-16 18:43:56 -07002439 IWL_ERR(priv, "failed to create the dvm debugfs entries\n");
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002440 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002441}