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