debugfs.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. * Copyright (c) 2012 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 "wil6210.h"
  22. #include "txrx.h"
  23. /* Nasty hack. Better have per device instances */
  24. static u32 mem_addr;
  25. static u32 dbg_txdesc_index;
  26. static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
  27. static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
  28. const char *name, struct vring *vring,
  29. char _s, char _h)
  30. {
  31. void __iomem *x = wmi_addr(wil, vring->hwtail);
  32. seq_printf(s, "VRING %s = {\n", name);
  33. seq_printf(s, " pa = %pad\n", &vring->pa);
  34. seq_printf(s, " va = 0x%p\n", vring->va);
  35. seq_printf(s, " size = %d\n", vring->size);
  36. seq_printf(s, " swtail = %d\n", vring->swtail);
  37. seq_printf(s, " swhead = %d\n", vring->swhead);
  38. seq_printf(s, " hwtail = [0x%08x] -> ", vring->hwtail);
  39. if (x)
  40. seq_printf(s, "0x%08x\n", ioread32(x));
  41. else
  42. seq_printf(s, "???\n");
  43. if (vring->va && (vring->size < 1025)) {
  44. uint i;
  45. for (i = 0; i < vring->size; i++) {
  46. volatile struct vring_tx_desc *d = &vring->va[i].tx;
  47. if ((i % 64) == 0 && (i != 0))
  48. seq_printf(s, "\n");
  49. seq_printf(s, "%c", (d->dma.status & BIT(0)) ?
  50. _s : (vring->ctx[i].skb ? _h : 'h'));
  51. }
  52. seq_printf(s, "\n");
  53. }
  54. seq_printf(s, "}\n");
  55. }
  56. static int wil_vring_debugfs_show(struct seq_file *s, void *data)
  57. {
  58. uint i;
  59. struct wil6210_priv *wil = s->private;
  60. wil_print_vring(s, wil, "rx", &wil->vring_rx, 'S', '_');
  61. for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) {
  62. struct vring *vring = &(wil->vring_tx[i]);
  63. if (vring->va) {
  64. int cid = wil->vring2cid_tid[i][0];
  65. int tid = wil->vring2cid_tid[i][1];
  66. char name[10];
  67. snprintf(name, sizeof(name), "tx_%2d", i);
  68. seq_printf(s, "\n%pM CID %d TID %d\n",
  69. wil->sta[cid].addr, cid, tid);
  70. wil_print_vring(s, wil, name, vring, '_', 'H');
  71. }
  72. }
  73. return 0;
  74. }
  75. static int wil_vring_seq_open(struct inode *inode, struct file *file)
  76. {
  77. return single_open(file, wil_vring_debugfs_show, inode->i_private);
  78. }
  79. static const struct file_operations fops_vring = {
  80. .open = wil_vring_seq_open,
  81. .release = single_release,
  82. .read = seq_read,
  83. .llseek = seq_lseek,
  84. };
  85. static void wil_print_ring(struct seq_file *s, const char *prefix,
  86. void __iomem *off)
  87. {
  88. struct wil6210_priv *wil = s->private;
  89. struct wil6210_mbox_ring r;
  90. int rsize;
  91. uint i;
  92. wil_memcpy_fromio_32(&r, off, sizeof(r));
  93. wil_mbox_ring_le2cpus(&r);
  94. /*
  95. * we just read memory block from NIC. This memory may be
  96. * garbage. Check validity before using it.
  97. */
  98. rsize = r.size / sizeof(struct wil6210_mbox_ring_desc);
  99. seq_printf(s, "ring %s = {\n", prefix);
  100. seq_printf(s, " base = 0x%08x\n", r.base);
  101. seq_printf(s, " size = 0x%04x bytes -> %d entries\n", r.size, rsize);
  102. seq_printf(s, " tail = 0x%08x\n", r.tail);
  103. seq_printf(s, " head = 0x%08x\n", r.head);
  104. seq_printf(s, " entry size = %d\n", r.entry_size);
  105. if (r.size % sizeof(struct wil6210_mbox_ring_desc)) {
  106. seq_printf(s, " ??? size is not multiple of %zd, garbage?\n",
  107. sizeof(struct wil6210_mbox_ring_desc));
  108. goto out;
  109. }
  110. if (!wmi_addr(wil, r.base) ||
  111. !wmi_addr(wil, r.tail) ||
  112. !wmi_addr(wil, r.head)) {
  113. seq_printf(s, " ??? pointers are garbage?\n");
  114. goto out;
  115. }
  116. for (i = 0; i < rsize; i++) {
  117. struct wil6210_mbox_ring_desc d;
  118. struct wil6210_mbox_hdr hdr;
  119. size_t delta = i * sizeof(d);
  120. void __iomem *x = wil->csr + HOSTADDR(r.base) + delta;
  121. wil_memcpy_fromio_32(&d, x, sizeof(d));
  122. seq_printf(s, " [%2x] %s %s%s 0x%08x", i,
  123. d.sync ? "F" : "E",
  124. (r.tail - r.base == delta) ? "t" : " ",
  125. (r.head - r.base == delta) ? "h" : " ",
  126. le32_to_cpu(d.addr));
  127. if (0 == wmi_read_hdr(wil, d.addr, &hdr)) {
  128. u16 len = le16_to_cpu(hdr.len);
  129. seq_printf(s, " -> %04x %04x %04x %02x\n",
  130. le16_to_cpu(hdr.seq), len,
  131. le16_to_cpu(hdr.type), hdr.flags);
  132. if (len <= MAX_MBOXITEM_SIZE) {
  133. int n = 0;
  134. char printbuf[16 * 3 + 2];
  135. unsigned char databuf[MAX_MBOXITEM_SIZE];
  136. void __iomem *src = wmi_buffer(wil, d.addr) +
  137. sizeof(struct wil6210_mbox_hdr);
  138. /*
  139. * No need to check @src for validity -
  140. * we already validated @d.addr while
  141. * reading header
  142. */
  143. wil_memcpy_fromio_32(databuf, src, len);
  144. while (n < len) {
  145. int l = min(len - n, 16);
  146. hex_dump_to_buffer(databuf + n, l,
  147. 16, 1, printbuf,
  148. sizeof(printbuf),
  149. false);
  150. seq_printf(s, " : %s\n", printbuf);
  151. n += l;
  152. }
  153. }
  154. } else {
  155. seq_printf(s, "\n");
  156. }
  157. }
  158. out:
  159. seq_printf(s, "}\n");
  160. }
  161. static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
  162. {
  163. struct wil6210_priv *wil = s->private;
  164. wil_print_ring(s, "tx", wil->csr + HOST_MBOX +
  165. offsetof(struct wil6210_mbox_ctl, tx));
  166. wil_print_ring(s, "rx", wil->csr + HOST_MBOX +
  167. offsetof(struct wil6210_mbox_ctl, rx));
  168. return 0;
  169. }
  170. static int wil_mbox_seq_open(struct inode *inode, struct file *file)
  171. {
  172. return single_open(file, wil_mbox_debugfs_show, inode->i_private);
  173. }
  174. static const struct file_operations fops_mbox = {
  175. .open = wil_mbox_seq_open,
  176. .release = single_release,
  177. .read = seq_read,
  178. .llseek = seq_lseek,
  179. };
  180. static int wil_debugfs_iomem_x32_set(void *data, u64 val)
  181. {
  182. iowrite32(val, (void __iomem *)data);
  183. wmb(); /* make sure write propagated to HW */
  184. return 0;
  185. }
  186. static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
  187. {
  188. *val = ioread32((void __iomem *)data);
  189. return 0;
  190. }
  191. DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
  192. wil_debugfs_iomem_x32_set, "0x%08llx\n");
  193. static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
  194. umode_t mode,
  195. struct dentry *parent,
  196. void __iomem *value)
  197. {
  198. return debugfs_create_file(name, mode, parent, (void * __force)value,
  199. &fops_iomem_x32);
  200. }
  201. static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
  202. const char *name,
  203. struct dentry *parent, u32 off)
  204. {
  205. struct dentry *d = debugfs_create_dir(name, parent);
  206. if (IS_ERR_OR_NULL(d))
  207. return -ENODEV;
  208. wil_debugfs_create_iomem_x32("ICC", S_IRUGO | S_IWUSR, d,
  209. wil->csr + off);
  210. wil_debugfs_create_iomem_x32("ICR", S_IRUGO | S_IWUSR, d,
  211. wil->csr + off + 4);
  212. wil_debugfs_create_iomem_x32("ICM", S_IRUGO | S_IWUSR, d,
  213. wil->csr + off + 8);
  214. wil_debugfs_create_iomem_x32("ICS", S_IWUSR, d,
  215. wil->csr + off + 12);
  216. wil_debugfs_create_iomem_x32("IMV", S_IRUGO | S_IWUSR, d,
  217. wil->csr + off + 16);
  218. wil_debugfs_create_iomem_x32("IMS", S_IWUSR, d,
  219. wil->csr + off + 20);
  220. wil_debugfs_create_iomem_x32("IMC", S_IWUSR, d,
  221. wil->csr + off + 24);
  222. return 0;
  223. }
  224. static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
  225. struct dentry *parent)
  226. {
  227. struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent);
  228. if (IS_ERR_OR_NULL(d))
  229. return -ENODEV;
  230. wil_debugfs_create_iomem_x32("CAUSE", S_IRUGO, d, wil->csr +
  231. HOSTADDR(RGF_DMA_PSEUDO_CAUSE));
  232. wil_debugfs_create_iomem_x32("MASK_SW", S_IRUGO, d, wil->csr +
  233. HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW));
  234. wil_debugfs_create_iomem_x32("MASK_FW", S_IRUGO, d, wil->csr +
  235. HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW));
  236. return 0;
  237. }
  238. static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
  239. struct dentry *parent)
  240. {
  241. struct dentry *d = debugfs_create_dir("ITR_CNT", parent);
  242. if (IS_ERR_OR_NULL(d))
  243. return -ENODEV;
  244. wil_debugfs_create_iomem_x32("TRSH", S_IRUGO, d, wil->csr +
  245. HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
  246. wil_debugfs_create_iomem_x32("DATA", S_IRUGO, d, wil->csr +
  247. HOSTADDR(RGF_DMA_ITR_CNT_DATA));
  248. wil_debugfs_create_iomem_x32("CTL", S_IRUGO, d, wil->csr +
  249. HOSTADDR(RGF_DMA_ITR_CNT_CRL));
  250. return 0;
  251. }
  252. static int wil_memread_debugfs_show(struct seq_file *s, void *data)
  253. {
  254. struct wil6210_priv *wil = s->private;
  255. void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr));
  256. if (a)
  257. seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, ioread32(a));
  258. else
  259. seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
  260. return 0;
  261. }
  262. static int wil_memread_seq_open(struct inode *inode, struct file *file)
  263. {
  264. return single_open(file, wil_memread_debugfs_show, inode->i_private);
  265. }
  266. static const struct file_operations fops_memread = {
  267. .open = wil_memread_seq_open,
  268. .release = single_release,
  269. .read = seq_read,
  270. .llseek = seq_lseek,
  271. };
  272. static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
  273. size_t count, loff_t *ppos)
  274. {
  275. enum { max_count = 4096 };
  276. struct debugfs_blob_wrapper *blob = file->private_data;
  277. loff_t pos = *ppos;
  278. size_t available = blob->size;
  279. void *buf;
  280. size_t ret;
  281. if (pos < 0)
  282. return -EINVAL;
  283. if (pos >= available || !count)
  284. return 0;
  285. if (count > available - pos)
  286. count = available - pos;
  287. if (count > max_count)
  288. count = max_count;
  289. buf = kmalloc(count, GFP_KERNEL);
  290. if (!buf)
  291. return -ENOMEM;
  292. wil_memcpy_fromio_32(buf, (const volatile void __iomem *)blob->data +
  293. pos, count);
  294. ret = copy_to_user(user_buf, buf, count);
  295. kfree(buf);
  296. if (ret == count)
  297. return -EFAULT;
  298. count -= ret;
  299. *ppos = pos + count;
  300. return count;
  301. }
  302. static const struct file_operations fops_ioblob = {
  303. .read = wil_read_file_ioblob,
  304. .open = simple_open,
  305. .llseek = default_llseek,
  306. };
  307. static
  308. struct dentry *wil_debugfs_create_ioblob(const char *name,
  309. umode_t mode,
  310. struct dentry *parent,
  311. struct debugfs_blob_wrapper *blob)
  312. {
  313. return debugfs_create_file(name, mode, parent, blob, &fops_ioblob);
  314. }
  315. /*---reset---*/
  316. static ssize_t wil_write_file_reset(struct file *file, const char __user *buf,
  317. size_t len, loff_t *ppos)
  318. {
  319. struct wil6210_priv *wil = file->private_data;
  320. struct net_device *ndev = wil_to_ndev(wil);
  321. /**
  322. * BUG:
  323. * this code does NOT sync device state with the rest of system
  324. * use with care, debug only!!!
  325. */
  326. rtnl_lock();
  327. dev_close(ndev);
  328. ndev->flags &= ~IFF_UP;
  329. rtnl_unlock();
  330. wil_reset(wil);
  331. return len;
  332. }
  333. static const struct file_operations fops_reset = {
  334. .write = wil_write_file_reset,
  335. .open = simple_open,
  336. };
  337. static void wil_seq_hexdump(struct seq_file *s, void *p, int len,
  338. const char *prefix)
  339. {
  340. char printbuf[16 * 3 + 2];
  341. int i = 0;
  342. while (i < len) {
  343. int l = min(len - i, 16);
  344. hex_dump_to_buffer(p + i, l, 16, 1, printbuf,
  345. sizeof(printbuf), false);
  346. seq_printf(s, "%s%s\n", prefix, printbuf);
  347. i += l;
  348. }
  349. }
  350. static void wil_seq_print_skb(struct seq_file *s, struct sk_buff *skb)
  351. {
  352. int i = 0;
  353. int len = skb_headlen(skb);
  354. void *p = skb->data;
  355. int nr_frags = skb_shinfo(skb)->nr_frags;
  356. seq_printf(s, " len = %d\n", len);
  357. wil_seq_hexdump(s, p, len, " : ");
  358. if (nr_frags) {
  359. seq_printf(s, " nr_frags = %d\n", nr_frags);
  360. for (i = 0; i < nr_frags; i++) {
  361. const struct skb_frag_struct *frag =
  362. &skb_shinfo(skb)->frags[i];
  363. len = skb_frag_size(frag);
  364. p = skb_frag_address_safe(frag);
  365. seq_printf(s, " [%2d] : len = %d\n", i, len);
  366. wil_seq_hexdump(s, p, len, " : ");
  367. }
  368. }
  369. }
  370. /*---------Tx/Rx descriptor------------*/
  371. static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
  372. {
  373. struct wil6210_priv *wil = s->private;
  374. struct vring *vring;
  375. bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS);
  376. if (tx)
  377. vring = &(wil->vring_tx[dbg_vring_index]);
  378. else
  379. vring = &wil->vring_rx;
  380. if (!vring->va) {
  381. if (tx)
  382. seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index);
  383. else
  384. seq_puts(s, "No Rx VRING\n");
  385. return 0;
  386. }
  387. if (dbg_txdesc_index < vring->size) {
  388. /* use struct vring_tx_desc for Rx as well,
  389. * only field used, .dma.length, is the same
  390. */
  391. volatile struct vring_tx_desc *d =
  392. &(vring->va[dbg_txdesc_index].tx);
  393. volatile u32 *u = (volatile u32 *)d;
  394. struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb;
  395. if (tx)
  396. seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index,
  397. dbg_txdesc_index);
  398. else
  399. seq_printf(s, "Rx[%3d] = {\n", dbg_txdesc_index);
  400. seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n",
  401. u[0], u[1], u[2], u[3]);
  402. seq_printf(s, " DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n",
  403. u[4], u[5], u[6], u[7]);
  404. seq_printf(s, " SKB = 0x%p\n", skb);
  405. if (skb) {
  406. skb_get(skb);
  407. wil_seq_print_skb(s, skb);
  408. kfree_skb(skb);
  409. }
  410. seq_printf(s, "}\n");
  411. } else {
  412. if (tx)
  413. seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n",
  414. dbg_vring_index, dbg_txdesc_index,
  415. vring->size);
  416. else
  417. seq_printf(s, "RxDesc index (%d) >= size (%d)\n",
  418. dbg_txdesc_index, vring->size);
  419. }
  420. return 0;
  421. }
  422. static int wil_txdesc_seq_open(struct inode *inode, struct file *file)
  423. {
  424. return single_open(file, wil_txdesc_debugfs_show, inode->i_private);
  425. }
  426. static const struct file_operations fops_txdesc = {
  427. .open = wil_txdesc_seq_open,
  428. .release = single_release,
  429. .read = seq_read,
  430. .llseek = seq_lseek,
  431. };
  432. /*---------beamforming------------*/
  433. static int wil_bf_debugfs_show(struct seq_file *s, void *data)
  434. {
  435. struct wil6210_priv *wil = s->private;
  436. seq_printf(s,
  437. "TSF : 0x%016llx\n"
  438. "TxMCS : %d\n"
  439. "Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n",
  440. wil->stats.tsf, wil->stats.bf_mcs,
  441. wil->stats.my_rx_sector, wil->stats.my_tx_sector,
  442. wil->stats.peer_rx_sector, wil->stats.peer_tx_sector);
  443. return 0;
  444. }
  445. static int wil_bf_seq_open(struct inode *inode, struct file *file)
  446. {
  447. return single_open(file, wil_bf_debugfs_show, inode->i_private);
  448. }
  449. static const struct file_operations fops_bf = {
  450. .open = wil_bf_seq_open,
  451. .release = single_release,
  452. .read = seq_read,
  453. .llseek = seq_lseek,
  454. };
  455. /*---------SSID------------*/
  456. static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf,
  457. size_t count, loff_t *ppos)
  458. {
  459. struct wil6210_priv *wil = file->private_data;
  460. struct wireless_dev *wdev = wil_to_wdev(wil);
  461. return simple_read_from_buffer(user_buf, count, ppos,
  462. wdev->ssid, wdev->ssid_len);
  463. }
  464. static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf,
  465. size_t count, loff_t *ppos)
  466. {
  467. struct wil6210_priv *wil = file->private_data;
  468. struct wireless_dev *wdev = wil_to_wdev(wil);
  469. struct net_device *ndev = wil_to_ndev(wil);
  470. if (*ppos != 0) {
  471. wil_err(wil, "Unable to set SSID substring from [%d]\n",
  472. (int)*ppos);
  473. return -EINVAL;
  474. }
  475. if (count > sizeof(wdev->ssid)) {
  476. wil_err(wil, "SSID too long, len = %d\n", (int)count);
  477. return -EINVAL;
  478. }
  479. if (netif_running(ndev)) {
  480. wil_err(wil, "Unable to change SSID on running interface\n");
  481. return -EINVAL;
  482. }
  483. wdev->ssid_len = count;
  484. return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos,
  485. buf, count);
  486. }
  487. static const struct file_operations fops_ssid = {
  488. .read = wil_read_file_ssid,
  489. .write = wil_write_file_ssid,
  490. .open = simple_open,
  491. };
  492. /*---------temp------------*/
  493. static void print_temp(struct seq_file *s, const char *prefix, u32 t)
  494. {
  495. switch (t) {
  496. case 0:
  497. case ~(u32)0:
  498. seq_printf(s, "%s N/A\n", prefix);
  499. break;
  500. default:
  501. seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000);
  502. break;
  503. }
  504. }
  505. static int wil_temp_debugfs_show(struct seq_file *s, void *data)
  506. {
  507. struct wil6210_priv *wil = s->private;
  508. u32 t_m, t_r;
  509. int rc = wmi_get_temperature(wil, &t_m, &t_r);
  510. if (rc) {
  511. seq_printf(s, "Failed\n");
  512. return 0;
  513. }
  514. print_temp(s, "MAC temperature :", t_m);
  515. print_temp(s, "Radio temperature :", t_r);
  516. return 0;
  517. }
  518. static int wil_temp_seq_open(struct inode *inode, struct file *file)
  519. {
  520. return single_open(file, wil_temp_debugfs_show, inode->i_private);
  521. }
  522. static const struct file_operations fops_temp = {
  523. .open = wil_temp_seq_open,
  524. .release = single_release,
  525. .read = seq_read,
  526. .llseek = seq_lseek,
  527. };
  528. /*---------Station matrix------------*/
  529. static void wil_print_rxtid(struct seq_file *s, struct wil_tid_ampdu_rx *r)
  530. {
  531. int i;
  532. u16 index = ((r->head_seq_num - r->ssn) & 0xfff) % r->buf_size;
  533. seq_printf(s, "0x%03x [", r->head_seq_num);
  534. for (i = 0; i < r->buf_size; i++) {
  535. if (i == index)
  536. seq_printf(s, "%c", r->reorder_buf[i] ? 'O' : '|');
  537. else
  538. seq_printf(s, "%c", r->reorder_buf[i] ? '*' : '_');
  539. }
  540. seq_puts(s, "]\n");
  541. }
  542. static int wil_sta_debugfs_show(struct seq_file *s, void *data)
  543. {
  544. struct wil6210_priv *wil = s->private;
  545. int i, tid;
  546. for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
  547. struct wil_sta_info *p = &wil->sta[i];
  548. char *status = "unknown";
  549. switch (p->status) {
  550. case wil_sta_unused:
  551. status = "unused ";
  552. break;
  553. case wil_sta_conn_pending:
  554. status = "pending ";
  555. break;
  556. case wil_sta_connected:
  557. status = "connected";
  558. break;
  559. }
  560. seq_printf(s, "[%d] %pM %s%s\n", i, p->addr, status,
  561. (p->data_port_open ? " data_port_open" : ""));
  562. if (p->status == wil_sta_connected) {
  563. for (tid = 0; tid < WIL_STA_TID_NUM; tid++) {
  564. struct wil_tid_ampdu_rx *r = p->tid_rx[tid];
  565. if (r) {
  566. seq_printf(s, "[%2d] ", tid);
  567. wil_print_rxtid(s, r);
  568. }
  569. }
  570. }
  571. }
  572. return 0;
  573. }
  574. static int wil_sta_seq_open(struct inode *inode, struct file *file)
  575. {
  576. return single_open(file, wil_sta_debugfs_show, inode->i_private);
  577. }
  578. static const struct file_operations fops_sta = {
  579. .open = wil_sta_seq_open,
  580. .release = single_release,
  581. .read = seq_read,
  582. .llseek = seq_lseek,
  583. };
  584. /*----------------*/
  585. int wil6210_debugfs_init(struct wil6210_priv *wil)
  586. {
  587. struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
  588. wil_to_wiphy(wil)->debugfsdir);
  589. if (IS_ERR_OR_NULL(dbg))
  590. return -ENODEV;
  591. debugfs_create_file("mbox", S_IRUGO, dbg, wil, &fops_mbox);
  592. debugfs_create_file("vrings", S_IRUGO, dbg, wil, &fops_vring);
  593. debugfs_create_file("stations", S_IRUGO, dbg, wil, &fops_sta);
  594. debugfs_create_file("desc", S_IRUGO, dbg, wil, &fops_txdesc);
  595. debugfs_create_u32("desc_index", S_IRUGO | S_IWUSR, dbg,
  596. &dbg_txdesc_index);
  597. debugfs_create_u32("vring_index", S_IRUGO | S_IWUSR, dbg,
  598. &dbg_vring_index);
  599. debugfs_create_file("bf", S_IRUGO, dbg, wil, &fops_bf);
  600. debugfs_create_file("ssid", S_IRUGO | S_IWUSR, dbg, wil, &fops_ssid);
  601. debugfs_create_u32("secure_pcp", S_IRUGO | S_IWUSR, dbg,
  602. &wil->secure_pcp);
  603. wil6210_debugfs_create_ISR(wil, "USER_ICR", dbg,
  604. HOSTADDR(RGF_USER_USER_ICR));
  605. wil6210_debugfs_create_ISR(wil, "DMA_EP_TX_ICR", dbg,
  606. HOSTADDR(RGF_DMA_EP_TX_ICR));
  607. wil6210_debugfs_create_ISR(wil, "DMA_EP_RX_ICR", dbg,
  608. HOSTADDR(RGF_DMA_EP_RX_ICR));
  609. wil6210_debugfs_create_ISR(wil, "DMA_EP_MISC_ICR", dbg,
  610. HOSTADDR(RGF_DMA_EP_MISC_ICR));
  611. wil6210_debugfs_create_pseudo_ISR(wil, dbg);
  612. wil6210_debugfs_create_ITR_CNT(wil, dbg);
  613. debugfs_create_u32("mem_addr", S_IRUGO | S_IWUSR, dbg, &mem_addr);
  614. debugfs_create_file("mem_val", S_IRUGO, dbg, wil, &fops_memread);
  615. debugfs_create_file("reset", S_IWUSR, dbg, wil, &fops_reset);
  616. debugfs_create_file("temp", S_IRUGO, dbg, wil, &fops_temp);
  617. wil->rgf_blob.data = (void * __force)wil->csr + 0;
  618. wil->rgf_blob.size = 0xa000;
  619. wil_debugfs_create_ioblob("blob_rgf", S_IRUGO, dbg, &wil->rgf_blob);
  620. wil->fw_code_blob.data = (void * __force)wil->csr + 0x40000;
  621. wil->fw_code_blob.size = 0x40000;
  622. wil_debugfs_create_ioblob("blob_fw_code", S_IRUGO, dbg,
  623. &wil->fw_code_blob);
  624. wil->fw_data_blob.data = (void * __force)wil->csr + 0x80000;
  625. wil->fw_data_blob.size = 0x8000;
  626. wil_debugfs_create_ioblob("blob_fw_data", S_IRUGO, dbg,
  627. &wil->fw_data_blob);
  628. wil->fw_peri_blob.data = (void * __force)wil->csr + 0x88000;
  629. wil->fw_peri_blob.size = 0x18000;
  630. wil_debugfs_create_ioblob("blob_fw_peri", S_IRUGO, dbg,
  631. &wil->fw_peri_blob);
  632. wil->uc_code_blob.data = (void * __force)wil->csr + 0xa0000;
  633. wil->uc_code_blob.size = 0x10000;
  634. wil_debugfs_create_ioblob("blob_uc_code", S_IRUGO, dbg,
  635. &wil->uc_code_blob);
  636. wil->uc_data_blob.data = (void * __force)wil->csr + 0xb0000;
  637. wil->uc_data_blob.size = 0x4000;
  638. wil_debugfs_create_ioblob("blob_uc_data", S_IRUGO, dbg,
  639. &wil->uc_data_blob);
  640. return 0;
  641. }
  642. void wil6210_debugfs_remove(struct wil6210_priv *wil)
  643. {
  644. debugfs_remove_recursive(wil->debug);
  645. wil->debug = NULL;
  646. }