blob: 3f9c03998491d15df71b500ef606b659e0c8c1c8 [file] [log] [blame]
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
Reinette Chatre1f447802010-01-15 13:43:41 -08005 * Copyright(c) 2008 - 2010 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
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/debugfs.h>
32
33#include <linux/ieee80211.h>
34#include <net/mac80211.h>
35
36
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070037#include "iwl-dev.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070038#include "iwl-debug.h"
Tomas Winklerfee12472008-04-03 16:05:21 -070039#include "iwl-core.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070040#include "iwl-io.h"
Wey-Yi Guy52259352009-08-07 15:41:43 -070041#include "iwl-calib.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070042
43/* create and remove of files */
44#define DEBUGFS_ADD_DIR(name, parent) do { \
45 dbgfs->dir_##name = debugfs_create_dir(#name, parent); \
46 if (!(dbgfs->dir_##name)) \
47 goto err; \
48} while (0)
49
Wey-Yi Guy43e85112009-11-20 12:04:58 -080050#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070051 dbgfs->dbgfs_##parent##_files.file_##name = \
Wey-Yi Guy43e85112009-11-20 12:04:58 -080052 debugfs_create_file(#name, mode, \
Reinette Chatrefcf89d02009-07-09 10:33:38 -070053 dbgfs->dir_##parent, priv, \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070054 &iwl_dbgfs_##name##_ops); \
55 if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \
56 goto err; \
57} while (0)
58
Tomas Winkler445c2df2008-05-15 13:54:16 +080059#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
60 dbgfs->dbgfs_##parent##_files.file_##name = \
Reinette Chatrefcf89d02009-07-09 10:33:38 -070061 debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
62 dbgfs->dir_##parent, ptr); \
Zhaolei9b240012008-10-22 17:06:12 +080063 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
64 || !dbgfs->dbgfs_##parent##_files.file_##name) \
Tomas Winkler445c2df2008-05-15 13:54:16 +080065 goto err; \
66} while (0)
67
Winkler, Tomas2ddfa122008-12-22 11:31:20 +080068#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
69 dbgfs->dbgfs_##parent##_files.file_##name = \
Reinette Chatrefcf89d02009-07-09 10:33:38 -070070 debugfs_create_x32(#name, S_IRUSR, dbgfs->dir_##parent, ptr); \
Winkler, Tomas2ddfa122008-12-22 11:31:20 +080071 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
72 || !dbgfs->dbgfs_##parent##_files.file_##name) \
73 goto err; \
74} while (0)
75
Tomas Winkler712b6cf2008-03-12 16:58:52 -070076#define DEBUGFS_REMOVE(name) do { \
77 debugfs_remove(name); \
78 name = NULL; \
79} while (0);
80
81/* file operation */
82#define DEBUGFS_READ_FUNC(name) \
83static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
84 char __user *user_buf, \
85 size_t count, loff_t *ppos);
86
87#define DEBUGFS_WRITE_FUNC(name) \
88static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
89 const char __user *user_buf, \
90 size_t count, loff_t *ppos);
91
92
93static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
94{
95 file->private_data = inode->i_private;
96 return 0;
97}
98
99#define DEBUGFS_READ_FILE_OPS(name) \
100 DEBUGFS_READ_FUNC(name); \
101static const struct file_operations iwl_dbgfs_##name##_ops = { \
102 .read = iwl_dbgfs_##name##_read, \
103 .open = iwl_dbgfs_open_file_generic, \
104};
105
Ester Kummer189a2b52008-05-15 13:54:18 +0800106#define DEBUGFS_WRITE_FILE_OPS(name) \
107 DEBUGFS_WRITE_FUNC(name); \
108static const struct file_operations iwl_dbgfs_##name##_ops = { \
109 .write = iwl_dbgfs_##name##_write, \
110 .open = iwl_dbgfs_open_file_generic, \
111};
112
113
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700114#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
115 DEBUGFS_READ_FUNC(name); \
116 DEBUGFS_WRITE_FUNC(name); \
117static const struct file_operations iwl_dbgfs_##name##_ops = { \
118 .write = iwl_dbgfs_##name##_write, \
119 .read = iwl_dbgfs_##name##_read, \
120 .open = iwl_dbgfs_open_file_generic, \
121};
122
123
124static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
125 char __user *user_buf,
126 size_t count, loff_t *ppos) {
127
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700128 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700129 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700130 int pos = 0;
131
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700132 int cnt;
133 ssize_t ret;
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800134 const size_t bufsz = 100 +
135 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700136 buf = kzalloc(bufsz, GFP_KERNEL);
137 if (!buf)
138 return -ENOMEM;
139 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
140 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
141 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800142 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700143 get_mgmt_string(cnt),
144 priv->tx_stats.mgmt[cnt]);
145 }
146 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
147 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
148 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800149 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700150 get_ctrl_string(cnt),
151 priv->tx_stats.ctrl[cnt]);
152 }
153 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
154 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
155 priv->tx_stats.data_cnt);
156 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
157 priv->tx_stats.data_bytes);
158 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
159 kfree(buf);
160 return ret;
161}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700162
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800163static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700164 const char __user *user_buf,
165 size_t count, loff_t *ppos)
166{
167 struct iwl_priv *priv = file->private_data;
168 u32 clear_flag;
169 char buf[8];
170 int buf_size;
171
172 memset(buf, 0, sizeof(buf));
173 buf_size = min(count, sizeof(buf) - 1);
174 if (copy_from_user(buf, user_buf, buf_size))
175 return -EFAULT;
176 if (sscanf(buf, "%x", &clear_flag) != 1)
177 return -EFAULT;
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800178 iwl_clear_traffic_stats(priv);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700179
180 return count;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700181}
182
183static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
184 char __user *user_buf,
185 size_t count, loff_t *ppos) {
186
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700187 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700188 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700189 int pos = 0;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700190 int cnt;
191 ssize_t ret;
192 const size_t bufsz = 100 +
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800193 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700194 buf = kzalloc(bufsz, GFP_KERNEL);
195 if (!buf)
196 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700197
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700198 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
199 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
200 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800201 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700202 get_mgmt_string(cnt),
203 priv->rx_stats.mgmt[cnt]);
204 }
205 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
206 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
207 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800208 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700209 get_ctrl_string(cnt),
210 priv->rx_stats.ctrl[cnt]);
211 }
212 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
213 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
214 priv->rx_stats.data_cnt);
215 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
216 priv->rx_stats.data_bytes);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700217
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700218 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
219 kfree(buf);
220 return ret;
221}
222
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700223#define BYTE1_MASK 0x000000ff;
224#define BYTE2_MASK 0x0000ffff;
225#define BYTE3_MASK 0x00ffffff;
226static ssize_t iwl_dbgfs_sram_read(struct file *file,
227 char __user *user_buf,
228 size_t count, loff_t *ppos)
229{
230 u32 val;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800231 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700232 ssize_t ret;
233 int i;
234 int pos = 0;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700235 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800236 size_t bufsz;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700237
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800238 /* default is to dump the entire data segment */
239 if (!priv->dbgfs->sram_offset && !priv->dbgfs->sram_len) {
240 priv->dbgfs->sram_offset = 0x800000;
241 if (priv->ucode_type == UCODE_INIT)
242 priv->dbgfs->sram_len = priv->ucode_init_data.len;
243 else
244 priv->dbgfs->sram_len = priv->ucode_data.len;
245 }
246 bufsz = 30 + priv->dbgfs->sram_len * sizeof(char) * 10;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800247 buf = kmalloc(bufsz, GFP_KERNEL);
248 if (!buf)
249 return -ENOMEM;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800250 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800251 priv->dbgfs->sram_len);
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800252 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800253 priv->dbgfs->sram_offset);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700254 for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
Tomas Winkler3395f6e2008-03-25 16:33:37 -0700255 val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700256 priv->dbgfs->sram_len - i);
257 if (i < 4) {
258 switch (i) {
259 case 1:
260 val &= BYTE1_MASK;
261 break;
262 case 2:
263 val &= BYTE2_MASK;
264 break;
265 case 3:
266 val &= BYTE3_MASK;
267 break;
268 }
269 }
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800270 if (!(i % 16))
271 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700272 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700273 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700274 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700275
276 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800277 kfree(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700278 return ret;
279}
280
281static ssize_t iwl_dbgfs_sram_write(struct file *file,
282 const char __user *user_buf,
283 size_t count, loff_t *ppos)
284{
285 struct iwl_priv *priv = file->private_data;
286 char buf[64];
287 int buf_size;
288 u32 offset, len;
289
290 memset(buf, 0, sizeof(buf));
291 buf_size = min(count, sizeof(buf) - 1);
292 if (copy_from_user(buf, user_buf, buf_size))
293 return -EFAULT;
294
295 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
296 priv->dbgfs->sram_offset = offset;
297 priv->dbgfs->sram_len = len;
298 } else {
299 priv->dbgfs->sram_offset = 0;
300 priv->dbgfs->sram_len = 0;
301 }
302
303 return count;
304}
305
306static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
307 size_t count, loff_t *ppos)
308{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700309 struct iwl_priv *priv = file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800310 struct iwl_station_entry *station;
Tomas Winkler5425e492008-04-15 16:01:38 -0700311 int max_sta = priv->hw_params.max_stations;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700312 char *buf;
313 int i, j, pos = 0;
314 ssize_t ret;
315 /* Add 30 for initial string */
316 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700317
318 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300319 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700320 return -ENOMEM;
321
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700322 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700323 priv->num_stations);
324
325 for (i = 0; i < max_sta; i++) {
326 station = &priv->stations[i];
327 if (station->used) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700328 pos += scnprintf(buf + pos, bufsz - pos,
329 "station %d:\ngeneral data:\n", i+1);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700330 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700331 station->sta.sta.sta_id);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700332 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700333 station->sta.mode);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700334 pos += scnprintf(buf + pos, bufsz - pos,
335 "flags: 0x%x\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700336 station->sta.station_flags_msk);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700337 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
338 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700339 "seq_num\t\ttxq_id");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700340 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700341 "\tframe_count\twait_for_ba\t");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700342 pos += scnprintf(buf + pos, bufsz - pos,
343 "start_idx\tbitmap0\t");
344 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700345 "bitmap1\trate_n_flags");
David S. Miller344234d2008-04-19 18:09:39 -0700346 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700347
348 for (j = 0; j < MAX_TID_COUNT; j++) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700349 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700350 "[%d]:\t\t%u", j,
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700351 station->tid[j].seq_number);
352 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700353 "\t%u\t\t%u\t\t%u\t\t",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700354 station->tid[j].agg.txq_id,
355 station->tid[j].agg.frame_count,
356 station->tid[j].agg.wait_for_ba);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700357 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700358 "%u\t%llu\t%u",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700359 station->tid[j].agg.start_idx,
John W. Linville16788592008-04-01 20:59:32 -0400360 (unsigned long long)station->tid[j].agg.bitmap,
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700361 station->tid[j].agg.rate_n_flags);
David S. Miller344234d2008-04-19 18:09:39 -0700362 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700363 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700364 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700365 }
366 }
367
368 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
369 kfree(buf);
370 return ret;
371}
372
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700373static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800374 char __user *user_buf,
375 size_t count,
376 loff_t *ppos)
377{
378 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700379 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800380 int pos = 0, ofs = 0, buf_size = 0;
381 const u8 *ptr;
382 char *buf;
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700383 u16 eeprom_ver;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800384 size_t eeprom_len = priv->cfg->eeprom_size;
385 buf_size = 4 * eeprom_len + 256;
386
387 if (eeprom_len % 16) {
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700388 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800389 return -ENODATA;
390 }
391
Julia Lawallc37457e2009-08-03 11:11:45 +0200392 ptr = priv->eeprom;
393 if (!ptr) {
394 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
395 return -ENOMEM;
396 }
397
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800398 /* 4 characters for byte 0xYY */
399 buf = kzalloc(buf_size, GFP_KERNEL);
400 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800401 IWL_ERR(priv, "Can not allocate Buffer\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800402 return -ENOMEM;
403 }
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700404 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
405 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
406 "version: 0x%x\n",
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700407 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700408 ? "OTP" : "EEPROM", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800409 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
410 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
411 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
412 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700413 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800414 if (buf_size - pos > 0)
415 buf[pos++] = '\n';
416 }
417
418 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
419 kfree(buf);
420 return ret;
421}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700422
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800423static ssize_t iwl_dbgfs_log_event_read(struct file *file,
424 char __user *user_buf,
425 size_t count, loff_t *ppos)
426{
427 struct iwl_priv *priv = file->private_data;
428 char *buf;
429 int pos = 0;
430 ssize_t ret = -ENOMEM;
431
Wey-Yi Guy937c3972010-01-15 13:43:36 -0800432 ret = pos = priv->cfg->ops->lib->dump_nic_event_log(
433 priv, true, &buf, true);
434 if (buf) {
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800435 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
436 kfree(buf);
437 }
438 return ret;
439}
440
Ester Kummer189a2b52008-05-15 13:54:18 +0800441static ssize_t iwl_dbgfs_log_event_write(struct file *file,
442 const char __user *user_buf,
443 size_t count, loff_t *ppos)
444{
445 struct iwl_priv *priv = file->private_data;
446 u32 event_log_flag;
447 char buf[8];
448 int buf_size;
449
450 memset(buf, 0, sizeof(buf));
451 buf_size = min(count, sizeof(buf) - 1);
452 if (copy_from_user(buf, user_buf, buf_size))
453 return -EFAULT;
454 if (sscanf(buf, "%d", &event_log_flag) != 1)
455 return -EFAULT;
456 if (event_log_flag == 1)
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800457 priv->cfg->ops->lib->dump_nic_event_log(priv, true,
458 NULL, false);
Ester Kummer189a2b52008-05-15 13:54:18 +0800459
460 return count;
461}
462
Winkler, Tomasd366df52008-12-02 12:14:01 -0800463
464
465static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
466 size_t count, loff_t *ppos)
467{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700468 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800469 struct ieee80211_channel *channels = NULL;
470 const struct ieee80211_supported_band *supp_band = NULL;
471 int pos = 0, i, bufsz = PAGE_SIZE;
472 char *buf;
473 ssize_t ret;
474
475 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
476 return -EAGAIN;
477
478 buf = kzalloc(bufsz, GFP_KERNEL);
479 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800480 IWL_ERR(priv, "Can not allocate Buffer\n");
Winkler, Tomasd366df52008-12-02 12:14:01 -0800481 return -ENOMEM;
482 }
483
484 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
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 2.4GHz band 802.11bg):\n",
490 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800491
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700492 for (i = 0; i < supp_band->n_channels; i++)
493 pos += scnprintf(buf + pos, bufsz - pos,
494 "%d: %ddBm: BSS%s%s, %s.\n",
495 ieee80211_frequency_to_channel(
496 channels[i].center_freq),
497 channels[i].max_power,
498 channels[i].flags & IEEE80211_CHAN_RADAR ?
499 " (IEEE 802.11h required)" : "",
500 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
501 || (channels[i].flags &
502 IEEE80211_CHAN_RADAR)) ? "" :
503 ", IBSS",
504 channels[i].flags &
505 IEEE80211_CHAN_PASSIVE_SCAN ?
506 "passive only" : "active/passive");
507 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800508 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700509 if (supp_band) {
510 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800511
Winkler, Tomasd366df52008-12-02 12:14:01 -0800512 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700513 "Displaying %d channels in 5.2GHz band (802.11a)\n",
514 supp_band->n_channels);
515
516 for (i = 0; i < supp_band->n_channels; i++)
517 pos += scnprintf(buf + pos, bufsz - pos,
518 "%d: %ddBm: BSS%s%s, %s.\n",
519 ieee80211_frequency_to_channel(
520 channels[i].center_freq),
521 channels[i].max_power,
522 channels[i].flags & IEEE80211_CHAN_RADAR ?
523 " (IEEE 802.11h required)" : "",
524 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
525 || (channels[i].flags &
526 IEEE80211_CHAN_RADAR)) ? "" :
527 ", IBSS",
528 channels[i].flags &
529 IEEE80211_CHAN_PASSIVE_SCAN ?
530 "passive only" : "active/passive");
531 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800532 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
533 kfree(buf);
534 return ret;
535}
536
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700537static ssize_t iwl_dbgfs_status_read(struct file *file,
538 char __user *user_buf,
539 size_t count, loff_t *ppos) {
540
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700541 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700542 char buf[512];
543 int pos = 0;
544 const size_t bufsz = sizeof(buf);
545
546 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
547 test_bit(STATUS_HCMD_ACTIVE, &priv->status));
548 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_SYNC_ACTIVE: %d\n",
549 test_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status));
550 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
551 test_bit(STATUS_INT_ENABLED, &priv->status));
552 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
553 test_bit(STATUS_RF_KILL_HW, &priv->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700554 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
555 test_bit(STATUS_CT_KILL, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700556 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
557 test_bit(STATUS_INIT, &priv->status));
558 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
559 test_bit(STATUS_ALIVE, &priv->status));
560 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
561 test_bit(STATUS_READY, &priv->status));
562 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
563 test_bit(STATUS_TEMPERATURE, &priv->status));
564 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
565 test_bit(STATUS_GEO_CONFIGURED, &priv->status));
566 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
567 test_bit(STATUS_EXIT_PENDING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700568 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
569 test_bit(STATUS_STATISTICS, &priv->status));
570 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
571 test_bit(STATUS_SCANNING, &priv->status));
572 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
573 test_bit(STATUS_SCAN_ABORTING, &priv->status));
574 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
575 test_bit(STATUS_SCAN_HW, &priv->status));
576 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
577 test_bit(STATUS_POWER_PMI, &priv->status));
578 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
579 test_bit(STATUS_FW_ERROR, &priv->status));
580 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_MODE_PENDING:\t %d\n",
581 test_bit(STATUS_MODE_PENDING, &priv->status));
582 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
583}
584
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700585static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
586 char __user *user_buf,
587 size_t count, loff_t *ppos) {
588
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700589 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700590 int pos = 0;
591 int cnt = 0;
592 char *buf;
593 int bufsz = 24 * 64; /* 24 items * 64 char per item */
594 ssize_t ret;
595
596 buf = kzalloc(bufsz, GFP_KERNEL);
597 if (!buf) {
598 IWL_ERR(priv, "Can not allocate Buffer\n");
599 return -ENOMEM;
600 }
601
602 pos += scnprintf(buf + pos, bufsz - pos,
603 "Interrupt Statistics Report:\n");
604
605 pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
606 priv->isr_stats.hw);
607 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
608 priv->isr_stats.sw);
609 if (priv->isr_stats.sw > 0) {
610 pos += scnprintf(buf + pos, bufsz - pos,
611 "\tLast Restarting Code: 0x%X\n",
612 priv->isr_stats.sw_err);
613 }
614#ifdef CONFIG_IWLWIFI_DEBUG
615 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
616 priv->isr_stats.sch);
617 pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
618 priv->isr_stats.alive);
619#endif
620 pos += scnprintf(buf + pos, bufsz - pos,
621 "HW RF KILL switch toggled:\t %u\n",
622 priv->isr_stats.rfkill);
623
624 pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
625 priv->isr_stats.ctkill);
626
627 pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
628 priv->isr_stats.wakeup);
629
630 pos += scnprintf(buf + pos, bufsz - pos,
631 "Rx command responses:\t\t %u\n",
632 priv->isr_stats.rx);
633 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
634 if (priv->isr_stats.rx_handlers[cnt] > 0)
635 pos += scnprintf(buf + pos, bufsz - pos,
636 "\tRx handler[%36s]:\t\t %u\n",
637 get_cmd_string(cnt),
638 priv->isr_stats.rx_handlers[cnt]);
639 }
640
641 pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
642 priv->isr_stats.tx);
643
644 pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
645 priv->isr_stats.unhandled);
646
647 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
648 kfree(buf);
649 return ret;
650}
651
652static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
653 const char __user *user_buf,
654 size_t count, loff_t *ppos)
655{
656 struct iwl_priv *priv = file->private_data;
657 char buf[8];
658 int buf_size;
659 u32 reset_flag;
660
661 memset(buf, 0, sizeof(buf));
662 buf_size = min(count, sizeof(buf) - 1);
663 if (copy_from_user(buf, user_buf, buf_size))
664 return -EFAULT;
665 if (sscanf(buf, "%x", &reset_flag) != 1)
666 return -EFAULT;
667 if (reset_flag == 0)
668 iwl_clear_isr_stats(priv);
669
670 return count;
671}
672
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700673static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
674 size_t count, loff_t *ppos)
675{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700676 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700677 int pos = 0, i;
678 char buf[256];
679 const size_t bufsz = sizeof(buf);
680 ssize_t ret;
681
682 for (i = 0; i < AC_NUM; i++) {
683 pos += scnprintf(buf + pos, bufsz - pos,
684 "\tcw_min\tcw_max\taifsn\ttxop\n");
685 pos += scnprintf(buf + pos, bufsz - pos,
686 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
687 priv->qos_data.def_qos_parm.ac[i].cw_min,
688 priv->qos_data.def_qos_parm.ac[i].cw_max,
689 priv->qos_data.def_qos_parm.ac[i].aifsn,
690 priv->qos_data.def_qos_parm.ac[i].edca_txop);
691 }
692 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
693 return ret;
694}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700695
Wey-Yi Guya283c012009-07-17 09:30:19 -0700696static ssize_t iwl_dbgfs_led_read(struct file *file, 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 Guya283c012009-07-17 09:30:19 -0700700 int pos = 0;
701 char buf[256];
702 const size_t bufsz = sizeof(buf);
703 ssize_t ret;
704
705 pos += scnprintf(buf + pos, bufsz - pos,
706 "allow blinking: %s\n",
707 (priv->allow_blinking) ? "True" : "False");
708 if (priv->allow_blinking) {
709 pos += scnprintf(buf + pos, bufsz - pos,
710 "Led blinking rate: %u\n",
711 priv->last_blink_rate);
712 pos += scnprintf(buf + pos, bufsz - pos,
713 "Last blink time: %lu\n",
714 priv->last_blink_time);
715 }
716
717 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
718 return ret;
719}
Wey-Yi Guya283c012009-07-17 09:30:19 -0700720
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700721static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
722 char __user *user_buf,
723 size_t count, loff_t *ppos)
724{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700725 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700726 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700727 struct iwl_tt_restriction *restriction;
728 char buf[100];
729 int pos = 0;
730 const size_t bufsz = sizeof(buf);
731 ssize_t ret;
732
733 pos += scnprintf(buf + pos, bufsz - pos,
734 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700735 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700736 pos += scnprintf(buf + pos, bufsz - pos,
737 "Thermal Throttling State: %d\n",
738 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700739 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700740 restriction = tt->restriction + tt->state;
741 pos += scnprintf(buf + pos, bufsz - pos,
742 "Tx mode: %d\n",
743 restriction->tx_stream);
744 pos += scnprintf(buf + pos, bufsz - pos,
745 "Rx mode: %d\n",
746 restriction->rx_stream);
747 pos += scnprintf(buf + pos, bufsz - pos,
748 "HT mode: %d\n",
749 restriction->is_ht);
750 }
751 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
752 return ret;
753}
754
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700755static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
756 const char __user *user_buf,
757 size_t count, loff_t *ppos)
758{
759 struct iwl_priv *priv = file->private_data;
760 char buf[8];
761 int buf_size;
762 int ht40;
763
764 memset(buf, 0, sizeof(buf));
765 buf_size = min(count, sizeof(buf) - 1);
766 if (copy_from_user(buf, user_buf, buf_size))
767 return -EFAULT;
768 if (sscanf(buf, "%d", &ht40) != 1)
769 return -EFAULT;
770 if (!iwl_is_associated(priv))
771 priv->disable_ht40 = ht40 ? true : false;
772 else {
773 IWL_ERR(priv, "Sta associated with AP - "
774 "Change to 40MHz channel support is not allowed\n");
775 return -EINVAL;
776 }
777
778 return count;
779}
780
781static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
782 char __user *user_buf,
783 size_t count, loff_t *ppos)
784{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700785 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700786 char buf[100];
787 int pos = 0;
788 const size_t bufsz = sizeof(buf);
789 ssize_t ret;
790
791 pos += scnprintf(buf + pos, bufsz - pos,
792 "11n 40MHz Mode: %s\n",
793 priv->disable_ht40 ? "Disabled" : "Enabled");
794 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
795 return ret;
796}
797
Johannes Berge312c242009-08-07 15:41:51 -0700798static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
799 const char __user *user_buf,
800 size_t count, loff_t *ppos)
801{
802 struct iwl_priv *priv = file->private_data;
803 char buf[8];
804 int buf_size;
805 int value;
806
807 memset(buf, 0, sizeof(buf));
808 buf_size = min(count, sizeof(buf) - 1);
809 if (copy_from_user(buf, user_buf, buf_size))
810 return -EFAULT;
811
812 if (sscanf(buf, "%d", &value) != 1)
813 return -EINVAL;
814
815 /*
816 * Our users expect 0 to be "CAM", but 0 isn't actually
817 * valid here. However, let's not confuse them and present
818 * IWL_POWER_INDEX_1 as "1", not "0".
819 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700820 if (value == 0)
821 return -EINVAL;
822 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700823 value -= 1;
824
825 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
826 return -EINVAL;
827
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700828 if (!iwl_is_ready_rf(priv))
829 return -EAGAIN;
830
Johannes Berge312c242009-08-07 15:41:51 -0700831 priv->power_data.debug_sleep_level_override = value;
832
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700833 iwl_power_update_mode(priv, true);
Johannes Berge312c242009-08-07 15:41:51 -0700834
835 return count;
836}
837
838static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
839 char __user *user_buf,
840 size_t count, loff_t *ppos)
841{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700842 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700843 char buf[10];
844 int pos, value;
845 const size_t bufsz = sizeof(buf);
846
847 /* see the write function */
848 value = priv->power_data.debug_sleep_level_override;
849 if (value >= 0)
850 value += 1;
851
852 pos = scnprintf(buf, bufsz, "%d\n", value);
853 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
854}
855
856static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
857 char __user *user_buf,
858 size_t count, loff_t *ppos)
859{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700860 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700861 char buf[200];
862 int pos = 0, i;
863 const size_t bufsz = sizeof(buf);
864 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
865
866 pos += scnprintf(buf + pos, bufsz - pos,
867 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
868 pos += scnprintf(buf + pos, bufsz - pos,
869 "RX/TX timeout: %d/%d usec\n",
870 le32_to_cpu(cmd->rx_data_timeout),
871 le32_to_cpu(cmd->tx_data_timeout));
872 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
873 pos += scnprintf(buf + pos, bufsz - pos,
874 "sleep_interval[%d]: %d\n", i,
875 le32_to_cpu(cmd->sleep_interval[i]));
876
877 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
878}
879
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700880DEBUGFS_READ_WRITE_FILE_OPS(sram);
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800881DEBUGFS_READ_WRITE_FILE_OPS(log_event);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700882DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700883DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800884DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700885DEBUGFS_READ_FILE_OPS(status);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700886DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700887DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700888DEBUGFS_READ_FILE_OPS(led);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700889DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700890DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Johannes Berge312c242009-08-07 15:41:51 -0700891DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
892DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700893
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700894static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
895 char __user *user_buf,
896 size_t count, loff_t *ppos)
897{
898 struct iwl_priv *priv = file->private_data;
899 int pos = 0, ofs = 0;
900 int cnt = 0, entry;
901 struct iwl_tx_queue *txq;
902 struct iwl_queue *q;
903 struct iwl_rx_queue *rxq = &priv->rxq;
904 char *buf;
905 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700906 (priv->cfg->num_of_queues * 32 * 8) + 400;
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700907 const u8 *ptr;
908 ssize_t ret;
909
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700910 if (!priv->txq) {
911 IWL_ERR(priv, "txq not ready\n");
912 return -EAGAIN;
913 }
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700914 buf = kzalloc(bufsz, GFP_KERNEL);
915 if (!buf) {
916 IWL_ERR(priv, "Can not allocate buffer\n");
917 return -ENOMEM;
918 }
919 pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n");
920 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
921 txq = &priv->txq[cnt];
922 q = &txq->q;
923 pos += scnprintf(buf + pos, bufsz - pos,
924 "q[%d]: read_ptr: %u, write_ptr: %u\n",
925 cnt, q->read_ptr, q->write_ptr);
926 }
927 if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) {
928 ptr = priv->tx_traffic;
929 pos += scnprintf(buf + pos, bufsz - pos,
930 "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
931 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
932 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
933 entry++, ofs += 16) {
934 pos += scnprintf(buf + pos, bufsz - pos,
935 "0x%.4x ", ofs);
936 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
937 buf + pos, bufsz - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700938 pos += strlen(buf + pos);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700939 if (bufsz - pos > 0)
940 buf[pos++] = '\n';
941 }
942 }
943 }
944
945 pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n");
946 pos += scnprintf(buf + pos, bufsz - pos,
947 "read: %u, write: %u\n",
948 rxq->read, rxq->write);
949
950 if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) {
951 ptr = priv->rx_traffic;
952 pos += scnprintf(buf + pos, bufsz - pos,
953 "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
954 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
955 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
956 entry++, ofs += 16) {
957 pos += scnprintf(buf + pos, bufsz - pos,
958 "0x%.4x ", ofs);
959 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
960 buf + pos, bufsz - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700961 pos += strlen(buf + pos);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700962 if (bufsz - pos > 0)
963 buf[pos++] = '\n';
964 }
965 }
966 }
967
968 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
969 kfree(buf);
970 return ret;
971}
972
973static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
974 const char __user *user_buf,
975 size_t count, loff_t *ppos)
976{
977 struct iwl_priv *priv = file->private_data;
978 char buf[8];
979 int buf_size;
980 int traffic_log;
981
982 memset(buf, 0, sizeof(buf));
983 buf_size = min(count, sizeof(buf) - 1);
984 if (copy_from_user(buf, user_buf, buf_size))
985 return -EFAULT;
986 if (sscanf(buf, "%d", &traffic_log) != 1)
987 return -EFAULT;
988 if (traffic_log == 0)
989 iwl_reset_traffic_log(priv);
990
991 return count;
992}
993
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700994static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
995 char __user *user_buf,
996 size_t count, loff_t *ppos) {
997
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700998 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700999 struct iwl_tx_queue *txq;
1000 struct iwl_queue *q;
1001 char *buf;
1002 int pos = 0;
1003 int cnt;
1004 int ret;
Wey-Yi Guyd23db552009-11-20 12:04:59 -08001005 const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001006
Wey-Yi Guy88804e22009-10-09 13:20:28 -07001007 if (!priv->txq) {
1008 IWL_ERR(priv, "txq not ready\n");
1009 return -EAGAIN;
1010 }
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001011 buf = kzalloc(bufsz, GFP_KERNEL);
1012 if (!buf)
1013 return -ENOMEM;
1014
1015 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
1016 txq = &priv->txq[cnt];
1017 q = &txq->q;
1018 pos += scnprintf(buf + pos, bufsz - pos,
1019 "hwq %.2d: read=%u write=%u stop=%d"
1020 " swq_id=%#.2x (ac %d/hwq %d)\n",
1021 cnt, q->read_ptr, q->write_ptr,
1022 !!test_bit(cnt, priv->queue_stopped),
1023 txq->swq_id,
1024 txq->swq_id & 0x80 ? txq->swq_id & 3 :
1025 txq->swq_id,
1026 txq->swq_id & 0x80 ? (txq->swq_id >> 2) &
1027 0x1f : txq->swq_id);
1028 if (cnt >= 4)
1029 continue;
1030 /* for the ACs, display the stop count too */
1031 pos += scnprintf(buf + pos, bufsz - pos,
1032 " stop-count: %d\n",
1033 atomic_read(&priv->queue_stop_count[cnt]));
1034 }
1035 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1036 kfree(buf);
1037 return ret;
1038}
1039
1040static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1041 char __user *user_buf,
1042 size_t count, loff_t *ppos) {
1043
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001044 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001045 struct iwl_rx_queue *rxq = &priv->rxq;
1046 char buf[256];
1047 int pos = 0;
1048 const size_t bufsz = sizeof(buf);
1049
1050 pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n",
1051 rxq->read);
1052 pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n",
1053 rxq->write);
1054 pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n",
1055 rxq->free_count);
1056 pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n",
1057 le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF);
1058 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1059}
1060
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001061static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
1062 int bufsz)
1063{
1064 int p = 0;
1065
1066 p += scnprintf(buf + p, bufsz - p,
1067 "Statistics Flag(0x%X):\n",
1068 le32_to_cpu(priv->statistics.flag));
1069 if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
1070 p += scnprintf(buf + p, bufsz - p,
1071 "\tStatistics have been cleared\n");
1072 p += scnprintf(buf + p, bufsz - p,
1073 "\tOperational Frequency: %s\n",
1074 (le32_to_cpu(priv->statistics.flag) &
1075 UCODE_STATISTICS_FREQUENCY_MSK)
1076 ? "2.4 GHz" : "5.2 GHz");
1077 p += scnprintf(buf + p, bufsz - p,
1078 "\tTGj Narrow Band: %s\n",
1079 (le32_to_cpu(priv->statistics.flag) &
1080 UCODE_STATISTICS_NARROW_BAND_MSK)
1081 ? "enabled" : "disabled");
1082 return p;
1083}
1084
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001085static const char ucode_stats_header[] =
1086 "%-32s current acumulative delta max\n";
1087static const char ucode_stats_short_format[] =
1088 " %-30s %10u\n";
1089static const char ucode_stats_format[] =
1090 " %-30s %10u %10u %10u %10u\n";
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001091
1092static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1093 char __user *user_buf,
1094 size_t count, loff_t *ppos)
1095{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001096 struct iwl_priv *priv = file->private_data;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001097 int pos = 0;
1098 char *buf;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001099 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
1100 sizeof(struct statistics_rx_non_phy) * 40 +
1101 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001102 ssize_t ret;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001103 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
1104 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001105 struct statistics_rx_non_phy *general, *accum_general;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001106 struct statistics_rx_non_phy *delta_general, *max_general;
1107 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001108
1109 if (!iwl_is_alive(priv))
1110 return -EAGAIN;
1111
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001112 buf = kzalloc(bufsz, GFP_KERNEL);
1113 if (!buf) {
1114 IWL_ERR(priv, "Can not allocate Buffer\n");
1115 return -ENOMEM;
1116 }
1117
1118 /* the statistic information display here is based on
1119 * the last statistics notification from uCode
1120 * might not reflect the current uCode activity
1121 */
1122 ofdm = &priv->statistics.rx.ofdm;
1123 cck = &priv->statistics.rx.cck;
1124 general = &priv->statistics.rx.general;
1125 ht = &priv->statistics.rx.ofdm_ht;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001126 accum_ofdm = &priv->accum_statistics.rx.ofdm;
1127 accum_cck = &priv->accum_statistics.rx.cck;
1128 accum_general = &priv->accum_statistics.rx.general;
1129 accum_ht = &priv->accum_statistics.rx.ofdm_ht;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001130 delta_ofdm = &priv->delta_statistics.rx.ofdm;
1131 delta_cck = &priv->delta_statistics.rx.cck;
1132 delta_general = &priv->delta_statistics.rx.general;
1133 delta_ht = &priv->delta_statistics.rx.ofdm_ht;
1134 max_ofdm = &priv->max_delta.rx.ofdm;
1135 max_cck = &priv->max_delta.rx.cck;
1136 max_general = &priv->max_delta.rx.general;
1137 max_ht = &priv->max_delta.rx.ofdm_ht;
1138
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001139 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001140 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1141 "Statistics_Rx - OFDM:");
1142 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1143 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
1144 accum_ofdm->ina_cnt,
1145 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
1146 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1147 "fina_cnt:",
1148 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
1149 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
1150 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1151 "plcp_err:",
1152 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
1153 delta_ofdm->plcp_err, max_ofdm->plcp_err);
1154 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1155 "crc32_err:",
1156 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
1157 delta_ofdm->crc32_err, max_ofdm->crc32_err);
1158 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1159 "overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001160 le32_to_cpu(ofdm->overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001161 accum_ofdm->overrun_err,
1162 delta_ofdm->overrun_err, max_ofdm->overrun_err);
1163 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1164 "early_overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001165 le32_to_cpu(ofdm->early_overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001166 accum_ofdm->early_overrun_err,
1167 delta_ofdm->early_overrun_err,
1168 max_ofdm->early_overrun_err);
1169 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1170 "crc32_good:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001171 le32_to_cpu(ofdm->crc32_good),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001172 accum_ofdm->crc32_good,
1173 delta_ofdm->crc32_good, max_ofdm->crc32_good);
1174 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1175 "false_alarm_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001176 le32_to_cpu(ofdm->false_alarm_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001177 accum_ofdm->false_alarm_cnt,
1178 delta_ofdm->false_alarm_cnt,
1179 max_ofdm->false_alarm_cnt);
1180 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1181 "fina_sync_err_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001182 le32_to_cpu(ofdm->fina_sync_err_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001183 accum_ofdm->fina_sync_err_cnt,
1184 delta_ofdm->fina_sync_err_cnt,
1185 max_ofdm->fina_sync_err_cnt);
1186 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1187 "sfd_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001188 le32_to_cpu(ofdm->sfd_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001189 accum_ofdm->sfd_timeout,
1190 delta_ofdm->sfd_timeout,
1191 max_ofdm->sfd_timeout);
1192 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1193 "fina_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001194 le32_to_cpu(ofdm->fina_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001195 accum_ofdm->fina_timeout,
1196 delta_ofdm->fina_timeout,
1197 max_ofdm->fina_timeout);
1198 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1199 "unresponded_rts:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001200 le32_to_cpu(ofdm->unresponded_rts),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001201 accum_ofdm->unresponded_rts,
1202 delta_ofdm->unresponded_rts,
1203 max_ofdm->unresponded_rts);
1204 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1205 "rxe_frame_lmt_ovrun:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001206 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001207 accum_ofdm->rxe_frame_limit_overrun,
1208 delta_ofdm->rxe_frame_limit_overrun,
1209 max_ofdm->rxe_frame_limit_overrun);
1210 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1211 "sent_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001212 le32_to_cpu(ofdm->sent_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001213 accum_ofdm->sent_ack_cnt,
1214 delta_ofdm->sent_ack_cnt,
1215 max_ofdm->sent_ack_cnt);
1216 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1217 "sent_cts_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001218 le32_to_cpu(ofdm->sent_cts_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001219 accum_ofdm->sent_cts_cnt,
1220 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
1221 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1222 "sent_ba_rsp_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001223 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001224 accum_ofdm->sent_ba_rsp_cnt,
1225 delta_ofdm->sent_ba_rsp_cnt,
1226 max_ofdm->sent_ba_rsp_cnt);
1227 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1228 "dsp_self_kill:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001229 le32_to_cpu(ofdm->dsp_self_kill),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001230 accum_ofdm->dsp_self_kill,
1231 delta_ofdm->dsp_self_kill,
1232 max_ofdm->dsp_self_kill);
1233 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1234 "mh_format_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001235 le32_to_cpu(ofdm->mh_format_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001236 accum_ofdm->mh_format_err,
1237 delta_ofdm->mh_format_err,
1238 max_ofdm->mh_format_err);
1239 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1240 "re_acq_main_rssi_sum:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001241 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001242 accum_ofdm->re_acq_main_rssi_sum,
1243 delta_ofdm->re_acq_main_rssi_sum,
1244 max_ofdm->re_acq_main_rssi_sum);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001245
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001246 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1247 "Statistics_Rx - CCK:");
1248 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1249 "ina_cnt:",
1250 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
1251 delta_cck->ina_cnt, max_cck->ina_cnt);
1252 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1253 "fina_cnt:",
1254 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
1255 delta_cck->fina_cnt, max_cck->fina_cnt);
1256 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1257 "plcp_err:",
1258 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1259 delta_cck->plcp_err, max_cck->plcp_err);
1260 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1261 "crc32_err:",
1262 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1263 delta_cck->crc32_err, max_cck->crc32_err);
1264 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1265 "overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001266 le32_to_cpu(cck->overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001267 accum_cck->overrun_err,
1268 delta_cck->overrun_err, max_cck->overrun_err);
1269 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1270 "early_overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001271 le32_to_cpu(cck->early_overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001272 accum_cck->early_overrun_err,
1273 delta_cck->early_overrun_err,
1274 max_cck->early_overrun_err);
1275 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1276 "crc32_good:",
1277 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1278 delta_cck->crc32_good,
1279 max_cck->crc32_good);
1280 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1281 "false_alarm_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001282 le32_to_cpu(cck->false_alarm_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001283 accum_cck->false_alarm_cnt,
1284 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1285 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1286 "fina_sync_err_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001287 le32_to_cpu(cck->fina_sync_err_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001288 accum_cck->fina_sync_err_cnt,
1289 delta_cck->fina_sync_err_cnt,
1290 max_cck->fina_sync_err_cnt);
1291 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1292 "sfd_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001293 le32_to_cpu(cck->sfd_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001294 accum_cck->sfd_timeout,
1295 delta_cck->sfd_timeout, max_cck->sfd_timeout);
1296 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1297 "fina_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001298 le32_to_cpu(cck->fina_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001299 accum_cck->fina_timeout,
1300 delta_cck->fina_timeout, max_cck->fina_timeout);
1301 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1302 "unresponded_rts:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001303 le32_to_cpu(cck->unresponded_rts),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001304 accum_cck->unresponded_rts,
1305 delta_cck->unresponded_rts,
1306 max_cck->unresponded_rts);
1307 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1308 "rxe_frame_lmt_ovrun:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001309 le32_to_cpu(cck->rxe_frame_limit_overrun),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001310 accum_cck->rxe_frame_limit_overrun,
1311 delta_cck->rxe_frame_limit_overrun,
1312 max_cck->rxe_frame_limit_overrun);
1313 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1314 "sent_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001315 le32_to_cpu(cck->sent_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001316 accum_cck->sent_ack_cnt,
1317 delta_cck->sent_ack_cnt,
1318 max_cck->sent_ack_cnt);
1319 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1320 "sent_cts_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001321 le32_to_cpu(cck->sent_cts_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001322 accum_cck->sent_cts_cnt,
1323 delta_cck->sent_cts_cnt,
1324 max_cck->sent_cts_cnt);
1325 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1326 "sent_ba_rsp_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001327 le32_to_cpu(cck->sent_ba_rsp_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001328 accum_cck->sent_ba_rsp_cnt,
1329 delta_cck->sent_ba_rsp_cnt,
1330 max_cck->sent_ba_rsp_cnt);
1331 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1332 "dsp_self_kill:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001333 le32_to_cpu(cck->dsp_self_kill),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001334 accum_cck->dsp_self_kill,
1335 delta_cck->dsp_self_kill,
1336 max_cck->dsp_self_kill);
1337 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1338 "mh_format_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001339 le32_to_cpu(cck->mh_format_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001340 accum_cck->mh_format_err,
1341 delta_cck->mh_format_err, max_cck->mh_format_err);
1342 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1343 "re_acq_main_rssi_sum:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001344 le32_to_cpu(cck->re_acq_main_rssi_sum),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001345 accum_cck->re_acq_main_rssi_sum,
1346 delta_cck->re_acq_main_rssi_sum,
1347 max_cck->re_acq_main_rssi_sum);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001348
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001349 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1350 "Statistics_Rx - GENERAL:");
1351 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1352 "bogus_cts:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001353 le32_to_cpu(general->bogus_cts),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001354 accum_general->bogus_cts,
1355 delta_general->bogus_cts, max_general->bogus_cts);
1356 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1357 "bogus_ack:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001358 le32_to_cpu(general->bogus_ack),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001359 accum_general->bogus_ack,
1360 delta_general->bogus_ack, max_general->bogus_ack);
1361 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1362 "non_bssid_frames:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001363 le32_to_cpu(general->non_bssid_frames),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001364 accum_general->non_bssid_frames,
1365 delta_general->non_bssid_frames,
1366 max_general->non_bssid_frames);
1367 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1368 "filtered_frames:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001369 le32_to_cpu(general->filtered_frames),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001370 accum_general->filtered_frames,
1371 delta_general->filtered_frames,
1372 max_general->filtered_frames);
1373 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1374 "non_channel_beacons:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001375 le32_to_cpu(general->non_channel_beacons),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001376 accum_general->non_channel_beacons,
1377 delta_general->non_channel_beacons,
1378 max_general->non_channel_beacons);
1379 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1380 "channel_beacons:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001381 le32_to_cpu(general->channel_beacons),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001382 accum_general->channel_beacons,
1383 delta_general->channel_beacons,
1384 max_general->channel_beacons);
1385 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1386 "num_missed_bcon:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001387 le32_to_cpu(general->num_missed_bcon),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001388 accum_general->num_missed_bcon,
1389 delta_general->num_missed_bcon,
1390 max_general->num_missed_bcon);
1391 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1392 "adc_rx_saturation_time:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001393 le32_to_cpu(general->adc_rx_saturation_time),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001394 accum_general->adc_rx_saturation_time,
1395 delta_general->adc_rx_saturation_time,
1396 max_general->adc_rx_saturation_time);
1397 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1398 "ina_detect_search_tm:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001399 le32_to_cpu(general->ina_detection_search_time),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001400 accum_general->ina_detection_search_time,
1401 delta_general->ina_detection_search_time,
1402 max_general->ina_detection_search_time);
1403 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1404 "beacon_silence_rssi_a:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001405 le32_to_cpu(general->beacon_silence_rssi_a),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001406 accum_general->beacon_silence_rssi_a,
1407 delta_general->beacon_silence_rssi_a,
1408 max_general->beacon_silence_rssi_a);
1409 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1410 "beacon_silence_rssi_b:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001411 le32_to_cpu(general->beacon_silence_rssi_b),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001412 accum_general->beacon_silence_rssi_b,
1413 delta_general->beacon_silence_rssi_b,
1414 max_general->beacon_silence_rssi_b);
1415 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1416 "beacon_silence_rssi_c:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001417 le32_to_cpu(general->beacon_silence_rssi_c),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001418 accum_general->beacon_silence_rssi_c,
1419 delta_general->beacon_silence_rssi_c,
1420 max_general->beacon_silence_rssi_c);
1421 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1422 "interference_data_flag:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001423 le32_to_cpu(general->interference_data_flag),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001424 accum_general->interference_data_flag,
1425 delta_general->interference_data_flag,
1426 max_general->interference_data_flag);
1427 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1428 "channel_load:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001429 le32_to_cpu(general->channel_load),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001430 accum_general->channel_load,
1431 delta_general->channel_load,
1432 max_general->channel_load);
1433 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1434 "dsp_false_alarms:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001435 le32_to_cpu(general->dsp_false_alarms),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001436 accum_general->dsp_false_alarms,
1437 delta_general->dsp_false_alarms,
1438 max_general->dsp_false_alarms);
1439 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1440 "beacon_rssi_a:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001441 le32_to_cpu(general->beacon_rssi_a),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001442 accum_general->beacon_rssi_a,
1443 delta_general->beacon_rssi_a,
1444 max_general->beacon_rssi_a);
1445 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1446 "beacon_rssi_b:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001447 le32_to_cpu(general->beacon_rssi_b),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001448 accum_general->beacon_rssi_b,
1449 delta_general->beacon_rssi_b,
1450 max_general->beacon_rssi_b);
1451 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1452 "beacon_rssi_c:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001453 le32_to_cpu(general->beacon_rssi_c),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001454 accum_general->beacon_rssi_c,
1455 delta_general->beacon_rssi_c,
1456 max_general->beacon_rssi_c);
1457 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1458 "beacon_energy_a:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001459 le32_to_cpu(general->beacon_energy_a),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001460 accum_general->beacon_energy_a,
1461 delta_general->beacon_energy_a,
1462 max_general->beacon_energy_a);
1463 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1464 "beacon_energy_b:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001465 le32_to_cpu(general->beacon_energy_b),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001466 accum_general->beacon_energy_b,
1467 delta_general->beacon_energy_b,
1468 max_general->beacon_energy_b);
1469 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1470 "beacon_energy_c:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001471 le32_to_cpu(general->beacon_energy_c),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001472 accum_general->beacon_energy_c,
1473 delta_general->beacon_energy_c,
1474 max_general->beacon_energy_c);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001475
1476 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001477 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1478 "Statistics_Rx - OFDM_HT:");
1479 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1480 "plcp_err:",
1481 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1482 delta_ht->plcp_err, max_ht->plcp_err);
1483 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1484 "overrun_err:",
1485 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1486 delta_ht->overrun_err, max_ht->overrun_err);
1487 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1488 "early_overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001489 le32_to_cpu(ht->early_overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001490 accum_ht->early_overrun_err,
1491 delta_ht->early_overrun_err,
1492 max_ht->early_overrun_err);
1493 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1494 "crc32_good:",
1495 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1496 delta_ht->crc32_good, max_ht->crc32_good);
1497 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1498 "crc32_err:",
1499 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1500 delta_ht->crc32_err, max_ht->crc32_err);
1501 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1502 "mh_format_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001503 le32_to_cpu(ht->mh_format_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001504 accum_ht->mh_format_err,
1505 delta_ht->mh_format_err, max_ht->mh_format_err);
1506 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1507 "agg_crc32_good:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001508 le32_to_cpu(ht->agg_crc32_good),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001509 accum_ht->agg_crc32_good,
1510 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1511 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1512 "agg_mpdu_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001513 le32_to_cpu(ht->agg_mpdu_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001514 accum_ht->agg_mpdu_cnt,
1515 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1516 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1517 "agg_cnt:",
1518 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1519 delta_ht->agg_cnt, max_ht->agg_cnt);
1520 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1521 "unsupport_mcs:",
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08001522 le32_to_cpu(ht->unsupport_mcs),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001523 accum_ht->unsupport_mcs,
1524 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001525
1526 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1527 kfree(buf);
1528 return ret;
1529}
1530
1531static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1532 char __user *user_buf,
1533 size_t count, loff_t *ppos)
1534{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001535 struct iwl_priv *priv = file->private_data;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001536 int pos = 0;
1537 char *buf;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001538 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001539 ssize_t ret;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001540 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001541
1542 if (!iwl_is_alive(priv))
1543 return -EAGAIN;
1544
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001545 buf = kzalloc(bufsz, GFP_KERNEL);
1546 if (!buf) {
1547 IWL_ERR(priv, "Can not allocate Buffer\n");
1548 return -ENOMEM;
1549 }
1550
1551 /* the statistic information display here is based on
1552 * the last statistics notification from uCode
1553 * might not reflect the current uCode activity
1554 */
1555 tx = &priv->statistics.tx;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001556 accum_tx = &priv->accum_statistics.tx;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001557 delta_tx = &priv->delta_statistics.tx;
1558 max_tx = &priv->max_delta.tx;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001559 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001560 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1561 "Statistics_Tx:");
1562 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1563 "preamble:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001564 le32_to_cpu(tx->preamble_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001565 accum_tx->preamble_cnt,
1566 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1567 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1568 "rx_detected_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001569 le32_to_cpu(tx->rx_detected_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001570 accum_tx->rx_detected_cnt,
1571 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1572 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1573 "bt_prio_defer_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001574 le32_to_cpu(tx->bt_prio_defer_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001575 accum_tx->bt_prio_defer_cnt,
1576 delta_tx->bt_prio_defer_cnt,
1577 max_tx->bt_prio_defer_cnt);
1578 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1579 "bt_prio_kill_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001580 le32_to_cpu(tx->bt_prio_kill_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001581 accum_tx->bt_prio_kill_cnt,
1582 delta_tx->bt_prio_kill_cnt,
1583 max_tx->bt_prio_kill_cnt);
1584 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1585 "few_bytes_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001586 le32_to_cpu(tx->few_bytes_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001587 accum_tx->few_bytes_cnt,
1588 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1589 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1590 "cts_timeout:",
1591 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1592 delta_tx->cts_timeout, max_tx->cts_timeout);
1593 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1594 "ack_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001595 le32_to_cpu(tx->ack_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001596 accum_tx->ack_timeout,
1597 delta_tx->ack_timeout, max_tx->ack_timeout);
1598 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1599 "expected_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001600 le32_to_cpu(tx->expected_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001601 accum_tx->expected_ack_cnt,
1602 delta_tx->expected_ack_cnt,
1603 max_tx->expected_ack_cnt);
1604 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1605 "actual_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001606 le32_to_cpu(tx->actual_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001607 accum_tx->actual_ack_cnt,
1608 delta_tx->actual_ack_cnt,
1609 max_tx->actual_ack_cnt);
1610 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1611 "dump_msdu_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001612 le32_to_cpu(tx->dump_msdu_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001613 accum_tx->dump_msdu_cnt,
1614 delta_tx->dump_msdu_cnt,
1615 max_tx->dump_msdu_cnt);
1616 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1617 "abort_nxt_frame_mismatch:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001618 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001619 accum_tx->burst_abort_next_frame_mismatch_cnt,
1620 delta_tx->burst_abort_next_frame_mismatch_cnt,
1621 max_tx->burst_abort_next_frame_mismatch_cnt);
1622 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1623 "abort_missing_nxt_frame:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001624 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001625 accum_tx->burst_abort_missing_next_frame_cnt,
1626 delta_tx->burst_abort_missing_next_frame_cnt,
1627 max_tx->burst_abort_missing_next_frame_cnt);
1628 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1629 "cts_timeout_collision:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001630 le32_to_cpu(tx->cts_timeout_collision),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001631 accum_tx->cts_timeout_collision,
1632 delta_tx->cts_timeout_collision,
1633 max_tx->cts_timeout_collision);
1634 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1635 "ack_ba_timeout_collision:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001636 le32_to_cpu(tx->ack_or_ba_timeout_collision),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001637 accum_tx->ack_or_ba_timeout_collision,
1638 delta_tx->ack_or_ba_timeout_collision,
1639 max_tx->ack_or_ba_timeout_collision);
1640 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1641 "agg ba_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001642 le32_to_cpu(tx->agg.ba_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001643 accum_tx->agg.ba_timeout,
1644 delta_tx->agg.ba_timeout,
1645 max_tx->agg.ba_timeout);
1646 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1647 "agg ba_resched_frames:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001648 le32_to_cpu(tx->agg.ba_reschedule_frames),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001649 accum_tx->agg.ba_reschedule_frames,
1650 delta_tx->agg.ba_reschedule_frames,
1651 max_tx->agg.ba_reschedule_frames);
1652 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1653 "agg scd_query_agg_frame:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001654 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001655 accum_tx->agg.scd_query_agg_frame_cnt,
1656 delta_tx->agg.scd_query_agg_frame_cnt,
1657 max_tx->agg.scd_query_agg_frame_cnt);
1658 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1659 "agg scd_query_no_agg:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001660 le32_to_cpu(tx->agg.scd_query_no_agg),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001661 accum_tx->agg.scd_query_no_agg,
1662 delta_tx->agg.scd_query_no_agg,
1663 max_tx->agg.scd_query_no_agg);
1664 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1665 "agg scd_query_agg:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001666 le32_to_cpu(tx->agg.scd_query_agg),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001667 accum_tx->agg.scd_query_agg,
1668 delta_tx->agg.scd_query_agg,
1669 max_tx->agg.scd_query_agg);
1670 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1671 "agg scd_query_mismatch:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001672 le32_to_cpu(tx->agg.scd_query_mismatch),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001673 accum_tx->agg.scd_query_mismatch,
1674 delta_tx->agg.scd_query_mismatch,
1675 max_tx->agg.scd_query_mismatch);
1676 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1677 "agg frame_not_ready:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001678 le32_to_cpu(tx->agg.frame_not_ready),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001679 accum_tx->agg.frame_not_ready,
1680 delta_tx->agg.frame_not_ready,
1681 max_tx->agg.frame_not_ready);
1682 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1683 "agg underrun:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001684 le32_to_cpu(tx->agg.underrun),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001685 accum_tx->agg.underrun,
1686 delta_tx->agg.underrun, max_tx->agg.underrun);
1687 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1688 "agg bt_prio_kill:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001689 le32_to_cpu(tx->agg.bt_prio_kill),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001690 accum_tx->agg.bt_prio_kill,
1691 delta_tx->agg.bt_prio_kill,
1692 max_tx->agg.bt_prio_kill);
1693 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1694 "agg rx_ba_rsp_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001695 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001696 accum_tx->agg.rx_ba_rsp_cnt,
1697 delta_tx->agg.rx_ba_rsp_cnt,
1698 max_tx->agg.rx_ba_rsp_cnt);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001699
1700 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1701 kfree(buf);
1702 return ret;
1703}
1704
1705static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1706 char __user *user_buf,
1707 size_t count, loff_t *ppos)
1708{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001709 struct iwl_priv *priv = file->private_data;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001710 int pos = 0;
1711 char *buf;
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08001712 int bufsz = sizeof(struct statistics_general) * 10 + 300;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001713 ssize_t ret;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001714 struct statistics_general *general, *accum_general;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001715 struct statistics_general *delta_general, *max_general;
1716 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1717 struct statistics_div *div, *accum_div, *delta_div, *max_div;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001718
1719 if (!iwl_is_alive(priv))
1720 return -EAGAIN;
1721
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001722 buf = kzalloc(bufsz, GFP_KERNEL);
1723 if (!buf) {
1724 IWL_ERR(priv, "Can not allocate Buffer\n");
1725 return -ENOMEM;
1726 }
1727
1728 /* the statistic information display here is based on
1729 * the last statistics notification from uCode
1730 * might not reflect the current uCode activity
1731 */
1732 general = &priv->statistics.general;
1733 dbg = &priv->statistics.general.dbg;
1734 div = &priv->statistics.general.div;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001735 accum_general = &priv->accum_statistics.general;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001736 delta_general = &priv->delta_statistics.general;
1737 max_general = &priv->max_delta.general;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001738 accum_dbg = &priv->accum_statistics.general.dbg;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001739 delta_dbg = &priv->delta_statistics.general.dbg;
1740 max_dbg = &priv->max_delta.general.dbg;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001741 accum_div = &priv->accum_statistics.general.div;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001742 delta_div = &priv->delta_statistics.general.div;
1743 max_div = &priv->max_delta.general.div;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001744 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001745 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1746 "Statistics_General:");
1747 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1748 "temperature:",
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001749 le32_to_cpu(general->temperature));
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001750 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1751 "temperature_m:",
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001752 le32_to_cpu(general->temperature_m));
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001753 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1754 "burst_check:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001755 le32_to_cpu(dbg->burst_check),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001756 accum_dbg->burst_check,
1757 delta_dbg->burst_check, max_dbg->burst_check);
1758 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1759 "burst_count:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001760 le32_to_cpu(dbg->burst_count),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001761 accum_dbg->burst_count,
1762 delta_dbg->burst_count, max_dbg->burst_count);
1763 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1764 "sleep_time:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001765 le32_to_cpu(general->sleep_time),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001766 accum_general->sleep_time,
1767 delta_general->sleep_time, max_general->sleep_time);
1768 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1769 "slots_out:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001770 le32_to_cpu(general->slots_out),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001771 accum_general->slots_out,
1772 delta_general->slots_out, max_general->slots_out);
1773 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1774 "slots_idle:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001775 le32_to_cpu(general->slots_idle),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001776 accum_general->slots_idle,
1777 delta_general->slots_idle, max_general->slots_idle);
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001778 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001779 le32_to_cpu(general->ttl_timestamp));
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001780 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1781 "tx_on_a:",
1782 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1783 delta_div->tx_on_a, max_div->tx_on_a);
1784 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1785 "tx_on_b:",
1786 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1787 delta_div->tx_on_b, max_div->tx_on_b);
1788 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1789 "exec_time:",
1790 le32_to_cpu(div->exec_time), accum_div->exec_time,
1791 delta_div->exec_time, max_div->exec_time);
1792 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1793 "probe_time:",
1794 le32_to_cpu(div->probe_time), accum_div->probe_time,
1795 delta_div->probe_time, max_div->probe_time);
1796 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1797 "rx_enable_counter:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001798 le32_to_cpu(general->rx_enable_counter),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001799 accum_general->rx_enable_counter,
1800 delta_general->rx_enable_counter,
1801 max_general->rx_enable_counter);
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08001802 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1803 "num_of_sos_states:",
1804 le32_to_cpu(general->num_of_sos_states),
1805 accum_general->num_of_sos_states,
1806 delta_general->num_of_sos_states,
1807 max_general->num_of_sos_states);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001808 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1809 kfree(buf);
1810 return ret;
1811}
1812
Wey-Yi Guy52259352009-08-07 15:41:43 -07001813static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1814 char __user *user_buf,
1815 size_t count, loff_t *ppos) {
1816
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001817 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001818 int pos = 0;
1819 int cnt = 0;
1820 char *buf;
1821 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1822 ssize_t ret;
1823 struct iwl_sensitivity_data *data;
1824
1825 data = &priv->sensitivity_data;
1826 buf = kzalloc(bufsz, GFP_KERNEL);
1827 if (!buf) {
1828 IWL_ERR(priv, "Can not allocate Buffer\n");
1829 return -ENOMEM;
1830 }
1831
1832 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1833 data->auto_corr_ofdm);
1834 pos += scnprintf(buf + pos, bufsz - pos,
1835 "auto_corr_ofdm_mrc:\t\t %u\n",
1836 data->auto_corr_ofdm_mrc);
1837 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1838 data->auto_corr_ofdm_x1);
1839 pos += scnprintf(buf + pos, bufsz - pos,
1840 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1841 data->auto_corr_ofdm_mrc_x1);
1842 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1843 data->auto_corr_cck);
1844 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1845 data->auto_corr_cck_mrc);
1846 pos += scnprintf(buf + pos, bufsz - pos,
1847 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1848 data->last_bad_plcp_cnt_ofdm);
1849 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1850 data->last_fa_cnt_ofdm);
1851 pos += scnprintf(buf + pos, bufsz - pos,
1852 "last_bad_plcp_cnt_cck:\t\t %u\n",
1853 data->last_bad_plcp_cnt_cck);
1854 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1855 data->last_fa_cnt_cck);
1856 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1857 data->nrg_curr_state);
1858 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1859 data->nrg_prev_state);
1860 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1861 for (cnt = 0; cnt < 10; cnt++) {
1862 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1863 data->nrg_value[cnt]);
1864 }
1865 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1866 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1867 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1868 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1869 data->nrg_silence_rssi[cnt]);
1870 }
1871 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1872 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1873 data->nrg_silence_ref);
1874 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1875 data->nrg_energy_idx);
1876 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1877 data->nrg_silence_idx);
1878 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1879 data->nrg_th_cck);
1880 pos += scnprintf(buf + pos, bufsz - pos,
1881 "nrg_auto_corr_silence_diff:\t %u\n",
1882 data->nrg_auto_corr_silence_diff);
1883 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1884 data->num_in_cck_no_fa);
1885 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1886 data->nrg_th_ofdm);
1887
1888 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1889 kfree(buf);
1890 return ret;
1891}
1892
1893
1894static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1895 char __user *user_buf,
1896 size_t count, loff_t *ppos) {
1897
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001898 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001899 int pos = 0;
1900 int cnt = 0;
1901 char *buf;
1902 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1903 ssize_t ret;
1904 struct iwl_chain_noise_data *data;
1905
1906 data = &priv->chain_noise_data;
1907 buf = kzalloc(bufsz, GFP_KERNEL);
1908 if (!buf) {
1909 IWL_ERR(priv, "Can not allocate Buffer\n");
1910 return -ENOMEM;
1911 }
1912
1913 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1914 data->active_chains);
1915 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1916 data->chain_noise_a);
1917 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1918 data->chain_noise_b);
1919 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1920 data->chain_noise_c);
1921 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1922 data->chain_signal_a);
1923 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1924 data->chain_signal_b);
1925 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1926 data->chain_signal_c);
1927 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1928 data->beacon_count);
1929
1930 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1931 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1932 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1933 data->disconn_array[cnt]);
1934 }
1935 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1936 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1937 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1938 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1939 data->delta_gain_code[cnt]);
1940 }
1941 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1942 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1943 data->radio_write);
1944 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1945 data->state);
1946
1947 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1948 kfree(buf);
1949 return ret;
1950}
1951
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001952static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1953 char __user *user_buf,
1954 size_t count, loff_t *ppos) {
1955
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001956 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001957 char buf[128];
1958 int pos = 0;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001959 const size_t bufsz = sizeof(buf);
1960 struct statistics_tx *tx;
1961
1962 if (!iwl_is_alive(priv))
1963 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1964 else {
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001965 tx = &priv->statistics.tx;
1966 if (tx->tx_power.ant_a ||
1967 tx->tx_power.ant_b ||
1968 tx->tx_power.ant_c) {
1969 pos += scnprintf(buf + pos, bufsz - pos,
1970 "tx power: (1/2 dB step)\n");
1971 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1972 tx->tx_power.ant_a)
1973 pos += scnprintf(buf + pos, bufsz - pos,
1974 "\tantenna A: 0x%X\n",
1975 tx->tx_power.ant_a);
1976 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1977 tx->tx_power.ant_b)
1978 pos += scnprintf(buf + pos, bufsz - pos,
1979 "\tantenna B: 0x%X\n",
1980 tx->tx_power.ant_b);
1981 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1982 tx->tx_power.ant_c)
1983 pos += scnprintf(buf + pos, bufsz - pos,
1984 "\tantenna C: 0x%X\n",
1985 tx->tx_power.ant_c);
1986 } else
1987 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1988 }
1989 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1990}
1991
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001992static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1993 char __user *user_buf,
1994 size_t count, loff_t *ppos)
1995{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001996 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001997 char buf[60];
1998 int pos = 0;
1999 const size_t bufsz = sizeof(buf);
2000 u32 pwrsave_status;
2001
2002 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
2003 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
2004
2005 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
2006 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
2007 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
2008 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
2009 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
2010 "error");
2011
2012 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2013}
2014
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002015static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08002016 const char __user *user_buf,
2017 size_t count, loff_t *ppos)
2018{
2019 struct iwl_priv *priv = file->private_data;
2020 char buf[8];
2021 int buf_size;
2022 int clear;
2023
2024 memset(buf, 0, sizeof(buf));
2025 buf_size = min(count, sizeof(buf) - 1);
2026 if (copy_from_user(buf, user_buf, buf_size))
2027 return -EFAULT;
2028 if (sscanf(buf, "%d", &clear) != 1)
2029 return -EFAULT;
2030
2031 /* make request to uCode to retrieve statistics information */
2032 mutex_lock(&priv->mutex);
2033 iwl_send_statistics_request(priv, CMD_SYNC, true);
2034 mutex_unlock(&priv->mutex);
2035
2036 return count;
2037}
2038
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002039static ssize_t iwl_dbgfs_csr_write(struct file *file,
2040 const char __user *user_buf,
2041 size_t count, loff_t *ppos)
2042{
2043 struct iwl_priv *priv = file->private_data;
2044 char buf[8];
2045 int buf_size;
2046 int csr;
2047
2048 memset(buf, 0, sizeof(buf));
2049 buf_size = min(count, sizeof(buf) - 1);
2050 if (copy_from_user(buf, user_buf, buf_size))
2051 return -EFAULT;
2052 if (sscanf(buf, "%d", &csr) != 1)
2053 return -EFAULT;
2054
2055 if (priv->cfg->ops->lib->dump_csr)
2056 priv->cfg->ops->lib->dump_csr(priv);
2057
2058 return count;
2059}
2060
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002061static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2062 char __user *user_buf,
2063 size_t count, loff_t *ppos) {
2064
2065 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2066 int pos = 0;
2067 char buf[128];
2068 const size_t bufsz = sizeof(buf);
2069 ssize_t ret;
2070
2071 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2072 priv->event_log.ucode_trace ? "On" : "Off");
2073 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
2074 priv->event_log.non_wraps_count);
2075 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
2076 priv->event_log.wraps_once_count);
2077 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2078 priv->event_log.wraps_more_count);
2079
2080 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2081 return ret;
2082}
2083
2084static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2085 const char __user *user_buf,
2086 size_t count, loff_t *ppos)
2087{
2088 struct iwl_priv *priv = file->private_data;
2089 char buf[8];
2090 int buf_size;
2091 int trace;
2092
2093 memset(buf, 0, sizeof(buf));
2094 buf_size = min(count, sizeof(buf) - 1);
2095 if (copy_from_user(buf, user_buf, buf_size))
2096 return -EFAULT;
2097 if (sscanf(buf, "%d", &trace) != 1)
2098 return -EFAULT;
2099
2100 if (trace) {
2101 priv->event_log.ucode_trace = true;
2102 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2103 mod_timer(&priv->ucode_trace,
2104 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
2105 } else {
2106 priv->event_log.ucode_trace = false;
2107 del_timer_sync(&priv->ucode_trace);
2108 }
2109
2110 return count;
2111}
2112
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002113static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
2114 char __user *user_buf,
2115 size_t count, loff_t *ppos)
2116{
2117 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2118 char *buf;
2119 int pos = 0;
2120 ssize_t ret = -EFAULT;
2121
2122 if (priv->cfg->ops->lib->dump_fh) {
2123 ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true);
2124 if (buf) {
2125 ret = simple_read_from_buffer(user_buf,
2126 count, ppos, buf, pos);
2127 kfree(buf);
2128 }
2129 }
2130
2131 return ret;
2132}
2133
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002134static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2135 char __user *user_buf,
2136 size_t count, loff_t *ppos) {
2137
2138 struct iwl_priv *priv = file->private_data;
2139 int pos = 0;
2140 char buf[12];
2141 const size_t bufsz = sizeof(buf);
2142 ssize_t ret;
2143
2144 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2145 priv->missed_beacon_threshold);
2146
2147 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2148 return ret;
2149}
2150
2151static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2152 const char __user *user_buf,
2153 size_t count, loff_t *ppos)
2154{
2155 struct iwl_priv *priv = file->private_data;
2156 char buf[8];
2157 int buf_size;
2158 int missed;
2159
2160 memset(buf, 0, sizeof(buf));
2161 buf_size = min(count, sizeof(buf) - 1);
2162 if (copy_from_user(buf, user_buf, buf_size))
2163 return -EFAULT;
2164 if (sscanf(buf, "%d", &missed) != 1)
2165 return -EINVAL;
2166
2167 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2168 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2169 priv->missed_beacon_threshold =
2170 IWL_MISSED_BEACON_THRESHOLD_DEF;
2171 else
2172 priv->missed_beacon_threshold = missed;
2173
2174 return count;
2175}
2176
Wey-Yi Guyafbdd692010-01-22 14:22:43 -08002177static ssize_t iwl_dbgfs_internal_scan_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 scan;
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", &scan) != 1)
2191 return -EINVAL;
2192
2193 iwl_internal_short_hw_scan(priv);
2194
2195 return count;
2196}
2197
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002198static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2199 char __user *user_buf,
2200 size_t count, loff_t *ppos) {
2201
2202 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2203 int pos = 0;
2204 char buf[12];
2205 const size_t bufsz = sizeof(buf);
2206 ssize_t ret;
2207
2208 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
2209 priv->cfg->plcp_delta_threshold);
2210
2211 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2212 return ret;
2213}
2214
2215static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2216 const char __user *user_buf,
2217 size_t count, loff_t *ppos) {
2218
2219 struct iwl_priv *priv = file->private_data;
2220 char buf[8];
2221 int buf_size;
2222 int plcp;
2223
2224 memset(buf, 0, sizeof(buf));
2225 buf_size = min(count, sizeof(buf) - 1);
2226 if (copy_from_user(buf, user_buf, buf_size))
2227 return -EFAULT;
2228 if (sscanf(buf, "%d", &plcp) != 1)
2229 return -EINVAL;
2230 if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
2231 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
2232 priv->cfg->plcp_delta_threshold =
2233 IWL_MAX_PLCP_ERR_THRESHOLD_DEF;
2234 else
2235 priv->cfg->plcp_delta_threshold = plcp;
2236 return count;
2237}
2238
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002239DEBUGFS_READ_FILE_OPS(rx_statistics);
2240DEBUGFS_READ_FILE_OPS(tx_statistics);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002241DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07002242DEBUGFS_READ_FILE_OPS(rx_queue);
2243DEBUGFS_READ_FILE_OPS(tx_queue);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002244DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2245DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2246DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002247DEBUGFS_READ_FILE_OPS(sensitivity);
2248DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyf204b242009-08-21 13:34:19 -07002249DEBUGFS_READ_FILE_OPS(tx_power);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002250DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002251DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2252DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002253DEBUGFS_WRITE_FILE_OPS(csr);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002254DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002255DEBUGFS_READ_FILE_OPS(fh_reg);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002256DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Wey-Yi Guyafbdd692010-01-22 14:22:43 -08002257DEBUGFS_WRITE_FILE_OPS(internal_scan);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002258DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002259
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002260/*
2261 * Create the debugfs files and directories
2262 *
2263 */
2264int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2265{
2266 struct iwl_debugfs *dbgfs;
Zhu Yi95b1a822008-05-29 16:34:50 +08002267 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Tomas Winkler3ac7f142008-07-21 02:40:14 +03002268 int ret = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002269
2270 dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL);
2271 if (!dbgfs) {
Tomas Winkler3ac7f142008-07-21 02:40:14 +03002272 ret = -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002273 goto err;
2274 }
2275
2276 priv->dbgfs = dbgfs;
2277 dbgfs->name = name;
Zhu Yi95b1a822008-05-29 16:34:50 +08002278 dbgfs->dir_drv = debugfs_create_dir(name, phyd);
Tomas Winkler3ac7f142008-07-21 02:40:14 +03002279 if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) {
2280 ret = -ENOENT;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002281 goto err;
2282 }
2283
2284 DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
Tomas Winkler445c2df2008-05-15 13:54:16 +08002285 DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002286 DEBUGFS_ADD_DIR(debug, dbgfs->dir_drv);
Wey-Yi Guy43e85112009-11-20 12:04:58 -08002287 DEBUGFS_ADD_FILE(nvm, data, S_IRUSR);
2288 DEBUGFS_ADD_FILE(sram, data, S_IWUSR | S_IRUSR);
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -08002289 DEBUGFS_ADD_FILE(log_event, data, S_IWUSR | S_IRUSR);
Wey-Yi Guy43e85112009-11-20 12:04:58 -08002290 DEBUGFS_ADD_FILE(stations, data, S_IRUSR);
2291 DEBUGFS_ADD_FILE(channels, data, S_IRUSR);
2292 DEBUGFS_ADD_FILE(status, data, S_IRUSR);
2293 DEBUGFS_ADD_FILE(interrupt, data, S_IWUSR | S_IRUSR);
2294 DEBUGFS_ADD_FILE(qos, data, S_IRUSR);
2295 DEBUGFS_ADD_FILE(led, data, S_IRUSR);
2296 DEBUGFS_ADD_FILE(sleep_level_override, data, S_IWUSR | S_IRUSR);
2297 DEBUGFS_ADD_FILE(current_sleep_command, data, S_IRUSR);
2298 DEBUGFS_ADD_FILE(thermal_throttling, data, S_IRUSR);
2299 DEBUGFS_ADD_FILE(disable_ht40, data, S_IWUSR | S_IRUSR);
2300 DEBUGFS_ADD_FILE(rx_statistics, debug, S_IRUSR);
2301 DEBUGFS_ADD_FILE(tx_statistics, debug, S_IRUSR);
2302 DEBUGFS_ADD_FILE(traffic_log, debug, S_IWUSR | S_IRUSR);
2303 DEBUGFS_ADD_FILE(rx_queue, debug, S_IRUSR);
2304 DEBUGFS_ADD_FILE(tx_queue, debug, S_IRUSR);
2305 DEBUGFS_ADD_FILE(tx_power, debug, S_IRUSR);
2306 DEBUGFS_ADD_FILE(power_save_status, debug, S_IRUSR);
2307 DEBUGFS_ADD_FILE(clear_ucode_statistics, debug, S_IWUSR);
2308 DEBUGFS_ADD_FILE(clear_traffic_statistics, debug, S_IWUSR);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002309 DEBUGFS_ADD_FILE(csr, debug, S_IWUSR);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002310 DEBUGFS_ADD_FILE(fh_reg, debug, S_IRUSR);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002311 DEBUGFS_ADD_FILE(missed_beacon, debug, S_IWUSR);
Wey-Yi Guyafbdd692010-01-22 14:22:43 -08002312 DEBUGFS_ADD_FILE(internal_scan, debug, S_IWUSR);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002313 DEBUGFS_ADD_FILE(plcp_delta, debug, S_IWUSR | S_IRUSR);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002314 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
Wey-Yi Guy43e85112009-11-20 12:04:58 -08002315 DEBUGFS_ADD_FILE(ucode_rx_stats, debug, S_IRUSR);
2316 DEBUGFS_ADD_FILE(ucode_tx_stats, debug, S_IRUSR);
2317 DEBUGFS_ADD_FILE(ucode_general_stats, debug, S_IRUSR);
2318 DEBUGFS_ADD_FILE(sensitivity, debug, S_IRUSR);
2319 DEBUGFS_ADD_FILE(chain_noise, debug, S_IRUSR);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002320 DEBUGFS_ADD_FILE(ucode_tracing, debug, S_IWUSR | S_IRUSR);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002321 }
Tomas Winkler445c2df2008-05-15 13:54:16 +08002322 DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
2323 DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
2324 &priv->disable_chain_noise_cal);
Wey-Yi Guy030b8652009-06-12 13:22:55 -07002325 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
2326 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
2327 DEBUGFS_ADD_BOOL(disable_tx_power, rf,
2328 &priv->disable_tx_power_cal);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002329 return 0;
2330
2331err:
Winkler, Tomas15b16872008-12-19 10:37:33 +08002332 IWL_ERR(priv, "Can't open the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002333 iwl_dbgfs_unregister(priv);
Tomas Winkler3ac7f142008-07-21 02:40:14 +03002334 return ret;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002335}
2336EXPORT_SYMBOL(iwl_dbgfs_register);
2337
2338/**
2339 * Remove the debugfs files and directories
2340 *
2341 */
2342void iwl_dbgfs_unregister(struct iwl_priv *priv)
2343{
Tomas Winkler3ac7f142008-07-21 02:40:14 +03002344 if (!priv->dbgfs)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002345 return;
2346
Johannes Berge312c242009-08-07 15:41:51 -07002347 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sleep_level_override);
2348 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_current_sleep_command);
Wey-Yi Guy0848e292009-05-22 11:01:46 -07002349 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002350 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
Ester Kummer189a2b52008-05-15 13:54:18 +08002351 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002352 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -08002353 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -07002354 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status);
Wey-Yi Guya83b9142009-04-08 11:39:32 -07002355 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -07002356 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_qos);
Wey-Yi Guya283c012009-07-17 09:30:19 -07002357 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_led);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -07002358 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -07002359 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_disable_ht40);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002360 DEBUGFS_REMOVE(priv->dbgfs->dir_data);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -07002361 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_statistics);
2362 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_statistics);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002363 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_traffic_log);
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07002364 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_queue);
2365 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_queue);
Wey-Yi Guyf204b242009-08-21 13:34:19 -07002366 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_power);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002367 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002368 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2369 file_clear_ucode_statistics);
2370 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2371 file_clear_traffic_statistics);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002372 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_csr);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002373 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_fh_reg);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002374 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_missed_beacon);
Wey-Yi Guyafbdd692010-01-22 14:22:43 -08002375 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_internal_scan);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002376 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_plcp_delta);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002377 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
2378 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2379 file_ucode_rx_stats);
2380 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2381 file_ucode_tx_stats);
2382 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2383 file_ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002384 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2385 file_sensitivity);
2386 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2387 file_chain_noise);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002388 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
2389 file_ucode_tracing);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002390 }
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002391 DEBUGFS_REMOVE(priv->dbgfs->dir_debug);
Tomas Winkler445c2df2008-05-15 13:54:16 +08002392 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
2393 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
Wey-Yi Guy030b8652009-06-12 13:22:55 -07002394 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
2395 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
2396 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power);
Tomas Winkler445c2df2008-05-15 13:54:16 +08002397 DEBUGFS_REMOVE(priv->dbgfs->dir_rf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002398 DEBUGFS_REMOVE(priv->dbgfs->dir_drv);
2399 kfree(priv->dbgfs);
2400 priv->dbgfs = NULL;
2401}
2402EXPORT_SYMBOL(iwl_dbgfs_unregister);
2403
2404
Tomas Winkler445c2df2008-05-15 13:54:16 +08002405