blob: df34c3105e1e43f21eeddec7fa37ec925a8bcb9a [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 Kolekar17f36fc2010-04-16 10:03:54 -07001056 return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file,
1057 user_buf, count, ppos);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001058}
1059
1060static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
1061 char __user *user_buf,
1062 size_t count, loff_t *ppos)
1063{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001064 struct iwl_priv *priv = file->private_data;
Abhijeet Kolekar17f36fc2010-04-16 10:03:54 -07001065 return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file,
1066 user_buf, count, ppos);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001067}
1068
1069static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
1070 char __user *user_buf,
1071 size_t count, loff_t *ppos)
1072{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001073 struct iwl_priv *priv = file->private_data;
Abhijeet Kolekar17f36fc2010-04-16 10:03:54 -07001074 return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file,
1075 user_buf, count, ppos);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001076}
1077
Wey-Yi Guy52259352009-08-07 15:41:43 -07001078static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
1079 char __user *user_buf,
1080 size_t count, loff_t *ppos) {
1081
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001082 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001083 int pos = 0;
1084 int cnt = 0;
1085 char *buf;
1086 int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
1087 ssize_t ret;
1088 struct iwl_sensitivity_data *data;
1089
1090 data = &priv->sensitivity_data;
1091 buf = kzalloc(bufsz, GFP_KERNEL);
1092 if (!buf) {
1093 IWL_ERR(priv, "Can not allocate Buffer\n");
1094 return -ENOMEM;
1095 }
1096
1097 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
1098 data->auto_corr_ofdm);
1099 pos += scnprintf(buf + pos, bufsz - pos,
1100 "auto_corr_ofdm_mrc:\t\t %u\n",
1101 data->auto_corr_ofdm_mrc);
1102 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
1103 data->auto_corr_ofdm_x1);
1104 pos += scnprintf(buf + pos, bufsz - pos,
1105 "auto_corr_ofdm_mrc_x1:\t\t %u\n",
1106 data->auto_corr_ofdm_mrc_x1);
1107 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
1108 data->auto_corr_cck);
1109 pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
1110 data->auto_corr_cck_mrc);
1111 pos += scnprintf(buf + pos, bufsz - pos,
1112 "last_bad_plcp_cnt_ofdm:\t\t %u\n",
1113 data->last_bad_plcp_cnt_ofdm);
1114 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
1115 data->last_fa_cnt_ofdm);
1116 pos += scnprintf(buf + pos, bufsz - pos,
1117 "last_bad_plcp_cnt_cck:\t\t %u\n",
1118 data->last_bad_plcp_cnt_cck);
1119 pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
1120 data->last_fa_cnt_cck);
1121 pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
1122 data->nrg_curr_state);
1123 pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
1124 data->nrg_prev_state);
1125 pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
1126 for (cnt = 0; cnt < 10; cnt++) {
1127 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1128 data->nrg_value[cnt]);
1129 }
1130 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1131 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
1132 for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
1133 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1134 data->nrg_silence_rssi[cnt]);
1135 }
1136 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1137 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
1138 data->nrg_silence_ref);
1139 pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
1140 data->nrg_energy_idx);
1141 pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
1142 data->nrg_silence_idx);
1143 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
1144 data->nrg_th_cck);
1145 pos += scnprintf(buf + pos, bufsz - pos,
1146 "nrg_auto_corr_silence_diff:\t %u\n",
1147 data->nrg_auto_corr_silence_diff);
1148 pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
1149 data->num_in_cck_no_fa);
1150 pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
1151 data->nrg_th_ofdm);
1152
1153 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1154 kfree(buf);
1155 return ret;
1156}
1157
1158
1159static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
1160 char __user *user_buf,
1161 size_t count, loff_t *ppos) {
1162
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001163 struct iwl_priv *priv = file->private_data;
Wey-Yi Guy52259352009-08-07 15:41:43 -07001164 int pos = 0;
1165 int cnt = 0;
1166 char *buf;
1167 int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
1168 ssize_t ret;
1169 struct iwl_chain_noise_data *data;
1170
1171 data = &priv->chain_noise_data;
1172 buf = kzalloc(bufsz, GFP_KERNEL);
1173 if (!buf) {
1174 IWL_ERR(priv, "Can not allocate Buffer\n");
1175 return -ENOMEM;
1176 }
1177
1178 pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
1179 data->active_chains);
1180 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
1181 data->chain_noise_a);
1182 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
1183 data->chain_noise_b);
1184 pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
1185 data->chain_noise_c);
1186 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
1187 data->chain_signal_a);
1188 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
1189 data->chain_signal_b);
1190 pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
1191 data->chain_signal_c);
1192 pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
1193 data->beacon_count);
1194
1195 pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
1196 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1197 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1198 data->disconn_array[cnt]);
1199 }
1200 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1201 pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
1202 for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
1203 pos += scnprintf(buf + pos, bufsz - pos, " %u",
1204 data->delta_gain_code[cnt]);
1205 }
1206 pos += scnprintf(buf + pos, bufsz - pos, "\n");
1207 pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
1208 data->radio_write);
1209 pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
1210 data->state);
1211
1212 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1213 kfree(buf);
1214 return ret;
1215}
1216
Wey-Yi Guy683abfb2010-04-26 17:20:07 -07001217static ssize_t iwl_dbgfs_chain_tx_power_read(struct file *file,
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001218 char __user *user_buf,
1219 size_t count, loff_t *ppos) {
1220
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001221 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001222 char buf[128];
1223 int pos = 0;
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001224 const size_t bufsz = sizeof(buf);
1225 struct statistics_tx *tx;
1226
1227 if (!iwl_is_alive(priv))
1228 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1229 else {
Wey-Yi Guyf204b242009-08-21 13:34:19 -07001230 tx = &priv->statistics.tx;
1231 if (tx->tx_power.ant_a ||
1232 tx->tx_power.ant_b ||
1233 tx->tx_power.ant_c) {
1234 pos += scnprintf(buf + pos, bufsz - pos,
1235 "tx power: (1/2 dB step)\n");
1236 if ((priv->cfg->valid_tx_ant & ANT_A) &&
1237 tx->tx_power.ant_a)
1238 pos += scnprintf(buf + pos, bufsz - pos,
1239 "\tantenna A: 0x%X\n",
1240 tx->tx_power.ant_a);
1241 if ((priv->cfg->valid_tx_ant & ANT_B) &&
1242 tx->tx_power.ant_b)
1243 pos += scnprintf(buf + pos, bufsz - pos,
1244 "\tantenna B: 0x%X\n",
1245 tx->tx_power.ant_b);
1246 if ((priv->cfg->valid_tx_ant & ANT_C) &&
1247 tx->tx_power.ant_c)
1248 pos += scnprintf(buf + pos, bufsz - pos,
1249 "\tantenna C: 0x%X\n",
1250 tx->tx_power.ant_c);
1251 } else
1252 pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
1253 }
1254 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1255}
1256
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001257static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
1258 char __user *user_buf,
1259 size_t count, loff_t *ppos)
1260{
H Hartley Sweeten28f63a42010-01-08 16:14:10 -07001261 struct iwl_priv *priv = file->private_data;
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001262 char buf[60];
1263 int pos = 0;
1264 const size_t bufsz = sizeof(buf);
1265 u32 pwrsave_status;
1266
1267 pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
1268 CSR_GP_REG_POWER_SAVE_STATUS_MSK;
1269
1270 pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
1271 pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
1272 (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
1273 (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
1274 (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
1275 "error");
1276
1277 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1278}
1279
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001280static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
Wey-Yi Guyef8d5522009-11-13 11:56:28 -08001281 const char __user *user_buf,
1282 size_t count, loff_t *ppos)
1283{
1284 struct iwl_priv *priv = file->private_data;
1285 char buf[8];
1286 int buf_size;
1287 int clear;
1288
1289 memset(buf, 0, sizeof(buf));
1290 buf_size = min(count, sizeof(buf) - 1);
1291 if (copy_from_user(buf, user_buf, buf_size))
1292 return -EFAULT;
1293 if (sscanf(buf, "%d", &clear) != 1)
1294 return -EFAULT;
1295
1296 /* make request to uCode to retrieve statistics information */
1297 mutex_lock(&priv->mutex);
1298 iwl_send_statistics_request(priv, CMD_SYNC, true);
1299 mutex_unlock(&priv->mutex);
1300
1301 return count;
1302}
1303
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08001304static ssize_t iwl_dbgfs_csr_write(struct file *file,
1305 const char __user *user_buf,
1306 size_t count, loff_t *ppos)
1307{
1308 struct iwl_priv *priv = file->private_data;
1309 char buf[8];
1310 int buf_size;
1311 int csr;
1312
1313 memset(buf, 0, sizeof(buf));
1314 buf_size = min(count, sizeof(buf) - 1);
1315 if (copy_from_user(buf, user_buf, buf_size))
1316 return -EFAULT;
1317 if (sscanf(buf, "%d", &csr) != 1)
1318 return -EFAULT;
1319
1320 if (priv->cfg->ops->lib->dump_csr)
1321 priv->cfg->ops->lib->dump_csr(priv);
1322
1323 return count;
1324}
1325
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001326static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
1327 char __user *user_buf,
1328 size_t count, loff_t *ppos) {
1329
1330 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1331 int pos = 0;
1332 char buf[128];
1333 const size_t bufsz = sizeof(buf);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001334
1335 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
1336 priv->event_log.ucode_trace ? "On" : "Off");
1337 pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
1338 priv->event_log.non_wraps_count);
1339 pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
1340 priv->event_log.wraps_once_count);
1341 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
1342 priv->event_log.wraps_more_count);
1343
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001344 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001345}
1346
1347static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
1348 const char __user *user_buf,
1349 size_t count, loff_t *ppos)
1350{
1351 struct iwl_priv *priv = file->private_data;
1352 char buf[8];
1353 int buf_size;
1354 int trace;
1355
1356 memset(buf, 0, sizeof(buf));
1357 buf_size = min(count, sizeof(buf) - 1);
1358 if (copy_from_user(buf, user_buf, buf_size))
1359 return -EFAULT;
1360 if (sscanf(buf, "%d", &trace) != 1)
1361 return -EFAULT;
1362
1363 if (trace) {
1364 priv->event_log.ucode_trace = true;
1365 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
1366 mod_timer(&priv->ucode_trace,
1367 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
1368 } else {
1369 priv->event_log.ucode_trace = false;
1370 del_timer_sync(&priv->ucode_trace);
1371 }
1372
1373 return count;
1374}
1375
Johannes Berg60987202010-02-18 00:36:07 -08001376static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1377 char __user *user_buf,
1378 size_t count, loff_t *ppos) {
1379
1380 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1381 int len = 0;
1382 char buf[20];
1383
1384 len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags));
1385 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1386}
1387
1388static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1389 char __user *user_buf,
1390 size_t count, loff_t *ppos) {
1391
1392 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1393 int len = 0;
1394 char buf[20];
1395
1396 len = sprintf(buf, "0x%04X\n",
1397 le32_to_cpu(priv->active_rxon.filter_flags));
1398 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1399}
1400
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08001401static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
1402 char __user *user_buf,
1403 size_t count, loff_t *ppos)
1404{
1405 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1406 char *buf;
1407 int pos = 0;
1408 ssize_t ret = -EFAULT;
1409
1410 if (priv->cfg->ops->lib->dump_fh) {
1411 ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true);
1412 if (buf) {
1413 ret = simple_read_from_buffer(user_buf,
1414 count, ppos, buf, pos);
1415 kfree(buf);
1416 }
1417 }
1418
1419 return ret;
1420}
1421
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001422static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
1423 char __user *user_buf,
1424 size_t count, loff_t *ppos) {
1425
1426 struct iwl_priv *priv = file->private_data;
1427 int pos = 0;
1428 char buf[12];
1429 const size_t bufsz = sizeof(buf);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001430
1431 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
1432 priv->missed_beacon_threshold);
1433
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001434 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001435}
1436
1437static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
1438 const char __user *user_buf,
1439 size_t count, loff_t *ppos)
1440{
1441 struct iwl_priv *priv = file->private_data;
1442 char buf[8];
1443 int buf_size;
1444 int missed;
1445
1446 memset(buf, 0, sizeof(buf));
1447 buf_size = min(count, sizeof(buf) - 1);
1448 if (copy_from_user(buf, user_buf, buf_size))
1449 return -EFAULT;
1450 if (sscanf(buf, "%d", &missed) != 1)
1451 return -EINVAL;
1452
1453 if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
1454 missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
1455 priv->missed_beacon_threshold =
1456 IWL_MISSED_BEACON_THRESHOLD_DEF;
1457 else
1458 priv->missed_beacon_threshold = missed;
1459
1460 return count;
1461}
1462
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001463static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
1464 char __user *user_buf,
1465 size_t count, loff_t *ppos) {
1466
1467 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1468 int pos = 0;
1469 char buf[12];
1470 const size_t bufsz = sizeof(buf);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001471
1472 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
1473 priv->cfg->plcp_delta_threshold);
1474
Wey-Yi Guy4967c312010-02-18 15:22:07 -08001475 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001476}
1477
1478static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
1479 const char __user *user_buf,
1480 size_t count, loff_t *ppos) {
1481
1482 struct iwl_priv *priv = file->private_data;
1483 char buf[8];
1484 int buf_size;
1485 int plcp;
1486
1487 memset(buf, 0, sizeof(buf));
1488 buf_size = min(count, sizeof(buf) - 1);
1489 if (copy_from_user(buf, user_buf, buf_size))
1490 return -EFAULT;
1491 if (sscanf(buf, "%d", &plcp) != 1)
1492 return -EINVAL;
1493 if ((plcp <= IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
1494 (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
1495 priv->cfg->plcp_delta_threshold =
1496 IWL_MAX_PLCP_ERR_THRESHOLD_DEF;
1497 else
1498 priv->cfg->plcp_delta_threshold = plcp;
1499 return count;
1500}
1501
Wey-Yi Guy528c3122010-02-18 22:03:07 -08001502static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
1503 char __user *user_buf,
1504 size_t count, loff_t *ppos) {
1505
1506 struct iwl_priv *priv = file->private_data;
1507 int i, pos = 0;
1508 char buf[300];
1509 const size_t bufsz = sizeof(buf);
1510 struct iwl_force_reset *force_reset;
1511
1512 for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
1513 force_reset = &priv->force_reset[i];
1514 pos += scnprintf(buf + pos, bufsz - pos,
1515 "Force reset method %d\n", i);
1516 pos += scnprintf(buf + pos, bufsz - pos,
1517 "\tnumber of reset request: %d\n",
1518 force_reset->reset_request_count);
1519 pos += scnprintf(buf + pos, bufsz - pos,
1520 "\tnumber of reset request success: %d\n",
1521 force_reset->reset_success_count);
1522 pos += scnprintf(buf + pos, bufsz - pos,
1523 "\tnumber of reset request reject: %d\n",
1524 force_reset->reset_reject_count);
1525 pos += scnprintf(buf + pos, bufsz - pos,
1526 "\treset duration: %lu\n",
1527 force_reset->reset_duration);
1528 }
1529 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1530}
1531
Wey-Yi Guy04cafd72010-02-03 11:47:20 -08001532static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
1533 const char __user *user_buf,
1534 size_t count, loff_t *ppos) {
1535
1536 struct iwl_priv *priv = file->private_data;
1537 char buf[8];
1538 int buf_size;
1539 int reset, ret;
1540
1541 memset(buf, 0, sizeof(buf));
1542 buf_size = min(count, sizeof(buf) - 1);
1543 if (copy_from_user(buf, user_buf, buf_size))
1544 return -EFAULT;
1545 if (sscanf(buf, "%d", &reset) != 1)
1546 return -EINVAL;
1547 switch (reset) {
1548 case IWL_RF_RESET:
1549 case IWL_FW_RESET:
1550 ret = iwl_force_reset(priv, reset);
1551 break;
1552 default:
1553 return -EINVAL;
1554 }
1555 return ret ? ret : count;
1556}
1557
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001558DEBUGFS_READ_FILE_OPS(rx_statistics);
1559DEBUGFS_READ_FILE_OPS(tx_statistics);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07001560DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
Wey-Yi Guy141b03e2009-08-07 15:41:41 -07001561DEBUGFS_READ_FILE_OPS(rx_queue);
1562DEBUGFS_READ_FILE_OPS(tx_queue);
Wey-Yi Guye8fe59a2009-08-07 15:41:42 -07001563DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
1564DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
1565DEBUGFS_READ_FILE_OPS(ucode_general_stats);
Wey-Yi Guy52259352009-08-07 15:41:43 -07001566DEBUGFS_READ_FILE_OPS(sensitivity);
1567DEBUGFS_READ_FILE_OPS(chain_noise);
Wey-Yi Guy683abfb2010-04-26 17:20:07 -07001568DEBUGFS_READ_FILE_OPS(chain_tx_power);
Wey-Yi Guyc09430a2009-10-16 14:25:50 -07001569DEBUGFS_READ_FILE_OPS(power_save_status);
Wey-Yi Guy7163b8a2009-11-20 12:04:56 -08001570DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
1571DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
Wey-Yi Guy696bdee2009-12-10 14:37:25 -08001572DEBUGFS_WRITE_FILE_OPS(csr);
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001573DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
Wey-Yi Guy1b3eb822010-01-15 13:43:39 -08001574DEBUGFS_READ_FILE_OPS(fh_reg);
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001575DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001576DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08001577DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
Johannes Berg60987202010-02-18 00:36:07 -08001578DEBUGFS_READ_FILE_OPS(rxon_flags);
1579DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07001580
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001581/*
1582 * Create the debugfs files and directories
1583 *
1584 */
1585int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1586{
Zhu Yi95b1a822008-05-29 16:34:50 +08001587 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001588 struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001589
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001590 dir_drv = debugfs_create_dir(name, phyd);
1591 if (!dir_drv)
1592 return -ENOMEM;
1593
1594 priv->debugfs_dir = dir_drv;
1595
1596 dir_data = debugfs_create_dir("data", dir_drv);
1597 if (!dir_data)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001598 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001599 dir_rf = debugfs_create_dir("rf", dir_drv);
1600 if (!dir_rf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001601 goto err;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001602 dir_debug = debugfs_create_dir("debug", dir_drv);
1603 if (!dir_debug)
1604 goto err;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001605
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001606 DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
1607 DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
1608 DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR);
1609 DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
1610 DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
1611 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
1612 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
1613 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
1614 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
Wey-Yi Guy381733c2010-04-25 09:39:46 -07001615 if (!priv->cfg->broken_powersave) {
1616 DEBUGFS_ADD_FILE(sleep_level_override, dir_data,
1617 S_IWUSR | S_IRUSR);
1618 DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
1619 }
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001620 DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
1621 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
1622 DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
1623 DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
1624 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
1625 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
1626 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
Wey-Yi Guy683abfb2010-04-26 17:20:07 -07001627 DEBUGFS_ADD_FILE(chain_tx_power, dir_debug, S_IRUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001628 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
1629 DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
1630 DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
1631 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
1632 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
1633 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001634 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
Wey-Yi Guy528c3122010-02-18 22:03:07 -08001635 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
Abhijeet Kolekarb8c76262010-04-08 15:29:07 -07001636 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
1637 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
1638 DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
1639
Wey-Yi Guy65d1f892010-04-25 15:41:43 -07001640 if (priv->cfg->sensitivity_calib_by_driver)
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001641 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
Wey-Yi Guy65d1f892010-04-25 15:41:43 -07001642 if (priv->cfg->chain_noise_calib_by_driver)
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001643 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
Wey-Yi Guy6e5c8002010-04-27 14:00:28 -07001644 if (priv->cfg->ucode_tracing)
1645 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
Johannes Berg60987202010-02-18 00:36:07 -08001646 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1647 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
Wey-Yi Guy65d1f892010-04-25 15:41:43 -07001648 if (priv->cfg->sensitivity_calib_by_driver)
1649 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
1650 &priv->disable_sens_cal);
1651 if (priv->cfg->chain_noise_calib_by_driver)
1652 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
1653 &priv->disable_chain_noise_cal);
Wey-Yi Guy4e7033e2010-04-27 14:33:33 -07001654 if (priv->cfg->tx_power_by_driver)
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