12be7d22fSVladimir Kondratiev /* 22be7d22fSVladimir Kondratiev * Copyright (c) 2012 Qualcomm Atheros, Inc. 32be7d22fSVladimir Kondratiev * 42be7d22fSVladimir Kondratiev * Permission to use, copy, modify, and/or distribute this software for any 52be7d22fSVladimir Kondratiev * purpose with or without fee is hereby granted, provided that the above 62be7d22fSVladimir Kondratiev * copyright notice and this permission notice appear in all copies. 72be7d22fSVladimir Kondratiev * 82be7d22fSVladimir Kondratiev * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 92be7d22fSVladimir Kondratiev * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 102be7d22fSVladimir Kondratiev * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 112be7d22fSVladimir Kondratiev * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 122be7d22fSVladimir Kondratiev * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 132be7d22fSVladimir Kondratiev * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 142be7d22fSVladimir Kondratiev * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 152be7d22fSVladimir Kondratiev */ 162be7d22fSVladimir Kondratiev 172be7d22fSVladimir Kondratiev #include <linux/module.h> 182be7d22fSVladimir Kondratiev #include <linux/debugfs.h> 192be7d22fSVladimir Kondratiev #include <linux/seq_file.h> 202be7d22fSVladimir Kondratiev #include <linux/pci.h> 212be7d22fSVladimir Kondratiev #include <linux/rtnetlink.h> 2284bb29b7SVladimir Kondratiev #include <linux/power_supply.h> 232be7d22fSVladimir Kondratiev 242be7d22fSVladimir Kondratiev #include "wil6210.h" 252be7d22fSVladimir Kondratiev #include "txrx.h" 262be7d22fSVladimir Kondratiev 272be7d22fSVladimir Kondratiev /* Nasty hack. Better have per device instances */ 282be7d22fSVladimir Kondratiev static u32 mem_addr; 292be7d22fSVladimir Kondratiev static u32 dbg_txdesc_index; 30af31cb5aSVladimir Kondratiev static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */ 312be7d22fSVladimir Kondratiev 322be7d22fSVladimir Kondratiev static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil, 3359f7c0a9SVladimir Kondratiev const char *name, struct vring *vring, 3459f7c0a9SVladimir Kondratiev char _s, char _h) 352be7d22fSVladimir Kondratiev { 362be7d22fSVladimir Kondratiev void __iomem *x = wmi_addr(wil, vring->hwtail); 372be7d22fSVladimir Kondratiev 382be7d22fSVladimir Kondratiev seq_printf(s, "VRING %s = {\n", name); 3939c52ee8SVladimir Kondratiev seq_printf(s, " pa = %pad\n", &vring->pa); 402be7d22fSVladimir Kondratiev seq_printf(s, " va = 0x%p\n", vring->va); 412be7d22fSVladimir Kondratiev seq_printf(s, " size = %d\n", vring->size); 422be7d22fSVladimir Kondratiev seq_printf(s, " swtail = %d\n", vring->swtail); 432be7d22fSVladimir Kondratiev seq_printf(s, " swhead = %d\n", vring->swhead); 442be7d22fSVladimir Kondratiev seq_printf(s, " hwtail = [0x%08x] -> ", vring->hwtail); 452be7d22fSVladimir Kondratiev if (x) 462be7d22fSVladimir Kondratiev seq_printf(s, "0x%08x\n", ioread32(x)); 472be7d22fSVladimir Kondratiev else 482be7d22fSVladimir Kondratiev seq_printf(s, "???\n"); 492be7d22fSVladimir Kondratiev 502be7d22fSVladimir Kondratiev if (vring->va && (vring->size < 1025)) { 512be7d22fSVladimir Kondratiev uint i; 522be7d22fSVladimir Kondratiev for (i = 0; i < vring->size; i++) { 532be7d22fSVladimir Kondratiev volatile struct vring_tx_desc *d = &vring->va[i].tx; 542be7d22fSVladimir Kondratiev if ((i % 64) == 0 && (i != 0)) 552be7d22fSVladimir Kondratiev seq_printf(s, "\n"); 5659f7c0a9SVladimir Kondratiev seq_printf(s, "%c", (d->dma.status & BIT(0)) ? 5759f7c0a9SVladimir Kondratiev _s : (vring->ctx[i].skb ? _h : 'h')); 582be7d22fSVladimir Kondratiev } 592be7d22fSVladimir Kondratiev seq_printf(s, "\n"); 602be7d22fSVladimir Kondratiev } 612be7d22fSVladimir Kondratiev seq_printf(s, "}\n"); 622be7d22fSVladimir Kondratiev } 632be7d22fSVladimir Kondratiev 642be7d22fSVladimir Kondratiev static int wil_vring_debugfs_show(struct seq_file *s, void *data) 652be7d22fSVladimir Kondratiev { 662be7d22fSVladimir Kondratiev uint i; 672be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 682be7d22fSVladimir Kondratiev 6959f7c0a9SVladimir Kondratiev wil_print_vring(s, wil, "rx", &wil->vring_rx, 'S', '_'); 702be7d22fSVladimir Kondratiev 712be7d22fSVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) { 722be7d22fSVladimir Kondratiev struct vring *vring = &(wil->vring_tx[i]); 737c0acf86SVladimir Kondratiev struct vring_tx_data *txdata = &wil->vring_tx_data[i]; 747c0acf86SVladimir Kondratiev 752be7d22fSVladimir Kondratiev if (vring->va) { 763df2cd36SVladimir Kondratiev int cid = wil->vring2cid_tid[i][0]; 773df2cd36SVladimir Kondratiev int tid = wil->vring2cid_tid[i][1]; 7867c3e1b4SVladimir Kondratiev u32 swhead = vring->swhead; 7967c3e1b4SVladimir Kondratiev u32 swtail = vring->swtail; 8067c3e1b4SVladimir Kondratiev int used = (vring->size + swhead - swtail) 8167c3e1b4SVladimir Kondratiev % vring->size; 8267c3e1b4SVladimir Kondratiev int avail = vring->size - used - 1; 832be7d22fSVladimir Kondratiev char name[10]; 847c0acf86SVladimir Kondratiev /* performance monitoring */ 857c0acf86SVladimir Kondratiev cycles_t now = get_cycles(); 86e48b1790SVladimir Kondratiev cycles_t idle = txdata->idle * 100; 877c0acf86SVladimir Kondratiev cycles_t total = now - txdata->begin; 887c0acf86SVladimir Kondratiev 89e48b1790SVladimir Kondratiev do_div(idle, total); 907c0acf86SVladimir Kondratiev txdata->begin = now; 917c0acf86SVladimir Kondratiev txdata->idle = 0ULL; 927c0acf86SVladimir Kondratiev 932be7d22fSVladimir Kondratiev snprintf(name, sizeof(name), "tx_%2d", i); 943df2cd36SVladimir Kondratiev 957c0acf86SVladimir Kondratiev seq_printf(s, "\n%pM CID %d TID %d [%3d|%3d] idle %3d%%\n", 967c0acf86SVladimir Kondratiev wil->sta[cid].addr, cid, tid, used, avail, 97e48b1790SVladimir Kondratiev (int)idle); 987c0acf86SVladimir Kondratiev 9959f7c0a9SVladimir Kondratiev wil_print_vring(s, wil, name, vring, '_', 'H'); 1002be7d22fSVladimir Kondratiev } 1012be7d22fSVladimir Kondratiev } 1022be7d22fSVladimir Kondratiev 1032be7d22fSVladimir Kondratiev return 0; 1042be7d22fSVladimir Kondratiev } 1052be7d22fSVladimir Kondratiev 1062be7d22fSVladimir Kondratiev static int wil_vring_seq_open(struct inode *inode, struct file *file) 1072be7d22fSVladimir Kondratiev { 1082be7d22fSVladimir Kondratiev return single_open(file, wil_vring_debugfs_show, inode->i_private); 1092be7d22fSVladimir Kondratiev } 1102be7d22fSVladimir Kondratiev 1112be7d22fSVladimir Kondratiev static const struct file_operations fops_vring = { 1122be7d22fSVladimir Kondratiev .open = wil_vring_seq_open, 1132be7d22fSVladimir Kondratiev .release = single_release, 1142be7d22fSVladimir Kondratiev .read = seq_read, 1152be7d22fSVladimir Kondratiev .llseek = seq_lseek, 1162be7d22fSVladimir Kondratiev }; 1172be7d22fSVladimir Kondratiev 1182be7d22fSVladimir Kondratiev static void wil_print_ring(struct seq_file *s, const char *prefix, 1192be7d22fSVladimir Kondratiev void __iomem *off) 1202be7d22fSVladimir Kondratiev { 1212be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 1222be7d22fSVladimir Kondratiev struct wil6210_mbox_ring r; 1232be7d22fSVladimir Kondratiev int rsize; 1242be7d22fSVladimir Kondratiev uint i; 1252be7d22fSVladimir Kondratiev 1262be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(&r, off, sizeof(r)); 1272be7d22fSVladimir Kondratiev wil_mbox_ring_le2cpus(&r); 1282be7d22fSVladimir Kondratiev /* 1292be7d22fSVladimir Kondratiev * we just read memory block from NIC. This memory may be 1302be7d22fSVladimir Kondratiev * garbage. Check validity before using it. 1312be7d22fSVladimir Kondratiev */ 1322be7d22fSVladimir Kondratiev rsize = r.size / sizeof(struct wil6210_mbox_ring_desc); 1332be7d22fSVladimir Kondratiev 1342be7d22fSVladimir Kondratiev seq_printf(s, "ring %s = {\n", prefix); 1352be7d22fSVladimir Kondratiev seq_printf(s, " base = 0x%08x\n", r.base); 1362be7d22fSVladimir Kondratiev seq_printf(s, " size = 0x%04x bytes -> %d entries\n", r.size, rsize); 1372be7d22fSVladimir Kondratiev seq_printf(s, " tail = 0x%08x\n", r.tail); 1382be7d22fSVladimir Kondratiev seq_printf(s, " head = 0x%08x\n", r.head); 1392be7d22fSVladimir Kondratiev seq_printf(s, " entry size = %d\n", r.entry_size); 1402be7d22fSVladimir Kondratiev 1412be7d22fSVladimir Kondratiev if (r.size % sizeof(struct wil6210_mbox_ring_desc)) { 1422be7d22fSVladimir Kondratiev seq_printf(s, " ??? size is not multiple of %zd, garbage?\n", 1432be7d22fSVladimir Kondratiev sizeof(struct wil6210_mbox_ring_desc)); 1442be7d22fSVladimir Kondratiev goto out; 1452be7d22fSVladimir Kondratiev } 1462be7d22fSVladimir Kondratiev 1472be7d22fSVladimir Kondratiev if (!wmi_addr(wil, r.base) || 1482be7d22fSVladimir Kondratiev !wmi_addr(wil, r.tail) || 1492be7d22fSVladimir Kondratiev !wmi_addr(wil, r.head)) { 1502be7d22fSVladimir Kondratiev seq_printf(s, " ??? pointers are garbage?\n"); 1512be7d22fSVladimir Kondratiev goto out; 1522be7d22fSVladimir Kondratiev } 1532be7d22fSVladimir Kondratiev 1542be7d22fSVladimir Kondratiev for (i = 0; i < rsize; i++) { 1552be7d22fSVladimir Kondratiev struct wil6210_mbox_ring_desc d; 1562be7d22fSVladimir Kondratiev struct wil6210_mbox_hdr hdr; 1572be7d22fSVladimir Kondratiev size_t delta = i * sizeof(d); 1582be7d22fSVladimir Kondratiev void __iomem *x = wil->csr + HOSTADDR(r.base) + delta; 1592be7d22fSVladimir Kondratiev 1602be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(&d, x, sizeof(d)); 1612be7d22fSVladimir Kondratiev 1622be7d22fSVladimir Kondratiev seq_printf(s, " [%2x] %s %s%s 0x%08x", i, 1632be7d22fSVladimir Kondratiev d.sync ? "F" : "E", 1642be7d22fSVladimir Kondratiev (r.tail - r.base == delta) ? "t" : " ", 1652be7d22fSVladimir Kondratiev (r.head - r.base == delta) ? "h" : " ", 1662be7d22fSVladimir Kondratiev le32_to_cpu(d.addr)); 1672be7d22fSVladimir Kondratiev if (0 == wmi_read_hdr(wil, d.addr, &hdr)) { 1682be7d22fSVladimir Kondratiev u16 len = le16_to_cpu(hdr.len); 1692be7d22fSVladimir Kondratiev seq_printf(s, " -> %04x %04x %04x %02x\n", 1702be7d22fSVladimir Kondratiev le16_to_cpu(hdr.seq), len, 1712be7d22fSVladimir Kondratiev le16_to_cpu(hdr.type), hdr.flags); 1722be7d22fSVladimir Kondratiev if (len <= MAX_MBOXITEM_SIZE) { 1732be7d22fSVladimir Kondratiev int n = 0; 1745d21608aSLarry Finger char printbuf[16 * 3 + 2]; 1752be7d22fSVladimir Kondratiev unsigned char databuf[MAX_MBOXITEM_SIZE]; 1762be7d22fSVladimir Kondratiev void __iomem *src = wmi_buffer(wil, d.addr) + 1772be7d22fSVladimir Kondratiev sizeof(struct wil6210_mbox_hdr); 1782be7d22fSVladimir Kondratiev /* 1792be7d22fSVladimir Kondratiev * No need to check @src for validity - 1802be7d22fSVladimir Kondratiev * we already validated @d.addr while 1812be7d22fSVladimir Kondratiev * reading header 1822be7d22fSVladimir Kondratiev */ 1832be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(databuf, src, len); 1842be7d22fSVladimir Kondratiev while (n < len) { 1852be7d22fSVladimir Kondratiev int l = min(len - n, 16); 1862be7d22fSVladimir Kondratiev hex_dump_to_buffer(databuf + n, l, 1872be7d22fSVladimir Kondratiev 16, 1, printbuf, 1882be7d22fSVladimir Kondratiev sizeof(printbuf), 1892be7d22fSVladimir Kondratiev false); 1902be7d22fSVladimir Kondratiev seq_printf(s, " : %s\n", printbuf); 1912be7d22fSVladimir Kondratiev n += l; 1922be7d22fSVladimir Kondratiev } 1932be7d22fSVladimir Kondratiev } 1942be7d22fSVladimir Kondratiev } else { 1952be7d22fSVladimir Kondratiev seq_printf(s, "\n"); 1962be7d22fSVladimir Kondratiev } 1972be7d22fSVladimir Kondratiev } 1982be7d22fSVladimir Kondratiev out: 1992be7d22fSVladimir Kondratiev seq_printf(s, "}\n"); 2002be7d22fSVladimir Kondratiev } 2012be7d22fSVladimir Kondratiev 2022be7d22fSVladimir Kondratiev static int wil_mbox_debugfs_show(struct seq_file *s, void *data) 2032be7d22fSVladimir Kondratiev { 2042be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 2052be7d22fSVladimir Kondratiev 2062be7d22fSVladimir Kondratiev wil_print_ring(s, "tx", wil->csr + HOST_MBOX + 2072be7d22fSVladimir Kondratiev offsetof(struct wil6210_mbox_ctl, tx)); 2082be7d22fSVladimir Kondratiev wil_print_ring(s, "rx", wil->csr + HOST_MBOX + 2092be7d22fSVladimir Kondratiev offsetof(struct wil6210_mbox_ctl, rx)); 2102be7d22fSVladimir Kondratiev 2112be7d22fSVladimir Kondratiev return 0; 2122be7d22fSVladimir Kondratiev } 2132be7d22fSVladimir Kondratiev 2142be7d22fSVladimir Kondratiev static int wil_mbox_seq_open(struct inode *inode, struct file *file) 2152be7d22fSVladimir Kondratiev { 2162be7d22fSVladimir Kondratiev return single_open(file, wil_mbox_debugfs_show, inode->i_private); 2172be7d22fSVladimir Kondratiev } 2182be7d22fSVladimir Kondratiev 2192be7d22fSVladimir Kondratiev static const struct file_operations fops_mbox = { 2202be7d22fSVladimir Kondratiev .open = wil_mbox_seq_open, 2212be7d22fSVladimir Kondratiev .release = single_release, 2222be7d22fSVladimir Kondratiev .read = seq_read, 2232be7d22fSVladimir Kondratiev .llseek = seq_lseek, 2242be7d22fSVladimir Kondratiev }; 2252be7d22fSVladimir Kondratiev 2262be7d22fSVladimir Kondratiev static int wil_debugfs_iomem_x32_set(void *data, u64 val) 2272be7d22fSVladimir Kondratiev { 2282be7d22fSVladimir Kondratiev iowrite32(val, (void __iomem *)data); 2292be7d22fSVladimir Kondratiev wmb(); /* make sure write propagated to HW */ 2302be7d22fSVladimir Kondratiev 2312be7d22fSVladimir Kondratiev return 0; 2322be7d22fSVladimir Kondratiev } 2332be7d22fSVladimir Kondratiev 2342be7d22fSVladimir Kondratiev static int wil_debugfs_iomem_x32_get(void *data, u64 *val) 2352be7d22fSVladimir Kondratiev { 2362be7d22fSVladimir Kondratiev *val = ioread32((void __iomem *)data); 2372be7d22fSVladimir Kondratiev 2382be7d22fSVladimir Kondratiev return 0; 2392be7d22fSVladimir Kondratiev } 2402be7d22fSVladimir Kondratiev 2412be7d22fSVladimir Kondratiev DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get, 2422be7d22fSVladimir Kondratiev wil_debugfs_iomem_x32_set, "0x%08llx\n"); 2432be7d22fSVladimir Kondratiev 2442be7d22fSVladimir Kondratiev static struct dentry *wil_debugfs_create_iomem_x32(const char *name, 2450ecc833bSAl Viro umode_t mode, 2462be7d22fSVladimir Kondratiev struct dentry *parent, 2472be7d22fSVladimir Kondratiev void __iomem *value) 2482be7d22fSVladimir Kondratiev { 2492be7d22fSVladimir Kondratiev return debugfs_create_file(name, mode, parent, (void * __force)value, 2502be7d22fSVladimir Kondratiev &fops_iomem_x32); 2512be7d22fSVladimir Kondratiev } 2522be7d22fSVladimir Kondratiev 2533de6cf20SVladimir Kondratiev static int wil_debugfs_ulong_set(void *data, u64 val) 2543de6cf20SVladimir Kondratiev { 2553de6cf20SVladimir Kondratiev *(ulong *)data = val; 2563de6cf20SVladimir Kondratiev return 0; 2573de6cf20SVladimir Kondratiev } 2583de6cf20SVladimir Kondratiev static int wil_debugfs_ulong_get(void *data, u64 *val) 2593de6cf20SVladimir Kondratiev { 2603de6cf20SVladimir Kondratiev *val = *(ulong *)data; 2613de6cf20SVladimir Kondratiev return 0; 2623de6cf20SVladimir Kondratiev } 2633de6cf20SVladimir Kondratiev DEFINE_SIMPLE_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get, 2643de6cf20SVladimir Kondratiev wil_debugfs_ulong_set, "%llu\n"); 2653de6cf20SVladimir Kondratiev 2663de6cf20SVladimir Kondratiev static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode, 2673de6cf20SVladimir Kondratiev struct dentry *parent, 2683de6cf20SVladimir Kondratiev ulong *value) 2693de6cf20SVladimir Kondratiev { 2703de6cf20SVladimir Kondratiev return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong); 2713de6cf20SVladimir Kondratiev } 2723de6cf20SVladimir Kondratiev 2732be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil, 2742be7d22fSVladimir Kondratiev const char *name, 2752be7d22fSVladimir Kondratiev struct dentry *parent, u32 off) 2762be7d22fSVladimir Kondratiev { 2772be7d22fSVladimir Kondratiev struct dentry *d = debugfs_create_dir(name, parent); 2782be7d22fSVladimir Kondratiev 2792be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(d)) 2802be7d22fSVladimir Kondratiev return -ENODEV; 2812be7d22fSVladimir Kondratiev 2822be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("ICC", S_IRUGO | S_IWUSR, d, 2832be7d22fSVladimir Kondratiev wil->csr + off); 2842be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("ICR", S_IRUGO | S_IWUSR, d, 2852be7d22fSVladimir Kondratiev wil->csr + off + 4); 2862be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("ICM", S_IRUGO | S_IWUSR, d, 2872be7d22fSVladimir Kondratiev wil->csr + off + 8); 2882be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("ICS", S_IWUSR, d, 2892be7d22fSVladimir Kondratiev wil->csr + off + 12); 2902be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("IMV", S_IRUGO | S_IWUSR, d, 2912be7d22fSVladimir Kondratiev wil->csr + off + 16); 2922be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("IMS", S_IWUSR, d, 2932be7d22fSVladimir Kondratiev wil->csr + off + 20); 2942be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("IMC", S_IWUSR, d, 2952be7d22fSVladimir Kondratiev wil->csr + off + 24); 2962be7d22fSVladimir Kondratiev 2972be7d22fSVladimir Kondratiev return 0; 2982be7d22fSVladimir Kondratiev } 2992be7d22fSVladimir Kondratiev 3002be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil, 3012be7d22fSVladimir Kondratiev struct dentry *parent) 3022be7d22fSVladimir Kondratiev { 3032be7d22fSVladimir Kondratiev struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent); 3042be7d22fSVladimir Kondratiev 3052be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(d)) 3062be7d22fSVladimir Kondratiev return -ENODEV; 3072be7d22fSVladimir Kondratiev 3082be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("CAUSE", S_IRUGO, d, wil->csr + 3092be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_PSEUDO_CAUSE)); 3102be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("MASK_SW", S_IRUGO, d, wil->csr + 3112be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW)); 3122be7d22fSVladimir Kondratiev wil_debugfs_create_iomem_x32("MASK_FW", S_IRUGO, d, wil->csr + 3132be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW)); 3142be7d22fSVladimir Kondratiev 3152be7d22fSVladimir Kondratiev return 0; 3162be7d22fSVladimir Kondratiev } 3172be7d22fSVladimir Kondratiev 3182be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil, 3192be7d22fSVladimir Kondratiev struct dentry *parent) 3202be7d22fSVladimir Kondratiev { 3212be7d22fSVladimir Kondratiev struct dentry *d = debugfs_create_dir("ITR_CNT", parent); 3222be7d22fSVladimir Kondratiev 3232be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(d)) 3242be7d22fSVladimir Kondratiev return -ENODEV; 3252be7d22fSVladimir Kondratiev 3264b63261cSVladimir Kondratiev wil_debugfs_create_iomem_x32("TRSH", S_IRUGO | S_IWUSR, d, wil->csr + 3272be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_ITR_CNT_TRSH)); 3284b63261cSVladimir Kondratiev wil_debugfs_create_iomem_x32("DATA", S_IRUGO | S_IWUSR, d, wil->csr + 3292be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_ITR_CNT_DATA)); 3304b63261cSVladimir Kondratiev wil_debugfs_create_iomem_x32("CTL", S_IRUGO | S_IWUSR, d, wil->csr + 3312be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_ITR_CNT_CRL)); 3322be7d22fSVladimir Kondratiev 3332be7d22fSVladimir Kondratiev return 0; 3342be7d22fSVladimir Kondratiev } 3352be7d22fSVladimir Kondratiev 3362be7d22fSVladimir Kondratiev static int wil_memread_debugfs_show(struct seq_file *s, void *data) 3372be7d22fSVladimir Kondratiev { 3382be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 3392be7d22fSVladimir Kondratiev void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr)); 3402be7d22fSVladimir Kondratiev 3412be7d22fSVladimir Kondratiev if (a) 3422be7d22fSVladimir Kondratiev seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, ioread32(a)); 3432be7d22fSVladimir Kondratiev else 3442be7d22fSVladimir Kondratiev seq_printf(s, "[0x%08x] = INVALID\n", mem_addr); 3452be7d22fSVladimir Kondratiev 3462be7d22fSVladimir Kondratiev return 0; 3472be7d22fSVladimir Kondratiev } 3482be7d22fSVladimir Kondratiev 3492be7d22fSVladimir Kondratiev static int wil_memread_seq_open(struct inode *inode, struct file *file) 3502be7d22fSVladimir Kondratiev { 3512be7d22fSVladimir Kondratiev return single_open(file, wil_memread_debugfs_show, inode->i_private); 3522be7d22fSVladimir Kondratiev } 3532be7d22fSVladimir Kondratiev 3542be7d22fSVladimir Kondratiev static const struct file_operations fops_memread = { 3552be7d22fSVladimir Kondratiev .open = wil_memread_seq_open, 3562be7d22fSVladimir Kondratiev .release = single_release, 3572be7d22fSVladimir Kondratiev .read = seq_read, 3582be7d22fSVladimir Kondratiev .llseek = seq_lseek, 3592be7d22fSVladimir Kondratiev }; 3602be7d22fSVladimir Kondratiev 3612be7d22fSVladimir Kondratiev static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf, 3622be7d22fSVladimir Kondratiev size_t count, loff_t *ppos) 3632be7d22fSVladimir Kondratiev { 3642be7d22fSVladimir Kondratiev enum { max_count = 4096 }; 3652be7d22fSVladimir Kondratiev struct debugfs_blob_wrapper *blob = file->private_data; 3662be7d22fSVladimir Kondratiev loff_t pos = *ppos; 3672be7d22fSVladimir Kondratiev size_t available = blob->size; 3682be7d22fSVladimir Kondratiev void *buf; 3692be7d22fSVladimir Kondratiev size_t ret; 3702be7d22fSVladimir Kondratiev 3712be7d22fSVladimir Kondratiev if (pos < 0) 3722be7d22fSVladimir Kondratiev return -EINVAL; 3732be7d22fSVladimir Kondratiev 3742be7d22fSVladimir Kondratiev if (pos >= available || !count) 3752be7d22fSVladimir Kondratiev return 0; 3762be7d22fSVladimir Kondratiev 3772be7d22fSVladimir Kondratiev if (count > available - pos) 3782be7d22fSVladimir Kondratiev count = available - pos; 3792be7d22fSVladimir Kondratiev if (count > max_count) 3802be7d22fSVladimir Kondratiev count = max_count; 3812be7d22fSVladimir Kondratiev 3822be7d22fSVladimir Kondratiev buf = kmalloc(count, GFP_KERNEL); 3832be7d22fSVladimir Kondratiev if (!buf) 3842be7d22fSVladimir Kondratiev return -ENOMEM; 3852be7d22fSVladimir Kondratiev 3862be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(buf, (const volatile void __iomem *)blob->data + 3872be7d22fSVladimir Kondratiev pos, count); 3882be7d22fSVladimir Kondratiev 3892be7d22fSVladimir Kondratiev ret = copy_to_user(user_buf, buf, count); 3902be7d22fSVladimir Kondratiev kfree(buf); 3912be7d22fSVladimir Kondratiev if (ret == count) 3922be7d22fSVladimir Kondratiev return -EFAULT; 3932be7d22fSVladimir Kondratiev 3942be7d22fSVladimir Kondratiev count -= ret; 3952be7d22fSVladimir Kondratiev *ppos = pos + count; 3962be7d22fSVladimir Kondratiev 3972be7d22fSVladimir Kondratiev return count; 3982be7d22fSVladimir Kondratiev } 3992be7d22fSVladimir Kondratiev 4002be7d22fSVladimir Kondratiev static const struct file_operations fops_ioblob = { 4012be7d22fSVladimir Kondratiev .read = wil_read_file_ioblob, 40293ecbd64SWei Yongjun .open = simple_open, 4032be7d22fSVladimir Kondratiev .llseek = default_llseek, 4042be7d22fSVladimir Kondratiev }; 4052be7d22fSVladimir Kondratiev 4062be7d22fSVladimir Kondratiev static 4072be7d22fSVladimir Kondratiev struct dentry *wil_debugfs_create_ioblob(const char *name, 4080ecc833bSAl Viro umode_t mode, 4092be7d22fSVladimir Kondratiev struct dentry *parent, 4102be7d22fSVladimir Kondratiev struct debugfs_blob_wrapper *blob) 4112be7d22fSVladimir Kondratiev { 4122be7d22fSVladimir Kondratiev return debugfs_create_file(name, mode, parent, blob, &fops_ioblob); 4132be7d22fSVladimir Kondratiev } 4142be7d22fSVladimir Kondratiev /*---reset---*/ 4152be7d22fSVladimir Kondratiev static ssize_t wil_write_file_reset(struct file *file, const char __user *buf, 4162be7d22fSVladimir Kondratiev size_t len, loff_t *ppos) 4172be7d22fSVladimir Kondratiev { 4182be7d22fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 4192be7d22fSVladimir Kondratiev struct net_device *ndev = wil_to_ndev(wil); 4202be7d22fSVladimir Kondratiev 4212be7d22fSVladimir Kondratiev /** 4222be7d22fSVladimir Kondratiev * BUG: 4232be7d22fSVladimir Kondratiev * this code does NOT sync device state with the rest of system 4242be7d22fSVladimir Kondratiev * use with care, debug only!!! 4252be7d22fSVladimir Kondratiev */ 4262be7d22fSVladimir Kondratiev rtnl_lock(); 4272be7d22fSVladimir Kondratiev dev_close(ndev); 4282be7d22fSVladimir Kondratiev ndev->flags &= ~IFF_UP; 4292be7d22fSVladimir Kondratiev rtnl_unlock(); 4302be7d22fSVladimir Kondratiev wil_reset(wil); 4312be7d22fSVladimir Kondratiev 4322be7d22fSVladimir Kondratiev return len; 4332be7d22fSVladimir Kondratiev } 4342be7d22fSVladimir Kondratiev 4352be7d22fSVladimir Kondratiev static const struct file_operations fops_reset = { 4362be7d22fSVladimir Kondratiev .write = wil_write_file_reset, 43793ecbd64SWei Yongjun .open = simple_open, 4382be7d22fSVladimir Kondratiev }; 4390b39aaf2SVladimir Kondratiev /*---write channel 1..4 to rxon for it, 0 to rxoff---*/ 4400b39aaf2SVladimir Kondratiev static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf, 4410b39aaf2SVladimir Kondratiev size_t len, loff_t *ppos) 4420b39aaf2SVladimir Kondratiev { 4430b39aaf2SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 4440b39aaf2SVladimir Kondratiev int rc; 4450b39aaf2SVladimir Kondratiev long channel; 4460b39aaf2SVladimir Kondratiev bool on; 4470b39aaf2SVladimir Kondratiev 4480b39aaf2SVladimir Kondratiev char *kbuf = kmalloc(len + 1, GFP_KERNEL); 4490b39aaf2SVladimir Kondratiev if (!kbuf) 4500b39aaf2SVladimir Kondratiev return -ENOMEM; 4510b39aaf2SVladimir Kondratiev if (copy_from_user(kbuf, buf, len)) 4520b39aaf2SVladimir Kondratiev return -EIO; 4530b39aaf2SVladimir Kondratiev 4540b39aaf2SVladimir Kondratiev kbuf[len] = '\0'; 4550b39aaf2SVladimir Kondratiev rc = kstrtol(kbuf, 0, &channel); 4560b39aaf2SVladimir Kondratiev kfree(kbuf); 4570b39aaf2SVladimir Kondratiev if (rc) 4580b39aaf2SVladimir Kondratiev return rc; 4590b39aaf2SVladimir Kondratiev 4600b39aaf2SVladimir Kondratiev if ((channel < 0) || (channel > 4)) { 4610b39aaf2SVladimir Kondratiev wil_err(wil, "Invalid channel %ld\n", channel); 4620b39aaf2SVladimir Kondratiev return -EINVAL; 4630b39aaf2SVladimir Kondratiev } 4640b39aaf2SVladimir Kondratiev on = !!channel; 4650b39aaf2SVladimir Kondratiev 4660b39aaf2SVladimir Kondratiev if (on) { 4670b39aaf2SVladimir Kondratiev rc = wmi_set_channel(wil, (int)channel); 4680b39aaf2SVladimir Kondratiev if (rc) 4690b39aaf2SVladimir Kondratiev return rc; 4700b39aaf2SVladimir Kondratiev } 4710b39aaf2SVladimir Kondratiev 4720b39aaf2SVladimir Kondratiev rc = wmi_rxon(wil, on); 4730b39aaf2SVladimir Kondratiev if (rc) 4740b39aaf2SVladimir Kondratiev return rc; 4750b39aaf2SVladimir Kondratiev 4760b39aaf2SVladimir Kondratiev return len; 4770b39aaf2SVladimir Kondratiev } 4780b39aaf2SVladimir Kondratiev 4790b39aaf2SVladimir Kondratiev static const struct file_operations fops_rxon = { 4800b39aaf2SVladimir Kondratiev .write = wil_write_file_rxon, 4810b39aaf2SVladimir Kondratiev .open = simple_open, 4820b39aaf2SVladimir Kondratiev }; 4830b39aaf2SVladimir Kondratiev /*---tx_mgmt---*/ 4840b39aaf2SVladimir Kondratiev /* Write mgmt frame to this file to send it */ 4850b39aaf2SVladimir Kondratiev static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf, 4860b39aaf2SVladimir Kondratiev size_t len, loff_t *ppos) 4870b39aaf2SVladimir Kondratiev { 4880b39aaf2SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 4890b39aaf2SVladimir Kondratiev struct wiphy *wiphy = wil_to_wiphy(wil); 4900b39aaf2SVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 4910b39aaf2SVladimir Kondratiev struct cfg80211_mgmt_tx_params params; 4920b39aaf2SVladimir Kondratiev int rc; 4930b39aaf2SVladimir Kondratiev 4940b39aaf2SVladimir Kondratiev void *frame = kmalloc(len, GFP_KERNEL); 4950b39aaf2SVladimir Kondratiev if (!frame) 4960b39aaf2SVladimir Kondratiev return -ENOMEM; 4970b39aaf2SVladimir Kondratiev 4980b39aaf2SVladimir Kondratiev if (copy_from_user(frame, buf, len)) 4990b39aaf2SVladimir Kondratiev return -EIO; 5000b39aaf2SVladimir Kondratiev 5010b39aaf2SVladimir Kondratiev params.buf = frame; 5020b39aaf2SVladimir Kondratiev params.len = len; 5030b39aaf2SVladimir Kondratiev params.chan = wdev->preset_chandef.chan; 5040b39aaf2SVladimir Kondratiev 5050b39aaf2SVladimir Kondratiev rc = wil_cfg80211_mgmt_tx(wiphy, wdev, ¶ms, NULL); 5060b39aaf2SVladimir Kondratiev 5070b39aaf2SVladimir Kondratiev kfree(frame); 5080b39aaf2SVladimir Kondratiev wil_info(wil, "%s() -> %d\n", __func__, rc); 5090b39aaf2SVladimir Kondratiev 5100b39aaf2SVladimir Kondratiev return len; 5110b39aaf2SVladimir Kondratiev } 5120b39aaf2SVladimir Kondratiev 5130b39aaf2SVladimir Kondratiev static const struct file_operations fops_txmgmt = { 5140b39aaf2SVladimir Kondratiev .write = wil_write_file_txmgmt, 5150b39aaf2SVladimir Kondratiev .open = simple_open, 5160b39aaf2SVladimir Kondratiev }; 5172be7d22fSVladimir Kondratiev 518ff974e40SVladimir Kondratiev /* Write WMI command (w/o mbox header) to this file to send it 519ff974e40SVladimir Kondratiev * WMI starts from wil6210_mbox_hdr_wmi header 520ff974e40SVladimir Kondratiev */ 521ff974e40SVladimir Kondratiev static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf, 522ff974e40SVladimir Kondratiev size_t len, loff_t *ppos) 523ff974e40SVladimir Kondratiev { 524ff974e40SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 525ff974e40SVladimir Kondratiev struct wil6210_mbox_hdr_wmi *wmi; 526ff974e40SVladimir Kondratiev void *cmd; 527ff974e40SVladimir Kondratiev int cmdlen = len - sizeof(struct wil6210_mbox_hdr_wmi); 528ff974e40SVladimir Kondratiev u16 cmdid; 529ff974e40SVladimir Kondratiev int rc, rc1; 530ff974e40SVladimir Kondratiev 531ff974e40SVladimir Kondratiev if (cmdlen <= 0) 532ff974e40SVladimir Kondratiev return -EINVAL; 533ff974e40SVladimir Kondratiev 534ff974e40SVladimir Kondratiev wmi = kmalloc(len, GFP_KERNEL); 535ff974e40SVladimir Kondratiev if (!wmi) 536ff974e40SVladimir Kondratiev return -ENOMEM; 537ff974e40SVladimir Kondratiev 538ff974e40SVladimir Kondratiev rc = simple_write_to_buffer(wmi, len, ppos, buf, len); 539ff974e40SVladimir Kondratiev if (rc < 0) 540ff974e40SVladimir Kondratiev return rc; 541ff974e40SVladimir Kondratiev 542ff974e40SVladimir Kondratiev cmd = &wmi[1]; 543ff974e40SVladimir Kondratiev cmdid = le16_to_cpu(wmi->id); 544ff974e40SVladimir Kondratiev 545ff974e40SVladimir Kondratiev rc1 = wmi_send(wil, cmdid, cmd, cmdlen); 546ff974e40SVladimir Kondratiev kfree(wmi); 547ff974e40SVladimir Kondratiev 548ff974e40SVladimir Kondratiev wil_info(wil, "%s(0x%04x[%d]) -> %d\n", __func__, cmdid, cmdlen, rc1); 549ff974e40SVladimir Kondratiev 550ff974e40SVladimir Kondratiev return rc; 551ff974e40SVladimir Kondratiev } 552ff974e40SVladimir Kondratiev 553ff974e40SVladimir Kondratiev static const struct file_operations fops_wmi = { 554ff974e40SVladimir Kondratiev .write = wil_write_file_wmi, 555ff974e40SVladimir Kondratiev .open = simple_open, 556ff974e40SVladimir Kondratiev }; 557ff974e40SVladimir Kondratiev 558c236658fSVladimir Kondratiev static void wil_seq_hexdump(struct seq_file *s, void *p, int len, 559c236658fSVladimir Kondratiev const char *prefix) 560c236658fSVladimir Kondratiev { 561c236658fSVladimir Kondratiev char printbuf[16 * 3 + 2]; 562c236658fSVladimir Kondratiev int i = 0; 563c236658fSVladimir Kondratiev while (i < len) { 564c236658fSVladimir Kondratiev int l = min(len - i, 16); 565c236658fSVladimir Kondratiev hex_dump_to_buffer(p + i, l, 16, 1, printbuf, 566c236658fSVladimir Kondratiev sizeof(printbuf), false); 567c236658fSVladimir Kondratiev seq_printf(s, "%s%s\n", prefix, printbuf); 568c236658fSVladimir Kondratiev i += l; 569c236658fSVladimir Kondratiev } 570c236658fSVladimir Kondratiev } 571c236658fSVladimir Kondratiev 572c236658fSVladimir Kondratiev static void wil_seq_print_skb(struct seq_file *s, struct sk_buff *skb) 573c236658fSVladimir Kondratiev { 574c236658fSVladimir Kondratiev int i = 0; 575c236658fSVladimir Kondratiev int len = skb_headlen(skb); 576c236658fSVladimir Kondratiev void *p = skb->data; 577c236658fSVladimir Kondratiev int nr_frags = skb_shinfo(skb)->nr_frags; 578c236658fSVladimir Kondratiev 579c236658fSVladimir Kondratiev seq_printf(s, " len = %d\n", len); 580c236658fSVladimir Kondratiev wil_seq_hexdump(s, p, len, " : "); 581c236658fSVladimir Kondratiev 582c236658fSVladimir Kondratiev if (nr_frags) { 583c236658fSVladimir Kondratiev seq_printf(s, " nr_frags = %d\n", nr_frags); 584c236658fSVladimir Kondratiev for (i = 0; i < nr_frags; i++) { 585c236658fSVladimir Kondratiev const struct skb_frag_struct *frag = 586c236658fSVladimir Kondratiev &skb_shinfo(skb)->frags[i]; 587c236658fSVladimir Kondratiev 588c236658fSVladimir Kondratiev len = skb_frag_size(frag); 589c236658fSVladimir Kondratiev p = skb_frag_address_safe(frag); 590c236658fSVladimir Kondratiev seq_printf(s, " [%2d] : len = %d\n", i, len); 591c236658fSVladimir Kondratiev wil_seq_hexdump(s, p, len, " : "); 592c236658fSVladimir Kondratiev } 593c236658fSVladimir Kondratiev } 594c236658fSVladimir Kondratiev } 595c236658fSVladimir Kondratiev 5963a85543eSVladimir Kondratiev /*---------Tx/Rx descriptor------------*/ 5972be7d22fSVladimir Kondratiev static int wil_txdesc_debugfs_show(struct seq_file *s, void *data) 5982be7d22fSVladimir Kondratiev { 5992be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 6003a85543eSVladimir Kondratiev struct vring *vring; 601af31cb5aSVladimir Kondratiev bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS); 602af31cb5aSVladimir Kondratiev if (tx) 6033a85543eSVladimir Kondratiev vring = &(wil->vring_tx[dbg_vring_index]); 6043a85543eSVladimir Kondratiev else 6053a85543eSVladimir Kondratiev vring = &wil->vring_rx; 6062be7d22fSVladimir Kondratiev 6072be7d22fSVladimir Kondratiev if (!vring->va) { 608af31cb5aSVladimir Kondratiev if (tx) 6093a85543eSVladimir Kondratiev seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index); 6103a85543eSVladimir Kondratiev else 6113a85543eSVladimir Kondratiev seq_puts(s, "No Rx VRING\n"); 6122be7d22fSVladimir Kondratiev return 0; 6132be7d22fSVladimir Kondratiev } 6142be7d22fSVladimir Kondratiev 6152be7d22fSVladimir Kondratiev if (dbg_txdesc_index < vring->size) { 6163a85543eSVladimir Kondratiev /* use struct vring_tx_desc for Rx as well, 6173a85543eSVladimir Kondratiev * only field used, .dma.length, is the same 6183a85543eSVladimir Kondratiev */ 6192be7d22fSVladimir Kondratiev volatile struct vring_tx_desc *d = 6202be7d22fSVladimir Kondratiev &(vring->va[dbg_txdesc_index].tx); 6212be7d22fSVladimir Kondratiev volatile u32 *u = (volatile u32 *)d; 622f88f113aSVladimir Kondratiev struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb; 6232be7d22fSVladimir Kondratiev 624af31cb5aSVladimir Kondratiev if (tx) 6253a85543eSVladimir Kondratiev seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index, 6263a85543eSVladimir Kondratiev dbg_txdesc_index); 6273a85543eSVladimir Kondratiev else 6283a85543eSVladimir Kondratiev seq_printf(s, "Rx[%3d] = {\n", dbg_txdesc_index); 6292be7d22fSVladimir Kondratiev seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n", 6302be7d22fSVladimir Kondratiev u[0], u[1], u[2], u[3]); 6312be7d22fSVladimir Kondratiev seq_printf(s, " DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n", 6322be7d22fSVladimir Kondratiev u[4], u[5], u[6], u[7]); 63339c52ee8SVladimir Kondratiev seq_printf(s, " SKB = 0x%p\n", skb); 6342be7d22fSVladimir Kondratiev 6352be7d22fSVladimir Kondratiev if (skb) { 636c236658fSVladimir Kondratiev skb_get(skb); 637c236658fSVladimir Kondratiev wil_seq_print_skb(s, skb); 638c236658fSVladimir Kondratiev kfree_skb(skb); 6392be7d22fSVladimir Kondratiev } 6402be7d22fSVladimir Kondratiev seq_printf(s, "}\n"); 6412be7d22fSVladimir Kondratiev } else { 642af31cb5aSVladimir Kondratiev if (tx) 6433a85543eSVladimir Kondratiev seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n", 6443a85543eSVladimir Kondratiev dbg_vring_index, dbg_txdesc_index, 6453a85543eSVladimir Kondratiev vring->size); 6463a85543eSVladimir Kondratiev else 6473a85543eSVladimir Kondratiev seq_printf(s, "RxDesc index (%d) >= size (%d)\n", 6482be7d22fSVladimir Kondratiev dbg_txdesc_index, vring->size); 6492be7d22fSVladimir Kondratiev } 6502be7d22fSVladimir Kondratiev 6512be7d22fSVladimir Kondratiev return 0; 6522be7d22fSVladimir Kondratiev } 6532be7d22fSVladimir Kondratiev 6542be7d22fSVladimir Kondratiev static int wil_txdesc_seq_open(struct inode *inode, struct file *file) 6552be7d22fSVladimir Kondratiev { 6562be7d22fSVladimir Kondratiev return single_open(file, wil_txdesc_debugfs_show, inode->i_private); 6572be7d22fSVladimir Kondratiev } 6582be7d22fSVladimir Kondratiev 6592be7d22fSVladimir Kondratiev static const struct file_operations fops_txdesc = { 6602be7d22fSVladimir Kondratiev .open = wil_txdesc_seq_open, 6612be7d22fSVladimir Kondratiev .release = single_release, 6622be7d22fSVladimir Kondratiev .read = seq_read, 6632be7d22fSVladimir Kondratiev .llseek = seq_lseek, 6642be7d22fSVladimir Kondratiev }; 6652be7d22fSVladimir Kondratiev 6662be7d22fSVladimir Kondratiev /*---------beamforming------------*/ 6672be7d22fSVladimir Kondratiev static int wil_bf_debugfs_show(struct seq_file *s, void *data) 6682be7d22fSVladimir Kondratiev { 6692be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 6702be7d22fSVladimir Kondratiev seq_printf(s, 6712be7d22fSVladimir Kondratiev "TSF : 0x%016llx\n" 6722be7d22fSVladimir Kondratiev "TxMCS : %d\n" 6732be7d22fSVladimir Kondratiev "Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n", 6742be7d22fSVladimir Kondratiev wil->stats.tsf, wil->stats.bf_mcs, 6752be7d22fSVladimir Kondratiev wil->stats.my_rx_sector, wil->stats.my_tx_sector, 6762be7d22fSVladimir Kondratiev wil->stats.peer_rx_sector, wil->stats.peer_tx_sector); 6772be7d22fSVladimir Kondratiev return 0; 6782be7d22fSVladimir Kondratiev } 6792be7d22fSVladimir Kondratiev 6802be7d22fSVladimir Kondratiev static int wil_bf_seq_open(struct inode *inode, struct file *file) 6812be7d22fSVladimir Kondratiev { 6822be7d22fSVladimir Kondratiev return single_open(file, wil_bf_debugfs_show, inode->i_private); 6832be7d22fSVladimir Kondratiev } 6842be7d22fSVladimir Kondratiev 6852be7d22fSVladimir Kondratiev static const struct file_operations fops_bf = { 6862be7d22fSVladimir Kondratiev .open = wil_bf_seq_open, 6872be7d22fSVladimir Kondratiev .release = single_release, 6882be7d22fSVladimir Kondratiev .read = seq_read, 6892be7d22fSVladimir Kondratiev .llseek = seq_lseek, 6902be7d22fSVladimir Kondratiev }; 6912be7d22fSVladimir Kondratiev /*---------SSID------------*/ 6922be7d22fSVladimir Kondratiev static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf, 6932be7d22fSVladimir Kondratiev size_t count, loff_t *ppos) 6942be7d22fSVladimir Kondratiev { 6952be7d22fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 6962be7d22fSVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 6972be7d22fSVladimir Kondratiev 6982be7d22fSVladimir Kondratiev return simple_read_from_buffer(user_buf, count, ppos, 6992be7d22fSVladimir Kondratiev wdev->ssid, wdev->ssid_len); 7002be7d22fSVladimir Kondratiev } 7012be7d22fSVladimir Kondratiev 7022be7d22fSVladimir Kondratiev static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf, 7032be7d22fSVladimir Kondratiev size_t count, loff_t *ppos) 7042be7d22fSVladimir Kondratiev { 7052be7d22fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 7062be7d22fSVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 7072be7d22fSVladimir Kondratiev struct net_device *ndev = wil_to_ndev(wil); 7082be7d22fSVladimir Kondratiev 7092be7d22fSVladimir Kondratiev if (*ppos != 0) { 7102be7d22fSVladimir Kondratiev wil_err(wil, "Unable to set SSID substring from [%d]\n", 7112be7d22fSVladimir Kondratiev (int)*ppos); 7122be7d22fSVladimir Kondratiev return -EINVAL; 7132be7d22fSVladimir Kondratiev } 7142be7d22fSVladimir Kondratiev 7152be7d22fSVladimir Kondratiev if (count > sizeof(wdev->ssid)) { 7162be7d22fSVladimir Kondratiev wil_err(wil, "SSID too long, len = %d\n", (int)count); 7172be7d22fSVladimir Kondratiev return -EINVAL; 7182be7d22fSVladimir Kondratiev } 7192be7d22fSVladimir Kondratiev if (netif_running(ndev)) { 7202be7d22fSVladimir Kondratiev wil_err(wil, "Unable to change SSID on running interface\n"); 7212be7d22fSVladimir Kondratiev return -EINVAL; 7222be7d22fSVladimir Kondratiev } 7232be7d22fSVladimir Kondratiev 7242be7d22fSVladimir Kondratiev wdev->ssid_len = count; 7252be7d22fSVladimir Kondratiev return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos, 7262be7d22fSVladimir Kondratiev buf, count); 7272be7d22fSVladimir Kondratiev } 7282be7d22fSVladimir Kondratiev 7292be7d22fSVladimir Kondratiev static const struct file_operations fops_ssid = { 7302be7d22fSVladimir Kondratiev .read = wil_read_file_ssid, 7312be7d22fSVladimir Kondratiev .write = wil_write_file_ssid, 73293ecbd64SWei Yongjun .open = simple_open, 7332be7d22fSVladimir Kondratiev }; 7342be7d22fSVladimir Kondratiev 7351a2780e0SVladimir Kondratiev /*---------temp------------*/ 7361a2780e0SVladimir Kondratiev static void print_temp(struct seq_file *s, const char *prefix, u32 t) 7371a2780e0SVladimir Kondratiev { 7381a2780e0SVladimir Kondratiev switch (t) { 7391a2780e0SVladimir Kondratiev case 0: 7401a2780e0SVladimir Kondratiev case ~(u32)0: 7411a2780e0SVladimir Kondratiev seq_printf(s, "%s N/A\n", prefix); 7421a2780e0SVladimir Kondratiev break; 7431a2780e0SVladimir Kondratiev default: 7441a2780e0SVladimir Kondratiev seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000); 7451a2780e0SVladimir Kondratiev break; 7461a2780e0SVladimir Kondratiev } 7471a2780e0SVladimir Kondratiev } 7481a2780e0SVladimir Kondratiev 7491a2780e0SVladimir Kondratiev static int wil_temp_debugfs_show(struct seq_file *s, void *data) 7501a2780e0SVladimir Kondratiev { 7511a2780e0SVladimir Kondratiev struct wil6210_priv *wil = s->private; 7521a2780e0SVladimir Kondratiev u32 t_m, t_r; 7531a2780e0SVladimir Kondratiev 7541a2780e0SVladimir Kondratiev int rc = wmi_get_temperature(wil, &t_m, &t_r); 7551a2780e0SVladimir Kondratiev if (rc) { 7561a2780e0SVladimir Kondratiev seq_printf(s, "Failed\n"); 7571a2780e0SVladimir Kondratiev return 0; 7581a2780e0SVladimir Kondratiev } 7591a2780e0SVladimir Kondratiev 760d45cff9fSVladimir Kondratiev print_temp(s, "T_mac =", t_m); 761d45cff9fSVladimir Kondratiev print_temp(s, "T_radio =", t_r); 7621a2780e0SVladimir Kondratiev 7631a2780e0SVladimir Kondratiev return 0; 7641a2780e0SVladimir Kondratiev } 7651a2780e0SVladimir Kondratiev 7661a2780e0SVladimir Kondratiev static int wil_temp_seq_open(struct inode *inode, struct file *file) 7671a2780e0SVladimir Kondratiev { 7681a2780e0SVladimir Kondratiev return single_open(file, wil_temp_debugfs_show, inode->i_private); 7691a2780e0SVladimir Kondratiev } 7701a2780e0SVladimir Kondratiev 7711a2780e0SVladimir Kondratiev static const struct file_operations fops_temp = { 7721a2780e0SVladimir Kondratiev .open = wil_temp_seq_open, 7731a2780e0SVladimir Kondratiev .release = single_release, 7741a2780e0SVladimir Kondratiev .read = seq_read, 7751a2780e0SVladimir Kondratiev .llseek = seq_lseek, 7761a2780e0SVladimir Kondratiev }; 7771a2780e0SVladimir Kondratiev 7789eb82d43SVladimir Kondratiev /*---------freq------------*/ 7799eb82d43SVladimir Kondratiev static int wil_freq_debugfs_show(struct seq_file *s, void *data) 7809eb82d43SVladimir Kondratiev { 7819eb82d43SVladimir Kondratiev struct wil6210_priv *wil = s->private; 7829eb82d43SVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 7839eb82d43SVladimir Kondratiev u16 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0; 7849eb82d43SVladimir Kondratiev 7859eb82d43SVladimir Kondratiev seq_printf(s, "Freq = %d\n", freq); 7869eb82d43SVladimir Kondratiev 7879eb82d43SVladimir Kondratiev return 0; 7889eb82d43SVladimir Kondratiev } 7899eb82d43SVladimir Kondratiev 7909eb82d43SVladimir Kondratiev static int wil_freq_seq_open(struct inode *inode, struct file *file) 7919eb82d43SVladimir Kondratiev { 7929eb82d43SVladimir Kondratiev return single_open(file, wil_freq_debugfs_show, inode->i_private); 7939eb82d43SVladimir Kondratiev } 7949eb82d43SVladimir Kondratiev 7959eb82d43SVladimir Kondratiev static const struct file_operations fops_freq = { 7969eb82d43SVladimir Kondratiev .open = wil_freq_seq_open, 7979eb82d43SVladimir Kondratiev .release = single_release, 7989eb82d43SVladimir Kondratiev .read = seq_read, 7999eb82d43SVladimir Kondratiev .llseek = seq_lseek, 8009eb82d43SVladimir Kondratiev }; 8019eb82d43SVladimir Kondratiev 8029eb82d43SVladimir Kondratiev /*---------link------------*/ 8039eb82d43SVladimir Kondratiev static int wil_link_debugfs_show(struct seq_file *s, void *data) 8049eb82d43SVladimir Kondratiev { 8059eb82d43SVladimir Kondratiev struct wil6210_priv *wil = s->private; 8069eb82d43SVladimir Kondratiev struct station_info sinfo; 8079eb82d43SVladimir Kondratiev int i, rc; 8089eb82d43SVladimir Kondratiev 8099eb82d43SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { 8109eb82d43SVladimir Kondratiev struct wil_sta_info *p = &wil->sta[i]; 8119eb82d43SVladimir Kondratiev char *status = "unknown"; 8129eb82d43SVladimir Kondratiev switch (p->status) { 8139eb82d43SVladimir Kondratiev case wil_sta_unused: 8149eb82d43SVladimir Kondratiev status = "unused "; 8159eb82d43SVladimir Kondratiev break; 8169eb82d43SVladimir Kondratiev case wil_sta_conn_pending: 8179eb82d43SVladimir Kondratiev status = "pending "; 8189eb82d43SVladimir Kondratiev break; 8199eb82d43SVladimir Kondratiev case wil_sta_connected: 8209eb82d43SVladimir Kondratiev status = "connected"; 8219eb82d43SVladimir Kondratiev break; 8229eb82d43SVladimir Kondratiev } 8239eb82d43SVladimir Kondratiev seq_printf(s, "[%d] %pM %s%s\n", i, p->addr, status, 8249eb82d43SVladimir Kondratiev (p->data_port_open ? " data_port_open" : "")); 8259eb82d43SVladimir Kondratiev 8269eb82d43SVladimir Kondratiev if (p->status == wil_sta_connected) { 8279eb82d43SVladimir Kondratiev rc = wil_cid_fill_sinfo(wil, i, &sinfo); 8289eb82d43SVladimir Kondratiev if (rc) 8299eb82d43SVladimir Kondratiev return rc; 8309eb82d43SVladimir Kondratiev 8319eb82d43SVladimir Kondratiev seq_printf(s, " Tx_mcs = %d\n", sinfo.txrate.mcs); 8329eb82d43SVladimir Kondratiev seq_printf(s, " Rx_mcs = %d\n", sinfo.rxrate.mcs); 8339eb82d43SVladimir Kondratiev seq_printf(s, " SQ = %d\n", sinfo.signal); 8349eb82d43SVladimir Kondratiev } 8359eb82d43SVladimir Kondratiev } 8369eb82d43SVladimir Kondratiev 8379eb82d43SVladimir Kondratiev return 0; 8389eb82d43SVladimir Kondratiev } 8399eb82d43SVladimir Kondratiev 8409eb82d43SVladimir Kondratiev static int wil_link_seq_open(struct inode *inode, struct file *file) 8419eb82d43SVladimir Kondratiev { 8429eb82d43SVladimir Kondratiev return single_open(file, wil_link_debugfs_show, inode->i_private); 8439eb82d43SVladimir Kondratiev } 8449eb82d43SVladimir Kondratiev 8459eb82d43SVladimir Kondratiev static const struct file_operations fops_link = { 8469eb82d43SVladimir Kondratiev .open = wil_link_seq_open, 8479eb82d43SVladimir Kondratiev .release = single_release, 8489eb82d43SVladimir Kondratiev .read = seq_read, 8499eb82d43SVladimir Kondratiev .llseek = seq_lseek, 8509eb82d43SVladimir Kondratiev }; 8519eb82d43SVladimir Kondratiev 85284bb29b7SVladimir Kondratiev /*---------info------------*/ 85384bb29b7SVladimir Kondratiev static int wil_info_debugfs_show(struct seq_file *s, void *data) 85484bb29b7SVladimir Kondratiev { 855be299858SVladimir Kondratiev struct wil6210_priv *wil = s->private; 856be299858SVladimir Kondratiev struct net_device *ndev = wil_to_ndev(wil); 85784bb29b7SVladimir Kondratiev int is_ac = power_supply_is_system_supplied(); 858be299858SVladimir Kondratiev int rx = atomic_xchg(&wil->isr_count_rx, 0); 859be299858SVladimir Kondratiev int tx = atomic_xchg(&wil->isr_count_tx, 0); 860be299858SVladimir Kondratiev static ulong rxf_old, txf_old; 861be299858SVladimir Kondratiev ulong rxf = ndev->stats.rx_packets; 862be299858SVladimir Kondratiev ulong txf = ndev->stats.tx_packets; 86355f8f680SVladimir Kondratiev unsigned int i; 86484bb29b7SVladimir Kondratiev 86584bb29b7SVladimir Kondratiev /* >0 : AC; 0 : battery; <0 : error */ 86684bb29b7SVladimir Kondratiev seq_printf(s, "AC powered : %d\n", is_ac); 867be299858SVladimir Kondratiev seq_printf(s, "Rx irqs:packets : %8d : %8ld\n", rx, rxf - rxf_old); 868be299858SVladimir Kondratiev seq_printf(s, "Tx irqs:packets : %8d : %8ld\n", tx, txf - txf_old); 869be299858SVladimir Kondratiev rxf_old = rxf; 870be299858SVladimir Kondratiev txf_old = txf; 87184bb29b7SVladimir Kondratiev 87255f8f680SVladimir Kondratiev 87355f8f680SVladimir Kondratiev #define CHECK_QSTATE(x) (state & BIT(__QUEUE_STATE_ ## x)) ? \ 87455f8f680SVladimir Kondratiev " " __stringify(x) : "" 87555f8f680SVladimir Kondratiev 87655f8f680SVladimir Kondratiev for (i = 0; i < ndev->num_tx_queues; i++) { 87755f8f680SVladimir Kondratiev struct netdev_queue *txq = netdev_get_tx_queue(ndev, i); 87855f8f680SVladimir Kondratiev unsigned long state = txq->state; 87955f8f680SVladimir Kondratiev 88055f8f680SVladimir Kondratiev seq_printf(s, "Tx queue[%i] state : 0x%lx%s%s%s\n", i, state, 88155f8f680SVladimir Kondratiev CHECK_QSTATE(DRV_XOFF), 88255f8f680SVladimir Kondratiev CHECK_QSTATE(STACK_XOFF), 88355f8f680SVladimir Kondratiev CHECK_QSTATE(FROZEN) 88455f8f680SVladimir Kondratiev ); 88555f8f680SVladimir Kondratiev } 88655f8f680SVladimir Kondratiev #undef CHECK_QSTATE 88784bb29b7SVladimir Kondratiev return 0; 88884bb29b7SVladimir Kondratiev } 88984bb29b7SVladimir Kondratiev 89084bb29b7SVladimir Kondratiev static int wil_info_seq_open(struct inode *inode, struct file *file) 89184bb29b7SVladimir Kondratiev { 89284bb29b7SVladimir Kondratiev return single_open(file, wil_info_debugfs_show, inode->i_private); 89384bb29b7SVladimir Kondratiev } 89484bb29b7SVladimir Kondratiev 89584bb29b7SVladimir Kondratiev static const struct file_operations fops_info = { 89684bb29b7SVladimir Kondratiev .open = wil_info_seq_open, 89784bb29b7SVladimir Kondratiev .release = single_release, 89884bb29b7SVladimir Kondratiev .read = seq_read, 89984bb29b7SVladimir Kondratiev .llseek = seq_lseek, 90084bb29b7SVladimir Kondratiev }; 90184bb29b7SVladimir Kondratiev 9023df2cd36SVladimir Kondratiev /*---------Station matrix------------*/ 903b4490f42SVladimir Kondratiev static void wil_print_rxtid(struct seq_file *s, struct wil_tid_ampdu_rx *r) 904b4490f42SVladimir Kondratiev { 905b4490f42SVladimir Kondratiev int i; 906b4490f42SVladimir Kondratiev u16 index = ((r->head_seq_num - r->ssn) & 0xfff) % r->buf_size; 907b4490f42SVladimir Kondratiev seq_printf(s, "0x%03x [", r->head_seq_num); 908b4490f42SVladimir Kondratiev for (i = 0; i < r->buf_size; i++) { 909b4490f42SVladimir Kondratiev if (i == index) 910b4490f42SVladimir Kondratiev seq_printf(s, "%c", r->reorder_buf[i] ? 'O' : '|'); 911b4490f42SVladimir Kondratiev else 912b4490f42SVladimir Kondratiev seq_printf(s, "%c", r->reorder_buf[i] ? '*' : '_'); 913b4490f42SVladimir Kondratiev } 914d5b1c32fSVladimir Kondratiev seq_printf(s, "] last drop 0x%03x\n", r->ssn_last_drop); 915b4490f42SVladimir Kondratiev } 9163df2cd36SVladimir Kondratiev 9173df2cd36SVladimir Kondratiev static int wil_sta_debugfs_show(struct seq_file *s, void *data) 9183df2cd36SVladimir Kondratiev { 9193df2cd36SVladimir Kondratiev struct wil6210_priv *wil = s->private; 920b4490f42SVladimir Kondratiev int i, tid; 9213df2cd36SVladimir Kondratiev 9223df2cd36SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { 9233df2cd36SVladimir Kondratiev struct wil_sta_info *p = &wil->sta[i]; 9243df2cd36SVladimir Kondratiev char *status = "unknown"; 9253df2cd36SVladimir Kondratiev switch (p->status) { 9263df2cd36SVladimir Kondratiev case wil_sta_unused: 9273df2cd36SVladimir Kondratiev status = "unused "; 9283df2cd36SVladimir Kondratiev break; 9293df2cd36SVladimir Kondratiev case wil_sta_conn_pending: 9303df2cd36SVladimir Kondratiev status = "pending "; 9313df2cd36SVladimir Kondratiev break; 9323df2cd36SVladimir Kondratiev case wil_sta_connected: 9333df2cd36SVladimir Kondratiev status = "connected"; 9343df2cd36SVladimir Kondratiev break; 9353df2cd36SVladimir Kondratiev } 936e58c9f70SVladimir Kondratiev seq_printf(s, "[%d] %pM %s%s\n", i, p->addr, status, 937e58c9f70SVladimir Kondratiev (p->data_port_open ? " data_port_open" : "")); 938b4490f42SVladimir Kondratiev 939b4490f42SVladimir Kondratiev if (p->status == wil_sta_connected) { 940b4490f42SVladimir Kondratiev for (tid = 0; tid < WIL_STA_TID_NUM; tid++) { 941b4490f42SVladimir Kondratiev struct wil_tid_ampdu_rx *r = p->tid_rx[tid]; 942b4490f42SVladimir Kondratiev if (r) { 943b4490f42SVladimir Kondratiev seq_printf(s, "[%2d] ", tid); 944b4490f42SVladimir Kondratiev wil_print_rxtid(s, r); 945b4490f42SVladimir Kondratiev } 946b4490f42SVladimir Kondratiev } 947b4490f42SVladimir Kondratiev } 9483df2cd36SVladimir Kondratiev } 9493df2cd36SVladimir Kondratiev 9503df2cd36SVladimir Kondratiev return 0; 9513df2cd36SVladimir Kondratiev } 9523df2cd36SVladimir Kondratiev 9533df2cd36SVladimir Kondratiev static int wil_sta_seq_open(struct inode *inode, struct file *file) 9543df2cd36SVladimir Kondratiev { 9553df2cd36SVladimir Kondratiev return single_open(file, wil_sta_debugfs_show, inode->i_private); 9563df2cd36SVladimir Kondratiev } 9573df2cd36SVladimir Kondratiev 9583df2cd36SVladimir Kondratiev static const struct file_operations fops_sta = { 9593df2cd36SVladimir Kondratiev .open = wil_sta_seq_open, 9603df2cd36SVladimir Kondratiev .release = single_release, 9613df2cd36SVladimir Kondratiev .read = seq_read, 9623df2cd36SVladimir Kondratiev .llseek = seq_lseek, 9633df2cd36SVladimir Kondratiev }; 9643df2cd36SVladimir Kondratiev 9652be7d22fSVladimir Kondratiev /*----------------*/ 9662be7d22fSVladimir Kondratiev int wil6210_debugfs_init(struct wil6210_priv *wil) 9672be7d22fSVladimir Kondratiev { 9682be7d22fSVladimir Kondratiev struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME, 9692be7d22fSVladimir Kondratiev wil_to_wiphy(wil)->debugfsdir); 9702be7d22fSVladimir Kondratiev 9712be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(dbg)) 9722be7d22fSVladimir Kondratiev return -ENODEV; 9732be7d22fSVladimir Kondratiev 9742be7d22fSVladimir Kondratiev debugfs_create_file("mbox", S_IRUGO, dbg, wil, &fops_mbox); 9752be7d22fSVladimir Kondratiev debugfs_create_file("vrings", S_IRUGO, dbg, wil, &fops_vring); 9763df2cd36SVladimir Kondratiev debugfs_create_file("stations", S_IRUGO, dbg, wil, &fops_sta); 9773a85543eSVladimir Kondratiev debugfs_create_file("desc", S_IRUGO, dbg, wil, &fops_txdesc); 9783a85543eSVladimir Kondratiev debugfs_create_u32("desc_index", S_IRUGO | S_IWUSR, dbg, 9792be7d22fSVladimir Kondratiev &dbg_txdesc_index); 9803a85543eSVladimir Kondratiev debugfs_create_u32("vring_index", S_IRUGO | S_IWUSR, dbg, 9813a85543eSVladimir Kondratiev &dbg_vring_index); 9823a85543eSVladimir Kondratiev 9832be7d22fSVladimir Kondratiev debugfs_create_file("bf", S_IRUGO, dbg, wil, &fops_bf); 9842be7d22fSVladimir Kondratiev debugfs_create_file("ssid", S_IRUGO | S_IWUSR, dbg, wil, &fops_ssid); 9852be7d22fSVladimir Kondratiev debugfs_create_u32("secure_pcp", S_IRUGO | S_IWUSR, dbg, 9862be7d22fSVladimir Kondratiev &wil->secure_pcp); 9873de6cf20SVladimir Kondratiev wil_debugfs_create_ulong("status", S_IRUGO | S_IWUSR, dbg, 9883de6cf20SVladimir Kondratiev &wil->status); 989*6f55007dSVladimir Kondratiev debugfs_create_u32("fw_version", S_IRUGO, dbg, &wil->fw_version); 990*6f55007dSVladimir Kondratiev debugfs_create_x32("hw_version", S_IRUGO, dbg, &wil->hw_version); 9912be7d22fSVladimir Kondratiev 9922be7d22fSVladimir Kondratiev wil6210_debugfs_create_ISR(wil, "USER_ICR", dbg, 9932be7d22fSVladimir Kondratiev HOSTADDR(RGF_USER_USER_ICR)); 9942be7d22fSVladimir Kondratiev wil6210_debugfs_create_ISR(wil, "DMA_EP_TX_ICR", dbg, 9952be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_EP_TX_ICR)); 9962be7d22fSVladimir Kondratiev wil6210_debugfs_create_ISR(wil, "DMA_EP_RX_ICR", dbg, 9972be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_EP_RX_ICR)); 9982be7d22fSVladimir Kondratiev wil6210_debugfs_create_ISR(wil, "DMA_EP_MISC_ICR", dbg, 9992be7d22fSVladimir Kondratiev HOSTADDR(RGF_DMA_EP_MISC_ICR)); 10002be7d22fSVladimir Kondratiev wil6210_debugfs_create_pseudo_ISR(wil, dbg); 10012be7d22fSVladimir Kondratiev wil6210_debugfs_create_ITR_CNT(wil, dbg); 10022be7d22fSVladimir Kondratiev 10032be7d22fSVladimir Kondratiev debugfs_create_u32("mem_addr", S_IRUGO | S_IWUSR, dbg, &mem_addr); 10042be7d22fSVladimir Kondratiev debugfs_create_file("mem_val", S_IRUGO, dbg, wil, &fops_memread); 10052be7d22fSVladimir Kondratiev 10062be7d22fSVladimir Kondratiev debugfs_create_file("reset", S_IWUSR, dbg, wil, &fops_reset); 10070b39aaf2SVladimir Kondratiev debugfs_create_file("rxon", S_IWUSR, dbg, wil, &fops_rxon); 10080b39aaf2SVladimir Kondratiev debugfs_create_file("tx_mgmt", S_IWUSR, dbg, wil, &fops_txmgmt); 1009ff974e40SVladimir Kondratiev debugfs_create_file("wmi_send", S_IWUSR, dbg, wil, &fops_wmi); 10101a2780e0SVladimir Kondratiev debugfs_create_file("temp", S_IRUGO, dbg, wil, &fops_temp); 10119eb82d43SVladimir Kondratiev debugfs_create_file("freq", S_IRUGO, dbg, wil, &fops_freq); 10129eb82d43SVladimir Kondratiev debugfs_create_file("link", S_IRUGO, dbg, wil, &fops_link); 101384bb29b7SVladimir Kondratiev debugfs_create_file("info", S_IRUGO, dbg, wil, &fops_info); 10142be7d22fSVladimir Kondratiev 10152be7d22fSVladimir Kondratiev wil->rgf_blob.data = (void * __force)wil->csr + 0; 10162be7d22fSVladimir Kondratiev wil->rgf_blob.size = 0xa000; 10172be7d22fSVladimir Kondratiev wil_debugfs_create_ioblob("blob_rgf", S_IRUGO, dbg, &wil->rgf_blob); 10182be7d22fSVladimir Kondratiev 10192be7d22fSVladimir Kondratiev wil->fw_code_blob.data = (void * __force)wil->csr + 0x40000; 10202be7d22fSVladimir Kondratiev wil->fw_code_blob.size = 0x40000; 10212be7d22fSVladimir Kondratiev wil_debugfs_create_ioblob("blob_fw_code", S_IRUGO, dbg, 10222be7d22fSVladimir Kondratiev &wil->fw_code_blob); 10232be7d22fSVladimir Kondratiev 10242be7d22fSVladimir Kondratiev wil->fw_data_blob.data = (void * __force)wil->csr + 0x80000; 10252be7d22fSVladimir Kondratiev wil->fw_data_blob.size = 0x8000; 10262be7d22fSVladimir Kondratiev wil_debugfs_create_ioblob("blob_fw_data", S_IRUGO, dbg, 10272be7d22fSVladimir Kondratiev &wil->fw_data_blob); 10282be7d22fSVladimir Kondratiev 10292be7d22fSVladimir Kondratiev wil->fw_peri_blob.data = (void * __force)wil->csr + 0x88000; 10302be7d22fSVladimir Kondratiev wil->fw_peri_blob.size = 0x18000; 10312be7d22fSVladimir Kondratiev wil_debugfs_create_ioblob("blob_fw_peri", S_IRUGO, dbg, 10322be7d22fSVladimir Kondratiev &wil->fw_peri_blob); 10332be7d22fSVladimir Kondratiev 10342be7d22fSVladimir Kondratiev wil->uc_code_blob.data = (void * __force)wil->csr + 0xa0000; 10352be7d22fSVladimir Kondratiev wil->uc_code_blob.size = 0x10000; 10362be7d22fSVladimir Kondratiev wil_debugfs_create_ioblob("blob_uc_code", S_IRUGO, dbg, 10372be7d22fSVladimir Kondratiev &wil->uc_code_blob); 10382be7d22fSVladimir Kondratiev 10392be7d22fSVladimir Kondratiev wil->uc_data_blob.data = (void * __force)wil->csr + 0xb0000; 10402be7d22fSVladimir Kondratiev wil->uc_data_blob.size = 0x4000; 10412be7d22fSVladimir Kondratiev wil_debugfs_create_ioblob("blob_uc_data", S_IRUGO, dbg, 10422be7d22fSVladimir Kondratiev &wil->uc_data_blob); 10432be7d22fSVladimir Kondratiev 10442be7d22fSVladimir Kondratiev return 0; 10452be7d22fSVladimir Kondratiev } 10462be7d22fSVladimir Kondratiev 10472be7d22fSVladimir Kondratiev void wil6210_debugfs_remove(struct wil6210_priv *wil) 10482be7d22fSVladimir Kondratiev { 10492be7d22fSVladimir Kondratiev debugfs_remove_recursive(wil->debug); 10502be7d22fSVladimir Kondratiev wil->debug = NULL; 10512be7d22fSVladimir Kondratiev } 1052