debug.c 45 KB

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