debug.c 45 KB

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