12be7d22fSVladimir Kondratiev /* 2a351f2f5SLazar Alexei * Copyright (c) 2012-2017 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" 2536345ac3SVladimir Kondratiev #include "wmi.h" 262be7d22fSVladimir Kondratiev #include "txrx.h" 27dc16427bSVladimir Kondratiev #include "pmc.h" 282be7d22fSVladimir Kondratiev 292be7d22fSVladimir Kondratiev /* Nasty hack. Better have per device instances */ 302be7d22fSVladimir Kondratiev static u32 mem_addr; 312be7d22fSVladimir Kondratiev static u32 dbg_txdesc_index; 32af31cb5aSVladimir Kondratiev static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */ 330436fd9aSVladimir Shulman u32 vring_idle_trsh = 16; /* HW fetches up to 16 descriptors at once */ 342be7d22fSVladimir Kondratiev 35b7cde470SVladimir Kondratiev enum dbg_off_type { 36b7cde470SVladimir Kondratiev doff_u32 = 0, 37b7cde470SVladimir Kondratiev doff_x32 = 1, 38b7cde470SVladimir Kondratiev doff_ulong = 2, 39b7cde470SVladimir Kondratiev doff_io32 = 3, 4074997a53SLior David doff_u8 = 4 41b7cde470SVladimir Kondratiev }; 42b7cde470SVladimir Kondratiev 43b7cde470SVladimir Kondratiev /* offset to "wil" */ 44b7cde470SVladimir Kondratiev struct dbg_off { 45b7cde470SVladimir Kondratiev const char *name; 46b7cde470SVladimir Kondratiev umode_t mode; 47b7cde470SVladimir Kondratiev ulong off; 48b7cde470SVladimir Kondratiev enum dbg_off_type type; 49b7cde470SVladimir Kondratiev }; 50b7cde470SVladimir Kondratiev 512be7d22fSVladimir Kondratiev static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil, 5259f7c0a9SVladimir Kondratiev const char *name, struct vring *vring, 5359f7c0a9SVladimir Kondratiev char _s, char _h) 542be7d22fSVladimir Kondratiev { 552be7d22fSVladimir Kondratiev void __iomem *x = wmi_addr(wil, vring->hwtail); 56995cdd0eSVladimir Kondratiev u32 v; 572be7d22fSVladimir Kondratiev 582be7d22fSVladimir Kondratiev seq_printf(s, "VRING %s = {\n", name); 5939c52ee8SVladimir Kondratiev seq_printf(s, " pa = %pad\n", &vring->pa); 602be7d22fSVladimir Kondratiev seq_printf(s, " va = 0x%p\n", vring->va); 612be7d22fSVladimir Kondratiev seq_printf(s, " size = %d\n", vring->size); 622be7d22fSVladimir Kondratiev seq_printf(s, " swtail = %d\n", vring->swtail); 632be7d22fSVladimir Kondratiev seq_printf(s, " swhead = %d\n", vring->swhead); 642be7d22fSVladimir Kondratiev seq_printf(s, " hwtail = [0x%08x] -> ", vring->hwtail); 65995cdd0eSVladimir Kondratiev if (x) { 66b9eeb512SVladimir Kondratiev v = readl(x); 67995cdd0eSVladimir Kondratiev seq_printf(s, "0x%08x = %d\n", v, v); 68995cdd0eSVladimir Kondratiev } else { 698fe59627SVladimir Kondratiev seq_puts(s, "???\n"); 70995cdd0eSVladimir Kondratiev } 712be7d22fSVladimir Kondratiev 72ee5dfe0dSHamad Kadmany if (vring->va && (vring->size <= (1 << WIL_RING_SIZE_ORDER_MAX))) { 732be7d22fSVladimir Kondratiev uint i; 748fe59627SVladimir Kondratiev 752be7d22fSVladimir Kondratiev for (i = 0; i < vring->size; i++) { 762be7d22fSVladimir Kondratiev volatile struct vring_tx_desc *d = &vring->va[i].tx; 778fe59627SVladimir Kondratiev 78ee5dfe0dSHamad Kadmany if ((i % 128) == 0 && (i != 0)) 798fe59627SVladimir Kondratiev seq_puts(s, "\n"); 8059f7c0a9SVladimir Kondratiev seq_printf(s, "%c", (d->dma.status & BIT(0)) ? 8159f7c0a9SVladimir Kondratiev _s : (vring->ctx[i].skb ? _h : 'h')); 822be7d22fSVladimir Kondratiev } 838fe59627SVladimir Kondratiev seq_puts(s, "\n"); 842be7d22fSVladimir Kondratiev } 858fe59627SVladimir Kondratiev seq_puts(s, "}\n"); 862be7d22fSVladimir Kondratiev } 872be7d22fSVladimir Kondratiev 882be7d22fSVladimir Kondratiev static int wil_vring_debugfs_show(struct seq_file *s, void *data) 892be7d22fSVladimir Kondratiev { 902be7d22fSVladimir Kondratiev uint i; 912be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 922be7d22fSVladimir Kondratiev 9359f7c0a9SVladimir Kondratiev wil_print_vring(s, wil, "rx", &wil->vring_rx, 'S', '_'); 942be7d22fSVladimir Kondratiev 952be7d22fSVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) { 968fe59627SVladimir Kondratiev struct vring *vring = &wil->vring_tx[i]; 977c0acf86SVladimir Kondratiev struct vring_tx_data *txdata = &wil->vring_tx_data[i]; 987c0acf86SVladimir Kondratiev 992be7d22fSVladimir Kondratiev if (vring->va) { 1003df2cd36SVladimir Kondratiev int cid = wil->vring2cid_tid[i][0]; 1013df2cd36SVladimir Kondratiev int tid = wil->vring2cid_tid[i][1]; 10267c3e1b4SVladimir Kondratiev u32 swhead = vring->swhead; 10367c3e1b4SVladimir Kondratiev u32 swtail = vring->swtail; 10467c3e1b4SVladimir Kondratiev int used = (vring->size + swhead - swtail) 10567c3e1b4SVladimir Kondratiev % vring->size; 10667c3e1b4SVladimir Kondratiev int avail = vring->size - used - 1; 1072be7d22fSVladimir Kondratiev char name[10]; 1088f55cbecSBoris Sorochkin char sidle[10]; 1097c0acf86SVladimir Kondratiev /* performance monitoring */ 1107c0acf86SVladimir Kondratiev cycles_t now = get_cycles(); 111c20e7789SChen Gang uint64_t idle = txdata->idle * 100; 112c20e7789SChen Gang uint64_t total = now - txdata->begin; 1137c0acf86SVladimir Kondratiev 1148f55cbecSBoris Sorochkin if (total != 0) { 115e48b1790SVladimir Kondratiev do_div(idle, total); 1168f55cbecSBoris Sorochkin snprintf(sidle, sizeof(sidle), "%3d%%", 1178f55cbecSBoris Sorochkin (int)idle); 1188f55cbecSBoris Sorochkin } else { 1198f55cbecSBoris Sorochkin snprintf(sidle, sizeof(sidle), "N/A"); 1208f55cbecSBoris Sorochkin } 1217c0acf86SVladimir Kondratiev txdata->begin = now; 1227c0acf86SVladimir Kondratiev txdata->idle = 0ULL; 1237c0acf86SVladimir Kondratiev 1242be7d22fSVladimir Kondratiev snprintf(name, sizeof(name), "tx_%2d", i); 1253df2cd36SVladimir Kondratiev 12641d6b093SVladimir Kondratiev if (cid < WIL6210_MAX_CID) 1273277213fSVladimir Kondratiev seq_printf(s, 128230d8442SVladimir Kondratiev "\n%pM CID %d TID %d 1x%s BACK([%u] %u TU A%s) [%3d|%3d] idle %s\n", 1293277213fSVladimir Kondratiev wil->sta[cid].addr, cid, tid, 130230d8442SVladimir Kondratiev txdata->dot1x_open ? "+" : "-", 13141d6b093SVladimir Kondratiev txdata->agg_wsize, 13241d6b093SVladimir Kondratiev txdata->agg_timeout, 133cbcf5866SVladimir Kondratiev txdata->agg_amsdu ? "+" : "-", 1348f55cbecSBoris Sorochkin used, avail, sidle); 13541d6b093SVladimir Kondratiev else 13641d6b093SVladimir Kondratiev seq_printf(s, 137230d8442SVladimir Kondratiev "\nBroadcast 1x%s [%3d|%3d] idle %s\n", 138230d8442SVladimir Kondratiev txdata->dot1x_open ? "+" : "-", 13941d6b093SVladimir Kondratiev used, avail, sidle); 1407c0acf86SVladimir Kondratiev 14159f7c0a9SVladimir Kondratiev wil_print_vring(s, wil, name, vring, '_', 'H'); 1422be7d22fSVladimir Kondratiev } 1432be7d22fSVladimir Kondratiev } 1442be7d22fSVladimir Kondratiev 1452be7d22fSVladimir Kondratiev return 0; 1462be7d22fSVladimir Kondratiev } 1472be7d22fSVladimir Kondratiev 1482be7d22fSVladimir Kondratiev static int wil_vring_seq_open(struct inode *inode, struct file *file) 1492be7d22fSVladimir Kondratiev { 1502be7d22fSVladimir Kondratiev return single_open(file, wil_vring_debugfs_show, inode->i_private); 1512be7d22fSVladimir Kondratiev } 1522be7d22fSVladimir Kondratiev 1532be7d22fSVladimir Kondratiev static const struct file_operations fops_vring = { 1542be7d22fSVladimir Kondratiev .open = wil_vring_seq_open, 1552be7d22fSVladimir Kondratiev .release = single_release, 1562be7d22fSVladimir Kondratiev .read = seq_read, 1572be7d22fSVladimir Kondratiev .llseek = seq_lseek, 1582be7d22fSVladimir Kondratiev }; 1592be7d22fSVladimir Kondratiev 160a202fbbfSAndy Shevchenko static void wil_seq_hexdump(struct seq_file *s, void *p, int len, 161a202fbbfSAndy Shevchenko const char *prefix) 162a202fbbfSAndy Shevchenko { 163a202fbbfSAndy Shevchenko seq_hex_dump(s, prefix, DUMP_PREFIX_NONE, 16, 1, p, len, false); 164a202fbbfSAndy Shevchenko } 165a202fbbfSAndy Shevchenko 1662be7d22fSVladimir Kondratiev static void wil_print_ring(struct seq_file *s, const char *prefix, 1672be7d22fSVladimir Kondratiev void __iomem *off) 1682be7d22fSVladimir Kondratiev { 1692be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 1702be7d22fSVladimir Kondratiev struct wil6210_mbox_ring r; 1712be7d22fSVladimir Kondratiev int rsize; 1722be7d22fSVladimir Kondratiev uint i; 1732be7d22fSVladimir Kondratiev 174349214c1SMaya Erez wil_halp_vote(wil); 175349214c1SMaya Erez 1762be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(&r, off, sizeof(r)); 1772be7d22fSVladimir Kondratiev wil_mbox_ring_le2cpus(&r); 1782be7d22fSVladimir Kondratiev /* 1792be7d22fSVladimir Kondratiev * we just read memory block from NIC. This memory may be 1802be7d22fSVladimir Kondratiev * garbage. Check validity before using it. 1812be7d22fSVladimir Kondratiev */ 1822be7d22fSVladimir Kondratiev rsize = r.size / sizeof(struct wil6210_mbox_ring_desc); 1832be7d22fSVladimir Kondratiev 1842be7d22fSVladimir Kondratiev seq_printf(s, "ring %s = {\n", prefix); 1852be7d22fSVladimir Kondratiev seq_printf(s, " base = 0x%08x\n", r.base); 1862be7d22fSVladimir Kondratiev seq_printf(s, " size = 0x%04x bytes -> %d entries\n", r.size, rsize); 1872be7d22fSVladimir Kondratiev seq_printf(s, " tail = 0x%08x\n", r.tail); 1882be7d22fSVladimir Kondratiev seq_printf(s, " head = 0x%08x\n", r.head); 1892be7d22fSVladimir Kondratiev seq_printf(s, " entry size = %d\n", r.entry_size); 1902be7d22fSVladimir Kondratiev 1912be7d22fSVladimir Kondratiev if (r.size % sizeof(struct wil6210_mbox_ring_desc)) { 1922be7d22fSVladimir Kondratiev seq_printf(s, " ??? size is not multiple of %zd, garbage?\n", 1932be7d22fSVladimir Kondratiev sizeof(struct wil6210_mbox_ring_desc)); 1942be7d22fSVladimir Kondratiev goto out; 1952be7d22fSVladimir Kondratiev } 1962be7d22fSVladimir Kondratiev 1972be7d22fSVladimir Kondratiev if (!wmi_addr(wil, r.base) || 1982be7d22fSVladimir Kondratiev !wmi_addr(wil, r.tail) || 1992be7d22fSVladimir Kondratiev !wmi_addr(wil, r.head)) { 2008fe59627SVladimir Kondratiev seq_puts(s, " ??? pointers are garbage?\n"); 2012be7d22fSVladimir Kondratiev goto out; 2022be7d22fSVladimir Kondratiev } 2032be7d22fSVladimir Kondratiev 2042be7d22fSVladimir Kondratiev for (i = 0; i < rsize; i++) { 2052be7d22fSVladimir Kondratiev struct wil6210_mbox_ring_desc d; 2062be7d22fSVladimir Kondratiev struct wil6210_mbox_hdr hdr; 2072be7d22fSVladimir Kondratiev size_t delta = i * sizeof(d); 2082be7d22fSVladimir Kondratiev void __iomem *x = wil->csr + HOSTADDR(r.base) + delta; 2092be7d22fSVladimir Kondratiev 2102be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(&d, x, sizeof(d)); 2112be7d22fSVladimir Kondratiev 2122be7d22fSVladimir Kondratiev seq_printf(s, " [%2x] %s %s%s 0x%08x", i, 2132be7d22fSVladimir Kondratiev d.sync ? "F" : "E", 2142be7d22fSVladimir Kondratiev (r.tail - r.base == delta) ? "t" : " ", 2152be7d22fSVladimir Kondratiev (r.head - r.base == delta) ? "h" : " ", 2162be7d22fSVladimir Kondratiev le32_to_cpu(d.addr)); 2172be7d22fSVladimir Kondratiev if (0 == wmi_read_hdr(wil, d.addr, &hdr)) { 2182be7d22fSVladimir Kondratiev u16 len = le16_to_cpu(hdr.len); 2198fe59627SVladimir Kondratiev 2202be7d22fSVladimir Kondratiev seq_printf(s, " -> %04x %04x %04x %02x\n", 2212be7d22fSVladimir Kondratiev le16_to_cpu(hdr.seq), len, 2222be7d22fSVladimir Kondratiev le16_to_cpu(hdr.type), hdr.flags); 2232be7d22fSVladimir Kondratiev if (len <= MAX_MBOXITEM_SIZE) { 2242be7d22fSVladimir Kondratiev unsigned char databuf[MAX_MBOXITEM_SIZE]; 2252be7d22fSVladimir Kondratiev void __iomem *src = wmi_buffer(wil, d.addr) + 2262be7d22fSVladimir Kondratiev sizeof(struct wil6210_mbox_hdr); 2272be7d22fSVladimir Kondratiev /* 2282be7d22fSVladimir Kondratiev * No need to check @src for validity - 2292be7d22fSVladimir Kondratiev * we already validated @d.addr while 2302be7d22fSVladimir Kondratiev * reading header 2312be7d22fSVladimir Kondratiev */ 2322be7d22fSVladimir Kondratiev wil_memcpy_fromio_32(databuf, src, len); 233a202fbbfSAndy Shevchenko wil_seq_hexdump(s, databuf, len, " : "); 2342be7d22fSVladimir Kondratiev } 2352be7d22fSVladimir Kondratiev } else { 2368fe59627SVladimir Kondratiev seq_puts(s, "\n"); 2372be7d22fSVladimir Kondratiev } 2382be7d22fSVladimir Kondratiev } 2392be7d22fSVladimir Kondratiev out: 2408fe59627SVladimir Kondratiev seq_puts(s, "}\n"); 241349214c1SMaya Erez wil_halp_unvote(wil); 2422be7d22fSVladimir Kondratiev } 2432be7d22fSVladimir Kondratiev 2442be7d22fSVladimir Kondratiev static int wil_mbox_debugfs_show(struct seq_file *s, void *data) 2452be7d22fSVladimir Kondratiev { 2462be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 2472be7d22fSVladimir Kondratiev 2482be7d22fSVladimir Kondratiev wil_print_ring(s, "tx", wil->csr + HOST_MBOX + 2492be7d22fSVladimir Kondratiev offsetof(struct wil6210_mbox_ctl, tx)); 2502be7d22fSVladimir Kondratiev wil_print_ring(s, "rx", wil->csr + HOST_MBOX + 2512be7d22fSVladimir Kondratiev offsetof(struct wil6210_mbox_ctl, rx)); 2522be7d22fSVladimir Kondratiev 2532be7d22fSVladimir Kondratiev return 0; 2542be7d22fSVladimir Kondratiev } 2552be7d22fSVladimir Kondratiev 2562be7d22fSVladimir Kondratiev static int wil_mbox_seq_open(struct inode *inode, struct file *file) 2572be7d22fSVladimir Kondratiev { 2582be7d22fSVladimir Kondratiev return single_open(file, wil_mbox_debugfs_show, inode->i_private); 2592be7d22fSVladimir Kondratiev } 2602be7d22fSVladimir Kondratiev 2612be7d22fSVladimir Kondratiev static const struct file_operations fops_mbox = { 2622be7d22fSVladimir Kondratiev .open = wil_mbox_seq_open, 2632be7d22fSVladimir Kondratiev .release = single_release, 2642be7d22fSVladimir Kondratiev .read = seq_read, 2652be7d22fSVladimir Kondratiev .llseek = seq_lseek, 2662be7d22fSVladimir Kondratiev }; 2672be7d22fSVladimir Kondratiev 2682be7d22fSVladimir Kondratiev static int wil_debugfs_iomem_x32_set(void *data, u64 val) 2692be7d22fSVladimir Kondratiev { 270b9eeb512SVladimir Kondratiev writel(val, (void __iomem *)data); 2712be7d22fSVladimir Kondratiev wmb(); /* make sure write propagated to HW */ 2722be7d22fSVladimir Kondratiev 2732be7d22fSVladimir Kondratiev return 0; 2742be7d22fSVladimir Kondratiev } 2752be7d22fSVladimir Kondratiev 2762be7d22fSVladimir Kondratiev static int wil_debugfs_iomem_x32_get(void *data, u64 *val) 2772be7d22fSVladimir Kondratiev { 278b9eeb512SVladimir Kondratiev *val = readl((void __iomem *)data); 2792be7d22fSVladimir Kondratiev 2802be7d22fSVladimir Kondratiev return 0; 2812be7d22fSVladimir Kondratiev } 2822be7d22fSVladimir Kondratiev 2832be7d22fSVladimir Kondratiev DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get, 2842be7d22fSVladimir Kondratiev wil_debugfs_iomem_x32_set, "0x%08llx\n"); 2852be7d22fSVladimir Kondratiev 2862be7d22fSVladimir Kondratiev static struct dentry *wil_debugfs_create_iomem_x32(const char *name, 2870ecc833bSAl Viro umode_t mode, 2882be7d22fSVladimir Kondratiev struct dentry *parent, 289b7cde470SVladimir Kondratiev void *value) 2902be7d22fSVladimir Kondratiev { 291b7cde470SVladimir Kondratiev return debugfs_create_file(name, mode, parent, value, 2922be7d22fSVladimir Kondratiev &fops_iomem_x32); 2932be7d22fSVladimir Kondratiev } 2942be7d22fSVladimir Kondratiev 2953de6cf20SVladimir Kondratiev static int wil_debugfs_ulong_set(void *data, u64 val) 2963de6cf20SVladimir Kondratiev { 2973de6cf20SVladimir Kondratiev *(ulong *)data = val; 2983de6cf20SVladimir Kondratiev return 0; 2993de6cf20SVladimir Kondratiev } 3008fe59627SVladimir Kondratiev 3013de6cf20SVladimir Kondratiev static int wil_debugfs_ulong_get(void *data, u64 *val) 3023de6cf20SVladimir Kondratiev { 3033de6cf20SVladimir Kondratiev *val = *(ulong *)data; 3043de6cf20SVladimir Kondratiev return 0; 3053de6cf20SVladimir Kondratiev } 3068fe59627SVladimir Kondratiev 3073de6cf20SVladimir Kondratiev DEFINE_SIMPLE_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get, 3088ea06188SVladimir Kondratiev wil_debugfs_ulong_set, "0x%llx\n"); 3093de6cf20SVladimir Kondratiev 3103de6cf20SVladimir Kondratiev static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode, 3113de6cf20SVladimir Kondratiev struct dentry *parent, 3123de6cf20SVladimir Kondratiev ulong *value) 3133de6cf20SVladimir Kondratiev { 3143de6cf20SVladimir Kondratiev return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong); 3153de6cf20SVladimir Kondratiev } 3163de6cf20SVladimir Kondratiev 317b7cde470SVladimir Kondratiev /** 318b7cde470SVladimir Kondratiev * wil6210_debugfs_init_offset - create set of debugfs files 319b7cde470SVladimir Kondratiev * @wil - driver's context, used for printing 320b7cde470SVladimir Kondratiev * @dbg - directory on the debugfs, where files will be created 321b7cde470SVladimir Kondratiev * @base - base address used in address calculation 322b7cde470SVladimir Kondratiev * @tbl - table with file descriptions. Should be terminated with empty element. 323b7cde470SVladimir Kondratiev * 324b7cde470SVladimir Kondratiev * Creates files accordingly to the @tbl. 325b7cde470SVladimir Kondratiev */ 326b7cde470SVladimir Kondratiev static void wil6210_debugfs_init_offset(struct wil6210_priv *wil, 327b7cde470SVladimir Kondratiev struct dentry *dbg, void *base, 328b7cde470SVladimir Kondratiev const struct dbg_off * const tbl) 329b7cde470SVladimir Kondratiev { 330b7cde470SVladimir Kondratiev int i; 331b7cde470SVladimir Kondratiev 332b7cde470SVladimir Kondratiev for (i = 0; tbl[i].name; i++) { 333867fa0d4SVladimir Kondratiev struct dentry *f; 334b7cde470SVladimir Kondratiev 335b7cde470SVladimir Kondratiev switch (tbl[i].type) { 336b7cde470SVladimir Kondratiev case doff_u32: 337b7cde470SVladimir Kondratiev f = debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg, 338b7cde470SVladimir Kondratiev base + tbl[i].off); 339b7cde470SVladimir Kondratiev break; 340b7cde470SVladimir Kondratiev case doff_x32: 341b7cde470SVladimir Kondratiev f = debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg, 342b7cde470SVladimir Kondratiev base + tbl[i].off); 343b7cde470SVladimir Kondratiev break; 344b7cde470SVladimir Kondratiev case doff_ulong: 345b7cde470SVladimir Kondratiev f = wil_debugfs_create_ulong(tbl[i].name, tbl[i].mode, 346b7cde470SVladimir Kondratiev dbg, base + tbl[i].off); 347b7cde470SVladimir Kondratiev break; 348b7cde470SVladimir Kondratiev case doff_io32: 349b7cde470SVladimir Kondratiev f = wil_debugfs_create_iomem_x32(tbl[i].name, 350b7cde470SVladimir Kondratiev tbl[i].mode, dbg, 351b7cde470SVladimir Kondratiev base + tbl[i].off); 352b7cde470SVladimir Kondratiev break; 35374997a53SLior David case doff_u8: 35474997a53SLior David f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg, 35574997a53SLior David base + tbl[i].off); 35674997a53SLior David break; 357867fa0d4SVladimir Kondratiev default: 358867fa0d4SVladimir Kondratiev f = ERR_PTR(-EINVAL); 359b7cde470SVladimir Kondratiev } 360b7cde470SVladimir Kondratiev if (IS_ERR_OR_NULL(f)) 361b7cde470SVladimir Kondratiev wil_err(wil, "Create file \"%s\": err %ld\n", 362b7cde470SVladimir Kondratiev tbl[i].name, PTR_ERR(f)); 363b7cde470SVladimir Kondratiev } 364b7cde470SVladimir Kondratiev } 365b7cde470SVladimir Kondratiev 366b7cde470SVladimir Kondratiev static const struct dbg_off isr_off[] = { 36778484c44SMaya Erez {"ICC", 0644, offsetof(struct RGF_ICR, ICC), doff_io32}, 36878484c44SMaya Erez {"ICR", 0644, offsetof(struct RGF_ICR, ICR), doff_io32}, 36978484c44SMaya Erez {"ICM", 0644, offsetof(struct RGF_ICR, ICM), doff_io32}, 37078484c44SMaya Erez {"ICS", 0244, offsetof(struct RGF_ICR, ICS), doff_io32}, 37178484c44SMaya Erez {"IMV", 0644, offsetof(struct RGF_ICR, IMV), doff_io32}, 37278484c44SMaya Erez {"IMS", 0244, offsetof(struct RGF_ICR, IMS), doff_io32}, 37378484c44SMaya Erez {"IMC", 0244, offsetof(struct RGF_ICR, IMC), doff_io32}, 374b7cde470SVladimir Kondratiev {}, 375b7cde470SVladimir Kondratiev }; 3768fe59627SVladimir Kondratiev 3772be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil, 3782be7d22fSVladimir Kondratiev const char *name, 3792be7d22fSVladimir Kondratiev struct dentry *parent, u32 off) 3802be7d22fSVladimir Kondratiev { 3812be7d22fSVladimir Kondratiev struct dentry *d = debugfs_create_dir(name, parent); 3822be7d22fSVladimir Kondratiev 3832be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(d)) 3842be7d22fSVladimir Kondratiev return -ENODEV; 3852be7d22fSVladimir Kondratiev 386b7cde470SVladimir Kondratiev wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr + off, 387b7cde470SVladimir Kondratiev isr_off); 3882be7d22fSVladimir Kondratiev 3892be7d22fSVladimir Kondratiev return 0; 3902be7d22fSVladimir Kondratiev } 3912be7d22fSVladimir Kondratiev 392b7cde470SVladimir Kondratiev static const struct dbg_off pseudo_isr_off[] = { 39378484c44SMaya Erez {"CAUSE", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32}, 39478484c44SMaya Erez {"MASK_SW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32}, 39578484c44SMaya Erez {"MASK_FW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32}, 396b7cde470SVladimir Kondratiev {}, 397b7cde470SVladimir Kondratiev }; 398b7cde470SVladimir Kondratiev 3992be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil, 4002be7d22fSVladimir Kondratiev struct dentry *parent) 4012be7d22fSVladimir Kondratiev { 4022be7d22fSVladimir Kondratiev struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent); 4032be7d22fSVladimir Kondratiev 4042be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(d)) 4052be7d22fSVladimir Kondratiev return -ENODEV; 4062be7d22fSVladimir Kondratiev 407b7cde470SVladimir Kondratiev wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr, 408b7cde470SVladimir Kondratiev pseudo_isr_off); 4092be7d22fSVladimir Kondratiev 4102be7d22fSVladimir Kondratiev return 0; 4112be7d22fSVladimir Kondratiev } 4122be7d22fSVladimir Kondratiev 41378366f69SVladimir Kondratiev static const struct dbg_off lgc_itr_cnt_off[] = { 41478484c44SMaya Erez {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32}, 41578484c44SMaya Erez {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32}, 41678484c44SMaya Erez {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32}, 417b7cde470SVladimir Kondratiev {}, 418b7cde470SVladimir Kondratiev }; 419b7cde470SVladimir Kondratiev 42078366f69SVladimir Kondratiev static const struct dbg_off tx_itr_cnt_off[] = { 42178484c44SMaya Erez {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_TRSH), 42278366f69SVladimir Kondratiev doff_io32}, 42378484c44SMaya Erez {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_DATA), 42478366f69SVladimir Kondratiev doff_io32}, 42578484c44SMaya Erez {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_CTL), 42678366f69SVladimir Kondratiev doff_io32}, 42778484c44SMaya Erez {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_TRSH), 42878366f69SVladimir Kondratiev doff_io32}, 42978484c44SMaya Erez {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_DATA), 43078366f69SVladimir Kondratiev doff_io32}, 43178484c44SMaya Erez {"IDL_CTL", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_CTL), 43278366f69SVladimir Kondratiev doff_io32}, 43378366f69SVladimir Kondratiev {}, 43478366f69SVladimir Kondratiev }; 43578366f69SVladimir Kondratiev 43678366f69SVladimir Kondratiev static const struct dbg_off rx_itr_cnt_off[] = { 43778484c44SMaya Erez {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_TRSH), 43878366f69SVladimir Kondratiev doff_io32}, 43978484c44SMaya Erez {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_DATA), 44078366f69SVladimir Kondratiev doff_io32}, 44178484c44SMaya Erez {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_CTL), 44278366f69SVladimir Kondratiev doff_io32}, 44378484c44SMaya Erez {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_TRSH), 44478366f69SVladimir Kondratiev doff_io32}, 44578484c44SMaya Erez {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_DATA), 44678366f69SVladimir Kondratiev doff_io32}, 44778484c44SMaya Erez {"IDL_CTL", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_CTL), 44878366f69SVladimir Kondratiev doff_io32}, 44978366f69SVladimir Kondratiev {}, 45078366f69SVladimir Kondratiev }; 45178366f69SVladimir Kondratiev 4522be7d22fSVladimir Kondratiev static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil, 4532be7d22fSVladimir Kondratiev struct dentry *parent) 4542be7d22fSVladimir Kondratiev { 45578366f69SVladimir Kondratiev struct dentry *d, *dtx, *drx; 4562be7d22fSVladimir Kondratiev 45778366f69SVladimir Kondratiev d = debugfs_create_dir("ITR_CNT", parent); 4582be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(d)) 4592be7d22fSVladimir Kondratiev return -ENODEV; 4602be7d22fSVladimir Kondratiev 46178366f69SVladimir Kondratiev dtx = debugfs_create_dir("TX", d); 46278366f69SVladimir Kondratiev drx = debugfs_create_dir("RX", d); 46378366f69SVladimir Kondratiev if (IS_ERR_OR_NULL(dtx) || IS_ERR_OR_NULL(drx)) 46478366f69SVladimir Kondratiev return -ENODEV; 4652be7d22fSVladimir Kondratiev 46678366f69SVladimir Kondratiev wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr, 46778366f69SVladimir Kondratiev lgc_itr_cnt_off); 46878366f69SVladimir Kondratiev 46978366f69SVladimir Kondratiev wil6210_debugfs_init_offset(wil, dtx, (void * __force)wil->csr, 47078366f69SVladimir Kondratiev tx_itr_cnt_off); 47178366f69SVladimir Kondratiev 47278366f69SVladimir Kondratiev wil6210_debugfs_init_offset(wil, drx, (void * __force)wil->csr, 47378366f69SVladimir Kondratiev rx_itr_cnt_off); 4742be7d22fSVladimir Kondratiev return 0; 4752be7d22fSVladimir Kondratiev } 4762be7d22fSVladimir Kondratiev 4772be7d22fSVladimir Kondratiev static int wil_memread_debugfs_show(struct seq_file *s, void *data) 4782be7d22fSVladimir Kondratiev { 4792be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 4802be7d22fSVladimir Kondratiev void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr)); 4812be7d22fSVladimir Kondratiev 4822be7d22fSVladimir Kondratiev if (a) 483b9eeb512SVladimir Kondratiev seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, readl(a)); 4842be7d22fSVladimir Kondratiev else 4852be7d22fSVladimir Kondratiev seq_printf(s, "[0x%08x] = INVALID\n", mem_addr); 4862be7d22fSVladimir Kondratiev 4872be7d22fSVladimir Kondratiev return 0; 4882be7d22fSVladimir Kondratiev } 4892be7d22fSVladimir Kondratiev 4902be7d22fSVladimir Kondratiev static int wil_memread_seq_open(struct inode *inode, struct file *file) 4912be7d22fSVladimir Kondratiev { 4922be7d22fSVladimir Kondratiev return single_open(file, wil_memread_debugfs_show, inode->i_private); 4932be7d22fSVladimir Kondratiev } 4942be7d22fSVladimir Kondratiev 4952be7d22fSVladimir Kondratiev static const struct file_operations fops_memread = { 4962be7d22fSVladimir Kondratiev .open = wil_memread_seq_open, 4972be7d22fSVladimir Kondratiev .release = single_release, 4982be7d22fSVladimir Kondratiev .read = seq_read, 4992be7d22fSVladimir Kondratiev .llseek = seq_lseek, 5002be7d22fSVladimir Kondratiev }; 5012be7d22fSVladimir Kondratiev 5022be7d22fSVladimir Kondratiev static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf, 5032be7d22fSVladimir Kondratiev size_t count, loff_t *ppos) 5042be7d22fSVladimir Kondratiev { 5052be7d22fSVladimir Kondratiev enum { max_count = 4096 }; 506349214c1SMaya Erez struct wil_blob_wrapper *wil_blob = file->private_data; 5072be7d22fSVladimir Kondratiev loff_t pos = *ppos; 508349214c1SMaya Erez size_t available = wil_blob->blob.size; 5092be7d22fSVladimir Kondratiev void *buf; 5102be7d22fSVladimir Kondratiev size_t ret; 5112be7d22fSVladimir Kondratiev 5122be7d22fSVladimir Kondratiev if (pos < 0) 5132be7d22fSVladimir Kondratiev return -EINVAL; 5142be7d22fSVladimir Kondratiev 5152be7d22fSVladimir Kondratiev if (pos >= available || !count) 5162be7d22fSVladimir Kondratiev return 0; 5172be7d22fSVladimir Kondratiev 5182be7d22fSVladimir Kondratiev if (count > available - pos) 5192be7d22fSVladimir Kondratiev count = available - pos; 5202be7d22fSVladimir Kondratiev if (count > max_count) 5212be7d22fSVladimir Kondratiev count = max_count; 5222be7d22fSVladimir Kondratiev 5232be7d22fSVladimir Kondratiev buf = kmalloc(count, GFP_KERNEL); 5242be7d22fSVladimir Kondratiev if (!buf) 5252be7d22fSVladimir Kondratiev return -ENOMEM; 5262be7d22fSVladimir Kondratiev 527*bd50e268SMaya Erez wil_memcpy_fromio_32(buf, (const void __iomem *) 528349214c1SMaya Erez wil_blob->blob.data + pos, count); 5292be7d22fSVladimir Kondratiev 5302be7d22fSVladimir Kondratiev ret = copy_to_user(user_buf, buf, count); 5312be7d22fSVladimir Kondratiev kfree(buf); 5322be7d22fSVladimir Kondratiev if (ret == count) 5332be7d22fSVladimir Kondratiev return -EFAULT; 5342be7d22fSVladimir Kondratiev 5352be7d22fSVladimir Kondratiev count -= ret; 5362be7d22fSVladimir Kondratiev *ppos = pos + count; 5372be7d22fSVladimir Kondratiev 5382be7d22fSVladimir Kondratiev return count; 5392be7d22fSVladimir Kondratiev } 5402be7d22fSVladimir Kondratiev 5412be7d22fSVladimir Kondratiev static const struct file_operations fops_ioblob = { 5422be7d22fSVladimir Kondratiev .read = wil_read_file_ioblob, 54393ecbd64SWei Yongjun .open = simple_open, 5442be7d22fSVladimir Kondratiev .llseek = default_llseek, 5452be7d22fSVladimir Kondratiev }; 5462be7d22fSVladimir Kondratiev 5472be7d22fSVladimir Kondratiev static 5482be7d22fSVladimir Kondratiev struct dentry *wil_debugfs_create_ioblob(const char *name, 5490ecc833bSAl Viro umode_t mode, 5502be7d22fSVladimir Kondratiev struct dentry *parent, 551349214c1SMaya Erez struct wil_blob_wrapper *wil_blob) 5522be7d22fSVladimir Kondratiev { 553349214c1SMaya Erez return debugfs_create_file(name, mode, parent, wil_blob, &fops_ioblob); 5542be7d22fSVladimir Kondratiev } 5558fe59627SVladimir Kondratiev 5562be7d22fSVladimir Kondratiev /*---reset---*/ 5572be7d22fSVladimir Kondratiev static ssize_t wil_write_file_reset(struct file *file, const char __user *buf, 5582be7d22fSVladimir Kondratiev size_t len, loff_t *ppos) 5592be7d22fSVladimir Kondratiev { 5602be7d22fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 5612be7d22fSVladimir Kondratiev struct net_device *ndev = wil_to_ndev(wil); 5622be7d22fSVladimir Kondratiev 5632be7d22fSVladimir Kondratiev /** 5642be7d22fSVladimir Kondratiev * BUG: 5652be7d22fSVladimir Kondratiev * this code does NOT sync device state with the rest of system 5662be7d22fSVladimir Kondratiev * use with care, debug only!!! 5672be7d22fSVladimir Kondratiev */ 5682be7d22fSVladimir Kondratiev rtnl_lock(); 5692be7d22fSVladimir Kondratiev dev_close(ndev); 5702be7d22fSVladimir Kondratiev ndev->flags &= ~IFF_UP; 5712be7d22fSVladimir Kondratiev rtnl_unlock(); 5722cd0f021SVladimir Kondratiev wil_reset(wil, true); 5732be7d22fSVladimir Kondratiev 5742be7d22fSVladimir Kondratiev return len; 5752be7d22fSVladimir Kondratiev } 5762be7d22fSVladimir Kondratiev 5772be7d22fSVladimir Kondratiev static const struct file_operations fops_reset = { 5782be7d22fSVladimir Kondratiev .write = wil_write_file_reset, 57993ecbd64SWei Yongjun .open = simple_open, 5802be7d22fSVladimir Kondratiev }; 5818fe59627SVladimir Kondratiev 5820b39aaf2SVladimir Kondratiev /*---write channel 1..4 to rxon for it, 0 to rxoff---*/ 5830b39aaf2SVladimir Kondratiev static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf, 5840b39aaf2SVladimir Kondratiev size_t len, loff_t *ppos) 5850b39aaf2SVladimir Kondratiev { 5860b39aaf2SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 5870b39aaf2SVladimir Kondratiev int rc; 5880b39aaf2SVladimir Kondratiev long channel; 5890b39aaf2SVladimir Kondratiev bool on; 5900b39aaf2SVladimir Kondratiev 59116e5c1fcSAl Viro char *kbuf = memdup_user_nul(buf, len); 5928fe59627SVladimir Kondratiev 59316e5c1fcSAl Viro if (IS_ERR(kbuf)) 59416e5c1fcSAl Viro return PTR_ERR(kbuf); 5950b39aaf2SVladimir Kondratiev rc = kstrtol(kbuf, 0, &channel); 5960b39aaf2SVladimir Kondratiev kfree(kbuf); 5970b39aaf2SVladimir Kondratiev if (rc) 5980b39aaf2SVladimir Kondratiev return rc; 5990b39aaf2SVladimir Kondratiev 6000b39aaf2SVladimir Kondratiev if ((channel < 0) || (channel > 4)) { 6010b39aaf2SVladimir Kondratiev wil_err(wil, "Invalid channel %ld\n", channel); 6020b39aaf2SVladimir Kondratiev return -EINVAL; 6030b39aaf2SVladimir Kondratiev } 6040b39aaf2SVladimir Kondratiev on = !!channel; 6050b39aaf2SVladimir Kondratiev 6060b39aaf2SVladimir Kondratiev if (on) { 6070b39aaf2SVladimir Kondratiev rc = wmi_set_channel(wil, (int)channel); 6080b39aaf2SVladimir Kondratiev if (rc) 6090b39aaf2SVladimir Kondratiev return rc; 6100b39aaf2SVladimir Kondratiev } 6110b39aaf2SVladimir Kondratiev 6120b39aaf2SVladimir Kondratiev rc = wmi_rxon(wil, on); 6130b39aaf2SVladimir Kondratiev if (rc) 6140b39aaf2SVladimir Kondratiev return rc; 6150b39aaf2SVladimir Kondratiev 6160b39aaf2SVladimir Kondratiev return len; 6170b39aaf2SVladimir Kondratiev } 6180b39aaf2SVladimir Kondratiev 6190b39aaf2SVladimir Kondratiev static const struct file_operations fops_rxon = { 6200b39aaf2SVladimir Kondratiev .write = wil_write_file_rxon, 6210b39aaf2SVladimir Kondratiev .open = simple_open, 6220b39aaf2SVladimir Kondratiev }; 6238fe59627SVladimir Kondratiev 62449cb5dfbSVladimir Kondratiev /* block ack control, write: 62549cb5dfbSVladimir Kondratiev * - "add <ringid> <agg_size> <timeout>" to trigger ADDBA 62649cb5dfbSVladimir Kondratiev * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side 62749cb5dfbSVladimir Kondratiev * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side 6283277213fSVladimir Kondratiev */ 62949cb5dfbSVladimir Kondratiev static ssize_t wil_write_back(struct file *file, const char __user *buf, 6303277213fSVladimir Kondratiev size_t len, loff_t *ppos) 6313277213fSVladimir Kondratiev { 6323277213fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 6333277213fSVladimir Kondratiev int rc; 6343277213fSVladimir Kondratiev char *kbuf = kmalloc(len + 1, GFP_KERNEL); 6352a19f776SColin Ian King char cmd[9]; 63649cb5dfbSVladimir Kondratiev int p1, p2, p3; 6373277213fSVladimir Kondratiev 6383277213fSVladimir Kondratiev if (!kbuf) 6393277213fSVladimir Kondratiev return -ENOMEM; 6403277213fSVladimir Kondratiev 6413277213fSVladimir Kondratiev rc = simple_write_to_buffer(kbuf, len, ppos, buf, len); 6423277213fSVladimir Kondratiev if (rc != len) { 6433277213fSVladimir Kondratiev kfree(kbuf); 6443277213fSVladimir Kondratiev return rc >= 0 ? -EIO : rc; 6453277213fSVladimir Kondratiev } 6463277213fSVladimir Kondratiev 6473277213fSVladimir Kondratiev kbuf[len] = '\0'; 64849cb5dfbSVladimir Kondratiev rc = sscanf(kbuf, "%8s %d %d %d", cmd, &p1, &p2, &p3); 6493277213fSVladimir Kondratiev kfree(kbuf); 6503277213fSVladimir Kondratiev 65149cb5dfbSVladimir Kondratiev if (rc < 0) 6523277213fSVladimir Kondratiev return rc; 65349cb5dfbSVladimir Kondratiev if (rc < 2) 6543277213fSVladimir Kondratiev return -EINVAL; 6553277213fSVladimir Kondratiev 65649cb5dfbSVladimir Kondratiev if (0 == strcmp(cmd, "add")) { 65749cb5dfbSVladimir Kondratiev if (rc < 3) { 65849cb5dfbSVladimir Kondratiev wil_err(wil, "BACK: add require at least 2 params\n"); 65949cb5dfbSVladimir Kondratiev return -EINVAL; 66049cb5dfbSVladimir Kondratiev } 66149cb5dfbSVladimir Kondratiev if (rc < 4) 66249cb5dfbSVladimir Kondratiev p3 = 0; 66349cb5dfbSVladimir Kondratiev wmi_addba(wil, p1, p2, p3); 66449cb5dfbSVladimir Kondratiev } else if (0 == strcmp(cmd, "del_tx")) { 66549cb5dfbSVladimir Kondratiev if (rc < 3) 66649cb5dfbSVladimir Kondratiev p2 = WLAN_REASON_QSTA_LEAVE_QBSS; 66749cb5dfbSVladimir Kondratiev wmi_delba_tx(wil, p1, p2); 66849cb5dfbSVladimir Kondratiev } else if (0 == strcmp(cmd, "del_rx")) { 66949cb5dfbSVladimir Kondratiev if (rc < 3) { 67049cb5dfbSVladimir Kondratiev wil_err(wil, 67149cb5dfbSVladimir Kondratiev "BACK: del_rx require at least 2 params\n"); 67249cb5dfbSVladimir Kondratiev return -EINVAL; 67349cb5dfbSVladimir Kondratiev } 67449cb5dfbSVladimir Kondratiev if (rc < 4) 67549cb5dfbSVladimir Kondratiev p3 = WLAN_REASON_QSTA_LEAVE_QBSS; 67649cb5dfbSVladimir Kondratiev wmi_delba_rx(wil, mk_cidxtid(p1, p2), p3); 67749cb5dfbSVladimir Kondratiev } else { 67849cb5dfbSVladimir Kondratiev wil_err(wil, "BACK: Unrecognized command \"%s\"\n", cmd); 67949cb5dfbSVladimir Kondratiev return -EINVAL; 68049cb5dfbSVladimir Kondratiev } 6813277213fSVladimir Kondratiev 6823277213fSVladimir Kondratiev return len; 6833277213fSVladimir Kondratiev } 6843277213fSVladimir Kondratiev 68549cb5dfbSVladimir Kondratiev static ssize_t wil_read_back(struct file *file, char __user *user_buf, 68649cb5dfbSVladimir Kondratiev size_t count, loff_t *ppos) 68749cb5dfbSVladimir Kondratiev { 68849cb5dfbSVladimir Kondratiev static const char text[] = "block ack control, write:\n" 68949cb5dfbSVladimir Kondratiev " - \"add <ringid> <agg_size> <timeout>\" to trigger ADDBA\n" 69049cb5dfbSVladimir Kondratiev "If missing, <timeout> defaults to 0\n" 69149cb5dfbSVladimir Kondratiev " - \"del_tx <ringid> <reason>\" to trigger DELBA for Tx side\n" 69249cb5dfbSVladimir Kondratiev " - \"del_rx <CID> <TID> <reason>\" to trigger DELBA for Rx side\n" 69349cb5dfbSVladimir Kondratiev "If missing, <reason> set to \"STA_LEAVING\" (36)\n"; 69449cb5dfbSVladimir Kondratiev 69549cb5dfbSVladimir Kondratiev return simple_read_from_buffer(user_buf, count, ppos, text, 69649cb5dfbSVladimir Kondratiev sizeof(text)); 69749cb5dfbSVladimir Kondratiev } 69849cb5dfbSVladimir Kondratiev 69949cb5dfbSVladimir Kondratiev static const struct file_operations fops_back = { 70049cb5dfbSVladimir Kondratiev .read = wil_read_back, 70149cb5dfbSVladimir Kondratiev .write = wil_write_back, 7023277213fSVladimir Kondratiev .open = simple_open, 7033277213fSVladimir Kondratiev }; 7043277213fSVladimir Kondratiev 705dc16427bSVladimir Kondratiev /* pmc control, write: 706dc16427bSVladimir Kondratiev * - "alloc <num descriptors> <descriptor_size>" to allocate PMC 707dc16427bSVladimir Kondratiev * - "free" to release memory allocated for PMC 708dc16427bSVladimir Kondratiev */ 709dc16427bSVladimir Kondratiev static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf, 710dc16427bSVladimir Kondratiev size_t len, loff_t *ppos) 711dc16427bSVladimir Kondratiev { 712dc16427bSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 713dc16427bSVladimir Kondratiev int rc; 714dc16427bSVladimir Kondratiev char *kbuf = kmalloc(len + 1, GFP_KERNEL); 715dc16427bSVladimir Kondratiev char cmd[9]; 716dc16427bSVladimir Kondratiev int num_descs, desc_size; 717dc16427bSVladimir Kondratiev 718dc16427bSVladimir Kondratiev if (!kbuf) 719dc16427bSVladimir Kondratiev return -ENOMEM; 720dc16427bSVladimir Kondratiev 721dc16427bSVladimir Kondratiev rc = simple_write_to_buffer(kbuf, len, ppos, buf, len); 722dc16427bSVladimir Kondratiev if (rc != len) { 723dc16427bSVladimir Kondratiev kfree(kbuf); 724dc16427bSVladimir Kondratiev return rc >= 0 ? -EIO : rc; 725dc16427bSVladimir Kondratiev } 726dc16427bSVladimir Kondratiev 727dc16427bSVladimir Kondratiev kbuf[len] = '\0'; 728dc16427bSVladimir Kondratiev rc = sscanf(kbuf, "%8s %d %d", cmd, &num_descs, &desc_size); 729dc16427bSVladimir Kondratiev kfree(kbuf); 730dc16427bSVladimir Kondratiev 731dc16427bSVladimir Kondratiev if (rc < 0) 732dc16427bSVladimir Kondratiev return rc; 733dc16427bSVladimir Kondratiev 734dc16427bSVladimir Kondratiev if (rc < 1) { 735dc16427bSVladimir Kondratiev wil_err(wil, "pmccfg: no params given\n"); 736dc16427bSVladimir Kondratiev return -EINVAL; 737dc16427bSVladimir Kondratiev } 738dc16427bSVladimir Kondratiev 739dc16427bSVladimir Kondratiev if (0 == strcmp(cmd, "alloc")) { 740dc16427bSVladimir Kondratiev if (rc != 3) { 741dc16427bSVladimir Kondratiev wil_err(wil, "pmccfg: alloc requires 2 params\n"); 742dc16427bSVladimir Kondratiev return -EINVAL; 743dc16427bSVladimir Kondratiev } 744dc16427bSVladimir Kondratiev wil_pmc_alloc(wil, num_descs, desc_size); 745dc16427bSVladimir Kondratiev } else if (0 == strcmp(cmd, "free")) { 746dc16427bSVladimir Kondratiev if (rc != 1) { 747dc16427bSVladimir Kondratiev wil_err(wil, "pmccfg: free does not have any params\n"); 748dc16427bSVladimir Kondratiev return -EINVAL; 749dc16427bSVladimir Kondratiev } 750dc16427bSVladimir Kondratiev wil_pmc_free(wil, true); 751dc16427bSVladimir Kondratiev } else { 752dc16427bSVladimir Kondratiev wil_err(wil, "pmccfg: Unrecognized command \"%s\"\n", cmd); 753dc16427bSVladimir Kondratiev return -EINVAL; 754dc16427bSVladimir Kondratiev } 755dc16427bSVladimir Kondratiev 756dc16427bSVladimir Kondratiev return len; 757dc16427bSVladimir Kondratiev } 758dc16427bSVladimir Kondratiev 759dc16427bSVladimir Kondratiev static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf, 760dc16427bSVladimir Kondratiev size_t count, loff_t *ppos) 761dc16427bSVladimir Kondratiev { 762dc16427bSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 763dc16427bSVladimir Kondratiev char text[256]; 764dc16427bSVladimir Kondratiev char help[] = "pmc control, write:\n" 765dc16427bSVladimir Kondratiev " - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n" 766dc16427bSVladimir Kondratiev " - \"free\" to free memory allocated for pmc\n"; 767dc16427bSVladimir Kondratiev 768dc16427bSVladimir Kondratiev sprintf(text, "Last command status: %d\n\n%s", 769dc16427bSVladimir Kondratiev wil_pmc_last_cmd_status(wil), 770dc16427bSVladimir Kondratiev help); 771dc16427bSVladimir Kondratiev 772dc16427bSVladimir Kondratiev return simple_read_from_buffer(user_buf, count, ppos, text, 773dc16427bSVladimir Kondratiev strlen(text) + 1); 774dc16427bSVladimir Kondratiev } 775dc16427bSVladimir Kondratiev 776dc16427bSVladimir Kondratiev static const struct file_operations fops_pmccfg = { 777dc16427bSVladimir Kondratiev .read = wil_read_pmccfg, 778dc16427bSVladimir Kondratiev .write = wil_write_pmccfg, 779dc16427bSVladimir Kondratiev .open = simple_open, 780dc16427bSVladimir Kondratiev }; 781dc16427bSVladimir Kondratiev 782dc16427bSVladimir Kondratiev static const struct file_operations fops_pmcdata = { 783dc16427bSVladimir Kondratiev .open = simple_open, 784dc16427bSVladimir Kondratiev .read = wil_pmc_read, 785dc16427bSVladimir Kondratiev .llseek = wil_pmc_llseek, 786dc16427bSVladimir Kondratiev }; 787dc16427bSVladimir Kondratiev 7880b39aaf2SVladimir Kondratiev /*---tx_mgmt---*/ 7890b39aaf2SVladimir Kondratiev /* Write mgmt frame to this file to send it */ 7900b39aaf2SVladimir Kondratiev static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf, 7910b39aaf2SVladimir Kondratiev size_t len, loff_t *ppos) 7920b39aaf2SVladimir Kondratiev { 7930b39aaf2SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 7940b39aaf2SVladimir Kondratiev struct wiphy *wiphy = wil_to_wiphy(wil); 7950b39aaf2SVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 7960b39aaf2SVladimir Kondratiev struct cfg80211_mgmt_tx_params params; 7970b39aaf2SVladimir Kondratiev int rc; 7980b39aaf2SVladimir Kondratiev void *frame = kmalloc(len, GFP_KERNEL); 7998fe59627SVladimir Kondratiev 8000b39aaf2SVladimir Kondratiev if (!frame) 8010b39aaf2SVladimir Kondratiev return -ENOMEM; 8020b39aaf2SVladimir Kondratiev 8038e09b7d2SLino Sanfilippo if (copy_from_user(frame, buf, len)) { 8048e09b7d2SLino Sanfilippo kfree(frame); 8050b39aaf2SVladimir Kondratiev return -EIO; 8068e09b7d2SLino Sanfilippo } 8070b39aaf2SVladimir Kondratiev 8080b39aaf2SVladimir Kondratiev params.buf = frame; 8090b39aaf2SVladimir Kondratiev params.len = len; 8100b39aaf2SVladimir Kondratiev params.chan = wdev->preset_chandef.chan; 8110b39aaf2SVladimir Kondratiev 8120b39aaf2SVladimir Kondratiev rc = wil_cfg80211_mgmt_tx(wiphy, wdev, ¶ms, NULL); 8130b39aaf2SVladimir Kondratiev 8140b39aaf2SVladimir Kondratiev kfree(frame); 815af3db60aSLazar Alexei wil_info(wil, "-> %d\n", rc); 8160b39aaf2SVladimir Kondratiev 8170b39aaf2SVladimir Kondratiev return len; 8180b39aaf2SVladimir Kondratiev } 8190b39aaf2SVladimir Kondratiev 8200b39aaf2SVladimir Kondratiev static const struct file_operations fops_txmgmt = { 8210b39aaf2SVladimir Kondratiev .write = wil_write_file_txmgmt, 8220b39aaf2SVladimir Kondratiev .open = simple_open, 8230b39aaf2SVladimir Kondratiev }; 8242be7d22fSVladimir Kondratiev 825ff974e40SVladimir Kondratiev /* Write WMI command (w/o mbox header) to this file to send it 826ff974e40SVladimir Kondratiev * WMI starts from wil6210_mbox_hdr_wmi header 827ff974e40SVladimir Kondratiev */ 828ff974e40SVladimir Kondratiev static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf, 829ff974e40SVladimir Kondratiev size_t len, loff_t *ppos) 830ff974e40SVladimir Kondratiev { 831ff974e40SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 832b874ddecSLior David struct wmi_cmd_hdr *wmi; 833ff974e40SVladimir Kondratiev void *cmd; 834b874ddecSLior David int cmdlen = len - sizeof(struct wmi_cmd_hdr); 835ff974e40SVladimir Kondratiev u16 cmdid; 836ff974e40SVladimir Kondratiev int rc, rc1; 837ff974e40SVladimir Kondratiev 83869218a48SLior David if (cmdlen < 0) 839ff974e40SVladimir Kondratiev return -EINVAL; 840ff974e40SVladimir Kondratiev 841ff974e40SVladimir Kondratiev wmi = kmalloc(len, GFP_KERNEL); 842ff974e40SVladimir Kondratiev if (!wmi) 843ff974e40SVladimir Kondratiev return -ENOMEM; 844ff974e40SVladimir Kondratiev 845ff974e40SVladimir Kondratiev rc = simple_write_to_buffer(wmi, len, ppos, buf, len); 8468e09b7d2SLino Sanfilippo if (rc < 0) { 8478e09b7d2SLino Sanfilippo kfree(wmi); 848ff974e40SVladimir Kondratiev return rc; 8498e09b7d2SLino Sanfilippo } 850ff974e40SVladimir Kondratiev 85169218a48SLior David cmd = (cmdlen > 0) ? &wmi[1] : NULL; 852b874ddecSLior David cmdid = le16_to_cpu(wmi->command_id); 853ff974e40SVladimir Kondratiev 854ff974e40SVladimir Kondratiev rc1 = wmi_send(wil, cmdid, cmd, cmdlen); 855ff974e40SVladimir Kondratiev kfree(wmi); 856ff974e40SVladimir Kondratiev 857af3db60aSLazar Alexei wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1); 858ff974e40SVladimir Kondratiev 859ff974e40SVladimir Kondratiev return rc; 860ff974e40SVladimir Kondratiev } 861ff974e40SVladimir Kondratiev 862ff974e40SVladimir Kondratiev static const struct file_operations fops_wmi = { 863ff974e40SVladimir Kondratiev .write = wil_write_file_wmi, 864ff974e40SVladimir Kondratiev .open = simple_open, 865ff974e40SVladimir Kondratiev }; 866ff974e40SVladimir Kondratiev 867c236658fSVladimir Kondratiev static void wil_seq_print_skb(struct seq_file *s, struct sk_buff *skb) 868c236658fSVladimir Kondratiev { 869c236658fSVladimir Kondratiev int i = 0; 870c236658fSVladimir Kondratiev int len = skb_headlen(skb); 871c236658fSVladimir Kondratiev void *p = skb->data; 872c236658fSVladimir Kondratiev int nr_frags = skb_shinfo(skb)->nr_frags; 873c236658fSVladimir Kondratiev 874c236658fSVladimir Kondratiev seq_printf(s, " len = %d\n", len); 875c236658fSVladimir Kondratiev wil_seq_hexdump(s, p, len, " : "); 876c236658fSVladimir Kondratiev 877c236658fSVladimir Kondratiev if (nr_frags) { 878c236658fSVladimir Kondratiev seq_printf(s, " nr_frags = %d\n", nr_frags); 879c236658fSVladimir Kondratiev for (i = 0; i < nr_frags; i++) { 880c236658fSVladimir Kondratiev const struct skb_frag_struct *frag = 881c236658fSVladimir Kondratiev &skb_shinfo(skb)->frags[i]; 882c236658fSVladimir Kondratiev 883c236658fSVladimir Kondratiev len = skb_frag_size(frag); 884c236658fSVladimir Kondratiev p = skb_frag_address_safe(frag); 885c236658fSVladimir Kondratiev seq_printf(s, " [%2d] : len = %d\n", i, len); 886c236658fSVladimir Kondratiev wil_seq_hexdump(s, p, len, " : "); 887c236658fSVladimir Kondratiev } 888c236658fSVladimir Kondratiev } 889c236658fSVladimir Kondratiev } 890c236658fSVladimir Kondratiev 8913a85543eSVladimir Kondratiev /*---------Tx/Rx descriptor------------*/ 8922be7d22fSVladimir Kondratiev static int wil_txdesc_debugfs_show(struct seq_file *s, void *data) 8932be7d22fSVladimir Kondratiev { 8942be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 8953a85543eSVladimir Kondratiev struct vring *vring; 896af31cb5aSVladimir Kondratiev bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS); 8978fe59627SVladimir Kondratiev 8988fe59627SVladimir Kondratiev vring = tx ? &wil->vring_tx[dbg_vring_index] : &wil->vring_rx; 8992be7d22fSVladimir Kondratiev 9002be7d22fSVladimir Kondratiev if (!vring->va) { 901af31cb5aSVladimir Kondratiev if (tx) 9023a85543eSVladimir Kondratiev seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index); 9033a85543eSVladimir Kondratiev else 9043a85543eSVladimir Kondratiev seq_puts(s, "No Rx VRING\n"); 9052be7d22fSVladimir Kondratiev return 0; 9062be7d22fSVladimir Kondratiev } 9072be7d22fSVladimir Kondratiev 9082be7d22fSVladimir Kondratiev if (dbg_txdesc_index < vring->size) { 9093a85543eSVladimir Kondratiev /* use struct vring_tx_desc for Rx as well, 9103a85543eSVladimir Kondratiev * only field used, .dma.length, is the same 9113a85543eSVladimir Kondratiev */ 9122be7d22fSVladimir Kondratiev volatile struct vring_tx_desc *d = 9138fe59627SVladimir Kondratiev &vring->va[dbg_txdesc_index].tx; 9142be7d22fSVladimir Kondratiev volatile u32 *u = (volatile u32 *)d; 915f88f113aSVladimir Kondratiev struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb; 9162be7d22fSVladimir Kondratiev 917af31cb5aSVladimir Kondratiev if (tx) 9183a85543eSVladimir Kondratiev seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index, 9193a85543eSVladimir Kondratiev dbg_txdesc_index); 9203a85543eSVladimir Kondratiev else 9213a85543eSVladimir Kondratiev seq_printf(s, "Rx[%3d] = {\n", dbg_txdesc_index); 9222be7d22fSVladimir Kondratiev seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n", 9232be7d22fSVladimir Kondratiev u[0], u[1], u[2], u[3]); 9242be7d22fSVladimir Kondratiev seq_printf(s, " DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n", 9252be7d22fSVladimir Kondratiev u[4], u[5], u[6], u[7]); 92639c52ee8SVladimir Kondratiev seq_printf(s, " SKB = 0x%p\n", skb); 9272be7d22fSVladimir Kondratiev 9282be7d22fSVladimir Kondratiev if (skb) { 929c236658fSVladimir Kondratiev skb_get(skb); 930c236658fSVladimir Kondratiev wil_seq_print_skb(s, skb); 931c236658fSVladimir Kondratiev kfree_skb(skb); 9322be7d22fSVladimir Kondratiev } 9338fe59627SVladimir Kondratiev seq_puts(s, "}\n"); 9342be7d22fSVladimir Kondratiev } else { 935af31cb5aSVladimir Kondratiev if (tx) 9363a85543eSVladimir Kondratiev seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n", 9373a85543eSVladimir Kondratiev dbg_vring_index, dbg_txdesc_index, 9383a85543eSVladimir Kondratiev vring->size); 9393a85543eSVladimir Kondratiev else 9403a85543eSVladimir Kondratiev seq_printf(s, "RxDesc index (%d) >= size (%d)\n", 9412be7d22fSVladimir Kondratiev dbg_txdesc_index, vring->size); 9422be7d22fSVladimir Kondratiev } 9432be7d22fSVladimir Kondratiev 9442be7d22fSVladimir Kondratiev return 0; 9452be7d22fSVladimir Kondratiev } 9462be7d22fSVladimir Kondratiev 9472be7d22fSVladimir Kondratiev static int wil_txdesc_seq_open(struct inode *inode, struct file *file) 9482be7d22fSVladimir Kondratiev { 9492be7d22fSVladimir Kondratiev return single_open(file, wil_txdesc_debugfs_show, inode->i_private); 9502be7d22fSVladimir Kondratiev } 9512be7d22fSVladimir Kondratiev 9522be7d22fSVladimir Kondratiev static const struct file_operations fops_txdesc = { 9532be7d22fSVladimir Kondratiev .open = wil_txdesc_seq_open, 9542be7d22fSVladimir Kondratiev .release = single_release, 9552be7d22fSVladimir Kondratiev .read = seq_read, 9562be7d22fSVladimir Kondratiev .llseek = seq_lseek, 9572be7d22fSVladimir Kondratiev }; 9582be7d22fSVladimir Kondratiev 9592be7d22fSVladimir Kondratiev /*---------beamforming------------*/ 96036345ac3SVladimir Kondratiev static char *wil_bfstatus_str(u32 status) 96136345ac3SVladimir Kondratiev { 96236345ac3SVladimir Kondratiev switch (status) { 96336345ac3SVladimir Kondratiev case 0: 96436345ac3SVladimir Kondratiev return "Failed"; 96536345ac3SVladimir Kondratiev case 1: 96636345ac3SVladimir Kondratiev return "OK"; 96736345ac3SVladimir Kondratiev case 2: 96836345ac3SVladimir Kondratiev return "Retrying"; 96936345ac3SVladimir Kondratiev default: 97036345ac3SVladimir Kondratiev return "??"; 97136345ac3SVladimir Kondratiev } 97236345ac3SVladimir Kondratiev } 97336345ac3SVladimir Kondratiev 97436345ac3SVladimir Kondratiev static bool is_all_zeros(void * const x_, size_t sz) 97536345ac3SVladimir Kondratiev { 97636345ac3SVladimir Kondratiev /* if reply is all-0, ignore this CID */ 97736345ac3SVladimir Kondratiev u32 *x = x_; 97836345ac3SVladimir Kondratiev int n; 97936345ac3SVladimir Kondratiev 98036345ac3SVladimir Kondratiev for (n = 0; n < sz / sizeof(*x); n++) 98136345ac3SVladimir Kondratiev if (x[n]) 98236345ac3SVladimir Kondratiev return false; 98336345ac3SVladimir Kondratiev 98436345ac3SVladimir Kondratiev return true; 98536345ac3SVladimir Kondratiev } 98636345ac3SVladimir Kondratiev 9872be7d22fSVladimir Kondratiev static int wil_bf_debugfs_show(struct seq_file *s, void *data) 9882be7d22fSVladimir Kondratiev { 98936345ac3SVladimir Kondratiev int rc; 99036345ac3SVladimir Kondratiev int i; 9912be7d22fSVladimir Kondratiev struct wil6210_priv *wil = s->private; 99236345ac3SVladimir Kondratiev struct wmi_notify_req_cmd cmd = { 99336345ac3SVladimir Kondratiev .interval_usec = 0, 99436345ac3SVladimir Kondratiev }; 99536345ac3SVladimir Kondratiev struct { 996b874ddecSLior David struct wmi_cmd_hdr wmi; 99736345ac3SVladimir Kondratiev struct wmi_notify_req_done_event evt; 99836345ac3SVladimir Kondratiev } __packed reply; 99936345ac3SVladimir Kondratiev 100036345ac3SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { 100136345ac3SVladimir Kondratiev u32 status; 100236345ac3SVladimir Kondratiev 100336345ac3SVladimir Kondratiev cmd.cid = i; 100436345ac3SVladimir Kondratiev rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd), 100536345ac3SVladimir Kondratiev WMI_NOTIFY_REQ_DONE_EVENTID, &reply, 100636345ac3SVladimir Kondratiev sizeof(reply), 20); 100736345ac3SVladimir Kondratiev /* if reply is all-0, ignore this CID */ 100836345ac3SVladimir Kondratiev if (rc || is_all_zeros(&reply.evt, sizeof(reply.evt))) 100936345ac3SVladimir Kondratiev continue; 101036345ac3SVladimir Kondratiev 101136345ac3SVladimir Kondratiev status = le32_to_cpu(reply.evt.status); 101236345ac3SVladimir Kondratiev seq_printf(s, "CID %d {\n" 101336345ac3SVladimir Kondratiev " TSF = 0x%016llx\n" 101436345ac3SVladimir Kondratiev " TxMCS = %2d TxTpt = %4d\n" 101536345ac3SVladimir Kondratiev " SQI = %4d\n" 101636345ac3SVladimir Kondratiev " Status = 0x%08x %s\n" 101736345ac3SVladimir Kondratiev " Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n" 101836345ac3SVladimir Kondratiev " Goodput(rx:tx) %4d:%4d\n" 101936345ac3SVladimir Kondratiev "}\n", 102036345ac3SVladimir Kondratiev i, 102136345ac3SVladimir Kondratiev le64_to_cpu(reply.evt.tsf), 102236345ac3SVladimir Kondratiev le16_to_cpu(reply.evt.bf_mcs), 102336345ac3SVladimir Kondratiev le32_to_cpu(reply.evt.tx_tpt), 102436345ac3SVladimir Kondratiev reply.evt.sqi, 102536345ac3SVladimir Kondratiev status, wil_bfstatus_str(status), 102636345ac3SVladimir Kondratiev le16_to_cpu(reply.evt.my_rx_sector), 102736345ac3SVladimir Kondratiev le16_to_cpu(reply.evt.my_tx_sector), 102836345ac3SVladimir Kondratiev le16_to_cpu(reply.evt.other_rx_sector), 102936345ac3SVladimir Kondratiev le16_to_cpu(reply.evt.other_tx_sector), 103036345ac3SVladimir Kondratiev le32_to_cpu(reply.evt.rx_goodput), 103136345ac3SVladimir Kondratiev le32_to_cpu(reply.evt.tx_goodput)); 103236345ac3SVladimir Kondratiev } 10332be7d22fSVladimir Kondratiev return 0; 10342be7d22fSVladimir Kondratiev } 10352be7d22fSVladimir Kondratiev 10362be7d22fSVladimir Kondratiev static int wil_bf_seq_open(struct inode *inode, struct file *file) 10372be7d22fSVladimir Kondratiev { 10382be7d22fSVladimir Kondratiev return single_open(file, wil_bf_debugfs_show, inode->i_private); 10392be7d22fSVladimir Kondratiev } 10402be7d22fSVladimir Kondratiev 10412be7d22fSVladimir Kondratiev static const struct file_operations fops_bf = { 10422be7d22fSVladimir Kondratiev .open = wil_bf_seq_open, 10432be7d22fSVladimir Kondratiev .release = single_release, 10442be7d22fSVladimir Kondratiev .read = seq_read, 10452be7d22fSVladimir Kondratiev .llseek = seq_lseek, 10462be7d22fSVladimir Kondratiev }; 10478fe59627SVladimir Kondratiev 10482be7d22fSVladimir Kondratiev /*---------SSID------------*/ 10492be7d22fSVladimir Kondratiev static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf, 10502be7d22fSVladimir Kondratiev size_t count, loff_t *ppos) 10512be7d22fSVladimir Kondratiev { 10522be7d22fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 10532be7d22fSVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 10542be7d22fSVladimir Kondratiev 10552be7d22fSVladimir Kondratiev return simple_read_from_buffer(user_buf, count, ppos, 10562be7d22fSVladimir Kondratiev wdev->ssid, wdev->ssid_len); 10572be7d22fSVladimir Kondratiev } 10582be7d22fSVladimir Kondratiev 10592be7d22fSVladimir Kondratiev static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf, 10602be7d22fSVladimir Kondratiev size_t count, loff_t *ppos) 10612be7d22fSVladimir Kondratiev { 10622be7d22fSVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 10632be7d22fSVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 10642be7d22fSVladimir Kondratiev struct net_device *ndev = wil_to_ndev(wil); 10652be7d22fSVladimir Kondratiev 10662be7d22fSVladimir Kondratiev if (*ppos != 0) { 10672be7d22fSVladimir Kondratiev wil_err(wil, "Unable to set SSID substring from [%d]\n", 10682be7d22fSVladimir Kondratiev (int)*ppos); 10692be7d22fSVladimir Kondratiev return -EINVAL; 10702be7d22fSVladimir Kondratiev } 10712be7d22fSVladimir Kondratiev 10722be7d22fSVladimir Kondratiev if (count > sizeof(wdev->ssid)) { 10732be7d22fSVladimir Kondratiev wil_err(wil, "SSID too long, len = %d\n", (int)count); 10742be7d22fSVladimir Kondratiev return -EINVAL; 10752be7d22fSVladimir Kondratiev } 10762be7d22fSVladimir Kondratiev if (netif_running(ndev)) { 10772be7d22fSVladimir Kondratiev wil_err(wil, "Unable to change SSID on running interface\n"); 10782be7d22fSVladimir Kondratiev return -EINVAL; 10792be7d22fSVladimir Kondratiev } 10802be7d22fSVladimir Kondratiev 10812be7d22fSVladimir Kondratiev wdev->ssid_len = count; 10822be7d22fSVladimir Kondratiev return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos, 10832be7d22fSVladimir Kondratiev buf, count); 10842be7d22fSVladimir Kondratiev } 10852be7d22fSVladimir Kondratiev 10862be7d22fSVladimir Kondratiev static const struct file_operations fops_ssid = { 10872be7d22fSVladimir Kondratiev .read = wil_read_file_ssid, 10882be7d22fSVladimir Kondratiev .write = wil_write_file_ssid, 108993ecbd64SWei Yongjun .open = simple_open, 10902be7d22fSVladimir Kondratiev }; 10912be7d22fSVladimir Kondratiev 10921a2780e0SVladimir Kondratiev /*---------temp------------*/ 10931a2780e0SVladimir Kondratiev static void print_temp(struct seq_file *s, const char *prefix, u32 t) 10941a2780e0SVladimir Kondratiev { 10951a2780e0SVladimir Kondratiev switch (t) { 10961a2780e0SVladimir Kondratiev case 0: 10971a2780e0SVladimir Kondratiev case ~(u32)0: 10981a2780e0SVladimir Kondratiev seq_printf(s, "%s N/A\n", prefix); 10991a2780e0SVladimir Kondratiev break; 11001a2780e0SVladimir Kondratiev default: 11011a2780e0SVladimir Kondratiev seq_printf(s, "%s %d.%03d\n", prefix, t / 1000, t % 1000); 11021a2780e0SVladimir Kondratiev break; 11031a2780e0SVladimir Kondratiev } 11041a2780e0SVladimir Kondratiev } 11051a2780e0SVladimir Kondratiev 11061a2780e0SVladimir Kondratiev static int wil_temp_debugfs_show(struct seq_file *s, void *data) 11071a2780e0SVladimir Kondratiev { 11081a2780e0SVladimir Kondratiev struct wil6210_priv *wil = s->private; 11091a2780e0SVladimir Kondratiev u32 t_m, t_r; 11101a2780e0SVladimir Kondratiev int rc = wmi_get_temperature(wil, &t_m, &t_r); 11118fe59627SVladimir Kondratiev 11121a2780e0SVladimir Kondratiev if (rc) { 11138fe59627SVladimir Kondratiev seq_puts(s, "Failed\n"); 11141a2780e0SVladimir Kondratiev return 0; 11151a2780e0SVladimir Kondratiev } 11161a2780e0SVladimir Kondratiev 1117d45cff9fSVladimir Kondratiev print_temp(s, "T_mac =", t_m); 1118d45cff9fSVladimir Kondratiev print_temp(s, "T_radio =", t_r); 11191a2780e0SVladimir Kondratiev 11201a2780e0SVladimir Kondratiev return 0; 11211a2780e0SVladimir Kondratiev } 11221a2780e0SVladimir Kondratiev 11231a2780e0SVladimir Kondratiev static int wil_temp_seq_open(struct inode *inode, struct file *file) 11241a2780e0SVladimir Kondratiev { 11251a2780e0SVladimir Kondratiev return single_open(file, wil_temp_debugfs_show, inode->i_private); 11261a2780e0SVladimir Kondratiev } 11271a2780e0SVladimir Kondratiev 11281a2780e0SVladimir Kondratiev static const struct file_operations fops_temp = { 11291a2780e0SVladimir Kondratiev .open = wil_temp_seq_open, 11301a2780e0SVladimir Kondratiev .release = single_release, 11311a2780e0SVladimir Kondratiev .read = seq_read, 11321a2780e0SVladimir Kondratiev .llseek = seq_lseek, 11331a2780e0SVladimir Kondratiev }; 11341a2780e0SVladimir Kondratiev 11359eb82d43SVladimir Kondratiev /*---------freq------------*/ 11369eb82d43SVladimir Kondratiev static int wil_freq_debugfs_show(struct seq_file *s, void *data) 11379eb82d43SVladimir Kondratiev { 11389eb82d43SVladimir Kondratiev struct wil6210_priv *wil = s->private; 11399eb82d43SVladimir Kondratiev struct wireless_dev *wdev = wil_to_wdev(wil); 11409eb82d43SVladimir Kondratiev u16 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0; 11419eb82d43SVladimir Kondratiev 11429eb82d43SVladimir Kondratiev seq_printf(s, "Freq = %d\n", freq); 11439eb82d43SVladimir Kondratiev 11449eb82d43SVladimir Kondratiev return 0; 11459eb82d43SVladimir Kondratiev } 11469eb82d43SVladimir Kondratiev 11479eb82d43SVladimir Kondratiev static int wil_freq_seq_open(struct inode *inode, struct file *file) 11489eb82d43SVladimir Kondratiev { 11499eb82d43SVladimir Kondratiev return single_open(file, wil_freq_debugfs_show, inode->i_private); 11509eb82d43SVladimir Kondratiev } 11519eb82d43SVladimir Kondratiev 11529eb82d43SVladimir Kondratiev static const struct file_operations fops_freq = { 11539eb82d43SVladimir Kondratiev .open = wil_freq_seq_open, 11549eb82d43SVladimir Kondratiev .release = single_release, 11559eb82d43SVladimir Kondratiev .read = seq_read, 11569eb82d43SVladimir Kondratiev .llseek = seq_lseek, 11579eb82d43SVladimir Kondratiev }; 11589eb82d43SVladimir Kondratiev 11599eb82d43SVladimir Kondratiev /*---------link------------*/ 11609eb82d43SVladimir Kondratiev static int wil_link_debugfs_show(struct seq_file *s, void *data) 11619eb82d43SVladimir Kondratiev { 11629eb82d43SVladimir Kondratiev struct wil6210_priv *wil = s->private; 11639eb82d43SVladimir Kondratiev struct station_info sinfo; 11649eb82d43SVladimir Kondratiev int i, rc; 11659eb82d43SVladimir Kondratiev 11669eb82d43SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { 11679eb82d43SVladimir Kondratiev struct wil_sta_info *p = &wil->sta[i]; 11689eb82d43SVladimir Kondratiev char *status = "unknown"; 11698fe59627SVladimir Kondratiev 11709eb82d43SVladimir Kondratiev switch (p->status) { 11719eb82d43SVladimir Kondratiev case wil_sta_unused: 11729eb82d43SVladimir Kondratiev status = "unused "; 11739eb82d43SVladimir Kondratiev break; 11749eb82d43SVladimir Kondratiev case wil_sta_conn_pending: 11759eb82d43SVladimir Kondratiev status = "pending "; 11769eb82d43SVladimir Kondratiev break; 11779eb82d43SVladimir Kondratiev case wil_sta_connected: 11789eb82d43SVladimir Kondratiev status = "connected"; 11799eb82d43SVladimir Kondratiev break; 11809eb82d43SVladimir Kondratiev } 1181230d8442SVladimir Kondratiev seq_printf(s, "[%d] %pM %s\n", i, p->addr, status); 11829eb82d43SVladimir Kondratiev 11839eb82d43SVladimir Kondratiev if (p->status == wil_sta_connected) { 11849eb82d43SVladimir Kondratiev rc = wil_cid_fill_sinfo(wil, i, &sinfo); 11859eb82d43SVladimir Kondratiev if (rc) 11869eb82d43SVladimir Kondratiev return rc; 11879eb82d43SVladimir Kondratiev 11889eb82d43SVladimir Kondratiev seq_printf(s, " Tx_mcs = %d\n", sinfo.txrate.mcs); 11899eb82d43SVladimir Kondratiev seq_printf(s, " Rx_mcs = %d\n", sinfo.rxrate.mcs); 11909eb82d43SVladimir Kondratiev seq_printf(s, " SQ = %d\n", sinfo.signal); 11919eb82d43SVladimir Kondratiev } 11929eb82d43SVladimir Kondratiev } 11939eb82d43SVladimir Kondratiev 11949eb82d43SVladimir Kondratiev return 0; 11959eb82d43SVladimir Kondratiev } 11969eb82d43SVladimir Kondratiev 11979eb82d43SVladimir Kondratiev static int wil_link_seq_open(struct inode *inode, struct file *file) 11989eb82d43SVladimir Kondratiev { 11999eb82d43SVladimir Kondratiev return single_open(file, wil_link_debugfs_show, inode->i_private); 12009eb82d43SVladimir Kondratiev } 12019eb82d43SVladimir Kondratiev 12029eb82d43SVladimir Kondratiev static const struct file_operations fops_link = { 12039eb82d43SVladimir Kondratiev .open = wil_link_seq_open, 12049eb82d43SVladimir Kondratiev .release = single_release, 12059eb82d43SVladimir Kondratiev .read = seq_read, 12069eb82d43SVladimir Kondratiev .llseek = seq_lseek, 12079eb82d43SVladimir Kondratiev }; 12089eb82d43SVladimir Kondratiev 120984bb29b7SVladimir Kondratiev /*---------info------------*/ 121084bb29b7SVladimir Kondratiev static int wil_info_debugfs_show(struct seq_file *s, void *data) 121184bb29b7SVladimir Kondratiev { 1212be299858SVladimir Kondratiev struct wil6210_priv *wil = s->private; 1213be299858SVladimir Kondratiev struct net_device *ndev = wil_to_ndev(wil); 121484bb29b7SVladimir Kondratiev int is_ac = power_supply_is_system_supplied(); 1215be299858SVladimir Kondratiev int rx = atomic_xchg(&wil->isr_count_rx, 0); 1216be299858SVladimir Kondratiev int tx = atomic_xchg(&wil->isr_count_tx, 0); 1217be299858SVladimir Kondratiev static ulong rxf_old, txf_old; 1218be299858SVladimir Kondratiev ulong rxf = ndev->stats.rx_packets; 1219be299858SVladimir Kondratiev ulong txf = ndev->stats.tx_packets; 122055f8f680SVladimir Kondratiev unsigned int i; 122184bb29b7SVladimir Kondratiev 122284bb29b7SVladimir Kondratiev /* >0 : AC; 0 : battery; <0 : error */ 122384bb29b7SVladimir Kondratiev seq_printf(s, "AC powered : %d\n", is_ac); 1224be299858SVladimir Kondratiev seq_printf(s, "Rx irqs:packets : %8d : %8ld\n", rx, rxf - rxf_old); 1225be299858SVladimir Kondratiev seq_printf(s, "Tx irqs:packets : %8d : %8ld\n", tx, txf - txf_old); 1226be299858SVladimir Kondratiev rxf_old = rxf; 1227be299858SVladimir Kondratiev txf_old = txf; 122884bb29b7SVladimir Kondratiev 122955f8f680SVladimir Kondratiev #define CHECK_QSTATE(x) (state & BIT(__QUEUE_STATE_ ## x)) ? \ 123055f8f680SVladimir Kondratiev " " __stringify(x) : "" 123155f8f680SVladimir Kondratiev 123255f8f680SVladimir Kondratiev for (i = 0; i < ndev->num_tx_queues; i++) { 123355f8f680SVladimir Kondratiev struct netdev_queue *txq = netdev_get_tx_queue(ndev, i); 123455f8f680SVladimir Kondratiev unsigned long state = txq->state; 123555f8f680SVladimir Kondratiev 123655f8f680SVladimir Kondratiev seq_printf(s, "Tx queue[%i] state : 0x%lx%s%s%s\n", i, state, 123755f8f680SVladimir Kondratiev CHECK_QSTATE(DRV_XOFF), 123855f8f680SVladimir Kondratiev CHECK_QSTATE(STACK_XOFF), 123955f8f680SVladimir Kondratiev CHECK_QSTATE(FROZEN) 124055f8f680SVladimir Kondratiev ); 124155f8f680SVladimir Kondratiev } 124255f8f680SVladimir Kondratiev #undef CHECK_QSTATE 124384bb29b7SVladimir Kondratiev return 0; 124484bb29b7SVladimir Kondratiev } 124584bb29b7SVladimir Kondratiev 124684bb29b7SVladimir Kondratiev static int wil_info_seq_open(struct inode *inode, struct file *file) 124784bb29b7SVladimir Kondratiev { 124884bb29b7SVladimir Kondratiev return single_open(file, wil_info_debugfs_show, inode->i_private); 124984bb29b7SVladimir Kondratiev } 125084bb29b7SVladimir Kondratiev 125184bb29b7SVladimir Kondratiev static const struct file_operations fops_info = { 125284bb29b7SVladimir Kondratiev .open = wil_info_seq_open, 125384bb29b7SVladimir Kondratiev .release = single_release, 125484bb29b7SVladimir Kondratiev .read = seq_read, 125584bb29b7SVladimir Kondratiev .llseek = seq_lseek, 125684bb29b7SVladimir Kondratiev }; 125784bb29b7SVladimir Kondratiev 1258c33407a8SVladimir Kondratiev /*---------recovery------------*/ 1259c33407a8SVladimir Kondratiev /* mode = [manual|auto] 1260c33407a8SVladimir Kondratiev * state = [idle|pending|running] 1261c33407a8SVladimir Kondratiev */ 1262c33407a8SVladimir Kondratiev static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf, 1263c33407a8SVladimir Kondratiev size_t count, loff_t *ppos) 1264c33407a8SVladimir Kondratiev { 1265c33407a8SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 1266c33407a8SVladimir Kondratiev char buf[80]; 1267c33407a8SVladimir Kondratiev int n; 1268c33407a8SVladimir Kondratiev static const char * const sstate[] = {"idle", "pending", "running"}; 1269c33407a8SVladimir Kondratiev 1270c33407a8SVladimir Kondratiev n = snprintf(buf, sizeof(buf), "mode = %s\nstate = %s\n", 1271c33407a8SVladimir Kondratiev no_fw_recovery ? "manual" : "auto", 1272c33407a8SVladimir Kondratiev sstate[wil->recovery_state]); 1273c33407a8SVladimir Kondratiev 1274c33407a8SVladimir Kondratiev n = min_t(int, n, sizeof(buf)); 1275c33407a8SVladimir Kondratiev 1276c33407a8SVladimir Kondratiev return simple_read_from_buffer(user_buf, count, ppos, 1277c33407a8SVladimir Kondratiev buf, n); 1278c33407a8SVladimir Kondratiev } 1279c33407a8SVladimir Kondratiev 1280c33407a8SVladimir Kondratiev static ssize_t wil_write_file_recovery(struct file *file, 1281c33407a8SVladimir Kondratiev const char __user *buf_, 1282c33407a8SVladimir Kondratiev size_t count, loff_t *ppos) 1283c33407a8SVladimir Kondratiev { 1284c33407a8SVladimir Kondratiev struct wil6210_priv *wil = file->private_data; 1285c33407a8SVladimir Kondratiev static const char run_command[] = "run"; 1286c33407a8SVladimir Kondratiev char buf[sizeof(run_command) + 1]; /* to detect "runx" */ 1287c33407a8SVladimir Kondratiev ssize_t rc; 1288c33407a8SVladimir Kondratiev 1289c33407a8SVladimir Kondratiev if (wil->recovery_state != fw_recovery_pending) { 1290c33407a8SVladimir Kondratiev wil_err(wil, "No recovery pending\n"); 1291c33407a8SVladimir Kondratiev return -EINVAL; 1292c33407a8SVladimir Kondratiev } 1293c33407a8SVladimir Kondratiev 1294c33407a8SVladimir Kondratiev if (*ppos != 0) { 1295c33407a8SVladimir Kondratiev wil_err(wil, "Offset [%d]\n", (int)*ppos); 1296c33407a8SVladimir Kondratiev return -EINVAL; 1297c33407a8SVladimir Kondratiev } 1298c33407a8SVladimir Kondratiev 1299c33407a8SVladimir Kondratiev if (count > sizeof(buf)) { 1300c33407a8SVladimir Kondratiev wil_err(wil, "Input too long, len = %d\n", (int)count); 1301c33407a8SVladimir Kondratiev return -EINVAL; 1302c33407a8SVladimir Kondratiev } 1303c33407a8SVladimir Kondratiev 1304c33407a8SVladimir Kondratiev rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, buf_, count); 1305c33407a8SVladimir Kondratiev if (rc < 0) 1306c33407a8SVladimir Kondratiev return rc; 1307c33407a8SVladimir Kondratiev 1308c33407a8SVladimir Kondratiev buf[rc] = '\0'; 1309c33407a8SVladimir Kondratiev if (0 == strcmp(buf, run_command)) 1310c33407a8SVladimir Kondratiev wil_set_recovery_state(wil, fw_recovery_running); 1311c33407a8SVladimir Kondratiev else 1312c33407a8SVladimir Kondratiev wil_err(wil, "Bad recovery command \"%s\"\n", buf); 1313c33407a8SVladimir Kondratiev 1314c33407a8SVladimir Kondratiev return rc; 1315c33407a8SVladimir Kondratiev } 1316c33407a8SVladimir Kondratiev 1317c33407a8SVladimir Kondratiev static const struct file_operations fops_recovery = { 1318c33407a8SVladimir Kondratiev .read = wil_read_file_recovery, 1319c33407a8SVladimir Kondratiev .write = wil_write_file_recovery, 1320c33407a8SVladimir Kondratiev .open = simple_open, 1321c33407a8SVladimir Kondratiev }; 1322c33407a8SVladimir Kondratiev 13233df2cd36SVladimir Kondratiev /*---------Station matrix------------*/ 1324b4490f42SVladimir Kondratiev static void wil_print_rxtid(struct seq_file *s, struct wil_tid_ampdu_rx *r) 1325b4490f42SVladimir Kondratiev { 1326b4490f42SVladimir Kondratiev int i; 1327b4490f42SVladimir Kondratiev u16 index = ((r->head_seq_num - r->ssn) & 0xfff) % r->buf_size; 132891a8edccSVladimir Kondratiev unsigned long long drop_dup = r->drop_dup, drop_old = r->drop_old; 13298fe59627SVladimir Kondratiev 133056637e7bSVladimir Kondratiev seq_printf(s, "([%2d] %3d TU) 0x%03x [", r->buf_size, r->timeout, 133156637e7bSVladimir Kondratiev r->head_seq_num); 1332b4490f42SVladimir Kondratiev for (i = 0; i < r->buf_size; i++) { 1333b4490f42SVladimir Kondratiev if (i == index) 1334b4490f42SVladimir Kondratiev seq_printf(s, "%c", r->reorder_buf[i] ? 'O' : '|'); 1335b4490f42SVladimir Kondratiev else 1336b4490f42SVladimir Kondratiev seq_printf(s, "%c", r->reorder_buf[i] ? '*' : '_'); 1337b4490f42SVladimir Kondratiev } 133891a8edccSVladimir Kondratiev seq_printf(s, 133991a8edccSVladimir Kondratiev "] total %llu drop %llu (dup %llu + old %llu) last 0x%03x\n", 134091a8edccSVladimir Kondratiev r->total, drop_dup + drop_old, drop_dup, drop_old, 134191a8edccSVladimir Kondratiev r->ssn_last_drop); 1342b4490f42SVladimir Kondratiev } 13433df2cd36SVladimir Kondratiev 134458527421SVladimir Kondratiev static void wil_print_rxtid_crypto(struct seq_file *s, int tid, 134558527421SVladimir Kondratiev struct wil_tid_crypto_rx *c) 134658527421SVladimir Kondratiev { 134758527421SVladimir Kondratiev int i; 134858527421SVladimir Kondratiev 134958527421SVladimir Kondratiev for (i = 0; i < 4; i++) { 135058527421SVladimir Kondratiev struct wil_tid_crypto_rx_single *cc = &c->key_id[i]; 135158527421SVladimir Kondratiev 135258527421SVladimir Kondratiev if (cc->key_set) 135358527421SVladimir Kondratiev goto has_keys; 135458527421SVladimir Kondratiev } 135558527421SVladimir Kondratiev return; 135658527421SVladimir Kondratiev 135758527421SVladimir Kondratiev has_keys: 135858527421SVladimir Kondratiev if (tid < WIL_STA_TID_NUM) 135958527421SVladimir Kondratiev seq_printf(s, " [%2d] PN", tid); 136058527421SVladimir Kondratiev else 136158527421SVladimir Kondratiev seq_puts(s, " [GR] PN"); 136258527421SVladimir Kondratiev 136358527421SVladimir Kondratiev for (i = 0; i < 4; i++) { 136458527421SVladimir Kondratiev struct wil_tid_crypto_rx_single *cc = &c->key_id[i]; 136558527421SVladimir Kondratiev 136658527421SVladimir Kondratiev seq_printf(s, " [%i%s]%6phN", i, cc->key_set ? "+" : "-", 136758527421SVladimir Kondratiev cc->pn); 136858527421SVladimir Kondratiev } 136958527421SVladimir Kondratiev seq_puts(s, "\n"); 137058527421SVladimir Kondratiev } 137158527421SVladimir Kondratiev 13723df2cd36SVladimir Kondratiev static int wil_sta_debugfs_show(struct seq_file *s, void *data) 1373bd33273bSVladimir Kondratiev __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock) 13743df2cd36SVladimir Kondratiev { 13753df2cd36SVladimir Kondratiev struct wil6210_priv *wil = s->private; 1376c4a110d8SVladimir Kondratiev int i, tid, mcs; 13773df2cd36SVladimir Kondratiev 13783df2cd36SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { 13793df2cd36SVladimir Kondratiev struct wil_sta_info *p = &wil->sta[i]; 13803df2cd36SVladimir Kondratiev char *status = "unknown"; 13819d865ee2SLior David u8 aid = 0; 13828fe59627SVladimir Kondratiev 13833df2cd36SVladimir Kondratiev switch (p->status) { 13843df2cd36SVladimir Kondratiev case wil_sta_unused: 13853df2cd36SVladimir Kondratiev status = "unused "; 13863df2cd36SVladimir Kondratiev break; 13873df2cd36SVladimir Kondratiev case wil_sta_conn_pending: 13883df2cd36SVladimir Kondratiev status = "pending "; 13893df2cd36SVladimir Kondratiev break; 13903df2cd36SVladimir Kondratiev case wil_sta_connected: 13913df2cd36SVladimir Kondratiev status = "connected"; 13929d865ee2SLior David aid = p->aid; 13933df2cd36SVladimir Kondratiev break; 13943df2cd36SVladimir Kondratiev } 13959d865ee2SLior David seq_printf(s, "[%d] %pM %s AID %d\n", i, p->addr, status, aid); 1396b4490f42SVladimir Kondratiev 1397b4490f42SVladimir Kondratiev if (p->status == wil_sta_connected) { 1398bd33273bSVladimir Kondratiev spin_lock_bh(&p->tid_rx_lock); 1399b4490f42SVladimir Kondratiev for (tid = 0; tid < WIL_STA_TID_NUM; tid++) { 1400b4490f42SVladimir Kondratiev struct wil_tid_ampdu_rx *r = p->tid_rx[tid]; 140158527421SVladimir Kondratiev struct wil_tid_crypto_rx *c = 140258527421SVladimir Kondratiev &p->tid_crypto_rx[tid]; 14038fe59627SVladimir Kondratiev 1404b4490f42SVladimir Kondratiev if (r) { 1405b4490f42SVladimir Kondratiev seq_printf(s, " [%2d] ", tid); 1406b4490f42SVladimir Kondratiev wil_print_rxtid(s, r); 1407b4490f42SVladimir Kondratiev } 140858527421SVladimir Kondratiev 140958527421SVladimir Kondratiev wil_print_rxtid_crypto(s, tid, c); 1410b4490f42SVladimir Kondratiev } 141158527421SVladimir Kondratiev wil_print_rxtid_crypto(s, WIL_STA_TID_NUM, 141258527421SVladimir Kondratiev &p->group_crypto_rx); 1413bd33273bSVladimir Kondratiev spin_unlock_bh(&p->tid_rx_lock); 14143b282bc6SVladimir Kondratiev seq_printf(s, 141558527421SVladimir Kondratiev "Rx invalid frame: non-data %lu, short %lu, large %lu, replay %lu\n", 14163b282bc6SVladimir Kondratiev p->stats.rx_non_data_frame, 14173b282bc6SVladimir Kondratiev p->stats.rx_short_frame, 141858527421SVladimir Kondratiev p->stats.rx_large_frame, 141958527421SVladimir Kondratiev p->stats.rx_replay); 14203b282bc6SVladimir Kondratiev 1421c4a110d8SVladimir Kondratiev seq_puts(s, "Rx/MCS:"); 1422c4a110d8SVladimir Kondratiev for (mcs = 0; mcs < ARRAY_SIZE(p->stats.rx_per_mcs); 1423c4a110d8SVladimir Kondratiev mcs++) 1424c4a110d8SVladimir Kondratiev seq_printf(s, " %lld", 1425c4a110d8SVladimir Kondratiev p->stats.rx_per_mcs[mcs]); 1426c4a110d8SVladimir Kondratiev seq_puts(s, "\n"); 1427b4490f42SVladimir Kondratiev } 14283df2cd36SVladimir Kondratiev } 14293df2cd36SVladimir Kondratiev 14303df2cd36SVladimir Kondratiev return 0; 14313df2cd36SVladimir Kondratiev } 14323df2cd36SVladimir Kondratiev 14333df2cd36SVladimir Kondratiev static int wil_sta_seq_open(struct inode *inode, struct file *file) 14343df2cd36SVladimir Kondratiev { 14353df2cd36SVladimir Kondratiev return single_open(file, wil_sta_debugfs_show, inode->i_private); 14363df2cd36SVladimir Kondratiev } 14373df2cd36SVladimir Kondratiev 14383df2cd36SVladimir Kondratiev static const struct file_operations fops_sta = { 14393df2cd36SVladimir Kondratiev .open = wil_sta_seq_open, 14403df2cd36SVladimir Kondratiev .release = single_release, 14413df2cd36SVladimir Kondratiev .read = seq_read, 14423df2cd36SVladimir Kondratiev .llseek = seq_lseek, 14433df2cd36SVladimir Kondratiev }; 14443df2cd36SVladimir Kondratiev 144510d599adSMaya Erez static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf, 144610d599adSMaya Erez size_t count, loff_t *ppos) 144710d599adSMaya Erez { 144810d599adSMaya Erez char buf[80]; 144910d599adSMaya Erez int n; 145010d599adSMaya Erez 145110d599adSMaya Erez n = snprintf(buf, sizeof(buf), 145210d599adSMaya Erez "led_id is set to %d, echo 1 to enable, 0 to disable\n", 145310d599adSMaya Erez led_id); 145410d599adSMaya Erez 145510d599adSMaya Erez n = min_t(int, n, sizeof(buf)); 145610d599adSMaya Erez 145710d599adSMaya Erez return simple_read_from_buffer(user_buf, count, ppos, 145810d599adSMaya Erez buf, n); 145910d599adSMaya Erez } 146010d599adSMaya Erez 146110d599adSMaya Erez static ssize_t wil_write_file_led_cfg(struct file *file, 146210d599adSMaya Erez const char __user *buf_, 146310d599adSMaya Erez size_t count, loff_t *ppos) 146410d599adSMaya Erez { 146510d599adSMaya Erez struct wil6210_priv *wil = file->private_data; 146610d599adSMaya Erez int val; 146710d599adSMaya Erez int rc; 146810d599adSMaya Erez 146910d599adSMaya Erez rc = kstrtoint_from_user(buf_, count, 0, &val); 147010d599adSMaya Erez if (rc) { 147110d599adSMaya Erez wil_err(wil, "Invalid argument\n"); 147210d599adSMaya Erez return rc; 147310d599adSMaya Erez } 147410d599adSMaya Erez 147510d599adSMaya Erez wil_info(wil, "%s led %d\n", val ? "Enabling" : "Disabling", led_id); 147610d599adSMaya Erez rc = wmi_led_cfg(wil, val); 147710d599adSMaya Erez if (rc) { 147810d599adSMaya Erez wil_info(wil, "%s led %d failed\n", 147910d599adSMaya Erez val ? "Enabling" : "Disabling", led_id); 148010d599adSMaya Erez return rc; 148110d599adSMaya Erez } 148210d599adSMaya Erez 148310d599adSMaya Erez return count; 148410d599adSMaya Erez } 148510d599adSMaya Erez 148610d599adSMaya Erez static const struct file_operations fops_led_cfg = { 148710d599adSMaya Erez .read = wil_read_file_led_cfg, 148810d599adSMaya Erez .write = wil_write_file_led_cfg, 148910d599adSMaya Erez .open = simple_open, 149010d599adSMaya Erez }; 149110d599adSMaya Erez 149210d599adSMaya Erez /* led_blink_time, write: 149310d599adSMaya Erez * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast> 149410d599adSMaya Erez */ 149510d599adSMaya Erez static ssize_t wil_write_led_blink_time(struct file *file, 149610d599adSMaya Erez const char __user *buf, 149710d599adSMaya Erez size_t len, loff_t *ppos) 149810d599adSMaya Erez { 149910d599adSMaya Erez int rc; 150010d599adSMaya Erez char *kbuf = kmalloc(len + 1, GFP_KERNEL); 150110d599adSMaya Erez 150210d599adSMaya Erez if (!kbuf) 150310d599adSMaya Erez return -ENOMEM; 150410d599adSMaya Erez 150510d599adSMaya Erez rc = simple_write_to_buffer(kbuf, len, ppos, buf, len); 150610d599adSMaya Erez if (rc != len) { 150710d599adSMaya Erez kfree(kbuf); 150810d599adSMaya Erez return rc >= 0 ? -EIO : rc; 150910d599adSMaya Erez } 151010d599adSMaya Erez 151110d599adSMaya Erez kbuf[len] = '\0'; 151210d599adSMaya Erez rc = sscanf(kbuf, "%d %d %d %d %d %d", 151310d599adSMaya Erez &led_blink_time[WIL_LED_TIME_SLOW].on_ms, 151410d599adSMaya Erez &led_blink_time[WIL_LED_TIME_SLOW].off_ms, 151510d599adSMaya Erez &led_blink_time[WIL_LED_TIME_MED].on_ms, 151610d599adSMaya Erez &led_blink_time[WIL_LED_TIME_MED].off_ms, 151710d599adSMaya Erez &led_blink_time[WIL_LED_TIME_FAST].on_ms, 151810d599adSMaya Erez &led_blink_time[WIL_LED_TIME_FAST].off_ms); 151910d599adSMaya Erez kfree(kbuf); 152010d599adSMaya Erez 152110d599adSMaya Erez if (rc < 0) 152210d599adSMaya Erez return rc; 152310d599adSMaya Erez if (rc < 6) 152410d599adSMaya Erez return -EINVAL; 152510d599adSMaya Erez 152610d599adSMaya Erez return len; 152710d599adSMaya Erez } 152810d599adSMaya Erez 152910d599adSMaya Erez static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf, 153010d599adSMaya Erez size_t count, loff_t *ppos) 153110d599adSMaya Erez { 153210d599adSMaya Erez static char text[400]; 153310d599adSMaya Erez 153410d599adSMaya Erez snprintf(text, sizeof(text), 153510d599adSMaya Erez "To set led blink on/off time variables write:\n" 153610d599adSMaya Erez "<blink_on_slow> <blink_off_slow> <blink_on_med> " 153710d599adSMaya Erez "<blink_off_med> <blink_on_fast> <blink_off_fast>\n" 153810d599adSMaya Erez "The current values are:\n" 153910d599adSMaya Erez "%d %d %d %d %d %d\n", 154010d599adSMaya Erez led_blink_time[WIL_LED_TIME_SLOW].on_ms, 154110d599adSMaya Erez led_blink_time[WIL_LED_TIME_SLOW].off_ms, 154210d599adSMaya Erez led_blink_time[WIL_LED_TIME_MED].on_ms, 154310d599adSMaya Erez led_blink_time[WIL_LED_TIME_MED].off_ms, 154410d599adSMaya Erez led_blink_time[WIL_LED_TIME_FAST].on_ms, 154510d599adSMaya Erez led_blink_time[WIL_LED_TIME_FAST].off_ms); 154610d599adSMaya Erez 154710d599adSMaya Erez return simple_read_from_buffer(user_buf, count, ppos, text, 154810d599adSMaya Erez sizeof(text)); 154910d599adSMaya Erez } 155010d599adSMaya Erez 155110d599adSMaya Erez static const struct file_operations fops_led_blink_time = { 155210d599adSMaya Erez .read = wil_read_led_blink_time, 155310d599adSMaya Erez .write = wil_write_led_blink_time, 155410d599adSMaya Erez .open = simple_open, 155510d599adSMaya Erez }; 155610d599adSMaya Erez 155712bace75SLior David /*---------FW capabilities------------*/ 155812bace75SLior David static int wil_fw_capabilities_debugfs_show(struct seq_file *s, void *data) 155912bace75SLior David { 156012bace75SLior David struct wil6210_priv *wil = s->private; 156112bace75SLior David 156212bace75SLior David seq_printf(s, "fw_capabilities : %*pb\n", WMI_FW_CAPABILITY_MAX, 156312bace75SLior David wil->fw_capabilities); 156412bace75SLior David 156512bace75SLior David return 0; 156612bace75SLior David } 156712bace75SLior David 156812bace75SLior David static int wil_fw_capabilities_seq_open(struct inode *inode, struct file *file) 156912bace75SLior David { 157012bace75SLior David return single_open(file, wil_fw_capabilities_debugfs_show, 157112bace75SLior David inode->i_private); 157212bace75SLior David } 157312bace75SLior David 157412bace75SLior David static const struct file_operations fops_fw_capabilities = { 157512bace75SLior David .open = wil_fw_capabilities_seq_open, 157612bace75SLior David .release = single_release, 157712bace75SLior David .read = seq_read, 157812bace75SLior David .llseek = seq_lseek, 157912bace75SLior David }; 158012bace75SLior David 158113cd9f75SLior David /*---------FW version------------*/ 158213cd9f75SLior David static int wil_fw_version_debugfs_show(struct seq_file *s, void *data) 158313cd9f75SLior David { 158413cd9f75SLior David struct wil6210_priv *wil = s->private; 158513cd9f75SLior David 158613cd9f75SLior David if (wil->fw_version[0]) 158713cd9f75SLior David seq_printf(s, "%s\n", wil->fw_version); 158813cd9f75SLior David else 158913cd9f75SLior David seq_puts(s, "N/A\n"); 159013cd9f75SLior David 159113cd9f75SLior David return 0; 159213cd9f75SLior David } 159313cd9f75SLior David 159413cd9f75SLior David static int wil_fw_version_seq_open(struct inode *inode, struct file *file) 159513cd9f75SLior David { 159613cd9f75SLior David return single_open(file, wil_fw_version_debugfs_show, 159713cd9f75SLior David inode->i_private); 159813cd9f75SLior David } 159913cd9f75SLior David 160013cd9f75SLior David static const struct file_operations fops_fw_version = { 160113cd9f75SLior David .open = wil_fw_version_seq_open, 160213cd9f75SLior David .release = single_release, 160313cd9f75SLior David .read = seq_read, 160413cd9f75SLior David .llseek = seq_lseek, 160513cd9f75SLior David }; 160613cd9f75SLior David 16072be7d22fSVladimir Kondratiev /*----------------*/ 1608b541d0a0SVladimir Kondratiev static void wil6210_debugfs_init_blobs(struct wil6210_priv *wil, 1609b541d0a0SVladimir Kondratiev struct dentry *dbg) 1610b541d0a0SVladimir Kondratiev { 1611b541d0a0SVladimir Kondratiev int i; 1612b541d0a0SVladimir Kondratiev char name[32]; 1613b541d0a0SVladimir Kondratiev 1614b541d0a0SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) { 1615349214c1SMaya Erez struct wil_blob_wrapper *wil_blob = &wil->blobs[i]; 1616349214c1SMaya Erez struct debugfs_blob_wrapper *blob = &wil_blob->blob; 1617b541d0a0SVladimir Kondratiev const struct fw_map *map = &fw_mapping[i]; 1618b541d0a0SVladimir Kondratiev 1619b541d0a0SVladimir Kondratiev if (!map->name) 1620b541d0a0SVladimir Kondratiev continue; 1621b541d0a0SVladimir Kondratiev 1622349214c1SMaya Erez wil_blob->wil = wil; 1623b541d0a0SVladimir Kondratiev blob->data = (void * __force)wil->csr + HOSTADDR(map->host); 1624b541d0a0SVladimir Kondratiev blob->size = map->to - map->from; 1625b541d0a0SVladimir Kondratiev snprintf(name, sizeof(name), "blob_%s", map->name); 162678484c44SMaya Erez wil_debugfs_create_ioblob(name, 0444, dbg, wil_blob); 1627b541d0a0SVladimir Kondratiev } 1628b541d0a0SVladimir Kondratiev } 1629b541d0a0SVladimir Kondratiev 1630b7cde470SVladimir Kondratiev /* misc files */ 1631b7cde470SVladimir Kondratiev static const struct { 1632b7cde470SVladimir Kondratiev const char *name; 1633b7cde470SVladimir Kondratiev umode_t mode; 1634b7cde470SVladimir Kondratiev const struct file_operations *fops; 1635b7cde470SVladimir Kondratiev } dbg_files[] = { 163678484c44SMaya Erez {"mbox", 0444, &fops_mbox}, 163778484c44SMaya Erez {"vrings", 0444, &fops_vring}, 163878484c44SMaya Erez {"stations", 0444, &fops_sta}, 163978484c44SMaya Erez {"desc", 0444, &fops_txdesc}, 164078484c44SMaya Erez {"bf", 0444, &fops_bf}, 164178484c44SMaya Erez {"ssid", 0644, &fops_ssid}, 164278484c44SMaya Erez {"mem_val", 0644, &fops_memread}, 164378484c44SMaya Erez {"reset", 0244, &fops_reset}, 164478484c44SMaya Erez {"rxon", 0244, &fops_rxon}, 164578484c44SMaya Erez {"tx_mgmt", 0244, &fops_txmgmt}, 164678484c44SMaya Erez {"wmi_send", 0244, &fops_wmi}, 164778484c44SMaya Erez {"back", 0644, &fops_back}, 164878484c44SMaya Erez {"pmccfg", 0644, &fops_pmccfg}, 164978484c44SMaya Erez {"pmcdata", 0444, &fops_pmcdata}, 165078484c44SMaya Erez {"temp", 0444, &fops_temp}, 165178484c44SMaya Erez {"freq", 0444, &fops_freq}, 165278484c44SMaya Erez {"link", 0444, &fops_link}, 165378484c44SMaya Erez {"info", 0444, &fops_info}, 165478484c44SMaya Erez {"recovery", 0644, &fops_recovery}, 165578484c44SMaya Erez {"led_cfg", 0644, &fops_led_cfg}, 165678484c44SMaya Erez {"led_blink_time", 0644, &fops_led_blink_time}, 165778484c44SMaya Erez {"fw_capabilities", 0444, &fops_fw_capabilities}, 165878484c44SMaya Erez {"fw_version", 0444, &fops_fw_version}, 1659b7cde470SVladimir Kondratiev }; 1660b7cde470SVladimir Kondratiev 1661b7cde470SVladimir Kondratiev static void wil6210_debugfs_init_files(struct wil6210_priv *wil, 1662b7cde470SVladimir Kondratiev struct dentry *dbg) 1663b7cde470SVladimir Kondratiev { 1664b7cde470SVladimir Kondratiev int i; 1665b7cde470SVladimir Kondratiev 1666b7cde470SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(dbg_files); i++) 1667b7cde470SVladimir Kondratiev debugfs_create_file(dbg_files[i].name, dbg_files[i].mode, dbg, 1668b7cde470SVladimir Kondratiev wil, dbg_files[i].fops); 1669b7cde470SVladimir Kondratiev } 1670b7cde470SVladimir Kondratiev 1671b7cde470SVladimir Kondratiev /* interrupt control blocks */ 1672b7cde470SVladimir Kondratiev static const struct { 1673b7cde470SVladimir Kondratiev const char *name; 1674b7cde470SVladimir Kondratiev u32 icr_off; 1675b7cde470SVladimir Kondratiev } dbg_icr[] = { 1676b7cde470SVladimir Kondratiev {"USER_ICR", HOSTADDR(RGF_USER_USER_ICR)}, 1677b7cde470SVladimir Kondratiev {"DMA_EP_TX_ICR", HOSTADDR(RGF_DMA_EP_TX_ICR)}, 1678b7cde470SVladimir Kondratiev {"DMA_EP_RX_ICR", HOSTADDR(RGF_DMA_EP_RX_ICR)}, 1679b7cde470SVladimir Kondratiev {"DMA_EP_MISC_ICR", HOSTADDR(RGF_DMA_EP_MISC_ICR)}, 1680b7cde470SVladimir Kondratiev }; 1681b7cde470SVladimir Kondratiev 1682b7cde470SVladimir Kondratiev static void wil6210_debugfs_init_isr(struct wil6210_priv *wil, 1683b7cde470SVladimir Kondratiev struct dentry *dbg) 1684b7cde470SVladimir Kondratiev { 1685b7cde470SVladimir Kondratiev int i; 1686b7cde470SVladimir Kondratiev 1687b7cde470SVladimir Kondratiev for (i = 0; i < ARRAY_SIZE(dbg_icr); i++) 1688b7cde470SVladimir Kondratiev wil6210_debugfs_create_ISR(wil, dbg_icr[i].name, dbg, 1689b7cde470SVladimir Kondratiev dbg_icr[i].icr_off); 1690b7cde470SVladimir Kondratiev } 1691b7cde470SVladimir Kondratiev 1692b7cde470SVladimir Kondratiev #define WIL_FIELD(name, mode, type) { __stringify(name), mode, \ 1693b7cde470SVladimir Kondratiev offsetof(struct wil6210_priv, name), type} 1694b7cde470SVladimir Kondratiev 1695b7cde470SVladimir Kondratiev /* fields in struct wil6210_priv */ 1696b7cde470SVladimir Kondratiev static const struct dbg_off dbg_wil_off[] = { 169778484c44SMaya Erez WIL_FIELD(privacy, 0444, doff_u32), 169878484c44SMaya Erez WIL_FIELD(status[0], 0644, doff_ulong), 169978484c44SMaya Erez WIL_FIELD(hw_version, 0444, doff_x32), 170078484c44SMaya Erez WIL_FIELD(recovery_count, 0444, doff_u32), 170178484c44SMaya Erez WIL_FIELD(ap_isolate, 0444, doff_u32), 170278484c44SMaya Erez WIL_FIELD(discovery_mode, 0644, doff_u8), 170378484c44SMaya Erez WIL_FIELD(chip_revision, 0444, doff_u8), 170478484c44SMaya Erez WIL_FIELD(abft_len, 0644, doff_u8), 1705b7cde470SVladimir Kondratiev {}, 1706b7cde470SVladimir Kondratiev }; 1707b7cde470SVladimir Kondratiev 1708b7cde470SVladimir Kondratiev static const struct dbg_off dbg_wil_regs[] = { 170978484c44SMaya Erez {"RGF_MAC_MTRL_COUNTER_0", 0444, HOSTADDR(RGF_MAC_MTRL_COUNTER_0), 1710b7cde470SVladimir Kondratiev doff_io32}, 171178484c44SMaya Erez {"RGF_USER_USAGE_1", 0444, HOSTADDR(RGF_USER_USAGE_1), doff_io32}, 1712b7cde470SVladimir Kondratiev {}, 1713b7cde470SVladimir Kondratiev }; 1714b7cde470SVladimir Kondratiev 1715b7cde470SVladimir Kondratiev /* static parameters */ 1716b7cde470SVladimir Kondratiev static const struct dbg_off dbg_statics[] = { 171778484c44SMaya Erez {"desc_index", 0644, (ulong)&dbg_txdesc_index, doff_u32}, 171878484c44SMaya Erez {"vring_index", 0644, (ulong)&dbg_vring_index, doff_u32}, 171978484c44SMaya Erez {"mem_addr", 0644, (ulong)&mem_addr, doff_u32}, 172078484c44SMaya Erez {"vring_idle_trsh", 0644, (ulong)&vring_idle_trsh, 17210436fd9aSVladimir Shulman doff_u32}, 172278484c44SMaya Erez {"led_polarity", 0644, (ulong)&led_polarity, doff_u8}, 1723b7cde470SVladimir Kondratiev {}, 1724b7cde470SVladimir Kondratiev }; 1725b7cde470SVladimir Kondratiev 17262be7d22fSVladimir Kondratiev int wil6210_debugfs_init(struct wil6210_priv *wil) 17272be7d22fSVladimir Kondratiev { 17282be7d22fSVladimir Kondratiev struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME, 17292be7d22fSVladimir Kondratiev wil_to_wiphy(wil)->debugfsdir); 17302be7d22fSVladimir Kondratiev 17312be7d22fSVladimir Kondratiev if (IS_ERR_OR_NULL(dbg)) 17322be7d22fSVladimir Kondratiev return -ENODEV; 17332be7d22fSVladimir Kondratiev 1734dc16427bSVladimir Kondratiev wil_pmc_init(wil); 1735dc16427bSVladimir Kondratiev 1736b7cde470SVladimir Kondratiev wil6210_debugfs_init_files(wil, dbg); 1737b7cde470SVladimir Kondratiev wil6210_debugfs_init_isr(wil, dbg); 1738b541d0a0SVladimir Kondratiev wil6210_debugfs_init_blobs(wil, dbg); 1739b7cde470SVladimir Kondratiev wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off); 1740b7cde470SVladimir Kondratiev wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr, 1741b7cde470SVladimir Kondratiev dbg_wil_regs); 1742b7cde470SVladimir Kondratiev wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics); 1743b7cde470SVladimir Kondratiev 1744b7cde470SVladimir Kondratiev wil6210_debugfs_create_pseudo_ISR(wil, dbg); 1745b7cde470SVladimir Kondratiev 1746b7cde470SVladimir Kondratiev wil6210_debugfs_create_ITR_CNT(wil, dbg); 17472be7d22fSVladimir Kondratiev 17482be7d22fSVladimir Kondratiev return 0; 17492be7d22fSVladimir Kondratiev } 17502be7d22fSVladimir Kondratiev 17512be7d22fSVladimir Kondratiev void wil6210_debugfs_remove(struct wil6210_priv *wil) 17522be7d22fSVladimir Kondratiev { 17532be7d22fSVladimir Kondratiev debugfs_remove_recursive(wil->debug); 17542be7d22fSVladimir Kondratiev wil->debug = NULL; 1755dc16427bSVladimir Kondratiev 1756dc16427bSVladimir Kondratiev /* free pmc memory without sending command to fw, as it will 1757dc16427bSVladimir Kondratiev * be reset on the way down anyway 1758dc16427bSVladimir Kondratiev */ 1759dc16427bSVladimir Kondratiev wil_pmc_free(wil, false); 17602be7d22fSVladimir Kondratiev } 1761