debug.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823
  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. vfree(buf);
  330. return ret;
  331. }
  332. spin_lock(&ar->debug.fwlog_queue.lock);
  333. }
  334. while ((skb = __skb_dequeue(&ar->debug.fwlog_queue))) {
  335. if (skb->len > count - len) {
  336. /* not enough space, put skb back and leave */
  337. __skb_queue_head(&ar->debug.fwlog_queue, skb);
  338. break;
  339. }
  340. memcpy(buf + len, skb->data, skb->len);
  341. len += skb->len;
  342. kfree_skb(skb);
  343. }
  344. spin_unlock(&ar->debug.fwlog_queue.lock);
  345. /* FIXME: what to do if len == 0? */
  346. not_copied = copy_to_user(user_buf, buf, len);
  347. if (not_copied != 0) {
  348. ret_cnt = -EFAULT;
  349. goto out;
  350. }
  351. *ppos = *ppos + len;
  352. ret_cnt = len;
  353. out:
  354. vfree(buf);
  355. return ret_cnt;
  356. }
  357. static const struct file_operations fops_fwlog_block = {
  358. .open = ath6kl_fwlog_open,
  359. .release = ath6kl_fwlog_release,
  360. .read = ath6kl_fwlog_block_read,
  361. .owner = THIS_MODULE,
  362. .llseek = default_llseek,
  363. };
  364. static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
  365. size_t count, loff_t *ppos)
  366. {
  367. struct ath6kl *ar = file->private_data;
  368. char buf[16];
  369. int len;
  370. len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
  371. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  372. }
  373. static ssize_t ath6kl_fwlog_mask_write(struct file *file,
  374. const char __user *user_buf,
  375. size_t count, loff_t *ppos)
  376. {
  377. struct ath6kl *ar = file->private_data;
  378. int ret;
  379. ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
  380. if (ret)
  381. return ret;
  382. ret = ath6kl_wmi_config_debug_module_cmd(ar->wmi,
  383. ATH6KL_FWLOG_VALID_MASK,
  384. ar->debug.fwlog_mask);
  385. if (ret)
  386. return ret;
  387. return count;
  388. }
  389. static const struct file_operations fops_fwlog_mask = {
  390. .open = ath6kl_debugfs_open,
  391. .read = ath6kl_fwlog_mask_read,
  392. .write = ath6kl_fwlog_mask_write,
  393. .owner = THIS_MODULE,
  394. .llseek = default_llseek,
  395. };
  396. static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
  397. size_t count, loff_t *ppos)
  398. {
  399. struct ath6kl *ar = file->private_data;
  400. struct ath6kl_vif *vif;
  401. struct target_stats *tgt_stats;
  402. char *buf;
  403. unsigned int len = 0, buf_len = 1500;
  404. int i;
  405. long left;
  406. ssize_t ret_cnt;
  407. vif = ath6kl_vif_first(ar);
  408. if (!vif)
  409. return -EIO;
  410. tgt_stats = &vif->target_stats;
  411. buf = kzalloc(buf_len, GFP_KERNEL);
  412. if (!buf)
  413. return -ENOMEM;
  414. if (down_interruptible(&ar->sem)) {
  415. kfree(buf);
  416. return -EBUSY;
  417. }
  418. set_bit(STATS_UPDATE_PEND, &vif->flags);
  419. if (ath6kl_wmi_get_stats_cmd(ar->wmi, 0)) {
  420. up(&ar->sem);
  421. kfree(buf);
  422. return -EIO;
  423. }
  424. left = wait_event_interruptible_timeout(ar->event_wq,
  425. !test_bit(STATS_UPDATE_PEND,
  426. &vif->flags), WMI_TIMEOUT);
  427. up(&ar->sem);
  428. if (left <= 0) {
  429. kfree(buf);
  430. return -ETIMEDOUT;
  431. }
  432. len += scnprintf(buf + len, buf_len - len, "\n");
  433. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  434. "Target Tx stats");
  435. len += scnprintf(buf + len, buf_len - len, "%25s\n\n",
  436. "=================");
  437. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  438. "Ucast packets", tgt_stats->tx_ucast_pkt);
  439. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  440. "Bcast packets", tgt_stats->tx_bcast_pkt);
  441. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  442. "Ucast byte", tgt_stats->tx_ucast_byte);
  443. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  444. "Bcast byte", tgt_stats->tx_bcast_byte);
  445. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  446. "Rts success cnt", tgt_stats->tx_rts_success_cnt);
  447. for (i = 0; i < 4; i++)
  448. len += scnprintf(buf + len, buf_len - len,
  449. "%18s %d %10llu\n", "PER on ac",
  450. i, tgt_stats->tx_pkt_per_ac[i]);
  451. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  452. "Error", tgt_stats->tx_err);
  453. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  454. "Fail count", tgt_stats->tx_fail_cnt);
  455. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  456. "Retry count", tgt_stats->tx_retry_cnt);
  457. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  458. "Multi retry cnt", tgt_stats->tx_mult_retry_cnt);
  459. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  460. "Rts fail cnt", tgt_stats->tx_rts_fail_cnt);
  461. len += scnprintf(buf + len, buf_len - len, "%25s %10llu\n\n",
  462. "TKIP counter measure used",
  463. tgt_stats->tkip_cnter_measures_invoked);
  464. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  465. "Target Rx stats");
  466. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  467. "=================");
  468. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  469. "Ucast packets", tgt_stats->rx_ucast_pkt);
  470. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  471. "Ucast Rate", tgt_stats->rx_ucast_rate);
  472. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  473. "Bcast packets", tgt_stats->rx_bcast_pkt);
  474. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  475. "Ucast byte", tgt_stats->rx_ucast_byte);
  476. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  477. "Bcast byte", tgt_stats->rx_bcast_byte);
  478. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  479. "Fragmented pkt", tgt_stats->rx_frgment_pkt);
  480. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  481. "Error", tgt_stats->rx_err);
  482. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  483. "CRC Err", tgt_stats->rx_crc_err);
  484. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  485. "Key chache miss", tgt_stats->rx_key_cache_miss);
  486. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  487. "Decrypt Err", tgt_stats->rx_decrypt_err);
  488. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  489. "Duplicate frame", tgt_stats->rx_dupl_frame);
  490. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  491. "Tkip Mic failure", tgt_stats->tkip_local_mic_fail);
  492. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  493. "TKIP format err", tgt_stats->tkip_fmt_err);
  494. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  495. "CCMP format Err", tgt_stats->ccmp_fmt_err);
  496. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n\n",
  497. "CCMP Replay Err", tgt_stats->ccmp_replays);
  498. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  499. "Misc Target stats");
  500. len += scnprintf(buf + len, buf_len - len, "%25s\n",
  501. "=================");
  502. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  503. "Beacon Miss count", tgt_stats->cs_bmiss_cnt);
  504. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  505. "Num Connects", tgt_stats->cs_connect_cnt);
  506. len += scnprintf(buf + len, buf_len - len, "%20s %10llu\n",
  507. "Num disconnects", tgt_stats->cs_discon_cnt);
  508. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  509. "Beacon avg rssi", tgt_stats->cs_ave_beacon_rssi);
  510. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  511. "ARP pkt received", tgt_stats->arp_received);
  512. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  513. "ARP pkt matched", tgt_stats->arp_matched);
  514. len += scnprintf(buf + len, buf_len - len, "%20s %10d\n",
  515. "ARP pkt replied", tgt_stats->arp_replied);
  516. if (len > buf_len)
  517. len = buf_len;
  518. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  519. kfree(buf);
  520. return ret_cnt;
  521. }
  522. static const struct file_operations fops_tgt_stats = {
  523. .read = read_file_tgt_stats,
  524. .open = ath6kl_debugfs_open,
  525. .owner = THIS_MODULE,
  526. .llseek = default_llseek,
  527. };
  528. #define print_credit_info(fmt_str, ep_list_field) \
  529. (len += scnprintf(buf + len, buf_len - len, fmt_str, \
  530. ep_list->ep_list_field))
  531. #define CREDIT_INFO_DISPLAY_STRING_LEN 200
  532. #define CREDIT_INFO_LEN 128
  533. static ssize_t read_file_credit_dist_stats(struct file *file,
  534. char __user *user_buf,
  535. size_t count, loff_t *ppos)
  536. {
  537. struct ath6kl *ar = file->private_data;
  538. struct htc_target *target = ar->htc_target;
  539. struct htc_endpoint_credit_dist *ep_list;
  540. char *buf;
  541. unsigned int buf_len, len = 0;
  542. ssize_t ret_cnt;
  543. buf_len = CREDIT_INFO_DISPLAY_STRING_LEN +
  544. get_queue_depth(&target->cred_dist_list) * CREDIT_INFO_LEN;
  545. buf = kzalloc(buf_len, GFP_KERNEL);
  546. if (!buf)
  547. return -ENOMEM;
  548. len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
  549. "Total Avail Credits: ",
  550. target->credit_info->total_avail_credits);
  551. len += scnprintf(buf + len, buf_len - len, "%25s%5d\n",
  552. "Free credits :",
  553. target->credit_info->cur_free_credits);
  554. len += scnprintf(buf + len, buf_len - len,
  555. " Epid Flags Cred_norm Cred_min Credits Cred_assngd"
  556. " Seek_cred Cred_sz Cred_per_msg Cred_to_dist"
  557. " qdepth\n");
  558. list_for_each_entry(ep_list, &target->cred_dist_list, list) {
  559. print_credit_info(" %2d", endpoint);
  560. print_credit_info("%10x", dist_flags);
  561. print_credit_info("%8d", cred_norm);
  562. print_credit_info("%9d", cred_min);
  563. print_credit_info("%9d", credits);
  564. print_credit_info("%10d", cred_assngd);
  565. print_credit_info("%13d", seek_cred);
  566. print_credit_info("%12d", cred_sz);
  567. print_credit_info("%9d", cred_per_msg);
  568. print_credit_info("%14d", cred_to_dist);
  569. len += scnprintf(buf + len, buf_len - len, "%12d\n",
  570. get_queue_depth(&ep_list->htc_ep->txq));
  571. }
  572. if (len > buf_len)
  573. len = buf_len;
  574. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  575. kfree(buf);
  576. return ret_cnt;
  577. }
  578. static const struct file_operations fops_credit_dist_stats = {
  579. .read = read_file_credit_dist_stats,
  580. .open = ath6kl_debugfs_open,
  581. .owner = THIS_MODULE,
  582. .llseek = default_llseek,
  583. };
  584. static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
  585. unsigned int buf_len, unsigned int len,
  586. int offset, const char *name)
  587. {
  588. int i;
  589. struct htc_endpoint_stats *ep_st;
  590. u32 *counter;
  591. len += scnprintf(buf + len, buf_len - len, "%s:", name);
  592. for (i = 0; i < ENDPOINT_MAX; i++) {
  593. ep_st = &target->endpoint[i].ep_st;
  594. counter = ((u32 *) ep_st) + (offset / 4);
  595. len += scnprintf(buf + len, buf_len - len, " %u", *counter);
  596. }
  597. len += scnprintf(buf + len, buf_len - len, "\n");
  598. return len;
  599. }
  600. static ssize_t ath6kl_endpoint_stats_read(struct file *file,
  601. char __user *user_buf,
  602. size_t count, loff_t *ppos)
  603. {
  604. struct ath6kl *ar = file->private_data;
  605. struct htc_target *target = ar->htc_target;
  606. char *buf;
  607. unsigned int buf_len, len = 0;
  608. ssize_t ret_cnt;
  609. buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) *
  610. (25 + ENDPOINT_MAX * 11);
  611. buf = kmalloc(buf_len, GFP_KERNEL);
  612. if (!buf)
  613. return -ENOMEM;
  614. #define EPSTAT(name) \
  615. do { \
  616. len = print_endpoint_stat(target, buf, buf_len, len, \
  617. offsetof(struct htc_endpoint_stats, \
  618. name), \
  619. #name); \
  620. } while (0)
  621. EPSTAT(cred_low_indicate);
  622. EPSTAT(tx_issued);
  623. EPSTAT(tx_pkt_bundled);
  624. EPSTAT(tx_bundles);
  625. EPSTAT(tx_dropped);
  626. EPSTAT(tx_cred_rpt);
  627. EPSTAT(cred_rpt_from_rx);
  628. EPSTAT(cred_rpt_from_other);
  629. EPSTAT(cred_rpt_ep0);
  630. EPSTAT(cred_from_rx);
  631. EPSTAT(cred_from_other);
  632. EPSTAT(cred_from_ep0);
  633. EPSTAT(cred_cosumd);
  634. EPSTAT(cred_retnd);
  635. EPSTAT(rx_pkts);
  636. EPSTAT(rx_lkahds);
  637. EPSTAT(rx_bundl);
  638. EPSTAT(rx_bundle_lkahd);
  639. EPSTAT(rx_bundle_from_hdr);
  640. EPSTAT(rx_alloc_thresh_hit);
  641. EPSTAT(rxalloc_thresh_byte);
  642. #undef EPSTAT
  643. if (len > buf_len)
  644. len = buf_len;
  645. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  646. kfree(buf);
  647. return ret_cnt;
  648. }
  649. static ssize_t ath6kl_endpoint_stats_write(struct file *file,
  650. const char __user *user_buf,
  651. size_t count, loff_t *ppos)
  652. {
  653. struct ath6kl *ar = file->private_data;
  654. struct htc_target *target = ar->htc_target;
  655. int ret, i;
  656. u32 val;
  657. struct htc_endpoint_stats *ep_st;
  658. ret = kstrtou32_from_user(user_buf, count, 0, &val);
  659. if (ret)
  660. return ret;
  661. if (val == 0) {
  662. for (i = 0; i < ENDPOINT_MAX; i++) {
  663. ep_st = &target->endpoint[i].ep_st;
  664. memset(ep_st, 0, sizeof(*ep_st));
  665. }
  666. }
  667. return count;
  668. }
  669. static const struct file_operations fops_endpoint_stats = {
  670. .open = ath6kl_debugfs_open,
  671. .read = ath6kl_endpoint_stats_read,
  672. .write = ath6kl_endpoint_stats_write,
  673. .owner = THIS_MODULE,
  674. .llseek = default_llseek,
  675. };
  676. static unsigned long ath6kl_get_num_reg(void)
  677. {
  678. int i;
  679. unsigned long n_reg = 0;
  680. for (i = 0; i < ARRAY_SIZE(diag_reg); i++)
  681. n_reg = n_reg +
  682. (diag_reg[i].reg_end - diag_reg[i].reg_start) / 4 + 1;
  683. return n_reg;
  684. }
  685. static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
  686. {
  687. int i;
  688. for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
  689. if (reg_addr >= diag_reg[i].reg_start &&
  690. reg_addr <= diag_reg[i].reg_end)
  691. return true;
  692. }
  693. return false;
  694. }
  695. static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
  696. size_t count, loff_t *ppos)
  697. {
  698. struct ath6kl *ar = file->private_data;
  699. u8 buf[50];
  700. unsigned int len = 0;
  701. if (ar->debug.dbgfs_diag_reg)
  702. len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n",
  703. ar->debug.dbgfs_diag_reg);
  704. else
  705. len += scnprintf(buf + len, sizeof(buf) - len,
  706. "All diag registers\n");
  707. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  708. }
  709. static ssize_t ath6kl_regread_write(struct file *file,
  710. const char __user *user_buf,
  711. size_t count, loff_t *ppos)
  712. {
  713. struct ath6kl *ar = file->private_data;
  714. unsigned long reg_addr;
  715. if (kstrtoul_from_user(user_buf, count, 0, &reg_addr))
  716. return -EINVAL;
  717. if ((reg_addr % 4) != 0)
  718. return -EINVAL;
  719. if (reg_addr && !ath6kl_dbg_is_diag_reg_valid(reg_addr))
  720. return -EINVAL;
  721. ar->debug.dbgfs_diag_reg = reg_addr;
  722. return count;
  723. }
  724. static const struct file_operations fops_diag_reg_read = {
  725. .read = ath6kl_regread_read,
  726. .write = ath6kl_regread_write,
  727. .open = ath6kl_debugfs_open,
  728. .owner = THIS_MODULE,
  729. .llseek = default_llseek,
  730. };
  731. static int ath6kl_regdump_open(struct inode *inode, struct file *file)
  732. {
  733. struct ath6kl *ar = inode->i_private;
  734. u8 *buf;
  735. unsigned long int reg_len;
  736. unsigned int len = 0, n_reg;
  737. u32 addr;
  738. __le32 reg_val;
  739. int i, status;
  740. /* Dump all the registers if no register is specified */
  741. if (!ar->debug.dbgfs_diag_reg)
  742. n_reg = ath6kl_get_num_reg();
  743. else
  744. n_reg = 1;
  745. reg_len = n_reg * REG_OUTPUT_LEN_PER_LINE;
  746. if (n_reg > 1)
  747. reg_len += REGTYPE_STR_LEN;
  748. buf = vmalloc(reg_len);
  749. if (!buf)
  750. return -ENOMEM;
  751. if (n_reg == 1) {
  752. addr = ar->debug.dbgfs_diag_reg;
  753. status = ath6kl_diag_read32(ar,
  754. TARG_VTOP(ar->target_type, addr),
  755. (u32 *)&reg_val);
  756. if (status)
  757. goto fail_reg_read;
  758. len += scnprintf(buf + len, reg_len - len,
  759. "0x%06x 0x%08x\n", addr, le32_to_cpu(reg_val));
  760. goto done;
  761. }
  762. for (i = 0; i < ARRAY_SIZE(diag_reg); i++) {
  763. len += scnprintf(buf + len, reg_len - len,
  764. "%s\n", diag_reg[i].reg_info);
  765. for (addr = diag_reg[i].reg_start;
  766. addr <= diag_reg[i].reg_end; addr += 4) {
  767. status = ath6kl_diag_read32(ar,
  768. TARG_VTOP(ar->target_type, addr),
  769. (u32 *)&reg_val);
  770. if (status)
  771. goto fail_reg_read;
  772. len += scnprintf(buf + len, reg_len - len,
  773. "0x%06x 0x%08x\n",
  774. addr, le32_to_cpu(reg_val));
  775. }
  776. }
  777. done:
  778. file->private_data = buf;
  779. return 0;
  780. fail_reg_read:
  781. ath6kl_warn("Unable to read memory:%u\n", addr);
  782. vfree(buf);
  783. return -EIO;
  784. }
  785. static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
  786. size_t count, loff_t *ppos)
  787. {
  788. u8 *buf = file->private_data;
  789. return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
  790. }
  791. static int ath6kl_regdump_release(struct inode *inode, struct file *file)
  792. {
  793. vfree(file->private_data);
  794. return 0;
  795. }
  796. static const struct file_operations fops_reg_dump = {
  797. .open = ath6kl_regdump_open,
  798. .read = ath6kl_regdump_read,
  799. .release = ath6kl_regdump_release,
  800. .owner = THIS_MODULE,
  801. .llseek = default_llseek,
  802. };
  803. static ssize_t ath6kl_lrssi_roam_write(struct file *file,
  804. const char __user *user_buf,
  805. size_t count, loff_t *ppos)
  806. {
  807. struct ath6kl *ar = file->private_data;
  808. unsigned long lrssi_roam_threshold;
  809. if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
  810. return -EINVAL;
  811. ar->lrssi_roam_threshold = lrssi_roam_threshold;
  812. ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
  813. return count;
  814. }
  815. static ssize_t ath6kl_lrssi_roam_read(struct file *file,
  816. char __user *user_buf,
  817. size_t count, loff_t *ppos)
  818. {
  819. struct ath6kl *ar = file->private_data;
  820. char buf[32];
  821. unsigned int len;
  822. len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
  823. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  824. }
  825. static const struct file_operations fops_lrssi_roam_threshold = {
  826. .read = ath6kl_lrssi_roam_read,
  827. .write = ath6kl_lrssi_roam_write,
  828. .open = ath6kl_debugfs_open,
  829. .owner = THIS_MODULE,
  830. .llseek = default_llseek,
  831. };
  832. static ssize_t ath6kl_regwrite_read(struct file *file,
  833. char __user *user_buf,
  834. size_t count, loff_t *ppos)
  835. {
  836. struct ath6kl *ar = file->private_data;
  837. u8 buf[32];
  838. unsigned int len = 0;
  839. len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
  840. ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
  841. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  842. }
  843. static ssize_t ath6kl_regwrite_write(struct file *file,
  844. const char __user *user_buf,
  845. size_t count, loff_t *ppos)
  846. {
  847. struct ath6kl *ar = file->private_data;
  848. char buf[32];
  849. char *sptr, *token;
  850. unsigned int len = 0;
  851. u32 reg_addr, reg_val;
  852. len = min(count, sizeof(buf) - 1);
  853. if (copy_from_user(buf, user_buf, len))
  854. return -EFAULT;
  855. buf[len] = '\0';
  856. sptr = buf;
  857. token = strsep(&sptr, "=");
  858. if (!token)
  859. return -EINVAL;
  860. if (kstrtou32(token, 0, &reg_addr))
  861. return -EINVAL;
  862. if (!ath6kl_dbg_is_diag_reg_valid(reg_addr))
  863. return -EINVAL;
  864. if (kstrtou32(sptr, 0, &reg_val))
  865. return -EINVAL;
  866. ar->debug.diag_reg_addr_wr = reg_addr;
  867. ar->debug.diag_reg_val_wr = reg_val;
  868. if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr,
  869. cpu_to_le32(ar->debug.diag_reg_val_wr)))
  870. return -EIO;
  871. return count;
  872. }
  873. static const struct file_operations fops_diag_reg_write = {
  874. .read = ath6kl_regwrite_read,
  875. .write = ath6kl_regwrite_write,
  876. .open = ath6kl_debugfs_open,
  877. .owner = THIS_MODULE,
  878. .llseek = default_llseek,
  879. };
  880. int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
  881. size_t len)
  882. {
  883. const struct wmi_target_roam_tbl *tbl;
  884. u16 num_entries;
  885. if (len < sizeof(*tbl))
  886. return -EINVAL;
  887. tbl = (const struct wmi_target_roam_tbl *) buf;
  888. num_entries = le16_to_cpu(tbl->num_entries);
  889. if (sizeof(*tbl) + num_entries * sizeof(struct wmi_bss_roam_info) >
  890. len)
  891. return -EINVAL;
  892. if (ar->debug.roam_tbl == NULL ||
  893. ar->debug.roam_tbl_len < (unsigned int) len) {
  894. kfree(ar->debug.roam_tbl);
  895. ar->debug.roam_tbl = kmalloc(len, GFP_ATOMIC);
  896. if (ar->debug.roam_tbl == NULL)
  897. return -ENOMEM;
  898. }
  899. memcpy(ar->debug.roam_tbl, buf, len);
  900. ar->debug.roam_tbl_len = len;
  901. if (test_bit(ROAM_TBL_PEND, &ar->flag)) {
  902. clear_bit(ROAM_TBL_PEND, &ar->flag);
  903. wake_up(&ar->event_wq);
  904. }
  905. return 0;
  906. }
  907. static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
  908. size_t count, loff_t *ppos)
  909. {
  910. struct ath6kl *ar = file->private_data;
  911. int ret;
  912. long left;
  913. struct wmi_target_roam_tbl *tbl;
  914. u16 num_entries, i;
  915. char *buf;
  916. unsigned int len, buf_len;
  917. ssize_t ret_cnt;
  918. if (down_interruptible(&ar->sem))
  919. return -EBUSY;
  920. set_bit(ROAM_TBL_PEND, &ar->flag);
  921. ret = ath6kl_wmi_get_roam_tbl_cmd(ar->wmi);
  922. if (ret) {
  923. up(&ar->sem);
  924. return ret;
  925. }
  926. left = wait_event_interruptible_timeout(
  927. ar->event_wq, !test_bit(ROAM_TBL_PEND, &ar->flag), WMI_TIMEOUT);
  928. up(&ar->sem);
  929. if (left <= 0)
  930. return -ETIMEDOUT;
  931. if (ar->debug.roam_tbl == NULL)
  932. return -ENOMEM;
  933. tbl = (struct wmi_target_roam_tbl *) ar->debug.roam_tbl;
  934. num_entries = le16_to_cpu(tbl->num_entries);
  935. buf_len = 100 + num_entries * 100;
  936. buf = kzalloc(buf_len, GFP_KERNEL);
  937. if (buf == NULL)
  938. return -ENOMEM;
  939. len = 0;
  940. len += scnprintf(buf + len, buf_len - len,
  941. "roam_mode=%u\n\n"
  942. "# roam_util bssid rssi rssidt last_rssi util bias\n",
  943. le16_to_cpu(tbl->roam_mode));
  944. for (i = 0; i < num_entries; i++) {
  945. struct wmi_bss_roam_info *info = &tbl->info[i];
  946. len += scnprintf(buf + len, buf_len - len,
  947. "%d %pM %d %d %d %d %d\n",
  948. a_sle32_to_cpu(info->roam_util), info->bssid,
  949. info->rssi, info->rssidt, info->last_rssi,
  950. info->util, info->bias);
  951. }
  952. if (len > buf_len)
  953. len = buf_len;
  954. ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  955. kfree(buf);
  956. return ret_cnt;
  957. }
  958. static const struct file_operations fops_roam_table = {
  959. .read = ath6kl_roam_table_read,
  960. .open = ath6kl_debugfs_open,
  961. .owner = THIS_MODULE,
  962. .llseek = default_llseek,
  963. };
  964. static ssize_t ath6kl_force_roam_write(struct file *file,
  965. const char __user *user_buf,
  966. size_t count, loff_t *ppos)
  967. {
  968. struct ath6kl *ar = file->private_data;
  969. int ret;
  970. char buf[20];
  971. size_t len;
  972. u8 bssid[ETH_ALEN];
  973. int i;
  974. int addr[ETH_ALEN];
  975. len = min(count, sizeof(buf) - 1);
  976. if (copy_from_user(buf, user_buf, len))
  977. return -EFAULT;
  978. buf[len] = '\0';
  979. if (sscanf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
  980. &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
  981. != ETH_ALEN)
  982. return -EINVAL;
  983. for (i = 0; i < ETH_ALEN; i++)
  984. bssid[i] = addr[i];
  985. ret = ath6kl_wmi_force_roam_cmd(ar->wmi, bssid);
  986. if (ret)
  987. return ret;
  988. return count;
  989. }
  990. static const struct file_operations fops_force_roam = {
  991. .write = ath6kl_force_roam_write,
  992. .open = ath6kl_debugfs_open,
  993. .owner = THIS_MODULE,
  994. .llseek = default_llseek,
  995. };
  996. static ssize_t ath6kl_roam_mode_write(struct file *file,
  997. const char __user *user_buf,
  998. size_t count, loff_t *ppos)
  999. {
  1000. struct ath6kl *ar = file->private_data;
  1001. int ret;
  1002. char buf[20];
  1003. size_t len;
  1004. enum wmi_roam_mode mode;
  1005. len = min(count, sizeof(buf) - 1);
  1006. if (copy_from_user(buf, user_buf, len))
  1007. return -EFAULT;
  1008. buf[len] = '\0';
  1009. if (len > 0 && buf[len - 1] == '\n')
  1010. buf[len - 1] = '\0';
  1011. if (strcasecmp(buf, "default") == 0)
  1012. mode = WMI_DEFAULT_ROAM_MODE;
  1013. else if (strcasecmp(buf, "bssbias") == 0)
  1014. mode = WMI_HOST_BIAS_ROAM_MODE;
  1015. else if (strcasecmp(buf, "lock") == 0)
  1016. mode = WMI_LOCK_BSS_MODE;
  1017. else
  1018. return -EINVAL;
  1019. ret = ath6kl_wmi_set_roam_mode_cmd(ar->wmi, mode);
  1020. if (ret)
  1021. return ret;
  1022. return count;
  1023. }
  1024. static const struct file_operations fops_roam_mode = {
  1025. .write = ath6kl_roam_mode_write,
  1026. .open = ath6kl_debugfs_open,
  1027. .owner = THIS_MODULE,
  1028. .llseek = default_llseek,
  1029. };
  1030. void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
  1031. {
  1032. ar->debug.keepalive = keepalive;
  1033. }
  1034. static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
  1035. size_t count, loff_t *ppos)
  1036. {
  1037. struct ath6kl *ar = file->private_data;
  1038. char buf[16];
  1039. int len;
  1040. len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
  1041. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1042. }
  1043. static ssize_t ath6kl_keepalive_write(struct file *file,
  1044. const char __user *user_buf,
  1045. size_t count, loff_t *ppos)
  1046. {
  1047. struct ath6kl *ar = file->private_data;
  1048. int ret;
  1049. u8 val;
  1050. ret = kstrtou8_from_user(user_buf, count, 0, &val);
  1051. if (ret)
  1052. return ret;
  1053. ret = ath6kl_wmi_set_keepalive_cmd(ar->wmi, 0, val);
  1054. if (ret)
  1055. return ret;
  1056. return count;
  1057. }
  1058. static const struct file_operations fops_keepalive = {
  1059. .open = ath6kl_debugfs_open,
  1060. .read = ath6kl_keepalive_read,
  1061. .write = ath6kl_keepalive_write,
  1062. .owner = THIS_MODULE,
  1063. .llseek = default_llseek,
  1064. };
  1065. void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
  1066. {
  1067. ar->debug.disc_timeout = timeout;
  1068. }
  1069. static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
  1070. char __user *user_buf,
  1071. size_t count, loff_t *ppos)
  1072. {
  1073. struct ath6kl *ar = file->private_data;
  1074. char buf[16];
  1075. int len;
  1076. len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
  1077. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1078. }
  1079. static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
  1080. const char __user *user_buf,
  1081. size_t count, loff_t *ppos)
  1082. {
  1083. struct ath6kl *ar = file->private_data;
  1084. int ret;
  1085. u8 val;
  1086. ret = kstrtou8_from_user(user_buf, count, 0, &val);
  1087. if (ret)
  1088. return ret;
  1089. ret = ath6kl_wmi_disctimeout_cmd(ar->wmi, 0, val);
  1090. if (ret)
  1091. return ret;
  1092. return count;
  1093. }
  1094. static const struct file_operations fops_disconnect_timeout = {
  1095. .open = ath6kl_debugfs_open,
  1096. .read = ath6kl_disconnect_timeout_read,
  1097. .write = ath6kl_disconnect_timeout_write,
  1098. .owner = THIS_MODULE,
  1099. .llseek = default_llseek,
  1100. };
  1101. static ssize_t ath6kl_create_qos_write(struct file *file,
  1102. const char __user *user_buf,
  1103. size_t count, loff_t *ppos)
  1104. {
  1105. struct ath6kl *ar = file->private_data;
  1106. struct ath6kl_vif *vif;
  1107. char buf[200];
  1108. ssize_t len;
  1109. char *sptr, *token;
  1110. struct wmi_create_pstream_cmd pstream;
  1111. u32 val32;
  1112. u16 val16;
  1113. vif = ath6kl_vif_first(ar);
  1114. if (!vif)
  1115. return -EIO;
  1116. len = min(count, sizeof(buf) - 1);
  1117. if (copy_from_user(buf, user_buf, len))
  1118. return -EFAULT;
  1119. buf[len] = '\0';
  1120. sptr = buf;
  1121. token = strsep(&sptr, " ");
  1122. if (!token)
  1123. return -EINVAL;
  1124. if (kstrtou8(token, 0, &pstream.user_pri))
  1125. return -EINVAL;
  1126. token = strsep(&sptr, " ");
  1127. if (!token)
  1128. return -EINVAL;
  1129. if (kstrtou8(token, 0, &pstream.traffic_direc))
  1130. return -EINVAL;
  1131. token = strsep(&sptr, " ");
  1132. if (!token)
  1133. return -EINVAL;
  1134. if (kstrtou8(token, 0, &pstream.traffic_class))
  1135. return -EINVAL;
  1136. token = strsep(&sptr, " ");
  1137. if (!token)
  1138. return -EINVAL;
  1139. if (kstrtou8(token, 0, &pstream.traffic_type))
  1140. return -EINVAL;
  1141. token = strsep(&sptr, " ");
  1142. if (!token)
  1143. return -EINVAL;
  1144. if (kstrtou8(token, 0, &pstream.voice_psc_cap))
  1145. return -EINVAL;
  1146. token = strsep(&sptr, " ");
  1147. if (!token)
  1148. return -EINVAL;
  1149. if (kstrtou32(token, 0, &val32))
  1150. return -EINVAL;
  1151. pstream.min_service_int = cpu_to_le32(val32);
  1152. token = strsep(&sptr, " ");
  1153. if (!token)
  1154. return -EINVAL;
  1155. if (kstrtou32(token, 0, &val32))
  1156. return -EINVAL;
  1157. pstream.max_service_int = cpu_to_le32(val32);
  1158. token = strsep(&sptr, " ");
  1159. if (!token)
  1160. return -EINVAL;
  1161. if (kstrtou32(token, 0, &val32))
  1162. return -EINVAL;
  1163. pstream.inactivity_int = cpu_to_le32(val32);
  1164. token = strsep(&sptr, " ");
  1165. if (!token)
  1166. return -EINVAL;
  1167. if (kstrtou32(token, 0, &val32))
  1168. return -EINVAL;
  1169. pstream.suspension_int = cpu_to_le32(val32);
  1170. token = strsep(&sptr, " ");
  1171. if (!token)
  1172. return -EINVAL;
  1173. if (kstrtou32(token, 0, &val32))
  1174. return -EINVAL;
  1175. pstream.service_start_time = cpu_to_le32(val32);
  1176. token = strsep(&sptr, " ");
  1177. if (!token)
  1178. return -EINVAL;
  1179. if (kstrtou8(token, 0, &pstream.tsid))
  1180. return -EINVAL;
  1181. token = strsep(&sptr, " ");
  1182. if (!token)
  1183. return -EINVAL;
  1184. if (kstrtou16(token, 0, &val16))
  1185. return -EINVAL;
  1186. pstream.nominal_msdu = cpu_to_le16(val16);
  1187. token = strsep(&sptr, " ");
  1188. if (!token)
  1189. return -EINVAL;
  1190. if (kstrtou16(token, 0, &val16))
  1191. return -EINVAL;
  1192. pstream.max_msdu = cpu_to_le16(val16);
  1193. token = strsep(&sptr, " ");
  1194. if (!token)
  1195. return -EINVAL;
  1196. if (kstrtou32(token, 0, &val32))
  1197. return -EINVAL;
  1198. pstream.min_data_rate = cpu_to_le32(val32);
  1199. token = strsep(&sptr, " ");
  1200. if (!token)
  1201. return -EINVAL;
  1202. if (kstrtou32(token, 0, &val32))
  1203. return -EINVAL;
  1204. pstream.mean_data_rate = cpu_to_le32(val32);
  1205. token = strsep(&sptr, " ");
  1206. if (!token)
  1207. return -EINVAL;
  1208. if (kstrtou32(token, 0, &val32))
  1209. return -EINVAL;
  1210. pstream.peak_data_rate = cpu_to_le32(val32);
  1211. token = strsep(&sptr, " ");
  1212. if (!token)
  1213. return -EINVAL;
  1214. if (kstrtou32(token, 0, &val32))
  1215. return -EINVAL;
  1216. pstream.max_burst_size = cpu_to_le32(val32);
  1217. token = strsep(&sptr, " ");
  1218. if (!token)
  1219. return -EINVAL;
  1220. if (kstrtou32(token, 0, &val32))
  1221. return -EINVAL;
  1222. pstream.delay_bound = cpu_to_le32(val32);
  1223. token = strsep(&sptr, " ");
  1224. if (!token)
  1225. return -EINVAL;
  1226. if (kstrtou32(token, 0, &val32))
  1227. return -EINVAL;
  1228. pstream.min_phy_rate = cpu_to_le32(val32);
  1229. token = strsep(&sptr, " ");
  1230. if (!token)
  1231. return -EINVAL;
  1232. if (kstrtou32(token, 0, &val32))
  1233. return -EINVAL;
  1234. pstream.sba = cpu_to_le32(val32);
  1235. token = strsep(&sptr, " ");
  1236. if (!token)
  1237. return -EINVAL;
  1238. if (kstrtou32(token, 0, &val32))
  1239. return -EINVAL;
  1240. pstream.medium_time = cpu_to_le32(val32);
  1241. pstream.nominal_phy = le32_to_cpu(pstream.min_phy_rate) / 1000000;
  1242. ath6kl_wmi_create_pstream_cmd(ar->wmi, vif->fw_vif_idx, &pstream);
  1243. return count;
  1244. }
  1245. static const struct file_operations fops_create_qos = {
  1246. .write = ath6kl_create_qos_write,
  1247. .open = ath6kl_debugfs_open,
  1248. .owner = THIS_MODULE,
  1249. .llseek = default_llseek,
  1250. };
  1251. static ssize_t ath6kl_delete_qos_write(struct file *file,
  1252. const char __user *user_buf,
  1253. size_t count, loff_t *ppos)
  1254. {
  1255. struct ath6kl *ar = file->private_data;
  1256. struct ath6kl_vif *vif;
  1257. char buf[100];
  1258. ssize_t len;
  1259. char *sptr, *token;
  1260. u8 traffic_class;
  1261. u8 tsid;
  1262. vif = ath6kl_vif_first(ar);
  1263. if (!vif)
  1264. return -EIO;
  1265. len = min(count, sizeof(buf) - 1);
  1266. if (copy_from_user(buf, user_buf, len))
  1267. return -EFAULT;
  1268. buf[len] = '\0';
  1269. sptr = buf;
  1270. token = strsep(&sptr, " ");
  1271. if (!token)
  1272. return -EINVAL;
  1273. if (kstrtou8(token, 0, &traffic_class))
  1274. return -EINVAL;
  1275. token = strsep(&sptr, " ");
  1276. if (!token)
  1277. return -EINVAL;
  1278. if (kstrtou8(token, 0, &tsid))
  1279. return -EINVAL;
  1280. ath6kl_wmi_delete_pstream_cmd(ar->wmi, vif->fw_vif_idx,
  1281. traffic_class, tsid);
  1282. return count;
  1283. }
  1284. static const struct file_operations fops_delete_qos = {
  1285. .write = ath6kl_delete_qos_write,
  1286. .open = ath6kl_debugfs_open,
  1287. .owner = THIS_MODULE,
  1288. .llseek = default_llseek,
  1289. };
  1290. static ssize_t ath6kl_bgscan_int_write(struct file *file,
  1291. const char __user *user_buf,
  1292. size_t count, loff_t *ppos)
  1293. {
  1294. struct ath6kl *ar = file->private_data;
  1295. u16 bgscan_int;
  1296. char buf[32];
  1297. ssize_t len;
  1298. len = min(count, sizeof(buf) - 1);
  1299. if (copy_from_user(buf, user_buf, len))
  1300. return -EFAULT;
  1301. buf[len] = '\0';
  1302. if (kstrtou16(buf, 0, &bgscan_int))
  1303. return -EINVAL;
  1304. if (bgscan_int == 0)
  1305. bgscan_int = 0xffff;
  1306. ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3,
  1307. 0, 0, 0);
  1308. return count;
  1309. }
  1310. static const struct file_operations fops_bgscan_int = {
  1311. .write = ath6kl_bgscan_int_write,
  1312. .open = ath6kl_debugfs_open,
  1313. .owner = THIS_MODULE,
  1314. .llseek = default_llseek,
  1315. };
  1316. static ssize_t ath6kl_listen_int_write(struct file *file,
  1317. const char __user *user_buf,
  1318. size_t count, loff_t *ppos)
  1319. {
  1320. struct ath6kl *ar = file->private_data;
  1321. struct ath6kl_vif *vif;
  1322. u16 listen_interval;
  1323. char buf[32];
  1324. ssize_t len;
  1325. vif = ath6kl_vif_first(ar);
  1326. if (!vif)
  1327. return -EIO;
  1328. len = min(count, sizeof(buf) - 1);
  1329. if (copy_from_user(buf, user_buf, len))
  1330. return -EFAULT;
  1331. buf[len] = '\0';
  1332. if (kstrtou16(buf, 0, &listen_interval))
  1333. return -EINVAL;
  1334. if ((listen_interval < 15) || (listen_interval > 3000))
  1335. return -EINVAL;
  1336. vif->listen_intvl_t = listen_interval;
  1337. ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
  1338. vif->listen_intvl_t, 0);
  1339. return count;
  1340. }
  1341. static ssize_t ath6kl_listen_int_read(struct file *file,
  1342. char __user *user_buf,
  1343. size_t count, loff_t *ppos)
  1344. {
  1345. struct ath6kl *ar = file->private_data;
  1346. struct ath6kl_vif *vif;
  1347. char buf[32];
  1348. int len;
  1349. vif = ath6kl_vif_first(ar);
  1350. if (!vif)
  1351. return -EIO;
  1352. len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
  1353. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1354. }
  1355. static const struct file_operations fops_listen_int = {
  1356. .read = ath6kl_listen_int_read,
  1357. .write = ath6kl_listen_int_write,
  1358. .open = ath6kl_debugfs_open,
  1359. .owner = THIS_MODULE,
  1360. .llseek = default_llseek,
  1361. };
  1362. static ssize_t ath6kl_power_params_write(struct file *file,
  1363. const char __user *user_buf,
  1364. size_t count, loff_t *ppos)
  1365. {
  1366. struct ath6kl *ar = file->private_data;
  1367. u8 buf[100];
  1368. unsigned int len = 0;
  1369. char *sptr, *token;
  1370. u16 idle_period, ps_poll_num, dtim,
  1371. tx_wakeup, num_tx;
  1372. len = min(count, sizeof(buf) - 1);
  1373. if (copy_from_user(buf, user_buf, len))
  1374. return -EFAULT;
  1375. buf[len] = '\0';
  1376. sptr = buf;
  1377. token = strsep(&sptr, " ");
  1378. if (!token)
  1379. return -EINVAL;
  1380. if (kstrtou16(token, 0, &idle_period))
  1381. return -EINVAL;
  1382. token = strsep(&sptr, " ");
  1383. if (!token)
  1384. return -EINVAL;
  1385. if (kstrtou16(token, 0, &ps_poll_num))
  1386. return -EINVAL;
  1387. token = strsep(&sptr, " ");
  1388. if (!token)
  1389. return -EINVAL;
  1390. if (kstrtou16(token, 0, &dtim))
  1391. return -EINVAL;
  1392. token = strsep(&sptr, " ");
  1393. if (!token)
  1394. return -EINVAL;
  1395. if (kstrtou16(token, 0, &tx_wakeup))
  1396. return -EINVAL;
  1397. token = strsep(&sptr, " ");
  1398. if (!token)
  1399. return -EINVAL;
  1400. if (kstrtou16(token, 0, &num_tx))
  1401. return -EINVAL;
  1402. ath6kl_wmi_pmparams_cmd(ar->wmi, 0, idle_period, ps_poll_num,
  1403. dtim, tx_wakeup, num_tx, 0);
  1404. return count;
  1405. }
  1406. static const struct file_operations fops_power_params = {
  1407. .write = ath6kl_power_params_write,
  1408. .open = ath6kl_debugfs_open,
  1409. .owner = THIS_MODULE,
  1410. .llseek = default_llseek,
  1411. };
  1412. void ath6kl_debug_init(struct ath6kl *ar)
  1413. {
  1414. skb_queue_head_init(&ar->debug.fwlog_queue);
  1415. init_completion(&ar->debug.fwlog_completion);
  1416. /*
  1417. * Actually we are lying here but don't know how to read the mask
  1418. * value from the firmware.
  1419. */
  1420. ar->debug.fwlog_mask = 0;
  1421. }
  1422. /*
  1423. * Initialisation needs to happen in two stages as fwlog events can come
  1424. * before cfg80211 is initialised, and debugfs depends on cfg80211
  1425. * initialisation.
  1426. */
  1427. int ath6kl_debug_init_fs(struct ath6kl *ar)
  1428. {
  1429. ar->debugfs_phy = debugfs_create_dir("ath6kl",
  1430. ar->wiphy->debugfsdir);
  1431. if (!ar->debugfs_phy)
  1432. return -ENOMEM;
  1433. debugfs_create_file("tgt_stats", S_IRUSR, ar->debugfs_phy, ar,
  1434. &fops_tgt_stats);
  1435. debugfs_create_file("credit_dist_stats", S_IRUSR, ar->debugfs_phy, ar,
  1436. &fops_credit_dist_stats);
  1437. debugfs_create_file("endpoint_stats", S_IRUSR | S_IWUSR,
  1438. ar->debugfs_phy, ar, &fops_endpoint_stats);
  1439. debugfs_create_file("fwlog", S_IRUSR, ar->debugfs_phy, ar,
  1440. &fops_fwlog);
  1441. debugfs_create_file("fwlog_block", S_IRUSR, ar->debugfs_phy, ar,
  1442. &fops_fwlog_block);
  1443. debugfs_create_file("fwlog_mask", S_IRUSR | S_IWUSR, ar->debugfs_phy,
  1444. ar, &fops_fwlog_mask);
  1445. debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
  1446. &fops_diag_reg_read);
  1447. debugfs_create_file("reg_dump", S_IRUSR, ar->debugfs_phy, ar,
  1448. &fops_reg_dump);
  1449. debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR,
  1450. ar->debugfs_phy, ar, &fops_lrssi_roam_threshold);
  1451. debugfs_create_file("reg_write", S_IRUSR | S_IWUSR,
  1452. ar->debugfs_phy, ar, &fops_diag_reg_write);
  1453. debugfs_create_file("war_stats", S_IRUSR, ar->debugfs_phy, ar,
  1454. &fops_war_stats);
  1455. debugfs_create_file("roam_table", S_IRUSR, ar->debugfs_phy, ar,
  1456. &fops_roam_table);
  1457. debugfs_create_file("force_roam", S_IWUSR, ar->debugfs_phy, ar,
  1458. &fops_force_roam);
  1459. debugfs_create_file("roam_mode", S_IWUSR, ar->debugfs_phy, ar,
  1460. &fops_roam_mode);
  1461. debugfs_create_file("keepalive", S_IRUSR | S_IWUSR, ar->debugfs_phy, ar,
  1462. &fops_keepalive);
  1463. debugfs_create_file("disconnect_timeout", S_IRUSR | S_IWUSR,
  1464. ar->debugfs_phy, ar, &fops_disconnect_timeout);
  1465. debugfs_create_file("create_qos", S_IWUSR, ar->debugfs_phy, ar,
  1466. &fops_create_qos);
  1467. debugfs_create_file("delete_qos", S_IWUSR, ar->debugfs_phy, ar,
  1468. &fops_delete_qos);
  1469. debugfs_create_file("bgscan_interval", S_IWUSR,
  1470. ar->debugfs_phy, ar, &fops_bgscan_int);
  1471. debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR,
  1472. ar->debugfs_phy, ar, &fops_listen_int);
  1473. debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar,
  1474. &fops_power_params);
  1475. return 0;
  1476. }
  1477. void ath6kl_debug_cleanup(struct ath6kl *ar)
  1478. {
  1479. skb_queue_purge(&ar->debug.fwlog_queue);
  1480. kfree(ar->debug.roam_tbl);
  1481. }
  1482. #endif