debugfs.c 31 KB

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