debugfs.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
  1. /*
  2. * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/debugfs.h>
  18. #include <linux/seq_file.h>
  19. #include <linux/pci.h>
  20. #include <linux/rtnetlink.h>
  21. #include <linux/power_supply.h>
  22. #include "wil6210.h"
  23. #include "wmi.h"
  24. #include "txrx.h"
  25. #include "pmc.h"
  26. /* Nasty hack. Better have per device instances */
  27. static u32 mem_addr;
  28. static u32 dbg_txdesc_index;
  29. static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
  30. enum dbg_off_type {
  31. doff_u32 = 0,
  32. doff_x32 = 1,
  33. doff_ulong = 2,
  34. doff_io32 = 3,
  35. doff_u8 = 4
  36. };
  37. /* offset to "wil" */
  38. struct dbg_off {
  39. const char *name;
  40. umode_t mode;
  41. ulong off;
  42. enum dbg_off_type type;
  43. };
  44. static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
  45. const char *name, struct vring *vring,
  46. char _s, char _h)
  47. {
  48. void __iomem *x = wmi_addr(wil, vring->hwtail);
  49. u32 v;
  50. seq_printf(s, "VRING %s = {\n", name);
  51. seq_printf(s, " pa = %pad\n", &vring->pa);
  52. seq_printf(s, " va = 0x%p\n", vring->va);
  53. seq_printf(s, " size = %d\n", vring->size);
  54. seq_printf(s, " swtail = %d\n", vring->swtail);
  55. seq_printf(s, " swhead = %d\n", vring->swhead);
  56. seq_printf(s, " hwtail = [0x%08x] -> ", vring->hwtail);
  57. if (x) {
  58. v = readl(x);
  59. seq_printf(s, "0x%08x = %d\n", v, v);
  60. } else {
  61. seq_puts(s, "???\n");
  62. }
  63. if (vring->va && (vring->size <= (1 << WIL_RING_SIZE_ORDER_MAX))) {
  64. uint i;
  65. for (i = 0; i < vring->size; i++) {
  66. volatile struct vring_tx_desc *d = &vring->va[i].tx;
  67. if ((i % 128) == 0 && (i != 0))
  68. seq_puts(s, "\n");
  69. seq_printf(s, "%c", (d->dma.status & BIT(0)) ?
  70. _s : (vring->ctx[i].skb ? _h : 'h'));
  71. }
  72. seq_puts(s, "\n");
  73. }
  74. seq_puts(s, "}\n");
  75. }
  76. static int wil_vring_debugfs_show(struct seq_file *s, void *data)
  77. {
  78. uint i;
  79. struct wil6210_priv *wil = s->private;
  80. wil_print_vring(s, wil, "rx", &wil->vring_rx, 'S', '_');
  81. for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) {
  82. struct vring *vring = &wil->vring_tx[i];
  83. struct vring_tx_data *txdata = &wil->vring_tx_data[i];
  84. if (vring->va) {
  85. int cid = wil->vring2cid_tid[i][0];
  86. int tid = wil->vring2cid_tid[i][1];
  87. u32 swhead = vring->swhead;
  88. u32 swtail = vring->swtail;
  89. int used = (vring->size + swhead - swtail)
  90. % vring->size;
  91. int avail = vring->size - used - 1;
  92. char name[10];
  93. char sidle[10];
  94. /* performance monitoring */
  95. cycles_t now = get_cycles();
  96. uint64_t idle = txdata->idle * 100;
  97. uint64_t total = now - txdata->begin;
  98. if (total != 0) {
  99. do_div(idle, total);
  100. snprintf(sidle, sizeof(sidle), "%3d%%",
  101. (int)idle);
  102. } else {
  103. snprintf(sidle, sizeof(sidle), "N/A");
  104. }
  105. txdata->begin = now;
  106. txdata->idle = 0ULL;
  107. snprintf(name, sizeof(name), "tx_%2d", i);
  108. if (cid < WIL6210_MAX_CID)
  109. seq_printf(s,
  110. "\n%pM CID %d TID %d 1x%s BACK([%u] %u TU A%s) [%3d|%3d] idle %s\n",
  111. wil->sta[cid].addr, cid, tid,
  112. txdata->dot1x_open ? "+" : "-",
  113. txdata->agg_wsize,
  114. txdata->agg_timeout,
  115. txdata->agg_amsdu ? "+" : "-",
  116. used, avail, sidle);
  117. else
  118. seq_printf(s,
  119. "\nBroadcast 1x%s [%3d|%3d] idle %s\n",
  120. txdata->dot1x_open ? "+" : "-",
  121. used, avail, sidle);
  122. wil_print_vring(s, wil, name, vring, '_', 'H');
  123. }
  124. }
  125. return 0;
  126. }
  127. static int wil_vring_seq_open(struct inode *inode, struct file *file)
  128. {
  129. return single_open(file, wil_vring_debugfs_show, inode->i_private);
  130. }
  131. static const struct file_operations fops_vring = {
  132. .open = wil_vring_seq_open,
  133. .release = single_release,
  134. .read = seq_read,
  135. .llseek = seq_lseek,
  136. };
  137. static void wil_seq_hexdump(struct seq_file *s, void *p, int len,
  138. const char *prefix)
  139. {
  140. seq_hex_dump(s, prefix, DUMP_PREFIX_NONE, 16, 1, p, len, false);
  141. }
  142. static void wil_print_ring(struct seq_file *s, const char *prefix,
  143. void __iomem *off)
  144. {
  145. struct wil6210_priv *wil = s->private;
  146. struct wil6210_mbox_ring r;
  147. int rsize;
  148. uint i;
  149. wil_halp_vote(wil);
  150. wil_memcpy_fromio_32(&r, off, sizeof(r));
  151. wil_mbox_ring_le2cpus(&r);
  152. /*
  153. * we just read memory block from NIC. This memory may be
  154. * garbage. Check validity before using it.
  155. */
  156. rsize = r.size / sizeof(struct wil6210_mbox_ring_desc);
  157. seq_printf(s, "ring %s = {\n", prefix);
  158. seq_printf(s, " base = 0x%08x\n", r.base);
  159. seq_printf(s, " size = 0x%04x bytes -> %d entries\n", r.size, rsize);
  160. seq_printf(s, " tail = 0x%08x\n", r.tail);
  161. seq_printf(s, " head = 0x%08x\n", r.head);
  162. seq_printf(s, " entry size = %d\n", r.entry_size);
  163. if (r.size % sizeof(struct wil6210_mbox_ring_desc)) {
  164. seq_printf(s, " ??? size is not multiple of %zd, garbage?\n",
  165. sizeof(struct wil6210_mbox_ring_desc));
  166. goto out;
  167. }
  168. if (!wmi_addr(wil, r.base) ||
  169. !wmi_addr(wil, r.tail) ||
  170. !wmi_addr(wil, r.head)) {
  171. seq_puts(s, " ??? pointers are garbage?\n");
  172. goto out;
  173. }
  174. for (i = 0; i < rsize; i++) {
  175. struct wil6210_mbox_ring_desc d;
  176. struct wil6210_mbox_hdr hdr;
  177. size_t delta = i * sizeof(d);
  178. void __iomem *x = wil->csr + HOSTADDR(r.base) + delta;
  179. wil_memcpy_fromio_32(&d, x, sizeof(d));
  180. seq_printf(s, " [%2x] %s %s%s 0x%08x", i,
  181. d.sync ? "F" : "E",
  182. (r.tail - r.base == delta) ? "t" : " ",
  183. (r.head - r.base == delta) ? "h" : " ",
  184. le32_to_cpu(d.addr));
  185. if (0 == wmi_read_hdr(wil, d.addr, &hdr)) {
  186. u16 len = le16_to_cpu(hdr.len);
  187. seq_printf(s, " -> %04x %04x %04x %02x\n",
  188. le16_to_cpu(hdr.seq), len,
  189. le16_to_cpu(hdr.type), hdr.flags);
  190. if (len <= MAX_MBOXITEM_SIZE) {
  191. unsigned char databuf[MAX_MBOXITEM_SIZE];
  192. void __iomem *src = wmi_buffer(wil, d.addr) +
  193. sizeof(struct wil6210_mbox_hdr);
  194. /*
  195. * No need to check @src for validity -
  196. * we already validated @d.addr while
  197. * reading header
  198. */
  199. wil_memcpy_fromio_32(databuf, src, len);
  200. wil_seq_hexdump(s, databuf, len, " : ");
  201. }
  202. } else {
  203. seq_puts(s, "\n");
  204. }
  205. }
  206. out:
  207. seq_puts(s, "}\n");
  208. wil_halp_unvote(wil);
  209. }
  210. static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
  211. {
  212. struct wil6210_priv *wil = s->private;
  213. wil_print_ring(s, "tx", wil->csr + HOST_MBOX +
  214. offsetof(struct wil6210_mbox_ctl, tx));
  215. wil_print_ring(s, "rx", wil->csr + HOST_MBOX +
  216. offsetof(struct wil6210_mbox_ctl, rx));
  217. return 0;
  218. }
  219. static int wil_mbox_seq_open(struct inode *inode, struct file *file)
  220. {
  221. return single_open(file, wil_mbox_debugfs_show, inode->i_private);
  222. }
  223. static const struct file_operations fops_mbox = {
  224. .open = wil_mbox_seq_open,
  225. .release = single_release,
  226. .read = seq_read,
  227. .llseek = seq_lseek,
  228. };
  229. static int wil_debugfs_iomem_x32_set(void *data, u64 val)
  230. {
  231. writel(val, (void __iomem *)data);
  232. wmb(); /* make sure write propagated to HW */
  233. return 0;
  234. }
  235. static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
  236. {
  237. *val = readl((void __iomem *)data);
  238. return 0;
  239. }
  240. DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
  241. wil_debugfs_iomem_x32_set, "0x%08llx\n");
  242. static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
  243. umode_t mode,
  244. struct dentry *parent,
  245. void *value)
  246. {
  247. return debugfs_create_file(name, mode, parent, value,
  248. &fops_iomem_x32);
  249. }
  250. static int wil_debugfs_ulong_set(void *data, u64 val)
  251. {
  252. *(ulong *)data = val;
  253. return 0;
  254. }
  255. static int wil_debugfs_ulong_get(void *data, u64 *val)
  256. {
  257. *val = *(ulong *)data;
  258. return 0;
  259. }
  260. DEFINE_SIMPLE_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get,
  261. wil_debugfs_ulong_set, "0x%llx\n");
  262. static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode,
  263. struct dentry *parent,
  264. ulong *value)
  265. {
  266. return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong);
  267. }
  268. /**
  269. * wil6210_debugfs_init_offset - create set of debugfs files
  270. * @wil - driver's context, used for printing
  271. * @dbg - directory on the debugfs, where files will be created
  272. * @base - base address used in address calculation
  273. * @tbl - table with file descriptions. Should be terminated with empty element.
  274. *
  275. * Creates files accordingly to the @tbl.
  276. */
  277. static void wil6210_debugfs_init_offset(struct wil6210_priv *wil,
  278. struct dentry *dbg, void *base,
  279. const struct dbg_off * const tbl)
  280. {
  281. int i;
  282. for (i = 0; tbl[i].name; i++) {
  283. struct dentry *f;
  284. switch (tbl[i].type) {
  285. case doff_u32:
  286. f = debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg,
  287. base + tbl[i].off);
  288. break;
  289. case doff_x32:
  290. f = debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg,
  291. base + tbl[i].off);
  292. break;
  293. case doff_ulong:
  294. f = wil_debugfs_create_ulong(tbl[i].name, tbl[i].mode,
  295. dbg, base + tbl[i].off);
  296. break;
  297. case doff_io32:
  298. f = wil_debugfs_create_iomem_x32(tbl[i].name,
  299. tbl[i].mode, dbg,
  300. base + tbl[i].off);
  301. break;
  302. case doff_u8:
  303. f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg,
  304. base + tbl[i].off);
  305. break;
  306. default:
  307. f = ERR_PTR(-EINVAL);
  308. }
  309. if (IS_ERR_OR_NULL(f))
  310. wil_err(wil, "Create file \"%s\": err %ld\n",
  311. tbl[i].name, PTR_ERR(f));
  312. }
  313. }
  314. static const struct dbg_off isr_off[] = {
  315. {"ICC", 0644, offsetof(struct RGF_ICR, ICC), doff_io32},
  316. {"ICR", 0644, offsetof(struct RGF_ICR, ICR), doff_io32},
  317. {"ICM", 0644, offsetof(struct RGF_ICR, ICM), doff_io32},
  318. {"ICS", 0244, offsetof(struct RGF_ICR, ICS), doff_io32},
  319. {"IMV", 0644, offsetof(struct RGF_ICR, IMV), doff_io32},
  320. {"IMS", 0244, offsetof(struct RGF_ICR, IMS), doff_io32},
  321. {"IMC", 0244, offsetof(struct RGF_ICR, IMC), doff_io32},
  322. {},
  323. };
  324. static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
  325. const char *name,
  326. struct dentry *parent, u32 off)
  327. {
  328. struct dentry *d = debugfs_create_dir(name, parent);
  329. if (IS_ERR_OR_NULL(d))
  330. return -ENODEV;
  331. wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr + off,
  332. isr_off);
  333. return 0;
  334. }
  335. static const struct dbg_off pseudo_isr_off[] = {
  336. {"CAUSE", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32},
  337. {"MASK_SW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32},
  338. {"MASK_FW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32},
  339. {},
  340. };
  341. static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
  342. struct dentry *parent)
  343. {
  344. struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent);
  345. if (IS_ERR_OR_NULL(d))
  346. return -ENODEV;
  347. wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
  348. pseudo_isr_off);
  349. return 0;
  350. }
  351. static const struct dbg_off lgc_itr_cnt_off[] = {
  352. {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32},
  353. {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32},
  354. {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32},
  355. {},
  356. };
  357. static const struct dbg_off tx_itr_cnt_off[] = {
  358. {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_TRSH),
  359. doff_io32},
  360. {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_DATA),
  361. doff_io32},
  362. {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_CTL),
  363. doff_io32},
  364. {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_TRSH),
  365. doff_io32},
  366. {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_DATA),
  367. doff_io32},
  368. {"IDL_CTL", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_CTL),
  369. doff_io32},
  370. {},
  371. };
  372. static const struct dbg_off rx_itr_cnt_off[] = {
  373. {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_TRSH),
  374. doff_io32},
  375. {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_DATA),
  376. doff_io32},
  377. {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_CTL),
  378. doff_io32},
  379. {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_TRSH),
  380. doff_io32},
  381. {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_DATA),
  382. doff_io32},
  383. {"IDL_CTL", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_CTL),
  384. doff_io32},
  385. {},
  386. };
  387. static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
  388. struct dentry *parent)
  389. {
  390. struct dentry *d, *dtx, *drx;
  391. d = debugfs_create_dir("ITR_CNT", parent);
  392. if (IS_ERR_OR_NULL(d))
  393. return -ENODEV;
  394. dtx = debugfs_create_dir("TX", d);
  395. drx = debugfs_create_dir("RX", d);
  396. if (IS_ERR_OR_NULL(dtx) || IS_ERR_OR_NULL(drx))
  397. return -ENODEV;
  398. wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
  399. lgc_itr_cnt_off);
  400. wil6210_debugfs_init_offset(wil, dtx, (void * __force)wil->csr,
  401. tx_itr_cnt_off);
  402. wil6210_debugfs_init_offset(wil, drx, (void * __force)wil->csr,
  403. rx_itr_cnt_off);
  404. return 0;
  405. }
  406. static int wil_memread_debugfs_show(struct seq_file *s, void *data)
  407. {
  408. struct wil6210_priv *wil = s->private;
  409. void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr));
  410. if (a)
  411. seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, readl(a));
  412. else
  413. seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
  414. return 0;
  415. }
  416. static int wil_memread_seq_open(struct inode *inode, struct file *file)
  417. {
  418. return single_open(file, wil_memread_debugfs_show, inode->i_private);
  419. }
  420. static const struct file_operations fops_memread = {
  421. .open = wil_memread_seq_open,
  422. .release = single_release,
  423. .read = seq_read,
  424. .llseek = seq_lseek,
  425. };
  426. static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
  427. size_t count, loff_t *ppos)
  428. {
  429. enum { max_count = 4096 };
  430. struct wil_blob_wrapper *wil_blob = file->private_data;
  431. loff_t pos = *ppos;
  432. size_t available = wil_blob->blob.size;
  433. void *buf;
  434. size_t ret;
  435. if (test_bit(wil_status_suspending, wil_blob->wil->status) ||
  436. test_bit(wil_status_suspended, wil_blob->wil->status))
  437. return 0;
  438. if (pos < 0)
  439. return -EINVAL;
  440. if (pos >= available || !count)
  441. return 0;
  442. if (count > available - pos)
  443. count = available - pos;
  444. if (count > max_count)
  445. count = max_count;
  446. buf = kmalloc(count, GFP_KERNEL);
  447. if (!buf)
  448. return -ENOMEM;
  449. wil_memcpy_fromio_32(buf, (const void __iomem *)
  450. wil_blob->blob.data + pos, count);
  451. ret = copy_to_user(user_buf, buf, count);
  452. kfree(buf);
  453. if (ret == count)
  454. return -EFAULT;
  455. count -= ret;
  456. *ppos = pos + count;
  457. return count;
  458. }
  459. static const struct file_operations fops_ioblob = {
  460. .read = wil_read_file_ioblob,
  461. .open = simple_open,
  462. .llseek = default_llseek,
  463. };
  464. static
  465. struct dentry *wil_debugfs_create_ioblob(const char *name,
  466. umode_t mode,
  467. struct dentry *parent,
  468. struct wil_blob_wrapper *wil_blob)
  469. {
  470. return debugfs_create_file(name, mode, parent, wil_blob, &fops_ioblob);
  471. }
  472. /*---reset---*/
  473. static ssize_t wil_write_file_reset(struct file *file, const char __user *buf,
  474. size_t len, loff_t *ppos)
  475. {
  476. struct wil6210_priv *wil = file->private_data;
  477. struct net_device *ndev = wil_to_ndev(wil);
  478. /**
  479. * BUG:
  480. * this code does NOT sync device state with the rest of system
  481. * use with care, debug only!!!
  482. */
  483. rtnl_lock();
  484. dev_close(ndev);
  485. ndev->flags &= ~IFF_UP;
  486. rtnl_unlock();
  487. wil_reset(wil, true);
  488. return len;
  489. }
  490. static const struct file_operations fops_reset = {
  491. .write = wil_write_file_reset,
  492. .open = simple_open,
  493. };
  494. /*---write channel 1..4 to rxon for it, 0 to rxoff---*/
  495. static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
  496. size_t len, loff_t *ppos)
  497. {
  498. struct wil6210_priv *wil = file->private_data;
  499. int rc;
  500. long channel;
  501. bool on;
  502. char *kbuf = memdup_user_nul(buf, len);
  503. if (IS_ERR(kbuf))
  504. return PTR_ERR(kbuf);
  505. rc = kstrtol(kbuf, 0, &channel);
  506. kfree(kbuf);
  507. if (rc)
  508. return rc;
  509. if ((channel < 0) || (channel > 4)) {
  510. wil_err(wil, "Invalid channel %ld\n", channel);
  511. return -EINVAL;
  512. }
  513. on = !!channel;
  514. if (on) {
  515. rc = wmi_set_channel(wil, (int)channel);
  516. if (rc)
  517. return rc;
  518. }
  519. rc = wmi_rxon(wil, on);
  520. if (rc)
  521. return rc;
  522. return len;
  523. }
  524. static const struct file_operations fops_rxon = {
  525. .write = wil_write_file_rxon,
  526. .open = simple_open,
  527. };
  528. /* block ack control, write:
  529. * - "add <ringid> <agg_size> <timeout>" to trigger ADDBA
  530. * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side
  531. * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side
  532. */
  533. static ssize_t wil_write_back(struct file *file, const char __user *buf,
  534. size_t len, loff_t *ppos)
  535. {
  536. struct wil6210_priv *wil = file->private_data;
  537. int rc;
  538. char *kbuf = kmalloc(len + 1, GFP_KERNEL);
  539. char cmd[9];
  540. int p1, p2, p3;
  541. if (!kbuf)
  542. return -ENOMEM;
  543. rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
  544. if (rc != len) {
  545. kfree(kbuf);
  546. return rc >= 0 ? -EIO : rc;
  547. }
  548. kbuf[len] = '\0';
  549. rc = sscanf(kbuf, "%8s %d %d %d", cmd, &p1, &p2, &p3);
  550. kfree(kbuf);
  551. if (rc < 0)
  552. return rc;
  553. if (rc < 2)
  554. return -EINVAL;
  555. if (0 == strcmp(cmd, "add")) {
  556. if (rc < 3) {
  557. wil_err(wil, "BACK: add require at least 2 params\n");
  558. return -EINVAL;
  559. }
  560. if (rc < 4)
  561. p3 = 0;
  562. wmi_addba(wil, p1, p2, p3);
  563. } else if (0 == strcmp(cmd, "del_tx")) {
  564. if (rc < 3)
  565. p2 = WLAN_REASON_QSTA_LEAVE_QBSS;
  566. wmi_delba_tx(wil, p1, p2);
  567. } else if (0 == strcmp(cmd, "del_rx")) {
  568. if (rc < 3) {
  569. wil_err(wil,
  570. "BACK: del_rx require at least 2 params\n");
  571. return -EINVAL;
  572. }
  573. if (rc < 4)
  574. p3 = WLAN_REASON_QSTA_LEAVE_QBSS;
  575. wmi_delba_rx(wil, mk_cidxtid(p1, p2), p3);
  576. } else {
  577. wil_err(wil, "BACK: Unrecognized command \"%s\"\n", cmd);
  578. return -EINVAL;
  579. }
  580. return len;
  581. }
  582. static ssize_t wil_read_back(struct file *file, char __user *user_buf,
  583. size_t count, loff_t *ppos)
  584. {
  585. static const char text[] = "block ack control, write:\n"
  586. " - \"add <ringid> <agg_size> <timeout>\" to trigger ADDBA\n"
  587. "If missing, <timeout> defaults to 0\n"
  588. " - \"del_tx <ringid> <reason>\" to trigger DELBA for Tx side\n"
  589. " - \"del_rx <CID> <TID> <reason>\" to trigger DELBA for Rx side\n"
  590. "If missing, <reason> set to \"STA_LEAVING\" (36)\n";
  591. return simple_read_from_buffer(user_buf, count, ppos, text,
  592. sizeof(text));
  593. }
  594. static const struct file_operations fops_back = {
  595. .read = wil_read_back,
  596. .write = wil_write_back,
  597. .open = simple_open,
  598. };
  599. /* pmc control, write:
  600. * - "alloc <num descriptors> <descriptor_size>" to allocate PMC
  601. * - "free" to release memory allocated for PMC
  602. */
  603. static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
  604. size_t len, loff_t *ppos)
  605. {
  606. struct wil6210_priv *wil = file->private_data;
  607. int rc;
  608. char *kbuf = kmalloc(len + 1, GFP_KERNEL);
  609. char cmd[9];
  610. int num_descs, desc_size;
  611. if (!kbuf)
  612. return -ENOMEM;
  613. rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
  614. if (rc != len) {
  615. kfree(kbuf);
  616. return rc >= 0 ? -EIO : rc;
  617. }
  618. kbuf[len] = '\0';
  619. rc = sscanf(kbuf, "%8s %d %d", cmd, &num_descs, &desc_size);
  620. kfree(kbuf);
  621. if (rc < 0)
  622. return rc;
  623. if (rc < 1) {
  624. wil_err(wil, "pmccfg: no params given\n");
  625. return -EINVAL;
  626. }
  627. if (0 == strcmp(cmd, "alloc")) {
  628. if (rc != 3) {
  629. wil_err(wil, "pmccfg: alloc requires 2 params\n");
  630. return -EINVAL;
  631. }
  632. wil_pmc_alloc(wil, num_descs, desc_size);
  633. } else if (0 == strcmp(cmd, "free")) {
  634. if (rc != 1) {
  635. wil_err(wil, "pmccfg: free does not have any params\n");
  636. return -EINVAL;
  637. }
  638. wil_pmc_free(wil, true);
  639. } else {
  640. wil_err(wil, "pmccfg: Unrecognized command \"%s\"\n", cmd);
  641. return -EINVAL;
  642. }
  643. return len;
  644. }
  645. static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
  646. size_t count, loff_t *ppos)
  647. {
  648. struct wil6210_priv *wil = file->private_data;
  649. char text[256];
  650. char help[] = "pmc control, write:\n"
  651. " - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
  652. " - \"free\" to free memory allocated for pmc\n";
  653. sprintf(text, "Last command status: %d\n\n%s",
  654. wil_pmc_last_cmd_status(wil),
  655. help);
  656. return simple_read_from_buffer(user_buf, count, ppos, text,
  657. strlen(text) + 1);
  658. }
  659. static const struct file_operations fops_pmccfg = {
  660. .read = wil_read_pmccfg,
  661. .write = wil_write_pmccfg,
  662. .open = simple_open,
  663. };
  664. static const struct file_operations fops_pmcdata = {
  665. .open = simple_open,
  666. .read = wil_pmc_read,
  667. .llseek = wil_pmc_llseek,
  668. };
  669. /*---tx_mgmt---*/
  670. /* Write mgmt frame to this file to send it */
  671. static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
  672. size_t len, loff_t *ppos)
  673. {
  674. struct wil6210_priv *wil = file->private_data;
  675. struct wiphy *wiphy = wil_to_wiphy(wil);
  676. struct wireless_dev *wdev = wil_to_wdev(wil);
  677. struct cfg80211_mgmt_tx_params params;
  678. int rc;
  679. void *frame;
  680. if (!len)
  681. return -EINVAL;
  682. frame = memdup_user(buf, len);
  683. if (IS_ERR(frame))
  684. return PTR_ERR(frame);
  685. params.buf = frame;
  686. params.len = len;
  687. params.chan = wdev->preset_chandef.chan;
  688. rc = wil_cfg80211_mgmt_tx(wiphy, wdev, &params, NULL);
  689. kfree(frame);
  690. wil_info(wil, "-> %d\n", rc);
  691. return len;
  692. }
  693. static const struct file_operations fops_txmgmt = {
  694. .write = wil_write_file_txmgmt,
  695. .open = simple_open,
  696. };
  697. /* Write WMI command (w/o mbox header) to this file to send it
  698. * WMI starts from wil6210_mbox_hdr_wmi header
  699. */
  700. static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
  701. size_t len, loff_t *ppos)
  702. {
  703. struct wil6210_priv *wil = file->private_data;
  704. struct wmi_cmd_hdr *wmi;
  705. void *cmd;
  706. int cmdlen = len - sizeof(struct wmi_cmd_hdr);
  707. u16 cmdid;
  708. int rc, rc1;
  709. if (cmdlen < 0)
  710. return -EINVAL;
  711. wmi = kmalloc(len, GFP_KERNEL);
  712. if (!wmi)
  713. return -ENOMEM;
  714. rc = simple_write_to_buffer(wmi, len, ppos, buf, len);
  715. if (rc < 0) {
  716. kfree(wmi);
  717. return rc;
  718. }
  719. cmd = (cmdlen > 0) ? &wmi[1] : NULL;
  720. cmdid = le16_to_cpu(wmi->command_id);
  721. rc1 = wmi_send(wil, cmdid, cmd, cmdlen);
  722. kfree(wmi);
  723. wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1);
  724. return rc;
  725. }
  726. static const struct file_operations fops_wmi = {
  727. .write = wil_write_file_wmi,
  728. .open = simple_open,
  729. };
  730. static void wil_seq_print_skb(struct seq_file *s, struct sk_buff *skb)
  731. {
  732. int i = 0;
  733. int len = skb_headlen(skb);
  734. void *p = skb->data;
  735. int nr_frags = skb_shinfo(skb)->nr_frags;
  736. seq_printf(s, " len = %d\n", len);
  737. wil_seq_hexdump(s, p, len, " : ");
  738. if (nr_frags) {
  739. seq_printf(s, " nr_frags = %d\n", nr_frags);
  740. for (i = 0; i < nr_frags; i++) {
  741. const struct skb_frag_struct *frag =
  742. &skb_shinfo(skb)->frags[i];
  743. len = skb_frag_size(frag);
  744. p = skb_frag_address_safe(frag);
  745. seq_printf(s, " [%2d] : len = %d\n", i, len);
  746. wil_seq_hexdump(s, p, len, " : ");
  747. }
  748. }
  749. }
  750. /*---------Tx/Rx descriptor------------*/
  751. static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
  752. {
  753. struct wil6210_priv *wil = s->private;
  754. struct vring *vring;
  755. bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS);
  756. vring = tx ? &wil->vring_tx[dbg_vring_index] : &wil->vring_rx;
  757. if (!vring->va) {
  758. if (tx)
  759. seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index);
  760. else
  761. seq_puts(s, "No Rx VRING\n");
  762. return 0;
  763. }
  764. if (dbg_txdesc_index < vring->size) {
  765. /* use struct vring_tx_desc for Rx as well,
  766. * only field used, .dma.length, is the same
  767. */
  768. volatile struct vring_tx_desc *d =
  769. &vring->va[dbg_txdesc_index].tx;
  770. volatile u32 *u = (volatile u32 *)d;
  771. struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb;
  772. if (tx)
  773. seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index,
  774. dbg_txdesc_index);
  775. else
  776. seq_printf(s, "Rx[%3d] = {\n", dbg_txdesc_index);
  777. seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n",
  778. u[0], u[1], u[2], u[3]);
  779. seq_printf(s, " DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n",
  780. u[4], u[5], u[6], u[7]);
  781. seq_printf(s, " SKB = 0x%p\n", skb);
  782. if (skb) {
  783. skb_get(skb);
  784. wil_seq_print_skb(s, skb);
  785. kfree_skb(skb);
  786. }
  787. seq_puts(s, "}\n");
  788. } else {
  789. if (tx)
  790. seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n",
  791. dbg_vring_index, dbg_txdesc_index,
  792. vring->size);
  793. else
  794. seq_printf(s, "RxDesc index (%d) >= size (%d)\n",
  795. dbg_txdesc_index, vring->size);
  796. }
  797. return 0;
  798. }
  799. static int wil_txdesc_seq_open(struct inode *inode, struct file *file)
  800. {
  801. return single_open(file, wil_txdesc_debugfs_show, inode->i_private);
  802. }
  803. static const struct file_operations fops_txdesc = {
  804. .open = wil_txdesc_seq_open,
  805. .release = single_release,
  806. .read = seq_read,
  807. .llseek = seq_lseek,
  808. };
  809. /*---------beamforming------------*/
  810. static char *wil_bfstatus_str(u32 status)
  811. {
  812. switch (status) {
  813. case 0:
  814. return "Failed";
  815. case 1:
  816. return "OK";
  817. case 2:
  818. return "Retrying";
  819. default:
  820. return "??";
  821. }
  822. }
  823. static bool is_all_zeros(void * const x_, size_t sz)
  824. {
  825. /* if reply is all-0, ignore this CID */
  826. u32 *x = x_;
  827. int n;
  828. for (n = 0; n < sz / sizeof(*x); n++)
  829. if (x[n])
  830. return false;
  831. return true;
  832. }
  833. static int wil_bf_debugfs_show(struct seq_file *s, void *data)
  834. {
  835. int rc;
  836. int i;
  837. struct wil6210_priv *wil = s->private;
  838. struct wmi_notify_req_cmd cmd = {
  839. .interval_usec = 0,
  840. };
  841. struct {
  842. struct wmi_cmd_hdr wmi;
  843. struct wmi_notify_req_done_event evt;
  844. } __packed reply;
  845. for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
  846. u32 status;
  847. cmd.cid = i;
  848. rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
  849. WMI_NOTIFY_REQ_DONE_EVENTID, &reply,
  850. sizeof(reply), 20);
  851. /* if reply is all-0, ignore this CID */
  852. if (rc || is_all_zeros(&reply.evt, sizeof(reply.evt)))
  853. continue;
  854. status = le32_to_cpu(reply.evt.status);
  855. seq_printf(s, "CID %d {\n"
  856. " TSF = 0x%016llx\n"
  857. " TxMCS = %2d TxTpt = %4d\n"
  858. " SQI = %4d\n"
  859. " RSSI = %4d\n"
  860. " Status = 0x%08x %s\n"
  861. " Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n"
  862. " Goodput(rx:tx) %4d:%4d\n"
  863. "}\n",
  864. i,
  865. le64_to_cpu(reply.evt.tsf),
  866. le16_to_cpu(reply.evt.bf_mcs),
  867. le32_to_cpu(reply.evt.tx_tpt),
  868. reply.evt.sqi,
  869. reply.evt.rssi,
  870. status, wil_bfstatus_str(status),
  871. le16_to_cpu(reply.evt.my_rx_sector),
  872. le16_to_cpu(reply.evt.my_tx_sector),
  873. le16_to_cpu(reply.evt.other_rx_sector),
  874. le16_to_cpu(reply.evt.other_tx_sector),
  875. le32_to_cpu(reply.evt.rx_goodput),
  876. le32_to_cpu(reply.evt.tx_goodput));
  877. }
  878. return 0;
  879. }
  880. static int wil_bf_seq_open(struct inode *inode, struct file *file)
  881. {
  882. return single_open(file, wil_bf_debugfs_show, inode->i_private);
  883. }
  884. static const struct file_operations fops_bf = {
  885. .open = wil_bf_seq_open,
  886. .release = single_release,
  887. .read = seq_read,
  888. .llseek = seq_lseek,
  889. };
  890. /*---------SSID------------*/
  891. static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf,
  892. size_t count, loff_t *ppos)
  893. {
  894. struct wil6210_priv *wil = file->private_data;
  895. struct wireless_dev *wdev = wil_to_wdev(wil);
  896. return simple_read_from_buffer(user_buf, count, ppos,
  897. wdev->ssid, wdev->ssid_len);
  898. }
  899. static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf,
  900. size_t count, loff_t *ppos)
  901. {
  902. struct wil6210_priv *wil = file->private_data;
  903. struct wireless_dev *wdev = wil_to_wdev(wil);
  904. struct net_device *ndev = wil_to_ndev(wil);
  905. if (*ppos != 0) {
  906. wil_err(wil, "Unable to set SSID substring from [%d]\n",
  907. (int)*ppos);
  908. return -EINVAL;
  909. }
  910. if (count > sizeof(wdev->ssid)) {
  911. wil_err(wil, "SSID too long, len = %d\n", (int)count);
  912. return -EINVAL;
  913. }
  914. if (netif_running(ndev)) {
  915. wil_err(wil, "Unable to change SSID on running interface\n");
  916. return -EINVAL;
  917. }
  918. wdev->ssid_len = count;
  919. return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos,
  920. buf, count);
  921. }
  922. static const struct file_operations fops_ssid = {
  923. .read = wil_read_file_ssid,
  924. .write = wil_write_file_ssid,
  925. .open = simple_open,
  926. };
  927. /*---------temp------------*/
  928. static void print_temp(struct seq_file *s, const char *prefix, u32 t)
  929. {
  930. switch (t) {
  931. case 0:
  932. case ~(u32)0:
  933. seq_printf(s, "%s N/A\n", prefix);
  934. break;
  935. default:
  936. seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000);
  937. break;
  938. }
  939. }
  940. static int wil_temp_debugfs_show(struct seq_file *s, void *data)
  941. {
  942. struct wil6210_priv *wil = s->private;
  943. u32 t_m, t_r;
  944. int rc = wmi_get_temperature(wil, &t_m, &t_r);
  945. if (rc) {
  946. seq_puts(s, "Failed\n");
  947. return 0;
  948. }
  949. print_temp(s, "T_mac =", t_m);
  950. print_temp(s, "T_radio =", t_r);
  951. return 0;
  952. }
  953. static int wil_temp_seq_open(struct inode *inode, struct file *file)
  954. {
  955. return single_open(file, wil_temp_debugfs_show, inode->i_private);
  956. }
  957. static const struct file_operations fops_temp = {
  958. .open = wil_temp_seq_open,
  959. .release = single_release,
  960. .read = seq_read,
  961. .llseek = seq_lseek,
  962. };
  963. /*---------freq------------*/
  964. static int wil_freq_debugfs_show(struct seq_file *s, void *data)
  965. {
  966. struct wil6210_priv *wil = s->private;
  967. struct wireless_dev *wdev = wil_to_wdev(wil);
  968. u16 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0;
  969. seq_printf(s, "Freq = %d\n", freq);
  970. return 0;
  971. }
  972. static int wil_freq_seq_open(struct inode *inode, struct file *file)
  973. {
  974. return single_open(file, wil_freq_debugfs_show, inode->i_private);
  975. }
  976. static const struct file_operations fops_freq = {
  977. .open = wil_freq_seq_open,
  978. .release = single_release,
  979. .read = seq_read,
  980. .llseek = seq_lseek,
  981. };
  982. /*---------link------------*/
  983. static int wil_link_debugfs_show(struct seq_file *s, void *data)
  984. {
  985. struct wil6210_priv *wil = s->private;
  986. struct station_info sinfo;
  987. int i, rc;
  988. for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
  989. struct wil_sta_info *p = &wil->sta[i];
  990. char *status = "unknown";
  991. switch (p->status) {
  992. case wil_sta_unused:
  993. status = "unused ";
  994. break;
  995. case wil_sta_conn_pending:
  996. status = "pending ";
  997. break;
  998. case wil_sta_connected:
  999. status = "connected";
  1000. break;
  1001. }
  1002. seq_printf(s, "[%d] %pM %s\n", i, p->addr, status);
  1003. if (p->status == wil_sta_connected) {
  1004. rc = wil_cid_fill_sinfo(wil, i, &sinfo);
  1005. if (rc)
  1006. return rc;
  1007. seq_printf(s, " Tx_mcs = %d\n", sinfo.txrate.mcs);
  1008. seq_printf(s, " Rx_mcs = %d\n", sinfo.rxrate.mcs);
  1009. seq_printf(s, " SQ = %d\n", sinfo.signal);
  1010. }
  1011. }
  1012. return 0;
  1013. }
  1014. static int wil_link_seq_open(struct inode *inode, struct file *file)
  1015. {
  1016. return single_open(file, wil_link_debugfs_show, inode->i_private);
  1017. }
  1018. static const struct file_operations fops_link = {
  1019. .open = wil_link_seq_open,
  1020. .release = single_release,
  1021. .read = seq_read,
  1022. .llseek = seq_lseek,
  1023. };
  1024. /*---------info------------*/
  1025. static int wil_info_debugfs_show(struct seq_file *s, void *data)
  1026. {
  1027. struct wil6210_priv *wil = s->private;
  1028. struct net_device *ndev = wil_to_ndev(wil);
  1029. int is_ac = power_supply_is_system_supplied();
  1030. int rx = atomic_xchg(&wil->isr_count_rx, 0);
  1031. int tx = atomic_xchg(&wil->isr_count_tx, 0);
  1032. static ulong rxf_old, txf_old;
  1033. ulong rxf = ndev->stats.rx_packets;
  1034. ulong txf = ndev->stats.tx_packets;
  1035. unsigned int i;
  1036. /* >0 : AC; 0 : battery; <0 : error */
  1037. seq_printf(s, "AC powered : %d\n", is_ac);
  1038. seq_printf(s, "Rx irqs:packets : %8d : %8ld\n", rx, rxf - rxf_old);
  1039. seq_printf(s, "Tx irqs:packets : %8d : %8ld\n", tx, txf - txf_old);
  1040. rxf_old = rxf;
  1041. txf_old = txf;
  1042. #define CHECK_QSTATE(x) (state & BIT(__QUEUE_STATE_ ## x)) ? \
  1043. " " __stringify(x) : ""
  1044. for (i = 0; i < ndev->num_tx_queues; i++) {
  1045. struct netdev_queue *txq = netdev_get_tx_queue(ndev, i);
  1046. unsigned long state = txq->state;
  1047. seq_printf(s, "Tx queue[%i] state : 0x%lx%s%s%s\n", i, state,
  1048. CHECK_QSTATE(DRV_XOFF),
  1049. CHECK_QSTATE(STACK_XOFF),
  1050. CHECK_QSTATE(FROZEN)
  1051. );
  1052. }
  1053. #undef CHECK_QSTATE
  1054. return 0;
  1055. }
  1056. static int wil_info_seq_open(struct inode *inode, struct file *file)
  1057. {
  1058. return single_open(file, wil_info_debugfs_show, inode->i_private);
  1059. }
  1060. static const struct file_operations fops_info = {
  1061. .open = wil_info_seq_open,
  1062. .release = single_release,
  1063. .read = seq_read,
  1064. .llseek = seq_lseek,
  1065. };
  1066. /*---------recovery------------*/
  1067. /* mode = [manual|auto]
  1068. * state = [idle|pending|running]
  1069. */
  1070. static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
  1071. size_t count, loff_t *ppos)
  1072. {
  1073. struct wil6210_priv *wil = file->private_data;
  1074. char buf[80];
  1075. int n;
  1076. static const char * const sstate[] = {"idle", "pending", "running"};
  1077. n = snprintf(buf, sizeof(buf), "mode = %s\nstate = %s\n",
  1078. no_fw_recovery ? "manual" : "auto",
  1079. sstate[wil->recovery_state]);
  1080. n = min_t(int, n, sizeof(buf));
  1081. return simple_read_from_buffer(user_buf, count, ppos,
  1082. buf, n);
  1083. }
  1084. static ssize_t wil_write_file_recovery(struct file *file,
  1085. const char __user *buf_,
  1086. size_t count, loff_t *ppos)
  1087. {
  1088. struct wil6210_priv *wil = file->private_data;
  1089. static const char run_command[] = "run";
  1090. char buf[sizeof(run_command) + 1]; /* to detect "runx" */
  1091. ssize_t rc;
  1092. if (wil->recovery_state != fw_recovery_pending) {
  1093. wil_err(wil, "No recovery pending\n");
  1094. return -EINVAL;
  1095. }
  1096. if (*ppos != 0) {
  1097. wil_err(wil, "Offset [%d]\n", (int)*ppos);
  1098. return -EINVAL;
  1099. }
  1100. if (count > sizeof(buf)) {
  1101. wil_err(wil, "Input too long, len = %d\n", (int)count);
  1102. return -EINVAL;
  1103. }
  1104. rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, buf_, count);
  1105. if (rc < 0)
  1106. return rc;
  1107. buf[rc] = '\0';
  1108. if (0 == strcmp(buf, run_command))
  1109. wil_set_recovery_state(wil, fw_recovery_running);
  1110. else
  1111. wil_err(wil, "Bad recovery command \"%s\"\n", buf);
  1112. return rc;
  1113. }
  1114. static const struct file_operations fops_recovery = {
  1115. .read = wil_read_file_recovery,
  1116. .write = wil_write_file_recovery,
  1117. .open = simple_open,
  1118. };
  1119. /*---------Station matrix------------*/
  1120. static void wil_print_rxtid(struct seq_file *s, struct wil_tid_ampdu_rx *r)
  1121. {
  1122. int i;
  1123. u16 index = ((r->head_seq_num - r->ssn) & 0xfff) % r->buf_size;
  1124. unsigned long long drop_dup = r->drop_dup, drop_old = r->drop_old;
  1125. seq_printf(s, "([%2d] %3d TU) 0x%03x [", r->buf_size, r->timeout,
  1126. r->head_seq_num);
  1127. for (i = 0; i < r->buf_size; i++) {
  1128. if (i == index)
  1129. seq_printf(s, "%c", r->reorder_buf[i] ? 'O' : '|');
  1130. else
  1131. seq_printf(s, "%c", r->reorder_buf[i] ? '*' : '_');
  1132. }
  1133. seq_printf(s,
  1134. "] total %llu drop %llu (dup %llu + old %llu) last 0x%03x\n",
  1135. r->total, drop_dup + drop_old, drop_dup, drop_old,
  1136. r->ssn_last_drop);
  1137. }
  1138. static void wil_print_rxtid_crypto(struct seq_file *s, int tid,
  1139. struct wil_tid_crypto_rx *c)
  1140. {
  1141. int i;
  1142. for (i = 0; i < 4; i++) {
  1143. struct wil_tid_crypto_rx_single *cc = &c->key_id[i];
  1144. if (cc->key_set)
  1145. goto has_keys;
  1146. }
  1147. return;
  1148. has_keys:
  1149. if (tid < WIL_STA_TID_NUM)
  1150. seq_printf(s, " [%2d] PN", tid);
  1151. else
  1152. seq_puts(s, " [GR] PN");
  1153. for (i = 0; i < 4; i++) {
  1154. struct wil_tid_crypto_rx_single *cc = &c->key_id[i];
  1155. seq_printf(s, " [%i%s]%6phN", i, cc->key_set ? "+" : "-",
  1156. cc->pn);
  1157. }
  1158. seq_puts(s, "\n");
  1159. }
  1160. static int wil_sta_debugfs_show(struct seq_file *s, void *data)
  1161. __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock)
  1162. {
  1163. struct wil6210_priv *wil = s->private;
  1164. int i, tid, mcs;
  1165. for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
  1166. struct wil_sta_info *p = &wil->sta[i];
  1167. char *status = "unknown";
  1168. u8 aid = 0;
  1169. switch (p->status) {
  1170. case wil_sta_unused:
  1171. status = "unused ";
  1172. break;
  1173. case wil_sta_conn_pending:
  1174. status = "pending ";
  1175. break;
  1176. case wil_sta_connected:
  1177. status = "connected";
  1178. aid = p->aid;
  1179. break;
  1180. }
  1181. seq_printf(s, "[%d] %pM %s AID %d\n", i, p->addr, status, aid);
  1182. if (p->status == wil_sta_connected) {
  1183. spin_lock_bh(&p->tid_rx_lock);
  1184. for (tid = 0; tid < WIL_STA_TID_NUM; tid++) {
  1185. struct wil_tid_ampdu_rx *r = p->tid_rx[tid];
  1186. struct wil_tid_crypto_rx *c =
  1187. &p->tid_crypto_rx[tid];
  1188. if (r) {
  1189. seq_printf(s, " [%2d] ", tid);
  1190. wil_print_rxtid(s, r);
  1191. }
  1192. wil_print_rxtid_crypto(s, tid, c);
  1193. }
  1194. wil_print_rxtid_crypto(s, WIL_STA_TID_NUM,
  1195. &p->group_crypto_rx);
  1196. spin_unlock_bh(&p->tid_rx_lock);
  1197. seq_printf(s,
  1198. "Rx invalid frame: non-data %lu, short %lu, large %lu, replay %lu\n",
  1199. p->stats.rx_non_data_frame,
  1200. p->stats.rx_short_frame,
  1201. p->stats.rx_large_frame,
  1202. p->stats.rx_replay);
  1203. seq_puts(s, "Rx/MCS:");
  1204. for (mcs = 0; mcs < ARRAY_SIZE(p->stats.rx_per_mcs);
  1205. mcs++)
  1206. seq_printf(s, " %lld",
  1207. p->stats.rx_per_mcs[mcs]);
  1208. seq_puts(s, "\n");
  1209. }
  1210. }
  1211. return 0;
  1212. }
  1213. static int wil_sta_seq_open(struct inode *inode, struct file *file)
  1214. {
  1215. return single_open(file, wil_sta_debugfs_show, inode->i_private);
  1216. }
  1217. static const struct file_operations fops_sta = {
  1218. .open = wil_sta_seq_open,
  1219. .release = single_release,
  1220. .read = seq_read,
  1221. .llseek = seq_lseek,
  1222. };
  1223. static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
  1224. size_t count, loff_t *ppos)
  1225. {
  1226. char buf[80];
  1227. int n;
  1228. n = snprintf(buf, sizeof(buf),
  1229. "led_id is set to %d, echo 1 to enable, 0 to disable\n",
  1230. led_id);
  1231. n = min_t(int, n, sizeof(buf));
  1232. return simple_read_from_buffer(user_buf, count, ppos,
  1233. buf, n);
  1234. }
  1235. static ssize_t wil_write_file_led_cfg(struct file *file,
  1236. const char __user *buf_,
  1237. size_t count, loff_t *ppos)
  1238. {
  1239. struct wil6210_priv *wil = file->private_data;
  1240. int val;
  1241. int rc;
  1242. rc = kstrtoint_from_user(buf_, count, 0, &val);
  1243. if (rc) {
  1244. wil_err(wil, "Invalid argument\n");
  1245. return rc;
  1246. }
  1247. wil_info(wil, "%s led %d\n", val ? "Enabling" : "Disabling", led_id);
  1248. rc = wmi_led_cfg(wil, val);
  1249. if (rc) {
  1250. wil_info(wil, "%s led %d failed\n",
  1251. val ? "Enabling" : "Disabling", led_id);
  1252. return rc;
  1253. }
  1254. return count;
  1255. }
  1256. static const struct file_operations fops_led_cfg = {
  1257. .read = wil_read_file_led_cfg,
  1258. .write = wil_write_file_led_cfg,
  1259. .open = simple_open,
  1260. };
  1261. /* led_blink_time, write:
  1262. * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast>
  1263. */
  1264. static ssize_t wil_write_led_blink_time(struct file *file,
  1265. const char __user *buf,
  1266. size_t len, loff_t *ppos)
  1267. {
  1268. int rc;
  1269. char *kbuf = kmalloc(len + 1, GFP_KERNEL);
  1270. if (!kbuf)
  1271. return -ENOMEM;
  1272. rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
  1273. if (rc != len) {
  1274. kfree(kbuf);
  1275. return rc >= 0 ? -EIO : rc;
  1276. }
  1277. kbuf[len] = '\0';
  1278. rc = sscanf(kbuf, "%d %d %d %d %d %d",
  1279. &led_blink_time[WIL_LED_TIME_SLOW].on_ms,
  1280. &led_blink_time[WIL_LED_TIME_SLOW].off_ms,
  1281. &led_blink_time[WIL_LED_TIME_MED].on_ms,
  1282. &led_blink_time[WIL_LED_TIME_MED].off_ms,
  1283. &led_blink_time[WIL_LED_TIME_FAST].on_ms,
  1284. &led_blink_time[WIL_LED_TIME_FAST].off_ms);
  1285. kfree(kbuf);
  1286. if (rc < 0)
  1287. return rc;
  1288. if (rc < 6)
  1289. return -EINVAL;
  1290. return len;
  1291. }
  1292. static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
  1293. size_t count, loff_t *ppos)
  1294. {
  1295. static char text[400];
  1296. snprintf(text, sizeof(text),
  1297. "To set led blink on/off time variables write:\n"
  1298. "<blink_on_slow> <blink_off_slow> <blink_on_med> "
  1299. "<blink_off_med> <blink_on_fast> <blink_off_fast>\n"
  1300. "The current values are:\n"
  1301. "%d %d %d %d %d %d\n",
  1302. led_blink_time[WIL_LED_TIME_SLOW].on_ms,
  1303. led_blink_time[WIL_LED_TIME_SLOW].off_ms,
  1304. led_blink_time[WIL_LED_TIME_MED].on_ms,
  1305. led_blink_time[WIL_LED_TIME_MED].off_ms,
  1306. led_blink_time[WIL_LED_TIME_FAST].on_ms,
  1307. led_blink_time[WIL_LED_TIME_FAST].off_ms);
  1308. return simple_read_from_buffer(user_buf, count, ppos, text,
  1309. sizeof(text));
  1310. }
  1311. static const struct file_operations fops_led_blink_time = {
  1312. .read = wil_read_led_blink_time,
  1313. .write = wil_write_led_blink_time,
  1314. .open = simple_open,
  1315. };
  1316. /*---------FW capabilities------------*/
  1317. static int wil_fw_capabilities_debugfs_show(struct seq_file *s, void *data)
  1318. {
  1319. struct wil6210_priv *wil = s->private;
  1320. seq_printf(s, "fw_capabilities : %*pb\n", WMI_FW_CAPABILITY_MAX,
  1321. wil->fw_capabilities);
  1322. return 0;
  1323. }
  1324. static int wil_fw_capabilities_seq_open(struct inode *inode, struct file *file)
  1325. {
  1326. return single_open(file, wil_fw_capabilities_debugfs_show,
  1327. inode->i_private);
  1328. }
  1329. static const struct file_operations fops_fw_capabilities = {
  1330. .open = wil_fw_capabilities_seq_open,
  1331. .release = single_release,
  1332. .read = seq_read,
  1333. .llseek = seq_lseek,
  1334. };
  1335. /*---------FW version------------*/
  1336. static int wil_fw_version_debugfs_show(struct seq_file *s, void *data)
  1337. {
  1338. struct wil6210_priv *wil = s->private;
  1339. if (wil->fw_version[0])
  1340. seq_printf(s, "%s\n", wil->fw_version);
  1341. else
  1342. seq_puts(s, "N/A\n");
  1343. return 0;
  1344. }
  1345. static int wil_fw_version_seq_open(struct inode *inode, struct file *file)
  1346. {
  1347. return single_open(file, wil_fw_version_debugfs_show,
  1348. inode->i_private);
  1349. }
  1350. static const struct file_operations fops_fw_version = {
  1351. .open = wil_fw_version_seq_open,
  1352. .release = single_release,
  1353. .read = seq_read,
  1354. .llseek = seq_lseek,
  1355. };
  1356. /*---------suspend_stats---------*/
  1357. static ssize_t wil_write_suspend_stats(struct file *file,
  1358. const char __user *buf,
  1359. size_t len, loff_t *ppos)
  1360. {
  1361. struct wil6210_priv *wil = file->private_data;
  1362. memset(&wil->suspend_stats, 0, sizeof(wil->suspend_stats));
  1363. wil->suspend_stats.min_suspend_time = ULONG_MAX;
  1364. wil->suspend_stats.collection_start = ktime_get();
  1365. return len;
  1366. }
  1367. static ssize_t wil_read_suspend_stats(struct file *file,
  1368. char __user *user_buf,
  1369. size_t count, loff_t *ppos)
  1370. {
  1371. struct wil6210_priv *wil = file->private_data;
  1372. static char text[400];
  1373. int n;
  1374. unsigned long long stats_collection_time =
  1375. ktime_to_us(ktime_sub(ktime_get(),
  1376. wil->suspend_stats.collection_start));
  1377. n = snprintf(text, sizeof(text),
  1378. "Suspend statistics:\n"
  1379. "successful suspends:%ld failed suspends:%ld\n"
  1380. "successful resumes:%ld failed resumes:%ld\n"
  1381. "rejected by host:%ld rejected by device:%ld\n"
  1382. "total suspend time:%lld min suspend time:%lld\n"
  1383. "max suspend time:%lld stats collection time: %lld\n",
  1384. wil->suspend_stats.successful_suspends,
  1385. wil->suspend_stats.failed_suspends,
  1386. wil->suspend_stats.successful_resumes,
  1387. wil->suspend_stats.failed_resumes,
  1388. wil->suspend_stats.rejected_by_host,
  1389. wil->suspend_stats.rejected_by_device,
  1390. wil->suspend_stats.total_suspend_time,
  1391. wil->suspend_stats.min_suspend_time,
  1392. wil->suspend_stats.max_suspend_time,
  1393. stats_collection_time);
  1394. n = min_t(int, n, sizeof(text));
  1395. return simple_read_from_buffer(user_buf, count, ppos, text, n);
  1396. }
  1397. static const struct file_operations fops_suspend_stats = {
  1398. .read = wil_read_suspend_stats,
  1399. .write = wil_write_suspend_stats,
  1400. .open = simple_open,
  1401. };
  1402. /*----------------*/
  1403. static void wil6210_debugfs_init_blobs(struct wil6210_priv *wil,
  1404. struct dentry *dbg)
  1405. {
  1406. int i;
  1407. char name[32];
  1408. for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) {
  1409. struct wil_blob_wrapper *wil_blob = &wil->blobs[i];
  1410. struct debugfs_blob_wrapper *blob = &wil_blob->blob;
  1411. const struct fw_map *map = &fw_mapping[i];
  1412. if (!map->name)
  1413. continue;
  1414. wil_blob->wil = wil;
  1415. blob->data = (void * __force)wil->csr + HOSTADDR(map->host);
  1416. blob->size = map->to - map->from;
  1417. snprintf(name, sizeof(name), "blob_%s", map->name);
  1418. wil_debugfs_create_ioblob(name, 0444, dbg, wil_blob);
  1419. }
  1420. }
  1421. /* misc files */
  1422. static const struct {
  1423. const char *name;
  1424. umode_t mode;
  1425. const struct file_operations *fops;
  1426. } dbg_files[] = {
  1427. {"mbox", 0444, &fops_mbox},
  1428. {"vrings", 0444, &fops_vring},
  1429. {"stations", 0444, &fops_sta},
  1430. {"desc", 0444, &fops_txdesc},
  1431. {"bf", 0444, &fops_bf},
  1432. {"ssid", 0644, &fops_ssid},
  1433. {"mem_val", 0644, &fops_memread},
  1434. {"reset", 0244, &fops_reset},
  1435. {"rxon", 0244, &fops_rxon},
  1436. {"tx_mgmt", 0244, &fops_txmgmt},
  1437. {"wmi_send", 0244, &fops_wmi},
  1438. {"back", 0644, &fops_back},
  1439. {"pmccfg", 0644, &fops_pmccfg},
  1440. {"pmcdata", 0444, &fops_pmcdata},
  1441. {"temp", 0444, &fops_temp},
  1442. {"freq", 0444, &fops_freq},
  1443. {"link", 0444, &fops_link},
  1444. {"info", 0444, &fops_info},
  1445. {"recovery", 0644, &fops_recovery},
  1446. {"led_cfg", 0644, &fops_led_cfg},
  1447. {"led_blink_time", 0644, &fops_led_blink_time},
  1448. {"fw_capabilities", 0444, &fops_fw_capabilities},
  1449. {"fw_version", 0444, &fops_fw_version},
  1450. {"suspend_stats", 0644, &fops_suspend_stats},
  1451. };
  1452. static void wil6210_debugfs_init_files(struct wil6210_priv *wil,
  1453. struct dentry *dbg)
  1454. {
  1455. int i;
  1456. for (i = 0; i < ARRAY_SIZE(dbg_files); i++)
  1457. debugfs_create_file(dbg_files[i].name, dbg_files[i].mode, dbg,
  1458. wil, dbg_files[i].fops);
  1459. }
  1460. /* interrupt control blocks */
  1461. static const struct {
  1462. const char *name;
  1463. u32 icr_off;
  1464. } dbg_icr[] = {
  1465. {"USER_ICR", HOSTADDR(RGF_USER_USER_ICR)},
  1466. {"DMA_EP_TX_ICR", HOSTADDR(RGF_DMA_EP_TX_ICR)},
  1467. {"DMA_EP_RX_ICR", HOSTADDR(RGF_DMA_EP_RX_ICR)},
  1468. {"DMA_EP_MISC_ICR", HOSTADDR(RGF_DMA_EP_MISC_ICR)},
  1469. };
  1470. static void wil6210_debugfs_init_isr(struct wil6210_priv *wil,
  1471. struct dentry *dbg)
  1472. {
  1473. int i;
  1474. for (i = 0; i < ARRAY_SIZE(dbg_icr); i++)
  1475. wil6210_debugfs_create_ISR(wil, dbg_icr[i].name, dbg,
  1476. dbg_icr[i].icr_off);
  1477. }
  1478. #define WIL_FIELD(name, mode, type) { __stringify(name), mode, \
  1479. offsetof(struct wil6210_priv, name), type}
  1480. /* fields in struct wil6210_priv */
  1481. static const struct dbg_off dbg_wil_off[] = {
  1482. WIL_FIELD(privacy, 0444, doff_u32),
  1483. WIL_FIELD(status[0], 0644, doff_ulong),
  1484. WIL_FIELD(hw_version, 0444, doff_x32),
  1485. WIL_FIELD(recovery_count, 0444, doff_u32),
  1486. WIL_FIELD(ap_isolate, 0444, doff_u32),
  1487. WIL_FIELD(discovery_mode, 0644, doff_u8),
  1488. WIL_FIELD(chip_revision, 0444, doff_u8),
  1489. WIL_FIELD(abft_len, 0644, doff_u8),
  1490. WIL_FIELD(wakeup_trigger, 0644, doff_u8),
  1491. WIL_FIELD(vring_idle_trsh, 0644, doff_u32),
  1492. {},
  1493. };
  1494. static const struct dbg_off dbg_wil_regs[] = {
  1495. {"RGF_MAC_MTRL_COUNTER_0", 0444, HOSTADDR(RGF_MAC_MTRL_COUNTER_0),
  1496. doff_io32},
  1497. {"RGF_USER_USAGE_1", 0444, HOSTADDR(RGF_USER_USAGE_1), doff_io32},
  1498. {},
  1499. };
  1500. /* static parameters */
  1501. static const struct dbg_off dbg_statics[] = {
  1502. {"desc_index", 0644, (ulong)&dbg_txdesc_index, doff_u32},
  1503. {"vring_index", 0644, (ulong)&dbg_vring_index, doff_u32},
  1504. {"mem_addr", 0644, (ulong)&mem_addr, doff_u32},
  1505. {"led_polarity", 0644, (ulong)&led_polarity, doff_u8},
  1506. {},
  1507. };
  1508. int wil6210_debugfs_init(struct wil6210_priv *wil)
  1509. {
  1510. struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
  1511. wil_to_wiphy(wil)->debugfsdir);
  1512. if (IS_ERR_OR_NULL(dbg))
  1513. return -ENODEV;
  1514. wil_pmc_init(wil);
  1515. wil6210_debugfs_init_files(wil, dbg);
  1516. wil6210_debugfs_init_isr(wil, dbg);
  1517. wil6210_debugfs_init_blobs(wil, dbg);
  1518. wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off);
  1519. wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr,
  1520. dbg_wil_regs);
  1521. wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics);
  1522. wil6210_debugfs_create_pseudo_ISR(wil, dbg);
  1523. wil6210_debugfs_create_ITR_CNT(wil, dbg);
  1524. wil->suspend_stats.collection_start = ktime_get();
  1525. return 0;
  1526. }
  1527. void wil6210_debugfs_remove(struct wil6210_priv *wil)
  1528. {
  1529. debugfs_remove_recursive(wil->debug);
  1530. wil->debug = NULL;
  1531. /* free pmc memory without sending command to fw, as it will
  1532. * be reset on the way down anyway
  1533. */
  1534. wil_pmc_free(wil, false);
  1535. }