blob: d9255b53be109d7b30bbc6313a68df6e916105d5 [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 */
Johannes Berg4c84a8f2010-01-22 14:22:54 -080044#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
45 if (!debugfs_create_file(#name, mode, parent, priv, \
46 &iwl_dbgfs_##name##_ops)) \
47 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070048} while (0)
49
Johannes Berg4c84a8f2010-01-22 14:22:54 -080050#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
51 struct dentry *__tmp; \
52 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
53 parent, ptr); \
54 if (IS_ERR(__tmp) || !__tmp) \
55 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070056} while (0)
57
Johannes Berg4c84a8f2010-01-22 14:22:54 -080058#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
59 struct dentry *__tmp; \
60 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
61 parent, ptr); \
62 if (IS_ERR(__tmp) || !__tmp) \
63 goto err; \
Tomas Winkler445c2df2008-05-15 13:54:16 +080064} while (0)
65
Tomas Winkler712b6cf2008-03-12 16:58:52 -070066/* file operation */
67#define DEBUGFS_READ_FUNC(name) \
68static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
69 char __user *user_buf, \
70 size_t count, loff_t *ppos);
71
72#define DEBUGFS_WRITE_FUNC(name) \
73static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
74 const char __user *user_buf, \
75 size_t count, loff_t *ppos);
76
77
78static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
79{
80 file->private_data = inode->i_private;
81 return 0;
82}
83
84#define DEBUGFS_READ_FILE_OPS(name) \
85 DEBUGFS_READ_FUNC(name); \
86static const struct file_operations iwl_dbgfs_##name##_ops = { \
87 .read = iwl_dbgfs_##name##_read, \
88 .open = iwl_dbgfs_open_file_generic, \
89};
90
Ester Kummer189a2b52008-05-15 13:54:18 +080091#define DEBUGFS_WRITE_FILE_OPS(name) \
92 DEBUGFS_WRITE_FUNC(name); \
93static const struct file_operations iwl_dbgfs_##name##_ops = { \
94 .write = iwl_dbgfs_##name##_write, \
95 .open = iwl_dbgfs_open_file_generic, \
96};
97
98
Tomas Winkler712b6cf2008-03-12 16:58:52 -070099#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
100 DEBUGFS_READ_FUNC(name); \
101 DEBUGFS_WRITE_FUNC(name); \
102static const struct file_operations iwl_dbgfs_##name##_ops = { \
103 .write = iwl_dbgfs_##name##_write, \
104 .read = iwl_dbgfs_##name##_read, \
105 .open = iwl_dbgfs_open_file_generic, \
106};
107
108
109static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
110 char __user *user_buf,
111 size_t count, loff_t *ppos) {
112
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700113 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700114 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700115 int pos = 0;
116
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700117 int cnt;
118 ssize_t ret;
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800119 const size_t bufsz = 100 +
120 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700121 buf = kzalloc(bufsz, GFP_KERNEL);
122 if (!buf)
123 return -ENOMEM;
124 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
125 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
126 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800127 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700128 get_mgmt_string(cnt),
129 priv->tx_stats.mgmt[cnt]);
130 }
131 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
132 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
133 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800134 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700135 get_ctrl_string(cnt),
136 priv->tx_stats.ctrl[cnt]);
137 }
138 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
139 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
140 priv->tx_stats.data_cnt);
141 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
142 priv->tx_stats.data_bytes);
143 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
144 kfree(buf);
145 return ret;
146}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700147
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800148static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700149 const char __user *user_buf,
150 size_t count, loff_t *ppos)
151{
152 struct iwl_priv *priv = file->private_data;
153 u32 clear_flag;
154 char buf[8];
155 int buf_size;
156
157 memset(buf, 0, sizeof(buf));
158 buf_size = min(count, sizeof(buf) - 1);
159 if (copy_from_user(buf, user_buf, buf_size))
160 return -EFAULT;
161 if (sscanf(buf, "%x", &clear_flag) != 1)
162 return -EFAULT;
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800163 iwl_clear_traffic_stats(priv);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700164
165 return count;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700166}
167
168static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
169 char __user *user_buf,
170 size_t count, loff_t *ppos) {
171
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700172 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700173 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700174 int pos = 0;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700175 int cnt;
176 ssize_t ret;
177 const size_t bufsz = 100 +
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800178 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700179 buf = kzalloc(bufsz, GFP_KERNEL);
180 if (!buf)
181 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700182
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700183 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
184 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
185 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800186 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700187 get_mgmt_string(cnt),
188 priv->rx_stats.mgmt[cnt]);
189 }
190 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
191 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
192 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800193 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700194 get_ctrl_string(cnt),
195 priv->rx_stats.ctrl[cnt]);
196 }
197 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
198 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
199 priv->rx_stats.data_cnt);
200 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
201 priv->rx_stats.data_bytes);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700202
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700203 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
204 kfree(buf);
205 return ret;
206}
207
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700208#define BYTE1_MASK 0x000000ff;
209#define BYTE2_MASK 0x0000ffff;
210#define BYTE3_MASK 0x00ffffff;
211static ssize_t iwl_dbgfs_sram_read(struct file *file,
212 char __user *user_buf,
213 size_t count, loff_t *ppos)
214{
215 u32 val;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800216 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700217 ssize_t ret;
218 int i;
219 int pos = 0;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700220 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800221 size_t bufsz;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700222
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800223 /* default is to dump the entire data segment */
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800224 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
225 priv->dbgfs_sram_offset = 0x800000;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800226 if (priv->ucode_type == UCODE_INIT)
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800227 priv->dbgfs_sram_len = priv->ucode_init_data.len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800228 else
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800229 priv->dbgfs_sram_len = priv->ucode_data.len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800230 }
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800231 bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800232 buf = kmalloc(bufsz, GFP_KERNEL);
233 if (!buf)
234 return -ENOMEM;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800235 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800236 priv->dbgfs_sram_len);
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800237 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800238 priv->dbgfs_sram_offset);
239 for (i = priv->dbgfs_sram_len; i > 0; i -= 4) {
240 val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \
241 priv->dbgfs_sram_len - i);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700242 if (i < 4) {
243 switch (i) {
244 case 1:
245 val &= BYTE1_MASK;
246 break;
247 case 2:
248 val &= BYTE2_MASK;
249 break;
250 case 3:
251 val &= BYTE3_MASK;
252 break;
253 }
254 }
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800255 if (!(i % 16))
256 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700257 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700258 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700259 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700260
261 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800262 kfree(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700263 return ret;
264}
265
266static ssize_t iwl_dbgfs_sram_write(struct file *file,
267 const char __user *user_buf,
268 size_t count, loff_t *ppos)
269{
270 struct iwl_priv *priv = file->private_data;
271 char buf[64];
272 int buf_size;
273 u32 offset, len;
274
275 memset(buf, 0, sizeof(buf));
276 buf_size = min(count, sizeof(buf) - 1);
277 if (copy_from_user(buf, user_buf, buf_size))
278 return -EFAULT;
279
280 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800281 priv->dbgfs_sram_offset = offset;
282 priv->dbgfs_sram_len = len;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700283 } else {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800284 priv->dbgfs_sram_offset = 0;
285 priv->dbgfs_sram_len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700286 }
287
288 return count;
289}
290
291static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
292 size_t count, loff_t *ppos)
293{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700294 struct iwl_priv *priv = file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800295 struct iwl_station_entry *station;
Tomas Winkler5425e492008-04-15 16:01:38 -0700296 int max_sta = priv->hw_params.max_stations;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700297 char *buf;
298 int i, j, pos = 0;
299 ssize_t ret;
300 /* Add 30 for initial string */
301 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700302
303 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300304 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700305 return -ENOMEM;
306
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700307 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700308 priv->num_stations);
309
310 for (i = 0; i < max_sta; i++) {
311 station = &priv->stations[i];
312 if (station->used) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700313 pos += scnprintf(buf + pos, bufsz - pos,
314 "station %d:\ngeneral data:\n", i+1);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700315 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700316 station->sta.sta.sta_id);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700317 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700318 station->sta.mode);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700319 pos += scnprintf(buf + pos, bufsz - pos,
320 "flags: 0x%x\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700321 station->sta.station_flags_msk);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700322 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
323 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700324 "seq_num\t\ttxq_id");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700325 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700326 "\tframe_count\twait_for_ba\t");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700327 pos += scnprintf(buf + pos, bufsz - pos,
328 "start_idx\tbitmap0\t");
329 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700330 "bitmap1\trate_n_flags");
David S. Miller344234d2008-04-19 18:09:39 -0700331 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700332
333 for (j = 0; j < MAX_TID_COUNT; j++) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700334 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700335 "[%d]:\t\t%u", j,
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700336 station->tid[j].seq_number);
337 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700338 "\t%u\t\t%u\t\t%u\t\t",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700339 station->tid[j].agg.txq_id,
340 station->tid[j].agg.frame_count,
341 station->tid[j].agg.wait_for_ba);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700342 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700343 "%u\t%llu\t%u",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700344 station->tid[j].agg.start_idx,
John W. Linville16788592008-04-01 20:59:32 -0400345 (unsigned long long)station->tid[j].agg.bitmap,
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700346 station->tid[j].agg.rate_n_flags);
David S. Miller344234d2008-04-19 18:09:39 -0700347 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700348 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700349 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700350 }
351 }
352
353 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
354 kfree(buf);
355 return ret;
356}
357
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700358static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800359 char __user *user_buf,
360 size_t count,
361 loff_t *ppos)
362{
363 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700364 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800365 int pos = 0, ofs = 0, buf_size = 0;
366 const u8 *ptr;
367 char *buf;
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700368 u16 eeprom_ver;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800369 size_t eeprom_len = priv->cfg->eeprom_size;
370 buf_size = 4 * eeprom_len + 256;
371
372 if (eeprom_len % 16) {
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700373 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800374 return -ENODATA;
375 }
376
Julia Lawallc37457e2009-08-03 11:11:45 +0200377 ptr = priv->eeprom;
378 if (!ptr) {
379 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
380 return -ENOMEM;
381 }
382
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800383 /* 4 characters for byte 0xYY */
384 buf = kzalloc(buf_size, GFP_KERNEL);
385 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800386 IWL_ERR(priv, "Can not allocate Buffer\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800387 return -ENOMEM;
388 }
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700389 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
390 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
391 "version: 0x%x\n",
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700392 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700393 ? "OTP" : "EEPROM", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800394 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
395 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
396 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
397 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700398 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800399 if (buf_size - pos > 0)
400 buf[pos++] = '\n';
401 }
402
403 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
404 kfree(buf);
405 return ret;
406}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700407
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800408static ssize_t iwl_dbgfs_log_event_read(struct file *file,
409 char __user *user_buf,
410 size_t count, loff_t *ppos)
411{
412 struct iwl_priv *priv = file->private_data;
413 char *buf;
414 int pos = 0;
415 ssize_t ret = -ENOMEM;
416
Wey-Yi Guy937c3972010-01-15 13:43:36 -0800417 ret = pos = priv->cfg->ops->lib->dump_nic_event_log(
418 priv, true, &buf, true);
419 if (buf) {
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800420 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
421 kfree(buf);
422 }
423 return ret;
424}
425
Ester Kummer189a2b52008-05-15 13:54:18 +0800426static ssize_t iwl_dbgfs_log_event_write(struct file *file,
427 const char __user *user_buf,
428 size_t count, loff_t *ppos)
429{
430 struct iwl_priv *priv = file->private_data;
431 u32 event_log_flag;
432 char buf[8];
433 int buf_size;
434
435 memset(buf, 0, sizeof(buf));
436 buf_size = min(count, sizeof(buf) - 1);
437 if (copy_from_user(buf, user_buf, buf_size))
438 return -EFAULT;
439 if (sscanf(buf, "%d", &event_log_flag) != 1)
440 return -EFAULT;
441 if (event_log_flag == 1)
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800442 priv->cfg->ops->lib->dump_nic_event_log(priv, true,
443 NULL, false);
Ester Kummer189a2b52008-05-15 13:54:18 +0800444
445 return count;
446}
447
Winkler, Tomasd366df52008-12-02 12:14:01 -0800448
449
450static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
451 size_t count, loff_t *ppos)
452{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700453 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800454 struct ieee80211_channel *channels = NULL;
455 const struct ieee80211_supported_band *supp_band = NULL;
456 int pos = 0, i, bufsz = PAGE_SIZE;
457 char *buf;
458 ssize_t ret;
459
460 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
461 return -EAGAIN;
462
463 buf = kzalloc(bufsz, GFP_KERNEL);
464 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800465 IWL_ERR(priv, "Can not allocate Buffer\n");
Winkler, Tomasd366df52008-12-02 12:14:01 -0800466 return -ENOMEM;
467 }
468
469 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700470 if (supp_band) {
471 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800472
Winkler, Tomasd366df52008-12-02 12:14:01 -0800473 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700474 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
475 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800476
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700477 for (i = 0; i < supp_band->n_channels; i++)
478 pos += scnprintf(buf + pos, bufsz - pos,
479 "%d: %ddBm: BSS%s%s, %s.\n",
480 ieee80211_frequency_to_channel(
481 channels[i].center_freq),
482 channels[i].max_power,
483 channels[i].flags & IEEE80211_CHAN_RADAR ?
484 " (IEEE 802.11h required)" : "",
485 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
486 || (channels[i].flags &
487 IEEE80211_CHAN_RADAR)) ? "" :
488 ", IBSS",
489 channels[i].flags &
490 IEEE80211_CHAN_PASSIVE_SCAN ?
491 "passive only" : "active/passive");
492 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800493 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700494 if (supp_band) {
495 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800496
Winkler, Tomasd366df52008-12-02 12:14:01 -0800497 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700498 "Displaying %d channels in 5.2GHz band (802.11a)\n",
499 supp_band->n_channels);
500
501 for (i = 0; i < supp_band->n_channels; i++)
502 pos += scnprintf(buf + pos, bufsz - pos,
503 "%d: %ddBm: BSS%s%s, %s.\n",
504 ieee80211_frequency_to_channel(
505 channels[i].center_freq),
506 channels[i].max_power,
507 channels[i].flags & IEEE80211_CHAN_RADAR ?
508 " (IEEE 802.11h required)" : "",
509 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
510 || (channels[i].flags &
511 IEEE80211_CHAN_RADAR)) ? "" :
512 ", IBSS",
513 channels[i].flags &
514 IEEE80211_CHAN_PASSIVE_SCAN ?
515 "passive only" : "active/passive");
516 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800517 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
518 kfree(buf);
519 return ret;
520}
521
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700522static ssize_t iwl_dbgfs_status_read(struct file *file,
523 char __user *user_buf,
524 size_t count, loff_t *ppos) {
525
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700526 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700527 char buf[512];
528 int pos = 0;
529 const size_t bufsz = sizeof(buf);
530
531 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
532 test_bit(STATUS_HCMD_ACTIVE, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700533 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
534 test_bit(STATUS_INT_ENABLED, &priv->status));
535 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
536 test_bit(STATUS_RF_KILL_HW, &priv->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700537 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
538 test_bit(STATUS_CT_KILL, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700539 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
540 test_bit(STATUS_INIT, &priv->status));
541 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
542 test_bit(STATUS_ALIVE, &priv->status));
543 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
544 test_bit(STATUS_READY, &priv->status));
545 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
546 test_bit(STATUS_TEMPERATURE, &priv->status));
547 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
548 test_bit(STATUS_GEO_CONFIGURED, &priv->status));
549 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
550 test_bit(STATUS_EXIT_PENDING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700551 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
552 test_bit(STATUS_STATISTICS, &priv->status));
553 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
554 test_bit(STATUS_SCANNING, &priv->status));
555 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
556 test_bit(STATUS_SCAN_ABORTING, &priv->status));
557 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
558 test_bit(STATUS_SCAN_HW, &priv->status));
559 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
560 test_bit(STATUS_POWER_PMI, &priv->status));
561 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
562 test_bit(STATUS_FW_ERROR, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700563 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
564}
565
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700566static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
567 char __user *user_buf,
568 size_t count, loff_t *ppos) {
569
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700570 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700571 int pos = 0;
572 int cnt = 0;
573 char *buf;
574 int bufsz = 24 * 64; /* 24 items * 64 char per item */
575 ssize_t ret;
576
577 buf = kzalloc(bufsz, GFP_KERNEL);
578 if (!buf) {
579 IWL_ERR(priv, "Can not allocate Buffer\n");
580 return -ENOMEM;
581 }
582
583 pos += scnprintf(buf + pos, bufsz - pos,
584 "Interrupt Statistics Report:\n");
585
586 pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
587 priv->isr_stats.hw);
588 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
589 priv->isr_stats.sw);
590 if (priv->isr_stats.sw > 0) {
591 pos += scnprintf(buf + pos, bufsz - pos,
592 "\tLast Restarting Code: 0x%X\n",
593 priv->isr_stats.sw_err);
594 }
595#ifdef CONFIG_IWLWIFI_DEBUG
596 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
597 priv->isr_stats.sch);
598 pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
599 priv->isr_stats.alive);
600#endif
601 pos += scnprintf(buf + pos, bufsz - pos,
602 "HW RF KILL switch toggled:\t %u\n",
603 priv->isr_stats.rfkill);
604
605 pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
606 priv->isr_stats.ctkill);
607
608 pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
609 priv->isr_stats.wakeup);
610
611 pos += scnprintf(buf + pos, bufsz - pos,
612 "Rx command responses:\t\t %u\n",
613 priv->isr_stats.rx);
614 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
615 if (priv->isr_stats.rx_handlers[cnt] > 0)
616 pos += scnprintf(buf + pos, bufsz - pos,
617 "\tRx handler[%36s]:\t\t %u\n",
618 get_cmd_string(cnt),
619 priv->isr_stats.rx_handlers[cnt]);
620 }
621
622 pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
623 priv->isr_stats.tx);
624
625 pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
626 priv->isr_stats.unhandled);
627
628 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
629 kfree(buf);
630 return ret;
631}
632
633static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
634 const char __user *user_buf,
635 size_t count, loff_t *ppos)
636{
637 struct iwl_priv *priv = file->private_data;
638 char buf[8];
639 int buf_size;
640 u32 reset_flag;
641
642 memset(buf, 0, sizeof(buf));
643 buf_size = min(count, sizeof(buf) - 1);
644 if (copy_from_user(buf, user_buf, buf_size))
645 return -EFAULT;
646 if (sscanf(buf, "%x", &reset_flag) != 1)
647 return -EFAULT;
648 if (reset_flag == 0)
649 iwl_clear_isr_stats(priv);
650
651 return count;
652}
653
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700654static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
655 size_t count, loff_t *ppos)
656{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700657 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700658 int pos = 0, i;
659 char buf[256];
660 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700661
662 for (i = 0; i < AC_NUM; i++) {
663 pos += scnprintf(buf + pos, bufsz - pos,
664 "\tcw_min\tcw_max\taifsn\ttxop\n");
665 pos += scnprintf(buf + pos, bufsz - pos,
666 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
667 priv->qos_data.def_qos_parm.ac[i].cw_min,
668 priv->qos_data.def_qos_parm.ac[i].cw_max,
669 priv->qos_data.def_qos_parm.ac[i].aifsn,
670 priv->qos_data.def_qos_parm.ac[i].edca_txop);
671 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800672 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700673}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700674
Wey-Yi Guya283c012009-07-17 09:30:19 -0700675static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
676 size_t count, loff_t *ppos)
677{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700678 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya283c012009-07-17 09:30:19 -0700679 int pos = 0;
680 char buf[256];
681 const size_t bufsz = sizeof(buf);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700682
683 pos += scnprintf(buf + pos, bufsz - pos,
684 "allow blinking: %s\n",
685 (priv->allow_blinking) ? "True" : "False");
686 if (priv->allow_blinking) {
687 pos += scnprintf(buf + pos, bufsz - pos,
688 "Led blinking rate: %u\n",
689 priv->last_blink_rate);
690 pos += scnprintf(buf + pos, bufsz - pos,
691 "Last blink time: %lu\n",
692 priv->last_blink_time);
693 }
694
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800695 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700696}
Wey-Yi Guya283c012009-07-17 09:30:19 -0700697
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700698static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
699 char __user *user_buf,
700 size_t count, loff_t *ppos)
701{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700702 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700703 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700704 struct iwl_tt_restriction *restriction;
705 char buf[100];
706 int pos = 0;
707 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700708
709 pos += scnprintf(buf + pos, bufsz - pos,
710 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700711 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700712 pos += scnprintf(buf + pos, bufsz - pos,
713 "Thermal Throttling State: %d\n",
714 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700715 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700716 restriction = tt->restriction + tt->state;
717 pos += scnprintf(buf + pos, bufsz - pos,
718 "Tx mode: %d\n",
719 restriction->tx_stream);
720 pos += scnprintf(buf + pos, bufsz - pos,
721 "Rx mode: %d\n",
722 restriction->rx_stream);
723 pos += scnprintf(buf + pos, bufsz - pos,
724 "HT mode: %d\n",
725 restriction->is_ht);
726 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800727 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700728}
729
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700730static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
731 const char __user *user_buf,
732 size_t count, loff_t *ppos)
733{
734 struct iwl_priv *priv = file->private_data;
735 char buf[8];
736 int buf_size;
737 int ht40;
738
739 memset(buf, 0, sizeof(buf));
740 buf_size = min(count, sizeof(buf) - 1);
741 if (copy_from_user(buf, user_buf, buf_size))
742 return -EFAULT;
743 if (sscanf(buf, "%d", &ht40) != 1)
744 return -EFAULT;
745 if (!iwl_is_associated(priv))
746 priv->disable_ht40 = ht40 ? true : false;
747 else {
748 IWL_ERR(priv, "Sta associated with AP - "
749 "Change to 40MHz channel support is not allowed\n");
750 return -EINVAL;
751 }
752
753 return count;
754}
755
756static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
757 char __user *user_buf,
758 size_t count, loff_t *ppos)
759{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700760 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700761 char buf[100];
762 int pos = 0;
763 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700764
765 pos += scnprintf(buf + pos, bufsz - pos,
766 "11n 40MHz Mode: %s\n",
767 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800768 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700769}
770
Johannes Berge312c242009-08-07 15:41:51 -0700771static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
772 const char __user *user_buf,
773 size_t count, loff_t *ppos)
774{
775 struct iwl_priv *priv = file->private_data;
776 char buf[8];
777 int buf_size;
778 int value;
779
780 memset(buf, 0, sizeof(buf));
781 buf_size = min(count, sizeof(buf) - 1);
782 if (copy_from_user(buf, user_buf, buf_size))
783 return -EFAULT;
784
785 if (sscanf(buf, "%d", &value) != 1)
786 return -EINVAL;
787
788 /*
789 * Our users expect 0 to be "CAM", but 0 isn't actually
790 * valid here. However, let's not confuse them and present
791 * IWL_POWER_INDEX_1 as "1", not "0".
792 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700793 if (value == 0)
794 return -EINVAL;
795 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700796 value -= 1;
797
798 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
799 return -EINVAL;
800
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700801 if (!iwl_is_ready_rf(priv))
802 return -EAGAIN;
803
Johannes Berge312c242009-08-07 15:41:51 -0700804 priv->power_data.debug_sleep_level_override = value;
805
Reinette Chatred3a57192010-01-21 11:52:28 -0800806 mutex_lock(&priv->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700807 iwl_power_update_mode(priv, true);
Reinette Chatred3a57192010-01-21 11:52:28 -0800808 mutex_unlock(&priv->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700809
810 return count;
811}
812
813static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
814 char __user *user_buf,
815 size_t count, loff_t *ppos)
816{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700817 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700818 char buf[10];
819 int pos, value;
820 const size_t bufsz = sizeof(buf);
821
822 /* see the write function */
823 value = priv->power_data.debug_sleep_level_override;
824 if (value >= 0)
825 value += 1;
826
827 pos = scnprintf(buf, bufsz, "%d\n", value);
828 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
829}
830
831static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
832 char __user *user_buf,
833 size_t count, loff_t *ppos)
834{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700835 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700836 char buf[200];
837 int pos = 0, i;
838 const size_t bufsz = sizeof(buf);
839 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
840
841 pos += scnprintf(buf + pos, bufsz - pos,
842 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
843 pos += scnprintf(buf + pos, bufsz - pos,
844 "RX/TX timeout: %d/%d usec\n",
845 le32_to_cpu(cmd->rx_data_timeout),
846 le32_to_cpu(cmd->tx_data_timeout));
847 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
848 pos += scnprintf(buf + pos, bufsz - pos,
849 "sleep_interval[%d]: %d\n", i,
850 le32_to_cpu(cmd->sleep_interval[i]));
851
852 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
853}
854
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700855DEBUGFS_READ_WRITE_FILE_OPS(sram);
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800856DEBUGFS_READ_WRITE_FILE_OPS(log_event);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700857DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700858DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800859DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700860DEBUGFS_READ_FILE_OPS(status);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700861DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700862DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700863DEBUGFS_READ_FILE_OPS(led);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700864DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700865DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Johannes Berge312c242009-08-07 15:41:51 -0700866DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
867DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700868
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700869static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
870 char __user *user_buf,
871 size_t count, loff_t *ppos)
872{
873 struct iwl_priv *priv = file->private_data;
874 int pos = 0, ofs = 0;
875 int cnt = 0, entry;
876 struct iwl_tx_queue *txq;
877 struct iwl_queue *q;
878 struct iwl_rx_queue *rxq = &priv->rxq;
879 char *buf;
880 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700881 (priv->cfg->num_of_queues * 32 * 8) + 400;
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700882 const u8 *ptr;
883 ssize_t ret;
884
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700885 if (!priv->txq) {
886 IWL_ERR(priv, "txq not ready\n");
887 return -EAGAIN;
888 }
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700889 buf = kzalloc(bufsz, GFP_KERNEL);
890 if (!buf) {
891 IWL_ERR(priv, "Can not allocate buffer\n");
892 return -ENOMEM;
893 }
894 pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n");
895 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
896 txq = &priv->txq[cnt];
897 q = &txq->q;
898 pos += scnprintf(buf + pos, bufsz - pos,
899 "q[%d]: read_ptr: %u, write_ptr: %u\n",
900 cnt, q->read_ptr, q->write_ptr);
901 }
902 if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) {
903 ptr = priv->tx_traffic;
904 pos += scnprintf(buf + pos, bufsz - pos,
905 "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
906 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
907 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
908 entry++, ofs += 16) {
909 pos += scnprintf(buf + pos, bufsz - pos,
910 "0x%.4x ", ofs);
911 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
912 buf + pos, bufsz - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700913 pos += strlen(buf + pos);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700914 if (bufsz - pos > 0)
915 buf[pos++] = '\n';
916 }
917 }
918 }
919
920 pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n");
921 pos += scnprintf(buf + pos, bufsz - pos,
922 "read: %u, write: %u\n",
923 rxq->read, rxq->write);
924
925 if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) {
926 ptr = priv->rx_traffic;
927 pos += scnprintf(buf + pos, bufsz - pos,
928 "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
929 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
930 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
931 entry++, ofs += 16) {
932 pos += scnprintf(buf + pos, bufsz - pos,
933 "0x%.4x ", ofs);
934 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
935 buf + pos, bufsz - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700936 pos += strlen(buf + pos);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700937 if (bufsz - pos > 0)
938 buf[pos++] = '\n';
939 }
940 }
941 }
942
943 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
944 kfree(buf);
945 return ret;
946}
947
948static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
949 const char __user *user_buf,
950 size_t count, loff_t *ppos)
951{
952 struct iwl_priv *priv = file->private_data;
953 char buf[8];
954 int buf_size;
955 int traffic_log;
956
957 memset(buf, 0, sizeof(buf));
958 buf_size = min(count, sizeof(buf) - 1);
959 if (copy_from_user(buf, user_buf, buf_size))
960 return -EFAULT;
961 if (sscanf(buf, "%d", &traffic_log) != 1)
962 return -EFAULT;
963 if (traffic_log == 0)
964 iwl_reset_traffic_log(priv);
965
966 return count;
967}
968
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700969static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
970 char __user *user_buf,
971 size_t count, loff_t *ppos) {
972
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700973 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700974 struct iwl_tx_queue *txq;
975 struct iwl_queue *q;
976 char *buf;
977 int pos = 0;
978 int cnt;
979 int ret;
Wey-Yi Guyd23db552009-11-20 12:04:59 -0800980 const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700981
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700982 if (!priv->txq) {
983 IWL_ERR(priv, "txq not ready\n");
984 return -EAGAIN;
985 }
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700986 buf = kzalloc(bufsz, GFP_KERNEL);
987 if (!buf)
988 return -ENOMEM;
989
990 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
991 txq = &priv->txq[cnt];
992 q = &txq->q;
993 pos += scnprintf(buf + pos, bufsz - pos,
994 "hwq %.2d: read=%u write=%u stop=%d"
995 " swq_id=%#.2x (ac %d/hwq %d)\n",
996 cnt, q->read_ptr, q->write_ptr,
997 !!test_bit(cnt, priv->queue_stopped),
998 txq->swq_id,
999 txq->swq_id & 0x80 ? txq->swq_id & 3 :
1000 txq->swq_id,
1001 txq->swq_id & 0x80 ? (txq->swq_id >> 2) &
1002 0x1f : txq->swq_id);
1003 if (cnt >= 4)
1004 continue;
1005 /* for the ACs, display the stop count too */
1006 pos += scnprintf(buf + pos, bufsz - pos,
1007 " stop-count: %d\n",
1008 atomic_read(&priv->queue_stop_count[cnt]));
1009 }
1010 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1011 kfree(buf);
1012 return ret;
1013}
1014
1015static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1016 char __user *user_buf,
1017 size_t count, loff_t *ppos) {
1018
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001019 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001020 struct iwl_rx_queue *rxq = &priv->rxq;
1021 char buf[256];
1022 int pos = 0;
1023 const size_t bufsz = sizeof(buf);
1024
1025 pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n",
1026 rxq->read);
1027 pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n",
1028 rxq->write);
1029 pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n",
1030 rxq->free_count);
1031 pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n",
1032 le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF);
1033 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1034}
1035
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001036static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
1037 int bufsz)
1038{
1039 int p = 0;
1040
1041 p += scnprintf(buf + p, bufsz - p,
1042 "Statistics Flag(0x%X):\n",
1043 le32_to_cpu(priv->statistics.flag));
1044 if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
1045 p += scnprintf(buf + p, bufsz - p,
1046 "\tStatistics have been cleared\n");
1047 p += scnprintf(buf + p, bufsz - p,
1048 "\tOperational Frequency: %s\n",
1049 (le32_to_cpu(priv->statistics.flag) &
1050 UCODE_STATISTICS_FREQUENCY_MSK)
1051 ? "2.4 GHz" : "5.2 GHz");
1052 p += scnprintf(buf + p, bufsz - p,
1053 "\tTGj Narrow Band: %s\n",
1054 (le32_to_cpu(priv->statistics.flag) &
1055 UCODE_STATISTICS_NARROW_BAND_MSK)
1056 ? "enabled" : "disabled");
1057 return p;
1058}
1059
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001060static const char ucode_stats_header[] =
1061 "%-32s current acumulative delta max\n";
1062static const char ucode_stats_short_format[] =
1063 " %-30s %10u\n";
1064static const char ucode_stats_format[] =
1065 " %-30s %10u %10u %10u %10u\n";
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001066
1067static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1068 char __user *user_buf,
1069 size_t count, loff_t *ppos)
1070{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001071 struct iwl_priv *priv = file->private_data;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001072 int pos = 0;
1073 char *buf;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001074 int bufsz = sizeof(struct statistics_rx_phy) * 40 +
1075 sizeof(struct statistics_rx_non_phy) * 40 +
1076 sizeof(struct statistics_rx_ht_phy) * 40 + 400;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001077 ssize_t ret;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001078 struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
1079 struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001080 struct statistics_rx_non_phy *general, *accum_general;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001081 struct statistics_rx_non_phy *delta_general, *max_general;
1082 struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001083
1084 if (!iwl_is_alive(priv))
1085 return -EAGAIN;
1086
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001087 buf = kzalloc(bufsz, GFP_KERNEL);
1088 if (!buf) {
1089 IWL_ERR(priv, "Can not allocate Buffer\n");
1090 return -ENOMEM;
1091 }
1092
1093 /* the statistic information display here is based on
1094 * the last statistics notification from uCode
1095 * might not reflect the current uCode activity
1096 */
1097 ofdm = &priv->statistics.rx.ofdm;
1098 cck = &priv->statistics.rx.cck;
1099 general = &priv->statistics.rx.general;
1100 ht = &priv->statistics.rx.ofdm_ht;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001101 accum_ofdm = &priv->accum_statistics.rx.ofdm;
1102 accum_cck = &priv->accum_statistics.rx.cck;
1103 accum_general = &priv->accum_statistics.rx.general;
1104 accum_ht = &priv->accum_statistics.rx.ofdm_ht;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001105 delta_ofdm = &priv->delta_statistics.rx.ofdm;
1106 delta_cck = &priv->delta_statistics.rx.cck;
1107 delta_general = &priv->delta_statistics.rx.general;
1108 delta_ht = &priv->delta_statistics.rx.ofdm_ht;
1109 max_ofdm = &priv->max_delta.rx.ofdm;
1110 max_cck = &priv->max_delta.rx.cck;
1111 max_general = &priv->max_delta.rx.general;
1112 max_ht = &priv->max_delta.rx.ofdm_ht;
1113
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001114 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001115 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1116 "Statistics_Rx - OFDM:");
1117 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1118 "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
1119 accum_ofdm->ina_cnt,
1120 delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
1121 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1122 "fina_cnt:",
1123 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
1124 delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
1125 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1126 "plcp_err:",
1127 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
1128 delta_ofdm->plcp_err, max_ofdm->plcp_err);
1129 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1130 "crc32_err:",
1131 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
1132 delta_ofdm->crc32_err, max_ofdm->crc32_err);
1133 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1134 "overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001135 le32_to_cpu(ofdm->overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001136 accum_ofdm->overrun_err,
1137 delta_ofdm->overrun_err, max_ofdm->overrun_err);
1138 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1139 "early_overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001140 le32_to_cpu(ofdm->early_overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001141 accum_ofdm->early_overrun_err,
1142 delta_ofdm->early_overrun_err,
1143 max_ofdm->early_overrun_err);
1144 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1145 "crc32_good:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001146 le32_to_cpu(ofdm->crc32_good),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001147 accum_ofdm->crc32_good,
1148 delta_ofdm->crc32_good, max_ofdm->crc32_good);
1149 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1150 "false_alarm_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001151 le32_to_cpu(ofdm->false_alarm_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001152 accum_ofdm->false_alarm_cnt,
1153 delta_ofdm->false_alarm_cnt,
1154 max_ofdm->false_alarm_cnt);
1155 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1156 "fina_sync_err_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001157 le32_to_cpu(ofdm->fina_sync_err_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001158 accum_ofdm->fina_sync_err_cnt,
1159 delta_ofdm->fina_sync_err_cnt,
1160 max_ofdm->fina_sync_err_cnt);
1161 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1162 "sfd_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001163 le32_to_cpu(ofdm->sfd_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001164 accum_ofdm->sfd_timeout,
1165 delta_ofdm->sfd_timeout,
1166 max_ofdm->sfd_timeout);
1167 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1168 "fina_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001169 le32_to_cpu(ofdm->fina_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001170 accum_ofdm->fina_timeout,
1171 delta_ofdm->fina_timeout,
1172 max_ofdm->fina_timeout);
1173 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1174 "unresponded_rts:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001175 le32_to_cpu(ofdm->unresponded_rts),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001176 accum_ofdm->unresponded_rts,
1177 delta_ofdm->unresponded_rts,
1178 max_ofdm->unresponded_rts);
1179 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1180 "rxe_frame_lmt_ovrun:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001181 le32_to_cpu(ofdm->rxe_frame_limit_overrun),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001182 accum_ofdm->rxe_frame_limit_overrun,
1183 delta_ofdm->rxe_frame_limit_overrun,
1184 max_ofdm->rxe_frame_limit_overrun);
1185 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1186 "sent_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001187 le32_to_cpu(ofdm->sent_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001188 accum_ofdm->sent_ack_cnt,
1189 delta_ofdm->sent_ack_cnt,
1190 max_ofdm->sent_ack_cnt);
1191 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1192 "sent_cts_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001193 le32_to_cpu(ofdm->sent_cts_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001194 accum_ofdm->sent_cts_cnt,
1195 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
1196 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1197 "sent_ba_rsp_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001198 le32_to_cpu(ofdm->sent_ba_rsp_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001199 accum_ofdm->sent_ba_rsp_cnt,
1200 delta_ofdm->sent_ba_rsp_cnt,
1201 max_ofdm->sent_ba_rsp_cnt);
1202 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1203 "dsp_self_kill:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001204 le32_to_cpu(ofdm->dsp_self_kill),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001205 accum_ofdm->dsp_self_kill,
1206 delta_ofdm->dsp_self_kill,
1207 max_ofdm->dsp_self_kill);
1208 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1209 "mh_format_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001210 le32_to_cpu(ofdm->mh_format_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001211 accum_ofdm->mh_format_err,
1212 delta_ofdm->mh_format_err,
1213 max_ofdm->mh_format_err);
1214 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1215 "re_acq_main_rssi_sum:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001216 le32_to_cpu(ofdm->re_acq_main_rssi_sum),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001217 accum_ofdm->re_acq_main_rssi_sum,
1218 delta_ofdm->re_acq_main_rssi_sum,
1219 max_ofdm->re_acq_main_rssi_sum);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001220
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001221 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1222 "Statistics_Rx - CCK:");
1223 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1224 "ina_cnt:",
1225 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
1226 delta_cck->ina_cnt, max_cck->ina_cnt);
1227 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1228 "fina_cnt:",
1229 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
1230 delta_cck->fina_cnt, max_cck->fina_cnt);
1231 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1232 "plcp_err:",
1233 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
1234 delta_cck->plcp_err, max_cck->plcp_err);
1235 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1236 "crc32_err:",
1237 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
1238 delta_cck->crc32_err, max_cck->crc32_err);
1239 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1240 "overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001241 le32_to_cpu(cck->overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001242 accum_cck->overrun_err,
1243 delta_cck->overrun_err, max_cck->overrun_err);
1244 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1245 "early_overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001246 le32_to_cpu(cck->early_overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001247 accum_cck->early_overrun_err,
1248 delta_cck->early_overrun_err,
1249 max_cck->early_overrun_err);
1250 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1251 "crc32_good:",
1252 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
1253 delta_cck->crc32_good,
1254 max_cck->crc32_good);
1255 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1256 "false_alarm_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001257 le32_to_cpu(cck->false_alarm_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001258 accum_cck->false_alarm_cnt,
1259 delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
1260 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1261 "fina_sync_err_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001262 le32_to_cpu(cck->fina_sync_err_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001263 accum_cck->fina_sync_err_cnt,
1264 delta_cck->fina_sync_err_cnt,
1265 max_cck->fina_sync_err_cnt);
1266 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1267 "sfd_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001268 le32_to_cpu(cck->sfd_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001269 accum_cck->sfd_timeout,
1270 delta_cck->sfd_timeout, max_cck->sfd_timeout);
1271 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1272 "fina_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001273 le32_to_cpu(cck->fina_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001274 accum_cck->fina_timeout,
1275 delta_cck->fina_timeout, max_cck->fina_timeout);
1276 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1277 "unresponded_rts:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001278 le32_to_cpu(cck->unresponded_rts),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001279 accum_cck->unresponded_rts,
1280 delta_cck->unresponded_rts,
1281 max_cck->unresponded_rts);
1282 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1283 "rxe_frame_lmt_ovrun:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001284 le32_to_cpu(cck->rxe_frame_limit_overrun),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001285 accum_cck->rxe_frame_limit_overrun,
1286 delta_cck->rxe_frame_limit_overrun,
1287 max_cck->rxe_frame_limit_overrun);
1288 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1289 "sent_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001290 le32_to_cpu(cck->sent_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001291 accum_cck->sent_ack_cnt,
1292 delta_cck->sent_ack_cnt,
1293 max_cck->sent_ack_cnt);
1294 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1295 "sent_cts_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001296 le32_to_cpu(cck->sent_cts_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001297 accum_cck->sent_cts_cnt,
1298 delta_cck->sent_cts_cnt,
1299 max_cck->sent_cts_cnt);
1300 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1301 "sent_ba_rsp_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001302 le32_to_cpu(cck->sent_ba_rsp_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001303 accum_cck->sent_ba_rsp_cnt,
1304 delta_cck->sent_ba_rsp_cnt,
1305 max_cck->sent_ba_rsp_cnt);
1306 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1307 "dsp_self_kill:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001308 le32_to_cpu(cck->dsp_self_kill),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001309 accum_cck->dsp_self_kill,
1310 delta_cck->dsp_self_kill,
1311 max_cck->dsp_self_kill);
1312 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1313 "mh_format_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001314 le32_to_cpu(cck->mh_format_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001315 accum_cck->mh_format_err,
1316 delta_cck->mh_format_err, max_cck->mh_format_err);
1317 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1318 "re_acq_main_rssi_sum:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001319 le32_to_cpu(cck->re_acq_main_rssi_sum),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001320 accum_cck->re_acq_main_rssi_sum,
1321 delta_cck->re_acq_main_rssi_sum,
1322 max_cck->re_acq_main_rssi_sum);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001323
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001324 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1325 "Statistics_Rx - GENERAL:");
1326 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1327 "bogus_cts:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001328 le32_to_cpu(general->bogus_cts),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001329 accum_general->bogus_cts,
1330 delta_general->bogus_cts, max_general->bogus_cts);
1331 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1332 "bogus_ack:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001333 le32_to_cpu(general->bogus_ack),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001334 accum_general->bogus_ack,
1335 delta_general->bogus_ack, max_general->bogus_ack);
1336 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1337 "non_bssid_frames:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001338 le32_to_cpu(general->non_bssid_frames),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001339 accum_general->non_bssid_frames,
1340 delta_general->non_bssid_frames,
1341 max_general->non_bssid_frames);
1342 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1343 "filtered_frames:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001344 le32_to_cpu(general->filtered_frames),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001345 accum_general->filtered_frames,
1346 delta_general->filtered_frames,
1347 max_general->filtered_frames);
1348 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1349 "non_channel_beacons:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001350 le32_to_cpu(general->non_channel_beacons),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001351 accum_general->non_channel_beacons,
1352 delta_general->non_channel_beacons,
1353 max_general->non_channel_beacons);
1354 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1355 "channel_beacons:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001356 le32_to_cpu(general->channel_beacons),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001357 accum_general->channel_beacons,
1358 delta_general->channel_beacons,
1359 max_general->channel_beacons);
1360 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1361 "num_missed_bcon:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001362 le32_to_cpu(general->num_missed_bcon),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001363 accum_general->num_missed_bcon,
1364 delta_general->num_missed_bcon,
1365 max_general->num_missed_bcon);
1366 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1367 "adc_rx_saturation_time:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001368 le32_to_cpu(general->adc_rx_saturation_time),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001369 accum_general->adc_rx_saturation_time,
1370 delta_general->adc_rx_saturation_time,
1371 max_general->adc_rx_saturation_time);
1372 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1373 "ina_detect_search_tm:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001374 le32_to_cpu(general->ina_detection_search_time),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001375 accum_general->ina_detection_search_time,
1376 delta_general->ina_detection_search_time,
1377 max_general->ina_detection_search_time);
1378 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1379 "beacon_silence_rssi_a:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001380 le32_to_cpu(general->beacon_silence_rssi_a),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001381 accum_general->beacon_silence_rssi_a,
1382 delta_general->beacon_silence_rssi_a,
1383 max_general->beacon_silence_rssi_a);
1384 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1385 "beacon_silence_rssi_b:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001386 le32_to_cpu(general->beacon_silence_rssi_b),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001387 accum_general->beacon_silence_rssi_b,
1388 delta_general->beacon_silence_rssi_b,
1389 max_general->beacon_silence_rssi_b);
1390 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1391 "beacon_silence_rssi_c:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001392 le32_to_cpu(general->beacon_silence_rssi_c),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001393 accum_general->beacon_silence_rssi_c,
1394 delta_general->beacon_silence_rssi_c,
1395 max_general->beacon_silence_rssi_c);
1396 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1397 "interference_data_flag:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001398 le32_to_cpu(general->interference_data_flag),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001399 accum_general->interference_data_flag,
1400 delta_general->interference_data_flag,
1401 max_general->interference_data_flag);
1402 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1403 "channel_load:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001404 le32_to_cpu(general->channel_load),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001405 accum_general->channel_load,
1406 delta_general->channel_load,
1407 max_general->channel_load);
1408 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1409 "dsp_false_alarms:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001410 le32_to_cpu(general->dsp_false_alarms),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001411 accum_general->dsp_false_alarms,
1412 delta_general->dsp_false_alarms,
1413 max_general->dsp_false_alarms);
1414 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1415 "beacon_rssi_a:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001416 le32_to_cpu(general->beacon_rssi_a),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001417 accum_general->beacon_rssi_a,
1418 delta_general->beacon_rssi_a,
1419 max_general->beacon_rssi_a);
1420 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1421 "beacon_rssi_b:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001422 le32_to_cpu(general->beacon_rssi_b),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001423 accum_general->beacon_rssi_b,
1424 delta_general->beacon_rssi_b,
1425 max_general->beacon_rssi_b);
1426 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1427 "beacon_rssi_c:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001428 le32_to_cpu(general->beacon_rssi_c),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001429 accum_general->beacon_rssi_c,
1430 delta_general->beacon_rssi_c,
1431 max_general->beacon_rssi_c);
1432 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1433 "beacon_energy_a:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001434 le32_to_cpu(general->beacon_energy_a),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001435 accum_general->beacon_energy_a,
1436 delta_general->beacon_energy_a,
1437 max_general->beacon_energy_a);
1438 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1439 "beacon_energy_b:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001440 le32_to_cpu(general->beacon_energy_b),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001441 accum_general->beacon_energy_b,
1442 delta_general->beacon_energy_b,
1443 max_general->beacon_energy_b);
1444 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1445 "beacon_energy_c:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001446 le32_to_cpu(general->beacon_energy_c),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001447 accum_general->beacon_energy_c,
1448 delta_general->beacon_energy_c,
1449 max_general->beacon_energy_c);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001450
1451 pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001452 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1453 "Statistics_Rx - OFDM_HT:");
1454 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1455 "plcp_err:",
1456 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
1457 delta_ht->plcp_err, max_ht->plcp_err);
1458 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1459 "overrun_err:",
1460 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
1461 delta_ht->overrun_err, max_ht->overrun_err);
1462 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1463 "early_overrun_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001464 le32_to_cpu(ht->early_overrun_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001465 accum_ht->early_overrun_err,
1466 delta_ht->early_overrun_err,
1467 max_ht->early_overrun_err);
1468 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1469 "crc32_good:",
1470 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
1471 delta_ht->crc32_good, max_ht->crc32_good);
1472 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1473 "crc32_err:",
1474 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
1475 delta_ht->crc32_err, max_ht->crc32_err);
1476 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1477 "mh_format_err:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001478 le32_to_cpu(ht->mh_format_err),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001479 accum_ht->mh_format_err,
1480 delta_ht->mh_format_err, max_ht->mh_format_err);
1481 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1482 "agg_crc32_good:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001483 le32_to_cpu(ht->agg_crc32_good),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001484 accum_ht->agg_crc32_good,
1485 delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
1486 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1487 "agg_mpdu_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001488 le32_to_cpu(ht->agg_mpdu_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001489 accum_ht->agg_mpdu_cnt,
1490 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
1491 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1492 "agg_cnt:",
1493 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
1494 delta_ht->agg_cnt, max_ht->agg_cnt);
1495 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1496 "unsupport_mcs:",
Wey-Yi Guyf0118a42010-01-08 10:04:42 -08001497 le32_to_cpu(ht->unsupport_mcs),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001498 accum_ht->unsupport_mcs,
1499 delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001500
1501 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1502 kfree(buf);
1503 return ret;
1504}
1505
1506static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1507 char __user *user_buf,
1508 size_t count, loff_t *ppos)
1509{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001510 struct iwl_priv *priv = file->private_data;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001511 int pos = 0;
1512 char *buf;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001513 int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001514 ssize_t ret;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001515 struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001516
1517 if (!iwl_is_alive(priv))
1518 return -EAGAIN;
1519
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001520 buf = kzalloc(bufsz, GFP_KERNEL);
1521 if (!buf) {
1522 IWL_ERR(priv, "Can not allocate Buffer\n");
1523 return -ENOMEM;
1524 }
1525
1526 /* the statistic information display here is based on
1527 * the last statistics notification from uCode
1528 * might not reflect the current uCode activity
1529 */
1530 tx = &priv->statistics.tx;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001531 accum_tx = &priv->accum_statistics.tx;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001532 delta_tx = &priv->delta_statistics.tx;
1533 max_tx = &priv->max_delta.tx;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001534 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001535 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1536 "Statistics_Tx:");
1537 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1538 "preamble:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001539 le32_to_cpu(tx->preamble_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001540 accum_tx->preamble_cnt,
1541 delta_tx->preamble_cnt, max_tx->preamble_cnt);
1542 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1543 "rx_detected_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001544 le32_to_cpu(tx->rx_detected_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001545 accum_tx->rx_detected_cnt,
1546 delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
1547 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1548 "bt_prio_defer_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001549 le32_to_cpu(tx->bt_prio_defer_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001550 accum_tx->bt_prio_defer_cnt,
1551 delta_tx->bt_prio_defer_cnt,
1552 max_tx->bt_prio_defer_cnt);
1553 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1554 "bt_prio_kill_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001555 le32_to_cpu(tx->bt_prio_kill_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001556 accum_tx->bt_prio_kill_cnt,
1557 delta_tx->bt_prio_kill_cnt,
1558 max_tx->bt_prio_kill_cnt);
1559 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1560 "few_bytes_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001561 le32_to_cpu(tx->few_bytes_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001562 accum_tx->few_bytes_cnt,
1563 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
1564 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1565 "cts_timeout:",
1566 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
1567 delta_tx->cts_timeout, max_tx->cts_timeout);
1568 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1569 "ack_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001570 le32_to_cpu(tx->ack_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001571 accum_tx->ack_timeout,
1572 delta_tx->ack_timeout, max_tx->ack_timeout);
1573 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1574 "expected_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001575 le32_to_cpu(tx->expected_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001576 accum_tx->expected_ack_cnt,
1577 delta_tx->expected_ack_cnt,
1578 max_tx->expected_ack_cnt);
1579 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1580 "actual_ack_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001581 le32_to_cpu(tx->actual_ack_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001582 accum_tx->actual_ack_cnt,
1583 delta_tx->actual_ack_cnt,
1584 max_tx->actual_ack_cnt);
1585 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1586 "dump_msdu_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001587 le32_to_cpu(tx->dump_msdu_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001588 accum_tx->dump_msdu_cnt,
1589 delta_tx->dump_msdu_cnt,
1590 max_tx->dump_msdu_cnt);
1591 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1592 "abort_nxt_frame_mismatch:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001593 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001594 accum_tx->burst_abort_next_frame_mismatch_cnt,
1595 delta_tx->burst_abort_next_frame_mismatch_cnt,
1596 max_tx->burst_abort_next_frame_mismatch_cnt);
1597 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1598 "abort_missing_nxt_frame:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001599 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001600 accum_tx->burst_abort_missing_next_frame_cnt,
1601 delta_tx->burst_abort_missing_next_frame_cnt,
1602 max_tx->burst_abort_missing_next_frame_cnt);
1603 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1604 "cts_timeout_collision:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001605 le32_to_cpu(tx->cts_timeout_collision),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001606 accum_tx->cts_timeout_collision,
1607 delta_tx->cts_timeout_collision,
1608 max_tx->cts_timeout_collision);
1609 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1610 "ack_ba_timeout_collision:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001611 le32_to_cpu(tx->ack_or_ba_timeout_collision),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001612 accum_tx->ack_or_ba_timeout_collision,
1613 delta_tx->ack_or_ba_timeout_collision,
1614 max_tx->ack_or_ba_timeout_collision);
1615 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1616 "agg ba_timeout:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001617 le32_to_cpu(tx->agg.ba_timeout),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001618 accum_tx->agg.ba_timeout,
1619 delta_tx->agg.ba_timeout,
1620 max_tx->agg.ba_timeout);
1621 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1622 "agg ba_resched_frames:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001623 le32_to_cpu(tx->agg.ba_reschedule_frames),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001624 accum_tx->agg.ba_reschedule_frames,
1625 delta_tx->agg.ba_reschedule_frames,
1626 max_tx->agg.ba_reschedule_frames);
1627 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1628 "agg scd_query_agg_frame:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001629 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001630 accum_tx->agg.scd_query_agg_frame_cnt,
1631 delta_tx->agg.scd_query_agg_frame_cnt,
1632 max_tx->agg.scd_query_agg_frame_cnt);
1633 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1634 "agg scd_query_no_agg:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001635 le32_to_cpu(tx->agg.scd_query_no_agg),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001636 accum_tx->agg.scd_query_no_agg,
1637 delta_tx->agg.scd_query_no_agg,
1638 max_tx->agg.scd_query_no_agg);
1639 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1640 "agg scd_query_agg:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001641 le32_to_cpu(tx->agg.scd_query_agg),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001642 accum_tx->agg.scd_query_agg,
1643 delta_tx->agg.scd_query_agg,
1644 max_tx->agg.scd_query_agg);
1645 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1646 "agg scd_query_mismatch:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001647 le32_to_cpu(tx->agg.scd_query_mismatch),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001648 accum_tx->agg.scd_query_mismatch,
1649 delta_tx->agg.scd_query_mismatch,
1650 max_tx->agg.scd_query_mismatch);
1651 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1652 "agg frame_not_ready:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001653 le32_to_cpu(tx->agg.frame_not_ready),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001654 accum_tx->agg.frame_not_ready,
1655 delta_tx->agg.frame_not_ready,
1656 max_tx->agg.frame_not_ready);
1657 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1658 "agg underrun:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001659 le32_to_cpu(tx->agg.underrun),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001660 accum_tx->agg.underrun,
1661 delta_tx->agg.underrun, max_tx->agg.underrun);
1662 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1663 "agg bt_prio_kill:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001664 le32_to_cpu(tx->agg.bt_prio_kill),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001665 accum_tx->agg.bt_prio_kill,
1666 delta_tx->agg.bt_prio_kill,
1667 max_tx->agg.bt_prio_kill);
1668 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1669 "agg rx_ba_rsp_cnt:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001670 le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001671 accum_tx->agg.rx_ba_rsp_cnt,
1672 delta_tx->agg.rx_ba_rsp_cnt,
1673 max_tx->agg.rx_ba_rsp_cnt);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001674
1675 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1676 kfree(buf);
1677 return ret;
1678}
1679
1680static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1681 char __user *user_buf,
1682 size_t count, loff_t *ppos)
1683{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001684 struct iwl_priv *priv = file->private_data;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001685 int pos = 0;
1686 char *buf;
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08001687 int bufsz = sizeof(struct statistics_general) * 10 + 300;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001688 ssize_t ret;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001689 struct statistics_general *general, *accum_general;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001690 struct statistics_general *delta_general, *max_general;
1691 struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
1692 struct statistics_div *div, *accum_div, *delta_div, *max_div;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001693
1694 if (!iwl_is_alive(priv))
1695 return -EAGAIN;
1696
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001697 buf = kzalloc(bufsz, GFP_KERNEL);
1698 if (!buf) {
1699 IWL_ERR(priv, "Can not allocate Buffer\n");
1700 return -ENOMEM;
1701 }
1702
1703 /* the statistic information display here is based on
1704 * the last statistics notification from uCode
1705 * might not reflect the current uCode activity
1706 */
1707 general = &priv->statistics.general;
1708 dbg = &priv->statistics.general.dbg;
1709 div = &priv->statistics.general.div;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001710 accum_general = &priv->accum_statistics.general;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001711 delta_general = &priv->delta_statistics.general;
1712 max_general = &priv->max_delta.general;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001713 accum_dbg = &priv->accum_statistics.general.dbg;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001714 delta_dbg = &priv->delta_statistics.general.dbg;
1715 max_dbg = &priv->max_delta.general.dbg;
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001716 accum_div = &priv->accum_statistics.general.div;
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001717 delta_div = &priv->delta_statistics.general.div;
1718 max_div = &priv->max_delta.general.div;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001719 pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001720 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
1721 "Statistics_General:");
1722 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1723 "temperature:",
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001724 le32_to_cpu(general->temperature));
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001725 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
1726 "temperature_m:",
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001727 le32_to_cpu(general->temperature_m));
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001728 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1729 "burst_check:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001730 le32_to_cpu(dbg->burst_check),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001731 accum_dbg->burst_check,
1732 delta_dbg->burst_check, max_dbg->burst_check);
1733 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1734 "burst_count:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001735 le32_to_cpu(dbg->burst_count),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001736 accum_dbg->burst_count,
1737 delta_dbg->burst_count, max_dbg->burst_count);
1738 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1739 "sleep_time:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001740 le32_to_cpu(general->sleep_time),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001741 accum_general->sleep_time,
1742 delta_general->sleep_time, max_general->sleep_time);
1743 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1744 "slots_out:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001745 le32_to_cpu(general->slots_out),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001746 accum_general->slots_out,
1747 delta_general->slots_out, max_general->slots_out);
1748 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1749 "slots_idle:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001750 le32_to_cpu(general->slots_idle),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001751 accum_general->slots_idle,
1752 delta_general->slots_idle, max_general->slots_idle);
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001753 pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001754 le32_to_cpu(general->ttl_timestamp));
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001755 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1756 "tx_on_a:",
1757 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
1758 delta_div->tx_on_a, max_div->tx_on_a);
1759 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1760 "tx_on_b:",
1761 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
1762 delta_div->tx_on_b, max_div->tx_on_b);
1763 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1764 "exec_time:",
1765 le32_to_cpu(div->exec_time), accum_div->exec_time,
1766 delta_div->exec_time, max_div->exec_time);
1767 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1768 "probe_time:",
1769 le32_to_cpu(div->probe_time), accum_div->probe_time,
1770 delta_div->probe_time, max_div->probe_time);
1771 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1772 "rx_enable_counter:",
Wey-Yi Guy92a35bd2009-10-09 13:20:29 -07001773 le32_to_cpu(general->rx_enable_counter),
Wey-Yi Guye3ef2162010-01-15 13:43:34 -08001774 accum_general->rx_enable_counter,
1775 delta_general->rx_enable_counter,
1776 max_general->rx_enable_counter);
Wey-Yi Guy11fc5242010-01-15 13:43:35 -08001777 pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
1778 "num_of_sos_states:",
1779 le32_to_cpu(general->num_of_sos_states),
1780 accum_general->num_of_sos_states,
1781 delta_general->num_of_sos_states,
1782 max_general->num_of_sos_states);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001783 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1784 kfree(buf);
1785 return ret;
1786}
1787
Wey-Yi Guy52259352009-08-07 15:41:43 -07001788static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1789 char __user *user_buf,
1790 size_t count, loff_t *ppos) {
1791
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001792 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001793 int pos = 0;
1794 int cnt = 0;
1795 char *buf;
1796 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1797 ssize_t ret;
1798 struct iwl_sensitivity_data *data;
1799
1800 data = &priv->sensitivity_data;
1801 buf = kzalloc(bufsz, GFP_KERNEL);
1802 if (!buf) {
1803 IWL_ERR(priv, "Can not allocate Buffer\n");
1804 return -ENOMEM;
1805 }
1806
1807 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1808 data->auto_corr_ofdm);
1809 pos += scnprintf(buf + pos, bufsz - pos,
1810 "auto_corr_ofdm_mrc:\t\t %u\n",
1811 data->auto_corr_ofdm_mrc);
1812 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1813 data->auto_corr_ofdm_x1);
1814 pos += scnprintf(buf + pos, bufsz - pos,
1815 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1816 data->auto_corr_ofdm_mrc_x1);
1817 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1818 data->auto_corr_cck);
1819 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1820 data->auto_corr_cck_mrc);
1821 pos += scnprintf(buf + pos, bufsz - pos,
1822 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1823 data->last_bad_plcp_cnt_ofdm);
1824 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1825 data->last_fa_cnt_ofdm);
1826 pos += scnprintf(buf + pos, bufsz - pos,
1827 "last_bad_plcp_cnt_cck:\t\t %u\n",
1828 data->last_bad_plcp_cnt_cck);
1829 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1830 data->last_fa_cnt_cck);
1831 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1832 data->nrg_curr_state);
1833 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1834 data->nrg_prev_state);
1835 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1836 for (cnt = 0; cnt < 10; cnt++) {
1837 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1838 data->nrg_value[cnt]);
1839 }
1840 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1841 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1842 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1843 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1844 data->nrg_silence_rssi[cnt]);
1845 }
1846 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1847 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1848 data->nrg_silence_ref);
1849 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1850 data->nrg_energy_idx);
1851 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1852 data->nrg_silence_idx);
1853 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1854 data->nrg_th_cck);
1855 pos += scnprintf(buf + pos, bufsz - pos,
1856 "nrg_auto_corr_silence_diff:\t %u\n",
1857 data->nrg_auto_corr_silence_diff);
1858 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1859 data->num_in_cck_no_fa);
1860 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1861 data->nrg_th_ofdm);
1862
1863 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1864 kfree(buf);
1865 return ret;
1866}
1867
1868
1869static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1870 char __user *user_buf,
1871 size_t count, loff_t *ppos) {
1872
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001873 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001874 int pos = 0;
1875 int cnt = 0;
1876 char *buf;
1877 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1878 ssize_t ret;
1879 struct iwl_chain_noise_data *data;
1880
1881 data = &priv->chain_noise_data;
1882 buf = kzalloc(bufsz, GFP_KERNEL);
1883 if (!buf) {
1884 IWL_ERR(priv, "Can not allocate Buffer\n");
1885 return -ENOMEM;
1886 }
1887
1888 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1889 data->active_chains);
1890 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1891 data->chain_noise_a);
1892 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1893 data->chain_noise_b);
1894 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1895 data->chain_noise_c);
1896 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1897 data->chain_signal_a);
1898 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1899 data->chain_signal_b);
1900 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1901 data->chain_signal_c);
1902 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1903 data->beacon_count);
1904
1905 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1906 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1907 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1908 data->disconn_array[cnt]);
1909 }
1910 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1911 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1912 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1913 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1914 data->delta_gain_code[cnt]);
1915 }
1916 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1917 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1918 data->radio_write);
1919 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1920 data->state);
1921
1922 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1923 kfree(buf);
1924 return ret;
1925}
1926
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001927static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1928 char __user *user_buf,
1929 size_t count, loff_t *ppos) {
1930
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001931 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001932 char buf[128];
1933 int pos = 0;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001934 const size_t bufsz = sizeof(buf);
1935 struct statistics_tx *tx;
1936
1937 if (!iwl_is_alive(priv))
1938 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1939 else {
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001940 tx = &priv->statistics.tx;
1941 if (tx->tx_power.ant_a ||
1942 tx->tx_power.ant_b ||
1943 tx->tx_power.ant_c) {
1944 pos += scnprintf(buf + pos, bufsz - pos,
1945 "tx power: (1/2 dB step)\n");
1946 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1947 tx->tx_power.ant_a)
1948 pos += scnprintf(buf + pos, bufsz - pos,
1949 "\tantenna A: 0x%X\n",
1950 tx->tx_power.ant_a);
1951 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1952 tx->tx_power.ant_b)
1953 pos += scnprintf(buf + pos, bufsz - pos,
1954 "\tantenna B: 0x%X\n",
1955 tx->tx_power.ant_b);
1956 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1957 tx->tx_power.ant_c)
1958 pos += scnprintf(buf + pos, bufsz - pos,
1959 "\tantenna C: 0x%X\n",
1960 tx->tx_power.ant_c);
1961 } else
1962 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1963 }
1964 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1965}
1966
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001967static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1968 char __user *user_buf,
1969 size_t count, loff_t *ppos)
1970{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001971 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001972 char buf[60];
1973 int pos = 0;
1974 const size_t bufsz = sizeof(buf);
1975 u32 pwrsave_status;
1976
1977 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
1978 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1979
1980 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1981 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1982 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1983 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1984 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1985 "error");
1986
1987 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1988}
1989
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001990static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001991 const char __user *user_buf,
1992 size_t count, loff_t *ppos)
1993{
1994 struct iwl_priv *priv = file->private_data;
1995 char buf[8];
1996 int buf_size;
1997 int clear;
1998
1999 memset(buf, 0, sizeof(buf));
2000 buf_size = min(count, sizeof(buf) - 1);
2001 if (copy_from_user(buf, user_buf, buf_size))
2002 return -EFAULT;
2003 if (sscanf(buf, "%d", &clear) != 1)
2004 return -EFAULT;
2005
2006 /* make request to uCode to retrieve statistics information */
2007 mutex_lock(&priv->mutex);
2008 iwl_send_statistics_request(priv, CMD_SYNC, true);
2009 mutex_unlock(&priv->mutex);
2010
2011 return count;
2012}
2013
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002014static ssize_t iwl_dbgfs_csr_write(struct file *file,
2015 const char __user *user_buf,
2016 size_t count, loff_t *ppos)
2017{
2018 struct iwl_priv *priv = file->private_data;
2019 char buf[8];
2020 int buf_size;
2021 int csr;
2022
2023 memset(buf, 0, sizeof(buf));
2024 buf_size = min(count, sizeof(buf) - 1);
2025 if (copy_from_user(buf, user_buf, buf_size))
2026 return -EFAULT;
2027 if (sscanf(buf, "%d", &csr) != 1)
2028 return -EFAULT;
2029
2030 if (priv->cfg->ops->lib->dump_csr)
2031 priv->cfg->ops->lib->dump_csr(priv);
2032
2033 return count;
2034}
2035
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002036static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2037 char __user *user_buf,
2038 size_t count, loff_t *ppos) {
2039
2040 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2041 int pos = 0;
2042 char buf[128];
2043 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002044
2045 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2046 priv->event_log.ucode_trace ? "On" : "Off");
2047 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
2048 priv->event_log.non_wraps_count);
2049 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
2050 priv->event_log.wraps_once_count);
2051 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2052 priv->event_log.wraps_more_count);
2053
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002054 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002055}
2056
2057static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2058 const char __user *user_buf,
2059 size_t count, loff_t *ppos)
2060{
2061 struct iwl_priv *priv = file->private_data;
2062 char buf[8];
2063 int buf_size;
2064 int trace;
2065
2066 memset(buf, 0, sizeof(buf));
2067 buf_size = min(count, sizeof(buf) - 1);
2068 if (copy_from_user(buf, user_buf, buf_size))
2069 return -EFAULT;
2070 if (sscanf(buf, "%d", &trace) != 1)
2071 return -EFAULT;
2072
2073 if (trace) {
2074 priv->event_log.ucode_trace = true;
2075 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
2076 mod_timer(&priv->ucode_trace,
2077 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
2078 } else {
2079 priv->event_log.ucode_trace = false;
2080 del_timer_sync(&priv->ucode_trace);
2081 }
2082
2083 return count;
2084}
2085
Johannes Berg60987202010-02-18 00:36:07 -08002086static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
2087 char __user *user_buf,
2088 size_t count, loff_t *ppos) {
2089
2090 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2091 int len = 0;
2092 char buf[20];
2093
2094 len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags));
2095 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2096}
2097
2098static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
2099 char __user *user_buf,
2100 size_t count, loff_t *ppos) {
2101
2102 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2103 int len = 0;
2104 char buf[20];
2105
2106 len = sprintf(buf, "0x%04X\n",
2107 le32_to_cpu(priv->active_rxon.filter_flags));
2108 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2109}
2110
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002111static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
2112 char __user *user_buf,
2113 size_t count, loff_t *ppos)
2114{
2115 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2116 char *buf;
2117 int pos = 0;
2118 ssize_t ret = -EFAULT;
2119
2120 if (priv->cfg->ops->lib->dump_fh) {
2121 ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true);
2122 if (buf) {
2123 ret = simple_read_from_buffer(user_buf,
2124 count, ppos, buf, pos);
2125 kfree(buf);
2126 }
2127 }
2128
2129 return ret;
2130}
2131
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002132static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2133 char __user *user_buf,
2134 size_t count, loff_t *ppos) {
2135
2136 struct iwl_priv *priv = file->private_data;
2137 int pos = 0;
2138 char buf[12];
2139 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002140
2141 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2142 priv->missed_beacon_threshold);
2143
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002144 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002145}
2146
2147static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2148 const char __user *user_buf,
2149 size_t count, loff_t *ppos)
2150{
2151 struct iwl_priv *priv = file->private_data;
2152 char buf[8];
2153 int buf_size;
2154 int missed;
2155
2156 memset(buf, 0, sizeof(buf));
2157 buf_size = min(count, sizeof(buf) - 1);
2158 if (copy_from_user(buf, user_buf, buf_size))
2159 return -EFAULT;
2160 if (sscanf(buf, "%d", &missed) != 1)
2161 return -EINVAL;
2162
2163 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
2164 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
2165 priv->missed_beacon_threshold =
2166 IWL_MISSED_BEACON_THRESHOLD_DEF;
2167 else
2168 priv->missed_beacon_threshold = missed;
2169
2170 return count;
2171}
2172
Wey-Yi Guyafbdd692010-01-22 14:22:43 -08002173static ssize_t iwl_dbgfs_internal_scan_write(struct file *file,
2174 const char __user *user_buf,
2175 size_t count, loff_t *ppos)
2176{
2177 struct iwl_priv *priv = file->private_data;
2178 char buf[8];
2179 int buf_size;
2180 int scan;
2181
2182 memset(buf, 0, sizeof(buf));
2183 buf_size = min(count, sizeof(buf) - 1);
2184 if (copy_from_user(buf, user_buf, buf_size))
2185 return -EFAULT;
2186 if (sscanf(buf, "%d", &scan) != 1)
2187 return -EINVAL;
2188
2189 iwl_internal_short_hw_scan(priv);
2190
2191 return count;
2192}
2193
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002194static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2195 char __user *user_buf,
2196 size_t count, loff_t *ppos) {
2197
2198 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2199 int pos = 0;
2200 char buf[12];
2201 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002202
2203 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
2204 priv->cfg->plcp_delta_threshold);
2205
Wey-Yi Guy4967c312010-02-18 15:22:07 -08002206 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002207}
2208
2209static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2210 const char __user *user_buf,
2211 size_t count, loff_t *ppos) {
2212
2213 struct iwl_priv *priv = file->private_data;
2214 char buf[8];
2215 int buf_size;
2216 int plcp;
2217
2218 memset(buf, 0, sizeof(buf));
2219 buf_size = min(count, sizeof(buf) - 1);
2220 if (copy_from_user(buf, user_buf, buf_size))
2221 return -EFAULT;
2222 if (sscanf(buf, "%d", &plcp) != 1)
2223 return -EINVAL;
2224 if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
2225 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
2226 priv->cfg->plcp_delta_threshold =
2227 IWL_MAX_PLCP_ERR_THRESHOLD_DEF;
2228 else
2229 priv->cfg->plcp_delta_threshold = plcp;
2230 return count;
2231}
2232
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002233static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
2234 char __user *user_buf,
2235 size_t count, loff_t *ppos) {
2236
2237 struct iwl_priv *priv = file->private_data;
2238 int i, pos = 0;
2239 char buf[300];
2240 const size_t bufsz = sizeof(buf);
2241 struct iwl_force_reset *force_reset;
2242
2243 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
2244 force_reset = &priv->force_reset[i];
2245 pos += scnprintf(buf + pos, bufsz - pos,
2246 "Force reset method %d\n", i);
2247 pos += scnprintf(buf + pos, bufsz - pos,
2248 "\tnumber of reset request: %d\n",
2249 force_reset->reset_request_count);
2250 pos += scnprintf(buf + pos, bufsz - pos,
2251 "\tnumber of reset request success: %d\n",
2252 force_reset->reset_success_count);
2253 pos += scnprintf(buf + pos, bufsz - pos,
2254 "\tnumber of reset request reject: %d\n",
2255 force_reset->reset_reject_count);
2256 pos += scnprintf(buf + pos, bufsz - pos,
2257 "\treset duration: %lu\n",
2258 force_reset->reset_duration);
2259 }
2260 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2261}
2262
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08002263static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
2264 const char __user *user_buf,
2265 size_t count, loff_t *ppos) {
2266
2267 struct iwl_priv *priv = file->private_data;
2268 char buf[8];
2269 int buf_size;
2270 int reset, ret;
2271
2272 memset(buf, 0, sizeof(buf));
2273 buf_size = min(count, sizeof(buf) - 1);
2274 if (copy_from_user(buf, user_buf, buf_size))
2275 return -EFAULT;
2276 if (sscanf(buf, "%d", &reset) != 1)
2277 return -EINVAL;
2278 switch (reset) {
2279 case IWL_RF_RESET:
2280 case IWL_FW_RESET:
2281 ret = iwl_force_reset(priv, reset);
2282 break;
2283 default:
2284 return -EINVAL;
2285 }
2286 return ret ? ret : count;
2287}
2288
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002289DEBUGFS_READ_FILE_OPS(rx_statistics);
2290DEBUGFS_READ_FILE_OPS(tx_statistics);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002291DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07002292DEBUGFS_READ_FILE_OPS(rx_queue);
2293DEBUGFS_READ_FILE_OPS(tx_queue);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002294DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
2295DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
2296DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07002297DEBUGFS_READ_FILE_OPS(sensitivity);
2298DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyf204b242009-08-21 13:34:19 -07002299DEBUGFS_READ_FILE_OPS(tx_power);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07002300DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08002301DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
2302DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08002303DEBUGFS_WRITE_FILE_OPS(csr);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08002304DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08002305DEBUGFS_READ_FILE_OPS(fh_reg);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08002306DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Wey-Yi Guyafbdd692010-01-22 14:22:43 -08002307DEBUGFS_WRITE_FILE_OPS(internal_scan);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08002308DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002309DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
Johannes Berg60987202010-02-18 00:36:07 -08002310DEBUGFS_READ_FILE_OPS(rxon_flags);
2311DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07002312
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002313/*
2314 * Create the debugfs files and directories
2315 *
2316 */
2317int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2318{
Zhu Yi95b1a822008-05-29 16:34:50 +08002319 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002320 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002321
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002322 dir_drv = debugfs_create_dir(name, phyd);
2323 if (!dir_drv)
2324 return -ENOMEM;
2325
2326 priv->debugfs_dir = dir_drv;
2327
2328 dir_data = debugfs_create_dir("data", dir_drv);
2329 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002330 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002331 dir_rf = debugfs_create_dir("rf", dir_drv);
2332 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002333 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002334 dir_debug = debugfs_create_dir("debug", dir_drv);
2335 if (!dir_debug)
2336 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002337
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002338 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
2339 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
2340 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
2341 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
2342 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
2343 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
2344 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
2345 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
2346 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
2347 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
2348 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
2349 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
2350 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
2351 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
2352 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
2353 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
2354 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
2355 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
2356 DEBUGFS_ADD_FILE(tx_power, dir_debug, S_IRUSR);
2357 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
2358 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
2359 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
2360 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
2361 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
2362 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2363 DEBUGFS_ADD_FILE(internal_scan, dir_debug, S_IWUSR);
2364 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08002365 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002366 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002367 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2368 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
2369 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
2370 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
2371 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
2372 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07002373 }
Johannes Berg60987202010-02-18 00:36:07 -08002374 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2375 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002376 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal);
2377 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
Tomas Winkler445c2df2008-05-15 13:54:16 +08002378 &priv->disable_chain_noise_cal);
Wey-Yi Guy030b8652009-06-12 13:22:55 -07002379 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
2380 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002381 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf,
Wey-Yi Guy030b8652009-06-12 13:22:55 -07002382 &priv->disable_tx_power_cal);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002383 return 0;
2384
2385err:
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002386 IWL_ERR(priv, "Can't create the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002387 iwl_dbgfs_unregister(priv);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002388 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002389}
2390EXPORT_SYMBOL(iwl_dbgfs_register);
2391
2392/**
2393 * Remove the debugfs files and directories
2394 *
2395 */
2396void iwl_dbgfs_unregister(struct iwl_priv *priv)
2397{
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002398 if (!priv->debugfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002399 return;
2400
Johannes Berg4c84a8f2010-01-22 14:22:54 -08002401 debugfs_remove_recursive(priv->debugfs_dir);
2402 priv->debugfs_dir = NULL;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07002403}
2404EXPORT_SYMBOL(iwl_dbgfs_unregister);
2405
2406
Tomas Winkler445c2df2008-05-15 13:54:16 +08002407