debug.c 46 KB

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