blob: e320cc10167ed06c772f538009d86485c549a4ab [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 Bergmann2b18ab362010-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 Bergmann2b18ab362010-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 Bergmann2b18ab362010-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 */
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -0700257 val = iwl_read_targ_mem(bus(priv), sram);
Jay Sternberg24834d22011-01-11 15:41:00 -0800258
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;
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -0700276 val = iwl_read_targ_mem(bus(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 Grumbach5f85a782011-08-25 23:11:18 -0700343 struct iwl_tid_data *tid_data;
Emmanuel Grumbachd6189122011-08-25 23:10:39 -0700344 int max_sta = hw_params(priv).max_stations;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700345 char *buf;
346 int i, j, pos = 0;
347 ssize_t ret;
348 /* Add 30 for initial string */
349 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700350
351 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300352 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700353 return -ENOMEM;
354
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700355 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700356 priv->num_stations);
357
358 for (i = 0; i < max_sta; i++) {
359 station = &priv->stations[i];
Johannes Bergda735112010-05-03 01:25:24 -0700360 if (!station->used)
361 continue;
362 pos += scnprintf(buf + pos, bufsz - pos,
363 "station %d - addr: %pM, flags: %#x\n",
364 i, station->sta.sta.addr,
365 station->sta.station_flags_msk);
366 pos += scnprintf(buf + pos, bufsz - pos,
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700367 "TID\tseq_num\ttxq_id\ttfds\trate_n_flags\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700368
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700369 for (j = 0; j < IWL_MAX_TID_COUNT; j++) {
370 tid_data = &priv->shrd->tid_data[i][j];
Johannes Bergda735112010-05-03 01:25:24 -0700371 pos += scnprintf(buf + pos, bufsz - pos,
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700372 "%d:\t%#x\t%#x\t%u\t%#x",
373 j, tid_data->seq_number,
374 tid_data->agg.txq_id,
375 tid_data->tfds_in_queue,
376 tid_data->agg.rate_n_flags);
Johannes Bergda735112010-05-03 01:25:24 -0700377
Emmanuel Grumbach5f85a782011-08-25 23:11:18 -0700378 if (tid_data->agg.wait_for_ba)
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700379 pos += scnprintf(buf + pos, bufsz - pos,
Johannes Bergda735112010-05-03 01:25:24 -0700380 " - waitforba");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700381 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700382 }
Johannes Bergda735112010-05-03 01:25:24 -0700383
384 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700385 }
386
387 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
388 kfree(buf);
389 return ret;
390}
391
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700392static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800393 char __user *user_buf,
394 size_t count,
395 loff_t *ppos)
396{
397 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700398 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800399 int pos = 0, ofs = 0, buf_size = 0;
400 const u8 *ptr;
401 char *buf;
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700402 u16 eeprom_ver;
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700403 size_t eeprom_len = priv->cfg->base_params->eeprom_size;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800404 buf_size = 4 * eeprom_len + 256;
405
406 if (eeprom_len % 16) {
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700407 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800408 return -ENODATA;
409 }
410
Julia Lawallc37457e2009-08-03 11:11:45 +0200411 ptr = priv->eeprom;
412 if (!ptr) {
413 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
414 return -ENOMEM;
415 }
416
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800417 /* 4 characters for byte 0xYY */
418 buf = kzalloc(buf_size, GFP_KERNEL);
419 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800420 IWL_ERR(priv, "Can not allocate Buffer\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800421 return -ENOMEM;
422 }
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700423 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
424 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
425 "version: 0x%x\n",
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700426 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700427 ? "OTP" : "EEPROM", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800428 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
429 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
430 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
431 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700432 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800433 if (buf_size - pos > 0)
434 buf[pos++] = '\n';
435 }
436
437 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
438 kfree(buf);
439 return ret;
440}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700441
Winkler, Tomasd366df52008-12-02 12:14:01 -0800442static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
443 size_t count, loff_t *ppos)
444{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700445 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800446 struct ieee80211_channel *channels = NULL;
447 const struct ieee80211_supported_band *supp_band = NULL;
448 int pos = 0, i, bufsz = PAGE_SIZE;
449 char *buf;
450 ssize_t ret;
451
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700452 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status))
Winkler, Tomasd366df52008-12-02 12:14:01 -0800453 return -EAGAIN;
454
455 buf = kzalloc(bufsz, GFP_KERNEL);
456 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800457 IWL_ERR(priv, "Can not allocate Buffer\n");
Winkler, Tomasd366df52008-12-02 12:14:01 -0800458 return -ENOMEM;
459 }
460
461 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700462 if (supp_band) {
463 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800464
Winkler, Tomasd366df52008-12-02 12:14:01 -0800465 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700466 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
467 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800468
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700469 for (i = 0; i < supp_band->n_channels; i++)
470 pos += scnprintf(buf + pos, bufsz - pos,
471 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700472 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700473 channels[i].max_power,
474 channels[i].flags & IEEE80211_CHAN_RADAR ?
475 " (IEEE 802.11h required)" : "",
476 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
477 || (channels[i].flags &
478 IEEE80211_CHAN_RADAR)) ? "" :
479 ", IBSS",
480 channels[i].flags &
481 IEEE80211_CHAN_PASSIVE_SCAN ?
482 "passive only" : "active/passive");
483 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800484 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700485 if (supp_band) {
486 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800487
Winkler, Tomasd366df52008-12-02 12:14:01 -0800488 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700489 "Displaying %d channels in 5.2GHz band (802.11a)\n",
490 supp_band->n_channels);
491
492 for (i = 0; i < supp_band->n_channels; i++)
493 pos += scnprintf(buf + pos, bufsz - pos,
494 "%d: %ddBm: BSS%s%s, %s.\n",
Shanyu Zhao81e95432010-07-28 13:40:27 -0700495 channels[i].hw_value,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700496 channels[i].max_power,
497 channels[i].flags & IEEE80211_CHAN_RADAR ?
498 " (IEEE 802.11h required)" : "",
499 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
500 || (channels[i].flags &
501 IEEE80211_CHAN_RADAR)) ? "" :
502 ", IBSS",
503 channels[i].flags &
504 IEEE80211_CHAN_PASSIVE_SCAN ?
505 "passive only" : "active/passive");
506 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800507 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
508 kfree(buf);
509 return ret;
510}
511
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700512static ssize_t iwl_dbgfs_status_read(struct file *file,
513 char __user *user_buf,
514 size_t count, loff_t *ppos) {
515
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700516 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700517 char buf[512];
518 int pos = 0;
519 const size_t bufsz = sizeof(buf);
520
521 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700522 test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700523 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700524 test_bit(STATUS_INT_ENABLED, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700525 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700526 test_bit(STATUS_RF_KILL_HW, &priv->shrd->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700527 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700528 test_bit(STATUS_CT_KILL, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700529 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700530 test_bit(STATUS_INIT, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700531 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700532 test_bit(STATUS_ALIVE, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700533 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700534 test_bit(STATUS_READY, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700535 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700536 test_bit(STATUS_TEMPERATURE, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700537 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700538 test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700539 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700540 test_bit(STATUS_EXIT_PENDING, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700541 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700542 test_bit(STATUS_STATISTICS, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700543 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700544 test_bit(STATUS_SCANNING, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700545 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700546 test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700547 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700548 test_bit(STATUS_SCAN_HW, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700549 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700550 test_bit(STATUS_POWER_PMI, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700551 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
Emmanuel Grumbach63013ae2011-08-25 23:10:42 -0700552 test_bit(STATUS_FW_ERROR, &priv->shrd->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700553 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
554}
555
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700556static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700557 char __user *user_buf,
558 size_t count, loff_t *ppos) {
559
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700560 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700561
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700562 int pos = 0;
563 int cnt = 0;
564 char *buf;
565 int bufsz = 24 * 64; /* 24 items * 64 char per item */
566 ssize_t ret;
567
568 buf = kzalloc(bufsz, GFP_KERNEL);
569 if (!buf) {
570 IWL_ERR(priv, "Can not allocate Buffer\n");
571 return -ENOMEM;
572 }
573
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700574 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700575 if (priv->rx_handlers_stats[cnt] > 0)
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700576 pos += scnprintf(buf + pos, bufsz - pos,
577 "\tRx handler[%36s]:\t\t %u\n",
578 get_cmd_string(cnt),
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700579 priv->rx_handlers_stats[cnt]);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700580 }
581
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700582 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
583 kfree(buf);
584 return ret;
585}
586
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700587static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700588 const char __user *user_buf,
589 size_t count, loff_t *ppos)
590{
591 struct iwl_priv *priv = file->private_data;
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700592
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700593 char buf[8];
594 int buf_size;
595 u32 reset_flag;
596
597 memset(buf, 0, sizeof(buf));
598 buf_size = min(count, sizeof(buf) - 1);
599 if (copy_from_user(buf, user_buf, buf_size))
600 return -EFAULT;
601 if (sscanf(buf, "%x", &reset_flag) != 1)
602 return -EFAULT;
603 if (reset_flag == 0)
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700604 memset(&priv->rx_handlers_stats[0], 0,
605 sizeof(priv->rx_handlers_stats));
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700606
607 return count;
608}
609
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700610static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
611 size_t count, loff_t *ppos)
612{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700613 struct iwl_priv *priv = file->private_data;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200614 struct iwl_rxon_context *ctx;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700615 int pos = 0, i;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200616 char buf[256 * NUM_IWL_RXON_CTX];
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700617 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700618
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200619 for_each_context(priv, ctx) {
620 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
621 ctx->ctxid);
622 for (i = 0; i < AC_NUM; i++) {
623 pos += scnprintf(buf + pos, bufsz - pos,
624 "\tcw_min\tcw_max\taifsn\ttxop\n");
625 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700626 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200627 ctx->qos_data.def_qos_parm.ac[i].cw_min,
628 ctx->qos_data.def_qos_parm.ac[i].cw_max,
629 ctx->qos_data.def_qos_parm.ac[i].aifsn,
630 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
631 }
632 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700633 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800634 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700635}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700636
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700637static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
638 char __user *user_buf,
639 size_t count, loff_t *ppos)
640{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700641 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700642 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700643 struct iwl_tt_restriction *restriction;
644 char buf[100];
645 int pos = 0;
646 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700647
648 pos += scnprintf(buf + pos, bufsz - pos,
649 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700650 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700651 pos += scnprintf(buf + pos, bufsz - pos,
652 "Thermal Throttling State: %d\n",
653 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700654 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700655 restriction = tt->restriction + tt->state;
656 pos += scnprintf(buf + pos, bufsz - pos,
657 "Tx mode: %d\n",
658 restriction->tx_stream);
659 pos += scnprintf(buf + pos, bufsz - pos,
660 "Rx mode: %d\n",
661 restriction->rx_stream);
662 pos += scnprintf(buf + pos, bufsz - pos,
663 "HT mode: %d\n",
664 restriction->is_ht);
665 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800666 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700667}
668
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700669static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
670 const char __user *user_buf,
671 size_t count, loff_t *ppos)
672{
673 struct iwl_priv *priv = file->private_data;
674 char buf[8];
675 int buf_size;
676 int ht40;
677
678 memset(buf, 0, sizeof(buf));
679 buf_size = min(count, sizeof(buf) - 1);
680 if (copy_from_user(buf, user_buf, buf_size))
681 return -EFAULT;
682 if (sscanf(buf, "%d", &ht40) != 1)
683 return -EFAULT;
Johannes Berg246ed352010-08-23 10:46:32 +0200684 if (!iwl_is_any_associated(priv))
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700685 priv->disable_ht40 = ht40 ? true : false;
686 else {
687 IWL_ERR(priv, "Sta associated with AP - "
688 "Change to 40MHz channel support is not allowed\n");
689 return -EINVAL;
690 }
691
692 return count;
693}
694
695static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
696 char __user *user_buf,
697 size_t count, loff_t *ppos)
698{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700699 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700700 char buf[100];
701 int pos = 0;
702 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700703
704 pos += scnprintf(buf + pos, bufsz - pos,
705 "11n 40MHz Mode: %s\n",
706 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800707 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700708}
709
Johannes Berge312c242009-08-07 15:41:51 -0700710static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
711 const char __user *user_buf,
712 size_t count, loff_t *ppos)
713{
714 struct iwl_priv *priv = file->private_data;
715 char buf[8];
716 int buf_size;
717 int value;
718
719 memset(buf, 0, sizeof(buf));
720 buf_size = min(count, sizeof(buf) - 1);
721 if (copy_from_user(buf, user_buf, buf_size))
722 return -EFAULT;
723
724 if (sscanf(buf, "%d", &value) != 1)
725 return -EINVAL;
726
727 /*
728 * Our users expect 0 to be "CAM", but 0 isn't actually
729 * valid here. However, let's not confuse them and present
730 * IWL_POWER_INDEX_1 as "1", not "0".
731 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700732 if (value == 0)
733 return -EINVAL;
734 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700735 value -= 1;
736
737 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
738 return -EINVAL;
739
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -0700740 if (!iwl_is_ready_rf(priv->shrd))
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700741 return -EAGAIN;
742
Johannes Berge312c242009-08-07 15:41:51 -0700743 priv->power_data.debug_sleep_level_override = value;
744
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -0700745 mutex_lock(&priv->shrd->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700746 iwl_power_update_mode(priv, true);
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -0700747 mutex_unlock(&priv->shrd->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700748
749 return count;
750}
751
752static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
753 char __user *user_buf,
754 size_t count, loff_t *ppos)
755{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700756 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700757 char buf[10];
758 int pos, value;
759 const size_t bufsz = sizeof(buf);
760
761 /* see the write function */
762 value = priv->power_data.debug_sleep_level_override;
763 if (value >= 0)
764 value += 1;
765
766 pos = scnprintf(buf, bufsz, "%d\n", value);
767 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
768}
769
770static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
771 char __user *user_buf,
772 size_t count, loff_t *ppos)
773{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700774 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700775 char buf[200];
776 int pos = 0, i;
777 const size_t bufsz = sizeof(buf);
778 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
779
780 pos += scnprintf(buf + pos, bufsz - pos,
781 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
782 pos += scnprintf(buf + pos, bufsz - pos,
783 "RX/TX timeout: %d/%d usec\n",
784 le32_to_cpu(cmd->rx_data_timeout),
785 le32_to_cpu(cmd->tx_data_timeout));
786 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
787 pos += scnprintf(buf + pos, bufsz - pos,
788 "sleep_interval[%d]: %d\n", i,
789 le32_to_cpu(cmd->sleep_interval[i]));
790
791 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
792}
793
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700794DEBUGFS_READ_WRITE_FILE_OPS(sram);
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700795DEBUGFS_READ_FILE_OPS(wowlan_sram);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700796DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700797DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800798DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700799DEBUGFS_READ_FILE_OPS(status);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700800DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700801DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700802DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700803DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Johannes Berge312c242009-08-07 15:41:51 -0700804DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
805DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700806
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700807static const char *fmt_value = " %-30s %10u\n";
808static const char *fmt_hex = " %-30s 0x%02X\n";
809static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
810static const char *fmt_header =
811 "%-32s current cumulative delta max\n";
812
813static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
814{
815 int p = 0;
816 u32 flag;
817
818 flag = le32_to_cpu(priv->statistics.flag);
819
820 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
821 if (flag & UCODE_STATISTICS_CLEAR_MSK)
822 p += scnprintf(buf + p, bufsz - p,
823 "\tStatistics have been cleared\n");
824 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
825 (flag & UCODE_STATISTICS_FREQUENCY_MSK)
826 ? "2.4 GHz" : "5.2 GHz");
827 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
828 (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
829 ? "enabled" : "disabled");
830
831 return p;
832}
833
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -0700834static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
835 char __user *user_buf,
836 size_t count, loff_t *ppos)
837{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700838 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700839 int pos = 0;
840 char *buf;
841 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
842 sizeof(struct statistics_rx_non_phy) * 40 +
843 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
844 ssize_t ret;
845 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
846 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
847 struct statistics_rx_non_phy *general, *accum_general;
848 struct statistics_rx_non_phy *delta_general, *max_general;
849 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
850
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -0700851 if (!iwl_is_alive(priv->shrd))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -0700852 return -EAGAIN;
853
854 buf = kzalloc(bufsz, GFP_KERNEL);
855 if (!buf) {
856 IWL_ERR(priv, "Can not allocate Buffer\n");
857 return -ENOMEM;
858 }
859
860 /*
861 * the statistic information display here is based on
862 * the last statistics notification from uCode
863 * might not reflect the current uCode activity
864 */
865 ofdm = &priv->statistics.rx_ofdm;
866 cck = &priv->statistics.rx_cck;
867 general = &priv->statistics.rx_non_phy;
868 ht = &priv->statistics.rx_ofdm_ht;
869 accum_ofdm = &priv->accum_stats.rx_ofdm;
870 accum_cck = &priv->accum_stats.rx_cck;
871 accum_general = &priv->accum_stats.rx_non_phy;
872 accum_ht = &priv->accum_stats.rx_ofdm_ht;
873 delta_ofdm = &priv->delta_stats.rx_ofdm;
874 delta_cck = &priv->delta_stats.rx_cck;
875 delta_general = &priv->delta_stats.rx_non_phy;
876 delta_ht = &priv->delta_stats.rx_ofdm_ht;
877 max_ofdm = &priv->max_delta_stats.rx_ofdm;
878 max_cck = &priv->max_delta_stats.rx_cck;
879 max_general = &priv->max_delta_stats.rx_non_phy;
880 max_ht = &priv->max_delta_stats.rx_ofdm_ht;
881
882 pos += iwl_statistics_flag(priv, buf, bufsz);
883 pos += scnprintf(buf + pos, bufsz - pos,
884 fmt_header, "Statistics_Rx - OFDM:");
885 pos += scnprintf(buf + pos, bufsz - pos,
886 fmt_table, "ina_cnt:",
887 le32_to_cpu(ofdm->ina_cnt),
888 accum_ofdm->ina_cnt,
889 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
890 pos += scnprintf(buf + pos, bufsz - pos,
891 fmt_table, "fina_cnt:",
892 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
893 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
894 pos += scnprintf(buf + pos, bufsz - pos,
895 fmt_table, "plcp_err:",
896 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
897 delta_ofdm->plcp_err, max_ofdm->plcp_err);
898 pos += scnprintf(buf + pos, bufsz - pos,
899 fmt_table, "crc32_err:",
900 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
901 delta_ofdm->crc32_err, max_ofdm->crc32_err);
902 pos += scnprintf(buf + pos, bufsz - pos,
903 fmt_table, "overrun_err:",
904 le32_to_cpu(ofdm->overrun_err),
905 accum_ofdm->overrun_err, delta_ofdm->overrun_err,
906 max_ofdm->overrun_err);
907 pos += scnprintf(buf + pos, bufsz - pos,
908 fmt_table, "early_overrun_err:",
909 le32_to_cpu(ofdm->early_overrun_err),
910 accum_ofdm->early_overrun_err,
911 delta_ofdm->early_overrun_err,
912 max_ofdm->early_overrun_err);
913 pos += scnprintf(buf + pos, bufsz - pos,
914 fmt_table, "crc32_good:",
915 le32_to_cpu(ofdm->crc32_good),
916 accum_ofdm->crc32_good, delta_ofdm->crc32_good,
917 max_ofdm->crc32_good);
918 pos += scnprintf(buf + pos, bufsz - pos,
919 fmt_table, "false_alarm_cnt:",
920 le32_to_cpu(ofdm->false_alarm_cnt),
921 accum_ofdm->false_alarm_cnt,
922 delta_ofdm->false_alarm_cnt,
923 max_ofdm->false_alarm_cnt);
924 pos += scnprintf(buf + pos, bufsz - pos,
925 fmt_table, "fina_sync_err_cnt:",
926 le32_to_cpu(ofdm->fina_sync_err_cnt),
927 accum_ofdm->fina_sync_err_cnt,
928 delta_ofdm->fina_sync_err_cnt,
929 max_ofdm->fina_sync_err_cnt);
930 pos += scnprintf(buf + pos, bufsz - pos,
931 fmt_table, "sfd_timeout:",
932 le32_to_cpu(ofdm->sfd_timeout),
933 accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
934 max_ofdm->sfd_timeout);
935 pos += scnprintf(buf + pos, bufsz - pos,
936 fmt_table, "fina_timeout:",
937 le32_to_cpu(ofdm->fina_timeout),
938 accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
939 max_ofdm->fina_timeout);
940 pos += scnprintf(buf + pos, bufsz - pos,
941 fmt_table, "unresponded_rts:",
942 le32_to_cpu(ofdm->unresponded_rts),
943 accum_ofdm->unresponded_rts,
944 delta_ofdm->unresponded_rts,
945 max_ofdm->unresponded_rts);
946 pos += scnprintf(buf + pos, bufsz - pos,
947 fmt_table, "rxe_frame_lmt_ovrun:",
948 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
949 accum_ofdm->rxe_frame_limit_overrun,
950 delta_ofdm->rxe_frame_limit_overrun,
951 max_ofdm->rxe_frame_limit_overrun);
952 pos += scnprintf(buf + pos, bufsz - pos,
953 fmt_table, "sent_ack_cnt:",
954 le32_to_cpu(ofdm->sent_ack_cnt),
955 accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
956 max_ofdm->sent_ack_cnt);
957 pos += scnprintf(buf + pos, bufsz - pos,
958 fmt_table, "sent_cts_cnt:",
959 le32_to_cpu(ofdm->sent_cts_cnt),
960 accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
961 max_ofdm->sent_cts_cnt);
962 pos += scnprintf(buf + pos, bufsz - pos,
963 fmt_table, "sent_ba_rsp_cnt:",
964 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
965 accum_ofdm->sent_ba_rsp_cnt,
966 delta_ofdm->sent_ba_rsp_cnt,
967 max_ofdm->sent_ba_rsp_cnt);
968 pos += scnprintf(buf + pos, bufsz - pos,
969 fmt_table, "dsp_self_kill:",
970 le32_to_cpu(ofdm->dsp_self_kill),
971 accum_ofdm->dsp_self_kill,
972 delta_ofdm->dsp_self_kill,
973 max_ofdm->dsp_self_kill);
974 pos += scnprintf(buf + pos, bufsz - pos,
975 fmt_table, "mh_format_err:",
976 le32_to_cpu(ofdm->mh_format_err),
977 accum_ofdm->mh_format_err,
978 delta_ofdm->mh_format_err,
979 max_ofdm->mh_format_err);
980 pos += scnprintf(buf + pos, bufsz - pos,
981 fmt_table, "re_acq_main_rssi_sum:",
982 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
983 accum_ofdm->re_acq_main_rssi_sum,
984 delta_ofdm->re_acq_main_rssi_sum,
985 max_ofdm->re_acq_main_rssi_sum);
986
987 pos += scnprintf(buf + pos, bufsz - pos,
988 fmt_header, "Statistics_Rx - CCK:");
989 pos += scnprintf(buf + pos, bufsz - pos,
990 fmt_table, "ina_cnt:",
991 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
992 delta_cck->ina_cnt, max_cck->ina_cnt);
993 pos += scnprintf(buf + pos, bufsz - pos,
994 fmt_table, "fina_cnt:",
995 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
996 delta_cck->fina_cnt, max_cck->fina_cnt);
997 pos += scnprintf(buf + pos, bufsz - pos,
998 fmt_table, "plcp_err:",
999 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1000 delta_cck->plcp_err, max_cck->plcp_err);
1001 pos += scnprintf(buf + pos, bufsz - pos,
1002 fmt_table, "crc32_err:",
1003 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1004 delta_cck->crc32_err, max_cck->crc32_err);
1005 pos += scnprintf(buf + pos, bufsz - pos,
1006 fmt_table, "overrun_err:",
1007 le32_to_cpu(cck->overrun_err),
1008 accum_cck->overrun_err, delta_cck->overrun_err,
1009 max_cck->overrun_err);
1010 pos += scnprintf(buf + pos, bufsz - pos,
1011 fmt_table, "early_overrun_err:",
1012 le32_to_cpu(cck->early_overrun_err),
1013 accum_cck->early_overrun_err,
1014 delta_cck->early_overrun_err,
1015 max_cck->early_overrun_err);
1016 pos += scnprintf(buf + pos, bufsz - pos,
1017 fmt_table, "crc32_good:",
1018 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1019 delta_cck->crc32_good, max_cck->crc32_good);
1020 pos += scnprintf(buf + pos, bufsz - pos,
1021 fmt_table, "false_alarm_cnt:",
1022 le32_to_cpu(cck->false_alarm_cnt),
1023 accum_cck->false_alarm_cnt,
1024 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1025 pos += scnprintf(buf + pos, bufsz - pos,
1026 fmt_table, "fina_sync_err_cnt:",
1027 le32_to_cpu(cck->fina_sync_err_cnt),
1028 accum_cck->fina_sync_err_cnt,
1029 delta_cck->fina_sync_err_cnt,
1030 max_cck->fina_sync_err_cnt);
1031 pos += scnprintf(buf + pos, bufsz - pos,
1032 fmt_table, "sfd_timeout:",
1033 le32_to_cpu(cck->sfd_timeout),
1034 accum_cck->sfd_timeout, delta_cck->sfd_timeout,
1035 max_cck->sfd_timeout);
1036 pos += scnprintf(buf + pos, bufsz - pos,
1037 fmt_table, "fina_timeout:",
1038 le32_to_cpu(cck->fina_timeout),
1039 accum_cck->fina_timeout, delta_cck->fina_timeout,
1040 max_cck->fina_timeout);
1041 pos += scnprintf(buf + pos, bufsz - pos,
1042 fmt_table, "unresponded_rts:",
1043 le32_to_cpu(cck->unresponded_rts),
1044 accum_cck->unresponded_rts, delta_cck->unresponded_rts,
1045 max_cck->unresponded_rts);
1046 pos += scnprintf(buf + pos, bufsz - pos,
1047 fmt_table, "rxe_frame_lmt_ovrun:",
1048 le32_to_cpu(cck->rxe_frame_limit_overrun),
1049 accum_cck->rxe_frame_limit_overrun,
1050 delta_cck->rxe_frame_limit_overrun,
1051 max_cck->rxe_frame_limit_overrun);
1052 pos += scnprintf(buf + pos, bufsz - pos,
1053 fmt_table, "sent_ack_cnt:",
1054 le32_to_cpu(cck->sent_ack_cnt),
1055 accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
1056 max_cck->sent_ack_cnt);
1057 pos += scnprintf(buf + pos, bufsz - pos,
1058 fmt_table, "sent_cts_cnt:",
1059 le32_to_cpu(cck->sent_cts_cnt),
1060 accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
1061 max_cck->sent_cts_cnt);
1062 pos += scnprintf(buf + pos, bufsz - pos,
1063 fmt_table, "sent_ba_rsp_cnt:",
1064 le32_to_cpu(cck->sent_ba_rsp_cnt),
1065 accum_cck->sent_ba_rsp_cnt,
1066 delta_cck->sent_ba_rsp_cnt,
1067 max_cck->sent_ba_rsp_cnt);
1068 pos += scnprintf(buf + pos, bufsz - pos,
1069 fmt_table, "dsp_self_kill:",
1070 le32_to_cpu(cck->dsp_self_kill),
1071 accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
1072 max_cck->dsp_self_kill);
1073 pos += scnprintf(buf + pos, bufsz - pos,
1074 fmt_table, "mh_format_err:",
1075 le32_to_cpu(cck->mh_format_err),
1076 accum_cck->mh_format_err, delta_cck->mh_format_err,
1077 max_cck->mh_format_err);
1078 pos += scnprintf(buf + pos, bufsz - pos,
1079 fmt_table, "re_acq_main_rssi_sum:",
1080 le32_to_cpu(cck->re_acq_main_rssi_sum),
1081 accum_cck->re_acq_main_rssi_sum,
1082 delta_cck->re_acq_main_rssi_sum,
1083 max_cck->re_acq_main_rssi_sum);
1084
1085 pos += scnprintf(buf + pos, bufsz - pos,
1086 fmt_header, "Statistics_Rx - GENERAL:");
1087 pos += scnprintf(buf + pos, bufsz - pos,
1088 fmt_table, "bogus_cts:",
1089 le32_to_cpu(general->bogus_cts),
1090 accum_general->bogus_cts, delta_general->bogus_cts,
1091 max_general->bogus_cts);
1092 pos += scnprintf(buf + pos, bufsz - pos,
1093 fmt_table, "bogus_ack:",
1094 le32_to_cpu(general->bogus_ack),
1095 accum_general->bogus_ack, delta_general->bogus_ack,
1096 max_general->bogus_ack);
1097 pos += scnprintf(buf + pos, bufsz - pos,
1098 fmt_table, "non_bssid_frames:",
1099 le32_to_cpu(general->non_bssid_frames),
1100 accum_general->non_bssid_frames,
1101 delta_general->non_bssid_frames,
1102 max_general->non_bssid_frames);
1103 pos += scnprintf(buf + pos, bufsz - pos,
1104 fmt_table, "filtered_frames:",
1105 le32_to_cpu(general->filtered_frames),
1106 accum_general->filtered_frames,
1107 delta_general->filtered_frames,
1108 max_general->filtered_frames);
1109 pos += scnprintf(buf + pos, bufsz - pos,
1110 fmt_table, "non_channel_beacons:",
1111 le32_to_cpu(general->non_channel_beacons),
1112 accum_general->non_channel_beacons,
1113 delta_general->non_channel_beacons,
1114 max_general->non_channel_beacons);
1115 pos += scnprintf(buf + pos, bufsz - pos,
1116 fmt_table, "channel_beacons:",
1117 le32_to_cpu(general->channel_beacons),
1118 accum_general->channel_beacons,
1119 delta_general->channel_beacons,
1120 max_general->channel_beacons);
1121 pos += scnprintf(buf + pos, bufsz - pos,
1122 fmt_table, "num_missed_bcon:",
1123 le32_to_cpu(general->num_missed_bcon),
1124 accum_general->num_missed_bcon,
1125 delta_general->num_missed_bcon,
1126 max_general->num_missed_bcon);
1127 pos += scnprintf(buf + pos, bufsz - pos,
1128 fmt_table, "adc_rx_saturation_time:",
1129 le32_to_cpu(general->adc_rx_saturation_time),
1130 accum_general->adc_rx_saturation_time,
1131 delta_general->adc_rx_saturation_time,
1132 max_general->adc_rx_saturation_time);
1133 pos += scnprintf(buf + pos, bufsz - pos,
1134 fmt_table, "ina_detect_search_tm:",
1135 le32_to_cpu(general->ina_detection_search_time),
1136 accum_general->ina_detection_search_time,
1137 delta_general->ina_detection_search_time,
1138 max_general->ina_detection_search_time);
1139 pos += scnprintf(buf + pos, bufsz - pos,
1140 fmt_table, "beacon_silence_rssi_a:",
1141 le32_to_cpu(general->beacon_silence_rssi_a),
1142 accum_general->beacon_silence_rssi_a,
1143 delta_general->beacon_silence_rssi_a,
1144 max_general->beacon_silence_rssi_a);
1145 pos += scnprintf(buf + pos, bufsz - pos,
1146 fmt_table, "beacon_silence_rssi_b:",
1147 le32_to_cpu(general->beacon_silence_rssi_b),
1148 accum_general->beacon_silence_rssi_b,
1149 delta_general->beacon_silence_rssi_b,
1150 max_general->beacon_silence_rssi_b);
1151 pos += scnprintf(buf + pos, bufsz - pos,
1152 fmt_table, "beacon_silence_rssi_c:",
1153 le32_to_cpu(general->beacon_silence_rssi_c),
1154 accum_general->beacon_silence_rssi_c,
1155 delta_general->beacon_silence_rssi_c,
1156 max_general->beacon_silence_rssi_c);
1157 pos += scnprintf(buf + pos, bufsz - pos,
1158 fmt_table, "interference_data_flag:",
1159 le32_to_cpu(general->interference_data_flag),
1160 accum_general->interference_data_flag,
1161 delta_general->interference_data_flag,
1162 max_general->interference_data_flag);
1163 pos += scnprintf(buf + pos, bufsz - pos,
1164 fmt_table, "channel_load:",
1165 le32_to_cpu(general->channel_load),
1166 accum_general->channel_load,
1167 delta_general->channel_load,
1168 max_general->channel_load);
1169 pos += scnprintf(buf + pos, bufsz - pos,
1170 fmt_table, "dsp_false_alarms:",
1171 le32_to_cpu(general->dsp_false_alarms),
1172 accum_general->dsp_false_alarms,
1173 delta_general->dsp_false_alarms,
1174 max_general->dsp_false_alarms);
1175 pos += scnprintf(buf + pos, bufsz - pos,
1176 fmt_table, "beacon_rssi_a:",
1177 le32_to_cpu(general->beacon_rssi_a),
1178 accum_general->beacon_rssi_a,
1179 delta_general->beacon_rssi_a,
1180 max_general->beacon_rssi_a);
1181 pos += scnprintf(buf + pos, bufsz - pos,
1182 fmt_table, "beacon_rssi_b:",
1183 le32_to_cpu(general->beacon_rssi_b),
1184 accum_general->beacon_rssi_b,
1185 delta_general->beacon_rssi_b,
1186 max_general->beacon_rssi_b);
1187 pos += scnprintf(buf + pos, bufsz - pos,
1188 fmt_table, "beacon_rssi_c:",
1189 le32_to_cpu(general->beacon_rssi_c),
1190 accum_general->beacon_rssi_c,
1191 delta_general->beacon_rssi_c,
1192 max_general->beacon_rssi_c);
1193 pos += scnprintf(buf + pos, bufsz - pos,
1194 fmt_table, "beacon_energy_a:",
1195 le32_to_cpu(general->beacon_energy_a),
1196 accum_general->beacon_energy_a,
1197 delta_general->beacon_energy_a,
1198 max_general->beacon_energy_a);
1199 pos += scnprintf(buf + pos, bufsz - pos,
1200 fmt_table, "beacon_energy_b:",
1201 le32_to_cpu(general->beacon_energy_b),
1202 accum_general->beacon_energy_b,
1203 delta_general->beacon_energy_b,
1204 max_general->beacon_energy_b);
1205 pos += scnprintf(buf + pos, bufsz - pos,
1206 fmt_table, "beacon_energy_c:",
1207 le32_to_cpu(general->beacon_energy_c),
1208 accum_general->beacon_energy_c,
1209 delta_general->beacon_energy_c,
1210 max_general->beacon_energy_c);
1211
1212 pos += scnprintf(buf + pos, bufsz - pos,
1213 fmt_header, "Statistics_Rx - OFDM_HT:");
1214 pos += scnprintf(buf + pos, bufsz - pos,
1215 fmt_table, "plcp_err:",
1216 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1217 delta_ht->plcp_err, max_ht->plcp_err);
1218 pos += scnprintf(buf + pos, bufsz - pos,
1219 fmt_table, "overrun_err:",
1220 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1221 delta_ht->overrun_err, max_ht->overrun_err);
1222 pos += scnprintf(buf + pos, bufsz - pos,
1223 fmt_table, "early_overrun_err:",
1224 le32_to_cpu(ht->early_overrun_err),
1225 accum_ht->early_overrun_err,
1226 delta_ht->early_overrun_err,
1227 max_ht->early_overrun_err);
1228 pos += scnprintf(buf + pos, bufsz - pos,
1229 fmt_table, "crc32_good:",
1230 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1231 delta_ht->crc32_good, max_ht->crc32_good);
1232 pos += scnprintf(buf + pos, bufsz - pos,
1233 fmt_table, "crc32_err:",
1234 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1235 delta_ht->crc32_err, max_ht->crc32_err);
1236 pos += scnprintf(buf + pos, bufsz - pos,
1237 fmt_table, "mh_format_err:",
1238 le32_to_cpu(ht->mh_format_err),
1239 accum_ht->mh_format_err,
1240 delta_ht->mh_format_err, max_ht->mh_format_err);
1241 pos += scnprintf(buf + pos, bufsz - pos,
1242 fmt_table, "agg_crc32_good:",
1243 le32_to_cpu(ht->agg_crc32_good),
1244 accum_ht->agg_crc32_good,
1245 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1246 pos += scnprintf(buf + pos, bufsz - pos,
1247 fmt_table, "agg_mpdu_cnt:",
1248 le32_to_cpu(ht->agg_mpdu_cnt),
1249 accum_ht->agg_mpdu_cnt,
1250 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1251 pos += scnprintf(buf + pos, bufsz - pos,
1252 fmt_table, "agg_cnt:",
1253 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1254 delta_ht->agg_cnt, max_ht->agg_cnt);
1255 pos += scnprintf(buf + pos, bufsz - pos,
1256 fmt_table, "unsupport_mcs:",
1257 le32_to_cpu(ht->unsupport_mcs),
1258 accum_ht->unsupport_mcs,
1259 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
1260
1261 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1262 kfree(buf);
1263 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001264}
1265
1266static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1267 char __user *user_buf,
1268 size_t count, loff_t *ppos)
1269{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001270 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001271 int pos = 0;
1272 char *buf;
1273 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
1274 ssize_t ret;
1275 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
1276
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -07001277 if (!iwl_is_alive(priv->shrd))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001278 return -EAGAIN;
1279
1280 buf = kzalloc(bufsz, GFP_KERNEL);
1281 if (!buf) {
1282 IWL_ERR(priv, "Can not allocate Buffer\n");
1283 return -ENOMEM;
1284 }
1285
1286 /* the statistic information display here is based on
1287 * the last statistics notification from uCode
1288 * might not reflect the current uCode activity
1289 */
1290 tx = &priv->statistics.tx;
1291 accum_tx = &priv->accum_stats.tx;
1292 delta_tx = &priv->delta_stats.tx;
1293 max_tx = &priv->max_delta_stats.tx;
1294
1295 pos += iwl_statistics_flag(priv, buf, bufsz);
1296 pos += scnprintf(buf + pos, bufsz - pos,
1297 fmt_header, "Statistics_Tx:");
1298 pos += scnprintf(buf + pos, bufsz - pos,
1299 fmt_table, "preamble:",
1300 le32_to_cpu(tx->preamble_cnt),
1301 accum_tx->preamble_cnt,
1302 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1303 pos += scnprintf(buf + pos, bufsz - pos,
1304 fmt_table, "rx_detected_cnt:",
1305 le32_to_cpu(tx->rx_detected_cnt),
1306 accum_tx->rx_detected_cnt,
1307 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1308 pos += scnprintf(buf + pos, bufsz - pos,
1309 fmt_table, "bt_prio_defer_cnt:",
1310 le32_to_cpu(tx->bt_prio_defer_cnt),
1311 accum_tx->bt_prio_defer_cnt,
1312 delta_tx->bt_prio_defer_cnt,
1313 max_tx->bt_prio_defer_cnt);
1314 pos += scnprintf(buf + pos, bufsz - pos,
1315 fmt_table, "bt_prio_kill_cnt:",
1316 le32_to_cpu(tx->bt_prio_kill_cnt),
1317 accum_tx->bt_prio_kill_cnt,
1318 delta_tx->bt_prio_kill_cnt,
1319 max_tx->bt_prio_kill_cnt);
1320 pos += scnprintf(buf + pos, bufsz - pos,
1321 fmt_table, "few_bytes_cnt:",
1322 le32_to_cpu(tx->few_bytes_cnt),
1323 accum_tx->few_bytes_cnt,
1324 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1325 pos += scnprintf(buf + pos, bufsz - pos,
1326 fmt_table, "cts_timeout:",
1327 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1328 delta_tx->cts_timeout, max_tx->cts_timeout);
1329 pos += scnprintf(buf + pos, bufsz - pos,
1330 fmt_table, "ack_timeout:",
1331 le32_to_cpu(tx->ack_timeout),
1332 accum_tx->ack_timeout,
1333 delta_tx->ack_timeout, max_tx->ack_timeout);
1334 pos += scnprintf(buf + pos, bufsz - pos,
1335 fmt_table, "expected_ack_cnt:",
1336 le32_to_cpu(tx->expected_ack_cnt),
1337 accum_tx->expected_ack_cnt,
1338 delta_tx->expected_ack_cnt,
1339 max_tx->expected_ack_cnt);
1340 pos += scnprintf(buf + pos, bufsz - pos,
1341 fmt_table, "actual_ack_cnt:",
1342 le32_to_cpu(tx->actual_ack_cnt),
1343 accum_tx->actual_ack_cnt,
1344 delta_tx->actual_ack_cnt,
1345 max_tx->actual_ack_cnt);
1346 pos += scnprintf(buf + pos, bufsz - pos,
1347 fmt_table, "dump_msdu_cnt:",
1348 le32_to_cpu(tx->dump_msdu_cnt),
1349 accum_tx->dump_msdu_cnt,
1350 delta_tx->dump_msdu_cnt,
1351 max_tx->dump_msdu_cnt);
1352 pos += scnprintf(buf + pos, bufsz - pos,
1353 fmt_table, "abort_nxt_frame_mismatch:",
1354 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
1355 accum_tx->burst_abort_next_frame_mismatch_cnt,
1356 delta_tx->burst_abort_next_frame_mismatch_cnt,
1357 max_tx->burst_abort_next_frame_mismatch_cnt);
1358 pos += scnprintf(buf + pos, bufsz - pos,
1359 fmt_table, "abort_missing_nxt_frame:",
1360 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
1361 accum_tx->burst_abort_missing_next_frame_cnt,
1362 delta_tx->burst_abort_missing_next_frame_cnt,
1363 max_tx->burst_abort_missing_next_frame_cnt);
1364 pos += scnprintf(buf + pos, bufsz - pos,
1365 fmt_table, "cts_timeout_collision:",
1366 le32_to_cpu(tx->cts_timeout_collision),
1367 accum_tx->cts_timeout_collision,
1368 delta_tx->cts_timeout_collision,
1369 max_tx->cts_timeout_collision);
1370 pos += scnprintf(buf + pos, bufsz - pos,
1371 fmt_table, "ack_ba_timeout_collision:",
1372 le32_to_cpu(tx->ack_or_ba_timeout_collision),
1373 accum_tx->ack_or_ba_timeout_collision,
1374 delta_tx->ack_or_ba_timeout_collision,
1375 max_tx->ack_or_ba_timeout_collision);
1376 pos += scnprintf(buf + pos, bufsz - pos,
1377 fmt_table, "agg ba_timeout:",
1378 le32_to_cpu(tx->agg.ba_timeout),
1379 accum_tx->agg.ba_timeout,
1380 delta_tx->agg.ba_timeout,
1381 max_tx->agg.ba_timeout);
1382 pos += scnprintf(buf + pos, bufsz - pos,
1383 fmt_table, "agg ba_resched_frames:",
1384 le32_to_cpu(tx->agg.ba_reschedule_frames),
1385 accum_tx->agg.ba_reschedule_frames,
1386 delta_tx->agg.ba_reschedule_frames,
1387 max_tx->agg.ba_reschedule_frames);
1388 pos += scnprintf(buf + pos, bufsz - pos,
1389 fmt_table, "agg scd_query_agg_frame:",
1390 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
1391 accum_tx->agg.scd_query_agg_frame_cnt,
1392 delta_tx->agg.scd_query_agg_frame_cnt,
1393 max_tx->agg.scd_query_agg_frame_cnt);
1394 pos += scnprintf(buf + pos, bufsz - pos,
1395 fmt_table, "agg scd_query_no_agg:",
1396 le32_to_cpu(tx->agg.scd_query_no_agg),
1397 accum_tx->agg.scd_query_no_agg,
1398 delta_tx->agg.scd_query_no_agg,
1399 max_tx->agg.scd_query_no_agg);
1400 pos += scnprintf(buf + pos, bufsz - pos,
1401 fmt_table, "agg scd_query_agg:",
1402 le32_to_cpu(tx->agg.scd_query_agg),
1403 accum_tx->agg.scd_query_agg,
1404 delta_tx->agg.scd_query_agg,
1405 max_tx->agg.scd_query_agg);
1406 pos += scnprintf(buf + pos, bufsz - pos,
1407 fmt_table, "agg scd_query_mismatch:",
1408 le32_to_cpu(tx->agg.scd_query_mismatch),
1409 accum_tx->agg.scd_query_mismatch,
1410 delta_tx->agg.scd_query_mismatch,
1411 max_tx->agg.scd_query_mismatch);
1412 pos += scnprintf(buf + pos, bufsz - pos,
1413 fmt_table, "agg frame_not_ready:",
1414 le32_to_cpu(tx->agg.frame_not_ready),
1415 accum_tx->agg.frame_not_ready,
1416 delta_tx->agg.frame_not_ready,
1417 max_tx->agg.frame_not_ready);
1418 pos += scnprintf(buf + pos, bufsz - pos,
1419 fmt_table, "agg underrun:",
1420 le32_to_cpu(tx->agg.underrun),
1421 accum_tx->agg.underrun,
1422 delta_tx->agg.underrun, max_tx->agg.underrun);
1423 pos += scnprintf(buf + pos, bufsz - pos,
1424 fmt_table, "agg bt_prio_kill:",
1425 le32_to_cpu(tx->agg.bt_prio_kill),
1426 accum_tx->agg.bt_prio_kill,
1427 delta_tx->agg.bt_prio_kill,
1428 max_tx->agg.bt_prio_kill);
1429 pos += scnprintf(buf + pos, bufsz - pos,
1430 fmt_table, "agg rx_ba_rsp_cnt:",
1431 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
1432 accum_tx->agg.rx_ba_rsp_cnt,
1433 delta_tx->agg.rx_ba_rsp_cnt,
1434 max_tx->agg.rx_ba_rsp_cnt);
1435
1436 if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
1437 pos += scnprintf(buf + pos, bufsz - pos,
1438 "tx power: (1/2 dB step)\n");
1439 if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
1440 pos += scnprintf(buf + pos, bufsz - pos,
1441 fmt_hex, "antenna A:",
1442 tx->tx_power.ant_a);
1443 if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
1444 pos += scnprintf(buf + pos, bufsz - pos,
1445 fmt_hex, "antenna B:",
1446 tx->tx_power.ant_b);
1447 if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
1448 pos += scnprintf(buf + pos, bufsz - pos,
1449 fmt_hex, "antenna C:",
1450 tx->tx_power.ant_c);
1451 }
1452 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1453 kfree(buf);
1454 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001455}
1456
1457static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1458 char __user *user_buf,
1459 size_t count, loff_t *ppos)
1460{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001461 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001462 int pos = 0;
1463 char *buf;
1464 int bufsz = sizeof(struct statistics_general) * 10 + 300;
1465 ssize_t ret;
1466 struct statistics_general_common *general, *accum_general;
1467 struct statistics_general_common *delta_general, *max_general;
1468 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1469 struct statistics_div *div, *accum_div, *delta_div, *max_div;
1470
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -07001471 if (!iwl_is_alive(priv->shrd))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001472 return -EAGAIN;
1473
1474 buf = kzalloc(bufsz, GFP_KERNEL);
1475 if (!buf) {
1476 IWL_ERR(priv, "Can not allocate Buffer\n");
1477 return -ENOMEM;
1478 }
1479
1480 /* the statistic information display here is based on
1481 * the last statistics notification from uCode
1482 * might not reflect the current uCode activity
1483 */
1484 general = &priv->statistics.common;
1485 dbg = &priv->statistics.common.dbg;
1486 div = &priv->statistics.common.div;
1487 accum_general = &priv->accum_stats.common;
1488 accum_dbg = &priv->accum_stats.common.dbg;
1489 accum_div = &priv->accum_stats.common.div;
1490 delta_general = &priv->delta_stats.common;
1491 max_general = &priv->max_delta_stats.common;
1492 delta_dbg = &priv->delta_stats.common.dbg;
1493 max_dbg = &priv->max_delta_stats.common.dbg;
1494 delta_div = &priv->delta_stats.common.div;
1495 max_div = &priv->max_delta_stats.common.div;
1496
1497 pos += iwl_statistics_flag(priv, buf, bufsz);
1498 pos += scnprintf(buf + pos, bufsz - pos,
1499 fmt_header, "Statistics_General:");
1500 pos += scnprintf(buf + pos, bufsz - pos,
1501 fmt_value, "temperature:",
1502 le32_to_cpu(general->temperature));
1503 pos += scnprintf(buf + pos, bufsz - pos,
1504 fmt_value, "temperature_m:",
1505 le32_to_cpu(general->temperature_m));
1506 pos += scnprintf(buf + pos, bufsz - pos,
1507 fmt_value, "ttl_timestamp:",
1508 le32_to_cpu(general->ttl_timestamp));
1509 pos += scnprintf(buf + pos, bufsz - pos,
1510 fmt_table, "burst_check:",
1511 le32_to_cpu(dbg->burst_check),
1512 accum_dbg->burst_check,
1513 delta_dbg->burst_check, max_dbg->burst_check);
1514 pos += scnprintf(buf + pos, bufsz - pos,
1515 fmt_table, "burst_count:",
1516 le32_to_cpu(dbg->burst_count),
1517 accum_dbg->burst_count,
1518 delta_dbg->burst_count, max_dbg->burst_count);
1519 pos += scnprintf(buf + pos, bufsz - pos,
1520 fmt_table, "wait_for_silence_timeout_count:",
1521 le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
1522 accum_dbg->wait_for_silence_timeout_cnt,
1523 delta_dbg->wait_for_silence_timeout_cnt,
1524 max_dbg->wait_for_silence_timeout_cnt);
1525 pos += scnprintf(buf + pos, bufsz - pos,
1526 fmt_table, "sleep_time:",
1527 le32_to_cpu(general->sleep_time),
1528 accum_general->sleep_time,
1529 delta_general->sleep_time, max_general->sleep_time);
1530 pos += scnprintf(buf + pos, bufsz - pos,
1531 fmt_table, "slots_out:",
1532 le32_to_cpu(general->slots_out),
1533 accum_general->slots_out,
1534 delta_general->slots_out, max_general->slots_out);
1535 pos += scnprintf(buf + pos, bufsz - pos,
1536 fmt_table, "slots_idle:",
1537 le32_to_cpu(general->slots_idle),
1538 accum_general->slots_idle,
1539 delta_general->slots_idle, max_general->slots_idle);
1540 pos += scnprintf(buf + pos, bufsz - pos,
1541 fmt_table, "tx_on_a:",
1542 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1543 delta_div->tx_on_a, max_div->tx_on_a);
1544 pos += scnprintf(buf + pos, bufsz - pos,
1545 fmt_table, "tx_on_b:",
1546 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1547 delta_div->tx_on_b, max_div->tx_on_b);
1548 pos += scnprintf(buf + pos, bufsz - pos,
1549 fmt_table, "exec_time:",
1550 le32_to_cpu(div->exec_time), accum_div->exec_time,
1551 delta_div->exec_time, max_div->exec_time);
1552 pos += scnprintf(buf + pos, bufsz - pos,
1553 fmt_table, "probe_time:",
1554 le32_to_cpu(div->probe_time), accum_div->probe_time,
1555 delta_div->probe_time, max_div->probe_time);
1556 pos += scnprintf(buf + pos, bufsz - pos,
1557 fmt_table, "rx_enable_counter:",
1558 le32_to_cpu(general->rx_enable_counter),
1559 accum_general->rx_enable_counter,
1560 delta_general->rx_enable_counter,
1561 max_general->rx_enable_counter);
1562 pos += scnprintf(buf + pos, bufsz - pos,
1563 fmt_table, "num_of_sos_states:",
1564 le32_to_cpu(general->num_of_sos_states),
1565 accum_general->num_of_sos_states,
1566 delta_general->num_of_sos_states,
1567 max_general->num_of_sos_states);
1568 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1569 kfree(buf);
1570 return ret;
1571}
1572
1573static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1574 char __user *user_buf,
1575 size_t count, loff_t *ppos)
1576{
1577 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1578 int pos = 0;
1579 char *buf;
1580 int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
1581 ssize_t ret;
1582 struct statistics_bt_activity *bt, *accum_bt;
1583
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -07001584 if (!iwl_is_alive(priv->shrd))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001585 return -EAGAIN;
1586
1587 if (!priv->bt_enable_flag)
1588 return -EINVAL;
1589
1590 /* make request to uCode to retrieve statistics information */
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001591 mutex_lock(&priv->shrd->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001592 ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001593 mutex_unlock(&priv->shrd->mutex);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001594
1595 if (ret) {
1596 IWL_ERR(priv,
1597 "Error sending statistics request: %zd\n", ret);
1598 return -EAGAIN;
1599 }
1600 buf = kzalloc(bufsz, GFP_KERNEL);
1601 if (!buf) {
1602 IWL_ERR(priv, "Can not allocate Buffer\n");
1603 return -ENOMEM;
1604 }
1605
1606 /*
1607 * the statistic information display here is based on
1608 * the last statistics notification from uCode
1609 * might not reflect the current uCode activity
1610 */
1611 bt = &priv->statistics.bt_activity;
1612 accum_bt = &priv->accum_stats.bt_activity;
1613
1614 pos += iwl_statistics_flag(priv, buf, bufsz);
1615 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
1616 pos += scnprintf(buf + pos, bufsz - pos,
1617 "\t\t\tcurrent\t\t\taccumulative\n");
1618 pos += scnprintf(buf + pos, bufsz - pos,
1619 "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1620 le32_to_cpu(bt->hi_priority_tx_req_cnt),
1621 accum_bt->hi_priority_tx_req_cnt);
1622 pos += scnprintf(buf + pos, bufsz - pos,
1623 "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1624 le32_to_cpu(bt->hi_priority_tx_denied_cnt),
1625 accum_bt->hi_priority_tx_denied_cnt);
1626 pos += scnprintf(buf + pos, bufsz - pos,
1627 "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
1628 le32_to_cpu(bt->lo_priority_tx_req_cnt),
1629 accum_bt->lo_priority_tx_req_cnt);
1630 pos += scnprintf(buf + pos, bufsz - pos,
1631 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
1632 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
1633 accum_bt->lo_priority_tx_denied_cnt);
1634 pos += scnprintf(buf + pos, bufsz - pos,
1635 "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1636 le32_to_cpu(bt->hi_priority_rx_req_cnt),
1637 accum_bt->hi_priority_rx_req_cnt);
1638 pos += scnprintf(buf + pos, bufsz - pos,
1639 "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1640 le32_to_cpu(bt->hi_priority_rx_denied_cnt),
1641 accum_bt->hi_priority_rx_denied_cnt);
1642 pos += scnprintf(buf + pos, bufsz - pos,
1643 "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
1644 le32_to_cpu(bt->lo_priority_rx_req_cnt),
1645 accum_bt->lo_priority_rx_req_cnt);
1646 pos += scnprintf(buf + pos, bufsz - pos,
1647 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
1648 le32_to_cpu(bt->lo_priority_rx_denied_cnt),
1649 accum_bt->lo_priority_rx_denied_cnt);
1650
1651 pos += scnprintf(buf + pos, bufsz - pos,
1652 "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
1653 le32_to_cpu(priv->statistics.num_bt_kills),
1654 priv->statistics.accum_num_bt_kills);
1655
1656 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1657 kfree(buf);
1658 return ret;
1659}
1660
1661static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
1662 char __user *user_buf,
1663 size_t count, loff_t *ppos)
1664{
1665 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1666 int pos = 0;
1667 char *buf;
1668 int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
1669 (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
1670 ssize_t ret;
1671
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -07001672 if (!iwl_is_alive(priv->shrd))
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001673 return -EAGAIN;
1674
1675 buf = kzalloc(bufsz, GFP_KERNEL);
1676 if (!buf) {
1677 IWL_ERR(priv, "Can not allocate Buffer\n");
1678 return -ENOMEM;
1679 }
1680
1681 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
1682 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
1683 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001684 priv->reply_tx_stats.pp_delay);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001685 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1686 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001687 priv->reply_tx_stats.pp_few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001688 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1689 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001690 priv->reply_tx_stats.pp_bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001691 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1692 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001693 priv->reply_tx_stats.pp_quiet_period);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001694 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1695 iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001696 priv->reply_tx_stats.pp_calc_ttak);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001697 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1698 iwl_get_tx_fail_reason(
1699 TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001700 priv->reply_tx_stats.int_crossed_retry);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001701 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1702 iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001703 priv->reply_tx_stats.short_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001704 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1705 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001706 priv->reply_tx_stats.long_limit);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001707 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1708 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001709 priv->reply_tx_stats.fifo_underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001710 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1711 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001712 priv->reply_tx_stats.drain_flow);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001713 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1714 iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001715 priv->reply_tx_stats.rfkill_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001716 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1717 iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001718 priv->reply_tx_stats.life_expire);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001719 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1720 iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001721 priv->reply_tx_stats.dest_ps);
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_FAIL_HOST_ABORTED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001724 priv->reply_tx_stats.host_abort);
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_FAIL_BT_RETRY),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001727 priv->reply_tx_stats.pp_delay);
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_FAIL_STA_INVALID),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001730 priv->reply_tx_stats.sta_invalid);
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_FAIL_FRAG_DROPPED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001733 priv->reply_tx_stats.frag_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001734 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1735 iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001736 priv->reply_tx_stats.tid_disable);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001737 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1738 iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001739 priv->reply_tx_stats.fifo_flush);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001740 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1741 iwl_get_tx_fail_reason(
1742 TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001743 priv->reply_tx_stats.insuff_cf_poll);
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_PASSIVE_NO_RX),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001746 priv->reply_tx_stats.fail_hw_drop);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001747 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1748 iwl_get_tx_fail_reason(
1749 TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001750 priv->reply_tx_stats.sta_color_mismatch);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001751 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001752 priv->reply_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001753
1754 pos += scnprintf(buf + pos, bufsz - pos,
1755 "\nStatistics_Agg_TX_Error:\n");
1756
1757 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1758 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001759 priv->reply_agg_tx_stats.underrun);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001760 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1761 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001762 priv->reply_agg_tx_stats.bt_prio);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001763 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1764 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001765 priv->reply_agg_tx_stats.few_bytes);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001766 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1767 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001768 priv->reply_agg_tx_stats.abort);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001769 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1770 iwl_get_agg_tx_fail_reason(
1771 AGG_TX_STATE_LAST_SENT_TTL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001772 priv->reply_agg_tx_stats.last_sent_ttl);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001773 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1774 iwl_get_agg_tx_fail_reason(
1775 AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001776 priv->reply_agg_tx_stats.last_sent_try);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001777 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1778 iwl_get_agg_tx_fail_reason(
1779 AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001780 priv->reply_agg_tx_stats.last_sent_bt_kill);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001781 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1782 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001783 priv->reply_agg_tx_stats.scd_query);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001784 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
1785 iwl_get_agg_tx_fail_reason(
1786 AGG_TX_STATE_TEST_BAD_CRC32_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001787 priv->reply_agg_tx_stats.bad_crc32);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001788 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1789 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001790 priv->reply_agg_tx_stats.response);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001791 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1792 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001793 priv->reply_agg_tx_stats.dump_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001794 pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
1795 iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001796 priv->reply_agg_tx_stats.delay_tx);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001797 pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001798 priv->reply_agg_tx_stats.unknown);
Wey-Yi Guyd6d023a2011-04-30 09:10:53 -07001799
1800 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1801 kfree(buf);
1802 return ret;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001803}
1804
Wey-Yi Guy52259352009-08-07 15:41:43 -07001805static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1806 char __user *user_buf,
1807 size_t count, loff_t *ppos) {
1808
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001809 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001810 int pos = 0;
1811 int cnt = 0;
1812 char *buf;
1813 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1814 ssize_t ret;
1815 struct iwl_sensitivity_data *data;
1816
1817 data = &priv->sensitivity_data;
1818 buf = kzalloc(bufsz, GFP_KERNEL);
1819 if (!buf) {
1820 IWL_ERR(priv, "Can not allocate Buffer\n");
1821 return -ENOMEM;
1822 }
1823
1824 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1825 data->auto_corr_ofdm);
1826 pos += scnprintf(buf + pos, bufsz - pos,
1827 "auto_corr_ofdm_mrc:\t\t %u\n",
1828 data->auto_corr_ofdm_mrc);
1829 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1830 data->auto_corr_ofdm_x1);
1831 pos += scnprintf(buf + pos, bufsz - pos,
1832 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1833 data->auto_corr_ofdm_mrc_x1);
1834 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1835 data->auto_corr_cck);
1836 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1837 data->auto_corr_cck_mrc);
1838 pos += scnprintf(buf + pos, bufsz - pos,
1839 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1840 data->last_bad_plcp_cnt_ofdm);
1841 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1842 data->last_fa_cnt_ofdm);
1843 pos += scnprintf(buf + pos, bufsz - pos,
1844 "last_bad_plcp_cnt_cck:\t\t %u\n",
1845 data->last_bad_plcp_cnt_cck);
1846 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1847 data->last_fa_cnt_cck);
1848 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1849 data->nrg_curr_state);
1850 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1851 data->nrg_prev_state);
1852 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1853 for (cnt = 0; cnt < 10; cnt++) {
1854 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1855 data->nrg_value[cnt]);
1856 }
1857 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1858 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1859 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1860 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1861 data->nrg_silence_rssi[cnt]);
1862 }
1863 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1864 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1865 data->nrg_silence_ref);
1866 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1867 data->nrg_energy_idx);
1868 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1869 data->nrg_silence_idx);
1870 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1871 data->nrg_th_cck);
1872 pos += scnprintf(buf + pos, bufsz - pos,
1873 "nrg_auto_corr_silence_diff:\t %u\n",
1874 data->nrg_auto_corr_silence_diff);
1875 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1876 data->num_in_cck_no_fa);
1877 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1878 data->nrg_th_ofdm);
1879
1880 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1881 kfree(buf);
1882 return ret;
1883}
1884
1885
1886static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1887 char __user *user_buf,
1888 size_t count, loff_t *ppos) {
1889
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001890 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001891 int pos = 0;
1892 int cnt = 0;
1893 char *buf;
1894 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1895 ssize_t ret;
1896 struct iwl_chain_noise_data *data;
1897
1898 data = &priv->chain_noise_data;
1899 buf = kzalloc(bufsz, GFP_KERNEL);
1900 if (!buf) {
1901 IWL_ERR(priv, "Can not allocate Buffer\n");
1902 return -ENOMEM;
1903 }
1904
1905 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1906 data->active_chains);
1907 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1908 data->chain_noise_a);
1909 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1910 data->chain_noise_b);
1911 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1912 data->chain_noise_c);
1913 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1914 data->chain_signal_a);
1915 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1916 data->chain_signal_b);
1917 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1918 data->chain_signal_c);
1919 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1920 data->beacon_count);
1921
1922 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1923 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1924 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1925 data->disconn_array[cnt]);
1926 }
1927 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1928 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1929 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1930 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1931 data->delta_gain_code[cnt]);
1932 }
1933 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1934 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1935 data->radio_write);
1936 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1937 data->state);
1938
1939 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1940 kfree(buf);
1941 return ret;
1942}
1943
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001944static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1945 char __user *user_buf,
1946 size_t count, loff_t *ppos)
1947{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001948 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001949 char buf[60];
1950 int pos = 0;
1951 const size_t bufsz = sizeof(buf);
1952 u32 pwrsave_status;
1953
Emmanuel Grumbach83ed9012011-08-25 23:11:14 -07001954 pwrsave_status = iwl_read32(bus(priv), CSR_GP_CNTRL) &
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001955 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1956
1957 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1958 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1959 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1960 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1961 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1962 "error");
1963
1964 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1965}
1966
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001967static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001968 const char __user *user_buf,
1969 size_t count, loff_t *ppos)
1970{
1971 struct iwl_priv *priv = file->private_data;
1972 char buf[8];
1973 int buf_size;
1974 int clear;
1975
1976 memset(buf, 0, sizeof(buf));
1977 buf_size = min(count, sizeof(buf) - 1);
1978 if (copy_from_user(buf, user_buf, buf_size))
1979 return -EFAULT;
1980 if (sscanf(buf, "%d", &clear) != 1)
1981 return -EFAULT;
1982
1983 /* make request to uCode to retrieve statistics information */
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001984 mutex_lock(&priv->shrd->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001985 iwl_send_statistics_request(priv, CMD_SYNC, true);
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001986 mutex_unlock(&priv->shrd->mutex);
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001987
1988 return count;
1989}
1990
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001991static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1992 char __user *user_buf,
1993 size_t count, loff_t *ppos) {
1994
Joe Perches57674302010-07-12 13:50:06 -07001995 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001996 int pos = 0;
1997 char buf[128];
1998 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001999
2000 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2001 priv->event_log.ucode_trace ? "On" : "Off");
2002 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
2003 priv->event_log.non_wraps_count);
2004 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
2005 priv->event_log.wraps_once_count);
2006 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2007 priv->event_log.wraps_more_count);
2008
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002009 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002010}
2011
2012static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2013 const char __user *user_buf,
2014 size_t count, loff_t *ppos)
2015{
2016 struct iwl_priv *priv = file->private_data;
2017 char buf[8];
2018 int buf_size;
2019 int trace;
2020
2021 memset(buf, 0, sizeof(buf));
2022 buf_size = min(count, sizeof(buf) - 1);
2023 if (copy_from_user(buf, user_buf, buf_size))
2024 return -EFAULT;
2025 if (sscanf(buf, "%d", &trace) != 1)
2026 return -EFAULT;
2027
2028 if (trace) {
2029 priv->event_log.ucode_trace = true;
2030 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2031 mod_timer(&priv->ucode_trace,
2032 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
2033 } else {
2034 priv->event_log.ucode_trace = false;
2035 del_timer_sync(&priv->ucode_trace);
2036 }
2037
2038 return count;
2039}
2040
Johannes Berg60987202010-02-18 00:36:07 -08002041static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
2042 char __user *user_buf,
2043 size_t count, loff_t *ppos) {
2044
Joe Perches57674302010-07-12 13:50:06 -07002045 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08002046 int len = 0;
2047 char buf[20];
2048
Johannes Berg246ed352010-08-23 10:46:32 +02002049 len = sprintf(buf, "0x%04X\n",
2050 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
Johannes Berg60987202010-02-18 00:36:07 -08002051 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2052}
2053
2054static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
2055 char __user *user_buf,
2056 size_t count, loff_t *ppos) {
2057
Joe Perches57674302010-07-12 13:50:06 -07002058 struct iwl_priv *priv = file->private_data;
Johannes Berg60987202010-02-18 00:36:07 -08002059 int len = 0;
2060 char buf[20];
2061
2062 len = sprintf(buf, "0x%04X\n",
Johannes Berg246ed352010-08-23 10:46:32 +02002063 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
Johannes Berg60987202010-02-18 00:36:07 -08002064 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2065}
2066
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002067static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2068 char __user *user_buf,
2069 size_t count, loff_t *ppos) {
2070
2071 struct iwl_priv *priv = file->private_data;
2072 int pos = 0;
2073 char buf[12];
2074 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002075
2076 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2077 priv->missed_beacon_threshold);
2078
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002079 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002080}
2081
2082static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2083 const char __user *user_buf,
2084 size_t count, loff_t *ppos)
2085{
2086 struct iwl_priv *priv = file->private_data;
2087 char buf[8];
2088 int buf_size;
2089 int missed;
2090
2091 memset(buf, 0, sizeof(buf));
2092 buf_size = min(count, sizeof(buf) - 1);
2093 if (copy_from_user(buf, user_buf, buf_size))
2094 return -EFAULT;
2095 if (sscanf(buf, "%d", &missed) != 1)
2096 return -EINVAL;
2097
2098 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2099 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2100 priv->missed_beacon_threshold =
2101 IWL_MISSED_BEACON_THRESHOLD_DEF;
2102 else
2103 priv->missed_beacon_threshold = missed;
2104
2105 return count;
2106}
2107
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002108static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2109 char __user *user_buf,
2110 size_t count, loff_t *ppos) {
2111
Joe Perches57674302010-07-12 13:50:06 -07002112 struct iwl_priv *priv = file->private_data;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002113 int pos = 0;
2114 char buf[12];
2115 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002116
2117 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002118 priv->cfg->base_params->plcp_delta_threshold);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002119
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002120 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002121}
2122
2123static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2124 const char __user *user_buf,
2125 size_t count, loff_t *ppos) {
2126
2127 struct iwl_priv *priv = file->private_data;
2128 char buf[8];
2129 int buf_size;
2130 int plcp;
2131
2132 memset(buf, 0, sizeof(buf));
2133 buf_size = min(count, sizeof(buf) - 1);
2134 if (copy_from_user(buf, user_buf, buf_size))
2135 return -EFAULT;
2136 if (sscanf(buf, "%d", &plcp) != 1)
2137 return -EINVAL;
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002138 if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002139 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002140 priv->cfg->base_params->plcp_delta_threshold =
Wey-Yi Guy680788a2010-06-17 15:25:00 -07002141 IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002142 else
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002143 priv->cfg->base_params->plcp_delta_threshold = plcp;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002144 return count;
2145}
2146
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002147static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
2148 char __user *user_buf,
2149 size_t count, loff_t *ppos) {
2150
2151 struct iwl_priv *priv = file->private_data;
2152 int i, pos = 0;
2153 char buf[300];
2154 const size_t bufsz = sizeof(buf);
2155 struct iwl_force_reset *force_reset;
2156
2157 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
2158 force_reset = &priv->force_reset[i];
2159 pos += scnprintf(buf + pos, bufsz - pos,
2160 "Force reset method %d\n", i);
2161 pos += scnprintf(buf + pos, bufsz - pos,
2162 "\tnumber of reset request: %d\n",
2163 force_reset->reset_request_count);
2164 pos += scnprintf(buf + pos, bufsz - pos,
2165 "\tnumber of reset request success: %d\n",
2166 force_reset->reset_success_count);
2167 pos += scnprintf(buf + pos, bufsz - pos,
2168 "\tnumber of reset request reject: %d\n",
2169 force_reset->reset_reject_count);
2170 pos += scnprintf(buf + pos, bufsz - pos,
2171 "\treset duration: %lu\n",
2172 force_reset->reset_duration);
2173 }
2174 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2175}
2176
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002177static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
2178 const char __user *user_buf,
2179 size_t count, loff_t *ppos) {
2180
2181 struct iwl_priv *priv = file->private_data;
2182 char buf[8];
2183 int buf_size;
2184 int reset, ret;
2185
2186 memset(buf, 0, sizeof(buf));
2187 buf_size = min(count, sizeof(buf) - 1);
2188 if (copy_from_user(buf, user_buf, buf_size))
2189 return -EFAULT;
2190 if (sscanf(buf, "%d", &reset) != 1)
2191 return -EINVAL;
2192 switch (reset) {
2193 case IWL_RF_RESET:
2194 case IWL_FW_RESET:
Wey-Yi Guyc04f9f22010-06-21 16:52:55 -07002195 ret = iwl_force_reset(priv, reset, true);
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002196 break;
2197 default:
2198 return -EINVAL;
2199 }
2200 return ret ? ret : count;
2201}
2202
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002203static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
2204 const char __user *user_buf,
2205 size_t count, loff_t *ppos) {
2206
2207 struct iwl_priv *priv = file->private_data;
2208 char buf[8];
2209 int buf_size;
2210 int flush;
2211
2212 memset(buf, 0, sizeof(buf));
2213 buf_size = min(count, sizeof(buf) - 1);
2214 if (copy_from_user(buf, user_buf, buf_size))
2215 return -EFAULT;
2216 if (sscanf(buf, "%d", &flush) != 1)
2217 return -EINVAL;
2218
Emmanuel Grumbach845a9c02011-08-25 23:11:04 -07002219 if (iwl_is_rfkill(priv->shrd))
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002220 return -EFAULT;
2221
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002222 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002223
2224 return count;
2225}
2226
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002227static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file,
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002228 const char __user *user_buf,
2229 size_t count, loff_t *ppos) {
2230
2231 struct iwl_priv *priv = file->private_data;
2232 char buf[8];
2233 int buf_size;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002234 int timeout;
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002235
2236 memset(buf, 0, sizeof(buf));
2237 buf_size = min(count, sizeof(buf) - 1);
2238 if (copy_from_user(buf, user_buf, buf_size))
2239 return -EFAULT;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002240 if (sscanf(buf, "%d", &timeout) != 1)
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002241 return -EINVAL;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002242 if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT)
2243 timeout = IWL_DEF_WD_TIMEOUT;
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002244
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002245 priv->cfg->base_params->wd_timeout = timeout;
2246 iwl_setup_watchdog(priv);
Wey-Yi Guy7bdc4732010-08-23 07:57:07 -07002247 return count;
2248}
2249
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002250static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
2251 char __user *user_buf,
2252 size_t count, loff_t *ppos) {
2253
2254 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2255 int pos = 0;
2256 char buf[200];
2257 const size_t bufsz = sizeof(buf);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002258
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002259 if (!priv->bt_enable_flag) {
2260 pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
Johannes Berg08960de2011-04-05 09:41:53 -07002261 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08002262 }
2263 pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
2264 priv->bt_enable_flag);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002265 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
2266 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
2267 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
2268 "last traffic notif: %d\n",
Wey-Yi Guy66e863a52010-11-08 14:54:37 -08002269 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002270 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
Wey-Yi Guy187bc4f2011-01-27 13:01:33 -08002271 "kill_ack_mask: %x, kill_cts_mask: %x\n",
2272 priv->bt_ch_announce, priv->kill_ack_mask,
2273 priv->kill_cts_mask);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002274
2275 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
2276 switch (priv->bt_traffic_load) {
2277 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
2278 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
2279 break;
2280 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
2281 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
2282 break;
2283 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
2284 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
2285 break;
2286 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
2287 default:
2288 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
2289 break;
2290 }
2291
Johannes Berg08960de2011-04-05 09:41:53 -07002292 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002293}
2294
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002295static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
2296 char __user *user_buf,
2297 size_t count, loff_t *ppos)
2298{
2299 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2300
2301 int pos = 0;
2302 char buf[40];
2303 const size_t bufsz = sizeof(buf);
2304
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002305 if (priv->cfg->ht_params)
2306 pos += scnprintf(buf + pos, bufsz - pos,
2307 "use %s for aggregation\n",
2308 (priv->cfg->ht_params->use_rts_for_aggregation) ?
2309 "rts/cts" : "cts-to-self");
2310 else
2311 pos += scnprintf(buf + pos, bufsz - pos, "N/A");
2312
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002313 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2314}
2315
2316static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
2317 const char __user *user_buf,
2318 size_t count, loff_t *ppos) {
2319
2320 struct iwl_priv *priv = file->private_data;
2321 char buf[8];
2322 int buf_size;
2323 int rts;
2324
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002325 if (!priv->cfg->ht_params)
2326 return -EINVAL;
2327
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002328 memset(buf, 0, sizeof(buf));
2329 buf_size = min(count, sizeof(buf) - 1);
2330 if (copy_from_user(buf, user_buf, buf_size))
2331 return -EFAULT;
2332 if (sscanf(buf, "%d", &rts) != 1)
2333 return -EINVAL;
2334 if (rts)
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002335 priv->cfg->ht_params->use_rts_for_aggregation = true;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002336 else
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -07002337 priv->cfg->ht_params->use_rts_for_aggregation = false;
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002338 return count;
2339}
2340
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002341DEBUGFS_READ_FILE_OPS(rx_statistics);
2342DEBUGFS_READ_FILE_OPS(tx_statistics);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002343DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2344DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2345DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002346DEBUGFS_READ_FILE_OPS(sensitivity);
2347DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002348DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002349DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2350DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002351DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002352DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002353DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002354DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
Johannes Berg60987202010-02-18 00:36:07 -08002355DEBUGFS_READ_FILE_OPS(rxon_flags);
2356DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy4bf49a92010-06-24 13:18:36 -07002357DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
Wey-Yi Guyffb7d892010-07-14 08:09:55 -07002358DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002359DEBUGFS_WRITE_FILE_OPS(wd_timeout);
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002360DEBUGFS_READ_FILE_OPS(bt_traffic);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002361DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002362DEBUGFS_READ_FILE_OPS(reply_tx_error);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002363
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002364/*
2365 * Create the debugfs files and directories
2366 *
2367 */
2368int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2369{
Zhu Yi95b1a822008-05-29 16:34:50 +08002370 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002371 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002372
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002373 dir_drv = debugfs_create_dir(name, phyd);
2374 if (!dir_drv)
2375 return -ENOMEM;
2376
2377 priv->debugfs_dir = dir_drv;
2378
2379 dir_data = debugfs_create_dir("data", dir_drv);
2380 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002381 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002382 dir_rf = debugfs_create_dir("rf", dir_drv);
2383 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002384 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002385 dir_debug = debugfs_create_dir("debug", dir_drv);
2386 if (!dir_debug)
2387 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002388
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002389 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2390 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
Johannes Bergc8ac61c2011-07-15 13:23:45 -07002391 DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002392 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2393 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2394 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -07002395 DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002396 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
Wey-Yi Guy23c0fcc2011-04-01 16:29:53 -07002397 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2398 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002399 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2400 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
2401 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
2402 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002403 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2404 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
2405 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002406 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002407 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002408 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002409 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2410 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2411 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
Wey-Yi Guyc68744f2011-06-18 08:03:18 -07002412 DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
Wey-Yi Guyc6abdc02010-09-01 17:10:51 -07002413 DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07002414
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002415 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2416 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
Wey-Yi Guyb7af6a92011-04-06 15:55:25 -07002417 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg0da0e5b2011-04-08 08:14:56 -07002418 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
Wey-Yi Guy54a9aa62010-09-05 10:49:42 -07002419 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
Johannes Berg60987202010-02-18 00:36:07 -08002420 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2421 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01002422 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
Stanislaw Gruszka88e58fc2011-01-28 16:47:47 +01002423 if (iwl_advanced_bt_coexist(priv))
Wey-Yi Guybefe8c42010-08-23 07:57:16 -07002424 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
Wey-Yi Guy703bc582011-04-03 08:14:41 -07002425 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
2426 &priv->disable_sens_cal);
2427 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
2428 &priv->disable_chain_noise_cal);
Emmanuel Grumbach87e56662011-08-25 23:10:50 -07002429
2430 if (iwl_trans_dbgfs_register(trans(priv), dir_debug))
2431 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002432 return 0;
2433
2434err:
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002435 IWL_ERR(priv, "Can't create the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002436 iwl_dbgfs_unregister(priv);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002437 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002438}
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002439
2440/**
2441 * Remove the debugfs files and directories
2442 *
2443 */
2444void iwl_dbgfs_unregister(struct iwl_priv *priv)
2445{
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002446 if (!priv->debugfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002447 return;
2448
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002449 debugfs_remove_recursive(priv->debugfs_dir);
2450 priv->debugfs_dir = NULL;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002451}
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002452
2453
Tomas Winkler445c2df2008-05-15 13:54:16 +08002454