blob: 1e142fbac6161aa4bacd448b62a0404c32a574c9 [file] [log] [blame]
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
Winkler, Tomas759ef892008-12-09 11:28:58 -080025 * Intel Linux Wireless <ilw@linux.intel.com>
Tomas Winkler712b6cf2008-03-12 16:58:52 -070026 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/debugfs.h>
32
33#include <linux/ieee80211.h>
34#include <net/mac80211.h>
35
36
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070037#include "iwl-dev.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070038#include "iwl-debug.h"
Tomas Winklerfee12472008-04-03 16:05:21 -070039#include "iwl-core.h"
Tomas Winkler3395f6e2008-03-25 16:33:37 -070040#include "iwl-io.h"
Tomas Winkler712b6cf2008-03-12 16:58:52 -070041
42
43/* create and remove of files */
44#define DEBUGFS_ADD_DIR(name, parent) do { \
45 dbgfs->dir_##name = debugfs_create_dir(#name, parent); \
46 if (!(dbgfs->dir_##name)) \
47 goto err; \
48} while (0)
49
50#define DEBUGFS_ADD_FILE(name, parent) do { \
51 dbgfs->dbgfs_##parent##_files.file_##name = \
52 debugfs_create_file(#name, 0644, dbgfs->dir_##parent, priv, \
53 &iwl_dbgfs_##name##_ops); \
54 if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \
55 goto err; \
56} while (0)
57
Tomas Winkler445c2df2008-05-15 13:54:16 +080058#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
59 dbgfs->dbgfs_##parent##_files.file_##name = \
60 debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \
Zhaolei9b240012008-10-22 17:06:12 +080061 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
62 || !dbgfs->dbgfs_##parent##_files.file_##name) \
Tomas Winkler445c2df2008-05-15 13:54:16 +080063 goto err; \
64} while (0)
65
Winkler, Tomas2ddfa122008-12-22 11:31:20 +080066#define DEBUGFS_ADD_X32(name, parent, ptr) do { \
67 dbgfs->dbgfs_##parent##_files.file_##name = \
68 debugfs_create_x32(#name, 0444, dbgfs->dir_##parent, ptr); \
69 if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
70 || !dbgfs->dbgfs_##parent##_files.file_##name) \
71 goto err; \
72} while (0)
73
Tomas Winkler712b6cf2008-03-12 16:58:52 -070074#define DEBUGFS_REMOVE(name) do { \
75 debugfs_remove(name); \
76 name = NULL; \
77} while (0);
78
79/* file operation */
80#define DEBUGFS_READ_FUNC(name) \
81static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
82 char __user *user_buf, \
83 size_t count, loff_t *ppos);
84
85#define DEBUGFS_WRITE_FUNC(name) \
86static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
87 const char __user *user_buf, \
88 size_t count, loff_t *ppos);
89
90
91static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
92{
93 file->private_data = inode->i_private;
94 return 0;
95}
96
97#define DEBUGFS_READ_FILE_OPS(name) \
98 DEBUGFS_READ_FUNC(name); \
99static const struct file_operations iwl_dbgfs_##name##_ops = { \
100 .read = iwl_dbgfs_##name##_read, \
101 .open = iwl_dbgfs_open_file_generic, \
102};
103
Ester Kummer189a2b52008-05-15 13:54:18 +0800104#define DEBUGFS_WRITE_FILE_OPS(name) \
105 DEBUGFS_WRITE_FUNC(name); \
106static const struct file_operations iwl_dbgfs_##name##_ops = { \
107 .write = iwl_dbgfs_##name##_write, \
108 .open = iwl_dbgfs_open_file_generic, \
109};
110
111
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700112#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
113 DEBUGFS_READ_FUNC(name); \
114 DEBUGFS_WRITE_FUNC(name); \
115static const struct file_operations iwl_dbgfs_##name##_ops = { \
116 .write = iwl_dbgfs_##name##_write, \
117 .read = iwl_dbgfs_##name##_read, \
118 .open = iwl_dbgfs_open_file_generic, \
119};
120
121
122static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
123 char __user *user_buf,
124 size_t count, loff_t *ppos) {
125
126 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
127 char buf[256];
128 int pos = 0;
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700129 const size_t bufsz = sizeof(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700130
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700131 pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n",
132 priv->tx_stats[0].cnt);
133 pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n",
134 priv->tx_stats[1].cnt);
135 pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n",
136 priv->tx_stats[2].cnt);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700137
138 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
139}
140
141static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
142 char __user *user_buf,
143 size_t count, loff_t *ppos) {
144
145 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
146 char buf[256];
147 int pos = 0;
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700148 const size_t bufsz = sizeof(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700149
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700150 pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n",
151 priv->rx_stats[0].cnt);
152 pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n",
153 priv->rx_stats[1].cnt);
154 pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n",
155 priv->rx_stats[2].cnt);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700156
157 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
158}
159
160#define BYTE1_MASK 0x000000ff;
161#define BYTE2_MASK 0x0000ffff;
162#define BYTE3_MASK 0x00ffffff;
163static ssize_t iwl_dbgfs_sram_read(struct file *file,
164 char __user *user_buf,
165 size_t count, loff_t *ppos)
166{
167 u32 val;
168 char buf[1024];
169 ssize_t ret;
170 int i;
171 int pos = 0;
172 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700173 const size_t bufsz = sizeof(buf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700174
175 printk(KERN_DEBUG "offset is: 0x%x\tlen is: 0x%x\n",
176 priv->dbgfs->sram_offset, priv->dbgfs->sram_len);
177
Tomas Winkler3395f6e2008-03-25 16:33:37 -0700178 iwl_grab_nic_access(priv);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700179 for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
Tomas Winkler3395f6e2008-03-25 16:33:37 -0700180 val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700181 priv->dbgfs->sram_len - i);
182 if (i < 4) {
183 switch (i) {
184 case 1:
185 val &= BYTE1_MASK;
186 break;
187 case 2:
188 val &= BYTE2_MASK;
189 break;
190 case 3:
191 val &= BYTE3_MASK;
192 break;
193 }
194 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700195 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700196 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700197 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler3395f6e2008-03-25 16:33:37 -0700198 iwl_release_nic_access(priv);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700199
200 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
201 return ret;
202}
203
204static ssize_t iwl_dbgfs_sram_write(struct file *file,
205 const char __user *user_buf,
206 size_t count, loff_t *ppos)
207{
208 struct iwl_priv *priv = file->private_data;
209 char buf[64];
210 int buf_size;
211 u32 offset, len;
212
213 memset(buf, 0, sizeof(buf));
214 buf_size = min(count, sizeof(buf) - 1);
215 if (copy_from_user(buf, user_buf, buf_size))
216 return -EFAULT;
217
218 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
219 priv->dbgfs->sram_offset = offset;
220 priv->dbgfs->sram_len = len;
221 } else {
222 priv->dbgfs->sram_offset = 0;
223 priv->dbgfs->sram_len = 0;
224 }
225
226 return count;
227}
228
229static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
230 size_t count, loff_t *ppos)
231{
232 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
Tomas Winkler6def9762008-05-05 10:22:31 +0800233 struct iwl_station_entry *station;
Tomas Winkler5425e492008-04-15 16:01:38 -0700234 int max_sta = priv->hw_params.max_stations;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700235 char *buf;
236 int i, j, pos = 0;
237 ssize_t ret;
238 /* Add 30 for initial string */
239 const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700240
241 buf = kmalloc(bufsz, GFP_KERNEL);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300242 if (!buf)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700243 return -ENOMEM;
244
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700245 pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700246 priv->num_stations);
247
248 for (i = 0; i < max_sta; i++) {
249 station = &priv->stations[i];
250 if (station->used) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700251 pos += scnprintf(buf + pos, bufsz - pos,
252 "station %d:\ngeneral data:\n", i+1);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700253 pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700254 station->sta.sta.sta_id);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700255 pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700256 station->sta.mode);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700257 pos += scnprintf(buf + pos, bufsz - pos,
258 "flags: 0x%x\n",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700259 station->sta.station_flags_msk);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700260 pos += scnprintf(buf + pos, bufsz - pos,
261 "ps_status: %u\n", station->ps_status);
262 pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
263 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700264 "seq_num\t\ttxq_id");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700265 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700266 "\tframe_count\twait_for_ba\t");
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700267 pos += scnprintf(buf + pos, bufsz - pos,
268 "start_idx\tbitmap0\t");
269 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700270 "bitmap1\trate_n_flags");
David S. Miller344234d2008-04-19 18:09:39 -0700271 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700272
273 for (j = 0; j < MAX_TID_COUNT; j++) {
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700274 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700275 "[%d]:\t\t%u", j,
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700276 station->tid[j].seq_number);
277 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700278 "\t%u\t\t%u\t\t%u\t\t",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700279 station->tid[j].agg.txq_id,
280 station->tid[j].agg.frame_count,
281 station->tid[j].agg.wait_for_ba);
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700282 pos += scnprintf(buf + pos, bufsz - pos,
David S. Miller344234d2008-04-19 18:09:39 -0700283 "%u\t%llu\t%u",
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700284 station->tid[j].agg.start_idx,
John W. Linville16788592008-04-01 20:59:32 -0400285 (unsigned long long)station->tid[j].agg.bitmap,
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700286 station->tid[j].agg.rate_n_flags);
David S. Miller344234d2008-04-19 18:09:39 -0700287 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700288 }
Abhijeet Kolekardb0589f2008-04-14 21:16:04 -0700289 pos += scnprintf(buf + pos, bufsz - pos, "\n");
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700290 }
291 }
292
293 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
294 kfree(buf);
295 return ret;
296}
297
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800298static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
299 char __user *user_buf,
300 size_t count,
301 loff_t *ppos)
302{
303 ssize_t ret;
304 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
305 int pos = 0, ofs = 0, buf_size = 0;
306 const u8 *ptr;
307 char *buf;
308 size_t eeprom_len = priv->cfg->eeprom_size;
309 buf_size = 4 * eeprom_len + 256;
310
311 if (eeprom_len % 16) {
312 IWL_ERROR("EEPROM size is not multiple of 16.\n");
313 return -ENODATA;
314 }
315
316 /* 4 characters for byte 0xYY */
317 buf = kzalloc(buf_size, GFP_KERNEL);
318 if (!buf) {
319 IWL_ERROR("Can not allocate Buffer\n");
320 return -ENOMEM;
321 }
322
323 ptr = priv->eeprom;
324 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
325 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
326 hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
327 buf_size - pos, 0);
328 pos += strlen(buf);
329 if (buf_size - pos > 0)
330 buf[pos++] = '\n';
331 }
332
333 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
334 kfree(buf);
335 return ret;
336}
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700337
Ester Kummer189a2b52008-05-15 13:54:18 +0800338static ssize_t iwl_dbgfs_log_event_write(struct file *file,
339 const char __user *user_buf,
340 size_t count, loff_t *ppos)
341{
342 struct iwl_priv *priv = file->private_data;
343 u32 event_log_flag;
344 char buf[8];
345 int buf_size;
346
347 memset(buf, 0, sizeof(buf));
348 buf_size = min(count, sizeof(buf) - 1);
349 if (copy_from_user(buf, user_buf, buf_size))
350 return -EFAULT;
351 if (sscanf(buf, "%d", &event_log_flag) != 1)
352 return -EFAULT;
353 if (event_log_flag == 1)
354 iwl_dump_nic_event_log(priv);
355
356 return count;
357}
358
Winkler, Tomasd366df52008-12-02 12:14:01 -0800359
360
361static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
362 size_t count, loff_t *ppos)
363{
364 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
365 struct ieee80211_channel *channels = NULL;
366 const struct ieee80211_supported_band *supp_band = NULL;
367 int pos = 0, i, bufsz = PAGE_SIZE;
368 char *buf;
369 ssize_t ret;
370
371 if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
372 return -EAGAIN;
373
374 buf = kzalloc(bufsz, GFP_KERNEL);
375 if (!buf) {
376 IWL_ERROR("Can not allocate Buffer\n");
377 return -ENOMEM;
378 }
379
380 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
381 channels = supp_band->channels;
382
383 pos += scnprintf(buf + pos, bufsz - pos,
384 "Displaying %d channels in 2.4GHz band 802.11bg):\n",
385 supp_band->n_channels);
386
387 for (i = 0; i < supp_band->n_channels; i++)
388 pos += scnprintf(buf + pos, bufsz - pos,
389 "%d: %ddBm: BSS%s%s, %s.\n",
390 ieee80211_frequency_to_channel(
391 channels[i].center_freq),
392 channels[i].max_power,
393 channels[i].flags & IEEE80211_CHAN_RADAR ?
394 " (IEEE 802.11h required)" : "",
395 (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
396 || (channels[i].flags &
397 IEEE80211_CHAN_RADAR)) ? "" :
398 ", IBSS",
399 channels[i].flags &
400 IEEE80211_CHAN_PASSIVE_SCAN ?
401 "passive only" : "active/passive");
402
403 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
404 channels = supp_band->channels;
405
406 pos += scnprintf(buf + pos, bufsz - pos,
407 "Displaying %d channels in 5.2GHz band (802.11a)\n",
408 supp_band->n_channels);
409
410 for (i = 0; i < supp_band->n_channels; i++)
411 pos += scnprintf(buf + pos, bufsz - pos,
412 "%d: %ddBm: BSS%s%s, %s.\n",
413 ieee80211_frequency_to_channel(
414 channels[i].center_freq),
415 channels[i].max_power,
416 channels[i].flags & IEEE80211_CHAN_RADAR ?
417 " (IEEE 802.11h required)" : "",
418 ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
419 || (channels[i].flags &
420 IEEE80211_CHAN_RADAR)) ? "" :
421 ", IBSS",
422 channels[i].flags &
423 IEEE80211_CHAN_PASSIVE_SCAN ?
424 "passive only" : "active/passive");
425
426 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
427 kfree(buf);
428 return ret;
429}
430
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700431DEBUGFS_READ_WRITE_FILE_OPS(sram);
Ester Kummer189a2b52008-05-15 13:54:18 +0800432DEBUGFS_WRITE_FILE_OPS(log_event);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800433DEBUGFS_READ_FILE_OPS(eeprom);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700434DEBUGFS_READ_FILE_OPS(stations);
435DEBUGFS_READ_FILE_OPS(rx_statistics);
436DEBUGFS_READ_FILE_OPS(tx_statistics);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800437DEBUGFS_READ_FILE_OPS(channels);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700438
439/*
440 * Create the debugfs files and directories
441 *
442 */
443int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
444{
445 struct iwl_debugfs *dbgfs;
Zhu Yi95b1a822008-05-29 16:34:50 +0800446 struct dentry *phyd = priv->hw->wiphy->debugfsdir;
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300447 int ret = 0;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700448
449 dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL);
450 if (!dbgfs) {
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300451 ret = -ENOMEM;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700452 goto err;
453 }
454
455 priv->dbgfs = dbgfs;
456 dbgfs->name = name;
Zhu Yi95b1a822008-05-29 16:34:50 +0800457 dbgfs->dir_drv = debugfs_create_dir(name, phyd);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300458 if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) {
459 ret = -ENOENT;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700460 goto err;
461 }
462
463 DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
Tomas Winkler445c2df2008-05-15 13:54:16 +0800464 DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv);
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800465 DEBUGFS_ADD_FILE(eeprom, data);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700466 DEBUGFS_ADD_FILE(sram, data);
Ester Kummer189a2b52008-05-15 13:54:18 +0800467 DEBUGFS_ADD_FILE(log_event, data);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700468 DEBUGFS_ADD_FILE(stations, data);
469 DEBUGFS_ADD_FILE(rx_statistics, data);
470 DEBUGFS_ADD_FILE(tx_statistics, data);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800471 DEBUGFS_ADD_FILE(channels, data);
Winkler, Tomas2ddfa122008-12-22 11:31:20 +0800472 DEBUGFS_ADD_X32(status, data, (u32 *)&priv->status);
Tomas Winkler445c2df2008-05-15 13:54:16 +0800473 DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
474 DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
475 &priv->disable_chain_noise_cal);
Emmanuel Grumbach203566f2008-06-12 09:46:54 +0800476 DEBUGFS_ADD_BOOL(disable_tx_power, rf, &priv->disable_tx_power_cal);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700477 return 0;
478
479err:
480 IWL_ERROR("Can't open the debugfs directory\n");
481 iwl_dbgfs_unregister(priv);
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300482 return ret;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700483}
484EXPORT_SYMBOL(iwl_dbgfs_register);
485
486/**
487 * Remove the debugfs files and directories
488 *
489 */
490void iwl_dbgfs_unregister(struct iwl_priv *priv)
491{
Tomas Winkler3ac7f142008-07-21 02:40:14 +0300492 if (!priv->dbgfs)
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700493 return;
494
Tomas Winkler8dd266e2008-05-05 10:22:32 +0800495 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_eeprom);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700496 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics);
497 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics);
498 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
Ester Kummer189a2b52008-05-15 13:54:18 +0800499 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700500 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
Winkler, Tomasd366df52008-12-02 12:14:01 -0800501 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700502 DEBUGFS_REMOVE(priv->dbgfs->dir_data);
Tomas Winkler445c2df2008-05-15 13:54:16 +0800503 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
504 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
Emmanuel Grumbach203566f2008-06-12 09:46:54 +0800505 DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power);
Tomas Winkler445c2df2008-05-15 13:54:16 +0800506 DEBUGFS_REMOVE(priv->dbgfs->dir_rf);
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700507 DEBUGFS_REMOVE(priv->dbgfs->dir_drv);
508 kfree(priv->dbgfs);
509 priv->dbgfs = NULL;
510}
511EXPORT_SYMBOL(iwl_dbgfs_unregister);
512
513
Tomas Winkler445c2df2008-05-15 13:54:16 +0800514