blob: d789f8db4481c75e3e837ade13b584e906d1bd6f [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 *****************************************************************************/
Tomas Winkler712b6cf2008-03-12 16:58:52 -070028#include <linux/ieee80211.h>
29#include <net/mac80211.h>
30
31
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070032#include "iwl-dev.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070033#include "iwl-debug.h"
Tomas Winklerfee12472008-04-03 16:05:21 -070034#include "iwl-core.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070035#include "iwl-io.h"
Wey-Yi Guy52259352009-08-07 15:41:43 -070036#include "iwl-calib.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070037
38/* create and remove of files */
Johannes Berg4c84a8f2010-01-22 14:22:54 -080039#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
40 if (!debugfs_create_file(#name, mode, parent, priv, \
41 &iwl_dbgfs_##name##_ops)) \
42 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070043} while (0)
44
Johannes Berg4c84a8f2010-01-22 14:22:54 -080045#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
46 struct dentry *__tmp; \
47 __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
48 parent, ptr); \
49 if (IS_ERR(__tmp) || !__tmp) \
50 goto err; \
Tomas Winkler712b6cf2008-03-12 16:58:52 -070051} while (0)
52
Johannes Berg4c84a8f2010-01-22 14:22:54 -080053#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
54 struct dentry *__tmp; \
55 __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
56 parent, ptr); \
57 if (IS_ERR(__tmp) || !__tmp) \
58 goto err; \
Tomas Winkler445c2df2008-05-15 13:54:16 +080059} while (0)
60
Tomas Winkler712b6cf2008-03-12 16:58:52 -070061/* file operation */
62#define DEBUGFS_READ_FUNC(name) \
63static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
64 char __user *user_buf, \
65 size_t count, loff_t *ppos);
66
67#define DEBUGFS_WRITE_FUNC(name) \
68static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
69 const char __user *user_buf, \
70 size_t count, loff_t *ppos);
71
72
73static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
74{
75 file->private_data = inode->i_private;
76 return 0;
77}
78
79#define DEBUGFS_READ_FILE_OPS(name) \
80 DEBUGFS_READ_FUNC(name); \
81static const struct file_operations iwl_dbgfs_##name##_ops = { \
82 .read = iwl_dbgfs_##name##_read, \
83 .open = iwl_dbgfs_open_file_generic, \
84};
85
Ester Kummer189a2b52008-05-15 13:54:18 +080086#define DEBUGFS_WRITE_FILE_OPS(name) \
87 DEBUGFS_WRITE_FUNC(name); \
88static const struct file_operations iwl_dbgfs_##name##_ops = { \
89 .write = iwl_dbgfs_##name##_write, \
90 .open = iwl_dbgfs_open_file_generic, \
91};
92
93
Tomas Winkler712b6cf2008-03-12 16:58:52 -070094#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
95 DEBUGFS_READ_FUNC(name); \
96 DEBUGFS_WRITE_FUNC(name); \
97static const struct file_operations iwl_dbgfs_##name##_ops = { \
98 .write = iwl_dbgfs_##name##_write, \
99 .read = iwl_dbgfs_##name##_read, \
100 .open = iwl_dbgfs_open_file_generic, \
101};
102
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -0700103int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
104{
105 int p = 0;
106
107 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n",
108 le32_to_cpu(priv->statistics.flag));
109 if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
110 p += scnprintf(buf + p, bufsz - p,
111 "\tStatistics have been cleared\n");
112 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
113 (le32_to_cpu(priv->statistics.flag) &
114 UCODE_STATISTICS_FREQUENCY_MSK)
115 ? "2.4 GHz" : "5.2 GHz");
116 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
117 (le32_to_cpu(priv->statistics.flag) &
118 UCODE_STATISTICS_NARROW_BAND_MSK)
119 ? "enabled" : "disabled");
120 return p;
121}
122EXPORT_SYMBOL(iwl_dbgfs_statistics_flag);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700123
124static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
125 char __user *user_buf,
126 size_t count, loff_t *ppos) {
127
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700128 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700129 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700130 int pos = 0;
131
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700132 int cnt;
133 ssize_t ret;
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800134 const size_t bufsz = 100 +
135 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700136 buf = kzalloc(bufsz, GFP_KERNEL);
137 if (!buf)
138 return -ENOMEM;
139 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
140 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
141 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800142 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700143 get_mgmt_string(cnt),
144 priv->tx_stats.mgmt[cnt]);
145 }
146 pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
147 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
148 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800149 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700150 get_ctrl_string(cnt),
151 priv->tx_stats.ctrl[cnt]);
152 }
153 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
154 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
155 priv->tx_stats.data_cnt);
156 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
157 priv->tx_stats.data_bytes);
158 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
159 kfree(buf);
160 return ret;
161}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700162
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800163static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700164 const char __user *user_buf,
165 size_t count, loff_t *ppos)
166{
167 struct iwl_priv *priv = file->private_data;
168 u32 clear_flag;
169 char buf[8];
170 int buf_size;
171
172 memset(buf, 0, sizeof(buf));
173 buf_size = min(count, sizeof(buf) - 1);
174 if (copy_from_user(buf, user_buf, buf_size))
175 return -EFAULT;
176 if (sscanf(buf, "%x", &clear_flag) != 1)
177 return -EFAULT;
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -0800178 iwl_clear_traffic_stats(priv);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700179
180 return count;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700181}
182
183static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
184 char __user *user_buf,
185 size_t count, loff_t *ppos) {
186
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700187 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700188 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700189 int pos = 0;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700190 int cnt;
191 ssize_t ret;
192 const size_t bufsz = 100 +
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800193 sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700194 buf = kzalloc(bufsz, GFP_KERNEL);
195 if (!buf)
196 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700197
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700198 pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
199 for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
200 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800201 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700202 get_mgmt_string(cnt),
203 priv->rx_stats.mgmt[cnt]);
204 }
205 pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
206 for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
207 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guy98a7b432009-11-13 11:56:31 -0800208 "\t%25s\t\t: %u\n",
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700209 get_ctrl_string(cnt),
210 priv->rx_stats.ctrl[cnt]);
211 }
212 pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
213 pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
214 priv->rx_stats.data_cnt);
215 pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
216 priv->rx_stats.data_bytes);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700217
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700218 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
219 kfree(buf);
220 return ret;
221}
222
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700223#define BYTE1_MASK 0x000000ff;
224#define BYTE2_MASK 0x0000ffff;
225#define BYTE3_MASK 0x00ffffff;
226static ssize_t iwl_dbgfs_sram_read(struct file *file,
227 char __user *user_buf,
228 size_t count, loff_t *ppos)
229{
230 u32 val;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800231 char *buf;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700232 ssize_t ret;
233 int i;
234 int pos = 0;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700235 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800236 size_t bufsz;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700237
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800238 /* default is to dump the entire data segment */
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800239 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
240 priv->dbgfs_sram_offset = 0x800000;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800241 if (priv->ucode_type == UCODE_INIT)
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800242 priv->dbgfs_sram_len = priv->ucode_init_data.len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800243 else
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800244 priv->dbgfs_sram_len = priv->ucode_data.len;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800245 }
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800246 bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10;
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800247 buf = kmalloc(bufsz, GFP_KERNEL);
248 if (!buf)
249 return -ENOMEM;
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800250 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800251 priv->dbgfs_sram_len);
Wey-Yi Guy5ade1e42009-11-20 12:05:04 -0800252 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800253 priv->dbgfs_sram_offset);
254 for (i = priv->dbgfs_sram_len; i > 0; i -= 4) {
255 val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \
256 priv->dbgfs_sram_len - i);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700257 if (i < 4) {
258 switch (i) {
259 case 1:
260 val &= BYTE1_MASK;
261 break;
262 case 2:
263 val &= BYTE2_MASK;
264 break;
265 case 3:
266 val &= BYTE3_MASK;
267 break;
268 }
269 }
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800270 if (!(i % 16))
271 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700272 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700273 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700274 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700275
276 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy2943f132009-11-20 12:05:00 -0800277 kfree(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700278 return ret;
279}
280
281static ssize_t iwl_dbgfs_sram_write(struct file *file,
282 const char __user *user_buf,
283 size_t count, loff_t *ppos)
284{
285 struct iwl_priv *priv = file->private_data;
286 char buf[64];
287 int buf_size;
288 u32 offset, len;
289
290 memset(buf, 0, sizeof(buf));
291 buf_size = min(count, sizeof(buf) - 1);
292 if (copy_from_user(buf, user_buf, buf_size))
293 return -EFAULT;
294
295 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800296 priv->dbgfs_sram_offset = offset;
297 priv->dbgfs_sram_len = len;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700298 } else {
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800299 priv->dbgfs_sram_offset = 0;
300 priv->dbgfs_sram_len = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700301 }
302
303 return count;
304}
305
306static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
307 size_t count, loff_t *ppos)
308{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700309 struct iwl_priv *priv = file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800310 struct iwl_station_entry *station;
Tomas Winkler5425e492008-04-15 16:01:38 -0700311 int max_sta = priv->hw_params.max_stations;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700312 char *buf;
313 int i, j, pos = 0;
314 ssize_t ret;
315 /* Add 30 for initial string */
316 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700317
318 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300319 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700320 return -ENOMEM;
321
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700322 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700323 priv->num_stations);
324
325 for (i = 0; i < max_sta; i++) {
326 station = &priv->stations[i];
327 if (station->used) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700328 pos += scnprintf(buf + pos, bufsz - pos,
329 "station %d:\ngeneral data:\n", i+1);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700330 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700331 station->sta.sta.sta_id);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700332 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700333 station->sta.mode);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700334 pos += scnprintf(buf + pos, bufsz - pos,
335 "flags: 0x%x\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700336 station->sta.station_flags_msk);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700337 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
338 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700339 "seq_num\t\ttxq_id");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700340 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700341 "\tframe_count\twait_for_ba\t");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700342 pos += scnprintf(buf + pos, bufsz - pos,
343 "start_idx\tbitmap0\t");
344 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700345 "bitmap1\trate_n_flags");
David S. Miller344234d2008-04-19 18:09:39 -0700346 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700347
348 for (j = 0; j < MAX_TID_COUNT; j++) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700349 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700350 "[%d]:\t\t%u", j,
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700351 station->tid[j].seq_number);
352 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700353 "\t%u\t\t%u\t\t%u\t\t",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700354 station->tid[j].agg.txq_id,
355 station->tid[j].agg.frame_count,
356 station->tid[j].agg.wait_for_ba);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700357 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700358 "%u\t%llu\t%u",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700359 station->tid[j].agg.start_idx,
John W. Linville16788592008-04-01 20:59:32 -0400360 (unsigned long long)station->tid[j].agg.bitmap,
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700361 station->tid[j].agg.rate_n_flags);
David S. Miller344234d2008-04-19 18:09:39 -0700362 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700363 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700364 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700365 }
366 }
367
368 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
369 kfree(buf);
370 return ret;
371}
372
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700373static ssize_t iwl_dbgfs_nvm_read(struct file *file,
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800374 char __user *user_buf,
375 size_t count,
376 loff_t *ppos)
377{
378 ssize_t ret;
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700379 struct iwl_priv *priv = file->private_data;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800380 int pos = 0, ofs = 0, buf_size = 0;
381 const u8 *ptr;
382 char *buf;
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700383 u16 eeprom_ver;
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800384 size_t eeprom_len = priv->cfg->eeprom_size;
385 buf_size = 4 * eeprom_len + 256;
386
387 if (eeprom_len % 16) {
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700388 IWL_ERR(priv, "NVM size is not multiple of 16.\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800389 return -ENODATA;
390 }
391
Julia Lawallc37457e2009-08-03 11:11:45 +0200392 ptr = priv->eeprom;
393 if (!ptr) {
394 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
395 return -ENOMEM;
396 }
397
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800398 /* 4 characters for byte 0xYY */
399 buf = kzalloc(buf_size, GFP_KERNEL);
400 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800401 IWL_ERR(priv, "Can not allocate Buffer\n");
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800402 return -ENOMEM;
403 }
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700404 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
405 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
406 "version: 0x%x\n",
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700407 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
Wey-Yi Guye307ddc2009-09-11 10:38:16 -0700408 ? "OTP" : "EEPROM", eeprom_ver);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800409 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
410 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
411 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
412 buf_size - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700413 pos += strlen(buf + pos);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800414 if (buf_size - pos > 0)
415 buf[pos++] = '\n';
416 }
417
418 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
419 kfree(buf);
420 return ret;
421}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700422
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800423static ssize_t iwl_dbgfs_log_event_read(struct file *file,
424 char __user *user_buf,
425 size_t count, loff_t *ppos)
426{
427 struct iwl_priv *priv = file->private_data;
428 char *buf;
429 int pos = 0;
430 ssize_t ret = -ENOMEM;
431
Wey-Yi Guy937c3972010-01-15 13:43:36 -0800432 ret = pos = priv->cfg->ops->lib->dump_nic_event_log(
433 priv, true, &buf, true);
434 if (buf) {
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800435 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
436 kfree(buf);
437 }
438 return ret;
439}
440
Ester Kummer189a2b52008-05-15 13:54:18 +0800441static ssize_t iwl_dbgfs_log_event_write(struct file *file,
442 const char __user *user_buf,
443 size_t count, loff_t *ppos)
444{
445 struct iwl_priv *priv = file->private_data;
446 u32 event_log_flag;
447 char buf[8];
448 int buf_size;
449
450 memset(buf, 0, sizeof(buf));
451 buf_size = min(count, sizeof(buf) - 1);
452 if (copy_from_user(buf, user_buf, buf_size))
453 return -EFAULT;
454 if (sscanf(buf, "%d", &event_log_flag) != 1)
455 return -EFAULT;
456 if (event_log_flag == 1)
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800457 priv->cfg->ops->lib->dump_nic_event_log(priv, true,
458 NULL, false);
Ester Kummer189a2b52008-05-15 13:54:18 +0800459
460 return count;
461}
462
Winkler, Tomasd366df52008-12-02 12:14:01 -0800463
464
465static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
466 size_t count, loff_t *ppos)
467{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700468 struct iwl_priv *priv = file->private_data;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800469 struct ieee80211_channel *channels = NULL;
470 const struct ieee80211_supported_band *supp_band = NULL;
471 int pos = 0, i, bufsz = PAGE_SIZE;
472 char *buf;
473 ssize_t ret;
474
475 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
476 return -EAGAIN;
477
478 buf = kzalloc(bufsz, GFP_KERNEL);
479 if (!buf) {
Winkler, Tomas15b16872008-12-19 10:37:33 +0800480 IWL_ERR(priv, "Can not allocate Buffer\n");
Winkler, Tomasd366df52008-12-02 12:14:01 -0800481 return -ENOMEM;
482 }
483
484 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700485 if (supp_band) {
486 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800487
Winkler, Tomasd366df52008-12-02 12:14:01 -0800488 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700489 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
490 supp_band->n_channels);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800491
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700492 for (i = 0; i < supp_band->n_channels; i++)
493 pos += scnprintf(buf + pos, bufsz - pos,
494 "%d: %ddBm: BSS%s%s, %s.\n",
495 ieee80211_frequency_to_channel(
496 channels[i].center_freq),
497 channels[i].max_power,
498 channels[i].flags & IEEE80211_CHAN_RADAR ?
499 " (IEEE 802.11h required)" : "",
500 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
501 || (channels[i].flags &
502 IEEE80211_CHAN_RADAR)) ? "" :
503 ", IBSS",
504 channels[i].flags &
505 IEEE80211_CHAN_PASSIVE_SCAN ?
506 "passive only" : "active/passive");
507 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800508 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700509 if (supp_band) {
510 channels = supp_band->channels;
Winkler, Tomasd366df52008-12-02 12:14:01 -0800511
Winkler, Tomasd366df52008-12-02 12:14:01 -0800512 pos += scnprintf(buf + pos, bufsz - pos,
Wey-Yi Guya2e23222009-05-22 11:01:55 -0700513 "Displaying %d channels in 5.2GHz band (802.11a)\n",
514 supp_band->n_channels);
515
516 for (i = 0; i < supp_band->n_channels; i++)
517 pos += scnprintf(buf + pos, bufsz - pos,
518 "%d: %ddBm: BSS%s%s, %s.\n",
519 ieee80211_frequency_to_channel(
520 channels[i].center_freq),
521 channels[i].max_power,
522 channels[i].flags & IEEE80211_CHAN_RADAR ?
523 " (IEEE 802.11h required)" : "",
524 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
525 || (channels[i].flags &
526 IEEE80211_CHAN_RADAR)) ? "" :
527 ", IBSS",
528 channels[i].flags &
529 IEEE80211_CHAN_PASSIVE_SCAN ?
530 "passive only" : "active/passive");
531 }
Winkler, Tomasd366df52008-12-02 12:14:01 -0800532 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
533 kfree(buf);
534 return ret;
535}
536
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700537static ssize_t iwl_dbgfs_status_read(struct file *file,
538 char __user *user_buf,
539 size_t count, loff_t *ppos) {
540
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700541 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700542 char buf[512];
543 int pos = 0;
544 const size_t bufsz = sizeof(buf);
545
546 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
547 test_bit(STATUS_HCMD_ACTIVE, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700548 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
549 test_bit(STATUS_INT_ENABLED, &priv->status));
550 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
551 test_bit(STATUS_RF_KILL_HW, &priv->status));
Wey-Yi Guy7812b162009-10-02 13:43:58 -0700552 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
553 test_bit(STATUS_CT_KILL, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700554 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
555 test_bit(STATUS_INIT, &priv->status));
556 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
557 test_bit(STATUS_ALIVE, &priv->status));
558 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
559 test_bit(STATUS_READY, &priv->status));
560 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
561 test_bit(STATUS_TEMPERATURE, &priv->status));
562 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
563 test_bit(STATUS_GEO_CONFIGURED, &priv->status));
564 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
565 test_bit(STATUS_EXIT_PENDING, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700566 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
567 test_bit(STATUS_STATISTICS, &priv->status));
568 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
569 test_bit(STATUS_SCANNING, &priv->status));
570 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
571 test_bit(STATUS_SCAN_ABORTING, &priv->status));
572 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
573 test_bit(STATUS_SCAN_HW, &priv->status));
574 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
575 test_bit(STATUS_POWER_PMI, &priv->status));
576 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
577 test_bit(STATUS_FW_ERROR, &priv->status));
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700578 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
579}
580
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700581static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
582 char __user *user_buf,
583 size_t count, loff_t *ppos) {
584
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700585 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700586 int pos = 0;
587 int cnt = 0;
588 char *buf;
589 int bufsz = 24 * 64; /* 24 items * 64 char per item */
590 ssize_t ret;
591
592 buf = kzalloc(bufsz, GFP_KERNEL);
593 if (!buf) {
594 IWL_ERR(priv, "Can not allocate Buffer\n");
595 return -ENOMEM;
596 }
597
598 pos += scnprintf(buf + pos, bufsz - pos,
599 "Interrupt Statistics Report:\n");
600
601 pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
602 priv->isr_stats.hw);
603 pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
604 priv->isr_stats.sw);
605 if (priv->isr_stats.sw > 0) {
606 pos += scnprintf(buf + pos, bufsz - pos,
607 "\tLast Restarting Code: 0x%X\n",
608 priv->isr_stats.sw_err);
609 }
610#ifdef CONFIG_IWLWIFI_DEBUG
611 pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
612 priv->isr_stats.sch);
613 pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
614 priv->isr_stats.alive);
615#endif
616 pos += scnprintf(buf + pos, bufsz - pos,
617 "HW RF KILL switch toggled:\t %u\n",
618 priv->isr_stats.rfkill);
619
620 pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
621 priv->isr_stats.ctkill);
622
623 pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
624 priv->isr_stats.wakeup);
625
626 pos += scnprintf(buf + pos, bufsz - pos,
627 "Rx command responses:\t\t %u\n",
628 priv->isr_stats.rx);
629 for (cnt = 0; cnt < REPLY_MAX; cnt++) {
630 if (priv->isr_stats.rx_handlers[cnt] > 0)
631 pos += scnprintf(buf + pos, bufsz - pos,
632 "\tRx handler[%36s]:\t\t %u\n",
633 get_cmd_string(cnt),
634 priv->isr_stats.rx_handlers[cnt]);
635 }
636
637 pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
638 priv->isr_stats.tx);
639
640 pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
641 priv->isr_stats.unhandled);
642
643 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
644 kfree(buf);
645 return ret;
646}
647
648static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
649 const char __user *user_buf,
650 size_t count, loff_t *ppos)
651{
652 struct iwl_priv *priv = file->private_data;
653 char buf[8];
654 int buf_size;
655 u32 reset_flag;
656
657 memset(buf, 0, sizeof(buf));
658 buf_size = min(count, sizeof(buf) - 1);
659 if (copy_from_user(buf, user_buf, buf_size))
660 return -EFAULT;
661 if (sscanf(buf, "%x", &reset_flag) != 1)
662 return -EFAULT;
663 if (reset_flag == 0)
664 iwl_clear_isr_stats(priv);
665
666 return count;
667}
668
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700669static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
670 size_t count, loff_t *ppos)
671{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700672 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700673 int pos = 0, i;
674 char buf[256];
675 const size_t bufsz = sizeof(buf);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700676
677 for (i = 0; i < AC_NUM; i++) {
678 pos += scnprintf(buf + pos, bufsz - pos,
679 "\tcw_min\tcw_max\taifsn\ttxop\n");
680 pos += scnprintf(buf + pos, bufsz - pos,
681 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
682 priv->qos_data.def_qos_parm.ac[i].cw_min,
683 priv->qos_data.def_qos_parm.ac[i].cw_max,
684 priv->qos_data.def_qos_parm.ac[i].aifsn,
685 priv->qos_data.def_qos_parm.ac[i].edca_txop);
686 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800687 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700688}
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700689
Wey-Yi Guya283c012009-07-17 09:30:19 -0700690static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
691 size_t count, loff_t *ppos)
692{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700693 struct iwl_priv *priv = file->private_data;
Wey-Yi Guya283c012009-07-17 09:30:19 -0700694 int pos = 0;
695 char buf[256];
696 const size_t bufsz = sizeof(buf);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700697
698 pos += scnprintf(buf + pos, bufsz - pos,
699 "allow blinking: %s\n",
700 (priv->allow_blinking) ? "True" : "False");
701 if (priv->allow_blinking) {
702 pos += scnprintf(buf + pos, bufsz - pos,
703 "Led blinking rate: %u\n",
704 priv->last_blink_rate);
705 pos += scnprintf(buf + pos, bufsz - pos,
706 "Last blink time: %lu\n",
707 priv->last_blink_time);
708 }
709
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800710 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700711}
Wey-Yi Guya283c012009-07-17 09:30:19 -0700712
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700713static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
714 char __user *user_buf,
715 size_t count, loff_t *ppos)
716{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700717 struct iwl_priv *priv = file->private_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700718 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700719 struct iwl_tt_restriction *restriction;
720 char buf[100];
721 int pos = 0;
722 const size_t bufsz = sizeof(buf);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700723
724 pos += scnprintf(buf + pos, bufsz - pos,
725 "Thermal Throttling Mode: %s\n",
Johannes Berg3ad3b922009-08-07 15:41:48 -0700726 tt->advanced_tt ? "Advance" : "Legacy");
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700727 pos += scnprintf(buf + pos, bufsz - pos,
728 "Thermal Throttling State: %d\n",
729 tt->state);
Johannes Berg3ad3b922009-08-07 15:41:48 -0700730 if (tt->advanced_tt) {
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700731 restriction = tt->restriction + tt->state;
732 pos += scnprintf(buf + pos, bufsz - pos,
733 "Tx mode: %d\n",
734 restriction->tx_stream);
735 pos += scnprintf(buf + pos, bufsz - pos,
736 "Rx mode: %d\n",
737 restriction->rx_stream);
738 pos += scnprintf(buf + pos, bufsz - pos,
739 "HT mode: %d\n",
740 restriction->is_ht);
741 }
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800742 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700743}
744
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700745static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
746 const char __user *user_buf,
747 size_t count, loff_t *ppos)
748{
749 struct iwl_priv *priv = file->private_data;
750 char buf[8];
751 int buf_size;
752 int ht40;
753
754 memset(buf, 0, sizeof(buf));
755 buf_size = min(count, sizeof(buf) - 1);
756 if (copy_from_user(buf, user_buf, buf_size))
757 return -EFAULT;
758 if (sscanf(buf, "%d", &ht40) != 1)
759 return -EFAULT;
760 if (!iwl_is_associated(priv))
761 priv->disable_ht40 = ht40 ? true : false;
762 else {
763 IWL_ERR(priv, "Sta associated with AP - "
764 "Change to 40MHz channel support is not allowed\n");
765 return -EINVAL;
766 }
767
768 return count;
769}
770
771static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
772 char __user *user_buf,
773 size_t count, loff_t *ppos)
774{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700775 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700776 char buf[100];
777 int pos = 0;
778 const size_t bufsz = sizeof(buf);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700779
780 pos += scnprintf(buf + pos, bufsz - pos,
781 "11n 40MHz Mode: %s\n",
782 priv->disable_ht40 ? "Disabled" : "Enabled");
Wey-Yi Guy4967c312010-02-18 15:22:07 -0800783 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700784}
785
Johannes Berge312c242009-08-07 15:41:51 -0700786static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
787 const char __user *user_buf,
788 size_t count, loff_t *ppos)
789{
790 struct iwl_priv *priv = file->private_data;
791 char buf[8];
792 int buf_size;
793 int value;
794
795 memset(buf, 0, sizeof(buf));
796 buf_size = min(count, sizeof(buf) - 1);
797 if (copy_from_user(buf, user_buf, buf_size))
798 return -EFAULT;
799
800 if (sscanf(buf, "%d", &value) != 1)
801 return -EINVAL;
802
803 /*
804 * Our users expect 0 to be "CAM", but 0 isn't actually
805 * valid here. However, let's not confuse them and present
806 * IWL_POWER_INDEX_1 as "1", not "0".
807 */
Reinette Chatre1a34c042009-10-09 13:20:25 -0700808 if (value == 0)
809 return -EINVAL;
810 else if (value > 0)
Johannes Berge312c242009-08-07 15:41:51 -0700811 value -= 1;
812
813 if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
814 return -EINVAL;
815
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700816 if (!iwl_is_ready_rf(priv))
817 return -EAGAIN;
818
Johannes Berge312c242009-08-07 15:41:51 -0700819 priv->power_data.debug_sleep_level_override = value;
820
Reinette Chatred3a57192010-01-21 11:52:28 -0800821 mutex_lock(&priv->mutex);
Wey-Yi Guy4ad177b2009-10-16 14:25:58 -0700822 iwl_power_update_mode(priv, true);
Reinette Chatred3a57192010-01-21 11:52:28 -0800823 mutex_unlock(&priv->mutex);
Johannes Berge312c242009-08-07 15:41:51 -0700824
825 return count;
826}
827
828static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
829 char __user *user_buf,
830 size_t count, loff_t *ppos)
831{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700832 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700833 char buf[10];
834 int pos, value;
835 const size_t bufsz = sizeof(buf);
836
837 /* see the write function */
838 value = priv->power_data.debug_sleep_level_override;
839 if (value >= 0)
840 value += 1;
841
842 pos = scnprintf(buf, bufsz, "%d\n", value);
843 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
844}
845
846static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
847 char __user *user_buf,
848 size_t count, loff_t *ppos)
849{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700850 struct iwl_priv *priv = file->private_data;
Johannes Berge312c242009-08-07 15:41:51 -0700851 char buf[200];
852 int pos = 0, i;
853 const size_t bufsz = sizeof(buf);
854 struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
855
856 pos += scnprintf(buf + pos, bufsz - pos,
857 "flags: %#.2x\n", le16_to_cpu(cmd->flags));
858 pos += scnprintf(buf + pos, bufsz - pos,
859 "RX/TX timeout: %d/%d usec\n",
860 le32_to_cpu(cmd->rx_data_timeout),
861 le32_to_cpu(cmd->tx_data_timeout));
862 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
863 pos += scnprintf(buf + pos, bufsz - pos,
864 "sleep_interval[%d]: %d\n", i,
865 le32_to_cpu(cmd->sleep_interval[i]));
866
867 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
868}
869
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700870DEBUGFS_READ_WRITE_FILE_OPS(sram);
Wey-Yi Guyb03d7d02009-12-14 14:12:20 -0800871DEBUGFS_READ_WRITE_FILE_OPS(log_event);
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700872DEBUGFS_READ_FILE_OPS(nvm);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700873DEBUGFS_READ_FILE_OPS(stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800874DEBUGFS_READ_FILE_OPS(channels);
Wey-Yi Guy08df05a2009-03-24 10:02:54 -0700875DEBUGFS_READ_FILE_OPS(status);
Wey-Yi Guya83b9142009-04-08 11:39:32 -0700876DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
Wey-Yi Guyf5ad69f2009-07-09 10:33:36 -0700877DEBUGFS_READ_FILE_OPS(qos);
Wey-Yi Guya283c012009-07-17 09:30:19 -0700878DEBUGFS_READ_FILE_OPS(led);
Wey-Yi Guyfbf3a2a2009-07-24 11:13:04 -0700879DEBUGFS_READ_FILE_OPS(thermal_throttling);
Wey-Yi Guy1e4247d2009-07-27 13:50:15 -0700880DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
Johannes Berge312c242009-08-07 15:41:51 -0700881DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
882DEBUGFS_READ_FILE_OPS(current_sleep_command);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700883
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700884static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
885 char __user *user_buf,
886 size_t count, loff_t *ppos)
887{
888 struct iwl_priv *priv = file->private_data;
889 int pos = 0, ofs = 0;
890 int cnt = 0, entry;
891 struct iwl_tx_queue *txq;
892 struct iwl_queue *q;
893 struct iwl_rx_queue *rxq = &priv->rxq;
894 char *buf;
895 int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700896 (priv->cfg->num_of_queues * 32 * 8) + 400;
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700897 const u8 *ptr;
898 ssize_t ret;
899
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700900 if (!priv->txq) {
901 IWL_ERR(priv, "txq not ready\n");
902 return -EAGAIN;
903 }
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700904 buf = kzalloc(bufsz, GFP_KERNEL);
905 if (!buf) {
906 IWL_ERR(priv, "Can not allocate buffer\n");
907 return -ENOMEM;
908 }
909 pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n");
910 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
911 txq = &priv->txq[cnt];
912 q = &txq->q;
913 pos += scnprintf(buf + pos, bufsz - pos,
914 "q[%d]: read_ptr: %u, write_ptr: %u\n",
915 cnt, q->read_ptr, q->write_ptr);
916 }
917 if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) {
918 ptr = priv->tx_traffic;
919 pos += scnprintf(buf + pos, bufsz - pos,
920 "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
921 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
922 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
923 entry++, ofs += 16) {
924 pos += scnprintf(buf + pos, bufsz - pos,
925 "0x%.4x ", ofs);
926 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
927 buf + pos, bufsz - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700928 pos += strlen(buf + pos);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700929 if (bufsz - pos > 0)
930 buf[pos++] = '\n';
931 }
932 }
933 }
934
935 pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n");
936 pos += scnprintf(buf + pos, bufsz - pos,
937 "read: %u, write: %u\n",
938 rxq->read, rxq->write);
939
940 if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) {
941 ptr = priv->rx_traffic;
942 pos += scnprintf(buf + pos, bufsz - pos,
943 "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
944 for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
945 for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
946 entry++, ofs += 16) {
947 pos += scnprintf(buf + pos, bufsz - pos,
948 "0x%.4x ", ofs);
949 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
950 buf + pos, bufsz - pos, 0);
Reinette Chatre2fac9712009-09-25 14:24:21 -0700951 pos += strlen(buf + pos);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700952 if (bufsz - pos > 0)
953 buf[pos++] = '\n';
954 }
955 }
956 }
957
958 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
959 kfree(buf);
960 return ret;
961}
962
963static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
964 const char __user *user_buf,
965 size_t count, loff_t *ppos)
966{
967 struct iwl_priv *priv = file->private_data;
968 char buf[8];
969 int buf_size;
970 int traffic_log;
971
972 memset(buf, 0, sizeof(buf));
973 buf_size = min(count, sizeof(buf) - 1);
974 if (copy_from_user(buf, user_buf, buf_size))
975 return -EFAULT;
976 if (sscanf(buf, "%d", &traffic_log) != 1)
977 return -EFAULT;
978 if (traffic_log == 0)
979 iwl_reset_traffic_log(priv);
980
981 return count;
982}
983
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700984static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
985 char __user *user_buf,
986 size_t count, loff_t *ppos) {
987
H Hartley Sweeten28f63a42010-01-08 16:14:10 -0700988 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700989 struct iwl_tx_queue *txq;
990 struct iwl_queue *q;
991 char *buf;
992 int pos = 0;
993 int cnt;
994 int ret;
Wey-Yi Guyd23db552009-11-20 12:04:59 -0800995 const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -0700996
Wey-Yi Guy88804e22009-10-09 13:20:28 -0700997 if (!priv->txq) {
998 IWL_ERR(priv, "txq not ready\n");
999 return -EAGAIN;
1000 }
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001001 buf = kzalloc(bufsz, GFP_KERNEL);
1002 if (!buf)
1003 return -ENOMEM;
1004
1005 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
1006 txq = &priv->txq[cnt];
1007 q = &txq->q;
1008 pos += scnprintf(buf + pos, bufsz - pos,
1009 "hwq %.2d: read=%u write=%u stop=%d"
1010 " swq_id=%#.2x (ac %d/hwq %d)\n",
1011 cnt, q->read_ptr, q->write_ptr,
1012 !!test_bit(cnt, priv->queue_stopped),
1013 txq->swq_id,
1014 txq->swq_id & 0x80 ? txq->swq_id & 3 :
1015 txq->swq_id,
1016 txq->swq_id & 0x80 ? (txq->swq_id >> 2) &
1017 0x1f : txq->swq_id);
1018 if (cnt >= 4)
1019 continue;
1020 /* for the ACs, display the stop count too */
1021 pos += scnprintf(buf + pos, bufsz - pos,
1022 " stop-count: %d\n",
1023 atomic_read(&priv->queue_stop_count[cnt]));
1024 }
1025 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1026 kfree(buf);
1027 return ret;
1028}
1029
1030static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
1031 char __user *user_buf,
1032 size_t count, loff_t *ppos) {
1033
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001034 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001035 struct iwl_rx_queue *rxq = &priv->rxq;
1036 char buf[256];
1037 int pos = 0;
1038 const size_t bufsz = sizeof(buf);
1039
1040 pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n",
1041 rxq->read);
1042 pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n",
1043 rxq->write);
1044 pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n",
1045 rxq->free_count);
1046 pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n",
1047 le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF);
1048 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1049}
1050
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001051static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
1052 char __user *user_buf,
1053 size_t count, loff_t *ppos)
1054{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001055 struct iwl_priv *priv = file->private_data;
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07001056 if (priv->cfg->ops->lib->debugfs_ops.rx_stats_read)
1057 return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file,
1058 user_buf, count, ppos);
1059 return 0;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001060}
1061
1062static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1063 char __user *user_buf,
1064 size_t count, loff_t *ppos)
1065{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001066 struct iwl_priv *priv = file->private_data;
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07001067 if (priv->cfg->ops->lib->debugfs_ops.tx_stats_read)
1068 return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file,
1069 user_buf, count, ppos);
1070 return 0;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001071}
1072
1073static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1074 char __user *user_buf,
1075 size_t count, loff_t *ppos)
1076{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001077 struct iwl_priv *priv = file->private_data;
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07001078 if (priv->cfg->ops->lib->debugfs_ops.general_stats_read)
1079 return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file,
1080 user_buf, count, ppos);
1081 return 0;
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001082}
1083
Wey-Yi Guy52259352009-08-07 15:41:43 -07001084static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1085 char __user *user_buf,
1086 size_t count, loff_t *ppos) {
1087
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001088 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001089 int pos = 0;
1090 int cnt = 0;
1091 char *buf;
1092 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1093 ssize_t ret;
1094 struct iwl_sensitivity_data *data;
1095
1096 data = &priv->sensitivity_data;
1097 buf = kzalloc(bufsz, GFP_KERNEL);
1098 if (!buf) {
1099 IWL_ERR(priv, "Can not allocate Buffer\n");
1100 return -ENOMEM;
1101 }
1102
1103 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1104 data->auto_corr_ofdm);
1105 pos += scnprintf(buf + pos, bufsz - pos,
1106 "auto_corr_ofdm_mrc:\t\t %u\n",
1107 data->auto_corr_ofdm_mrc);
1108 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1109 data->auto_corr_ofdm_x1);
1110 pos += scnprintf(buf + pos, bufsz - pos,
1111 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1112 data->auto_corr_ofdm_mrc_x1);
1113 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1114 data->auto_corr_cck);
1115 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1116 data->auto_corr_cck_mrc);
1117 pos += scnprintf(buf + pos, bufsz - pos,
1118 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1119 data->last_bad_plcp_cnt_ofdm);
1120 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1121 data->last_fa_cnt_ofdm);
1122 pos += scnprintf(buf + pos, bufsz - pos,
1123 "last_bad_plcp_cnt_cck:\t\t %u\n",
1124 data->last_bad_plcp_cnt_cck);
1125 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1126 data->last_fa_cnt_cck);
1127 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1128 data->nrg_curr_state);
1129 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1130 data->nrg_prev_state);
1131 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1132 for (cnt = 0; cnt < 10; cnt++) {
1133 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1134 data->nrg_value[cnt]);
1135 }
1136 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1137 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1138 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1139 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1140 data->nrg_silence_rssi[cnt]);
1141 }
1142 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1143 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1144 data->nrg_silence_ref);
1145 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1146 data->nrg_energy_idx);
1147 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1148 data->nrg_silence_idx);
1149 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1150 data->nrg_th_cck);
1151 pos += scnprintf(buf + pos, bufsz - pos,
1152 "nrg_auto_corr_silence_diff:\t %u\n",
1153 data->nrg_auto_corr_silence_diff);
1154 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1155 data->num_in_cck_no_fa);
1156 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1157 data->nrg_th_ofdm);
1158
1159 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1160 kfree(buf);
1161 return ret;
1162}
1163
1164
1165static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1166 char __user *user_buf,
1167 size_t count, loff_t *ppos) {
1168
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001169 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001170 int pos = 0;
1171 int cnt = 0;
1172 char *buf;
1173 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1174 ssize_t ret;
1175 struct iwl_chain_noise_data *data;
1176
1177 data = &priv->chain_noise_data;
1178 buf = kzalloc(bufsz, GFP_KERNEL);
1179 if (!buf) {
1180 IWL_ERR(priv, "Can not allocate Buffer\n");
1181 return -ENOMEM;
1182 }
1183
1184 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1185 data->active_chains);
1186 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1187 data->chain_noise_a);
1188 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1189 data->chain_noise_b);
1190 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1191 data->chain_noise_c);
1192 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1193 data->chain_signal_a);
1194 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1195 data->chain_signal_b);
1196 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1197 data->chain_signal_c);
1198 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1199 data->beacon_count);
1200
1201 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1202 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1203 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1204 data->disconn_array[cnt]);
1205 }
1206 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1207 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1208 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1209 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1210 data->delta_gain_code[cnt]);
1211 }
1212 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1213 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1214 data->radio_write);
1215 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1216 data->state);
1217
1218 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1219 kfree(buf);
1220 return ret;
1221}
1222
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001223static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
1224 char __user *user_buf,
1225 size_t count, loff_t *ppos) {
1226
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001227 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001228 char buf[128];
1229 int pos = 0;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001230 const size_t bufsz = sizeof(buf);
1231 struct statistics_tx *tx;
1232
1233 if (!iwl_is_alive(priv))
1234 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1235 else {
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001236 tx = &priv->statistics.tx;
1237 if (tx->tx_power.ant_a ||
1238 tx->tx_power.ant_b ||
1239 tx->tx_power.ant_c) {
1240 pos += scnprintf(buf + pos, bufsz - pos,
1241 "tx power: (1/2 dB step)\n");
1242 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1243 tx->tx_power.ant_a)
1244 pos += scnprintf(buf + pos, bufsz - pos,
1245 "\tantenna A: 0x%X\n",
1246 tx->tx_power.ant_a);
1247 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1248 tx->tx_power.ant_b)
1249 pos += scnprintf(buf + pos, bufsz - pos,
1250 "\tantenna B: 0x%X\n",
1251 tx->tx_power.ant_b);
1252 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1253 tx->tx_power.ant_c)
1254 pos += scnprintf(buf + pos, bufsz - pos,
1255 "\tantenna C: 0x%X\n",
1256 tx->tx_power.ant_c);
1257 } else
1258 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1259 }
1260 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1261}
1262
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001263static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1264 char __user *user_buf,
1265 size_t count, loff_t *ppos)
1266{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001267 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001268 char buf[60];
1269 int pos = 0;
1270 const size_t bufsz = sizeof(buf);
1271 u32 pwrsave_status;
1272
1273 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
1274 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1275
1276 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1277 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1278 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1279 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1280 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1281 "error");
1282
1283 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1284}
1285
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001286static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001287 const char __user *user_buf,
1288 size_t count, loff_t *ppos)
1289{
1290 struct iwl_priv *priv = file->private_data;
1291 char buf[8];
1292 int buf_size;
1293 int clear;
1294
1295 memset(buf, 0, sizeof(buf));
1296 buf_size = min(count, sizeof(buf) - 1);
1297 if (copy_from_user(buf, user_buf, buf_size))
1298 return -EFAULT;
1299 if (sscanf(buf, "%d", &clear) != 1)
1300 return -EFAULT;
1301
1302 /* make request to uCode to retrieve statistics information */
1303 mutex_lock(&priv->mutex);
1304 iwl_send_statistics_request(priv, CMD_SYNC, true);
1305 mutex_unlock(&priv->mutex);
1306
1307 return count;
1308}
1309
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08001310static ssize_t iwl_dbgfs_csr_write(struct file *file,
1311 const char __user *user_buf,
1312 size_t count, loff_t *ppos)
1313{
1314 struct iwl_priv *priv = file->private_data;
1315 char buf[8];
1316 int buf_size;
1317 int csr;
1318
1319 memset(buf, 0, sizeof(buf));
1320 buf_size = min(count, sizeof(buf) - 1);
1321 if (copy_from_user(buf, user_buf, buf_size))
1322 return -EFAULT;
1323 if (sscanf(buf, "%d", &csr) != 1)
1324 return -EFAULT;
1325
1326 if (priv->cfg->ops->lib->dump_csr)
1327 priv->cfg->ops->lib->dump_csr(priv);
1328
1329 return count;
1330}
1331
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001332static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1333 char __user *user_buf,
1334 size_t count, loff_t *ppos) {
1335
1336 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1337 int pos = 0;
1338 char buf[128];
1339 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001340
1341 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1342 priv->event_log.ucode_trace ? "On" : "Off");
1343 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1344 priv->event_log.non_wraps_count);
1345 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1346 priv->event_log.wraps_once_count);
1347 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1348 priv->event_log.wraps_more_count);
1349
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001350 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001351}
1352
1353static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
1354 const char __user *user_buf,
1355 size_t count, loff_t *ppos)
1356{
1357 struct iwl_priv *priv = file->private_data;
1358 char buf[8];
1359 int buf_size;
1360 int trace;
1361
1362 memset(buf, 0, sizeof(buf));
1363 buf_size = min(count, sizeof(buf) - 1);
1364 if (copy_from_user(buf, user_buf, buf_size))
1365 return -EFAULT;
1366 if (sscanf(buf, "%d", &trace) != 1)
1367 return -EFAULT;
1368
1369 if (trace) {
1370 priv->event_log.ucode_trace = true;
1371 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
1372 mod_timer(&priv->ucode_trace,
1373 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
1374 } else {
1375 priv->event_log.ucode_trace = false;
1376 del_timer_sync(&priv->ucode_trace);
1377 }
1378
1379 return count;
1380}
1381
Johannes Berg60987202010-02-18 00:36:07 -08001382static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1383 char __user *user_buf,
1384 size_t count, loff_t *ppos) {
1385
1386 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1387 int len = 0;
1388 char buf[20];
1389
1390 len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags));
1391 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1392}
1393
1394static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1395 char __user *user_buf,
1396 size_t count, loff_t *ppos) {
1397
1398 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1399 int len = 0;
1400 char buf[20];
1401
1402 len = sprintf(buf, "0x%04X\n",
1403 le32_to_cpu(priv->active_rxon.filter_flags));
1404 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1405}
1406
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08001407static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
1408 char __user *user_buf,
1409 size_t count, loff_t *ppos)
1410{
1411 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1412 char *buf;
1413 int pos = 0;
1414 ssize_t ret = -EFAULT;
1415
1416 if (priv->cfg->ops->lib->dump_fh) {
1417 ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true);
1418 if (buf) {
1419 ret = simple_read_from_buffer(user_buf,
1420 count, ppos, buf, pos);
1421 kfree(buf);
1422 }
1423 }
1424
1425 return ret;
1426}
1427
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001428static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
1429 char __user *user_buf,
1430 size_t count, loff_t *ppos) {
1431
1432 struct iwl_priv *priv = file->private_data;
1433 int pos = 0;
1434 char buf[12];
1435 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001436
1437 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
1438 priv->missed_beacon_threshold);
1439
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001440 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001441}
1442
1443static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
1444 const char __user *user_buf,
1445 size_t count, loff_t *ppos)
1446{
1447 struct iwl_priv *priv = file->private_data;
1448 char buf[8];
1449 int buf_size;
1450 int missed;
1451
1452 memset(buf, 0, sizeof(buf));
1453 buf_size = min(count, sizeof(buf) - 1);
1454 if (copy_from_user(buf, user_buf, buf_size))
1455 return -EFAULT;
1456 if (sscanf(buf, "%d", &missed) != 1)
1457 return -EINVAL;
1458
1459 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
1460 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
1461 priv->missed_beacon_threshold =
1462 IWL_MISSED_BEACON_THRESHOLD_DEF;
1463 else
1464 priv->missed_beacon_threshold = missed;
1465
1466 return count;
1467}
1468
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001469static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
1470 char __user *user_buf,
1471 size_t count, loff_t *ppos) {
1472
1473 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1474 int pos = 0;
1475 char buf[12];
1476 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001477
1478 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
1479 priv->cfg->plcp_delta_threshold);
1480
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001481 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001482}
1483
1484static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
1485 const char __user *user_buf,
1486 size_t count, loff_t *ppos) {
1487
1488 struct iwl_priv *priv = file->private_data;
1489 char buf[8];
1490 int buf_size;
1491 int plcp;
1492
1493 memset(buf, 0, sizeof(buf));
1494 buf_size = min(count, sizeof(buf) - 1);
1495 if (copy_from_user(buf, user_buf, buf_size))
1496 return -EFAULT;
1497 if (sscanf(buf, "%d", &plcp) != 1)
1498 return -EINVAL;
1499 if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
1500 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
1501 priv->cfg->plcp_delta_threshold =
1502 IWL_MAX_PLCP_ERR_THRESHOLD_DEF;
1503 else
1504 priv->cfg->plcp_delta_threshold = plcp;
1505 return count;
1506}
1507
Wey-Yi Guy528c3122010-02-18 22:03:07 -08001508static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
1509 char __user *user_buf,
1510 size_t count, loff_t *ppos) {
1511
1512 struct iwl_priv *priv = file->private_data;
1513 int i, pos = 0;
1514 char buf[300];
1515 const size_t bufsz = sizeof(buf);
1516 struct iwl_force_reset *force_reset;
1517
1518 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
1519 force_reset = &priv->force_reset[i];
1520 pos += scnprintf(buf + pos, bufsz - pos,
1521 "Force reset method %d\n", i);
1522 pos += scnprintf(buf + pos, bufsz - pos,
1523 "\tnumber of reset request: %d\n",
1524 force_reset->reset_request_count);
1525 pos += scnprintf(buf + pos, bufsz - pos,
1526 "\tnumber of reset request success: %d\n",
1527 force_reset->reset_success_count);
1528 pos += scnprintf(buf + pos, bufsz - pos,
1529 "\tnumber of reset request reject: %d\n",
1530 force_reset->reset_reject_count);
1531 pos += scnprintf(buf + pos, bufsz - pos,
1532 "\treset duration: %lu\n",
1533 force_reset->reset_duration);
1534 }
1535 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1536}
1537
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08001538static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
1539 const char __user *user_buf,
1540 size_t count, loff_t *ppos) {
1541
1542 struct iwl_priv *priv = file->private_data;
1543 char buf[8];
1544 int buf_size;
1545 int reset, ret;
1546
1547 memset(buf, 0, sizeof(buf));
1548 buf_size = min(count, sizeof(buf) - 1);
1549 if (copy_from_user(buf, user_buf, buf_size))
1550 return -EFAULT;
1551 if (sscanf(buf, "%d", &reset) != 1)
1552 return -EINVAL;
1553 switch (reset) {
1554 case IWL_RF_RESET:
1555 case IWL_FW_RESET:
1556 ret = iwl_force_reset(priv, reset);
1557 break;
1558 default:
1559 return -EINVAL;
1560 }
1561 return ret ? ret : count;
1562}
1563
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001564DEBUGFS_READ_FILE_OPS(rx_statistics);
1565DEBUGFS_READ_FILE_OPS(tx_statistics);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07001566DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001567DEBUGFS_READ_FILE_OPS(rx_queue);
1568DEBUGFS_READ_FILE_OPS(tx_queue);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001569DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
1570DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
1571DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07001572DEBUGFS_READ_FILE_OPS(sensitivity);
1573DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001574DEBUGFS_READ_FILE_OPS(tx_power);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001575DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001576DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
1577DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08001578DEBUGFS_WRITE_FILE_OPS(csr);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001579DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08001580DEBUGFS_READ_FILE_OPS(fh_reg);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001581DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001582DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08001583DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
Johannes Berg60987202010-02-18 00:36:07 -08001584DEBUGFS_READ_FILE_OPS(rxon_flags);
1585DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07001586
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001587/*
1588 * Create the debugfs files and directories
1589 *
1590 */
1591int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1592{
Zhu Yi95b1a822008-05-29 16:34:50 +08001593 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001594 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001595
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001596 dir_drv = debugfs_create_dir(name, phyd);
1597 if (!dir_drv)
1598 return -ENOMEM;
1599
1600 priv->debugfs_dir = dir_drv;
1601
1602 dir_data = debugfs_create_dir("data", dir_drv);
1603 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001604 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001605 dir_rf = debugfs_create_dir("rf", dir_drv);
1606 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001607 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001608 dir_debug = debugfs_create_dir("debug", dir_drv);
1609 if (!dir_debug)
1610 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001611
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001612 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
1613 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
1614 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
1615 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
1616 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
1617 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
1618 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
1619 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
1620 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
1621 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
1622 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
1623 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
1624 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
1625 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
1626 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
1627 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
1628 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
1629 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
1630 DEBUGFS_ADD_FILE(tx_power, dir_debug, S_IRUSR);
1631 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
1632 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
1633 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
1634 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
1635 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
1636 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001637 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08001638 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07001639 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
1640 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
1641 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1642
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001643 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001644 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
1645 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
1646 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001647 }
Johannes Berg60987202010-02-18 00:36:07 -08001648 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1649 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001650 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal);
1651 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
Tomas Winkler445c2df2008-05-15 13:54:16 +08001652 &priv->disable_chain_noise_cal);
Wey-Yi Guy030b8652009-06-12 13:22:55 -07001653 if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
1654 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001655 DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf,
Wey-Yi Guy030b8652009-06-12 13:22:55 -07001656 &priv->disable_tx_power_cal);
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001657 return 0;
1658
1659err:
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001660 IWL_ERR(priv, "Can't create the debugfs directory\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001661 iwl_dbgfs_unregister(priv);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001662 return -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001663}
1664EXPORT_SYMBOL(iwl_dbgfs_register);
1665
1666/**
1667 * Remove the debugfs files and directories
1668 *
1669 */
1670void iwl_dbgfs_unregister(struct iwl_priv *priv)
1671{
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001672 if (!priv->debugfs_dir)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001673 return;
1674
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001675 debugfs_remove_recursive(priv->debugfs_dir);
1676 priv->debugfs_dir = NULL;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001677}
1678EXPORT_SYMBOL(iwl_dbgfs_unregister);
1679
1680
Tomas Winkler445c2df2008-05-15 13:54:16 +08001681