debugfs.c 18 KB

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