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