Commit | Line | Data |
---|---|---|
8c0ea102 LC |
1 | /* |
2 | * This file is part of wl18xx | |
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" | |
e7d32324 EP |
25 | #include "../wlcore/debug.h" |
26 | #include "../wlcore/ps.h" | |
8c0ea102 LC |
27 | |
28 | #include "wl18xx.h" | |
29 | #include "acx.h" | |
e7d32324 | 30 | #include "cmd.h" |
8c0ea102 LC |
31 | #include "debugfs.h" |
32 | ||
33 | #define WL18XX_DEBUGFS_FWSTATS_FILE(a, b, c) \ | |
34 | DEBUGFS_FWSTATS_FILE(a, b, c, wl18xx_acx_statistics) | |
35 | #define WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(a, b, c) \ | |
36 | DEBUGFS_FWSTATS_FILE_ARRAY(a, b, c, wl18xx_acx_statistics) | |
37 | ||
c5d94169 | 38 | |
c48276cb EP |
39 | WL18XX_DEBUGFS_FWSTATS_FILE(error, error_frame_non_ctrl, "%u"); |
40 | WL18XX_DEBUGFS_FWSTATS_FILE(error, error_frame_ctrl, "%u"); | |
41 | WL18XX_DEBUGFS_FWSTATS_FILE(error, error_frame_during_protection, "%u"); | |
42 | WL18XX_DEBUGFS_FWSTATS_FILE(error, null_frame_tx_start, "%u"); | |
43 | WL18XX_DEBUGFS_FWSTATS_FILE(error, null_frame_cts_start, "%u"); | |
44 | WL18XX_DEBUGFS_FWSTATS_FILE(error, bar_retry, "%u"); | |
45 | WL18XX_DEBUGFS_FWSTATS_FILE(error, num_frame_cts_nul_flid, "%u"); | |
46 | WL18XX_DEBUGFS_FWSTATS_FILE(error, tx_abort_failure, "%u"); | |
47 | WL18XX_DEBUGFS_FWSTATS_FILE(error, tx_resume_failure, "%u"); | |
48 | WL18XX_DEBUGFS_FWSTATS_FILE(error, rx_cmplt_db_overflow_cnt, "%u"); | |
49 | WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_rx_exch, "%u"); | |
50 | WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_tx_exch, "%u"); | |
51 | WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_tx, "%u"); | |
52 | WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_nvic_pending, "%u"); | |
53 | WL18XX_DEBUGFS_FWSTATS_FILE(error, rx_excessive_frame_len, "%u"); | |
54 | WL18XX_DEBUGFS_FWSTATS_FILE(error, burst_mismatch, "%u"); | |
55 | WL18XX_DEBUGFS_FWSTATS_FILE(error, tbc_exch_mismatch, "%u"); | |
8dd8e53c IR |
56 | |
57 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_prepared_descs, "%u"); | |
58 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_cmplt, "%u"); | |
8c0ea102 LC |
59 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_template_prepared, "%u"); |
60 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_data_prepared, "%u"); | |
61 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_template_programmed, "%u"); | |
62 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_data_programmed, "%u"); | |
63 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_burst_programmed, "%u"); | |
64 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_starts, "%u"); | |
c48276cb | 65 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_stop, "%u"); |
8c0ea102 LC |
66 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_templates, "%u"); |
67 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_int_templates, "%u"); | |
68 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_fw_gen, "%u"); | |
69 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_data, "%u"); | |
70 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_null_frame, "%u"); | |
71 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_exch, "%u"); | |
72 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_retry_template, "%u"); | |
73 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_retry_data, "%u"); | |
c48276cb EP |
74 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(tx, tx_retry_per_rate, |
75 | NUM_OF_RATES_INDEXES); | |
8c0ea102 LC |
76 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_exch_pending, "%u"); |
77 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_exch_expiry, "%u"); | |
8c0ea102 LC |
78 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_done_template, "%u"); |
79 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_done_data, "%u"); | |
80 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_done_int_template, "%u"); | |
c48276cb EP |
81 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_cfe1, "%u"); |
82 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_cfe2, "%u"); | |
c5d94169 LC |
83 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_called, "%u"); |
84 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_mpdu_alloc_failed, "%u"); | |
85 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_init_called, "%u"); | |
86 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_in_process_called, "%u"); | |
87 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_tkip_called, "%u"); | |
88 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_key_not_found, "%u"); | |
89 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_need_fragmentation, "%u"); | |
90 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_bad_mblk_num, "%u"); | |
91 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_failed, "%u"); | |
92 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_cache_hit, "%u"); | |
93 | WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_cache_miss, "%u"); | |
8c0ea102 | 94 | |
8dd8e53c IR |
95 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_beacon_early_term, "%u"); |
96 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_out_of_mpdu_nodes, "%u"); | |
8c0ea102 | 97 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_hdr_overflow, "%u"); |
8c0ea102 | 98 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_dropped_frame, "%u"); |
8c0ea102 LC |
99 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_done, "%u"); |
100 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_defrag, "%u"); | |
101 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_defrag_end, "%u"); | |
8c0ea102 LC |
102 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_cmplt, "%u"); |
103 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_pre_complt, "%u"); | |
104 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_cmplt_task, "%u"); | |
105 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_phy_hdr, "%u"); | |
106 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_timeout, "%u"); | |
c48276cb | 107 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_rts_timeout, "%u"); |
8dd8e53c | 108 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_timeout_wa, "%u"); |
c5d94169 LC |
109 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_called, "%u"); |
110 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_init_called, "%u"); | |
111 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_in_process_called, "%u"); | |
112 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_tkip_called, "%u"); | |
113 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_need_defrag, "%u"); | |
114 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_decrypt_failed, "%u"); | |
115 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, decrypt_key_not_found, "%u"); | |
116 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_need_decrypt, "%u"); | |
8dd8e53c | 117 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_tkip_replays, "%u"); |
c48276cb | 118 | WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_xfr, "%u"); |
8c0ea102 LC |
119 | |
120 | WL18XX_DEBUGFS_FWSTATS_FILE(isr, irqs, "%u"); | |
121 | ||
8c0ea102 LC |
122 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, missing_bcns_cnt, "%u"); |
123 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_bcns_cnt, "%u"); | |
124 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, connection_out_of_sync, "%u"); | |
125 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(pwr, cont_miss_bcns_spread, | |
126 | PWR_STAT_MAX_CONT_MISSED_BCNS_SPREAD); | |
127 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_bcns_cnt, "%u"); | |
c48276cb EP |
128 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_time_count, "%u"); |
129 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_time_avg, "%u"); | |
130 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_cycle_avg, "%u"); | |
131 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_percent, "%u"); | |
132 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, ap_sleep_active_conf, "%u"); | |
133 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, ap_sleep_user_conf, "%u"); | |
134 | WL18XX_DEBUGFS_FWSTATS_FILE(pwr, ap_sleep_counter, "%u"); | |
8c0ea102 LC |
135 | |
136 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, beacon_filter, "%u"); | |
137 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, arp_filter, "%u"); | |
138 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, mc_filter, "%u"); | |
139 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, dup_filter, "%u"); | |
140 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, data_filter, "%u"); | |
141 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, ibss_filter, "%u"); | |
142 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, protection_filter, "%u"); | |
8dd8e53c IR |
143 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, accum_arp_pend_requests, "%u"); |
144 | WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, max_arp_queue_dep, "%u"); | |
8c0ea102 | 145 | |
a3fa71c4 | 146 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(rx_rate, rx_frames_per_rates, 50); |
c5d94169 | 147 | |
c48276cb EP |
148 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(aggr_size, tx_agg_rate, |
149 | AGGR_STATS_TX_AGG); | |
150 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(aggr_size, tx_agg_len, | |
151 | AGGR_STATS_TX_AGG); | |
c5d94169 LC |
152 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(aggr_size, rx_size, |
153 | AGGR_STATS_RX_SIZE_LEN); | |
154 | ||
155 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, hs_tx_stat_fifo_int, "%u"); | |
c5d94169 LC |
156 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, enc_tx_stat_fifo_int, "%u"); |
157 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, enc_rx_stat_fifo_int, "%u"); | |
158 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, rx_complete_stat_fifo_int, "%u"); | |
159 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, pre_proc_swi, "%u"); | |
160 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, post_proc_swi, "%u"); | |
161 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, sec_frag_swi, "%u"); | |
162 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, pre_to_defrag_swi, "%u"); | |
fc645df0 | 163 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, defrag_to_rx_xfer_swi, "%u"); |
c5d94169 LC |
164 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, dec_packet_in, "%u"); |
165 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, dec_packet_in_fifo_full, "%u"); | |
166 | WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, dec_packet_out, "%u"); | |
c5d94169 | 167 | |
8dd8e53c IR |
168 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(pipeline, pipeline_fifo_full, |
169 | PIPE_STATS_HW_FIFO); | |
170 | ||
fc645df0 GM |
171 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(diversity, num_of_packets_per_ant, |
172 | DIVERSITY_STATS_NUM_OF_ANT); | |
173 | WL18XX_DEBUGFS_FWSTATS_FILE(diversity, total_num_of_toggles, "%u"); | |
174 | ||
c48276cb EP |
175 | WL18XX_DEBUGFS_FWSTATS_FILE(thermal, irq_thr_low, "%u"); |
176 | WL18XX_DEBUGFS_FWSTATS_FILE(thermal, irq_thr_high, "%u"); | |
177 | WL18XX_DEBUGFS_FWSTATS_FILE(thermal, tx_stop, "%u"); | |
178 | WL18XX_DEBUGFS_FWSTATS_FILE(thermal, tx_resume, "%u"); | |
179 | WL18XX_DEBUGFS_FWSTATS_FILE(thermal, false_irq, "%u"); | |
180 | WL18XX_DEBUGFS_FWSTATS_FILE(thermal, adc_source_unexpected, "%u"); | |
181 | ||
182 | WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(calib, fail_count, | |
183 | WL18XX_NUM_OF_CALIBRATIONS_ERRORS); | |
184 | WL18XX_DEBUGFS_FWSTATS_FILE(calib, calib_count, "%u"); | |
185 | ||
186 | WL18XX_DEBUGFS_FWSTATS_FILE(roaming, rssi_level, "%d"); | |
187 | ||
188 | WL18XX_DEBUGFS_FWSTATS_FILE(dfs, num_of_radar_detections, "%d"); | |
8c0ea102 | 189 | |
18b70ac9 LC |
190 | static ssize_t conf_read(struct file *file, char __user *user_buf, |
191 | size_t count, loff_t *ppos) | |
192 | { | |
193 | struct wl1271 *wl = file->private_data; | |
194 | struct wl18xx_priv *priv = wl->priv; | |
195 | struct wlcore_conf_header header; | |
196 | char *buf, *pos; | |
197 | size_t len; | |
198 | int ret; | |
199 | ||
200 | len = WL18XX_CONF_SIZE; | |
201 | buf = kmalloc(len, GFP_KERNEL); | |
202 | if (!buf) | |
203 | return -ENOMEM; | |
204 | ||
205 | header.magic = cpu_to_le32(WL18XX_CONF_MAGIC); | |
206 | header.version = cpu_to_le32(WL18XX_CONF_VERSION); | |
207 | header.checksum = 0; | |
208 | ||
209 | mutex_lock(&wl->mutex); | |
210 | ||
211 | pos = buf; | |
212 | memcpy(pos, &header, sizeof(header)); | |
213 | pos += sizeof(header); | |
214 | memcpy(pos, &wl->conf, sizeof(wl->conf)); | |
215 | pos += sizeof(wl->conf); | |
216 | memcpy(pos, &priv->conf, sizeof(priv->conf)); | |
217 | ||
218 | mutex_unlock(&wl->mutex); | |
219 | ||
220 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); | |
221 | ||
222 | kfree(buf); | |
223 | return ret; | |
224 | } | |
225 | ||
226 | static const struct file_operations conf_ops = { | |
227 | .read = conf_read, | |
228 | .open = simple_open, | |
229 | .llseek = default_llseek, | |
230 | }; | |
231 | ||
f74ea74b LC |
232 | static ssize_t clear_fw_stats_write(struct file *file, |
233 | const char __user *user_buf, | |
234 | size_t count, loff_t *ppos) | |
235 | { | |
236 | struct wl1271 *wl = file->private_data; | |
237 | int ret; | |
238 | ||
239 | mutex_lock(&wl->mutex); | |
240 | ||
4cc53383 | 241 | if (unlikely(wl->state != WLCORE_STATE_ON)) |
f74ea74b LC |
242 | goto out; |
243 | ||
244 | ret = wl18xx_acx_clear_statistics(wl); | |
245 | if (ret < 0) { | |
246 | count = ret; | |
247 | goto out; | |
248 | } | |
249 | out: | |
250 | mutex_unlock(&wl->mutex); | |
251 | return count; | |
252 | } | |
253 | ||
254 | static const struct file_operations clear_fw_stats_ops = { | |
255 | .write = clear_fw_stats_write, | |
256 | .open = simple_open, | |
257 | .llseek = default_llseek, | |
258 | }; | |
259 | ||
e7d32324 EP |
260 | static ssize_t radar_detection_write(struct file *file, |
261 | const char __user *user_buf, | |
262 | size_t count, loff_t *ppos) | |
263 | { | |
264 | struct wl1271 *wl = file->private_data; | |
265 | int ret; | |
266 | u8 channel; | |
267 | ||
268 | ret = kstrtou8_from_user(user_buf, count, 10, &channel); | |
269 | if (ret < 0) { | |
270 | wl1271_warning("illegal channel"); | |
271 | return -EINVAL; | |
272 | } | |
273 | ||
274 | mutex_lock(&wl->mutex); | |
275 | ||
276 | if (unlikely(wl->state != WLCORE_STATE_ON)) | |
277 | goto out; | |
278 | ||
279 | ret = wl1271_ps_elp_wakeup(wl); | |
280 | if (ret < 0) | |
281 | goto out; | |
282 | ||
283 | ret = wl18xx_cmd_radar_detection_debug(wl, channel); | |
284 | if (ret < 0) | |
285 | count = ret; | |
286 | ||
287 | wl1271_ps_elp_sleep(wl); | |
288 | out: | |
289 | mutex_unlock(&wl->mutex); | |
290 | return count; | |
291 | } | |
292 | ||
293 | static const struct file_operations radar_detection_ops = { | |
294 | .write = radar_detection_write, | |
295 | .open = simple_open, | |
296 | .llseek = default_llseek, | |
297 | }; | |
298 | ||
d1c54096 GM |
299 | static ssize_t dynamic_fw_traces_write(struct file *file, |
300 | const char __user *user_buf, | |
301 | size_t count, loff_t *ppos) | |
302 | { | |
303 | struct wl1271 *wl = file->private_data; | |
304 | unsigned long value; | |
305 | int ret; | |
306 | ||
307 | ret = kstrtoul_from_user(user_buf, count, 0, &value); | |
308 | if (ret < 0) | |
309 | return ret; | |
310 | ||
311 | mutex_lock(&wl->mutex); | |
312 | ||
313 | wl->dynamic_fw_traces = value; | |
314 | ||
315 | if (unlikely(wl->state != WLCORE_STATE_ON)) | |
316 | goto out; | |
317 | ||
318 | ret = wl1271_ps_elp_wakeup(wl); | |
319 | if (ret < 0) | |
320 | goto out; | |
321 | ||
322 | ret = wl18xx_acx_dynamic_fw_traces(wl); | |
323 | if (ret < 0) | |
324 | count = ret; | |
325 | ||
326 | wl1271_ps_elp_sleep(wl); | |
327 | out: | |
328 | mutex_unlock(&wl->mutex); | |
329 | return count; | |
330 | } | |
331 | ||
332 | static ssize_t dynamic_fw_traces_read(struct file *file, | |
333 | char __user *userbuf, | |
334 | size_t count, loff_t *ppos) | |
335 | { | |
336 | struct wl1271 *wl = file->private_data; | |
337 | return wl1271_format_buffer(userbuf, count, ppos, | |
338 | "%d\n", wl->dynamic_fw_traces); | |
339 | } | |
340 | ||
341 | static const struct file_operations dynamic_fw_traces_ops = { | |
342 | .read = dynamic_fw_traces_read, | |
343 | .write = dynamic_fw_traces_write, | |
344 | .open = simple_open, | |
345 | .llseek = default_llseek, | |
346 | }; | |
347 | ||
8cf77e17 EP |
348 | #ifdef CONFIG_CFG80211_CERTIFICATION_ONUS |
349 | static ssize_t radar_debug_mode_write(struct file *file, | |
350 | const char __user *user_buf, | |
351 | size_t count, loff_t *ppos) | |
352 | { | |
353 | struct wl1271 *wl = file->private_data; | |
354 | struct wl12xx_vif *wlvif; | |
355 | unsigned long value; | |
356 | int ret; | |
357 | ||
358 | ret = kstrtoul_from_user(user_buf, count, 10, &value); | |
359 | if (ret < 0) { | |
360 | wl1271_warning("illegal radar_debug_mode value!"); | |
361 | return -EINVAL; | |
362 | } | |
363 | ||
364 | /* valid values: 0/1 */ | |
365 | if (!(value == 0 || value == 1)) { | |
366 | wl1271_warning("value is not in valid!"); | |
367 | return -EINVAL; | |
368 | } | |
369 | ||
370 | mutex_lock(&wl->mutex); | |
371 | ||
372 | wl->radar_debug_mode = value; | |
373 | ||
374 | if (unlikely(wl->state != WLCORE_STATE_ON)) | |
375 | goto out; | |
376 | ||
377 | ret = wl1271_ps_elp_wakeup(wl); | |
378 | if (ret < 0) | |
379 | goto out; | |
380 | ||
381 | wl12xx_for_each_wlvif_ap(wl, wlvif) { | |
382 | wlcore_cmd_generic_cfg(wl, wlvif, | |
383 | WLCORE_CFG_FEATURE_RADAR_DEBUG, | |
384 | wl->radar_debug_mode, 0); | |
385 | } | |
386 | ||
387 | wl1271_ps_elp_sleep(wl); | |
388 | out: | |
389 | mutex_unlock(&wl->mutex); | |
390 | return count; | |
391 | } | |
392 | ||
393 | static ssize_t radar_debug_mode_read(struct file *file, | |
394 | char __user *userbuf, | |
395 | size_t count, loff_t *ppos) | |
396 | { | |
397 | struct wl1271 *wl = file->private_data; | |
398 | ||
399 | return wl1271_format_buffer(userbuf, count, ppos, | |
400 | "%d\n", wl->radar_debug_mode); | |
401 | } | |
402 | ||
403 | static const struct file_operations radar_debug_mode_ops = { | |
404 | .write = radar_debug_mode_write, | |
405 | .read = radar_debug_mode_read, | |
406 | .open = simple_open, | |
407 | .llseek = default_llseek, | |
408 | }; | |
409 | #endif /* CFG80211_CERTIFICATION_ONUS */ | |
410 | ||
8c0ea102 LC |
411 | int wl18xx_debugfs_add_files(struct wl1271 *wl, |
412 | struct dentry *rootdir) | |
413 | { | |
414 | int ret = 0; | |
ad62d81a | 415 | struct dentry *entry, *stats, *moddir; |
8c0ea102 | 416 | |
ad62d81a LC |
417 | moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir); |
418 | if (!moddir || IS_ERR(moddir)) { | |
419 | entry = moddir; | |
420 | goto err; | |
421 | } | |
422 | ||
423 | stats = debugfs_create_dir("fw_stats", moddir); | |
8c0ea102 LC |
424 | if (!stats || IS_ERR(stats)) { |
425 | entry = stats; | |
426 | goto err; | |
427 | } | |
428 | ||
f74ea74b LC |
429 | DEBUGFS_ADD(clear_fw_stats, stats); |
430 | ||
c48276cb EP |
431 | DEBUGFS_FWSTATS_ADD(error, error_frame_non_ctrl); |
432 | DEBUGFS_FWSTATS_ADD(error, error_frame_ctrl); | |
433 | DEBUGFS_FWSTATS_ADD(error, error_frame_during_protection); | |
434 | DEBUGFS_FWSTATS_ADD(error, null_frame_tx_start); | |
435 | DEBUGFS_FWSTATS_ADD(error, null_frame_cts_start); | |
436 | DEBUGFS_FWSTATS_ADD(error, bar_retry); | |
437 | DEBUGFS_FWSTATS_ADD(error, num_frame_cts_nul_flid); | |
438 | DEBUGFS_FWSTATS_ADD(error, tx_abort_failure); | |
439 | DEBUGFS_FWSTATS_ADD(error, tx_resume_failure); | |
440 | DEBUGFS_FWSTATS_ADD(error, rx_cmplt_db_overflow_cnt); | |
441 | DEBUGFS_FWSTATS_ADD(error, elp_while_rx_exch); | |
442 | DEBUGFS_FWSTATS_ADD(error, elp_while_tx_exch); | |
443 | DEBUGFS_FWSTATS_ADD(error, elp_while_tx); | |
444 | DEBUGFS_FWSTATS_ADD(error, elp_while_nvic_pending); | |
445 | DEBUGFS_FWSTATS_ADD(error, rx_excessive_frame_len); | |
446 | DEBUGFS_FWSTATS_ADD(error, burst_mismatch); | |
447 | DEBUGFS_FWSTATS_ADD(error, tbc_exch_mismatch); | |
8c0ea102 | 448 | |
8dd8e53c IR |
449 | DEBUGFS_FWSTATS_ADD(tx, tx_prepared_descs); |
450 | DEBUGFS_FWSTATS_ADD(tx, tx_cmplt); | |
8c0ea102 LC |
451 | DEBUGFS_FWSTATS_ADD(tx, tx_template_prepared); |
452 | DEBUGFS_FWSTATS_ADD(tx, tx_data_prepared); | |
453 | DEBUGFS_FWSTATS_ADD(tx, tx_template_programmed); | |
454 | DEBUGFS_FWSTATS_ADD(tx, tx_data_programmed); | |
455 | DEBUGFS_FWSTATS_ADD(tx, tx_burst_programmed); | |
456 | DEBUGFS_FWSTATS_ADD(tx, tx_starts); | |
c48276cb | 457 | DEBUGFS_FWSTATS_ADD(tx, tx_stop); |
8c0ea102 LC |
458 | DEBUGFS_FWSTATS_ADD(tx, tx_start_templates); |
459 | DEBUGFS_FWSTATS_ADD(tx, tx_start_int_templates); | |
460 | DEBUGFS_FWSTATS_ADD(tx, tx_start_fw_gen); | |
461 | DEBUGFS_FWSTATS_ADD(tx, tx_start_data); | |
462 | DEBUGFS_FWSTATS_ADD(tx, tx_start_null_frame); | |
463 | DEBUGFS_FWSTATS_ADD(tx, tx_exch); | |
464 | DEBUGFS_FWSTATS_ADD(tx, tx_retry_template); | |
465 | DEBUGFS_FWSTATS_ADD(tx, tx_retry_data); | |
c48276cb | 466 | DEBUGFS_FWSTATS_ADD(tx, tx_retry_per_rate); |
8c0ea102 LC |
467 | DEBUGFS_FWSTATS_ADD(tx, tx_exch_pending); |
468 | DEBUGFS_FWSTATS_ADD(tx, tx_exch_expiry); | |
8c0ea102 LC |
469 | DEBUGFS_FWSTATS_ADD(tx, tx_done_template); |
470 | DEBUGFS_FWSTATS_ADD(tx, tx_done_data); | |
471 | DEBUGFS_FWSTATS_ADD(tx, tx_done_int_template); | |
c48276cb EP |
472 | DEBUGFS_FWSTATS_ADD(tx, tx_cfe1); |
473 | DEBUGFS_FWSTATS_ADD(tx, tx_cfe2); | |
c5d94169 LC |
474 | DEBUGFS_FWSTATS_ADD(tx, frag_called); |
475 | DEBUGFS_FWSTATS_ADD(tx, frag_mpdu_alloc_failed); | |
476 | DEBUGFS_FWSTATS_ADD(tx, frag_init_called); | |
477 | DEBUGFS_FWSTATS_ADD(tx, frag_in_process_called); | |
478 | DEBUGFS_FWSTATS_ADD(tx, frag_tkip_called); | |
479 | DEBUGFS_FWSTATS_ADD(tx, frag_key_not_found); | |
480 | DEBUGFS_FWSTATS_ADD(tx, frag_need_fragmentation); | |
481 | DEBUGFS_FWSTATS_ADD(tx, frag_bad_mblk_num); | |
482 | DEBUGFS_FWSTATS_ADD(tx, frag_failed); | |
483 | DEBUGFS_FWSTATS_ADD(tx, frag_cache_hit); | |
484 | DEBUGFS_FWSTATS_ADD(tx, frag_cache_miss); | |
8c0ea102 | 485 | |
8dd8e53c IR |
486 | DEBUGFS_FWSTATS_ADD(rx, rx_beacon_early_term); |
487 | DEBUGFS_FWSTATS_ADD(rx, rx_out_of_mpdu_nodes); | |
8c0ea102 | 488 | DEBUGFS_FWSTATS_ADD(rx, rx_hdr_overflow); |
8c0ea102 | 489 | DEBUGFS_FWSTATS_ADD(rx, rx_dropped_frame); |
8c0ea102 LC |
490 | DEBUGFS_FWSTATS_ADD(rx, rx_done); |
491 | DEBUGFS_FWSTATS_ADD(rx, rx_defrag); | |
492 | DEBUGFS_FWSTATS_ADD(rx, rx_defrag_end); | |
8c0ea102 LC |
493 | DEBUGFS_FWSTATS_ADD(rx, rx_cmplt); |
494 | DEBUGFS_FWSTATS_ADD(rx, rx_pre_complt); | |
495 | DEBUGFS_FWSTATS_ADD(rx, rx_cmplt_task); | |
496 | DEBUGFS_FWSTATS_ADD(rx, rx_phy_hdr); | |
497 | DEBUGFS_FWSTATS_ADD(rx, rx_timeout); | |
c48276cb | 498 | DEBUGFS_FWSTATS_ADD(rx, rx_rts_timeout); |
8dd8e53c | 499 | DEBUGFS_FWSTATS_ADD(rx, rx_timeout_wa); |
c5d94169 LC |
500 | DEBUGFS_FWSTATS_ADD(rx, defrag_called); |
501 | DEBUGFS_FWSTATS_ADD(rx, defrag_init_called); | |
502 | DEBUGFS_FWSTATS_ADD(rx, defrag_in_process_called); | |
503 | DEBUGFS_FWSTATS_ADD(rx, defrag_tkip_called); | |
504 | DEBUGFS_FWSTATS_ADD(rx, defrag_need_defrag); | |
505 | DEBUGFS_FWSTATS_ADD(rx, defrag_decrypt_failed); | |
506 | DEBUGFS_FWSTATS_ADD(rx, decrypt_key_not_found); | |
507 | DEBUGFS_FWSTATS_ADD(rx, defrag_need_decrypt); | |
8dd8e53c | 508 | DEBUGFS_FWSTATS_ADD(rx, rx_tkip_replays); |
c48276cb | 509 | DEBUGFS_FWSTATS_ADD(rx, rx_xfr); |
8c0ea102 LC |
510 | |
511 | DEBUGFS_FWSTATS_ADD(isr, irqs); | |
512 | ||
8c0ea102 LC |
513 | DEBUGFS_FWSTATS_ADD(pwr, missing_bcns_cnt); |
514 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_bcns_cnt); | |
515 | DEBUGFS_FWSTATS_ADD(pwr, connection_out_of_sync); | |
516 | DEBUGFS_FWSTATS_ADD(pwr, cont_miss_bcns_spread); | |
517 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_bcns_cnt); | |
c48276cb EP |
518 | DEBUGFS_FWSTATS_ADD(pwr, sleep_time_count); |
519 | DEBUGFS_FWSTATS_ADD(pwr, sleep_time_avg); | |
520 | DEBUGFS_FWSTATS_ADD(pwr, sleep_cycle_avg); | |
521 | DEBUGFS_FWSTATS_ADD(pwr, sleep_percent); | |
522 | DEBUGFS_FWSTATS_ADD(pwr, ap_sleep_active_conf); | |
523 | DEBUGFS_FWSTATS_ADD(pwr, ap_sleep_user_conf); | |
524 | DEBUGFS_FWSTATS_ADD(pwr, ap_sleep_counter); | |
8c0ea102 LC |
525 | |
526 | DEBUGFS_FWSTATS_ADD(rx_filter, beacon_filter); | |
527 | DEBUGFS_FWSTATS_ADD(rx_filter, arp_filter); | |
528 | DEBUGFS_FWSTATS_ADD(rx_filter, mc_filter); | |
529 | DEBUGFS_FWSTATS_ADD(rx_filter, dup_filter); | |
530 | DEBUGFS_FWSTATS_ADD(rx_filter, data_filter); | |
531 | DEBUGFS_FWSTATS_ADD(rx_filter, ibss_filter); | |
532 | DEBUGFS_FWSTATS_ADD(rx_filter, protection_filter); | |
8dd8e53c IR |
533 | DEBUGFS_FWSTATS_ADD(rx_filter, accum_arp_pend_requests); |
534 | DEBUGFS_FWSTATS_ADD(rx_filter, max_arp_queue_dep); | |
8c0ea102 | 535 | |
c5d94169 LC |
536 | DEBUGFS_FWSTATS_ADD(rx_rate, rx_frames_per_rates); |
537 | ||
c48276cb EP |
538 | DEBUGFS_FWSTATS_ADD(aggr_size, tx_agg_rate); |
539 | DEBUGFS_FWSTATS_ADD(aggr_size, tx_agg_len); | |
c5d94169 LC |
540 | DEBUGFS_FWSTATS_ADD(aggr_size, rx_size); |
541 | ||
542 | DEBUGFS_FWSTATS_ADD(pipeline, hs_tx_stat_fifo_int); | |
c5d94169 LC |
543 | DEBUGFS_FWSTATS_ADD(pipeline, enc_tx_stat_fifo_int); |
544 | DEBUGFS_FWSTATS_ADD(pipeline, enc_rx_stat_fifo_int); | |
545 | DEBUGFS_FWSTATS_ADD(pipeline, rx_complete_stat_fifo_int); | |
546 | DEBUGFS_FWSTATS_ADD(pipeline, pre_proc_swi); | |
547 | DEBUGFS_FWSTATS_ADD(pipeline, post_proc_swi); | |
548 | DEBUGFS_FWSTATS_ADD(pipeline, sec_frag_swi); | |
549 | DEBUGFS_FWSTATS_ADD(pipeline, pre_to_defrag_swi); | |
fc645df0 | 550 | DEBUGFS_FWSTATS_ADD(pipeline, defrag_to_rx_xfer_swi); |
c5d94169 LC |
551 | DEBUGFS_FWSTATS_ADD(pipeline, dec_packet_in); |
552 | DEBUGFS_FWSTATS_ADD(pipeline, dec_packet_in_fifo_full); | |
553 | DEBUGFS_FWSTATS_ADD(pipeline, dec_packet_out); | |
8dd8e53c | 554 | DEBUGFS_FWSTATS_ADD(pipeline, pipeline_fifo_full); |
c5d94169 | 555 | |
fc645df0 GM |
556 | DEBUGFS_FWSTATS_ADD(diversity, num_of_packets_per_ant); |
557 | DEBUGFS_FWSTATS_ADD(diversity, total_num_of_toggles); | |
558 | ||
c48276cb EP |
559 | DEBUGFS_FWSTATS_ADD(thermal, irq_thr_low); |
560 | DEBUGFS_FWSTATS_ADD(thermal, irq_thr_high); | |
561 | DEBUGFS_FWSTATS_ADD(thermal, tx_stop); | |
562 | DEBUGFS_FWSTATS_ADD(thermal, tx_resume); | |
563 | DEBUGFS_FWSTATS_ADD(thermal, false_irq); | |
564 | DEBUGFS_FWSTATS_ADD(thermal, adc_source_unexpected); | |
565 | ||
566 | DEBUGFS_FWSTATS_ADD(calib, fail_count); | |
567 | ||
568 | DEBUGFS_FWSTATS_ADD(calib, calib_count); | |
569 | ||
570 | DEBUGFS_FWSTATS_ADD(roaming, rssi_level); | |
571 | ||
572 | DEBUGFS_FWSTATS_ADD(dfs, num_of_radar_detections); | |
8c0ea102 | 573 | |
18b70ac9 | 574 | DEBUGFS_ADD(conf, moddir); |
e7d32324 | 575 | DEBUGFS_ADD(radar_detection, moddir); |
8cf77e17 EP |
576 | #ifdef CONFIG_CFG80211_CERTIFICATION_ONUS |
577 | DEBUGFS_ADD(radar_debug_mode, moddir); | |
578 | #endif | |
d1c54096 | 579 | DEBUGFS_ADD(dynamic_fw_traces, moddir); |
18b70ac9 | 580 | |
8c0ea102 LC |
581 | return 0; |
582 | ||
583 | err: | |
584 | if (IS_ERR(entry)) | |
585 | ret = PTR_ERR(entry); | |
586 | else | |
587 | ret = -ENOMEM; | |
588 | ||
589 | return ret; | |
590 | } |