1 /*
2  * This file is part of wl12xx
3  *
4  * Copyright (C) 2009 Nokia Corporation
5  * Copyright (C) 2011-2012 Texas Instruments
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  *
21  */
22 
23 #include "../wlcore/debugfs.h"
24 #include "../wlcore/wlcore.h"
25 
26 #include "wl12xx.h"
27 #include "acx.h"
28 #include "debugfs.h"
29 
30 #define WL12XX_DEBUGFS_FWSTATS_FILE(a, b, c) \
31 	DEBUGFS_FWSTATS_FILE(a, b, c, wl12xx_acx_statistics)
32 
33 WL12XX_DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u");
34 
35 WL12XX_DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u");
36 WL12XX_DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u");
37 WL12XX_DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u");
38 WL12XX_DEBUGFS_FWSTATS_FILE(rx, dropped, "%u");
39 WL12XX_DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u");
40 WL12XX_DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u");
41 WL12XX_DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u");
42 WL12XX_DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u");
43 
44 WL12XX_DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u");
45 WL12XX_DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u");
46 WL12XX_DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u");
47 WL12XX_DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u");
48 
49 WL12XX_DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u");
50 WL12XX_DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u");
51 WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u");
52 WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u");
53 WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u");
54 WL12XX_DEBUGFS_FWSTATS_FILE(isr, irqs, "%u");
55 WL12XX_DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u");
56 WL12XX_DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u");
57 WL12XX_DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u");
58 WL12XX_DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u");
59 WL12XX_DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u");
60 WL12XX_DEBUGFS_FWSTATS_FILE(isr, commands, "%u");
61 WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u");
62 WL12XX_DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u");
63 WL12XX_DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u");
64 WL12XX_DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u");
65 WL12XX_DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u");
66 WL12XX_DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u");
67 
68 WL12XX_DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u");
69 WL12XX_DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u");
70 /* skipping wep.reserved */
71 WL12XX_DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u");
72 WL12XX_DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u");
73 WL12XX_DEBUGFS_FWSTATS_FILE(wep, packets, "%u");
74 WL12XX_DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u");
75 
76 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u");
77 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u");
78 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u");
79 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u");
80 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u");
81 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u");
82 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u");
83 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u");
84 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u");
85 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u");
86 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u");
87 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u");
88 /* skipping cont_miss_bcns_spread for now */
89 WL12XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u");
90 
91 WL12XX_DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u");
92 WL12XX_DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u");
93 
94 WL12XX_DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u");
95 WL12XX_DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u");
96 WL12XX_DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u");
97 WL12XX_DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u");
98 WL12XX_DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u");
99 WL12XX_DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u");
100 
101 WL12XX_DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u");
102 WL12XX_DEBUGFS_FWSTATS_FILE(event, calibration, "%u");
103 WL12XX_DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u");
104 WL12XX_DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u");
105 WL12XX_DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u");
106 WL12XX_DEBUGFS_FWSTATS_FILE(event, oom_late, "%u");
107 WL12XX_DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u");
108 WL12XX_DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u");
109 
110 WL12XX_DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u");
111 WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u");
112 WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u");
113 WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u");
114 WL12XX_DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u");
115 WL12XX_DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u");
116 WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u");
117 
118 WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u");
119 WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u");
120 WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
121 			    "%u");
122 WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u");
123 WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u");
124 
125 int wl12xx_debugfs_add_files(struct wl1271 *wl,
126 			     struct dentry *rootdir)
127 {
128 	struct dentry *stats, *moddir;
129 
130 	moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir);
131 	stats = debugfs_create_dir("fw_stats", moddir);
132 
133 	DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
134 
135 	DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
136 	DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
137 	DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
138 	DEBUGFS_FWSTATS_ADD(rx, dropped);
139 	DEBUGFS_FWSTATS_ADD(rx, fcs_err);
140 	DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
141 	DEBUGFS_FWSTATS_ADD(rx, path_reset);
142 	DEBUGFS_FWSTATS_ADD(rx, reset_counter);
143 
144 	DEBUGFS_FWSTATS_ADD(dma, rx_requested);
145 	DEBUGFS_FWSTATS_ADD(dma, rx_errors);
146 	DEBUGFS_FWSTATS_ADD(dma, tx_requested);
147 	DEBUGFS_FWSTATS_ADD(dma, tx_errors);
148 
149 	DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
150 	DEBUGFS_FWSTATS_ADD(isr, fiqs);
151 	DEBUGFS_FWSTATS_ADD(isr, rx_headers);
152 	DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
153 	DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
154 	DEBUGFS_FWSTATS_ADD(isr, irqs);
155 	DEBUGFS_FWSTATS_ADD(isr, tx_procs);
156 	DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
157 	DEBUGFS_FWSTATS_ADD(isr, dma0_done);
158 	DEBUGFS_FWSTATS_ADD(isr, dma1_done);
159 	DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
160 	DEBUGFS_FWSTATS_ADD(isr, commands);
161 	DEBUGFS_FWSTATS_ADD(isr, rx_procs);
162 	DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
163 	DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
164 	DEBUGFS_FWSTATS_ADD(isr, pci_pm);
165 	DEBUGFS_FWSTATS_ADD(isr, wakeups);
166 	DEBUGFS_FWSTATS_ADD(isr, low_rssi);
167 
168 	DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
169 	DEBUGFS_FWSTATS_ADD(wep, default_key_count);
170 	/* skipping wep.reserved */
171 	DEBUGFS_FWSTATS_ADD(wep, key_not_found);
172 	DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
173 	DEBUGFS_FWSTATS_ADD(wep, packets);
174 	DEBUGFS_FWSTATS_ADD(wep, interrupt);
175 
176 	DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
177 	DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
178 	DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
179 	DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
180 	DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
181 	DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
182 	DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
183 	DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
184 	DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
185 	DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
186 	DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
187 	DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
188 	/* skipping cont_miss_bcns_spread for now */
189 	DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
190 
191 	DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
192 	DEBUGFS_FWSTATS_ADD(mic, calc_failure);
193 
194 	DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
195 	DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
196 	DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
197 	DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
198 	DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
199 	DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
200 
201 	DEBUGFS_FWSTATS_ADD(event, heart_beat);
202 	DEBUGFS_FWSTATS_ADD(event, calibration);
203 	DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
204 	DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
205 	DEBUGFS_FWSTATS_ADD(event, rx_pool);
206 	DEBUGFS_FWSTATS_ADD(event, oom_late);
207 	DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
208 	DEBUGFS_FWSTATS_ADD(event, tx_stuck);
209 
210 	DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
211 	DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
212 	DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
213 	DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
214 	DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
215 	DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
216 	DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
217 
218 	DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
219 	DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
220 	DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
221 	DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
222 	DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
223 
224 	return 0;
225 }
226