debugfs.c 20 KB

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