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