debugfs.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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 "wlcore.h"
  27. #include "debug.h"
  28. #include "acx.h"
  29. #include "ps.h"
  30. #include "io.h"
  31. #include "tx.h"
  32. /* ms */
  33. #define WL1271_DEBUGFS_STATS_LIFETIME 1000
  34. /* debugfs macros idea from mac80211 */
  35. #define DEBUGFS_FORMAT_BUFFER_SIZE 100
  36. static int wl1271_format_buffer(char __user *userbuf, size_t count,
  37. loff_t *ppos, char *fmt, ...)
  38. {
  39. va_list args;
  40. char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
  41. int res;
  42. va_start(args, fmt);
  43. res = vscnprintf(buf, sizeof(buf), fmt, args);
  44. va_end(args);
  45. return simple_read_from_buffer(userbuf, count, ppos, buf, res);
  46. }
  47. #define DEBUGFS_READONLY_FILE(name, fmt, value...) \
  48. static ssize_t name## _read(struct file *file, char __user *userbuf, \
  49. size_t count, loff_t *ppos) \
  50. { \
  51. struct wl1271 *wl = file->private_data; \
  52. return wl1271_format_buffer(userbuf, count, ppos, \
  53. fmt "\n", ##value); \
  54. } \
  55. \
  56. static const struct file_operations name## _ops = { \
  57. .read = name## _read, \
  58. .open = simple_open, \
  59. .llseek = generic_file_llseek, \
  60. };
  61. #define DEBUGFS_ADD(name, parent) \
  62. entry = debugfs_create_file(#name, 0400, parent, \
  63. wl, &name## _ops); \
  64. if (!entry || IS_ERR(entry)) \
  65. goto err; \
  66. #define DEBUGFS_ADD_PREFIX(prefix, name, parent) \
  67. do { \
  68. entry = debugfs_create_file(#name, 0400, parent, \
  69. wl, &prefix## _## name## _ops); \
  70. if (!entry || IS_ERR(entry)) \
  71. goto err; \
  72. } while (0);
  73. #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \
  74. static ssize_t sub## _ ##name## _read(struct file *file, \
  75. char __user *userbuf, \
  76. size_t count, loff_t *ppos) \
  77. { \
  78. struct wl1271 *wl = file->private_data; \
  79. \
  80. wl1271_debugfs_update_stats(wl); \
  81. \
  82. return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \
  83. wl->stats.fw_stats->sub.name); \
  84. } \
  85. \
  86. static const struct file_operations sub## _ ##name## _ops = { \
  87. .read = sub## _ ##name## _read, \
  88. .open = simple_open, \
  89. .llseek = generic_file_llseek, \
  90. };
  91. #define DEBUGFS_FWSTATS_ADD(sub, name) \
  92. DEBUGFS_ADD(sub## _ ##name, stats)
  93. static void wl1271_debugfs_update_stats(struct wl1271 *wl)
  94. {
  95. int ret;
  96. mutex_lock(&wl->mutex);
  97. ret = wl1271_ps_elp_wakeup(wl);
  98. if (ret < 0)
  99. goto out;
  100. if (wl->state == WL1271_STATE_ON && !wl->plt &&
  101. time_after(jiffies, wl->stats.fw_stats_update +
  102. msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) {
  103. wl1271_acx_statistics(wl, wl->stats.fw_stats);
  104. wl->stats.fw_stats_update = jiffies;
  105. }
  106. wl1271_ps_elp_sleep(wl);
  107. out:
  108. mutex_unlock(&wl->mutex);
  109. }
  110. DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u");
  111. DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u");
  112. DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u");
  113. DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u");
  114. DEBUGFS_FWSTATS_FILE(rx, dropped, "%u");
  115. DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u");
  116. DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u");
  117. DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u");
  118. DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u");
  119. DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u");
  120. DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u");
  121. DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u");
  122. DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u");
  123. DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u");
  124. DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u");
  125. DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u");
  126. DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u");
  127. DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u");
  128. DEBUGFS_FWSTATS_FILE(isr, irqs, "%u");
  129. DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u");
  130. DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u");
  131. DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u");
  132. DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u");
  133. DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u");
  134. DEBUGFS_FWSTATS_FILE(isr, commands, "%u");
  135. DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u");
  136. DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u");
  137. DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u");
  138. DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u");
  139. DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u");
  140. DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u");
  141. DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u");
  142. DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u");
  143. /* skipping wep.reserved */
  144. DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u");
  145. DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u");
  146. DEBUGFS_FWSTATS_FILE(wep, packets, "%u");
  147. DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u");
  148. DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u");
  149. DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u");
  150. DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u");
  151. DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u");
  152. DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u");
  153. DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u");
  154. DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u");
  155. DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u");
  156. DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u");
  157. DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u");
  158. DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u");
  159. DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u");
  160. /* skipping cont_miss_bcns_spread for now */
  161. DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u");
  162. DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u");
  163. DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u");
  164. DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u");
  165. DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u");
  166. DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u");
  167. DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u");
  168. DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u");
  169. DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u");
  170. DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u");
  171. DEBUGFS_FWSTATS_FILE(event, calibration, "%u");
  172. DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u");
  173. DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u");
  174. DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u");
  175. DEBUGFS_FWSTATS_FILE(event, oom_late, "%u");
  176. DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u");
  177. DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u");
  178. DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u");
  179. DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u");
  180. DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u");
  181. DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u");
  182. DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u");
  183. DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u");
  184. DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u");
  185. DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u");
  186. DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u");
  187. DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, "%u");
  188. DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u");
  189. DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u");
  190. DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count);
  191. DEBUGFS_READONLY_FILE(excessive_retries, "%u",
  192. wl->stats.excessive_retries);
  193. static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
  194. size_t count, loff_t *ppos)
  195. {
  196. struct wl1271 *wl = file->private_data;
  197. u32 queue_len;
  198. char buf[20];
  199. int res;
  200. queue_len = wl1271_tx_total_queue_count(wl);
  201. res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
  202. return simple_read_from_buffer(userbuf, count, ppos, buf, res);
  203. }
  204. static const struct file_operations tx_queue_len_ops = {
  205. .read = tx_queue_len_read,
  206. .open = simple_open,
  207. .llseek = default_llseek,
  208. };
  209. static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
  210. size_t count, loff_t *ppos)
  211. {
  212. struct wl1271 *wl = file->private_data;
  213. bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
  214. int res;
  215. char buf[10];
  216. res = scnprintf(buf, sizeof(buf), "%d\n", state);
  217. return simple_read_from_buffer(user_buf, count, ppos, buf, res);
  218. }
  219. static ssize_t gpio_power_write(struct file *file,
  220. const char __user *user_buf,
  221. size_t count, loff_t *ppos)
  222. {
  223. struct wl1271 *wl = file->private_data;
  224. unsigned long value;
  225. int ret;
  226. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  227. if (ret < 0) {
  228. wl1271_warning("illegal value in gpio_power");
  229. return -EINVAL;
  230. }
  231. mutex_lock(&wl->mutex);
  232. if (value)
  233. wl1271_power_on(wl);
  234. else
  235. wl1271_power_off(wl);
  236. mutex_unlock(&wl->mutex);
  237. return count;
  238. }
  239. static const struct file_operations gpio_power_ops = {
  240. .read = gpio_power_read,
  241. .write = gpio_power_write,
  242. .open = simple_open,
  243. .llseek = default_llseek,
  244. };
  245. static ssize_t start_recovery_write(struct file *file,
  246. const char __user *user_buf,
  247. size_t count, loff_t *ppos)
  248. {
  249. struct wl1271 *wl = file->private_data;
  250. mutex_lock(&wl->mutex);
  251. wl12xx_queue_recovery_work(wl);
  252. mutex_unlock(&wl->mutex);
  253. return count;
  254. }
  255. static const struct file_operations start_recovery_ops = {
  256. .write = start_recovery_write,
  257. .open = simple_open,
  258. .llseek = default_llseek,
  259. };
  260. static ssize_t dynamic_ps_timeout_read(struct file *file, char __user *user_buf,
  261. size_t count, loff_t *ppos)
  262. {
  263. struct wl1271 *wl = file->private_data;
  264. return wl1271_format_buffer(user_buf, count,
  265. ppos, "%d\n",
  266. wl->conf.conn.dynamic_ps_timeout);
  267. }
  268. static ssize_t dynamic_ps_timeout_write(struct file *file,
  269. const char __user *user_buf,
  270. size_t count, loff_t *ppos)
  271. {
  272. struct wl1271 *wl = file->private_data;
  273. struct wl12xx_vif *wlvif;
  274. unsigned long value;
  275. int ret;
  276. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  277. if (ret < 0) {
  278. wl1271_warning("illegal value in dynamic_ps");
  279. return -EINVAL;
  280. }
  281. if (value < 1 || value > 65535) {
  282. wl1271_warning("dyanmic_ps_timeout is not in valid range");
  283. return -ERANGE;
  284. }
  285. mutex_lock(&wl->mutex);
  286. wl->conf.conn.dynamic_ps_timeout = value;
  287. if (wl->state == WL1271_STATE_OFF)
  288. goto out;
  289. ret = wl1271_ps_elp_wakeup(wl);
  290. if (ret < 0)
  291. goto out;
  292. /* In case we're already in PSM, trigger it again to set new timeout
  293. * immediately without waiting for re-association
  294. */
  295. wl12xx_for_each_wlvif_sta(wl, wlvif) {
  296. if (test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags))
  297. wl1271_ps_set_mode(wl, wlvif, STATION_AUTO_PS_MODE);
  298. }
  299. wl1271_ps_elp_sleep(wl);
  300. out:
  301. mutex_unlock(&wl->mutex);
  302. return count;
  303. }
  304. static const struct file_operations dynamic_ps_timeout_ops = {
  305. .read = dynamic_ps_timeout_read,
  306. .write = dynamic_ps_timeout_write,
  307. .open = simple_open,
  308. .llseek = default_llseek,
  309. };
  310. static ssize_t forced_ps_read(struct file *file, char __user *user_buf,
  311. size_t count, loff_t *ppos)
  312. {
  313. struct wl1271 *wl = file->private_data;
  314. return wl1271_format_buffer(user_buf, count,
  315. ppos, "%d\n",
  316. wl->conf.conn.forced_ps);
  317. }
  318. static ssize_t forced_ps_write(struct file *file,
  319. const char __user *user_buf,
  320. size_t count, loff_t *ppos)
  321. {
  322. struct wl1271 *wl = file->private_data;
  323. struct wl12xx_vif *wlvif;
  324. unsigned long value;
  325. int ret, ps_mode;
  326. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  327. if (ret < 0) {
  328. wl1271_warning("illegal value in forced_ps");
  329. return -EINVAL;
  330. }
  331. if (value != 1 && value != 0) {
  332. wl1271_warning("forced_ps should be either 0 or 1");
  333. return -ERANGE;
  334. }
  335. mutex_lock(&wl->mutex);
  336. if (wl->conf.conn.forced_ps == value)
  337. goto out;
  338. wl->conf.conn.forced_ps = value;
  339. if (wl->state == WL1271_STATE_OFF)
  340. goto out;
  341. ret = wl1271_ps_elp_wakeup(wl);
  342. if (ret < 0)
  343. goto out;
  344. /* In case we're already in PSM, trigger it again to switch mode
  345. * immediately without waiting for re-association
  346. */
  347. ps_mode = value ? STATION_POWER_SAVE_MODE : STATION_AUTO_PS_MODE;
  348. wl12xx_for_each_wlvif_sta(wl, wlvif) {
  349. if (test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags))
  350. wl1271_ps_set_mode(wl, wlvif, ps_mode);
  351. }
  352. wl1271_ps_elp_sleep(wl);
  353. out:
  354. mutex_unlock(&wl->mutex);
  355. return count;
  356. }
  357. static const struct file_operations forced_ps_ops = {
  358. .read = forced_ps_read,
  359. .write = forced_ps_write,
  360. .open = simple_open,
  361. .llseek = default_llseek,
  362. };
  363. static ssize_t split_scan_timeout_read(struct file *file, char __user *user_buf,
  364. size_t count, loff_t *ppos)
  365. {
  366. struct wl1271 *wl = file->private_data;
  367. return wl1271_format_buffer(user_buf, count,
  368. ppos, "%d\n",
  369. wl->conf.scan.split_scan_timeout / 1000);
  370. }
  371. static ssize_t split_scan_timeout_write(struct file *file,
  372. const char __user *user_buf,
  373. size_t count, loff_t *ppos)
  374. {
  375. struct wl1271 *wl = file->private_data;
  376. unsigned long value;
  377. int ret;
  378. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  379. if (ret < 0) {
  380. wl1271_warning("illegal value in split_scan_timeout");
  381. return -EINVAL;
  382. }
  383. if (value == 0)
  384. wl1271_info("split scan will be disabled");
  385. mutex_lock(&wl->mutex);
  386. wl->conf.scan.split_scan_timeout = value * 1000;
  387. mutex_unlock(&wl->mutex);
  388. return count;
  389. }
  390. static const struct file_operations split_scan_timeout_ops = {
  391. .read = split_scan_timeout_read,
  392. .write = split_scan_timeout_write,
  393. .open = simple_open,
  394. .llseek = default_llseek,
  395. };
  396. static ssize_t driver_state_read(struct file *file, char __user *user_buf,
  397. size_t count, loff_t *ppos)
  398. {
  399. struct wl1271 *wl = file->private_data;
  400. int res = 0;
  401. ssize_t ret;
  402. char *buf;
  403. #define DRIVER_STATE_BUF_LEN 1024
  404. buf = kmalloc(DRIVER_STATE_BUF_LEN, GFP_KERNEL);
  405. if (!buf)
  406. return -ENOMEM;
  407. mutex_lock(&wl->mutex);
  408. #define DRIVER_STATE_PRINT(x, fmt) \
  409. (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
  410. #x " = " fmt "\n", wl->x))
  411. #define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld")
  412. #define DRIVER_STATE_PRINT_INT(x) DRIVER_STATE_PRINT(x, "%d")
  413. #define DRIVER_STATE_PRINT_STR(x) DRIVER_STATE_PRINT(x, "%s")
  414. #define DRIVER_STATE_PRINT_LHEX(x) DRIVER_STATE_PRINT(x, "0x%lx")
  415. #define DRIVER_STATE_PRINT_HEX(x) DRIVER_STATE_PRINT(x, "0x%x")
  416. DRIVER_STATE_PRINT_INT(tx_blocks_available);
  417. DRIVER_STATE_PRINT_INT(tx_allocated_blocks);
  418. DRIVER_STATE_PRINT_INT(tx_allocated_pkts[0]);
  419. DRIVER_STATE_PRINT_INT(tx_allocated_pkts[1]);
  420. DRIVER_STATE_PRINT_INT(tx_allocated_pkts[2]);
  421. DRIVER_STATE_PRINT_INT(tx_allocated_pkts[3]);
  422. DRIVER_STATE_PRINT_INT(tx_frames_cnt);
  423. DRIVER_STATE_PRINT_LHEX(tx_frames_map[0]);
  424. DRIVER_STATE_PRINT_INT(tx_queue_count[0]);
  425. DRIVER_STATE_PRINT_INT(tx_queue_count[1]);
  426. DRIVER_STATE_PRINT_INT(tx_queue_count[2]);
  427. DRIVER_STATE_PRINT_INT(tx_queue_count[3]);
  428. DRIVER_STATE_PRINT_INT(tx_packets_count);
  429. DRIVER_STATE_PRINT_INT(tx_results_count);
  430. DRIVER_STATE_PRINT_LHEX(flags);
  431. DRIVER_STATE_PRINT_INT(tx_blocks_freed);
  432. DRIVER_STATE_PRINT_INT(rx_counter);
  433. DRIVER_STATE_PRINT_INT(state);
  434. DRIVER_STATE_PRINT_INT(channel);
  435. DRIVER_STATE_PRINT_INT(band);
  436. DRIVER_STATE_PRINT_INT(power_level);
  437. DRIVER_STATE_PRINT_INT(sg_enabled);
  438. DRIVER_STATE_PRINT_INT(enable_11a);
  439. DRIVER_STATE_PRINT_INT(noise);
  440. DRIVER_STATE_PRINT_HEX(ap_fw_ps_map);
  441. DRIVER_STATE_PRINT_LHEX(ap_ps_map);
  442. DRIVER_STATE_PRINT_HEX(quirks);
  443. DRIVER_STATE_PRINT_HEX(irq);
  444. DRIVER_STATE_PRINT_HEX(ref_clock);
  445. DRIVER_STATE_PRINT_HEX(tcxo_clock);
  446. DRIVER_STATE_PRINT_HEX(hw_pg_ver);
  447. DRIVER_STATE_PRINT_HEX(platform_quirks);
  448. DRIVER_STATE_PRINT_HEX(chip.id);
  449. DRIVER_STATE_PRINT_STR(chip.fw_ver_str);
  450. DRIVER_STATE_PRINT_INT(sched_scanning);
  451. #undef DRIVER_STATE_PRINT_INT
  452. #undef DRIVER_STATE_PRINT_LONG
  453. #undef DRIVER_STATE_PRINT_HEX
  454. #undef DRIVER_STATE_PRINT_LHEX
  455. #undef DRIVER_STATE_PRINT_STR
  456. #undef DRIVER_STATE_PRINT
  457. #undef DRIVER_STATE_BUF_LEN
  458. mutex_unlock(&wl->mutex);
  459. ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
  460. kfree(buf);
  461. return ret;
  462. }
  463. static const struct file_operations driver_state_ops = {
  464. .read = driver_state_read,
  465. .open = simple_open,
  466. .llseek = default_llseek,
  467. };
  468. static ssize_t vifs_state_read(struct file *file, char __user *user_buf,
  469. size_t count, loff_t *ppos)
  470. {
  471. struct wl1271 *wl = file->private_data;
  472. struct wl12xx_vif *wlvif;
  473. int ret, res = 0;
  474. const int buf_size = 4096;
  475. char *buf;
  476. char tmp_buf[64];
  477. buf = kzalloc(buf_size, GFP_KERNEL);
  478. if (!buf)
  479. return -ENOMEM;
  480. mutex_lock(&wl->mutex);
  481. #define VIF_STATE_PRINT(x, fmt) \
  482. (res += scnprintf(buf + res, buf_size - res, \
  483. #x " = " fmt "\n", wlvif->x))
  484. #define VIF_STATE_PRINT_LONG(x) VIF_STATE_PRINT(x, "%ld")
  485. #define VIF_STATE_PRINT_INT(x) VIF_STATE_PRINT(x, "%d")
  486. #define VIF_STATE_PRINT_STR(x) VIF_STATE_PRINT(x, "%s")
  487. #define VIF_STATE_PRINT_LHEX(x) VIF_STATE_PRINT(x, "0x%lx")
  488. #define VIF_STATE_PRINT_LLHEX(x) VIF_STATE_PRINT(x, "0x%llx")
  489. #define VIF_STATE_PRINT_HEX(x) VIF_STATE_PRINT(x, "0x%x")
  490. #define VIF_STATE_PRINT_NSTR(x, len) \
  491. do { \
  492. memset(tmp_buf, 0, sizeof(tmp_buf)); \
  493. memcpy(tmp_buf, wlvif->x, \
  494. min_t(u8, len, sizeof(tmp_buf) - 1)); \
  495. res += scnprintf(buf + res, buf_size - res, \
  496. #x " = %s\n", tmp_buf); \
  497. } while (0)
  498. wl12xx_for_each_wlvif(wl, wlvif) {
  499. VIF_STATE_PRINT_INT(role_id);
  500. VIF_STATE_PRINT_INT(bss_type);
  501. VIF_STATE_PRINT_LHEX(flags);
  502. VIF_STATE_PRINT_INT(p2p);
  503. VIF_STATE_PRINT_INT(dev_role_id);
  504. VIF_STATE_PRINT_INT(dev_hlid);
  505. if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
  506. wlvif->bss_type == BSS_TYPE_IBSS) {
  507. VIF_STATE_PRINT_INT(sta.hlid);
  508. VIF_STATE_PRINT_INT(sta.ba_rx_bitmap);
  509. VIF_STATE_PRINT_INT(sta.basic_rate_idx);
  510. VIF_STATE_PRINT_INT(sta.ap_rate_idx);
  511. VIF_STATE_PRINT_INT(sta.p2p_rate_idx);
  512. VIF_STATE_PRINT_INT(sta.qos);
  513. } else {
  514. VIF_STATE_PRINT_INT(ap.global_hlid);
  515. VIF_STATE_PRINT_INT(ap.bcast_hlid);
  516. VIF_STATE_PRINT_LHEX(ap.sta_hlid_map[0]);
  517. VIF_STATE_PRINT_INT(ap.mgmt_rate_idx);
  518. VIF_STATE_PRINT_INT(ap.bcast_rate_idx);
  519. VIF_STATE_PRINT_INT(ap.ucast_rate_idx[0]);
  520. VIF_STATE_PRINT_INT(ap.ucast_rate_idx[1]);
  521. VIF_STATE_PRINT_INT(ap.ucast_rate_idx[2]);
  522. VIF_STATE_PRINT_INT(ap.ucast_rate_idx[3]);
  523. }
  524. VIF_STATE_PRINT_INT(last_tx_hlid);
  525. VIF_STATE_PRINT_LHEX(links_map[0]);
  526. VIF_STATE_PRINT_NSTR(ssid, wlvif->ssid_len);
  527. VIF_STATE_PRINT_INT(band);
  528. VIF_STATE_PRINT_INT(channel);
  529. VIF_STATE_PRINT_HEX(bitrate_masks[0]);
  530. VIF_STATE_PRINT_HEX(bitrate_masks[1]);
  531. VIF_STATE_PRINT_HEX(basic_rate_set);
  532. VIF_STATE_PRINT_HEX(basic_rate);
  533. VIF_STATE_PRINT_HEX(rate_set);
  534. VIF_STATE_PRINT_INT(beacon_int);
  535. VIF_STATE_PRINT_INT(default_key);
  536. VIF_STATE_PRINT_INT(aid);
  537. VIF_STATE_PRINT_INT(session_counter);
  538. VIF_STATE_PRINT_INT(psm_entry_retry);
  539. VIF_STATE_PRINT_INT(power_level);
  540. VIF_STATE_PRINT_INT(rssi_thold);
  541. VIF_STATE_PRINT_INT(last_rssi_event);
  542. VIF_STATE_PRINT_INT(ba_support);
  543. VIF_STATE_PRINT_INT(ba_allowed);
  544. VIF_STATE_PRINT_INT(is_gem);
  545. VIF_STATE_PRINT_LLHEX(tx_security_seq);
  546. VIF_STATE_PRINT_INT(tx_security_last_seq_lsb);
  547. }
  548. #undef VIF_STATE_PRINT_INT
  549. #undef VIF_STATE_PRINT_LONG
  550. #undef VIF_STATE_PRINT_HEX
  551. #undef VIF_STATE_PRINT_LHEX
  552. #undef VIF_STATE_PRINT_LLHEX
  553. #undef VIF_STATE_PRINT_STR
  554. #undef VIF_STATE_PRINT_NSTR
  555. #undef VIF_STATE_PRINT
  556. mutex_unlock(&wl->mutex);
  557. ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
  558. kfree(buf);
  559. return ret;
  560. }
  561. static const struct file_operations vifs_state_ops = {
  562. .read = vifs_state_read,
  563. .open = simple_open,
  564. .llseek = default_llseek,
  565. };
  566. static ssize_t dtim_interval_read(struct file *file, char __user *user_buf,
  567. size_t count, loff_t *ppos)
  568. {
  569. struct wl1271 *wl = file->private_data;
  570. u8 value;
  571. if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
  572. wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM)
  573. value = wl->conf.conn.listen_interval;
  574. else
  575. value = 0;
  576. return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
  577. }
  578. static ssize_t dtim_interval_write(struct file *file,
  579. const char __user *user_buf,
  580. size_t count, loff_t *ppos)
  581. {
  582. struct wl1271 *wl = file->private_data;
  583. unsigned long value;
  584. int ret;
  585. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  586. if (ret < 0) {
  587. wl1271_warning("illegal value for dtim_interval");
  588. return -EINVAL;
  589. }
  590. if (value < 1 || value > 10) {
  591. wl1271_warning("dtim value is not in valid range");
  592. return -ERANGE;
  593. }
  594. mutex_lock(&wl->mutex);
  595. wl->conf.conn.listen_interval = value;
  596. /* for some reason there are different event types for 1 and >1 */
  597. if (value == 1)
  598. wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_DTIM;
  599. else
  600. wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM;
  601. /*
  602. * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only
  603. * take effect on the next time we enter psm.
  604. */
  605. mutex_unlock(&wl->mutex);
  606. return count;
  607. }
  608. static const struct file_operations dtim_interval_ops = {
  609. .read = dtim_interval_read,
  610. .write = dtim_interval_write,
  611. .open = simple_open,
  612. .llseek = default_llseek,
  613. };
  614. static ssize_t suspend_dtim_interval_read(struct file *file,
  615. char __user *user_buf,
  616. size_t count, loff_t *ppos)
  617. {
  618. struct wl1271 *wl = file->private_data;
  619. u8 value;
  620. if (wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
  621. wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM)
  622. value = wl->conf.conn.suspend_listen_interval;
  623. else
  624. value = 0;
  625. return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
  626. }
  627. static ssize_t suspend_dtim_interval_write(struct file *file,
  628. const char __user *user_buf,
  629. size_t count, loff_t *ppos)
  630. {
  631. struct wl1271 *wl = file->private_data;
  632. unsigned long value;
  633. int ret;
  634. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  635. if (ret < 0) {
  636. wl1271_warning("illegal value for suspend_dtim_interval");
  637. return -EINVAL;
  638. }
  639. if (value < 1 || value > 10) {
  640. wl1271_warning("suspend_dtim value is not in valid range");
  641. return -ERANGE;
  642. }
  643. mutex_lock(&wl->mutex);
  644. wl->conf.conn.suspend_listen_interval = value;
  645. /* for some reason there are different event types for 1 and >1 */
  646. if (value == 1)
  647. wl->conf.conn.suspend_wake_up_event = CONF_WAKE_UP_EVENT_DTIM;
  648. else
  649. wl->conf.conn.suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM;
  650. mutex_unlock(&wl->mutex);
  651. return count;
  652. }
  653. static const struct file_operations suspend_dtim_interval_ops = {
  654. .read = suspend_dtim_interval_read,
  655. .write = suspend_dtim_interval_write,
  656. .open = simple_open,
  657. .llseek = default_llseek,
  658. };
  659. static ssize_t beacon_interval_read(struct file *file, char __user *user_buf,
  660. size_t count, loff_t *ppos)
  661. {
  662. struct wl1271 *wl = file->private_data;
  663. u8 value;
  664. if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_BEACON ||
  665. wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_BEACONS)
  666. value = wl->conf.conn.listen_interval;
  667. else
  668. value = 0;
  669. return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
  670. }
  671. static ssize_t beacon_interval_write(struct file *file,
  672. const char __user *user_buf,
  673. size_t count, loff_t *ppos)
  674. {
  675. struct wl1271 *wl = file->private_data;
  676. unsigned long value;
  677. int ret;
  678. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  679. if (ret < 0) {
  680. wl1271_warning("illegal value for beacon_interval");
  681. return -EINVAL;
  682. }
  683. if (value < 1 || value > 255) {
  684. wl1271_warning("beacon interval value is not in valid range");
  685. return -ERANGE;
  686. }
  687. mutex_lock(&wl->mutex);
  688. wl->conf.conn.listen_interval = value;
  689. /* for some reason there are different event types for 1 and >1 */
  690. if (value == 1)
  691. wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_BEACON;
  692. else
  693. wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_BEACONS;
  694. /*
  695. * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only
  696. * take effect on the next time we enter psm.
  697. */
  698. mutex_unlock(&wl->mutex);
  699. return count;
  700. }
  701. static const struct file_operations beacon_interval_ops = {
  702. .read = beacon_interval_read,
  703. .write = beacon_interval_write,
  704. .open = simple_open,
  705. .llseek = default_llseek,
  706. };
  707. static ssize_t rx_streaming_interval_write(struct file *file,
  708. const char __user *user_buf,
  709. size_t count, loff_t *ppos)
  710. {
  711. struct wl1271 *wl = file->private_data;
  712. struct wl12xx_vif *wlvif;
  713. unsigned long value;
  714. int ret;
  715. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  716. if (ret < 0) {
  717. wl1271_warning("illegal value in rx_streaming_interval!");
  718. return -EINVAL;
  719. }
  720. /* valid values: 0, 10-100 */
  721. if (value && (value < 10 || value > 100)) {
  722. wl1271_warning("value is not in range!");
  723. return -ERANGE;
  724. }
  725. mutex_lock(&wl->mutex);
  726. wl->conf.rx_streaming.interval = value;
  727. ret = wl1271_ps_elp_wakeup(wl);
  728. if (ret < 0)
  729. goto out;
  730. wl12xx_for_each_wlvif_sta(wl, wlvif) {
  731. wl1271_recalc_rx_streaming(wl, wlvif);
  732. }
  733. wl1271_ps_elp_sleep(wl);
  734. out:
  735. mutex_unlock(&wl->mutex);
  736. return count;
  737. }
  738. static ssize_t rx_streaming_interval_read(struct file *file,
  739. char __user *userbuf,
  740. size_t count, loff_t *ppos)
  741. {
  742. struct wl1271 *wl = file->private_data;
  743. return wl1271_format_buffer(userbuf, count, ppos,
  744. "%d\n", wl->conf.rx_streaming.interval);
  745. }
  746. static const struct file_operations rx_streaming_interval_ops = {
  747. .read = rx_streaming_interval_read,
  748. .write = rx_streaming_interval_write,
  749. .open = simple_open,
  750. .llseek = default_llseek,
  751. };
  752. static ssize_t rx_streaming_always_write(struct file *file,
  753. const char __user *user_buf,
  754. size_t count, loff_t *ppos)
  755. {
  756. struct wl1271 *wl = file->private_data;
  757. struct wl12xx_vif *wlvif;
  758. unsigned long value;
  759. int ret;
  760. ret = kstrtoul_from_user(user_buf, count, 10, &value);
  761. if (ret < 0) {
  762. wl1271_warning("illegal value in rx_streaming_write!");
  763. return -EINVAL;
  764. }
  765. /* valid values: 0, 10-100 */
  766. if (!(value == 0 || value == 1)) {
  767. wl1271_warning("value is not in valid!");
  768. return -EINVAL;
  769. }
  770. mutex_lock(&wl->mutex);
  771. wl->conf.rx_streaming.always = value;
  772. ret = wl1271_ps_elp_wakeup(wl);
  773. if (ret < 0)
  774. goto out;
  775. wl12xx_for_each_wlvif_sta(wl, wlvif) {
  776. wl1271_recalc_rx_streaming(wl, wlvif);
  777. }
  778. wl1271_ps_elp_sleep(wl);
  779. out:
  780. mutex_unlock(&wl->mutex);
  781. return count;
  782. }
  783. static ssize_t rx_streaming_always_read(struct file *file,
  784. char __user *userbuf,
  785. size_t count, loff_t *ppos)
  786. {
  787. struct wl1271 *wl = file->private_data;
  788. return wl1271_format_buffer(userbuf, count, ppos,
  789. "%d\n", wl->conf.rx_streaming.always);
  790. }
  791. static const struct file_operations rx_streaming_always_ops = {
  792. .read = rx_streaming_always_read,
  793. .write = rx_streaming_always_write,
  794. .open = simple_open,
  795. .llseek = default_llseek,
  796. };
  797. static ssize_t beacon_filtering_write(struct file *file,
  798. const char __user *user_buf,
  799. size_t count, loff_t *ppos)
  800. {
  801. struct wl1271 *wl = file->private_data;
  802. struct wl12xx_vif *wlvif;
  803. char buf[10];
  804. size_t len;
  805. unsigned long value;
  806. int ret;
  807. len = min(count, sizeof(buf) - 1);
  808. if (copy_from_user(buf, user_buf, len))
  809. return -EFAULT;
  810. buf[len] = '\0';
  811. ret = kstrtoul(buf, 0, &value);
  812. if (ret < 0) {
  813. wl1271_warning("illegal value for beacon_filtering!");
  814. return -EINVAL;
  815. }
  816. mutex_lock(&wl->mutex);
  817. ret = wl1271_ps_elp_wakeup(wl);
  818. if (ret < 0)
  819. goto out;
  820. wl12xx_for_each_wlvif(wl, wlvif) {
  821. ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value);
  822. }
  823. wl1271_ps_elp_sleep(wl);
  824. out:
  825. mutex_unlock(&wl->mutex);
  826. return count;
  827. }
  828. static const struct file_operations beacon_filtering_ops = {
  829. .write = beacon_filtering_write,
  830. .open = simple_open,
  831. .llseek = default_llseek,
  832. };
  833. static int wl1271_debugfs_add_files(struct wl1271 *wl,
  834. struct dentry *rootdir)
  835. {
  836. int ret = 0;
  837. struct dentry *entry, *stats, *streaming;
  838. stats = debugfs_create_dir("fw-statistics", rootdir);
  839. if (!stats || IS_ERR(stats)) {
  840. entry = stats;
  841. goto err;
  842. }
  843. DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
  844. DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
  845. DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
  846. DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
  847. DEBUGFS_FWSTATS_ADD(rx, dropped);
  848. DEBUGFS_FWSTATS_ADD(rx, fcs_err);
  849. DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
  850. DEBUGFS_FWSTATS_ADD(rx, path_reset);
  851. DEBUGFS_FWSTATS_ADD(rx, reset_counter);
  852. DEBUGFS_FWSTATS_ADD(dma, rx_requested);
  853. DEBUGFS_FWSTATS_ADD(dma, rx_errors);
  854. DEBUGFS_FWSTATS_ADD(dma, tx_requested);
  855. DEBUGFS_FWSTATS_ADD(dma, tx_errors);
  856. DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
  857. DEBUGFS_FWSTATS_ADD(isr, fiqs);
  858. DEBUGFS_FWSTATS_ADD(isr, rx_headers);
  859. DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
  860. DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
  861. DEBUGFS_FWSTATS_ADD(isr, irqs);
  862. DEBUGFS_FWSTATS_ADD(isr, tx_procs);
  863. DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
  864. DEBUGFS_FWSTATS_ADD(isr, dma0_done);
  865. DEBUGFS_FWSTATS_ADD(isr, dma1_done);
  866. DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
  867. DEBUGFS_FWSTATS_ADD(isr, commands);
  868. DEBUGFS_FWSTATS_ADD(isr, rx_procs);
  869. DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
  870. DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
  871. DEBUGFS_FWSTATS_ADD(isr, pci_pm);
  872. DEBUGFS_FWSTATS_ADD(isr, wakeups);
  873. DEBUGFS_FWSTATS_ADD(isr, low_rssi);
  874. DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
  875. DEBUGFS_FWSTATS_ADD(wep, default_key_count);
  876. /* skipping wep.reserved */
  877. DEBUGFS_FWSTATS_ADD(wep, key_not_found);
  878. DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
  879. DEBUGFS_FWSTATS_ADD(wep, packets);
  880. DEBUGFS_FWSTATS_ADD(wep, interrupt);
  881. DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
  882. DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
  883. DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
  884. DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
  885. DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
  886. DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
  887. DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
  888. DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
  889. DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
  890. DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
  891. DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
  892. DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
  893. /* skipping cont_miss_bcns_spread for now */
  894. DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
  895. DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
  896. DEBUGFS_FWSTATS_ADD(mic, calc_failure);
  897. DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
  898. DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
  899. DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
  900. DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
  901. DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
  902. DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
  903. DEBUGFS_FWSTATS_ADD(event, heart_beat);
  904. DEBUGFS_FWSTATS_ADD(event, calibration);
  905. DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
  906. DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
  907. DEBUGFS_FWSTATS_ADD(event, rx_pool);
  908. DEBUGFS_FWSTATS_ADD(event, oom_late);
  909. DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
  910. DEBUGFS_FWSTATS_ADD(event, tx_stuck);
  911. DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
  912. DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
  913. DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
  914. DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
  915. DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
  916. DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
  917. DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
  918. DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
  919. DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
  920. DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
  921. DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
  922. DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
  923. DEBUGFS_ADD(tx_queue_len, rootdir);
  924. DEBUGFS_ADD(retry_count, rootdir);
  925. DEBUGFS_ADD(excessive_retries, rootdir);
  926. DEBUGFS_ADD(gpio_power, rootdir);
  927. DEBUGFS_ADD(start_recovery, rootdir);
  928. DEBUGFS_ADD(driver_state, rootdir);
  929. DEBUGFS_ADD(vifs_state, rootdir);
  930. DEBUGFS_ADD(dtim_interval, rootdir);
  931. DEBUGFS_ADD(suspend_dtim_interval, rootdir);
  932. DEBUGFS_ADD(beacon_interval, rootdir);
  933. DEBUGFS_ADD(beacon_filtering, rootdir);
  934. DEBUGFS_ADD(dynamic_ps_timeout, rootdir);
  935. DEBUGFS_ADD(forced_ps, rootdir);
  936. DEBUGFS_ADD(split_scan_timeout, rootdir);
  937. streaming = debugfs_create_dir("rx_streaming", rootdir);
  938. if (!streaming || IS_ERR(streaming))
  939. goto err;
  940. DEBUGFS_ADD_PREFIX(rx_streaming, interval, streaming);
  941. DEBUGFS_ADD_PREFIX(rx_streaming, always, streaming);
  942. return 0;
  943. err:
  944. if (IS_ERR(entry))
  945. ret = PTR_ERR(entry);
  946. else
  947. ret = -ENOMEM;
  948. return ret;
  949. }
  950. void wl1271_debugfs_reset(struct wl1271 *wl)
  951. {
  952. if (!wl->stats.fw_stats)
  953. return;
  954. memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
  955. wl->stats.retry_count = 0;
  956. wl->stats.excessive_retries = 0;
  957. }
  958. int wl1271_debugfs_init(struct wl1271 *wl)
  959. {
  960. int ret;
  961. struct dentry *rootdir;
  962. rootdir = debugfs_create_dir(KBUILD_MODNAME,
  963. wl->hw->wiphy->debugfsdir);
  964. if (IS_ERR(rootdir)) {
  965. ret = PTR_ERR(rootdir);
  966. goto err;
  967. }
  968. wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
  969. GFP_KERNEL);
  970. if (!wl->stats.fw_stats) {
  971. ret = -ENOMEM;
  972. goto err_fw;
  973. }
  974. wl->stats.fw_stats_update = jiffies;
  975. ret = wl1271_debugfs_add_files(wl, rootdir);
  976. if (ret < 0)
  977. goto err_file;
  978. return 0;
  979. err_file:
  980. kfree(wl->stats.fw_stats);
  981. wl->stats.fw_stats = NULL;
  982. err_fw:
  983. debugfs_remove_recursive(rootdir);
  984. err:
  985. return ret;
  986. }
  987. void wl1271_debugfs_exit(struct wl1271 *wl)
  988. {
  989. kfree(wl->stats.fw_stats);
  990. wl->stats.fw_stats = NULL;
  991. }