blob: 866303dd6877318c0125e3f7771c69a16677cea9 [file] [log] [blame]
Kalle Valo2f01a1f2009-04-29 23:33:31 +03001/*
2 * This file is part of wl12xx
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
Kalle Valoef2f8d42009-06-12 14:17:19 +030024#include "wl1251_debugfs.h"
Kalle Valo2f01a1f2009-04-29 23:33:31 +030025
26#include <linux/skbuff.h>
27
Kalle Valo13674112009-06-12 14:17:25 +030028#include "wl1251.h"
Kalle Valoef2f8d42009-06-12 14:17:19 +030029#include "wl1251_acx.h"
30#include "wl1251_ps.h"
Kalle Valo2f01a1f2009-04-29 23:33:31 +030031
32/* ms */
33#define WL12XX_DEBUGFS_STATS_LIFETIME 1000
34
35/* debugfs macros idea from mac80211 */
36
37#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
38static ssize_t name## _read(struct file *file, char __user *userbuf, \
39 size_t count, loff_t *ppos) \
40{ \
41 struct wl12xx *wl = file->private_data; \
42 char buf[buflen]; \
43 int res; \
44 \
45 res = scnprintf(buf, buflen, fmt "\n", ##value); \
46 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
47} \
48 \
49static const struct file_operations name## _ops = { \
50 .read = name## _read, \
51 .open = wl12xx_open_file_generic, \
52};
53
54#define DEBUGFS_ADD(name, parent) \
55 wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
56 wl, &name## _ops); \
57 if (IS_ERR(wl->debugfs.name)) { \
58 ret = PTR_ERR(wl->debugfs.name); \
59 wl->debugfs.name = NULL; \
60 goto out; \
61 }
62
63#define DEBUGFS_DEL(name) \
64 do { \
65 debugfs_remove(wl->debugfs.name); \
66 wl->debugfs.name = NULL; \
67 } while (0)
68
69#define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \
70static ssize_t sub## _ ##name## _read(struct file *file, \
71 char __user *userbuf, \
72 size_t count, loff_t *ppos) \
73{ \
74 struct wl12xx *wl = file->private_data; \
75 char buf[buflen]; \
76 int res; \
77 \
78 wl12xx_debugfs_update_stats(wl); \
79 \
80 res = scnprintf(buf, buflen, fmt "\n", \
81 wl->stats.fw_stats->sub.name); \
82 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
83} \
84 \
85static const struct file_operations sub## _ ##name## _ops = { \
86 .read = sub## _ ##name## _read, \
87 .open = wl12xx_open_file_generic, \
88};
89
90#define DEBUGFS_FWSTATS_ADD(sub, name) \
91 DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)
92
93#define DEBUGFS_FWSTATS_DEL(sub, name) \
94 DEBUGFS_DEL(sub## _ ##name)
95
96static void wl12xx_debugfs_update_stats(struct wl12xx *wl)
97{
Kalle Valoc5483b72009-06-12 14:16:32 +030098 int ret;
99
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300100 mutex_lock(&wl->mutex);
101
Kalle Valoc5483b72009-06-12 14:16:32 +0300102 ret = wl12xx_ps_elp_wakeup(wl);
103 if (ret < 0)
104 goto out;
Kalle Valo01d9cfb2009-06-12 14:16:26 +0300105
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300106 if (wl->state == WL12XX_STATE_ON &&
107 time_after(jiffies, wl->stats.fw_stats_update +
108 msecs_to_jiffies(WL12XX_DEBUGFS_STATS_LIFETIME))) {
109 wl12xx_acx_statistics(wl, wl->stats.fw_stats);
110 wl->stats.fw_stats_update = jiffies;
111 }
112
Kalle Valo01d9cfb2009-06-12 14:16:26 +0300113 wl12xx_ps_elp_sleep(wl);
114
Kalle Valoc5483b72009-06-12 14:16:32 +0300115out:
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300116 mutex_unlock(&wl->mutex);
117}
118
119static int wl12xx_open_file_generic(struct inode *inode, struct file *file)
120{
121 file->private_data = inode->i_private;
122 return 0;
123}
124
125DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");
126
127DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
128DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u");
129DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u");
130DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u");
131DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u");
132DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u");
133DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u");
134DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u");
135
136DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u");
137DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u");
138DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u");
139DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u");
140
141DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u");
142DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u");
143DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u");
144DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u");
145DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u");
146DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u");
147DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u");
148DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u");
149DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u");
150DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u");
151DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u");
152DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u");
153DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u");
154DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u");
155DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u");
156DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u");
157DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u");
158DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u");
159
160DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u");
161DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u");
162/* skipping wep.reserved */
163DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u");
164DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u");
165DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u");
166DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u");
167
168DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u");
169DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u");
170DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u");
171DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u");
172DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u");
173DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u");
174DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u");
175DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u");
176DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u");
177DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u");
178DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u");
179DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u");
180/* skipping cont_miss_bcns_spread for now */
181DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u");
182
183DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u");
184DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u");
185
186DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u");
187DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u");
188DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u");
189DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u");
190DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u");
191DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u");
192
193DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u");
194DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u");
195DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u");
196DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u");
197DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u");
198DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u");
199DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u");
200DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u");
201
202DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u");
203DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u");
204DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u");
205DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u");
206DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u");
207DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u");
208DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u");
209
210DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u");
211DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u");
212DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
213 20, "%u");
214DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u");
215DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u");
216
217DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
218DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
219 wl->stats.excessive_retries);
220
221static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
222 size_t count, loff_t *ppos)
223{
224 struct wl12xx *wl = file->private_data;
225 u32 queue_len;
226 char buf[20];
227 int res;
228
229 queue_len = skb_queue_len(&wl->tx_queue);
230
231 res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
232 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
233}
234
235static const struct file_operations tx_queue_len_ops = {
236 .read = tx_queue_len_read,
237 .open = wl12xx_open_file_generic,
238};
239
240static void wl12xx_debugfs_delete_files(struct wl12xx *wl)
241{
242 DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
243
244 DEBUGFS_FWSTATS_DEL(rx, out_of_mem);
245 DEBUGFS_FWSTATS_DEL(rx, hdr_overflow);
246 DEBUGFS_FWSTATS_DEL(rx, hw_stuck);
247 DEBUGFS_FWSTATS_DEL(rx, dropped);
248 DEBUGFS_FWSTATS_DEL(rx, fcs_err);
249 DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig);
250 DEBUGFS_FWSTATS_DEL(rx, path_reset);
251 DEBUGFS_FWSTATS_DEL(rx, reset_counter);
252
253 DEBUGFS_FWSTATS_DEL(dma, rx_requested);
254 DEBUGFS_FWSTATS_DEL(dma, rx_errors);
255 DEBUGFS_FWSTATS_DEL(dma, tx_requested);
256 DEBUGFS_FWSTATS_DEL(dma, tx_errors);
257
258 DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt);
259 DEBUGFS_FWSTATS_DEL(isr, fiqs);
260 DEBUGFS_FWSTATS_DEL(isr, rx_headers);
261 DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow);
262 DEBUGFS_FWSTATS_DEL(isr, rx_rdys);
263 DEBUGFS_FWSTATS_DEL(isr, irqs);
264 DEBUGFS_FWSTATS_DEL(isr, tx_procs);
265 DEBUGFS_FWSTATS_DEL(isr, decrypt_done);
266 DEBUGFS_FWSTATS_DEL(isr, dma0_done);
267 DEBUGFS_FWSTATS_DEL(isr, dma1_done);
268 DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete);
269 DEBUGFS_FWSTATS_DEL(isr, commands);
270 DEBUGFS_FWSTATS_DEL(isr, rx_procs);
271 DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes);
272 DEBUGFS_FWSTATS_DEL(isr, host_acknowledges);
273 DEBUGFS_FWSTATS_DEL(isr, pci_pm);
274 DEBUGFS_FWSTATS_DEL(isr, wakeups);
275 DEBUGFS_FWSTATS_DEL(isr, low_rssi);
276
277 DEBUGFS_FWSTATS_DEL(wep, addr_key_count);
278 DEBUGFS_FWSTATS_DEL(wep, default_key_count);
279 /* skipping wep.reserved */
280 DEBUGFS_FWSTATS_DEL(wep, key_not_found);
281 DEBUGFS_FWSTATS_DEL(wep, decrypt_fail);
282 DEBUGFS_FWSTATS_DEL(wep, packets);
283 DEBUGFS_FWSTATS_DEL(wep, interrupt);
284
285 DEBUGFS_FWSTATS_DEL(pwr, ps_enter);
286 DEBUGFS_FWSTATS_DEL(pwr, elp_enter);
287 DEBUGFS_FWSTATS_DEL(pwr, missing_bcns);
288 DEBUGFS_FWSTATS_DEL(pwr, wake_on_host);
289 DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp);
290 DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps);
291 DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps);
292 DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons);
293 DEBUGFS_FWSTATS_DEL(pwr, power_save_off);
294 DEBUGFS_FWSTATS_DEL(pwr, enable_ps);
295 DEBUGFS_FWSTATS_DEL(pwr, disable_ps);
296 DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps);
297 /* skipping cont_miss_bcns_spread for now */
298 DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons);
299
300 DEBUGFS_FWSTATS_DEL(mic, rx_pkts);
301 DEBUGFS_FWSTATS_DEL(mic, calc_failure);
302
303 DEBUGFS_FWSTATS_DEL(aes, encrypt_fail);
304 DEBUGFS_FWSTATS_DEL(aes, decrypt_fail);
305 DEBUGFS_FWSTATS_DEL(aes, encrypt_packets);
306 DEBUGFS_FWSTATS_DEL(aes, decrypt_packets);
307 DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt);
308 DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt);
309
310 DEBUGFS_FWSTATS_DEL(event, heart_beat);
311 DEBUGFS_FWSTATS_DEL(event, calibration);
312 DEBUGFS_FWSTATS_DEL(event, rx_mismatch);
313 DEBUGFS_FWSTATS_DEL(event, rx_mem_empty);
314 DEBUGFS_FWSTATS_DEL(event, rx_pool);
315 DEBUGFS_FWSTATS_DEL(event, oom_late);
316 DEBUGFS_FWSTATS_DEL(event, phy_transmit_error);
317 DEBUGFS_FWSTATS_DEL(event, tx_stuck);
318
319 DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts);
320 DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts);
321 DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime);
322 DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn);
323 DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn);
324 DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization);
325 DEBUGFS_FWSTATS_DEL(ps, upsd_utilization);
326
327 DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop);
328 DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data);
329 DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
330 DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data);
331 DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data);
332
333 DEBUGFS_DEL(tx_queue_len);
334 DEBUGFS_DEL(retry_count);
335 DEBUGFS_DEL(excessive_retries);
336}
337
338static int wl12xx_debugfs_add_files(struct wl12xx *wl)
339{
340 int ret = 0;
341
342 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
343
344 DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
345 DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
346 DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
347 DEBUGFS_FWSTATS_ADD(rx, dropped);
348 DEBUGFS_FWSTATS_ADD(rx, fcs_err);
349 DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
350 DEBUGFS_FWSTATS_ADD(rx, path_reset);
351 DEBUGFS_FWSTATS_ADD(rx, reset_counter);
352
353 DEBUGFS_FWSTATS_ADD(dma, rx_requested);
354 DEBUGFS_FWSTATS_ADD(dma, rx_errors);
355 DEBUGFS_FWSTATS_ADD(dma, tx_requested);
356 DEBUGFS_FWSTATS_ADD(dma, tx_errors);
357
358 DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
359 DEBUGFS_FWSTATS_ADD(isr, fiqs);
360 DEBUGFS_FWSTATS_ADD(isr, rx_headers);
361 DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
362 DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
363 DEBUGFS_FWSTATS_ADD(isr, irqs);
364 DEBUGFS_FWSTATS_ADD(isr, tx_procs);
365 DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
366 DEBUGFS_FWSTATS_ADD(isr, dma0_done);
367 DEBUGFS_FWSTATS_ADD(isr, dma1_done);
368 DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
369 DEBUGFS_FWSTATS_ADD(isr, commands);
370 DEBUGFS_FWSTATS_ADD(isr, rx_procs);
371 DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
372 DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
373 DEBUGFS_FWSTATS_ADD(isr, pci_pm);
374 DEBUGFS_FWSTATS_ADD(isr, wakeups);
375 DEBUGFS_FWSTATS_ADD(isr, low_rssi);
376
377 DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
378 DEBUGFS_FWSTATS_ADD(wep, default_key_count);
379 /* skipping wep.reserved */
380 DEBUGFS_FWSTATS_ADD(wep, key_not_found);
381 DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
382 DEBUGFS_FWSTATS_ADD(wep, packets);
383 DEBUGFS_FWSTATS_ADD(wep, interrupt);
384
385 DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
386 DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
387 DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
388 DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
389 DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
390 DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
391 DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
392 DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
393 DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
394 DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
395 DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
396 DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
397 /* skipping cont_miss_bcns_spread for now */
398 DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
399
400 DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
401 DEBUGFS_FWSTATS_ADD(mic, calc_failure);
402
403 DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
404 DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
405 DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
406 DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
407 DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
408 DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
409
410 DEBUGFS_FWSTATS_ADD(event, heart_beat);
411 DEBUGFS_FWSTATS_ADD(event, calibration);
412 DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
413 DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
414 DEBUGFS_FWSTATS_ADD(event, rx_pool);
415 DEBUGFS_FWSTATS_ADD(event, oom_late);
416 DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
417 DEBUGFS_FWSTATS_ADD(event, tx_stuck);
418
419 DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
420 DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
421 DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
422 DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
423 DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
424 DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
425 DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
426
427 DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
428 DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
429 DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
430 DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
431 DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
432
433 DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir);
434 DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
435 DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
436
437out:
438 if (ret < 0)
439 wl12xx_debugfs_delete_files(wl);
440
441 return ret;
442}
443
444void wl12xx_debugfs_reset(struct wl12xx *wl)
445{
446 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
447 wl->stats.retry_count = 0;
448 wl->stats.excessive_retries = 0;
449}
450
451int wl12xx_debugfs_init(struct wl12xx *wl)
452{
453 int ret;
454
455 wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
456
457 if (IS_ERR(wl->debugfs.rootdir)) {
458 ret = PTR_ERR(wl->debugfs.rootdir);
459 wl->debugfs.rootdir = NULL;
460 goto err;
461 }
462
463 wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics",
464 wl->debugfs.rootdir);
465
466 if (IS_ERR(wl->debugfs.fw_statistics)) {
467 ret = PTR_ERR(wl->debugfs.fw_statistics);
468 wl->debugfs.fw_statistics = NULL;
469 goto err_root;
470 }
471
472 wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
473 GFP_KERNEL);
474
475 if (!wl->stats.fw_stats) {
476 ret = -ENOMEM;
477 goto err_fw;
478 }
479
480 wl->stats.fw_stats_update = jiffies;
481
482 ret = wl12xx_debugfs_add_files(wl);
483
484 if (ret < 0)
485 goto err_file;
486
487 return 0;
488
489err_file:
490 kfree(wl->stats.fw_stats);
491 wl->stats.fw_stats = NULL;
492
493err_fw:
494 debugfs_remove(wl->debugfs.fw_statistics);
495 wl->debugfs.fw_statistics = NULL;
496
497err_root:
498 debugfs_remove(wl->debugfs.rootdir);
499 wl->debugfs.rootdir = NULL;
500
501err:
502 return ret;
503}
504
505void wl12xx_debugfs_exit(struct wl12xx *wl)
506{
507 wl12xx_debugfs_delete_files(wl);
508
509 kfree(wl->stats.fw_stats);
510 wl->stats.fw_stats = NULL;
511
512 debugfs_remove(wl->debugfs.fw_statistics);
513 wl->debugfs.fw_statistics = NULL;
514
515 debugfs_remove(wl->debugfs.rootdir);
516 wl->debugfs.rootdir = NULL;
517
518}