wl1271_debugfs.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include "wl1271_debugfs.h"
  24. #include <linux/skbuff.h>
  25. #include "wl1271.h"
  26. #include "wl1271_acx.h"
  27. #include "wl1271_ps.h"
  28. /* ms */
  29. #define WL1271_DEBUGFS_STATS_LIFETIME 1000
  30. /* debugfs macros idea from mac80211 */
  31. #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
  32. static ssize_t name## _read(struct file *file, char __user *userbuf, \
  33. size_t count, loff_t *ppos) \
  34. { \
  35. struct wl1271 *wl = file->private_data; \
  36. char buf[buflen]; \
  37. int res; \
  38. \
  39. res = scnprintf(buf, buflen, fmt "\n", ##value); \
  40. return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
  41. } \
  42. \
  43. static const struct file_operations name## _ops = { \
  44. .read = name## _read, \
  45. .open = wl1271_open_file_generic, \
  46. };
  47. #define DEBUGFS_ADD(name, parent) \
  48. wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
  49. wl, &name## _ops); \
  50. if (IS_ERR(wl->debugfs.name)) { \
  51. ret = PTR_ERR(wl->debugfs.name); \
  52. wl->debugfs.name = NULL; \
  53. goto out; \
  54. }
  55. #define DEBUGFS_DEL(name) \
  56. do { \
  57. debugfs_remove(wl->debugfs.name); \
  58. wl->debugfs.name = NULL; \
  59. } while (0)
  60. #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \
  61. static ssize_t sub## _ ##name## _read(struct file *file, \
  62. char __user *userbuf, \
  63. size_t count, loff_t *ppos) \
  64. { \
  65. struct wl1271 *wl = file->private_data; \
  66. char buf[buflen]; \
  67. int res; \
  68. \
  69. wl1271_debugfs_update_stats(wl); \
  70. \
  71. res = scnprintf(buf, buflen, fmt "\n", \
  72. wl->stats.fw_stats->sub.name); \
  73. return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
  74. } \
  75. \
  76. static const struct file_operations sub## _ ##name## _ops = { \
  77. .read = sub## _ ##name## _read, \
  78. .open = wl1271_open_file_generic, \
  79. };
  80. #define DEBUGFS_FWSTATS_ADD(sub, name) \
  81. DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)
  82. #define DEBUGFS_FWSTATS_DEL(sub, name) \
  83. DEBUGFS_DEL(sub## _ ##name)
  84. static void wl1271_debugfs_update_stats(struct wl1271 *wl)
  85. {
  86. int ret;
  87. mutex_lock(&wl->mutex);
  88. ret = wl1271_ps_elp_wakeup(wl, false);
  89. if (ret < 0)
  90. goto out;
  91. if (wl->state == WL1271_STATE_ON &&
  92. time_after(jiffies, wl->stats.fw_stats_update +
  93. msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) {
  94. wl1271_acx_statistics(wl, wl->stats.fw_stats);
  95. wl->stats.fw_stats_update = jiffies;
  96. }
  97. wl1271_ps_elp_sleep(wl);
  98. out:
  99. mutex_unlock(&wl->mutex);
  100. }
  101. static int wl1271_open_file_generic(struct inode *inode, struct file *file)
  102. {
  103. file->private_data = inode->i_private;
  104. return 0;
  105. }
  106. DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");
  107. DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
  108. DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u");
  109. DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u");
  110. DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u");
  111. DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u");
  112. DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u");
  113. DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u");
  114. DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u");
  115. DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u");
  116. DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u");
  117. DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u");
  118. DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u");
  119. DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u");
  120. DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u");
  121. DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u");
  122. DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u");
  123. DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u");
  124. DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u");
  125. DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u");
  126. DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u");
  127. DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u");
  128. DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u");
  129. DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u");
  130. DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u");
  131. DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u");
  132. DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u");
  133. DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u");
  134. DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u");
  135. DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u");
  136. DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u");
  137. DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u");
  138. DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u");
  139. /* skipping wep.reserved */
  140. DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u");
  141. DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u");
  142. DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u");
  143. DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u");
  144. DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u");
  145. DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u");
  146. DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u");
  147. DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u");
  148. DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u");
  149. DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u");
  150. DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u");
  151. DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u");
  152. DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u");
  153. DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u");
  154. DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u");
  155. DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u");
  156. /* skipping cont_miss_bcns_spread for now */
  157. DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u");
  158. DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u");
  159. DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u");
  160. DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u");
  161. DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u");
  162. DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u");
  163. DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u");
  164. DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u");
  165. DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u");
  166. DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u");
  167. DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u");
  168. DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u");
  169. DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u");
  170. DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u");
  171. DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u");
  172. DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u");
  173. DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u");
  174. DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u");
  175. DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u");
  176. DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u");
  177. DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u");
  178. DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u");
  179. DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u");
  180. DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u");
  181. DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u");
  182. DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u");
  183. DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data,
  184. 20, "%u");
  185. DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u");
  186. DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u");
  187. DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
  188. DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
  189. wl->stats.excessive_retries);
  190. static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
  191. size_t count, loff_t *ppos)
  192. {
  193. struct wl1271 *wl = file->private_data;
  194. u32 queue_len;
  195. char buf[20];
  196. int res;
  197. queue_len = skb_queue_len(&wl->tx_queue);
  198. res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
  199. return simple_read_from_buffer(userbuf, count, ppos, buf, res);
  200. }
  201. static const struct file_operations tx_queue_len_ops = {
  202. .read = tx_queue_len_read,
  203. .open = wl1271_open_file_generic,
  204. };
  205. static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
  206. size_t count, loff_t *ppos)
  207. {
  208. struct wl1271 *wl = file->private_data;
  209. bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
  210. int res;
  211. char buf[10];
  212. res = scnprintf(buf, sizeof(buf), "%d\n", state);
  213. return simple_read_from_buffer(user_buf, count, ppos, buf, res);
  214. }
  215. static ssize_t gpio_power_write(struct file *file,
  216. const char __user *user_buf,
  217. size_t count, loff_t *ppos)
  218. {
  219. struct wl1271 *wl = file->private_data;
  220. char buf[10];
  221. size_t len;
  222. unsigned long value;
  223. int ret;
  224. mutex_lock(&wl->mutex);
  225. len = min(count, sizeof(buf) - 1);
  226. if (copy_from_user(buf, user_buf, len)) {
  227. ret = -EFAULT;
  228. goto out;
  229. }
  230. buf[len] = '\0';
  231. ret = strict_strtoul(buf, 0, &value);
  232. if (ret < 0) {
  233. wl1271_warning("illegal value in gpio_power");
  234. goto out;
  235. }
  236. if (value) {
  237. wl->set_power(true);
  238. set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
  239. } else {
  240. wl->set_power(false);
  241. clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
  242. }
  243. out:
  244. mutex_unlock(&wl->mutex);
  245. return count;
  246. }
  247. static const struct file_operations gpio_power_ops = {
  248. .read = gpio_power_read,
  249. .write = gpio_power_write,
  250. .open = wl1271_open_file_generic
  251. };
  252. static void wl1271_debugfs_delete_files(struct wl1271 *wl)
  253. {
  254. DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
  255. DEBUGFS_FWSTATS_DEL(rx, out_of_mem);
  256. DEBUGFS_FWSTATS_DEL(rx, hdr_overflow);
  257. DEBUGFS_FWSTATS_DEL(rx, hw_stuck);
  258. DEBUGFS_FWSTATS_DEL(rx, dropped);
  259. DEBUGFS_FWSTATS_DEL(rx, fcs_err);
  260. DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig);
  261. DEBUGFS_FWSTATS_DEL(rx, path_reset);
  262. DEBUGFS_FWSTATS_DEL(rx, reset_counter);
  263. DEBUGFS_FWSTATS_DEL(dma, rx_requested);
  264. DEBUGFS_FWSTATS_DEL(dma, rx_errors);
  265. DEBUGFS_FWSTATS_DEL(dma, tx_requested);
  266. DEBUGFS_FWSTATS_DEL(dma, tx_errors);
  267. DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt);
  268. DEBUGFS_FWSTATS_DEL(isr, fiqs);
  269. DEBUGFS_FWSTATS_DEL(isr, rx_headers);
  270. DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow);
  271. DEBUGFS_FWSTATS_DEL(isr, rx_rdys);
  272. DEBUGFS_FWSTATS_DEL(isr, irqs);
  273. DEBUGFS_FWSTATS_DEL(isr, tx_procs);
  274. DEBUGFS_FWSTATS_DEL(isr, decrypt_done);
  275. DEBUGFS_FWSTATS_DEL(isr, dma0_done);
  276. DEBUGFS_FWSTATS_DEL(isr, dma1_done);
  277. DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete);
  278. DEBUGFS_FWSTATS_DEL(isr, commands);
  279. DEBUGFS_FWSTATS_DEL(isr, rx_procs);
  280. DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes);
  281. DEBUGFS_FWSTATS_DEL(isr, host_acknowledges);
  282. DEBUGFS_FWSTATS_DEL(isr, pci_pm);
  283. DEBUGFS_FWSTATS_DEL(isr, wakeups);
  284. DEBUGFS_FWSTATS_DEL(isr, low_rssi);
  285. DEBUGFS_FWSTATS_DEL(wep, addr_key_count);
  286. DEBUGFS_FWSTATS_DEL(wep, default_key_count);
  287. /* skipping wep.reserved */
  288. DEBUGFS_FWSTATS_DEL(wep, key_not_found);
  289. DEBUGFS_FWSTATS_DEL(wep, decrypt_fail);
  290. DEBUGFS_FWSTATS_DEL(wep, packets);
  291. DEBUGFS_FWSTATS_DEL(wep, interrupt);
  292. DEBUGFS_FWSTATS_DEL(pwr, ps_enter);
  293. DEBUGFS_FWSTATS_DEL(pwr, elp_enter);
  294. DEBUGFS_FWSTATS_DEL(pwr, missing_bcns);
  295. DEBUGFS_FWSTATS_DEL(pwr, wake_on_host);
  296. DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp);
  297. DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps);
  298. DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps);
  299. DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons);
  300. DEBUGFS_FWSTATS_DEL(pwr, power_save_off);
  301. DEBUGFS_FWSTATS_DEL(pwr, enable_ps);
  302. DEBUGFS_FWSTATS_DEL(pwr, disable_ps);
  303. DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps);
  304. /* skipping cont_miss_bcns_spread for now */
  305. DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons);
  306. DEBUGFS_FWSTATS_DEL(mic, rx_pkts);
  307. DEBUGFS_FWSTATS_DEL(mic, calc_failure);
  308. DEBUGFS_FWSTATS_DEL(aes, encrypt_fail);
  309. DEBUGFS_FWSTATS_DEL(aes, decrypt_fail);
  310. DEBUGFS_FWSTATS_DEL(aes, encrypt_packets);
  311. DEBUGFS_FWSTATS_DEL(aes, decrypt_packets);
  312. DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt);
  313. DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt);
  314. DEBUGFS_FWSTATS_DEL(event, heart_beat);
  315. DEBUGFS_FWSTATS_DEL(event, calibration);
  316. DEBUGFS_FWSTATS_DEL(event, rx_mismatch);
  317. DEBUGFS_FWSTATS_DEL(event, rx_mem_empty);
  318. DEBUGFS_FWSTATS_DEL(event, rx_pool);
  319. DEBUGFS_FWSTATS_DEL(event, oom_late);
  320. DEBUGFS_FWSTATS_DEL(event, phy_transmit_error);
  321. DEBUGFS_FWSTATS_DEL(event, tx_stuck);
  322. DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts);
  323. DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts);
  324. DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime);
  325. DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn);
  326. DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn);
  327. DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization);
  328. DEBUGFS_FWSTATS_DEL(ps, upsd_utilization);
  329. DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop);
  330. DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data);
  331. DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
  332. DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data);
  333. DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data);
  334. DEBUGFS_DEL(tx_queue_len);
  335. DEBUGFS_DEL(retry_count);
  336. DEBUGFS_DEL(excessive_retries);
  337. DEBUGFS_DEL(gpio_power);
  338. }
  339. static int wl1271_debugfs_add_files(struct wl1271 *wl)
  340. {
  341. int ret = 0;
  342. DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
  343. DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
  344. DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
  345. DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
  346. DEBUGFS_FWSTATS_ADD(rx, dropped);
  347. DEBUGFS_FWSTATS_ADD(rx, fcs_err);
  348. DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
  349. DEBUGFS_FWSTATS_ADD(rx, path_reset);
  350. DEBUGFS_FWSTATS_ADD(rx, reset_counter);
  351. DEBUGFS_FWSTATS_ADD(dma, rx_requested);
  352. DEBUGFS_FWSTATS_ADD(dma, rx_errors);
  353. DEBUGFS_FWSTATS_ADD(dma, tx_requested);
  354. DEBUGFS_FWSTATS_ADD(dma, tx_errors);
  355. DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
  356. DEBUGFS_FWSTATS_ADD(isr, fiqs);
  357. DEBUGFS_FWSTATS_ADD(isr, rx_headers);
  358. DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
  359. DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
  360. DEBUGFS_FWSTATS_ADD(isr, irqs);
  361. DEBUGFS_FWSTATS_ADD(isr, tx_procs);
  362. DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
  363. DEBUGFS_FWSTATS_ADD(isr, dma0_done);
  364. DEBUGFS_FWSTATS_ADD(isr, dma1_done);
  365. DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
  366. DEBUGFS_FWSTATS_ADD(isr, commands);
  367. DEBUGFS_FWSTATS_ADD(isr, rx_procs);
  368. DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
  369. DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
  370. DEBUGFS_FWSTATS_ADD(isr, pci_pm);
  371. DEBUGFS_FWSTATS_ADD(isr, wakeups);
  372. DEBUGFS_FWSTATS_ADD(isr, low_rssi);
  373. DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
  374. DEBUGFS_FWSTATS_ADD(wep, default_key_count);
  375. /* skipping wep.reserved */
  376. DEBUGFS_FWSTATS_ADD(wep, key_not_found);
  377. DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
  378. DEBUGFS_FWSTATS_ADD(wep, packets);
  379. DEBUGFS_FWSTATS_ADD(wep, interrupt);
  380. DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
  381. DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
  382. DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
  383. DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
  384. DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
  385. DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
  386. DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
  387. DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
  388. DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
  389. DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
  390. DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
  391. DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
  392. /* skipping cont_miss_bcns_spread for now */
  393. DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
  394. DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
  395. DEBUGFS_FWSTATS_ADD(mic, calc_failure);
  396. DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
  397. DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
  398. DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
  399. DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
  400. DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
  401. DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
  402. DEBUGFS_FWSTATS_ADD(event, heart_beat);
  403. DEBUGFS_FWSTATS_ADD(event, calibration);
  404. DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
  405. DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
  406. DEBUGFS_FWSTATS_ADD(event, rx_pool);
  407. DEBUGFS_FWSTATS_ADD(event, oom_late);
  408. DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
  409. DEBUGFS_FWSTATS_ADD(event, tx_stuck);
  410. DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
  411. DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
  412. DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
  413. DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
  414. DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
  415. DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
  416. DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
  417. DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
  418. DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
  419. DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
  420. DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
  421. DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
  422. DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir);
  423. DEBUGFS_ADD(retry_count, wl->debugfs.rootdir);
  424. DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir);
  425. DEBUGFS_ADD(gpio_power, wl->debugfs.rootdir);
  426. out:
  427. if (ret < 0)
  428. wl1271_debugfs_delete_files(wl);
  429. return ret;
  430. }
  431. void wl1271_debugfs_reset(struct wl1271 *wl)
  432. {
  433. memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
  434. wl->stats.retry_count = 0;
  435. wl->stats.excessive_retries = 0;
  436. }
  437. int wl1271_debugfs_init(struct wl1271 *wl)
  438. {
  439. int ret;
  440. wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
  441. if (IS_ERR(wl->debugfs.rootdir)) {
  442. ret = PTR_ERR(wl->debugfs.rootdir);
  443. wl->debugfs.rootdir = NULL;
  444. goto err;
  445. }
  446. wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics",
  447. wl->debugfs.rootdir);
  448. if (IS_ERR(wl->debugfs.fw_statistics)) {
  449. ret = PTR_ERR(wl->debugfs.fw_statistics);
  450. wl->debugfs.fw_statistics = NULL;
  451. goto err_root;
  452. }
  453. wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
  454. GFP_KERNEL);
  455. if (!wl->stats.fw_stats) {
  456. ret = -ENOMEM;
  457. goto err_fw;
  458. }
  459. wl->stats.fw_stats_update = jiffies;
  460. ret = wl1271_debugfs_add_files(wl);
  461. if (ret < 0)
  462. goto err_file;
  463. return 0;
  464. err_file:
  465. kfree(wl->stats.fw_stats);
  466. wl->stats.fw_stats = NULL;
  467. err_fw:
  468. debugfs_remove(wl->debugfs.fw_statistics);
  469. wl->debugfs.fw_statistics = NULL;
  470. err_root:
  471. debugfs_remove(wl->debugfs.rootdir);
  472. wl->debugfs.rootdir = NULL;
  473. err:
  474. return ret;
  475. }
  476. void wl1271_debugfs_exit(struct wl1271 *wl)
  477. {
  478. wl1271_debugfs_delete_files(wl);
  479. kfree(wl->stats.fw_stats);
  480. wl->stats.fw_stats = NULL;
  481. debugfs_remove(wl->debugfs.fw_statistics);
  482. wl->debugfs.fw_statistics = NULL;
  483. debugfs_remove(wl->debugfs.rootdir);
  484. wl->debugfs.rootdir = NULL;
  485. }