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