debug.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  1. /*
  2. * Copyright (c) 2004-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include "core.h"
  18. #include <linux/skbuff.h>
  19. #include <linux/fs.h>
  20. #include <linux/vmalloc.h>
  21. #include <linux/export.h>
  22. #include "debug.h"
  23. #include "target.h"
  24. struct ath6kl_fwlog_slot {
  25. __le32 timestamp;
  26. __le32 length;
  27. /* max ATH6KL_FWLOG_PAYLOAD_SIZE bytes */
  28. u8 payload[0];
  29. };
  30. #define ATH6KL_FWLOG_MAX_ENTRIES 20
  31. #define ATH6KL_FWLOG_VALID_MASK 0x1ffff
  32. int ath6kl_printk(const char *level, const char *fmt, ...)
  33. {
  34. struct va_format vaf;
  35. va_list args;
  36. int rtn;
  37. va_start(args, fmt);
  38. vaf.fmt = fmt;
  39. vaf.va = &args;
  40. rtn = printk("%sath6kl: %pV", level, &vaf);
  41. va_end(args);
  42. return rtn;
  43. }
  44. EXPORT_SYMBOL(ath6kl_printk);
  45. int ath6kl_info(const char *fmt, ...)
  46. {
  47. struct va_format vaf = {
  48. .fmt = fmt,
  49. };
  50. va_list args;
  51. int ret;
  52. va_start(args, fmt);
  53. vaf.va = &args;
  54. ret = ath6kl_printk(KERN_INFO, "%pV", &vaf);
  55. va_end(args);
  56. return ret;
  57. }
  58. EXPORT_SYMBOL(ath6kl_info);
  59. int ath6kl_err(const char *fmt, ...)
  60. {
  61. struct va_format vaf = {
  62. .fmt = fmt,
  63. };
  64. va_list args;
  65. int ret;
  66. va_start(args, fmt);
  67. vaf.va = &args;
  68. ret = ath6kl_printk(KERN_ERR, "%pV", &vaf);
  69. va_end(args);
  70. return ret;
  71. }
  72. EXPORT_SYMBOL(ath6kl_err);
  73. int ath6kl_warn(const char *fmt, ...)
  74. {
  75. struct va_format vaf = {
  76. .fmt = fmt,
  77. };
  78. va_list args;
  79. int ret;
  80. va_start(args, fmt);
  81. vaf.va = &args;
  82. ret = ath6kl_printk(KERN_WARNING, "%pV", &vaf);
  83. va_end(args);
  84. return ret;
  85. }
  86. EXPORT_SYMBOL(ath6kl_warn);
  87. #ifdef CONFIG_ATH6KL_DEBUG
  88. void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
  89. {
  90. struct va_format vaf;
  91. va_list args;
  92. if (!(debug_mask & mask))
  93. return;
  94. va_start(args, fmt);
  95. vaf.fmt = fmt;
  96. vaf.va = &args;
  97. ath6kl_printk(KERN_DEBUG, "%pV", &vaf);
  98. va_end(args);
  99. }
  100. EXPORT_SYMBOL(ath6kl_dbg);
  101. void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
  102. const char *msg, const char *prefix,
  103. const void *buf, size_t len)
  104. {
  105. if (debug_mask & mask) {
  106. if (msg)
  107. ath6kl_dbg(mask, "%s\n", msg);
  108. print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len);
  109. }
  110. }
  111. EXPORT_SYMBOL(ath6kl_dbg_dump);
  112. #define REG_OUTPUT_LEN_PER_LINE 25
  113. #define REGTYPE_STR_LEN 100
  114. struct ath6kl_diag_reg_info {
  115. u32 reg_start;
  116. u32 reg_end;
  117. const char *reg_info;
  118. };
  119. static const struct ath6kl_diag_reg_info diag_reg[] = {
  120. { 0x20000, 0x200fc, "General DMA and Rx registers" },
  121. { 0x28000, 0x28900, "MAC PCU register & keycache" },
  122. { 0x20800, 0x20a40, "QCU" },
  123. { 0x21000, 0x212f0, "DCU" },
  124. { 0x4000, 0x42e4, "RTC" },
  125. { 0x540000, 0x540000 + (256 * 1024), "RAM" },
  126. { 0x29800, 0x2B210, "Base Band" },
  127. { 0x1C000, 0x1C748, "Analog" },
  128. };
  129. void ath6kl_dump_registers(struct ath6kl_device *dev,
  130. struct ath6kl_irq_proc_registers *irq_proc_reg,
  131. struct ath6kl_irq_enable_reg *irq_enable_reg)
  132. {
  133. ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n"));
  134. if (irq_proc_reg != NULL) {
  135. ath6kl_dbg(ATH6KL_DBG_IRQ,
  136. "Host Int status: 0x%x\n",
  137. irq_proc_reg->host_int_status);
  138. ath6kl_dbg(ATH6KL_DBG_IRQ,
  139. "CPU Int status: 0x%x\n",
  140. irq_proc_reg->cpu_int_status);
  141. ath6kl_dbg(ATH6KL_DBG_IRQ,
  142. "Error Int status: 0x%x\n",
  143. irq_proc_reg->error_int_status);
  144. ath6kl_dbg(ATH6KL_DBG_IRQ,
  145. "Counter Int status: 0x%x\n",
  146. irq_proc_reg->counter_int_status);
  147. ath6kl_dbg(ATH6KL_DBG_IRQ,
  148. "Mbox Frame: 0x%x\n",
  149. irq_proc_reg->mbox_frame);
  150. ath6kl_dbg(ATH6KL_DBG_IRQ,
  151. "Rx Lookahead Valid: 0x%x\n",
  152. irq_proc_reg->rx_lkahd_valid);
  153. ath6kl_dbg(ATH6KL_DBG_IRQ,
  154. "Rx Lookahead 0: 0x%x\n",
  155. irq_proc_reg->rx_lkahd[0]);
  156. ath6kl_dbg(ATH6KL_DBG_IRQ,
  157. "Rx Lookahead 1: 0x%x\n",
  158. irq_proc_reg->rx_lkahd[1]);
  159. if (dev->ar->mbox_info.gmbox_addr != 0) {
  160. /*
  161. * If the target supports GMBOX hardware, dump some
  162. * additional state.
  163. */
  164. ath6kl_dbg(ATH6KL_DBG_IRQ,
  165. "GMBOX Host Int status 2: 0x%x\n",
  166. irq_proc_reg->host_int_status2);
  167. ath6kl_dbg(ATH6KL_DBG_IRQ,
  168. "GMBOX RX Avail: 0x%x\n",
  169. irq_proc_reg->gmbox_rx_avail);
  170. ath6kl_dbg(ATH6KL_DBG_IRQ,
  171. "GMBOX lookahead alias 0: 0x%x\n",
  172. irq_proc_reg->rx_gmbox_lkahd_alias[0]);
  173. ath6kl_dbg(ATH6KL_DBG_IRQ,
  174. "GMBOX lookahead alias 1: 0x%x\n",
  175. irq_proc_reg->rx_gmbox_lkahd_alias[1]);
  176. }
  177. }
  178. if (irq_enable_reg != NULL) {
  179. ath6kl_dbg(ATH6KL_DBG_IRQ,
  180. "Int status Enable: 0x%x\n",
  181. irq_enable_reg->int_status_en);
  182. ath6kl_dbg(ATH6KL_DBG_IRQ, "Counter Int status Enable: 0x%x\n",
  183. irq_enable_reg->cntr_int_status_en);
  184. }
  185. ath6kl_dbg(ATH6KL_DBG_IRQ, "<------------------------------->\n");
  186. }
  187. static void dump_cred_dist(struct htc_endpoint_credit_dist *ep_dist)
  188. {
  189. ath6kl_dbg(ATH6KL_DBG_CREDIT,
  190. "--- endpoint: %d svc_id: 0x%X ---\n",
  191. ep_dist->endpoint, ep_dist->svc_id);
  192. ath6kl_dbg(ATH6KL_DBG_CREDIT, " dist_flags : 0x%X\n",
  193. ep_dist->dist_flags);
  194. ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_norm : %d\n",
  195. ep_dist->cred_norm);
  196. ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_min : %d\n",
  197. ep_dist->cred_min);
  198. ath6kl_dbg(ATH6KL_DBG_CREDIT, " credits : %d\n",
  199. ep_dist->credits);
  200. ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_assngd : %d\n",
  201. ep_dist->cred_assngd);
  202. ath6kl_dbg(ATH6KL_DBG_CREDIT, " seek_cred : %d\n",
  203. ep_dist->seek_cred);
  204. ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_sz : %d\n",
  205. ep_dist->cred_sz);
  206. ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_per_msg : %d\n",
  207. ep_dist->cred_per_msg);
  208. ath6kl_dbg(ATH6KL_DBG_CREDIT, " cred_to_dist : %d\n",
  209. ep_dist->cred_to_dist);
  210. ath6kl_dbg(ATH6KL_DBG_CREDIT, " txq_depth : %d\n",
  211. get_queue_depth(&ep_dist->htc_ep->txq));
  212. ath6kl_dbg(ATH6KL_DBG_CREDIT,
  213. "----------------------------------\n");
  214. }
  215. /* FIXME: move to htc.c */
  216. void dump_cred_dist_stats(struct htc_target *target)
  217. {
  218. struct htc_endpoint_credit_dist *ep_list;
  219. list_for_each_entry(ep_list, &target->cred_dist_list, list)
  220. dump_cred_dist(ep_list);
  221. ath6kl_dbg(ATH6KL_DBG_CREDIT,
  222. "credit distribution total %d free %d\n",
  223. target->credit_info->total_avail_credits,
  224. target->credit_info->cur_free_credits);
  225. }
  226. void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
  227. {
  228. switch (war) {
  229. case ATH6KL_WAR_INVALID_RATE:
  230. ar->debug.war_stats.invalid_rate++;
  231. break;
  232. }
  233. }
  234. static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
  235. size_t count, loff_t *ppos)
  236. {
  237. struct ath6kl *ar = file->private_data;
  238. char *buf;
  239. unsigned int len = 0, buf_len = 1500;
  240. ssize_t ret_cnt;
  241. buf = kzalloc(buf_len, GFP_KERNEL);
  242. if (!buf)
  243. return -ENOMEM;
  244. len += scnprintf(buf + len, buf_len - len, "\n");
  245. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  246. "Workaround stats");
  247. len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
  248. "=================");
  249. len += scnprintf(buf + len, buf_len - len, "%20s %10u\n",
  250. "Invalid rates", ar->debug.war_stats.invalid_rate);
  251. if (WARN_ON(len > buf_len))
  252. len = buf_len;
  253. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  254. kfree(buf);
  255. return ret_cnt;
  256. }
  257. static const struct file_operations fops_war_stats = {
  258. .read = read_file_war_stats,
  259. .open = simple_open,
  260. .owner = THIS_MODULE,
  261. .llseek = default_llseek,
  262. };
  263. void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len)
  264. {
  265. struct ath6kl_fwlog_slot *slot;
  266. struct sk_buff *skb;
  267. size_t slot_len;
  268. if (WARN_ON(len > ATH6KL_FWLOG_PAYLOAD_SIZE))
  269. return;
  270. slot_len = sizeof(*slot) + ATH6KL_FWLOG_PAYLOAD_SIZE;
  271. skb = alloc_skb(slot_len, GFP_KERNEL);
  272. if (!skb)
  273. return;
  274. slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len);
  275. slot->timestamp = cpu_to_le32(jiffies);
  276. slot->length = cpu_to_le32(len);
  277. memcpy(slot->payload, buf, len);
  278. /* Need to pad each record to fixed length ATH6KL_FWLOG_PAYLOAD_SIZE */
  279. memset(slot->payload + len, 0, ATH6KL_FWLOG_PAYLOAD_SIZE - len);
  280. spin_lock(&ar->debug.fwlog_queue.lock);
  281. __skb_queue_tail(&ar->debug.fwlog_queue, skb);
  282. complete(&ar->debug.fwlog_completion);
  283. /* drop oldest entries */
  284. while (skb_queue_len(&ar->debug.fwlog_queue) >
  285. ATH6KL_FWLOG_MAX_ENTRIES) {
  286. skb = __skb_dequeue(&ar->debug.fwlog_queue);
  287. kfree_skb(skb);
  288. }
  289. spin_unlock(&ar->debug.fwlog_queue.lock);
  290. return;
  291. }
  292. static int ath6kl_fwlog_open(struct inode *inode, struct file *file)
  293. {
  294. struct ath6kl *ar = inode->i_private;
  295. if (ar->debug.fwlog_open)
  296. return -EBUSY;
  297. ar->debug.fwlog_open = true;
  298. file->private_data = inode->i_private;
  299. return 0;
  300. }
  301. static int ath6kl_fwlog_release(struct inode *inode, struct file *file)
  302. {
  303. struct ath6kl *ar = inode->i_private;
  304. ar->debug.fwlog_open = false;
  305. return 0;
  306. }
  307. static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
  308. size_t count, loff_t *ppos)
  309. {
  310. struct ath6kl *ar = file->private_data;
  311. struct sk_buff *skb;
  312. ssize_t ret_cnt;
  313. size_t len = 0;
  314. char *buf;
  315. buf = vmalloc(count);
  316. if (!buf)
  317. return -ENOMEM;
  318. /* read undelivered logs from firmware */
  319. ath6kl_read_fwlogs(ar);
  320. spin_lock(&ar->debug.fwlog_queue.lock);
  321. while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
  322. if (skb->len > count - len) {
  323. /* not enough space, put skb back and leave */
  324. __skb_queue_head(&ar->debug.fwlog_queue, skb);
  325. break;
  326. }
  327. memcpy(buf + len, skb->data, skb->len);
  328. len += skb->len;
  329. kfree_skb(skb);
  330. }
  331. spin_unlock(&ar->debug.fwlog_queue.lock);
  332. /* FIXME: what to do if len == 0? */
  333. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  334. vfree(buf);
  335. return ret_cnt;
  336. }
  337. static const struct file_operations fops_fwlog = {
  338. .open = ath6kl_fwlog_open,
  339. .release = ath6kl_fwlog_release,
  340. .read = ath6kl_fwlog_read,
  341. .owner = THIS_MODULE,
  342. .llseek = default_llseek,
  343. };
  344. static ssize_t ath6kl_fwlog_block_read(struct file *file,
  345. char __user *user_buf,
  346. size_t count,
  347. loff_t *ppos)
  348. {
  349. struct ath6kl *ar = file->private_data;
  350. struct sk_buff *skb;
  351. ssize_t ret_cnt;
  352. size_t len = 0, not_copied;
  353. char *buf;
  354. int ret;
  355. buf = vmalloc(count);
  356. if (!buf)
  357. return -ENOMEM;
  358. spin_lock(&ar->debug.fwlog_queue.lock);
  359. if (skb_queue_len(&ar->debug.fwlog_queue) == 0) {
  360. /* we must init under queue lock */
  361. init_completion(&ar->debug.fwlog_completion);
  362. spin_unlock(&ar->debug.fwlog_queue.lock);
  363. ret = wait_for_completion_interruptible(
  364. &ar->debug.fwlog_completion);
  365. if (ret == -ERESTARTSYS) {
  366. vfree(buf);
  367. return ret;
  368. }
  369. spin_lock(&ar->debug.fwlog_queue.lock);
  370. }
  371. while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
  372. if (skb->len > count - len) {
  373. /* not enough space, put skb back and leave */
  374. __skb_queue_head(&ar->debug.fwlog_queue, skb);
  375. break;
  376. }
  377. memcpy(buf + len, skb->data, skb->len);
  378. len += skb->len;
  379. kfree_skb(skb);
  380. }
  381. spin_unlock(&ar->debug.fwlog_queue.lock);
  382. /* FIXME: what to do if len == 0? */
  383. not_copied = copy_to_user(user_buf, buf, len);
  384. if (not_copied != 0) {
  385. ret_cnt = -EFAULT;
  386. goto out;
  387. }
  388. *ppos = *ppos + len;
  389. ret_cnt = len;
  390. out:
  391. vfree(buf);
  392. return ret_cnt;
  393. }
  394. static const struct file_operations fops_fwlog_block = {
  395. .open = ath6kl_fwlog_open,
  396. .release = ath6kl_fwlog_release,
  397. .read = ath6kl_fwlog_block_read,
  398. .owner = THIS_MODULE,
  399. .llseek = default_llseek,
  400. };
  401. static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
  402. size_t count, loff_t *ppos)
  403. {
  404. struct ath6kl *ar = file->private_data;
  405. char buf[16];
  406. int len;
  407. len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
  408. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  409. }
  410. static ssize_t ath6kl_fwlog_mask_write(struct file *file,
  411. const char __user *user_buf,
  412. size_t count, loff_t *ppos)
  413. {
  414. struct ath6kl *ar = file->private_data;
  415. int ret;
  416. ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
  417. if (ret)
  418. return ret;
  419. ret = ath6kl_wmi_config_debug_module_cmd(ar->wmi,
  420. ATH6KL_FWLOG_VALID_MASK,
  421. ar->debug.fwlog_mask);
  422. if (ret)
  423. return ret;
  424. return count;
  425. }
  426. static const struct file_operations fops_fwlog_mask = {
  427. .open = simple_open,
  428. .read = ath6kl_fwlog_mask_read,
  429. .write = ath6kl_fwlog_mask_write,
  430. .owner = THIS_MODULE,
  431. .llseek = default_llseek,
  432. };
  433. static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
  434. size_t count, loff_t *ppos)
  435. {
  436. struct ath6kl *ar = file->private_data;
  437. struct ath6kl_vif *vif;
  438. struct target_stats *tgt_stats;
  439. char *buf;
  440. unsigned int len = 0, buf_len = 1500;
  441. int i;
  442. long left;
  443. ssize_t ret_cnt;
  444. vif = ath6kl_vif_first(ar);
  445. if (!vif)
  446. return -EIO;
  447. tgt_stats = &vif->target_stats;
  448. buf = kzalloc(buf_len, GFP_KERNEL);
  449. if (!buf)
  450. return -ENOMEM;
  451. if (down_interruptible(&ar->sem)) {
  452. kfree(buf);
  453. return -EBUSY;
  454. }
  455. set_bit(STATS_UPDATE_PEND, &vif->flags);
  456. if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) {
  457. up(&ar->sem);
  458. kfree(buf);
  459. return -EIO;
  460. }
  461. left = wait_event_interruptible_timeout(ar->event_wq,
  462. !test_bit(STATS_UPDATE_PEND,
  463. &vif->flags), WMI_TIMEOUT);
  464. up(&ar->sem);
  465. if (left <= 0) {
  466. kfree(buf);
  467. return -ETIMEDOUT;
  468. }
  469. len += scnprintf(buf + len, buf_len - len, "\n");
  470. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  471. "Target Tx stats");
  472. len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
  473. "=================");
  474. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  475. "Ucast packets", tgt_stats->tx_ucast_pkt);
  476. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  477. "Bcast packets", tgt_stats->tx_bcast_pkt);
  478. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  479. "Ucast byte", tgt_stats->tx_ucast_byte);
  480. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  481. "Bcast byte", tgt_stats->tx_bcast_byte);
  482. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  483. "Rts success cnt", tgt_stats->tx_rts_success_cnt);
  484. for (i = 0; i < 4; i++)
  485. len += scnprintf(buf + len, buf_len - len,
  486. "%18s %d %10llu\n", "PER on ac",
  487. i, tgt_stats->tx_pkt_per_ac[i]);
  488. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  489. "Error", tgt_stats->tx_err);
  490. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  491. "Fail count", tgt_stats->tx_fail_cnt);
  492. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  493. "Retry count", tgt_stats->tx_retry_cnt);
  494. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  495. "Multi retry cnt", tgt_stats->tx_mult_retry_cnt);
  496. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  497. "Rts fail cnt", tgt_stats->tx_rts_fail_cnt);
  498. len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n\n",
  499. "TKIP counter measure used",
  500. tgt_stats->tkip_cnter_measures_invoked);
  501. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  502. "Target Rx stats");
  503. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  504. "=================");
  505. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  506. "Ucast packets", tgt_stats->rx_ucast_pkt);
  507. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  508. "Ucast Rate", tgt_stats->rx_ucast_rate);
  509. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  510. "Bcast packets", tgt_stats->rx_bcast_pkt);
  511. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  512. "Ucast byte", tgt_stats->rx_ucast_byte);
  513. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  514. "Bcast byte", tgt_stats->rx_bcast_byte);
  515. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  516. "Fragmented pkt", tgt_stats->rx_frgment_pkt);
  517. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  518. "Error", tgt_stats->rx_err);
  519. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  520. "CRC Err", tgt_stats->rx_crc_err);
  521. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  522. "Key chache miss", tgt_stats->rx_key_cache_miss);
  523. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  524. "Decrypt Err", tgt_stats->rx_decrypt_err);
  525. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  526. "Duplicate frame", tgt_stats->rx_dupl_frame);
  527. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  528. "Tkip Mic failure", tgt_stats->tkip_local_mic_fail);
  529. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  530. "TKIP format err", tgt_stats->tkip_fmt_err);
  531. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  532. "CCMP format Err", tgt_stats->ccmp_fmt_err);
  533. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n\n",
  534. "CCMP Replay Err", tgt_stats->ccmp_replays);
  535. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  536. "Misc Target stats");
  537. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  538. "=================");
  539. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  540. "Beacon Miss count", tgt_stats->cs_bmiss_cnt);
  541. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  542. "Num Connects", tgt_stats->cs_connect_cnt);
  543. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  544. "Num disconnects", tgt_stats->cs_discon_cnt);
  545. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  546. "Beacon avg rssi", tgt_stats->cs_ave_beacon_rssi);
  547. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  548. "ARP pkt received", tgt_stats->arp_received);
  549. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  550. "ARP pkt matched", tgt_stats->arp_matched);
  551. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  552. "ARP pkt replied", tgt_stats->arp_replied);
  553. if (len > buf_len)
  554. len = buf_len;
  555. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  556. kfree(buf);
  557. return ret_cnt;
  558. }
  559. static const struct file_operations fops_tgt_stats = {
  560. .read = read_file_tgt_stats,
  561. .open = simple_open,
  562. .owner = THIS_MODULE,
  563. .llseek = default_llseek,
  564. };
  565. #define print_credit_info(fmt_str, ep_list_field) \
  566. (len += scnprintf(buf + len, buf_len - len, fmt_str, \
  567. ep_list->ep_list_field))
  568. #define CREDIT_INFO_DISPLAY_STRING_LEN 200
  569. #define CREDIT_INFO_LEN 128
  570. static ssize_t read_file_credit_dist_stats(struct file *file,
  571. char __user *user_buf,
  572. size_t count, loff_t *ppos)
  573. {
  574. struct ath6kl *ar = file->private_data;
  575. struct htc_target *target = ar->htc_target;
  576. struct htc_endpoint_credit_dist *ep_list;
  577. char *buf;
  578. unsigned int buf_len, len = 0;
  579. ssize_t ret_cnt;
  580. buf_len = CREDIT_INFO_DISPLAY_STRING_LEN +
  581. get_queue_depth(&target->cred_dist_list) * CREDIT_INFO_LEN;
  582. buf = kzalloc(buf_len, GFP_KERNEL);
  583. if (!buf)
  584. return -ENOMEM;
  585. len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
  586. "Total Avail Credits: ",
  587. target->credit_info->total_avail_credits);
  588. len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
  589. "Free credits :",
  590. target->credit_info->cur_free_credits);
  591. len += scnprintf(buf + len, buf_len - len,
  592. " Epid Flags Cred_norm Cred_min Credits Cred_assngd"
  593. " Seek_cred Cred_sz Cred_per_msg Cred_to_dist"
  594. " qdepth\n");
  595. list_for_each_entry(ep_list, &target->cred_dist_list, list) {
  596. print_credit_info(" %2d", endpoint);
  597. print_credit_info("%10x", dist_flags);
  598. print_credit_info("%8d", cred_norm);
  599. print_credit_info("%9d", cred_min);
  600. print_credit_info("%9d", credits);
  601. print_credit_info("%10d", cred_assngd);
  602. print_credit_info("%13d", seek_cred);
  603. print_credit_info("%12d", cred_sz);
  604. print_credit_info("%9d", cred_per_msg);
  605. print_credit_info("%14d", cred_to_dist);
  606. len += scnprintf(buf + len, buf_len - len, "%12d\n",
  607. get_queue_depth(&ep_list->htc_ep->txq));
  608. }
  609. if (len > buf_len)
  610. len = buf_len;
  611. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  612. kfree(buf);
  613. return ret_cnt;
  614. }
  615. static const struct file_operations fops_credit_dist_stats = {
  616. .read = read_file_credit_dist_stats,
  617. .open = simple_open,
  618. .owner = THIS_MODULE,
  619. .llseek = default_llseek,
  620. };
  621. static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
  622. unsigned int buf_len, unsigned int len,
  623. int offset, const char *name)
  624. {
  625. int i;
  626. struct htc_endpoint_stats *ep_st;
  627. u32 *counter;
  628. len += scnprintf(buf + len, buf_len - len, "%s:", name);
  629. for (i = 0; i < ENDPOINT_MAX; i++) {
  630. ep_st = &target->endpoint[i].ep_st;
  631. counter = ((u32 *) ep_st) + (offset / 4);
  632. len += scnprintf(buf + len, buf_len - len, " %u", *counter);
  633. }
  634. len += scnprintf(buf + len, buf_len - len, "\n");
  635. return len;
  636. }
  637. static ssize_t ath6kl_endpoint_stats_read(struct file *file,
  638. char __user *user_buf,
  639. size_t count, loff_t *ppos)
  640. {
  641. struct ath6kl *ar = file->private_data;
  642. struct htc_target *target = ar->htc_target;
  643. char *buf;
  644. unsigned int buf_len, len = 0;
  645. ssize_t ret_cnt;
  646. buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) *
  647. (25 + ENDPOINT_MAX * 11);
  648. buf = kmalloc(buf_len, GFP_KERNEL);
  649. if (!buf)
  650. return -ENOMEM;
  651. #define EPSTAT(name) \
  652. do { \
  653. len = print_endpoint_stat(target, buf, buf_len, len, \
  654. offsetof(struct htc_endpoint_stats, \
  655. name), \
  656. #name); \
  657. } while (0)
  658. EPSTAT(cred_low_indicate);
  659. EPSTAT(tx_issued);
  660. EPSTAT(tx_pkt_bundled);
  661. EPSTAT(tx_bundles);
  662. EPSTAT(tx_dropped);
  663. EPSTAT(tx_cred_rpt);
  664. EPSTAT(cred_rpt_from_rx);
  665. EPSTAT(cred_rpt_from_other);
  666. EPSTAT(cred_rpt_ep0);
  667. EPSTAT(cred_from_rx);
  668. EPSTAT(cred_from_other);
  669. EPSTAT(cred_from_ep0);
  670. EPSTAT(cred_cosumd);
  671. EPSTAT(cred_retnd);
  672. EPSTAT(rx_pkts);
  673. EPSTAT(rx_lkahds);
  674. EPSTAT(rx_bundl);
  675. EPSTAT(rx_bundle_lkahd);
  676. EPSTAT(rx_bundle_from_hdr);
  677. EPSTAT(rx_alloc_thresh_hit);
  678. EPSTAT(rxalloc_thresh_byte);
  679. #undef EPSTAT
  680. if (len > buf_len)
  681. len = buf_len;
  682. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  683. kfree(buf);
  684. return ret_cnt;
  685. }
  686. static ssize_t ath6kl_endpoint_stats_write(struct file *file,
  687. const char __user *user_buf,
  688. size_t count, loff_t *ppos)
  689. {
  690. struct ath6kl *ar = file->private_data;
  691. struct htc_target *target = ar->htc_target;
  692. int ret, i;
  693. u32 val;
  694. struct htc_endpoint_stats *ep_st;
  695. ret = kstrtou32_from_user(user_buf, count, 0, &val);
  696. if (ret)
  697. return ret;
  698. if (val == 0) {
  699. for (i = 0; i < ENDPOINT_MAX; i++) {
  700. ep_st = &target->endpoint[i].ep_st;
  701. memset(ep_st, 0, sizeof(*ep_st));
  702. }
  703. }
  704. return count;
  705. }
  706. static const struct file_operations fops_endpoint_stats = {
  707. .open = simple_open,
  708. .read = ath6kl_endpoint_stats_read,
  709. .write = ath6kl_endpoint_stats_write,
  710. .owner = THIS_MODULE,
  711. .llseek = default_llseek,
  712. };
  713. static unsigned long ath6kl_get_num_reg(void)
  714. {
  715. int i;
  716. unsigned long n_reg = 0;
  717. for (i = 0; i < ARRAY_SIZE(diag_reg); i++)
  718. n_reg = n_reg +
  719. (diag_reg[i].reg_end - diag_reg[i].reg_start) / 4 + 1;
  720. return n_reg;
  721. }
  722. static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
  723. {
  724. int i;
  725. for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
  726. if (reg_addr >= diag_reg[i].reg_start &&
  727. reg_addr <= diag_reg[i].reg_end)
  728. return true;
  729. }
  730. return false;
  731. }
  732. static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
  733. size_t count, loff_t *ppos)
  734. {
  735. struct ath6kl *ar = file->private_data;
  736. u8 buf[50];
  737. unsigned int len = 0;
  738. if (ar->debug.dbgfs_diag_reg)
  739. len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n",
  740. ar->debug.dbgfs_diag_reg);
  741. else
  742. len += scnprintf(buf + len, sizeof(buf) - len,
  743. "All diag registers\n");
  744. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  745. }
  746. static ssize_t ath6kl_regread_write(struct file *file,
  747. const char __user *user_buf,
  748. size_t count, loff_t *ppos)
  749. {
  750. struct ath6kl *ar = file->private_data;
  751. unsigned long reg_addr;
  752. if (kstrtoul_from_user(user_buf, count, 0, &reg_addr))
  753. return -EINVAL;
  754. if ((reg_addr % 4) != 0)
  755. return -EINVAL;
  756. if (reg_addr && !ath6kl_dbg_is_diag_reg_valid(reg_addr))
  757. return -EINVAL;
  758. ar->debug.dbgfs_diag_reg = reg_addr;
  759. return count;
  760. }
  761. static const struct file_operations fops_diag_reg_read = {
  762. .read = ath6kl_regread_read,
  763. .write = ath6kl_regread_write,
  764. .open = simple_open,
  765. .owner = THIS_MODULE,
  766. .llseek = default_llseek,
  767. };
  768. static int ath6kl_regdump_open(struct inode *inode, struct file *file)
  769. {
  770. struct ath6kl *ar = inode->i_private;
  771. u8 *buf;
  772. unsigned long int reg_len;
  773. unsigned int len = 0, n_reg;
  774. u32 addr;
  775. __le32 reg_val;
  776. int i, status;
  777. /* Dump all the registers if no register is specified */
  778. if (!ar->debug.dbgfs_diag_reg)
  779. n_reg = ath6kl_get_num_reg();
  780. else
  781. n_reg = 1;
  782. reg_len = n_reg * REG_OUTPUT_LEN_PER_LINE;
  783. if (n_reg > 1)
  784. reg_len += REGTYPE_STR_LEN;
  785. buf = vmalloc(reg_len);
  786. if (!buf)
  787. return -ENOMEM;
  788. if (n_reg == 1) {
  789. addr = ar->debug.dbgfs_diag_reg;
  790. status = ath6kl_diag_read32(ar,
  791. TARG_VTOP(ar->target_type, addr),
  792. (u32 *)&reg_val);
  793. if (status)
  794. goto fail_reg_read;
  795. len += scnprintf(buf + len, reg_len - len,
  796. "0x%06x 0x%08x\n", addr, le32_to_cpu(reg_val));
  797. goto done;
  798. }
  799. for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
  800. len += scnprintf(buf + len, reg_len - len,
  801. "%s\n", diag_reg[i].reg_info);
  802. for (addr = diag_reg[i].reg_start;
  803. addr <= diag_reg[i].reg_end; addr += 4) {
  804. status = ath6kl_diag_read32(ar,
  805. TARG_VTOP(ar->target_type, addr),
  806. (u32 *)&reg_val);
  807. if (status)
  808. goto fail_reg_read;
  809. len += scnprintf(buf + len, reg_len - len,
  810. "0x%06x 0x%08x\n",
  811. addr, le32_to_cpu(reg_val));
  812. }
  813. }
  814. done:
  815. file->private_data = buf;
  816. return 0;
  817. fail_reg_read:
  818. ath6kl_warn("Unable to read memory:%u\n", addr);
  819. vfree(buf);
  820. return -EIO;
  821. }
  822. static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
  823. size_t count, loff_t *ppos)
  824. {
  825. u8 *buf = file->private_data;
  826. return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
  827. }
  828. static int ath6kl_regdump_release(struct inode *inode, struct file *file)
  829. {
  830. vfree(file->private_data);
  831. return 0;
  832. }
  833. static const struct file_operations fops_reg_dump = {
  834. .open = ath6kl_regdump_open,
  835. .read = ath6kl_regdump_read,
  836. .release = ath6kl_regdump_release,
  837. .owner = THIS_MODULE,
  838. .llseek = default_llseek,
  839. };
  840. static ssize_t ath6kl_lrssi_roam_write(struct file *file,
  841. const char __user *user_buf,
  842. size_t count, loff_t *ppos)
  843. {
  844. struct ath6kl *ar = file->private_data;
  845. unsigned long lrssi_roam_threshold;
  846. if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
  847. return -EINVAL;
  848. ar->lrssi_roam_threshold = lrssi_roam_threshold;
  849. ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
  850. return count;
  851. }
  852. static ssize_t ath6kl_lrssi_roam_read(struct file *file,
  853. char __user *user_buf,
  854. size_t count, loff_t *ppos)
  855. {
  856. struct ath6kl *ar = file->private_data;
  857. char buf[32];
  858. unsigned int len;
  859. len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
  860. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  861. }
  862. static const struct file_operations fops_lrssi_roam_threshold = {
  863. .read = ath6kl_lrssi_roam_read,
  864. .write = ath6kl_lrssi_roam_write,
  865. .open = simple_open,
  866. .owner = THIS_MODULE,
  867. .llseek = default_llseek,
  868. };
  869. static ssize_t ath6kl_regwrite_read(struct file *file,
  870. char __user *user_buf,
  871. size_t count, loff_t *ppos)
  872. {
  873. struct ath6kl *ar = file->private_data;
  874. u8 buf[32];
  875. unsigned int len = 0;
  876. len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
  877. ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
  878. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  879. }
  880. static ssize_t ath6kl_regwrite_write(struct file *file,
  881. const char __user *user_buf,
  882. size_t count, loff_t *ppos)
  883. {
  884. struct ath6kl *ar = file->private_data;
  885. char buf[32];
  886. char *sptr, *token;
  887. unsigned int len = 0;
  888. u32 reg_addr, reg_val;
  889. len = min(count, sizeof(buf) - 1);
  890. if (copy_from_user(buf, user_buf, len))
  891. return -EFAULT;
  892. buf[len] = '\0';
  893. sptr = buf;
  894. token = strsep(&sptr, "=");
  895. if (!token)
  896. return -EINVAL;
  897. if (kstrtou32(token, 0, &reg_addr))
  898. return -EINVAL;
  899. if (!ath6kl_dbg_is_diag_reg_valid(reg_addr))
  900. return -EINVAL;
  901. if (kstrtou32(sptr, 0, &reg_val))
  902. return -EINVAL;
  903. ar->debug.diag_reg_addr_wr = reg_addr;
  904. ar->debug.diag_reg_val_wr = reg_val;
  905. if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr,
  906. cpu_to_le32(ar->debug.diag_reg_val_wr)))
  907. return -EIO;
  908. return count;
  909. }
  910. static const struct file_operations fops_diag_reg_write = {
  911. .read = ath6kl_regwrite_read,
  912. .write = ath6kl_regwrite_write,
  913. .open = simple_open,
  914. .owner = THIS_MODULE,
  915. .llseek = default_llseek,
  916. };
  917. int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
  918. size_t len)
  919. {
  920. const struct wmi_target_roam_tbl *tbl;
  921. u16 num_entries;
  922. if (len < sizeof(*tbl))
  923. return -EINVAL;
  924. tbl = (const struct wmi_target_roam_tbl *) buf;
  925. num_entries = le16_to_cpu(tbl->num_entries);
  926. if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) >
  927. len)
  928. return -EINVAL;
  929. if (ar->debug.roam_tbl == NULL ||
  930. ar->debug.roam_tbl_len < (unsigned int) len) {
  931. kfree(ar->debug.roam_tbl);
  932. ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC);
  933. if (ar->debug.roam_tbl == NULL)
  934. return -ENOMEM;
  935. }
  936. memcpy(ar->debug.roam_tbl, buf, len);
  937. ar->debug.roam_tbl_len = len;
  938. if (test_bit(ROAM_TBL_PEND, &ar->flag)) {
  939. clear_bit(ROAM_TBL_PEND, &ar->flag);
  940. wake_up(&ar->event_wq);
  941. }
  942. return 0;
  943. }
  944. static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
  945. size_t count, loff_t *ppos)
  946. {
  947. struct ath6kl *ar = file->private_data;
  948. int ret;
  949. long left;
  950. struct wmi_target_roam_tbl *tbl;
  951. u16 num_entries, i;
  952. char *buf;
  953. unsigned int len, buf_len;
  954. ssize_t ret_cnt;
  955. if (down_interruptible(&ar->sem))
  956. return -EBUSY;
  957. set_bit(ROAM_TBL_PEND, &ar->flag);
  958. ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi);
  959. if (ret) {
  960. up(&ar->sem);
  961. return ret;
  962. }
  963. left = wait_event_interruptible_timeout(
  964. ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT);
  965. up(&ar->sem);
  966. if (left <= 0)
  967. return -ETIMEDOUT;
  968. if (ar->debug.roam_tbl == NULL)
  969. return -ENOMEM;
  970. tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl;
  971. num_entries = le16_to_cpu(tbl->num_entries);
  972. buf_len = 100 + num_entries * 100;
  973. buf = kzalloc(buf_len, GFP_KERNEL);
  974. if (buf == NULL)
  975. return -ENOMEM;
  976. len = 0;
  977. len += scnprintf(buf + len, buf_len - len,
  978. "roam_mode=%u\n\n"
  979. "# roam_util bssid rssi rssidt last_rssi util bias\n",
  980. le16_to_cpu(tbl->roam_mode));
  981. for (i = 0; i < num_entries; i++) {
  982. struct wmi_bss_roam_info *info = &tbl->info[i];
  983. len += scnprintf(buf + len, buf_len - len,
  984. "%d %pM %d %d %d %d %d\n",
  985. a_sle32_to_cpu(info->roam_util), info->bssid,
  986. info->rssi, info->rssidt, info->last_rssi,
  987. info->util, info->bias);
  988. }
  989. if (len > buf_len)
  990. len = buf_len;
  991. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  992. kfree(buf);
  993. return ret_cnt;
  994. }
  995. static const struct file_operations fops_roam_table = {
  996. .read = ath6kl_roam_table_read,
  997. .open = simple_open,
  998. .owner = THIS_MODULE,
  999. .llseek = default_llseek,
  1000. };
  1001. static ssize_t ath6kl_force_roam_write(struct file *file,
  1002. const char __user *user_buf,
  1003. size_t count, loff_t *ppos)
  1004. {
  1005. struct ath6kl *ar = file->private_data;
  1006. int ret;
  1007. char buf[20];
  1008. size_t len;
  1009. u8 bssid[ETH_ALEN];
  1010. int i;
  1011. int addr[ETH_ALEN];
  1012. len = min(count, sizeof(buf) - 1);
  1013. if (copy_from_user(buf, user_buf, len))
  1014. return -EFAULT;
  1015. buf[len] = '\0';
  1016. if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
  1017. &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
  1018. != ETH_ALEN)
  1019. return -EINVAL;
  1020. for (i = 0; i < ETH_ALEN; i++)
  1021. bssid[i] = addr[i];
  1022. ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
  1023. if (ret)
  1024. return ret;
  1025. return count;
  1026. }
  1027. static const struct file_operations fops_force_roam = {
  1028. .write = ath6kl_force_roam_write,
  1029. .open = simple_open,
  1030. .owner = THIS_MODULE,
  1031. .llseek = default_llseek,
  1032. };
  1033. static ssize_t ath6kl_roam_mode_write(struct file *file,
  1034. const char __user *user_buf,
  1035. size_t count, loff_t *ppos)
  1036. {
  1037. struct ath6kl *ar = file->private_data;
  1038. int ret;
  1039. char buf[20];
  1040. size_t len;
  1041. enum wmi_roam_mode mode;
  1042. len = min(count, sizeof(buf) - 1);
  1043. if (copy_from_user(buf, user_buf, len))
  1044. return -EFAULT;
  1045. buf[len] = '\0';
  1046. if (len > 0 && buf[len - 1] == '\n')
  1047. buf[len - 1] = '\0';
  1048. if (strcasecmp(buf, "default") == 0)
  1049. mode = WMI_DEFAULT_ROAM_MODE;
  1050. else if (strcasecmp(buf, "bssbias") == 0)
  1051. mode = WMI_HOST_BIAS_ROAM_MODE;
  1052. else if (strcasecmp(buf, "lock") == 0)
  1053. mode = WMI_LOCK_BSS_MODE;
  1054. else
  1055. return -EINVAL;
  1056. ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode);
  1057. if (ret)
  1058. return ret;
  1059. return count;
  1060. }
  1061. static const struct file_operations fops_roam_mode = {
  1062. .write = ath6kl_roam_mode_write,
  1063. .open = simple_open,
  1064. .owner = THIS_MODULE,
  1065. .llseek = default_llseek,
  1066. };
  1067. void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
  1068. {
  1069. ar->debug.keepalive = keepalive;
  1070. }
  1071. static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
  1072. size_t count, loff_t *ppos)
  1073. {
  1074. struct ath6kl *ar = file->private_data;
  1075. char buf[16];
  1076. int len;
  1077. len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
  1078. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1079. }
  1080. static ssize_t ath6kl_keepalive_write(struct file *file,
  1081. const char __user *user_buf,
  1082. size_t count, loff_t *ppos)
  1083. {
  1084. struct ath6kl *ar = file->private_data;
  1085. int ret;
  1086. u8 val;
  1087. ret = kstrtou8_from_user(user_buf, count, 0, &val);
  1088. if (ret)
  1089. return ret;
  1090. ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val);
  1091. if (ret)
  1092. return ret;
  1093. return count;
  1094. }
  1095. static const struct file_operations fops_keepalive = {
  1096. .open = simple_open,
  1097. .read = ath6kl_keepalive_read,
  1098. .write = ath6kl_keepalive_write,
  1099. .owner = THIS_MODULE,
  1100. .llseek = default_llseek,
  1101. };
  1102. void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
  1103. {
  1104. ar->debug.disc_timeout = timeout;
  1105. }
  1106. static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
  1107. char __user *user_buf,
  1108. size_t count, loff_t *ppos)
  1109. {
  1110. struct ath6kl *ar = file->private_data;
  1111. char buf[16];
  1112. int len;
  1113. len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
  1114. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1115. }
  1116. static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
  1117. const char __user *user_buf,
  1118. size_t count, loff_t *ppos)
  1119. {
  1120. struct ath6kl *ar = file->private_data;
  1121. int ret;
  1122. u8 val;
  1123. ret = kstrtou8_from_user(user_buf, count, 0, &val);
  1124. if (ret)
  1125. return ret;
  1126. ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val);
  1127. if (ret)
  1128. return ret;
  1129. return count;
  1130. }
  1131. static const struct file_operations fops_disconnect_timeout = {
  1132. .open = simple_open,
  1133. .read = ath6kl_disconnect_timeout_read,
  1134. .write = ath6kl_disconnect_timeout_write,
  1135. .owner = THIS_MODULE,
  1136. .llseek = default_llseek,
  1137. };
  1138. static ssize_t ath6kl_create_qos_write(struct file *file,
  1139. const char __user *user_buf,
  1140. size_t count, loff_t *ppos)
  1141. {
  1142. struct ath6kl *ar = file->private_data;
  1143. struct ath6kl_vif *vif;
  1144. char buf[200];
  1145. ssize_t len;
  1146. char *sptr, *token;
  1147. struct wmi_create_pstream_cmd pstream;
  1148. u32 val32;
  1149. u16 val16;
  1150. vif = ath6kl_vif_first(ar);
  1151. if (!vif)
  1152. return -EIO;
  1153. len = min(count, sizeof(buf) - 1);
  1154. if (copy_from_user(buf, user_buf, len))
  1155. return -EFAULT;
  1156. buf[len] = '\0';
  1157. sptr = buf;
  1158. token = strsep(&sptr, " ");
  1159. if (!token)
  1160. return -EINVAL;
  1161. if (kstrtou8(token, 0, &pstream.user_pri))
  1162. return -EINVAL;
  1163. token = strsep(&sptr, " ");
  1164. if (!token)
  1165. return -EINVAL;
  1166. if (kstrtou8(token, 0, &pstream.traffic_direc))
  1167. return -EINVAL;
  1168. token = strsep(&sptr, " ");
  1169. if (!token)
  1170. return -EINVAL;
  1171. if (kstrtou8(token, 0, &pstream.traffic_class))
  1172. return -EINVAL;
  1173. token = strsep(&sptr, " ");
  1174. if (!token)
  1175. return -EINVAL;
  1176. if (kstrtou8(token, 0, &pstream.traffic_type))
  1177. return -EINVAL;
  1178. token = strsep(&sptr, " ");
  1179. if (!token)
  1180. return -EINVAL;
  1181. if (kstrtou8(token, 0, &pstream.voice_psc_cap))
  1182. return -EINVAL;
  1183. token = strsep(&sptr, " ");
  1184. if (!token)
  1185. return -EINVAL;
  1186. if (kstrtou32(token, 0, &val32))
  1187. return -EINVAL;
  1188. pstream.min_service_int = cpu_to_le32(val32);
  1189. token = strsep(&sptr, " ");
  1190. if (!token)
  1191. return -EINVAL;
  1192. if (kstrtou32(token, 0, &val32))
  1193. return -EINVAL;
  1194. pstream.max_service_int = cpu_to_le32(val32);
  1195. token = strsep(&sptr, " ");
  1196. if (!token)
  1197. return -EINVAL;
  1198. if (kstrtou32(token, 0, &val32))
  1199. return -EINVAL;
  1200. pstream.inactivity_int = cpu_to_le32(val32);
  1201. token = strsep(&sptr, " ");
  1202. if (!token)
  1203. return -EINVAL;
  1204. if (kstrtou32(token, 0, &val32))
  1205. return -EINVAL;
  1206. pstream.suspension_int = cpu_to_le32(val32);
  1207. token = strsep(&sptr, " ");
  1208. if (!token)
  1209. return -EINVAL;
  1210. if (kstrtou32(token, 0, &val32))
  1211. return -EINVAL;
  1212. pstream.service_start_time = cpu_to_le32(val32);
  1213. token = strsep(&sptr, " ");
  1214. if (!token)
  1215. return -EINVAL;
  1216. if (kstrtou8(token, 0, &pstream.tsid))
  1217. return -EINVAL;
  1218. token = strsep(&sptr, " ");
  1219. if (!token)
  1220. return -EINVAL;
  1221. if (kstrtou16(token, 0, &val16))
  1222. return -EINVAL;
  1223. pstream.nominal_msdu = cpu_to_le16(val16);
  1224. token = strsep(&sptr, " ");
  1225. if (!token)
  1226. return -EINVAL;
  1227. if (kstrtou16(token, 0, &val16))
  1228. return -EINVAL;
  1229. pstream.max_msdu = cpu_to_le16(val16);
  1230. token = strsep(&sptr, " ");
  1231. if (!token)
  1232. return -EINVAL;
  1233. if (kstrtou32(token, 0, &val32))
  1234. return -EINVAL;
  1235. pstream.min_data_rate = cpu_to_le32(val32);
  1236. token = strsep(&sptr, " ");
  1237. if (!token)
  1238. return -EINVAL;
  1239. if (kstrtou32(token, 0, &val32))
  1240. return -EINVAL;
  1241. pstream.mean_data_rate = cpu_to_le32(val32);
  1242. token = strsep(&sptr, " ");
  1243. if (!token)
  1244. return -EINVAL;
  1245. if (kstrtou32(token, 0, &val32))
  1246. return -EINVAL;
  1247. pstream.peak_data_rate = cpu_to_le32(val32);
  1248. token = strsep(&sptr, " ");
  1249. if (!token)
  1250. return -EINVAL;
  1251. if (kstrtou32(token, 0, &val32))
  1252. return -EINVAL;
  1253. pstream.max_burst_size = cpu_to_le32(val32);
  1254. token = strsep(&sptr, " ");
  1255. if (!token)
  1256. return -EINVAL;
  1257. if (kstrtou32(token, 0, &val32))
  1258. return -EINVAL;
  1259. pstream.delay_bound = cpu_to_le32(val32);
  1260. token = strsep(&sptr, " ");
  1261. if (!token)
  1262. return -EINVAL;
  1263. if (kstrtou32(token, 0, &val32))
  1264. return -EINVAL;
  1265. pstream.min_phy_rate = cpu_to_le32(val32);
  1266. token = strsep(&sptr, " ");
  1267. if (!token)
  1268. return -EINVAL;
  1269. if (kstrtou32(token, 0, &val32))
  1270. return -EINVAL;
  1271. pstream.sba = cpu_to_le32(val32);
  1272. token = strsep(&sptr, " ");
  1273. if (!token)
  1274. return -EINVAL;
  1275. if (kstrtou32(token, 0, &val32))
  1276. return -EINVAL;
  1277. pstream.medium_time = cpu_to_le32(val32);
  1278. pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000;
  1279. ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream);
  1280. return count;
  1281. }
  1282. static const struct file_operations fops_create_qos = {
  1283. .write = ath6kl_create_qos_write,
  1284. .open = simple_open,
  1285. .owner = THIS_MODULE,
  1286. .llseek = default_llseek,
  1287. };
  1288. static ssize_t ath6kl_delete_qos_write(struct file *file,
  1289. const char __user *user_buf,
  1290. size_t count, loff_t *ppos)
  1291. {
  1292. struct ath6kl *ar = file->private_data;
  1293. struct ath6kl_vif *vif;
  1294. char buf[100];
  1295. ssize_t len;
  1296. char *sptr, *token;
  1297. u8 traffic_class;
  1298. u8 tsid;
  1299. vif = ath6kl_vif_first(ar);
  1300. if (!vif)
  1301. return -EIO;
  1302. len = min(count, sizeof(buf) - 1);
  1303. if (copy_from_user(buf, user_buf, len))
  1304. return -EFAULT;
  1305. buf[len] = '\0';
  1306. sptr = buf;
  1307. token = strsep(&sptr, " ");
  1308. if (!token)
  1309. return -EINVAL;
  1310. if (kstrtou8(token, 0, &traffic_class))
  1311. return -EINVAL;
  1312. token = strsep(&sptr, " ");
  1313. if (!token)
  1314. return -EINVAL;
  1315. if (kstrtou8(token, 0, &tsid))
  1316. return -EINVAL;
  1317. ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx,
  1318. traffic_class, tsid);
  1319. return count;
  1320. }
  1321. static const struct file_operations fops_delete_qos = {
  1322. .write = ath6kl_delete_qos_write,
  1323. .open = simple_open,
  1324. .owner = THIS_MODULE,
  1325. .llseek = default_llseek,
  1326. };
  1327. static ssize_t ath6kl_bgscan_int_write(struct file *file,
  1328. const char __user *user_buf,
  1329. size_t count, loff_t *ppos)
  1330. {
  1331. struct ath6kl *ar = file->private_data;
  1332. struct ath6kl_vif *vif;
  1333. u16 bgscan_int;
  1334. char buf[32];
  1335. ssize_t len;
  1336. vif = ath6kl_vif_first(ar);
  1337. if (!vif)
  1338. return -EIO;
  1339. len = min(count, sizeof(buf) - 1);
  1340. if (copy_from_user(buf, user_buf, len))
  1341. return -EFAULT;
  1342. buf[len] = '\0';
  1343. if (kstrtou16(buf, 0, &bgscan_int))
  1344. return -EINVAL;
  1345. if (bgscan_int == 0)
  1346. bgscan_int = 0xffff;
  1347. vif->bg_scan_period = bgscan_int;
  1348. ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3,
  1349. 0, 0, 0);
  1350. return count;
  1351. }
  1352. static const struct file_operations fops_bgscan_int = {
  1353. .write = ath6kl_bgscan_int_write,
  1354. .open = simple_open,
  1355. .owner = THIS_MODULE,
  1356. .llseek = default_llseek,
  1357. };
  1358. static ssize_t ath6kl_listen_int_write(struct file *file,
  1359. const char __user *user_buf,
  1360. size_t count, loff_t *ppos)
  1361. {
  1362. struct ath6kl *ar = file->private_data;
  1363. struct ath6kl_vif *vif;
  1364. u16 listen_interval;
  1365. char buf[32];
  1366. ssize_t len;
  1367. vif = ath6kl_vif_first(ar);
  1368. if (!vif)
  1369. return -EIO;
  1370. len = min(count, sizeof(buf) - 1);
  1371. if (copy_from_user(buf, user_buf, len))
  1372. return -EFAULT;
  1373. buf[len] = '\0';
  1374. if (kstrtou16(buf, 0, &listen_interval))
  1375. return -EINVAL;
  1376. if ((listen_interval < 15) || (listen_interval > 3000))
  1377. return -EINVAL;
  1378. vif->listen_intvl_t = listen_interval;
  1379. ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
  1380. vif->listen_intvl_t, 0);
  1381. return count;
  1382. }
  1383. static ssize_t ath6kl_listen_int_read(struct file *file,
  1384. char __user *user_buf,
  1385. size_t count, loff_t *ppos)
  1386. {
  1387. struct ath6kl *ar = file->private_data;
  1388. struct ath6kl_vif *vif;
  1389. char buf[32];
  1390. int len;
  1391. vif = ath6kl_vif_first(ar);
  1392. if (!vif)
  1393. return -EIO;
  1394. len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
  1395. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1396. }
  1397. static const struct file_operations fops_listen_int = {
  1398. .read = ath6kl_listen_int_read,
  1399. .write = ath6kl_listen_int_write,
  1400. .open = simple_open,
  1401. .owner = THIS_MODULE,
  1402. .llseek = default_llseek,
  1403. };
  1404. static ssize_t ath6kl_power_params_write(struct file *file,
  1405. const char __user *user_buf,
  1406. size_t count, loff_t *ppos)
  1407. {
  1408. struct ath6kl *ar = file->private_data;
  1409. u8 buf[100];
  1410. unsigned int len = 0;
  1411. char *sptr, *token;
  1412. u16 idle_period, ps_poll_num, dtim,
  1413. tx_wakeup, num_tx;
  1414. len = min(count, sizeof(buf) - 1);
  1415. if (copy_from_user(buf, user_buf, len))
  1416. return -EFAULT;
  1417. buf[len] = '\0';
  1418. sptr = buf;
  1419. token = strsep(&sptr, " ");
  1420. if (!token)
  1421. return -EINVAL;
  1422. if (kstrtou16(token, 0, &idle_period))
  1423. return -EINVAL;
  1424. token = strsep(&sptr, " ");
  1425. if (!token)
  1426. return -EINVAL;
  1427. if (kstrtou16(token, 0, &ps_poll_num))
  1428. return -EINVAL;
  1429. token = strsep(&sptr, " ");
  1430. if (!token)
  1431. return -EINVAL;
  1432. if (kstrtou16(token, 0, &dtim))
  1433. return -EINVAL;
  1434. token = strsep(&sptr, " ");
  1435. if (!token)
  1436. return -EINVAL;
  1437. if (kstrtou16(token, 0, &tx_wakeup))
  1438. return -EINVAL;
  1439. token = strsep(&sptr, " ");
  1440. if (!token)
  1441. return -EINVAL;
  1442. if (kstrtou16(token, 0, &num_tx))
  1443. return -EINVAL;
  1444. ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num,
  1445. dtim, tx_wakeup, num_tx, 0);
  1446. return count;
  1447. }
  1448. static const struct file_operations fops_power_params = {
  1449. .write = ath6kl_power_params_write,
  1450. .open = simple_open,
  1451. .owner = THIS_MODULE,
  1452. .llseek = default_llseek,
  1453. };
  1454. void ath6kl_debug_init(struct ath6kl *ar)
  1455. {
  1456. skb_queue_head_init(&ar->debug.fwlog_queue);
  1457. init_completion(&ar->debug.fwlog_completion);
  1458. /*
  1459. * Actually we are lying here but don't know how to read the mask
  1460. * value from the firmware.
  1461. */
  1462. ar->debug.fwlog_mask = 0;
  1463. }
  1464. /*
  1465. * Initialisation needs to happen in two stages as fwlog events can come
  1466. * before cfg80211 is initialised, and debugfs depends on cfg80211
  1467. * initialisation.
  1468. */
  1469. int ath6kl_debug_init_fs(struct ath6kl *ar)
  1470. {
  1471. ar->debugfs_phy = debugfs_create_dir("ath6kl",
  1472. ar->wiphy->debugfsdir);
  1473. if (!ar->debugfs_phy)
  1474. return -ENOMEM;
  1475. debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar,
  1476. &fops_tgt_stats);
  1477. debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar,
  1478. &fops_credit_dist_stats);
  1479. debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR,
  1480. ar->debugfs_phy, ar, &fops_endpoint_stats);
  1481. debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar,
  1482. &fops_fwlog);
  1483. debugfs_create_file("fwlog_block", S_IRUSR, ar->debugfs_phy, ar,
  1484. &fops_fwlog_block);
  1485. debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy,
  1486. ar, &fops_fwlog_mask);
  1487. debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
  1488. &fops_diag_reg_read);
  1489. debugfs_create_file("reg_dump", S_IRUSR, ar->debugfs_phy, ar,
  1490. &fops_reg_dump);
  1491. debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR,
  1492. ar->debugfs_phy, ar, &fops_lrssi_roam_threshold);
  1493. debugfs_create_file("reg_write", S_IRUSR | S_IWUSR,
  1494. ar->debugfs_phy, ar, &fops_diag_reg_write);
  1495. debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar,
  1496. &fops_war_stats);
  1497. debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar,
  1498. &fops_roam_table);
  1499. debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar,
  1500. &fops_force_roam);
  1501. debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar,
  1502. &fops_roam_mode);
  1503. debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
  1504. &fops_keepalive);
  1505. debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR,
  1506. ar->debugfs_phy, ar, &fops_disconnect_timeout);
  1507. debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar,
  1508. &fops_create_qos);
  1509. debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar,
  1510. &fops_delete_qos);
  1511. debugfs_create_file("bgscan_interval", S_IWUSR,
  1512. ar->debugfs_phy, ar, &fops_bgscan_int);
  1513. debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR,
  1514. ar->debugfs_phy, ar, &fops_listen_int);
  1515. debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar,
  1516. &fops_power_params);
  1517. return 0;
  1518. }
  1519. void ath6kl_debug_cleanup(struct ath6kl *ar)
  1520. {
  1521. skb_queue_purge(&ar->debug.fwlog_queue);
  1522. complete(&ar->debug.fwlog_completion);
  1523. kfree(ar->debug.roam_tbl);
  1524. }
  1525. #endif