debug.c 45 KB

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