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