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
33WL12XX_DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u");
34
35WL12XX_DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u");
36WL12XX_DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u");
37WL12XX_DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u");
38WL12XX_DEBUGFS_FWSTATS_FILE(rx, dropped, "%u");
39WL12XX_DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u");
40WL12XX_DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u");
41WL12XX_DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u");
42WL12XX_DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u");
43
44WL12XX_DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u");
45WL12XX_DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u");
46WL12XX_DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u");
47WL12XX_DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u");
48
49WL12XX_DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u");
50WL12XX_DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u");
51WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u");
52WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u");
53WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u");
54WL12XX_DEBUGFS_FWSTATS_FILE(isr, irqs, "%u");
55WL12XX_DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u");
56WL12XX_DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u");
57WL12XX_DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u");
58WL12XX_DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u");
59WL12XX_DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u");
60WL12XX_DEBUGFS_FWSTATS_FILE(isr, commands, "%u");
61WL12XX_DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u");
62WL12XX_DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u");
63WL12XX_DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u");
64WL12XX_DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u");
65WL12XX_DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u");
66WL12XX_DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u");
67
68WL12XX_DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u");
69WL12XX_DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u");
70/* skipping wep.reserved */
71WL12XX_DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u");
72WL12XX_DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u");
73WL12XX_DEBUGFS_FWSTATS_FILE(wep, packets, "%u");
74WL12XX_DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u");
75
76WL12XX_DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u");
77WL12XX_DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u");
78WL12XX_DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u");
79WL12XX_DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u");
80WL12XX_DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u");
81WL12XX_DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u");
82WL12XX_DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u");
83WL12XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u");
84WL12XX_DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u");
85WL12XX_DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u");
86WL12XX_DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u");
87WL12XX_DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u");
88/* skipping cont_miss_bcns_spread for now */
89WL12XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u");
90
91WL12XX_DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u");
92WL12XX_DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u");
93
94WL12XX_DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u");
95WL12XX_DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u");
96WL12XX_DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u");
97WL12XX_DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u");
98WL12XX_DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u");
99WL12XX_DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u");
100
101WL12XX_DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u");
102WL12XX_DEBUGFS_FWSTATS_FILE(event, calibration, "%u");
103WL12XX_DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u");
104WL12XX_DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u");
105WL12XX_DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u");
106WL12XX_DEBUGFS_FWSTATS_FILE(event, oom_late, "%u");
107WL12XX_DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u");
108WL12XX_DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u");
109
110WL12XX_DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u");
111WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u");
112WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u");
113WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u");
114WL12XX_DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u");
115WL12XX_DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u");
116WL12XX_DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u");
117
118WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u");
119WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u");
120WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
121			    "%u");
122WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u");
123WL12XX_DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u");
124
125int wl12xx_debugfs_add_files(struct wl1271 *wl,
126			     struct dentry *rootdir)
127{
128	int ret = 0;
129	struct dentry *entry, *stats, *moddir;
130
131	moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir);
132	if (!moddir || IS_ERR(moddir)) {
133		entry = moddir;
134		goto err;
135	}
136
137	stats = debugfs_create_dir("fw_stats", moddir);
138	if (!stats || IS_ERR(stats)) {
139		entry = stats;
140		goto err;
141	}
142
143	DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
144
145	DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
146	DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
147	DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
148	DEBUGFS_FWSTATS_ADD(rx, dropped);
149	DEBUGFS_FWSTATS_ADD(rx, fcs_err);
150	DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
151	DEBUGFS_FWSTATS_ADD(rx, path_reset);
152	DEBUGFS_FWSTATS_ADD(rx, reset_counter);
153
154	DEBUGFS_FWSTATS_ADD(dma, rx_requested);
155	DEBUGFS_FWSTATS_ADD(dma, rx_errors);
156	DEBUGFS_FWSTATS_ADD(dma, tx_requested);
157	DEBUGFS_FWSTATS_ADD(dma, tx_errors);
158
159	DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
160	DEBUGFS_FWSTATS_ADD(isr, fiqs);
161	DEBUGFS_FWSTATS_ADD(isr, rx_headers);
162	DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
163	DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
164	DEBUGFS_FWSTATS_ADD(isr, irqs);
165	DEBUGFS_FWSTATS_ADD(isr, tx_procs);
166	DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
167	DEBUGFS_FWSTATS_ADD(isr, dma0_done);
168	DEBUGFS_FWSTATS_ADD(isr, dma1_done);
169	DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
170	DEBUGFS_FWSTATS_ADD(isr, commands);
171	DEBUGFS_FWSTATS_ADD(isr, rx_procs);
172	DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
173	DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
174	DEBUGFS_FWSTATS_ADD(isr, pci_pm);
175	DEBUGFS_FWSTATS_ADD(isr, wakeups);
176	DEBUGFS_FWSTATS_ADD(isr, low_rssi);
177
178	DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
179	DEBUGFS_FWSTATS_ADD(wep, default_key_count);
180	/* skipping wep.reserved */
181	DEBUGFS_FWSTATS_ADD(wep, key_not_found);
182	DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
183	DEBUGFS_FWSTATS_ADD(wep, packets);
184	DEBUGFS_FWSTATS_ADD(wep, interrupt);
185
186	DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
187	DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
188	DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
189	DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
190	DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
191	DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
192	DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
193	DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
194	DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
195	DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
196	DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
197	DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
198	/* skipping cont_miss_bcns_spread for now */
199	DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
200
201	DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
202	DEBUGFS_FWSTATS_ADD(mic, calc_failure);
203
204	DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
205	DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
206	DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
207	DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
208	DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
209	DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
210
211	DEBUGFS_FWSTATS_ADD(event, heart_beat);
212	DEBUGFS_FWSTATS_ADD(event, calibration);
213	DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
214	DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
215	DEBUGFS_FWSTATS_ADD(event, rx_pool);
216	DEBUGFS_FWSTATS_ADD(event, oom_late);
217	DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
218	DEBUGFS_FWSTATS_ADD(event, tx_stuck);
219
220	DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
221	DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
222	DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
223	DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
224	DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
225	DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
226	DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
227
228	DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
229	DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
230	DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
231	DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
232	DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
233
234	return 0;
235
236err:
237	if (IS_ERR(entry))
238		ret = PTR_ERR(entry);
239	else
240		ret = -ENOMEM;
241
242	return ret;
243}
244