debug.c 45 KB

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