aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl1251/debugfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl1251/debugfs.c')
-rw-r--r--drivers/net/wireless/wl1251/debugfs.c541
1 files changed, 541 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl1251/debugfs.c b/drivers/net/wireless/wl1251/debugfs.c
new file mode 100644
index 000000000000..6e5caaa9f613
--- /dev/null
+++ b/drivers/net/wireless/wl1251/debugfs.c
@@ -0,0 +1,541 @@
1/*
2 * This file is part of wl1251
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 *
20 */
21
22#include "debugfs.h"
23
24#include <linux/skbuff.h>
25#include <linux/slab.h>
26
27#include "wl1251.h"
28#include "acx.h"
29#include "ps.h"
30
31/* ms */
32#define WL1251_DEBUGFS_STATS_LIFETIME 1000
33
34/* debugfs macros idea from mac80211 */
35
36#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
37static ssize_t name## _read(struct file *file, char __user *userbuf, \
38 size_t count, loff_t *ppos) \
39{ \
40 struct wl1251 *wl = file->private_data; \
41 char buf[buflen]; \
42 int res; \
43 \
44 res = scnprintf(buf, buflen, fmt "\n", ##value); \
45 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
46} \
47 \
48static const struct file_operations name## _ops = { \
49 .read = name## _read, \
50 .open = wl1251_open_file_generic, \
51};
52
53#define DEBUGFS_ADD(name, parent) \
54 wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
55 wl, &name## _ops); \
56 if (IS_ERR(wl->debugfs.name)) { \
57 ret = PTR_ERR(wl->debugfs.name); \
58 wl->debugfs.name = NULL; \
59 goto out; \
60 }
61
62#define DEBUGFS_DEL(name) \
63 do { \
64 debugfs_remove(wl->debugfs.name); \
65 wl->debugfs.name = NULL; \
66 } while (0)
67
68#define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \
69static ssize_t sub## _ ##name## _read(struct file *file, \
70 char __user *userbuf, \
71 size_t count, loff_t *ppos) \
72{ \
73 struct wl1251 *wl = file->private_data; \
74 char buf[buflen]; \
75 int res; \
76 \
77 wl1251_debugfs_update_stats(wl); \
78 \
79 res = scnprintf(buf, buflen, fmt "\n", \
80 wl->stats.fw_stats->sub.name); \
81 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
82} \
83 \
84static const struct file_operations sub## _ ##name## _ops = { \
85 .read = sub## _ ##name## _read, \
86 .open = wl1251_open_file_generic, \
87};
88
89#define DEBUGFS_FWSTATS_ADD(sub, name) \
90 DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)
91
92#define DEBUGFS_FWSTATS_DEL(sub, name) \
93 DEBUGFS_DEL(sub## _ ##name)
94
95static void wl1251_debugfs_update_stats(struct wl1251 *wl)
96{
97 int ret;
98
99 mutex_lock(&wl->mutex);
100
101 ret = wl1251_ps_elp_wakeup(wl);
102 if (ret < 0)
103 goto out;
104
105 if (wl->state == WL1251_STATE_ON &&
106 time_after(jiffies, wl->stats.fw_stats_update +
107 msecs_to_jiffies(WL1251_DEBUGFS_STATS_LIFETIME))) {
108 wl1251_acx_statistics(wl, wl->stats.fw_stats);
109 wl->stats.fw_stats_update = jiffies;
110 }
111
112 wl1251_ps_elp_sleep(wl);
113
114out:
115 mutex_unlock(&wl->mutex);
116}
117
118static int wl1251_open_file_generic(struct inode *inode, struct file *file)
119{
120 file->private_data = inode->i_private;
121 return 0;
122}
123
124DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");
125
126DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
127DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u");
128DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u");
129DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u");
130DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u");
131DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u");
132DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u");
133DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u");
134
135DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u");
136DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u");
137DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u");
138DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u");
139
140DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u");
141DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u");
142DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u");
143DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u");
144DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u");
145DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u");
146DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u");
147DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u");
148DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u");
149DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u");
150DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u");
151DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u");
152DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u");
153DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u");
154DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u");
155DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u");
156DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u");
157DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u");
158
159DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u");
160DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u");
161/* skipping wep.reserved */
162DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u");
163DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u");
164DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u");
165DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u");
166
167DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u");
168DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u");
169DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u");
170DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u");
171DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u");
172DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u");
173DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u");
174DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u");
175DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u");
176DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u");
177DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u");
178DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u");
179/* skipping cont_miss_bcns_spread for now */
180DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u");
181
182DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u");
183DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u");
184
185DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u");
186DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u");
187DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u");
188DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u");
189DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u");
190DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u");
191
192DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u");
193DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u");
194DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u");
195DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u");
196DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u");
197DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u");
198DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u");
199DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u");
200
201DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u");
202DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u");
203DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u");
204DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u");
205DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u");
206DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u");
207DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u");
208
209DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u");
210DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u");
211DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
212 20, "%u");
213DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u");
214DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u");
215
216DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
217DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
218 wl->stats.excessive_retries);
219
220static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
221 size_t count, loff_t *ppos)
222{
223 struct wl1251 *wl = file->private_data;
224 u32 queue_len;
225 char buf[20];
226 int res;
227
228 queue_len = skb_queue_len(&wl->tx_queue);
229
230 res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
231 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
232}
233
234static const struct file_operations tx_queue_len_ops = {
235 .read = tx_queue_len_read,
236 .open = wl1251_open_file_generic,
237};
238
239static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
240 size_t count, loff_t *ppos)
241{
242 struct wl1251 *wl = file->private_data;
243 char buf[3], status;
244 int len;
245
246 if (wl->tx_queue_stopped)
247 status = 's';
248 else
249 status = 'r';
250
251 len = scnprintf(buf, sizeof(buf), "%c\n", status);
252 return simple_read_from_buffer(userbuf, count, ppos, buf, len);
253}
254
255static const struct file_operations tx_queue_status_ops = {
256 .read = tx_queue_status_read,
257 .open = wl1251_open_file_generic,
258};
259
260static void wl1251_debugfs_delete_files(struct wl1251 *wl)
261{
262 DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
263
264 DEBUGFS_FWSTATS_DEL(rx, out_of_mem);
265 DEBUGFS_FWSTATS_DEL(rx, hdr_overflow);
266 DEBUGFS_FWSTATS_DEL(rx, hw_stuck);
267 DEBUGFS_FWSTATS_DEL(rx, dropped);
268 DEBUGFS_FWSTATS_DEL(rx, fcs_err);
269 DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig);
270 DEBUGFS_FWSTATS_DEL(rx, path_reset);
271 DEBUGFS_FWSTATS_DEL(rx, reset_counter);
272
273 DEBUGFS_FWSTATS_DEL(dma, rx_requested);
274 DEBUGFS_FWSTATS_DEL(dma, rx_errors);
275 DEBUGFS_FWSTATS_DEL(dma, tx_requested);
276 DEBUGFS_FWSTATS_DEL(dma, tx_errors);
277
278 DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt);
279 DEBUGFS_FWSTATS_DEL(isr, fiqs);
280 DEBUGFS_FWSTATS_DEL(isr, rx_headers);
281 DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow);
282 DEBUGFS_FWSTATS_DEL(isr, rx_rdys);
283 DEBUGFS_FWSTATS_DEL(isr, irqs);
284 DEBUGFS_FWSTATS_DEL(isr, tx_procs);
285 DEBUGFS_FWSTATS_DEL(isr, decrypt_done);
286 DEBUGFS_FWSTATS_DEL(isr, dma0_done);
287 DEBUGFS_FWSTATS_DEL(isr, dma1_done);
288 DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete);
289 DEBUGFS_FWSTATS_DEL(isr, commands);
290 DEBUGFS_FWSTATS_DEL(isr, rx_procs);
291 DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes);
292 DEBUGFS_FWSTATS_DEL(isr, host_acknowledges);
293 DEBUGFS_FWSTATS_DEL(isr, pci_pm);
294 DEBUGFS_FWSTATS_DEL(isr, wakeups);
295 DEBUGFS_FWSTATS_DEL(isr, low_rssi);
296
297 DEBUGFS_FWSTATS_DEL(wep, addr_key_count);
298 DEBUGFS_FWSTATS_DEL(wep, default_key_count);
299 /* skipping wep.reserved */
300 DEBUGFS_FWSTATS_DEL(wep, key_not_found);
301 DEBUGFS_FWSTATS_DEL(wep, decrypt_fail);
302 DEBUGFS_FWSTATS_DEL(wep, packets);
303 DEBUGFS_FWSTATS_DEL(wep, interrupt);
304
305 DEBUGFS_FWSTATS_DEL(pwr, ps_enter);
306 DEBUGFS_FWSTATS_DEL(pwr, elp_enter);
307 DEBUGFS_FWSTATS_DEL(pwr, missing_bcns);
308 DEBUGFS_FWSTATS_DEL(pwr, wake_on_host);
309 DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp);
310 DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps);
311 DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps);
312 DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons);
313 DEBUGFS_FWSTATS_DEL(pwr, power_save_off);
314 DEBUGFS_FWSTATS_DEL(pwr, enable_ps);
315 DEBUGFS_FWSTATS_DEL(pwr, disable_ps);
316 DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps);
317 /* skipping cont_miss_bcns_spread for now */
318 DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons);
319
320 DEBUGFS_FWSTATS_DEL(mic, rx_pkts);
321 DEBUGFS_FWSTATS_DEL(mic, calc_failure);
322
323 DEBUGFS_FWSTATS_DEL(aes, encrypt_fail);
324 DEBUGFS_FWSTATS_DEL(aes, decrypt_fail);
325 DEBUGFS_FWSTATS_DEL(aes, encrypt_packets);
326 DEBUGFS_FWSTATS_DEL(aes, decrypt_packets);
327 DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt);
328 DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt);
329
330 DEBUGFS_FWSTATS_DEL(event, heart_beat);
331 DEBUGFS_FWSTATS_DEL(event, calibration);
332 DEBUGFS_FWSTATS_DEL(event, rx_mismatch);
333 DEBUGFS_FWSTATS_DEL(event, rx_mem_empty);
334 DEBUGFS_FWSTATS_DEL(event, rx_pool);
335 DEBUGFS_FWSTATS_DEL(event, oom_late);
336 DEBUGFS_FWSTATS_DEL(event, phy_transmit_error);
337 DEBUGFS_FWSTATS_DEL(event, tx_stuck);
338
339 DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts);
340 DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts);
341 DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime);
342 DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn);
343 DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn);
344 DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization);
345 DEBUGFS_FWSTATS_DEL(ps, upsd_utilization);
346
347 DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop);
348 DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data);
349 DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
350 DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data);
351 DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data);
352
353 DEBUGFS_DEL(tx_queue_len);
354 DEBUGFS_DEL(tx_queue_status);
355 DEBUGFS_DEL(retry_count);
356 DEBUGFS_DEL(excessive_retries);
357}
358
359static int wl1251_debugfs_add_files(struct wl1251 *wl)
360{
361 int ret = 0;
362
363 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
364
365 DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
366 DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
367 DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
368 DEBUGFS_FWSTATS_ADD(rx, dropped);
369 DEBUGFS_FWSTATS_ADD(rx, fcs_err);
370 DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
371 DEBUGFS_FWSTATS_ADD(rx, path_reset);
372 DEBUGFS_FWSTATS_ADD(rx, reset_counter);
373
374 DEBUGFS_FWSTATS_ADD(dma, rx_requested);
375 DEBUGFS_FWSTATS_ADD(dma, rx_errors);
376 DEBUGFS_FWSTATS_ADD(dma, tx_requested);
377 DEBUGFS_FWSTATS_ADD(dma, tx_errors);
378
379 DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
380 DEBUGFS_FWSTATS_ADD(isr, fiqs);
381 DEBUGFS_FWSTATS_ADD(isr, rx_headers);
382 DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
383 DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
384 DEBUGFS_FWSTATS_ADD(isr, irqs);
385 DEBUGFS_FWSTATS_ADD(isr, tx_procs);
386 DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
387 DEBUGFS_FWSTATS_ADD(isr, dma0_done);
388 DEBUGFS_FWSTATS_ADD(isr, dma1_done);
389 DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
390 DEBUGFS_FWSTATS_ADD(isr, commands);
391 DEBUGFS_FWSTATS_ADD(isr, rx_procs);
392 DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
393 DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
394 DEBUGFS_FWSTATS_ADD(isr, pci_pm);
395 DEBUGFS_FWSTATS_ADD(isr, wakeups);
396 DEBUGFS_FWSTATS_ADD(isr, low_rssi);
397
398 DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
399 DEBUGFS_FWSTATS_ADD(wep, default_key_count);
400 /* skipping wep.reserved */
401 DEBUGFS_FWSTATS_ADD(wep, key_not_found);
402 DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
403 DEBUGFS_FWSTATS_ADD(wep, packets);
404 DEBUGFS_FWSTATS_ADD(wep, interrupt);
405
406 DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
407 DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
408 DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
409 DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
410 DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
411 DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
412 DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
413 DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
414 DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
415 DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
416 DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
417 DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
418 /* skipping cont_miss_bcns_spread for now */
419 DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
420
421 DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
422 DEBUGFS_FWSTATS_ADD(mic, calc_failure);
423
424 DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
425 DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
426 DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
427 DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
428 DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
429 DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
430
431 DEBUGFS_FWSTATS_ADD(event, heart_beat);
432 DEBUGFS_FWSTATS_ADD(event, calibration);
433 DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
434 DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
435 DEBUGFS_FWSTATS_ADD(event, rx_pool);
436 DEBUGFS_FWSTATS_ADD(event, oom_late);
437 DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
438 DEBUGFS_FWSTATS_ADD(event, tx_stuck);
439
440 DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
441 DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
442 DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
443 DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
444 DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
445 DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
446 DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
447
448 DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
449 DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
450 DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
451 DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
452 DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
453
454 DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir);
455 DEBUGFS_ADD(tx_queue_status, wl->debugfs.rootdir);
456 DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
457 DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
458
459out:
460 if (ret < 0)
461 wl1251_debugfs_delete_files(wl);
462
463 return ret;
464}
465
466void wl1251_debugfs_reset(struct wl1251 *wl)
467{
468 if (wl->stats.fw_stats != NULL)
469 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
470 wl->stats.retry_count = 0;
471 wl->stats.excessive_retries = 0;
472}
473
474int wl1251_debugfs_init(struct wl1251 *wl)
475{
476 int ret;
477
478 wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
479
480 if (IS_ERR(wl->debugfs.rootdir)) {
481 ret = PTR_ERR(wl->debugfs.rootdir);
482 wl->debugfs.rootdir = NULL;
483 goto err;
484 }
485
486 wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics",
487 wl->debugfs.rootdir);
488
489 if (IS_ERR(wl->debugfs.fw_statistics)) {
490 ret = PTR_ERR(wl->debugfs.fw_statistics);
491 wl->debugfs.fw_statistics = NULL;
492 goto err_root;
493 }
494
495 wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
496 GFP_KERNEL);
497
498 if (!wl->stats.fw_stats) {
499 ret = -ENOMEM;
500 goto err_fw;
501 }
502
503 wl->stats.fw_stats_update = jiffies;
504
505 ret = wl1251_debugfs_add_files(wl);
506
507 if (ret < 0)
508 goto err_file;
509
510 return 0;
511
512err_file:
513 kfree(wl->stats.fw_stats);
514 wl->stats.fw_stats = NULL;
515
516err_fw:
517 debugfs_remove(wl->debugfs.fw_statistics);
518 wl->debugfs.fw_statistics = NULL;
519
520err_root:
521 debugfs_remove(wl->debugfs.rootdir);
522 wl->debugfs.rootdir = NULL;
523
524err:
525 return ret;
526}
527
528void wl1251_debugfs_exit(struct wl1251 *wl)
529{
530 wl1251_debugfs_delete_files(wl);
531
532 kfree(wl->stats.fw_stats);
533 wl->stats.fw_stats = NULL;
534
535 debugfs_remove(wl->debugfs.fw_statistics);
536 wl->debugfs.fw_statistics = NULL;
537
538 debugfs_remove(wl->debugfs.rootdir);
539 wl->debugfs.rootdir = NULL;
540
541}