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