blob: fa070de2840c53b54446cef67fc071f8748d62b1 [file] [log] [blame]
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -07005 * Copyright(c) 2008 - 2011 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
22 * in the file called LICENSE.GPL.
23 *
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>
33
34#include <linux/ieee80211.h>
35#include <net/mac80211.h>
36
37
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070038#include "iwl-dev.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070039#include "iwl-debug.h"
Tomas Winklerfee12472008-04-03 16:05:21 -070040#include "iwl-core.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070041#include "iwl-io.h"
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -070042#include "iwl-agn.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070043
44/* create and remove of files */
Johannes Berg4c84a8f2010-01-22 14:22:54 -080045#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
46 if (!debugfs_create_file(#name, mode, parent, priv, \
47 &iwl_dbgfs_##name##_ops)) \
48 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070049} while (0)
50
Johannes Berg4c84a8f2010-01-22 14:22:54 -080051#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
52 struct dentry *__tmp; \
53 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
54 parent, ptr); \
55 if (IS_ERR(__tmp) || !__tmp) \
56 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070057} while (0)
58
Johannes Berg4c84a8f2010-01-22 14:22:54 -080059#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
60 struct dentry *__tmp; \
61 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
62 parent, ptr); \
63 if (IS_ERR(__tmp) || !__tmp) \
64 goto err; \
Tomas Winkler445c2df2008-05-15 13:54:16 +080065} while (0)
66
Tomas Winkler712b6cf2008-03-12 16:58:52 -070067/* file operation */
68#define DEBUGFS_READ_FUNC(name) \
69static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
70 char __user *user_buf, \
71 size_t count, loff_t *ppos);
72
73#define DEBUGFS_WRITE_FUNC(name) \
74static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
75 const char __user *user_buf, \
76 size_t count, loff_t *ppos);
77
78
79static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
80{
81 file->private_data = inode->i_private;
82 return 0;
83}
84
85#define DEBUGFS_READ_FILE_OPS(name) \
86 DEBUGFS_READ_FUNC(name); \
87static const struct file_operations iwl_dbgfs_##name##_ops = { \
88 .read = iwl_dbgfs_##name##_read, \
89 .open = iwl_dbgfs_open_file_generic, \
Arnd Bergmann2b18ab32010-07-06 19:05:31 +020090 .llseek = generic_file_llseek, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070091};
92
Ester Kummer189a2b52008-05-15 13:54:18 +080093#define DEBUGFS_WRITE_FILE_OPS(name) \
94 DEBUGFS_WRITE_FUNC(name); \
95static const struct file_operations iwl_dbgfs_##name##_ops = { \
96 .write = iwl_dbgfs_##name##_write, \
97 .open = iwl_dbgfs_open_file_generic, \
Arnd Bergmann2b18ab32010-07-06 19:05:31 +020098 .llseek = generic_file_llseek, \
Ester Kummer189a2b52008-05-15 13:54:18 +080099};
100
101
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700102#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
103 DEBUGFS_READ_FUNC(name); \
104 DEBUGFS_WRITE_FUNC(name); \
105static const struct file_operations iwl_dbgfs_##name##_ops = { \
106 .write = iwl_dbgfs_##name##_write, \
107 .read = iwl_dbgfs_##name##_read, \
108 .open = iwl_dbgfs_open_file_generic, \
Arnd Bergmann2b18ab32010-07-06 19:05:31 +0200109 .llseek = generic_file_llseek, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700110};
111
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700112static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
113 char __user *user_buf,
114 size_t count, loff_t *ppos) {
115
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700116 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700117 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700118 int pos = 0;
119
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700120 int cnt;
121 ssize_t ret;
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800122 const size_t bufsz = 100 +
123 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700124 buf = kzalloc(bufsz, GFP_KERNEL);
125 if (!buf)
126 return -ENOMEM;
127 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
128 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
129 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800130 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700131 get_mgmt_string(cnt),
132 priv->tx_stats.mgmt[cnt]);
133 }
134 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
135 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
136 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800137 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700138 get_ctrl_string(cnt),
139 priv->tx_stats.ctrl[cnt]);
140 }
141 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
142 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
143 priv->tx_stats.data_cnt);
144 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
145 priv->tx_stats.data_bytes);
146 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
147 kfree(buf);
148 return ret;
149}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700150
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800151static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700152 const char __user *user_buf,
153 size_t count, loff_t *ppos)
154{
155 struct iwl_priv *priv = file->private_data;
156 u32 clear_flag;
157 char buf[8];
158 int buf_size;
159
160 memset(buf, 0, sizeof(buf));
161 buf_size = min(count, sizeof(buf) - 1);
162 if (copy_from_user(buf, user_buf, buf_size))
163 return -EFAULT;
164 if (sscanf(buf, "%x", &clear_flag) != 1)
165 return -EFAULT;
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800166 iwl_clear_traffic_stats(priv);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700167
168 return count;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700169}
170
171static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
172 char __user *user_buf,
173 size_t count, loff_t *ppos) {
174
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700175 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700176 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700177 int pos = 0;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700178 int cnt;
179 ssize_t ret;
180 const size_t bufsz = 100 +
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800181 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700182 buf = kzalloc(bufsz, GFP_KERNEL);
183 if (!buf)
184 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700185
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700186 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
187 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
188 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800189 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700190 get_mgmt_string(cnt),
191 priv->rx_stats.mgmt[cnt]);
192 }
193 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
194 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
195 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800196 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700197 get_ctrl_string(cnt),
198 priv->rx_stats.ctrl[cnt]);
199 }
200 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
201 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
202 priv->rx_stats.data_cnt);
203 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
204 priv->rx_stats.data_bytes);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700205
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700206 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
207 kfree(buf);
208 return ret;
209}
210
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700211static ssize_t iwl_dbgfs_sram_read(struct file *file,
212 char __user *user_buf,
213 size_t count, loff_t *ppos)
214{
Jay Sternberg24834d22011-01-11 15:41:00 -0800215 u32 val = 0;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800216 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700217 ssize_t ret;
Jay Sternberg24834d22011-01-11 15:41:00 -0800218 int i = 0;
219 bool device_format = false;
220 int offset = 0;
221 int len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700222 int pos = 0;
Jay Sternberg24834d22011-01-11 15:41:00 -0800223 int sram;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700224 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800225 size_t bufsz;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700226
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800227 /* default is to dump the entire data segment */
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800228 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
229 priv->dbgfs_sram_offset = 0x800000;
Johannes Berg872907b2011-06-06 09:41:15 -0700230 if (priv->ucode_type == IWL_UCODE_INIT)
Johannes Bergdbf28e212011-04-16 08:29:24 -0700231 priv->dbgfs_sram_len = priv->ucode_init.data.len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800232 else
Johannes Bergdbf28e212011-04-16 08:29:24 -0700233 priv->dbgfs_sram_len = priv->ucode_rt.data.len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800234 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800235 len = priv->dbgfs_sram_len;
236
237 if (len == -4) {
238 device_format = true;
239 len = 4;
240 }
241
242 bufsz = 50 + len * 4;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800243 buf = kmalloc(bufsz, GFP_KERNEL);
244 if (!buf)
245 return -ENOMEM;
Jay Sternberg24834d22011-01-11 15:41:00 -0800246
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800247 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
Jay Sternberg24834d22011-01-11 15:41:00 -0800248 len);
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800249 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800250 priv->dbgfs_sram_offset);
Jay Sternberg24834d22011-01-11 15:41:00 -0800251
252 /* adjust sram address since reads are only on even u32 boundaries */
253 offset = priv->dbgfs_sram_offset & 0x3;
254 sram = priv->dbgfs_sram_offset & ~0x3;
255
256 /* read the first u32 from sram */
257 val = iwl_read_targ_mem(priv, sram);
258
259 for (; len; len--) {
260 /* put the address at the start of every line */
261 if (i == 0)
262 pos += scnprintf(buf + pos, bufsz - pos,
263 "%08X: ", sram + offset);
264
265 if (device_format)
266 pos += scnprintf(buf + pos, bufsz - pos,
267 "%02x", (val >> (8 * (3 - offset))) & 0xff);
268 else
269 pos += scnprintf(buf + pos, bufsz - pos,
270 "%02x ", (val >> (8 * offset)) & 0xff);
271
272 /* if all bytes processed, read the next u32 from sram */
273 if (++offset == 4) {
274 sram += 4;
275 offset = 0;
276 val = iwl_read_targ_mem(priv, sram);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700277 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800278
279 /* put in extra spaces and split lines for human readability */
280 if (++i == 16) {
281 i = 0;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800282 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Jay Sternberg24834d22011-01-11 15:41:00 -0800283 } else if (!(i & 7)) {
284 pos += scnprintf(buf + pos, bufsz - pos, " ");
285 } else if (!(i & 3)) {
286 pos += scnprintf(buf + pos, bufsz - pos, " ");
287 }
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700288 }
Jay Sternberg24834d22011-01-11 15:41:00 -0800289 if (i)
290 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700291
292 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800293 kfree(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700294 return ret;
295}
296
297static ssize_t iwl_dbgfs_sram_write(struct file *file,
298 const char __user *user_buf,
299 size_t count, loff_t *ppos)
300{
301 struct iwl_priv *priv = file->private_data;
302 char buf[64];
303 int buf_size;
304 u32 offset, len;
305
306 memset(buf, 0, sizeof(buf));
307 buf_size = min(count, sizeof(buf) - 1);
308 if (copy_from_user(buf, user_buf, buf_size))
309 return -EFAULT;
310
311 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800312 priv->dbgfs_sram_offset = offset;
313 priv->dbgfs_sram_len = len;
Jay Sternberg24834d22011-01-11 15:41:00 -0800314 } else if (sscanf(buf, "%x", &offset) == 1) {
315 priv->dbgfs_sram_offset = offset;
316 priv->dbgfs_sram_len = -4;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700317 } else {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800318 priv->dbgfs_sram_offset = 0;
319 priv->dbgfs_sram_len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700320 }
321
322 return count;
323}
324
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700325static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
326 char __user *user_buf,
327 size_t count, loff_t *ppos)
328{
329 struct iwl_priv *priv = file->private_data;
330
331 if (!priv->wowlan_sram)
332 return -ENODATA;
333
334 return simple_read_from_buffer(user_buf, count, ppos,
335 priv->wowlan_sram,
336 priv->ucode_wowlan.data.len);
337}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700338static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
339 size_t count, loff_t *ppos)
340{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700341 struct iwl_priv *priv = file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800342 struct iwl_station_entry *station;
Emmanuel Grumbachd6189122011-08-25 23:10:39 -0700343 int max_sta = hw_params(priv).max_stations;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700344 char *buf;
345 int i, j, pos = 0;
346 ssize_t ret;
347 /* Add 30 for initial string */
348 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700349
350 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300351 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700352 return -ENOMEM;
353
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700354 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700355 priv->num_stations);
356
357 for (i = 0; i < max_sta; i++) {
358 station = &priv->stations[i];
Johannes Bergda735112010-05-03 01:25:24 -0700359 if (!station->used)
360 continue;
361 pos += scnprintf(buf + pos, bufsz - pos,
362 "station %d - addr: %pM, flags: %#x\n",
363 i, station->sta.sta.addr,
364 station->sta.station_flags_msk);
365 pos += scnprintf(buf + pos, bufsz - pos,
366 "TID\tseq_num\ttxq_id\tframes\ttfds\t");
367 pos += scnprintf(buf + pos, bufsz - pos,
368 "start_idx\tbitmap\t\t\trate_n_flags\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700369
Johannes Bergda735112010-05-03 01:25:24 -0700370 for (j = 0; j < MAX_TID_COUNT; j++) {
371 pos += scnprintf(buf + pos, bufsz - pos,
372 "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x",
373 j, station->tid[j].seq_number,
374 station->tid[j].agg.txq_id,
375 station->tid[j].agg.frame_count,
376 station->tid[j].tfds_in_queue,
377 station->tid[j].agg.start_idx,
378 station->tid[j].agg.bitmap,
379 station->tid[j].agg.rate_n_flags);
380
381 if (station->tid[j].agg.wait_for_ba)
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700382 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Bergda735112010-05-03 01:25:24 -0700383 " - waitforba");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700384 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700385 }
Johannes Bergda735112010-05-03 01:25:24 -0700386
387 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700388 }
389
390 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
391 kfree(buf);
392 return ret;
393}
394
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700395static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800396 char __user *user_buf,
397 size_t count,
398 loff_t *ppos)
399{
400 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700401 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800402 int pos = 0, ofs = 0, buf_size = 0;
403 const u8 *ptr;
404 char *buf;
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700405 u16 eeprom_ver;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700406 size_t eeprom_len = priv->cfg->base_params->eeprom_size;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800407 buf_size = 4 * eeprom_len + 256;
408
409 if (eeprom_len % 16) {
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700410 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800411 return -ENODATA;
412 }
413
Julia Lawallc37457e2009-08-03 11:11:45 +0200414 ptr = priv->eeprom;
415 if (!ptr) {
416 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
417 return -ENOMEM;
418 }
419
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800420 /* 4 characters for byte 0xYY */
421 buf = kzalloc(buf_size, GFP_KERNEL);
422 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800423 IWL_ERR(priv, "Can not allocate Buffer\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800424 return -ENOMEM;
425 }
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700426 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
427 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
428 "version: 0x%x\n",
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700429 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700430 ? "OTP" : "EEPROM", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800431 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
432 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
433 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
434 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700435 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800436 if (buf_size - pos > 0)
437 buf[pos++] = '\n';
438 }
439
440 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
441 kfree(buf);
442 return ret;
443}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700444
Winkler, Tomasd366df52008-12-02 12:14:01 -0800445static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
446 size_t count, loff_t *ppos)
447{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700448 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800449 struct ieee80211_channel *channels = NULL;
450 const struct ieee80211_supported_band *supp_band = NULL;
451 int pos = 0, i, bufsz = PAGE_SIZE;
452 char *buf;
453 ssize_t ret;
454
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700455 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status))
Winkler, Tomasd366df52008-12-02 12:14:01 -0800456 return -EAGAIN;
457
458 buf = kzalloc(bufsz, GFP_KERNEL);
459 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800460 IWL_ERR(priv, "Can not allocate Buffer\n");
Winkler, Tomasd366df52008-12-02 12:14:01 -0800461 return -ENOMEM;
462 }
463
464 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700465 if (supp_band) {
466 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800467
Winkler, Tomasd366df52008-12-02 12:14:01 -0800468 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700469 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
470 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800471
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700472 for (i = 0; i < supp_band->n_channels; i++)
473 pos += scnprintf(buf + pos, bufsz - pos,
474 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700475 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700476 channels[i].max_power,
477 channels[i].flags & IEEE80211_CHAN_RADAR ?
478 " (IEEE 802.11h required)" : "",
479 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
480 || (channels[i].flags &
481 IEEE80211_CHAN_RADAR)) ? "" :
482 ", IBSS",
483 channels[i].flags &
484 IEEE80211_CHAN_PASSIVE_SCAN ?
485 "passive only" : "active/passive");
486 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800487 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700488 if (supp_band) {
489 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800490
Winkler, Tomasd366df52008-12-02 12:14:01 -0800491 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700492 "Displaying %d channels in 5.2GHz band (802.11a)\n",
493 supp_band->n_channels);
494
495 for (i = 0; i < supp_band->n_channels; i++)
496 pos += scnprintf(buf + pos, bufsz - pos,
497 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700498 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700499 channels[i].max_power,
500 channels[i].flags & IEEE80211_CHAN_RADAR ?
501 " (IEEE 802.11h required)" : "",
502 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
503 || (channels[i].flags &
504 IEEE80211_CHAN_RADAR)) ? "" :
505 ", IBSS",
506 channels[i].flags &
507 IEEE80211_CHAN_PASSIVE_SCAN ?
508 "passive only" : "active/passive");
509 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800510 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
511 kfree(buf);
512 return ret;
513}
514
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700515static ssize_t iwl_dbgfs_status_read(struct file *file,
516 char __user *user_buf,
517 size_t count, loff_t *ppos) {
518
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700519 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700520 char buf[512];
521 int pos = 0;
522 const size_t bufsz = sizeof(buf);
523
524 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700525 test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700526 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700527 test_bit(STATUS_INT_ENABLED, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700528 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700529 test_bit(STATUS_RF_KILL_HW, &priv->shrd->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700530 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700531 test_bit(STATUS_CT_KILL, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700532 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700533 test_bit(STATUS_INIT, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700534 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700535 test_bit(STATUS_ALIVE, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700536 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700537 test_bit(STATUS_READY, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700538 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700539 test_bit(STATUS_TEMPERATURE, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700540 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700541 test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700542 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700543 test_bit(STATUS_EXIT_PENDING, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700544 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700545 test_bit(STATUS_STATISTICS, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700546 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700547 test_bit(STATUS_SCANNING, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700548 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700549 test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700550 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700551 test_bit(STATUS_SCAN_HW, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700552 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700553 test_bit(STATUS_POWER_PMI, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700554 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700555 test_bit(STATUS_FW_ERROR, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700556 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
557}
558
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700559static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
560 char __user *user_buf,
561 size_t count, loff_t *ppos) {
562
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700563 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700564 int pos = 0;
565 int cnt = 0;
566 char *buf;
567 int bufsz = 24 * 64; /* 24 items * 64 char per item */
568 ssize_t ret;
569
570 buf = kzalloc(bufsz, GFP_KERNEL);
571 if (!buf) {
572 IWL_ERR(priv, "Can not allocate Buffer\n");
573 return -ENOMEM;
574 }
575
576 pos += scnprintf(buf + pos, bufsz - pos,
577 "Interrupt Statistics Report:\n");
578
579 pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
580 priv->isr_stats.hw);
581 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
582 priv->isr_stats.sw);
Wey-Yi Guy6e6ebf42010-08-27 10:41:37 -0700583 if (priv->isr_stats.sw || priv->isr_stats.hw) {
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700584 pos += scnprintf(buf + pos, bufsz - pos,
585 "\tLast Restarting Code: 0x%X\n",
Wey-Yi Guy6e6ebf42010-08-27 10:41:37 -0700586 priv->isr_stats.err_code);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700587 }
588#ifdef CONFIG_IWLWIFI_DEBUG
589 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
590 priv->isr_stats.sch);
591 pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
592 priv->isr_stats.alive);
593#endif
594 pos += scnprintf(buf + pos, bufsz - pos,
595 "HW RF KILL switch toggled:\t %u\n",
596 priv->isr_stats.rfkill);
597
598 pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
599 priv->isr_stats.ctkill);
600
601 pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
602 priv->isr_stats.wakeup);
603
604 pos += scnprintf(buf + pos, bufsz - pos,
605 "Rx command responses:\t\t %u\n",
606 priv->isr_stats.rx);
607 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
608 if (priv->isr_stats.rx_handlers[cnt] > 0)
609 pos += scnprintf(buf + pos, bufsz - pos,
610 "\tRx handler[%36s]:\t\t %u\n",
611 get_cmd_string(cnt),
612 priv->isr_stats.rx_handlers[cnt]);
613 }
614
615 pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
616 priv->isr_stats.tx);
617
618 pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
619 priv->isr_stats.unhandled);
620
621 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
622 kfree(buf);
623 return ret;
624}
625
626static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
627 const char __user *user_buf,
628 size_t count, loff_t *ppos)
629{
630 struct iwl_priv *priv = file->private_data;
631 char buf[8];
632 int buf_size;
633 u32 reset_flag;
634
635 memset(buf, 0, sizeof(buf));
636 buf_size = min(count, sizeof(buf) - 1);
637 if (copy_from_user(buf, user_buf, buf_size))
638 return -EFAULT;
639 if (sscanf(buf, "%x", &reset_flag) != 1)
640 return -EFAULT;
641 if (reset_flag == 0)
642 iwl_clear_isr_stats(priv);
643
644 return count;
645}
646
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700647static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
648 size_t count, loff_t *ppos)
649{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700650 struct iwl_priv *priv = file->private_data;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200651 struct iwl_rxon_context *ctx;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700652 int pos = 0, i;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200653 char buf[256 * NUM_IWL_RXON_CTX];
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700654 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700655
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200656 for_each_context(priv, ctx) {
657 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
658 ctx->ctxid);
659 for (i = 0; i < AC_NUM; i++) {
660 pos += scnprintf(buf + pos, bufsz - pos,
661 "\tcw_min\tcw_max\taifsn\ttxop\n");
662 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700663 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200664 ctx->qos_data.def_qos_parm.ac[i].cw_min,
665 ctx->qos_data.def_qos_parm.ac[i].cw_max,
666 ctx->qos_data.def_qos_parm.ac[i].aifsn,
667 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
668 }
669 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700670 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800671 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700672}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700673
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700674static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
675 char __user *user_buf,
676 size_t count, loff_t *ppos)
677{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700678 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700679 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700680 struct iwl_tt_restriction *restriction;
681 char buf[100];
682 int pos = 0;
683 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700684
685 pos += scnprintf(buf + pos, bufsz - pos,
686 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700687 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700688 pos += scnprintf(buf + pos, bufsz - pos,
689 "Thermal Throttling State: %d\n",
690 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700691 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700692 restriction = tt->restriction + tt->state;
693 pos += scnprintf(buf + pos, bufsz - pos,
694 "Tx mode: %d\n",
695 restriction->tx_stream);
696 pos += scnprintf(buf + pos, bufsz - pos,
697 "Rx mode: %d\n",
698 restriction->rx_stream);
699 pos += scnprintf(buf + pos, bufsz - pos,
700 "HT mode: %d\n",
701 restriction->is_ht);
702 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800703 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700704}
705
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700706static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
707 const char __user *user_buf,
708 size_t count, loff_t *ppos)
709{
710 struct iwl_priv *priv = file->private_data;
711 char buf[8];
712 int buf_size;
713 int ht40;
714
715 memset(buf, 0, sizeof(buf));
716 buf_size = min(count, sizeof(buf) - 1);
717 if (copy_from_user(buf, user_buf, buf_size))
718 return -EFAULT;
719 if (sscanf(buf, "%d", &ht40) != 1)
720 return -EFAULT;
Johannes Berg246ed352010-08-23 10:46:32 +0200721 if (!iwl_is_any_associated(priv))
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700722 priv->disable_ht40 = ht40 ? true : false;
723 else {
724 IWL_ERR(priv, "Sta associated with AP - "
725 "Change to 40MHz channel support is not allowed\n");
726 return -EINVAL;
727 }
728
729 return count;
730}
731
732static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
733 char __user *user_buf,
734 size_t count, loff_t *ppos)
735{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700736 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700737 char buf[100];
738 int pos = 0;
739 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700740
741 pos += scnprintf(buf + pos, bufsz - pos,
742 "11n 40MHz Mode: %s\n",
743 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800744 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700745}
746
Johannes Berge312c242009-08-07 15:41:51 -0700747static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
748 const char __user *user_buf,
749 size_t count, loff_t *ppos)
750{
751 struct iwl_priv *priv = file->private_data;
752 char buf[8];
753 int buf_size;
754 int value;
755
756 memset(buf, 0, sizeof(buf));
757 buf_size = min(count, sizeof(buf) - 1);
758 if (copy_from_user(buf, user_buf, buf_size))
759 return -EFAULT;
760
761 if (sscanf(buf, "%d", &value) != 1)
762 return -EINVAL;
763
764 /*
765 * Our users expect 0 to be "CAM", but 0 isn't actually
766 * valid here. However, let's not confuse them and present
767 * IWL_POWER_INDEX_1 as "1", not "0".
768 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700769 if (value == 0)
770 return -EINVAL;
771 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700772 value -= 1;
773
774 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
775 return -EINVAL;
776
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700777 if (!iwl_is_ready_rf(priv))
778 return -EAGAIN;
779
Johannes Berge312c242009-08-07 15:41:51 -0700780 priv->power_data.debug_sleep_level_override = value;
781
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -0700782 mutex_lock(&priv->shrd->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700783 iwl_power_update_mode(priv, true);
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -0700784 mutex_unlock(&priv->shrd->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700785
786 return count;
787}
788
789static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
790 char __user *user_buf,
791 size_t count, loff_t *ppos)
792{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700793 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700794 char buf[10];
795 int pos, value;
796 const size_t bufsz = sizeof(buf);
797
798 /* see the write function */
799 value = priv->power_data.debug_sleep_level_override;
800 if (value >= 0)
801 value += 1;
802
803 pos = scnprintf(buf, bufsz, "%d\n", value);
804 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
805}
806
807static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
808 char __user *user_buf,
809 size_t count, loff_t *ppos)
810{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700811 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700812 char buf[200];
813 int pos = 0, i;
814 const size_t bufsz = sizeof(buf);
815 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
816
817 pos += scnprintf(buf + pos, bufsz - pos,
818 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
819 pos += scnprintf(buf + pos, bufsz - pos,
820 "RX/TX timeout: %d/%d usec\n",
821 le32_to_cpu(cmd->rx_data_timeout),
822 le32_to_cpu(cmd->tx_data_timeout));
823 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
824 pos += scnprintf(buf + pos, bufsz - pos,
825 "sleep_interval[%d]: %d\n", i,
826 le32_to_cpu(cmd->sleep_interval[i]));
827
828 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
829}
830
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700831DEBUGFS_READ_WRITE_FILE_OPS(sram);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700832DEBUGFS_READ_FILE_OPS(wowlan_sram);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700833DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700834DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800835DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700836DEBUGFS_READ_FILE_OPS(status);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700837DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700838DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700839DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700840DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Johannes Berge312c242009-08-07 15:41:51 -0700841DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
842DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700843
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700844static const char *fmt_value = " %-30s %10u\n";
845static const char *fmt_hex = " %-30s 0x%02X\n";
846static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
847static const char *fmt_header =
848 "%-32s current cumulative delta max\n";
849
850static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
851{
852 int p = 0;
853 u32 flag;
854
855 flag = le32_to_cpu(priv->statistics.flag);
856
857 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
858 if (flag & UCODE_STATISTICS_CLEAR_MSK)
859 p += scnprintf(buf + p, bufsz - p,
860 "\tStatistics have been cleared\n");
861 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
862 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
863 ? "2.4 GHz" : "5.2 GHz");
864 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
865 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
866 ? "enabled" : "disabled");
867
868 return p;
869}
870
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -0700871static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
872 char __user *user_buf,
873 size_t count, loff_t *ppos)
874{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700875 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700876 int pos = 0;
877 char *buf;
878 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
879 sizeof(struct statistics_rx_non_phy) * 40 +
880 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
881 ssize_t ret;
882 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
883 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
884 struct statistics_rx_non_phy *general, *accum_general;
885 struct statistics_rx_non_phy *delta_general, *max_general;
886 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
887
888 if (!iwl_is_alive(priv))
889 return -EAGAIN;
890
891 buf = kzalloc(bufsz, GFP_KERNEL);
892 if (!buf) {
893 IWL_ERR(priv, "Can not allocate Buffer\n");
894 return -ENOMEM;
895 }
896
897 /*
898 * the statistic information display here is based on
899 * the last statistics notification from uCode
900 * might not reflect the current uCode activity
901 */
902 ofdm = &priv->statistics.rx_ofdm;
903 cck = &priv->statistics.rx_cck;
904 general = &priv->statistics.rx_non_phy;
905 ht = &priv->statistics.rx_ofdm_ht;
906 accum_ofdm = &priv->accum_stats.rx_ofdm;
907 accum_cck = &priv->accum_stats.rx_cck;
908 accum_general = &priv->accum_stats.rx_non_phy;
909 accum_ht = &priv->accum_stats.rx_ofdm_ht;
910 delta_ofdm = &priv->delta_stats.rx_ofdm;
911 delta_cck = &priv->delta_stats.rx_cck;
912 delta_general = &priv->delta_stats.rx_non_phy;
913 delta_ht = &priv->delta_stats.rx_ofdm_ht;
914 max_ofdm = &priv->max_delta_stats.rx_ofdm;
915 max_cck = &priv->max_delta_stats.rx_cck;
916 max_general = &priv->max_delta_stats.rx_non_phy;
917 max_ht = &priv->max_delta_stats.rx_ofdm_ht;
918
919 pos += iwl_statistics_flag(priv, buf, bufsz);
920 pos += scnprintf(buf + pos, bufsz - pos,
921 fmt_header, "Statistics_Rx - OFDM:");
922 pos += scnprintf(buf + pos, bufsz - pos,
923 fmt_table, "ina_cnt:",
924 le32_to_cpu(ofdm->ina_cnt),
925 accum_ofdm->ina_cnt,
926 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
927 pos += scnprintf(buf + pos, bufsz - pos,
928 fmt_table, "fina_cnt:",
929 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
930 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
931 pos += scnprintf(buf + pos, bufsz - pos,
932 fmt_table, "plcp_err:",
933 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
934 delta_ofdm->plcp_err, max_ofdm->plcp_err);
935 pos += scnprintf(buf + pos, bufsz - pos,
936 fmt_table, "crc32_err:",
937 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
938 delta_ofdm->crc32_err, max_ofdm->crc32_err);
939 pos += scnprintf(buf + pos, bufsz - pos,
940 fmt_table, "overrun_err:",
941 le32_to_cpu(ofdm->overrun_err),
942 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
943 max_ofdm->overrun_err);
944 pos += scnprintf(buf + pos, bufsz - pos,
945 fmt_table, "early_overrun_err:",
946 le32_to_cpu(ofdm->early_overrun_err),
947 accum_ofdm->early_overrun_err,
948 delta_ofdm->early_overrun_err,
949 max_ofdm->early_overrun_err);
950 pos += scnprintf(buf + pos, bufsz - pos,
951 fmt_table, "crc32_good:",
952 le32_to_cpu(ofdm->crc32_good),
953 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
954 max_ofdm->crc32_good);
955 pos += scnprintf(buf + pos, bufsz - pos,
956 fmt_table, "false_alarm_cnt:",
957 le32_to_cpu(ofdm->false_alarm_cnt),
958 accum_ofdm->false_alarm_cnt,
959 delta_ofdm->false_alarm_cnt,
960 max_ofdm->false_alarm_cnt);
961 pos += scnprintf(buf + pos, bufsz - pos,
962 fmt_table, "fina_sync_err_cnt:",
963 le32_to_cpu(ofdm->fina_sync_err_cnt),
964 accum_ofdm->fina_sync_err_cnt,
965 delta_ofdm->fina_sync_err_cnt,
966 max_ofdm->fina_sync_err_cnt);
967 pos += scnprintf(buf + pos, bufsz - pos,
968 fmt_table, "sfd_timeout:",
969 le32_to_cpu(ofdm->sfd_timeout),
970 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
971 max_ofdm->sfd_timeout);
972 pos += scnprintf(buf + pos, bufsz - pos,
973 fmt_table, "fina_timeout:",
974 le32_to_cpu(ofdm->fina_timeout),
975 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
976 max_ofdm->fina_timeout);
977 pos += scnprintf(buf + pos, bufsz - pos,
978 fmt_table, "unresponded_rts:",
979 le32_to_cpu(ofdm->unresponded_rts),
980 accum_ofdm->unresponded_rts,
981 delta_ofdm->unresponded_rts,
982 max_ofdm->unresponded_rts);
983 pos += scnprintf(buf + pos, bufsz - pos,
984 fmt_table, "rxe_frame_lmt_ovrun:",
985 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
986 accum_ofdm->rxe_frame_limit_overrun,
987 delta_ofdm->rxe_frame_limit_overrun,
988 max_ofdm->rxe_frame_limit_overrun);
989 pos += scnprintf(buf + pos, bufsz - pos,
990 fmt_table, "sent_ack_cnt:",
991 le32_to_cpu(ofdm->sent_ack_cnt),
992 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
993 max_ofdm->sent_ack_cnt);
994 pos += scnprintf(buf + pos, bufsz - pos,
995 fmt_table, "sent_cts_cnt:",
996 le32_to_cpu(ofdm->sent_cts_cnt),
997 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
998 max_ofdm->sent_cts_cnt);
999 pos += scnprintf(buf + pos, bufsz - pos,
1000 fmt_table, "sent_ba_rsp_cnt:",
1001 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
1002 accum_ofdm->sent_ba_rsp_cnt,
1003 delta_ofdm->sent_ba_rsp_cnt,
1004 max_ofdm->sent_ba_rsp_cnt);
1005 pos += scnprintf(buf + pos, bufsz - pos,
1006 fmt_table, "dsp_self_kill:",
1007 le32_to_cpu(ofdm->dsp_self_kill),
1008 accum_ofdm->dsp_self_kill,
1009 delta_ofdm->dsp_self_kill,
1010 max_ofdm->dsp_self_kill);
1011 pos += scnprintf(buf + pos, bufsz - pos,
1012 fmt_table, "mh_format_err:",
1013 le32_to_cpu(ofdm->mh_format_err),
1014 accum_ofdm->mh_format_err,
1015 delta_ofdm->mh_format_err,
1016 max_ofdm->mh_format_err);
1017 pos += scnprintf(buf + pos, bufsz - pos,
1018 fmt_table, "re_acq_main_rssi_sum:",
1019 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
1020 accum_ofdm->re_acq_main_rssi_sum,
1021 delta_ofdm->re_acq_main_rssi_sum,
1022 max_ofdm->re_acq_main_rssi_sum);
1023
1024 pos += scnprintf(buf + pos, bufsz - pos,
1025 fmt_header, "Statistics_Rx - CCK:");
1026 pos += scnprintf(buf + pos, bufsz - pos,
1027 fmt_table, "ina_cnt:",
1028 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
1029 delta_cck->ina_cnt, max_cck->ina_cnt);
1030 pos += scnprintf(buf + pos, bufsz - pos,
1031 fmt_table, "fina_cnt:",
1032 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
1033 delta_cck->fina_cnt, max_cck->fina_cnt);
1034 pos += scnprintf(buf + pos, bufsz - pos,
1035 fmt_table, "plcp_err:",
1036 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1037 delta_cck->plcp_err, max_cck->plcp_err);
1038 pos += scnprintf(buf + pos, bufsz - pos,
1039 fmt_table, "crc32_err:",
1040 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1041 delta_cck->crc32_err, max_cck->crc32_err);
1042 pos += scnprintf(buf + pos, bufsz - pos,
1043 fmt_table, "overrun_err:",
1044 le32_to_cpu(cck->overrun_err),
1045 accum_cck->overrun_err, delta_cck->overrun_err,
1046 max_cck->overrun_err);
1047 pos += scnprintf(buf + pos, bufsz - pos,
1048 fmt_table, "early_overrun_err:",
1049 le32_to_cpu(cck->early_overrun_err),
1050 accum_cck->early_overrun_err,
1051 delta_cck->early_overrun_err,
1052 max_cck->early_overrun_err);
1053 pos += scnprintf(buf + pos, bufsz - pos,
1054 fmt_table, "crc32_good:",
1055 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1056 delta_cck->crc32_good, max_cck->crc32_good);
1057 pos += scnprintf(buf + pos, bufsz - pos,
1058 fmt_table, "false_alarm_cnt:",
1059 le32_to_cpu(cck->false_alarm_cnt),
1060 accum_cck->false_alarm_cnt,
1061 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1062 pos += scnprintf(buf + pos, bufsz - pos,
1063 fmt_table, "fina_sync_err_cnt:",
1064 le32_to_cpu(cck->fina_sync_err_cnt),
1065 accum_cck->fina_sync_err_cnt,
1066 delta_cck->fina_sync_err_cnt,
1067 max_cck->fina_sync_err_cnt);
1068 pos += scnprintf(buf + pos, bufsz - pos,
1069 fmt_table, "sfd_timeout:",
1070 le32_to_cpu(cck->sfd_timeout),
1071 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
1072 max_cck->sfd_timeout);
1073 pos += scnprintf(buf + pos, bufsz - pos,
1074 fmt_table, "fina_timeout:",
1075 le32_to_cpu(cck->fina_timeout),
1076 accum_cck->fina_timeout, delta_cck->fina_timeout,
1077 max_cck->fina_timeout);
1078 pos += scnprintf(buf + pos, bufsz - pos,
1079 fmt_table, "unresponded_rts:",
1080 le32_to_cpu(cck->unresponded_rts),
1081 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
1082 max_cck->unresponded_rts);
1083 pos += scnprintf(buf + pos, bufsz - pos,
1084 fmt_table, "rxe_frame_lmt_ovrun:",
1085 le32_to_cpu(cck->rxe_frame_limit_overrun),
1086 accum_cck->rxe_frame_limit_overrun,
1087 delta_cck->rxe_frame_limit_overrun,
1088 max_cck->rxe_frame_limit_overrun);
1089 pos += scnprintf(buf + pos, bufsz - pos,
1090 fmt_table, "sent_ack_cnt:",
1091 le32_to_cpu(cck->sent_ack_cnt),
1092 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
1093 max_cck->sent_ack_cnt);
1094 pos += scnprintf(buf + pos, bufsz - pos,
1095 fmt_table, "sent_cts_cnt:",
1096 le32_to_cpu(cck->sent_cts_cnt),
1097 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
1098 max_cck->sent_cts_cnt);
1099 pos += scnprintf(buf + pos, bufsz - pos,
1100 fmt_table, "sent_ba_rsp_cnt:",
1101 le32_to_cpu(cck->sent_ba_rsp_cnt),
1102 accum_cck->sent_ba_rsp_cnt,
1103 delta_cck->sent_ba_rsp_cnt,
1104 max_cck->sent_ba_rsp_cnt);
1105 pos += scnprintf(buf + pos, bufsz - pos,
1106 fmt_table, "dsp_self_kill:",
1107 le32_to_cpu(cck->dsp_self_kill),
1108 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
1109 max_cck->dsp_self_kill);
1110 pos += scnprintf(buf + pos, bufsz - pos,
1111 fmt_table, "mh_format_err:",
1112 le32_to_cpu(cck->mh_format_err),
1113 accum_cck->mh_format_err, delta_cck->mh_format_err,
1114 max_cck->mh_format_err);
1115 pos += scnprintf(buf + pos, bufsz - pos,
1116 fmt_table, "re_acq_main_rssi_sum:",
1117 le32_to_cpu(cck->re_acq_main_rssi_sum),
1118 accum_cck->re_acq_main_rssi_sum,
1119 delta_cck->re_acq_main_rssi_sum,
1120 max_cck->re_acq_main_rssi_sum);
1121
1122 pos += scnprintf(buf + pos, bufsz - pos,
1123 fmt_header, "Statistics_Rx - GENERAL:");
1124 pos += scnprintf(buf + pos, bufsz - pos,
1125 fmt_table, "bogus_cts:",
1126 le32_to_cpu(general->bogus_cts),
1127 accum_general->bogus_cts, delta_general->bogus_cts,
1128 max_general->bogus_cts);
1129 pos += scnprintf(buf + pos, bufsz - pos,
1130 fmt_table, "bogus_ack:",
1131 le32_to_cpu(general->bogus_ack),
1132 accum_general->bogus_ack, delta_general->bogus_ack,
1133 max_general->bogus_ack);
1134 pos += scnprintf(buf + pos, bufsz - pos,
1135 fmt_table, "non_bssid_frames:",
1136 le32_to_cpu(general->non_bssid_frames),
1137 accum_general->non_bssid_frames,
1138 delta_general->non_bssid_frames,
1139 max_general->non_bssid_frames);
1140 pos += scnprintf(buf + pos, bufsz - pos,
1141 fmt_table, "filtered_frames:",
1142 le32_to_cpu(general->filtered_frames),
1143 accum_general->filtered_frames,
1144 delta_general->filtered_frames,
1145 max_general->filtered_frames);
1146 pos += scnprintf(buf + pos, bufsz - pos,
1147 fmt_table, "non_channel_beacons:",
1148 le32_to_cpu(general->non_channel_beacons),
1149 accum_general->non_channel_beacons,
1150 delta_general->non_channel_beacons,
1151 max_general->non_channel_beacons);
1152 pos += scnprintf(buf + pos, bufsz - pos,
1153 fmt_table, "channel_beacons:",
1154 le32_to_cpu(general->channel_beacons),
1155 accum_general->channel_beacons,
1156 delta_general->channel_beacons,
1157 max_general->channel_beacons);
1158 pos += scnprintf(buf + pos, bufsz - pos,
1159 fmt_table, "num_missed_bcon:",
1160 le32_to_cpu(general->num_missed_bcon),
1161 accum_general->num_missed_bcon,
1162 delta_general->num_missed_bcon,
1163 max_general->num_missed_bcon);
1164 pos += scnprintf(buf + pos, bufsz - pos,
1165 fmt_table, "adc_rx_saturation_time:",
1166 le32_to_cpu(general->adc_rx_saturation_time),
1167 accum_general->adc_rx_saturation_time,
1168 delta_general->adc_rx_saturation_time,
1169 max_general->adc_rx_saturation_time);
1170 pos += scnprintf(buf + pos, bufsz - pos,
1171 fmt_table, "ina_detect_search_tm:",
1172 le32_to_cpu(general->ina_detection_search_time),
1173 accum_general->ina_detection_search_time,
1174 delta_general->ina_detection_search_time,
1175 max_general->ina_detection_search_time);
1176 pos += scnprintf(buf + pos, bufsz - pos,
1177 fmt_table, "beacon_silence_rssi_a:",
1178 le32_to_cpu(general->beacon_silence_rssi_a),
1179 accum_general->beacon_silence_rssi_a,
1180 delta_general->beacon_silence_rssi_a,
1181 max_general->beacon_silence_rssi_a);
1182 pos += scnprintf(buf + pos, bufsz - pos,
1183 fmt_table, "beacon_silence_rssi_b:",
1184 le32_to_cpu(general->beacon_silence_rssi_b),
1185 accum_general->beacon_silence_rssi_b,
1186 delta_general->beacon_silence_rssi_b,
1187 max_general->beacon_silence_rssi_b);
1188 pos += scnprintf(buf + pos, bufsz - pos,
1189 fmt_table, "beacon_silence_rssi_c:",
1190 le32_to_cpu(general->beacon_silence_rssi_c),
1191 accum_general->beacon_silence_rssi_c,
1192 delta_general->beacon_silence_rssi_c,
1193 max_general->beacon_silence_rssi_c);
1194 pos += scnprintf(buf + pos, bufsz - pos,
1195 fmt_table, "interference_data_flag:",
1196 le32_to_cpu(general->interference_data_flag),
1197 accum_general->interference_data_flag,
1198 delta_general->interference_data_flag,
1199 max_general->interference_data_flag);
1200 pos += scnprintf(buf + pos, bufsz - pos,
1201 fmt_table, "channel_load:",
1202 le32_to_cpu(general->channel_load),
1203 accum_general->channel_load,
1204 delta_general->channel_load,
1205 max_general->channel_load);
1206 pos += scnprintf(buf + pos, bufsz - pos,
1207 fmt_table, "dsp_false_alarms:",
1208 le32_to_cpu(general->dsp_false_alarms),
1209 accum_general->dsp_false_alarms,
1210 delta_general->dsp_false_alarms,
1211 max_general->dsp_false_alarms);
1212 pos += scnprintf(buf + pos, bufsz - pos,
1213 fmt_table, "beacon_rssi_a:",
1214 le32_to_cpu(general->beacon_rssi_a),
1215 accum_general->beacon_rssi_a,
1216 delta_general->beacon_rssi_a,
1217 max_general->beacon_rssi_a);
1218 pos += scnprintf(buf + pos, bufsz - pos,
1219 fmt_table, "beacon_rssi_b:",
1220 le32_to_cpu(general->beacon_rssi_b),
1221 accum_general->beacon_rssi_b,
1222 delta_general->beacon_rssi_b,
1223 max_general->beacon_rssi_b);
1224 pos += scnprintf(buf + pos, bufsz - pos,
1225 fmt_table, "beacon_rssi_c:",
1226 le32_to_cpu(general->beacon_rssi_c),
1227 accum_general->beacon_rssi_c,
1228 delta_general->beacon_rssi_c,
1229 max_general->beacon_rssi_c);
1230 pos += scnprintf(buf + pos, bufsz - pos,
1231 fmt_table, "beacon_energy_a:",
1232 le32_to_cpu(general->beacon_energy_a),
1233 accum_general->beacon_energy_a,
1234 delta_general->beacon_energy_a,
1235 max_general->beacon_energy_a);
1236 pos += scnprintf(buf + pos, bufsz - pos,
1237 fmt_table, "beacon_energy_b:",
1238 le32_to_cpu(general->beacon_energy_b),
1239 accum_general->beacon_energy_b,
1240 delta_general->beacon_energy_b,
1241 max_general->beacon_energy_b);
1242 pos += scnprintf(buf + pos, bufsz - pos,
1243 fmt_table, "beacon_energy_c:",
1244 le32_to_cpu(general->beacon_energy_c),
1245 accum_general->beacon_energy_c,
1246 delta_general->beacon_energy_c,
1247 max_general->beacon_energy_c);
1248
1249 pos += scnprintf(buf + pos, bufsz - pos,
1250 fmt_header, "Statistics_Rx - OFDM_HT:");
1251 pos += scnprintf(buf + pos, bufsz - pos,
1252 fmt_table, "plcp_err:",
1253 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1254 delta_ht->plcp_err, max_ht->plcp_err);
1255 pos += scnprintf(buf + pos, bufsz - pos,
1256 fmt_table, "overrun_err:",
1257 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1258 delta_ht->overrun_err, max_ht->overrun_err);
1259 pos += scnprintf(buf + pos, bufsz - pos,
1260 fmt_table, "early_overrun_err:",
1261 le32_to_cpu(ht->early_overrun_err),
1262 accum_ht->early_overrun_err,
1263 delta_ht->early_overrun_err,
1264 max_ht->early_overrun_err);
1265 pos += scnprintf(buf + pos, bufsz - pos,
1266 fmt_table, "crc32_good:",
1267 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1268 delta_ht->crc32_good, max_ht->crc32_good);
1269 pos += scnprintf(buf + pos, bufsz - pos,
1270 fmt_table, "crc32_err:",
1271 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1272 delta_ht->crc32_err, max_ht->crc32_err);
1273 pos += scnprintf(buf + pos, bufsz - pos,
1274 fmt_table, "mh_format_err:",
1275 le32_to_cpu(ht->mh_format_err),
1276 accum_ht->mh_format_err,
1277 delta_ht->mh_format_err, max_ht->mh_format_err);
1278 pos += scnprintf(buf + pos, bufsz - pos,
1279 fmt_table, "agg_crc32_good:",
1280 le32_to_cpu(ht->agg_crc32_good),
1281 accum_ht->agg_crc32_good,
1282 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1283 pos += scnprintf(buf + pos, bufsz - pos,
1284 fmt_table, "agg_mpdu_cnt:",
1285 le32_to_cpu(ht->agg_mpdu_cnt),
1286 accum_ht->agg_mpdu_cnt,
1287 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1288 pos += scnprintf(buf + pos, bufsz - pos,
1289 fmt_table, "agg_cnt:",
1290 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1291 delta_ht->agg_cnt, max_ht->agg_cnt);
1292 pos += scnprintf(buf + pos, bufsz - pos,
1293 fmt_table, "unsupport_mcs:",
1294 le32_to_cpu(ht->unsupport_mcs),
1295 accum_ht->unsupport_mcs,
1296 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1297
1298 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1299 kfree(buf);
1300 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001301}
1302
1303static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1304 char __user *user_buf,
1305 size_t count, loff_t *ppos)
1306{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001307 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001308 int pos = 0;
1309 char *buf;
1310 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1311 ssize_t ret;
1312 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1313
1314 if (!iwl_is_alive(priv))
1315 return -EAGAIN;
1316
1317 buf = kzalloc(bufsz, GFP_KERNEL);
1318 if (!buf) {
1319 IWL_ERR(priv, "Can not allocate Buffer\n");
1320 return -ENOMEM;
1321 }
1322
1323 /* the statistic information display here is based on
1324 * the last statistics notification from uCode
1325 * might not reflect the current uCode activity
1326 */
1327 tx = &priv->statistics.tx;
1328 accum_tx = &priv->accum_stats.tx;
1329 delta_tx = &priv->delta_stats.tx;
1330 max_tx = &priv->max_delta_stats.tx;
1331
1332 pos += iwl_statistics_flag(priv, buf, bufsz);
1333 pos += scnprintf(buf + pos, bufsz - pos,
1334 fmt_header, "Statistics_Tx:");
1335 pos += scnprintf(buf + pos, bufsz - pos,
1336 fmt_table, "preamble:",
1337 le32_to_cpu(tx->preamble_cnt),
1338 accum_tx->preamble_cnt,
1339 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1340 pos += scnprintf(buf + pos, bufsz - pos,
1341 fmt_table, "rx_detected_cnt:",
1342 le32_to_cpu(tx->rx_detected_cnt),
1343 accum_tx->rx_detected_cnt,
1344 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1345 pos += scnprintf(buf + pos, bufsz - pos,
1346 fmt_table, "bt_prio_defer_cnt:",
1347 le32_to_cpu(tx->bt_prio_defer_cnt),
1348 accum_tx->bt_prio_defer_cnt,
1349 delta_tx->bt_prio_defer_cnt,
1350 max_tx->bt_prio_defer_cnt);
1351 pos += scnprintf(buf + pos, bufsz - pos,
1352 fmt_table, "bt_prio_kill_cnt:",
1353 le32_to_cpu(tx->bt_prio_kill_cnt),
1354 accum_tx->bt_prio_kill_cnt,
1355 delta_tx->bt_prio_kill_cnt,
1356 max_tx->bt_prio_kill_cnt);
1357 pos += scnprintf(buf + pos, bufsz - pos,
1358 fmt_table, "few_bytes_cnt:",
1359 le32_to_cpu(tx->few_bytes_cnt),
1360 accum_tx->few_bytes_cnt,
1361 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1362 pos += scnprintf(buf + pos, bufsz - pos,
1363 fmt_table, "cts_timeout:",
1364 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1365 delta_tx->cts_timeout, max_tx->cts_timeout);
1366 pos += scnprintf(buf + pos, bufsz - pos,
1367 fmt_table, "ack_timeout:",
1368 le32_to_cpu(tx->ack_timeout),
1369 accum_tx->ack_timeout,
1370 delta_tx->ack_timeout, max_tx->ack_timeout);
1371 pos += scnprintf(buf + pos, bufsz - pos,
1372 fmt_table, "expected_ack_cnt:",
1373 le32_to_cpu(tx->expected_ack_cnt),
1374 accum_tx->expected_ack_cnt,
1375 delta_tx->expected_ack_cnt,
1376 max_tx->expected_ack_cnt);
1377 pos += scnprintf(buf + pos, bufsz - pos,
1378 fmt_table, "actual_ack_cnt:",
1379 le32_to_cpu(tx->actual_ack_cnt),
1380 accum_tx->actual_ack_cnt,
1381 delta_tx->actual_ack_cnt,
1382 max_tx->actual_ack_cnt);
1383 pos += scnprintf(buf + pos, bufsz - pos,
1384 fmt_table, "dump_msdu_cnt:",
1385 le32_to_cpu(tx->dump_msdu_cnt),
1386 accum_tx->dump_msdu_cnt,
1387 delta_tx->dump_msdu_cnt,
1388 max_tx->dump_msdu_cnt);
1389 pos += scnprintf(buf + pos, bufsz - pos,
1390 fmt_table, "abort_nxt_frame_mismatch:",
1391 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1392 accum_tx->burst_abort_next_frame_mismatch_cnt,
1393 delta_tx->burst_abort_next_frame_mismatch_cnt,
1394 max_tx->burst_abort_next_frame_mismatch_cnt);
1395 pos += scnprintf(buf + pos, bufsz - pos,
1396 fmt_table, "abort_missing_nxt_frame:",
1397 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1398 accum_tx->burst_abort_missing_next_frame_cnt,
1399 delta_tx->burst_abort_missing_next_frame_cnt,
1400 max_tx->burst_abort_missing_next_frame_cnt);
1401 pos += scnprintf(buf + pos, bufsz - pos,
1402 fmt_table, "cts_timeout_collision:",
1403 le32_to_cpu(tx->cts_timeout_collision),
1404 accum_tx->cts_timeout_collision,
1405 delta_tx->cts_timeout_collision,
1406 max_tx->cts_timeout_collision);
1407 pos += scnprintf(buf + pos, bufsz - pos,
1408 fmt_table, "ack_ba_timeout_collision:",
1409 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1410 accum_tx->ack_or_ba_timeout_collision,
1411 delta_tx->ack_or_ba_timeout_collision,
1412 max_tx->ack_or_ba_timeout_collision);
1413 pos += scnprintf(buf + pos, bufsz - pos,
1414 fmt_table, "agg ba_timeout:",
1415 le32_to_cpu(tx->agg.ba_timeout),
1416 accum_tx->agg.ba_timeout,
1417 delta_tx->agg.ba_timeout,
1418 max_tx->agg.ba_timeout);
1419 pos += scnprintf(buf + pos, bufsz - pos,
1420 fmt_table, "agg ba_resched_frames:",
1421 le32_to_cpu(tx->agg.ba_reschedule_frames),
1422 accum_tx->agg.ba_reschedule_frames,
1423 delta_tx->agg.ba_reschedule_frames,
1424 max_tx->agg.ba_reschedule_frames);
1425 pos += scnprintf(buf + pos, bufsz - pos,
1426 fmt_table, "agg scd_query_agg_frame:",
1427 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1428 accum_tx->agg.scd_query_agg_frame_cnt,
1429 delta_tx->agg.scd_query_agg_frame_cnt,
1430 max_tx->agg.scd_query_agg_frame_cnt);
1431 pos += scnprintf(buf + pos, bufsz - pos,
1432 fmt_table, "agg scd_query_no_agg:",
1433 le32_to_cpu(tx->agg.scd_query_no_agg),
1434 accum_tx->agg.scd_query_no_agg,
1435 delta_tx->agg.scd_query_no_agg,
1436 max_tx->agg.scd_query_no_agg);
1437 pos += scnprintf(buf + pos, bufsz - pos,
1438 fmt_table, "agg scd_query_agg:",
1439 le32_to_cpu(tx->agg.scd_query_agg),
1440 accum_tx->agg.scd_query_agg,
1441 delta_tx->agg.scd_query_agg,
1442 max_tx->agg.scd_query_agg);
1443 pos += scnprintf(buf + pos, bufsz - pos,
1444 fmt_table, "agg scd_query_mismatch:",
1445 le32_to_cpu(tx->agg.scd_query_mismatch),
1446 accum_tx->agg.scd_query_mismatch,
1447 delta_tx->agg.scd_query_mismatch,
1448 max_tx->agg.scd_query_mismatch);
1449 pos += scnprintf(buf + pos, bufsz - pos,
1450 fmt_table, "agg frame_not_ready:",
1451 le32_to_cpu(tx->agg.frame_not_ready),
1452 accum_tx->agg.frame_not_ready,
1453 delta_tx->agg.frame_not_ready,
1454 max_tx->agg.frame_not_ready);
1455 pos += scnprintf(buf + pos, bufsz - pos,
1456 fmt_table, "agg underrun:",
1457 le32_to_cpu(tx->agg.underrun),
1458 accum_tx->agg.underrun,
1459 delta_tx->agg.underrun, max_tx->agg.underrun);
1460 pos += scnprintf(buf + pos, bufsz - pos,
1461 fmt_table, "agg bt_prio_kill:",
1462 le32_to_cpu(tx->agg.bt_prio_kill),
1463 accum_tx->agg.bt_prio_kill,
1464 delta_tx->agg.bt_prio_kill,
1465 max_tx->agg.bt_prio_kill);
1466 pos += scnprintf(buf + pos, bufsz - pos,
1467 fmt_table, "agg rx_ba_rsp_cnt:",
1468 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1469 accum_tx->agg.rx_ba_rsp_cnt,
1470 delta_tx->agg.rx_ba_rsp_cnt,
1471 max_tx->agg.rx_ba_rsp_cnt);
1472
1473 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
1474 pos += scnprintf(buf + pos, bufsz - pos,
1475 "tx power: (1/2 dB step)\n");
1476 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
1477 pos += scnprintf(buf + pos, bufsz - pos,
1478 fmt_hex, "antenna A:",
1479 tx->tx_power.ant_a);
1480 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
1481 pos += scnprintf(buf + pos, bufsz - pos,
1482 fmt_hex, "antenna B:",
1483 tx->tx_power.ant_b);
1484 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
1485 pos += scnprintf(buf + pos, bufsz - pos,
1486 fmt_hex, "antenna C:",
1487 tx->tx_power.ant_c);
1488 }
1489 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1490 kfree(buf);
1491 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001492}
1493
1494static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1495 char __user *user_buf,
1496 size_t count, loff_t *ppos)
1497{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001498 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001499 int pos = 0;
1500 char *buf;
1501 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1502 ssize_t ret;
1503 struct statistics_general_common *general, *accum_general;
1504 struct statistics_general_common *delta_general, *max_general;
1505 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1506 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1507
1508 if (!iwl_is_alive(priv))
1509 return -EAGAIN;
1510
1511 buf = kzalloc(bufsz, GFP_KERNEL);
1512 if (!buf) {
1513 IWL_ERR(priv, "Can not allocate Buffer\n");
1514 return -ENOMEM;
1515 }
1516
1517 /* the statistic information display here is based on
1518 * the last statistics notification from uCode
1519 * might not reflect the current uCode activity
1520 */
1521 general = &priv->statistics.common;
1522 dbg = &priv->statistics.common.dbg;
1523 div = &priv->statistics.common.div;
1524 accum_general = &priv->accum_stats.common;
1525 accum_dbg = &priv->accum_stats.common.dbg;
1526 accum_div = &priv->accum_stats.common.div;
1527 delta_general = &priv->delta_stats.common;
1528 max_general = &priv->max_delta_stats.common;
1529 delta_dbg = &priv->delta_stats.common.dbg;
1530 max_dbg = &priv->max_delta_stats.common.dbg;
1531 delta_div = &priv->delta_stats.common.div;
1532 max_div = &priv->max_delta_stats.common.div;
1533
1534 pos += iwl_statistics_flag(priv, buf, bufsz);
1535 pos += scnprintf(buf + pos, bufsz - pos,
1536 fmt_header, "Statistics_General:");
1537 pos += scnprintf(buf + pos, bufsz - pos,
1538 fmt_value, "temperature:",
1539 le32_to_cpu(general->temperature));
1540 pos += scnprintf(buf + pos, bufsz - pos,
1541 fmt_value, "temperature_m:",
1542 le32_to_cpu(general->temperature_m));
1543 pos += scnprintf(buf + pos, bufsz - pos,
1544 fmt_value, "ttl_timestamp:",
1545 le32_to_cpu(general->ttl_timestamp));
1546 pos += scnprintf(buf + pos, bufsz - pos,
1547 fmt_table, "burst_check:",
1548 le32_to_cpu(dbg->burst_check),
1549 accum_dbg->burst_check,
1550 delta_dbg->burst_check, max_dbg->burst_check);
1551 pos += scnprintf(buf + pos, bufsz - pos,
1552 fmt_table, "burst_count:",
1553 le32_to_cpu(dbg->burst_count),
1554 accum_dbg->burst_count,
1555 delta_dbg->burst_count, max_dbg->burst_count);
1556 pos += scnprintf(buf + pos, bufsz - pos,
1557 fmt_table, "wait_for_silence_timeout_count:",
1558 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
1559 accum_dbg->wait_for_silence_timeout_cnt,
1560 delta_dbg->wait_for_silence_timeout_cnt,
1561 max_dbg->wait_for_silence_timeout_cnt);
1562 pos += scnprintf(buf + pos, bufsz - pos,
1563 fmt_table, "sleep_time:",
1564 le32_to_cpu(general->sleep_time),
1565 accum_general->sleep_time,
1566 delta_general->sleep_time, max_general->sleep_time);
1567 pos += scnprintf(buf + pos, bufsz - pos,
1568 fmt_table, "slots_out:",
1569 le32_to_cpu(general->slots_out),
1570 accum_general->slots_out,
1571 delta_general->slots_out, max_general->slots_out);
1572 pos += scnprintf(buf + pos, bufsz - pos,
1573 fmt_table, "slots_idle:",
1574 le32_to_cpu(general->slots_idle),
1575 accum_general->slots_idle,
1576 delta_general->slots_idle, max_general->slots_idle);
1577 pos += scnprintf(buf + pos, bufsz - pos,
1578 fmt_table, "tx_on_a:",
1579 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1580 delta_div->tx_on_a, max_div->tx_on_a);
1581 pos += scnprintf(buf + pos, bufsz - pos,
1582 fmt_table, "tx_on_b:",
1583 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1584 delta_div->tx_on_b, max_div->tx_on_b);
1585 pos += scnprintf(buf + pos, bufsz - pos,
1586 fmt_table, "exec_time:",
1587 le32_to_cpu(div->exec_time), accum_div->exec_time,
1588 delta_div->exec_time, max_div->exec_time);
1589 pos += scnprintf(buf + pos, bufsz - pos,
1590 fmt_table, "probe_time:",
1591 le32_to_cpu(div->probe_time), accum_div->probe_time,
1592 delta_div->probe_time, max_div->probe_time);
1593 pos += scnprintf(buf + pos, bufsz - pos,
1594 fmt_table, "rx_enable_counter:",
1595 le32_to_cpu(general->rx_enable_counter),
1596 accum_general->rx_enable_counter,
1597 delta_general->rx_enable_counter,
1598 max_general->rx_enable_counter);
1599 pos += scnprintf(buf + pos, bufsz - pos,
1600 fmt_table, "num_of_sos_states:",
1601 le32_to_cpu(general->num_of_sos_states),
1602 accum_general->num_of_sos_states,
1603 delta_general->num_of_sos_states,
1604 max_general->num_of_sos_states);
1605 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1606 kfree(buf);
1607 return ret;
1608}
1609
1610static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1611 char __user *user_buf,
1612 size_t count, loff_t *ppos)
1613{
1614 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1615 int pos = 0;
1616 char *buf;
1617 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
1618 ssize_t ret;
1619 struct statistics_bt_activity *bt, *accum_bt;
1620
1621 if (!iwl_is_alive(priv))
1622 return -EAGAIN;
1623
1624 if (!priv->bt_enable_flag)
1625 return -EINVAL;
1626
1627 /* make request to uCode to retrieve statistics information */
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001628 mutex_lock(&priv->shrd->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001629 ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001630 mutex_unlock(&priv->shrd->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001631
1632 if (ret) {
1633 IWL_ERR(priv,
1634 "Error sending statistics request: %zd\n", ret);
1635 return -EAGAIN;
1636 }
1637 buf = kzalloc(bufsz, GFP_KERNEL);
1638 if (!buf) {
1639 IWL_ERR(priv, "Can not allocate Buffer\n");
1640 return -ENOMEM;
1641 }
1642
1643 /*
1644 * the statistic information display here is based on
1645 * the last statistics notification from uCode
1646 * might not reflect the current uCode activity
1647 */
1648 bt = &priv->statistics.bt_activity;
1649 accum_bt = &priv->accum_stats.bt_activity;
1650
1651 pos += iwl_statistics_flag(priv, buf, bufsz);
1652 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
1653 pos += scnprintf(buf + pos, bufsz - pos,
1654 "\t\t\tcurrent\t\t\taccumulative\n");
1655 pos += scnprintf(buf + pos, bufsz - pos,
1656 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1657 le32_to_cpu(bt->hi_priority_tx_req_cnt),
1658 accum_bt->hi_priority_tx_req_cnt);
1659 pos += scnprintf(buf + pos, bufsz - pos,
1660 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1661 le32_to_cpu(bt->hi_priority_tx_denied_cnt),
1662 accum_bt->hi_priority_tx_denied_cnt);
1663 pos += scnprintf(buf + pos, bufsz - pos,
1664 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1665 le32_to_cpu(bt->lo_priority_tx_req_cnt),
1666 accum_bt->lo_priority_tx_req_cnt);
1667 pos += scnprintf(buf + pos, bufsz - pos,
1668 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1669 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
1670 accum_bt->lo_priority_tx_denied_cnt);
1671 pos += scnprintf(buf + pos, bufsz - pos,
1672 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1673 le32_to_cpu(bt->hi_priority_rx_req_cnt),
1674 accum_bt->hi_priority_rx_req_cnt);
1675 pos += scnprintf(buf + pos, bufsz - pos,
1676 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1677 le32_to_cpu(bt->hi_priority_rx_denied_cnt),
1678 accum_bt->hi_priority_rx_denied_cnt);
1679 pos += scnprintf(buf + pos, bufsz - pos,
1680 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1681 le32_to_cpu(bt->lo_priority_rx_req_cnt),
1682 accum_bt->lo_priority_rx_req_cnt);
1683 pos += scnprintf(buf + pos, bufsz - pos,
1684 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1685 le32_to_cpu(bt->lo_priority_rx_denied_cnt),
1686 accum_bt->lo_priority_rx_denied_cnt);
1687
1688 pos += scnprintf(buf + pos, bufsz - pos,
1689 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1690 le32_to_cpu(priv->statistics.num_bt_kills),
1691 priv->statistics.accum_num_bt_kills);
1692
1693 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1694 kfree(buf);
1695 return ret;
1696}
1697
1698static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1699 char __user *user_buf,
1700 size_t count, loff_t *ppos)
1701{
1702 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1703 int pos = 0;
1704 char *buf;
1705 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
1706 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
1707 ssize_t ret;
1708
1709 if (!iwl_is_alive(priv))
1710 return -EAGAIN;
1711
1712 buf = kzalloc(bufsz, GFP_KERNEL);
1713 if (!buf) {
1714 IWL_ERR(priv, "Can not allocate Buffer\n");
1715 return -ENOMEM;
1716 }
1717
1718 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1719 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1720 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001721 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001722 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1723 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001724 priv->reply_tx_stats.pp_few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001725 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1726 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001727 priv->reply_tx_stats.pp_bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001728 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1729 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001730 priv->reply_tx_stats.pp_quiet_period);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001731 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1732 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001733 priv->reply_tx_stats.pp_calc_ttak);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001734 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1735 iwl_get_tx_fail_reason(
1736 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001737 priv->reply_tx_stats.int_crossed_retry);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001738 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1739 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001740 priv->reply_tx_stats.short_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001741 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1742 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001743 priv->reply_tx_stats.long_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001744 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1745 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001746 priv->reply_tx_stats.fifo_underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001747 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1748 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001749 priv->reply_tx_stats.drain_flow);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001750 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1751 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001752 priv->reply_tx_stats.rfkill_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001753 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1754 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001755 priv->reply_tx_stats.life_expire);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001756 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1757 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001758 priv->reply_tx_stats.dest_ps);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001759 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1760 iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001761 priv->reply_tx_stats.host_abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001762 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1763 iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001764 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001765 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1766 iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001767 priv->reply_tx_stats.sta_invalid);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001768 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1769 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001770 priv->reply_tx_stats.frag_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001771 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1772 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001773 priv->reply_tx_stats.tid_disable);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001774 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1775 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001776 priv->reply_tx_stats.fifo_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001777 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1778 iwl_get_tx_fail_reason(
1779 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001780 priv->reply_tx_stats.insuff_cf_poll);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001781 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1782 iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001783 priv->reply_tx_stats.fail_hw_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001784 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1785 iwl_get_tx_fail_reason(
1786 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001787 priv->reply_tx_stats.sta_color_mismatch);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001788 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001789 priv->reply_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001790
1791 pos += scnprintf(buf + pos, bufsz - pos,
1792 "\nStatistics_Agg_TX_Error:\n");
1793
1794 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1795 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001796 priv->reply_agg_tx_stats.underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001797 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1798 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001799 priv->reply_agg_tx_stats.bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001800 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1801 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001802 priv->reply_agg_tx_stats.few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001803 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1804 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001805 priv->reply_agg_tx_stats.abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001806 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1807 iwl_get_agg_tx_fail_reason(
1808 AGG_TX_STATE_LAST_SENT_TTL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001809 priv->reply_agg_tx_stats.last_sent_ttl);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001810 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1811 iwl_get_agg_tx_fail_reason(
1812 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001813 priv->reply_agg_tx_stats.last_sent_try);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001814 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1815 iwl_get_agg_tx_fail_reason(
1816 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001817 priv->reply_agg_tx_stats.last_sent_bt_kill);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001818 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1819 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001820 priv->reply_agg_tx_stats.scd_query);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001821 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1822 iwl_get_agg_tx_fail_reason(
1823 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001824 priv->reply_agg_tx_stats.bad_crc32);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001825 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1826 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001827 priv->reply_agg_tx_stats.response);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001828 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1829 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001830 priv->reply_agg_tx_stats.dump_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001831 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1832 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001833 priv->reply_agg_tx_stats.delay_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001834 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001835 priv->reply_agg_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001836
1837 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1838 kfree(buf);
1839 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001840}
1841
Wey-Yi Guy52259352009-08-07 15:41:43 -07001842static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1843 char __user *user_buf,
1844 size_t count, loff_t *ppos) {
1845
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001846 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001847 int pos = 0;
1848 int cnt = 0;
1849 char *buf;
1850 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1851 ssize_t ret;
1852 struct iwl_sensitivity_data *data;
1853
1854 data = &priv->sensitivity_data;
1855 buf = kzalloc(bufsz, GFP_KERNEL);
1856 if (!buf) {
1857 IWL_ERR(priv, "Can not allocate Buffer\n");
1858 return -ENOMEM;
1859 }
1860
1861 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1862 data->auto_corr_ofdm);
1863 pos += scnprintf(buf + pos, bufsz - pos,
1864 "auto_corr_ofdm_mrc:\t\t %u\n",
1865 data->auto_corr_ofdm_mrc);
1866 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1867 data->auto_corr_ofdm_x1);
1868 pos += scnprintf(buf + pos, bufsz - pos,
1869 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1870 data->auto_corr_ofdm_mrc_x1);
1871 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1872 data->auto_corr_cck);
1873 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1874 data->auto_corr_cck_mrc);
1875 pos += scnprintf(buf + pos, bufsz - pos,
1876 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1877 data->last_bad_plcp_cnt_ofdm);
1878 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1879 data->last_fa_cnt_ofdm);
1880 pos += scnprintf(buf + pos, bufsz - pos,
1881 "last_bad_plcp_cnt_cck:\t\t %u\n",
1882 data->last_bad_plcp_cnt_cck);
1883 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1884 data->last_fa_cnt_cck);
1885 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1886 data->nrg_curr_state);
1887 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1888 data->nrg_prev_state);
1889 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1890 for (cnt = 0; cnt < 10; cnt++) {
1891 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1892 data->nrg_value[cnt]);
1893 }
1894 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1895 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1896 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1897 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1898 data->nrg_silence_rssi[cnt]);
1899 }
1900 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1901 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1902 data->nrg_silence_ref);
1903 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1904 data->nrg_energy_idx);
1905 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1906 data->nrg_silence_idx);
1907 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1908 data->nrg_th_cck);
1909 pos += scnprintf(buf + pos, bufsz - pos,
1910 "nrg_auto_corr_silence_diff:\t %u\n",
1911 data->nrg_auto_corr_silence_diff);
1912 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1913 data->num_in_cck_no_fa);
1914 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1915 data->nrg_th_ofdm);
1916
1917 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1918 kfree(buf);
1919 return ret;
1920}
1921
1922
1923static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1924 char __user *user_buf,
1925 size_t count, loff_t *ppos) {
1926
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001927 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001928 int pos = 0;
1929 int cnt = 0;
1930 char *buf;
1931 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1932 ssize_t ret;
1933 struct iwl_chain_noise_data *data;
1934
1935 data = &priv->chain_noise_data;
1936 buf = kzalloc(bufsz, GFP_KERNEL);
1937 if (!buf) {
1938 IWL_ERR(priv, "Can not allocate Buffer\n");
1939 return -ENOMEM;
1940 }
1941
1942 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1943 data->active_chains);
1944 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1945 data->chain_noise_a);
1946 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1947 data->chain_noise_b);
1948 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1949 data->chain_noise_c);
1950 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1951 data->chain_signal_a);
1952 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1953 data->chain_signal_b);
1954 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1955 data->chain_signal_c);
1956 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1957 data->beacon_count);
1958
1959 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1960 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1961 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1962 data->disconn_array[cnt]);
1963 }
1964 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1965 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1966 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1967 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1968 data->delta_gain_code[cnt]);
1969 }
1970 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1971 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1972 data->radio_write);
1973 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1974 data->state);
1975
1976 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1977 kfree(buf);
1978 return ret;
1979}
1980
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001981static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1982 char __user *user_buf,
1983 size_t count, loff_t *ppos)
1984{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001985 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001986 char buf[60];
1987 int pos = 0;
1988 const size_t bufsz = sizeof(buf);
1989 u32 pwrsave_status;
1990
1991 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
1992 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1993
1994 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1995 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1996 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1997 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1998 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1999 "error");
2000
2001 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2002}
2003
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002004static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08002005 const char __user *user_buf,
2006 size_t count, loff_t *ppos)
2007{
2008 struct iwl_priv *priv = file->private_data;
2009 char buf[8];
2010 int buf_size;
2011 int clear;
2012
2013 memset(buf, 0, sizeof(buf));
2014 buf_size = min(count, sizeof(buf) - 1);
2015 if (copy_from_user(buf, user_buf, buf_size))
2016 return -EFAULT;
2017 if (sscanf(buf, "%d", &clear) != 1)
2018 return -EFAULT;
2019
2020 /* make request to uCode to retrieve statistics information */
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07002021 mutex_lock(&priv->shrd->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08002022 iwl_send_statistics_request(priv, CMD_SYNC, true);
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07002023 mutex_unlock(&priv->shrd->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08002024
2025 return count;
2026}
2027
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002028static ssize_t iwl_dbgfs_csr_write(struct file *file,
2029 const char __user *user_buf,
2030 size_t count, loff_t *ppos)
2031{
2032 struct iwl_priv *priv = file->private_data;
2033 char buf[8];
2034 int buf_size;
2035 int csr;
2036
2037 memset(buf, 0, sizeof(buf));
2038 buf_size = min(count, sizeof(buf) - 1);
2039 if (copy_from_user(buf, user_buf, buf_size))
2040 return -EFAULT;
2041 if (sscanf(buf, "%d", &csr) != 1)
2042 return -EFAULT;
2043
Wey-Yi Guy3ecccbc2011-03-29 17:53:15 -07002044 iwl_dump_csr(priv);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002045
2046 return count;
2047}
2048
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002049static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2050 char __user *user_buf,
2051 size_t count, loff_t *ppos) {
2052
Joe Perches57674302010-07-12 13:50:06 -07002053 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002054 int pos = 0;
2055 char buf[128];
2056 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002057
2058 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2059 priv->event_log.ucode_trace ? "On" : "Off");
2060 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
2061 priv->event_log.non_wraps_count);
2062 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
2063 priv->event_log.wraps_once_count);
2064 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2065 priv->event_log.wraps_more_count);
2066
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002067 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002068}
2069
2070static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2071 const char __user *user_buf,
2072 size_t count, loff_t *ppos)
2073{
2074 struct iwl_priv *priv = file->private_data;
2075 char buf[8];
2076 int buf_size;
2077 int trace;
2078
2079 memset(buf, 0, sizeof(buf));
2080 buf_size = min(count, sizeof(buf) - 1);
2081 if (copy_from_user(buf, user_buf, buf_size))
2082 return -EFAULT;
2083 if (sscanf(buf, "%d", &trace) != 1)
2084 return -EFAULT;
2085
2086 if (trace) {
2087 priv->event_log.ucode_trace = true;
2088 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2089 mod_timer(&priv->ucode_trace,
2090 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
2091 } else {
2092 priv->event_log.ucode_trace = false;
2093 del_timer_sync(&priv->ucode_trace);
2094 }
2095
2096 return count;
2097}
2098
Johannes Berg60987202010-02-18 00:36:07 -08002099static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
2100 char __user *user_buf,
2101 size_t count, loff_t *ppos) {
2102
Joe Perches57674302010-07-12 13:50:06 -07002103 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08002104 int len = 0;
2105 char buf[20];
2106
Johannes Berg246ed352010-08-23 10:46:32 +02002107 len = sprintf(buf, "0x%04X\n",
2108 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
Johannes Berg60987202010-02-18 00:36:07 -08002109 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2110}
2111
2112static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
2113 char __user *user_buf,
2114 size_t count, loff_t *ppos) {
2115
Joe Perches57674302010-07-12 13:50:06 -07002116 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08002117 int len = 0;
2118 char buf[20];
2119
2120 len = sprintf(buf, "0x%04X\n",
Johannes Berg246ed352010-08-23 10:46:32 +02002121 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
Johannes Berg60987202010-02-18 00:36:07 -08002122 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2123}
2124
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002125static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
2126 char __user *user_buf,
2127 size_t count, loff_t *ppos)
2128{
Joe Perches57674302010-07-12 13:50:06 -07002129 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002130 char *buf;
2131 int pos = 0;
2132 ssize_t ret = -EFAULT;
2133
Wey-Yi Guy3ecccbc2011-03-29 17:53:15 -07002134 ret = pos = iwl_dump_fh(priv, &buf, true);
2135 if (buf) {
2136 ret = simple_read_from_buffer(user_buf,
2137 count, ppos, buf, pos);
2138 kfree(buf);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002139 }
2140
2141 return ret;
2142}
2143
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002144static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2145 char __user *user_buf,
2146 size_t count, loff_t *ppos) {
2147
2148 struct iwl_priv *priv = file->private_data;
2149 int pos = 0;
2150 char buf[12];
2151 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002152
2153 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2154 priv->missed_beacon_threshold);
2155
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002156 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002157}
2158
2159static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2160 const char __user *user_buf,
2161 size_t count, loff_t *ppos)
2162{
2163 struct iwl_priv *priv = file->private_data;
2164 char buf[8];
2165 int buf_size;
2166 int missed;
2167
2168 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", &missed) != 1)
2173 return -EINVAL;
2174
2175 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2176 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2177 priv->missed_beacon_threshold =
2178 IWL_MISSED_BEACON_THRESHOLD_DEF;
2179 else
2180 priv->missed_beacon_threshold = missed;
2181
2182 return count;
2183}
2184
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002185static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2186 char __user *user_buf,
2187 size_t count, loff_t *ppos) {
2188
Joe Perches57674302010-07-12 13:50:06 -07002189 struct iwl_priv *priv = file->private_data;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002190 int pos = 0;
2191 char buf[12];
2192 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002193
2194 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002195 priv->cfg->base_params->plcp_delta_threshold);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002196
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002197 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002198}
2199
2200static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2201 const char __user *user_buf,
2202 size_t count, loff_t *ppos) {
2203
2204 struct iwl_priv *priv = file->private_data;
2205 char buf[8];
2206 int buf_size;
2207 int plcp;
2208
2209 memset(buf, 0, sizeof(buf));
2210 buf_size = min(count, sizeof(buf) - 1);
2211 if (copy_from_user(buf, user_buf, buf_size))
2212 return -EFAULT;
2213 if (sscanf(buf, "%d", &plcp) != 1)
2214 return -EINVAL;
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002215 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002216 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002217 priv->cfg->base_params->plcp_delta_threshold =
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002218 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002219 else
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002220 priv->cfg->base_params->plcp_delta_threshold = plcp;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002221 return count;
2222}
2223
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002224static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
2225 char __user *user_buf,
2226 size_t count, loff_t *ppos) {
2227
2228 struct iwl_priv *priv = file->private_data;
2229 int i, pos = 0;
2230 char buf[300];
2231 const size_t bufsz = sizeof(buf);
2232 struct iwl_force_reset *force_reset;
2233
2234 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
2235 force_reset = &priv->force_reset[i];
2236 pos += scnprintf(buf + pos, bufsz - pos,
2237 "Force reset method %d\n", i);
2238 pos += scnprintf(buf + pos, bufsz - pos,
2239 "\tnumber of reset request: %d\n",
2240 force_reset->reset_request_count);
2241 pos += scnprintf(buf + pos, bufsz - pos,
2242 "\tnumber of reset request success: %d\n",
2243 force_reset->reset_success_count);
2244 pos += scnprintf(buf + pos, bufsz - pos,
2245 "\tnumber of reset request reject: %d\n",
2246 force_reset->reset_reject_count);
2247 pos += scnprintf(buf + pos, bufsz - pos,
2248 "\treset duration: %lu\n",
2249 force_reset->reset_duration);
2250 }
2251 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2252}
2253
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002254static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
2255 const char __user *user_buf,
2256 size_t count, loff_t *ppos) {
2257
2258 struct iwl_priv *priv = file->private_data;
2259 char buf[8];
2260 int buf_size;
2261 int reset, ret;
2262
2263 memset(buf, 0, sizeof(buf));
2264 buf_size = min(count, sizeof(buf) - 1);
2265 if (copy_from_user(buf, user_buf, buf_size))
2266 return -EFAULT;
2267 if (sscanf(buf, "%d", &reset) != 1)
2268 return -EINVAL;
2269 switch (reset) {
2270 case IWL_RF_RESET:
2271 case IWL_FW_RESET:
Wey-Yi Guyc04f9f22010-06-21 16:52:55 -07002272 ret = iwl_force_reset(priv, reset, true);
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002273 break;
2274 default:
2275 return -EINVAL;
2276 }
2277 return ret ? ret : count;
2278}
2279
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002280static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
2281 const char __user *user_buf,
2282 size_t count, loff_t *ppos) {
2283
2284 struct iwl_priv *priv = file->private_data;
2285 char buf[8];
2286 int buf_size;
2287 int flush;
2288
2289 memset(buf, 0, sizeof(buf));
2290 buf_size = min(count, sizeof(buf) - 1);
2291 if (copy_from_user(buf, user_buf, buf_size))
2292 return -EFAULT;
2293 if (sscanf(buf, "%d", &flush) != 1)
2294 return -EINVAL;
2295
2296 if (iwl_is_rfkill(priv))
2297 return -EFAULT;
2298
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002299 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002300
2301 return count;
2302}
2303
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002304static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file,
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002305 const char __user *user_buf,
2306 size_t count, loff_t *ppos) {
2307
2308 struct iwl_priv *priv = file->private_data;
2309 char buf[8];
2310 int buf_size;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002311 int timeout;
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002312
2313 memset(buf, 0, sizeof(buf));
2314 buf_size = min(count, sizeof(buf) - 1);
2315 if (copy_from_user(buf, user_buf, buf_size))
2316 return -EFAULT;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002317 if (sscanf(buf, "%d", &timeout) != 1)
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002318 return -EINVAL;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002319 if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT)
2320 timeout = IWL_DEF_WD_TIMEOUT;
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002321
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002322 priv->cfg->base_params->wd_timeout = timeout;
2323 iwl_setup_watchdog(priv);
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002324 return count;
2325}
2326
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002327static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
2328 char __user *user_buf,
2329 size_t count, loff_t *ppos) {
2330
2331 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2332 int pos = 0;
2333 char buf[200];
2334 const size_t bufsz = sizeof(buf);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002335
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002336 if (!priv->bt_enable_flag) {
2337 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
Johannes Berg08960de2011-04-05 09:41:53 -07002338 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002339 }
2340 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
2341 priv->bt_enable_flag);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002342 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
2343 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
2344 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
2345 "last traffic notif: %d\n",
Wey-Yi Guy66e863a52010-11-08 14:54:37 -08002346 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002347 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
Wey-Yi Guy187bc4f2011-01-27 13:01:33 -08002348 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2349 priv->bt_ch_announce, priv->kill_ack_mask,
2350 priv->kill_cts_mask);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002351
2352 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
2353 switch (priv->bt_traffic_load) {
2354 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
2355 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
2356 break;
2357 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
2358 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
2359 break;
2360 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
2361 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
2362 break;
2363 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
2364 default:
2365 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
2366 break;
2367 }
2368
Johannes Berg08960de2011-04-05 09:41:53 -07002369 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002370}
2371
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002372static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2373 char __user *user_buf,
2374 size_t count, loff_t *ppos)
2375{
2376 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2377
2378 int pos = 0;
2379 char buf[40];
2380 const size_t bufsz = sizeof(buf);
2381
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002382 if (priv->cfg->ht_params)
2383 pos += scnprintf(buf + pos, bufsz - pos,
2384 "use %s for aggregation\n",
2385 (priv->cfg->ht_params->use_rts_for_aggregation) ?
2386 "rts/cts" : "cts-to-self");
2387 else
2388 pos += scnprintf(buf + pos, bufsz - pos, "N/A");
2389
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002390 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2391}
2392
2393static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2394 const char __user *user_buf,
2395 size_t count, loff_t *ppos) {
2396
2397 struct iwl_priv *priv = file->private_data;
2398 char buf[8];
2399 int buf_size;
2400 int rts;
2401
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002402 if (!priv->cfg->ht_params)
2403 return -EINVAL;
2404
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002405 memset(buf, 0, sizeof(buf));
2406 buf_size = min(count, sizeof(buf) - 1);
2407 if (copy_from_user(buf, user_buf, buf_size))
2408 return -EFAULT;
2409 if (sscanf(buf, "%d", &rts) != 1)
2410 return -EINVAL;
2411 if (rts)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002412 priv->cfg->ht_params->use_rts_for_aggregation = true;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002413 else
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002414 priv->cfg->ht_params->use_rts_for_aggregation = false;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002415 return count;
2416}
2417
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002418DEBUGFS_READ_FILE_OPS(rx_statistics);
2419DEBUGFS_READ_FILE_OPS(tx_statistics);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002420DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2421DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2422DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002423DEBUGFS_READ_FILE_OPS(sensitivity);
2424DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002425DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002426DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2427DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002428DEBUGFS_WRITE_FILE_OPS(csr);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002429DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002430DEBUGFS_READ_FILE_OPS(fh_reg);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002431DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002432DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002433DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
Johannes Berg60987202010-02-18 00:36:07 -08002434DEBUGFS_READ_FILE_OPS(rxon_flags);
2435DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002436DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
Wey-Yi Guyffb7d892010-07-14 08:09:55 -07002437DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002438DEBUGFS_WRITE_FILE_OPS(wd_timeout);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002439DEBUGFS_READ_FILE_OPS(bt_traffic);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002440DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002441DEBUGFS_READ_FILE_OPS(reply_tx_error);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002442
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002443/*
2444 * Create the debugfs files and directories
2445 *
2446 */
2447int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2448{
Zhu Yi95b1a822008-05-29 16:34:50 +08002449 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002450 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002451
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002452 dir_drv = debugfs_create_dir(name, phyd);
2453 if (!dir_drv)
2454 return -ENOMEM;
2455
2456 priv->debugfs_dir = dir_drv;
2457
2458 dir_data = debugfs_create_dir("data", dir_drv);
2459 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002460 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002461 dir_rf = debugfs_create_dir("rf", dir_drv);
2462 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002463 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002464 dir_debug = debugfs_create_dir("debug", dir_drv);
2465 if (!dir_debug)
2466 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002467
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002468 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2469 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
Johannes Bergc8ac61c2011-07-15 13:23:45 -07002470 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002471 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2472 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2473 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
2474 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
2475 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
Wey-Yi Guy23c0fcc2011-04-01 16:29:53 -07002476 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2477 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002478 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2479 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
2480 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
2481 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002482 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2483 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
2484 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
2485 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
2486 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
2487 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002488 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002489 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002490 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2491 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2492 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002493 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002494 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002495
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002496 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2497 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
Wey-Yi Guyb7af6a92011-04-06 15:55:25 -07002498 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg0da0e5b2011-04-08 08:14:56 -07002499 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002500 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
Johannes Berg60987202010-02-18 00:36:07 -08002501 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2502 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002503 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +01002504 if (iwl_advanced_bt_coexist(priv))
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002505 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002506 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
2507 &priv->disable_sens_cal);
2508 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
2509 &priv->disable_chain_noise_cal);
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002510
2511 if (iwl_trans_dbgfs_register(trans(priv), dir_debug))
2512 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002513 return 0;
2514
2515err:
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002516 IWL_ERR(priv, "Can't create the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002517 iwl_dbgfs_unregister(priv);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002518 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002519}
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002520
2521/**
2522 * Remove the debugfs files and directories
2523 *
2524 */
2525void iwl_dbgfs_unregister(struct iwl_priv *priv)
2526{
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002527 if (!priv->debugfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002528 return;
2529
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002530 debugfs_remove_recursive(priv->debugfs_dir);
2531 priv->debugfs_dir = NULL;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002532}
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002533
2534
Tomas Winkler445c2df2008-05-15 13:54:16 +08002535