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