debug.c 45 KB

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