debugfs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * This file is part of wl1251
  4. *
  5. * Copyright (C) 2009 Nokia Corporation
  6. */
  7. #include "debugfs.h"
  8. #include <linux/skbuff.h>
  9. #include <linux/slab.h>
  10. #include "wl1251.h"
  11. #include "acx.h"
  12. #include "ps.h"
  13. /* ms */
  14. #define WL1251_DEBUGFS_STATS_LIFETIME 1000
  15. /* debugfs macros idea from mac80211 */
  16. #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
  17. static ssize_t name## _read(struct file *file, char __user *userbuf, \
  18. size_t count, loff_t *ppos) \
  19. { \
  20. struct wl1251 *wl = file->private_data; \
  21. char buf[buflen]; \
  22. int res; \
  23. \
  24. res = scnprintf(buf, buflen, fmt "\n", ##value); \
  25. return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
  26. } \
  27. \
  28. static const struct file_operations name## _ops = { \
  29. .read = name## _read, \
  30. .open = simple_open, \
  31. .llseek = generic_file_llseek, \
  32. };
  33. #define DEBUGFS_ADD(name, parent) \
  34. wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
  35. wl, &name## _ops) \
  36. #define DEBUGFS_DEL(name) \
  37. do { \
  38. debugfs_remove(wl->debugfs.name); \
  39. wl->debugfs.name = NULL; \
  40. } while (0)
  41. #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \
  42. static ssize_t sub## _ ##name## _read(struct file *file, \
  43. char __user *userbuf, \
  44. size_t count, loff_t *ppos) \
  45. { \
  46. struct wl1251 *wl = file->private_data; \
  47. char buf[buflen]; \
  48. int res; \
  49. \
  50. wl1251_debugfs_update_stats(wl); \
  51. \
  52. res = scnprintf(buf, buflen, fmt "\n", \
  53. wl->stats.fw_stats->sub.name); \
  54. return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
  55. } \
  56. \
  57. static const struct file_operations sub## _ ##name## _ops = { \
  58. .read = sub## _ ##name## _read, \
  59. .open = simple_open, \
  60. .llseek = generic_file_llseek, \
  61. };
  62. #define DEBUGFS_FWSTATS_ADD(sub, name) \
  63. DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)
  64. #define DEBUGFS_FWSTATS_DEL(sub, name) \
  65. DEBUGFS_DEL(sub## _ ##name)
  66. static void wl1251_debugfs_update_stats(struct wl1251 *wl)
  67. {
  68. int ret;
  69. mutex_lock(&wl->mutex);
  70. ret = wl1251_ps_elp_wakeup(wl);
  71. if (ret < 0)
  72. goto out;
  73. if (wl->state == WL1251_STATE_ON &&
  74. time_after(jiffies, wl->stats.fw_stats_update +
  75. msecs_to_jiffies(WL1251_DEBUGFS_STATS_LIFETIME))) {
  76. wl1251_acx_statistics(wl, wl->stats.fw_stats);
  77. wl->stats.fw_stats_update = jiffies;
  78. }
  79. wl1251_ps_elp_sleep(wl);
  80. out:
  81. mutex_unlock(&wl->mutex);
  82. }
  83. DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");
  84. DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
  85. DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u");
  86. DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u");
  87. DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u");
  88. DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u");
  89. DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u");
  90. DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u");
  91. DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u");
  92. DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u");
  93. DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u");
  94. DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u");
  95. DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u");
  96. DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u");
  97. DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u");
  98. DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u");
  99. DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u");
  100. DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u");
  101. DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u");
  102. DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u");
  103. DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u");
  104. DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u");
  105. DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u");
  106. DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u");
  107. DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u");
  108. DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u");
  109. DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u");
  110. DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u");
  111. DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u");
  112. DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u");
  113. DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u");
  114. DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u");
  115. DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u");
  116. /* skipping wep.reserved */
  117. DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u");
  118. DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u");
  119. DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u");
  120. DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u");
  121. DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u");
  122. DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u");
  123. DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u");
  124. DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u");
  125. DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u");
  126. DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u");
  127. DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u");
  128. DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u");
  129. DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u");
  130. DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u");
  131. DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u");
  132. DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u");
  133. /* skipping cont_miss_bcns_spread for now */
  134. DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u");
  135. DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u");
  136. DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u");
  137. DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u");
  138. DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u");
  139. DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u");
  140. DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u");
  141. DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u");
  142. DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u");
  143. DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u");
  144. DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u");
  145. DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u");
  146. DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u");
  147. DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u");
  148. DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u");
  149. DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u");
  150. DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u");
  151. DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u");
  152. DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u");
  153. DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u");
  154. DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u");
  155. DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u");
  156. DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u");
  157. DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u");
  158. DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u");
  159. DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u");
  160. DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
  161. 20, "%u");
  162. DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u");
  163. DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u");
  164. DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
  165. DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
  166. wl->stats.excessive_retries);
  167. static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
  168. size_t count, loff_t *ppos)
  169. {
  170. struct wl1251 *wl = file->private_data;
  171. u32 queue_len;
  172. char buf[20];
  173. int res;
  174. queue_len = skb_queue_len(&wl->tx_queue);
  175. res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
  176. return simple_read_from_buffer(userbuf, count, ppos, buf, res);
  177. }
  178. static const struct file_operations tx_queue_len_ops = {
  179. .read = tx_queue_len_read,
  180. .open = simple_open,
  181. .llseek = generic_file_llseek,
  182. };
  183. static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
  184. size_t count, loff_t *ppos)
  185. {
  186. struct wl1251 *wl = file->private_data;
  187. char buf[3], status;
  188. int len;
  189. if (wl->tx_queue_stopped)
  190. status = 's';
  191. else
  192. status = 'r';
  193. len = scnprintf(buf, sizeof(buf), "%c\n", status);
  194. return simple_read_from_buffer(userbuf, count, ppos, buf, len);
  195. }
  196. static const struct file_operations tx_queue_status_ops = {
  197. .read = tx_queue_status_read,
  198. .open = simple_open,
  199. .llseek = generic_file_llseek,
  200. };
  201. static void wl1251_debugfs_delete_files(struct wl1251 *wl)
  202. {
  203. DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
  204. DEBUGFS_FWSTATS_DEL(rx, out_of_mem);
  205. DEBUGFS_FWSTATS_DEL(rx, hdr_overflow);
  206. DEBUGFS_FWSTATS_DEL(rx, hw_stuck);
  207. DEBUGFS_FWSTATS_DEL(rx, dropped);
  208. DEBUGFS_FWSTATS_DEL(rx, fcs_err);
  209. DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig);
  210. DEBUGFS_FWSTATS_DEL(rx, path_reset);
  211. DEBUGFS_FWSTATS_DEL(rx, reset_counter);
  212. DEBUGFS_FWSTATS_DEL(dma, rx_requested);
  213. DEBUGFS_FWSTATS_DEL(dma, rx_errors);
  214. DEBUGFS_FWSTATS_DEL(dma, tx_requested);
  215. DEBUGFS_FWSTATS_DEL(dma, tx_errors);
  216. DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt);
  217. DEBUGFS_FWSTATS_DEL(isr, fiqs);
  218. DEBUGFS_FWSTATS_DEL(isr, rx_headers);
  219. DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow);
  220. DEBUGFS_FWSTATS_DEL(isr, rx_rdys);
  221. DEBUGFS_FWSTATS_DEL(isr, irqs);
  222. DEBUGFS_FWSTATS_DEL(isr, tx_procs);
  223. DEBUGFS_FWSTATS_DEL(isr, decrypt_done);
  224. DEBUGFS_FWSTATS_DEL(isr, dma0_done);
  225. DEBUGFS_FWSTATS_DEL(isr, dma1_done);
  226. DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete);
  227. DEBUGFS_FWSTATS_DEL(isr, commands);
  228. DEBUGFS_FWSTATS_DEL(isr, rx_procs);
  229. DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes);
  230. DEBUGFS_FWSTATS_DEL(isr, host_acknowledges);
  231. DEBUGFS_FWSTATS_DEL(isr, pci_pm);
  232. DEBUGFS_FWSTATS_DEL(isr, wakeups);
  233. DEBUGFS_FWSTATS_DEL(isr, low_rssi);
  234. DEBUGFS_FWSTATS_DEL(wep, addr_key_count);
  235. DEBUGFS_FWSTATS_DEL(wep, default_key_count);
  236. /* skipping wep.reserved */
  237. DEBUGFS_FWSTATS_DEL(wep, key_not_found);
  238. DEBUGFS_FWSTATS_DEL(wep, decrypt_fail);
  239. DEBUGFS_FWSTATS_DEL(wep, packets);
  240. DEBUGFS_FWSTATS_DEL(wep, interrupt);
  241. DEBUGFS_FWSTATS_DEL(pwr, ps_enter);
  242. DEBUGFS_FWSTATS_DEL(pwr, elp_enter);
  243. DEBUGFS_FWSTATS_DEL(pwr, missing_bcns);
  244. DEBUGFS_FWSTATS_DEL(pwr, wake_on_host);
  245. DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp);
  246. DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps);
  247. DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps);
  248. DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons);
  249. DEBUGFS_FWSTATS_DEL(pwr, power_save_off);
  250. DEBUGFS_FWSTATS_DEL(pwr, enable_ps);
  251. DEBUGFS_FWSTATS_DEL(pwr, disable_ps);
  252. DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps);
  253. /* skipping cont_miss_bcns_spread for now */
  254. DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons);
  255. DEBUGFS_FWSTATS_DEL(mic, rx_pkts);
  256. DEBUGFS_FWSTATS_DEL(mic, calc_failure);
  257. DEBUGFS_FWSTATS_DEL(aes, encrypt_fail);
  258. DEBUGFS_FWSTATS_DEL(aes, decrypt_fail);
  259. DEBUGFS_FWSTATS_DEL(aes, encrypt_packets);
  260. DEBUGFS_FWSTATS_DEL(aes, decrypt_packets);
  261. DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt);
  262. DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt);
  263. DEBUGFS_FWSTATS_DEL(event, heart_beat);
  264. DEBUGFS_FWSTATS_DEL(event, calibration);
  265. DEBUGFS_FWSTATS_DEL(event, rx_mismatch);
  266. DEBUGFS_FWSTATS_DEL(event, rx_mem_empty);
  267. DEBUGFS_FWSTATS_DEL(event, rx_pool);
  268. DEBUGFS_FWSTATS_DEL(event, oom_late);
  269. DEBUGFS_FWSTATS_DEL(event, phy_transmit_error);
  270. DEBUGFS_FWSTATS_DEL(event, tx_stuck);
  271. DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts);
  272. DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts);
  273. DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime);
  274. DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn);
  275. DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn);
  276. DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization);
  277. DEBUGFS_FWSTATS_DEL(ps, upsd_utilization);
  278. DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop);
  279. DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data);
  280. DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
  281. DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data);
  282. DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data);
  283. DEBUGFS_DEL(tx_queue_len);
  284. DEBUGFS_DEL(tx_queue_status);
  285. DEBUGFS_DEL(retry_count);
  286. DEBUGFS_DEL(excessive_retries);
  287. }
  288. static void wl1251_debugfs_add_files(struct wl1251 *wl)
  289. {
  290. DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
  291. DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
  292. DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
  293. DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
  294. DEBUGFS_FWSTATS_ADD(rx, dropped);
  295. DEBUGFS_FWSTATS_ADD(rx, fcs_err);
  296. DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
  297. DEBUGFS_FWSTATS_ADD(rx, path_reset);
  298. DEBUGFS_FWSTATS_ADD(rx, reset_counter);
  299. DEBUGFS_FWSTATS_ADD(dma, rx_requested);
  300. DEBUGFS_FWSTATS_ADD(dma, rx_errors);
  301. DEBUGFS_FWSTATS_ADD(dma, tx_requested);
  302. DEBUGFS_FWSTATS_ADD(dma, tx_errors);
  303. DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
  304. DEBUGFS_FWSTATS_ADD(isr, fiqs);
  305. DEBUGFS_FWSTATS_ADD(isr, rx_headers);
  306. DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
  307. DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
  308. DEBUGFS_FWSTATS_ADD(isr, irqs);
  309. DEBUGFS_FWSTATS_ADD(isr, tx_procs);
  310. DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
  311. DEBUGFS_FWSTATS_ADD(isr, dma0_done);
  312. DEBUGFS_FWSTATS_ADD(isr, dma1_done);
  313. DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
  314. DEBUGFS_FWSTATS_ADD(isr, commands);
  315. DEBUGFS_FWSTATS_ADD(isr, rx_procs);
  316. DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
  317. DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
  318. DEBUGFS_FWSTATS_ADD(isr, pci_pm);
  319. DEBUGFS_FWSTATS_ADD(isr, wakeups);
  320. DEBUGFS_FWSTATS_ADD(isr, low_rssi);
  321. DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
  322. DEBUGFS_FWSTATS_ADD(wep, default_key_count);
  323. /* skipping wep.reserved */
  324. DEBUGFS_FWSTATS_ADD(wep, key_not_found);
  325. DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
  326. DEBUGFS_FWSTATS_ADD(wep, packets);
  327. DEBUGFS_FWSTATS_ADD(wep, interrupt);
  328. DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
  329. DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
  330. DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
  331. DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
  332. DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
  333. DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
  334. DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
  335. DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
  336. DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
  337. DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
  338. DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
  339. DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
  340. /* skipping cont_miss_bcns_spread for now */
  341. DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
  342. DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
  343. DEBUGFS_FWSTATS_ADD(mic, calc_failure);
  344. DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
  345. DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
  346. DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
  347. DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
  348. DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
  349. DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
  350. DEBUGFS_FWSTATS_ADD(event, heart_beat);
  351. DEBUGFS_FWSTATS_ADD(event, calibration);
  352. DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
  353. DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
  354. DEBUGFS_FWSTATS_ADD(event, rx_pool);
  355. DEBUGFS_FWSTATS_ADD(event, oom_late);
  356. DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
  357. DEBUGFS_FWSTATS_ADD(event, tx_stuck);
  358. DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
  359. DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
  360. DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
  361. DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
  362. DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
  363. DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
  364. DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
  365. DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
  366. DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
  367. DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
  368. DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
  369. DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
  370. DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir);
  371. DEBUGFS_ADD(tx_queue_status, wl->debugfs.rootdir);
  372. DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
  373. DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
  374. }
  375. void wl1251_debugfs_reset(struct wl1251 *wl)
  376. {
  377. if (wl->stats.fw_stats != NULL)
  378. memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
  379. wl->stats.retry_count = 0;
  380. wl->stats.excessive_retries = 0;
  381. }
  382. int wl1251_debugfs_init(struct wl1251 *wl)
  383. {
  384. wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), GFP_KERNEL);
  385. if (!wl->stats.fw_stats)
  386. return -ENOMEM;
  387. wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
  388. wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics",
  389. wl->debugfs.rootdir);
  390. wl->stats.fw_stats_update = jiffies;
  391. wl1251_debugfs_add_files(wl);
  392. return 0;
  393. }
  394. void wl1251_debugfs_exit(struct wl1251 *wl)
  395. {
  396. wl1251_debugfs_delete_files(wl);
  397. kfree(wl->stats.fw_stats);
  398. wl->stats.fw_stats = NULL;
  399. debugfs_remove(wl->debugfs.fw_statistics);
  400. wl->debugfs.fw_statistics = NULL;
  401. debugfs_remove(wl->debugfs.rootdir);
  402. wl->debugfs.rootdir = NULL;
  403. }