2 * Copyright (c) 2012-2016 Qualcomm Atheros, Inc.
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.
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.
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 #include <linux/power_supply.h>
29 /* Nasty hack. Better have per device instances */
31 static u32 dbg_txdesc_index;
32 static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
33 u32 vring_idle_trsh = 16; /* HW fetches up to 16 descriptors at once */
48 enum dbg_off_type type;
51 static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
52 const char *name, struct vring *vring,
55 void __iomem *x = wmi_addr(wil, vring->hwtail);
58 seq_printf(s, "VRING %s = {\n", name);
59 seq_printf(s, " pa = %pad\n", &vring->pa);
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);
67 seq_printf(s, "0x%08x = %d\n", v, v);
72 if (vring->va && (vring->size <= (1 << WIL_RING_SIZE_ORDER_MAX))) {
75 for (i = 0; i < vring->size; i++) {
76 volatile struct vring_tx_desc *d = &vring->va[i].tx;
78 if ((i % 128) == 0 && (i != 0))
80 seq_printf(s, "%c", (d->dma.status & BIT(0)) ?
81 _s : (vring->ctx[i].skb ? _h : 'h'));
88 static int wil_vring_debugfs_show(struct seq_file *s, void *data)
91 struct wil6210_priv *wil = s->private;
93 wil_print_vring(s, wil, "rx", &wil->vring_rx, 'S', '_');
95 for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) {
96 struct vring *vring = &wil->vring_tx[i];
97 struct vring_tx_data *txdata = &wil->vring_tx_data[i];
100 int cid = wil->vring2cid_tid[i][0];
101 int tid = wil->vring2cid_tid[i][1];
102 u32 swhead = vring->swhead;
103 u32 swtail = vring->swtail;
104 int used = (vring->size + swhead - swtail)
106 int avail = vring->size - used - 1;
109 /* performance monitoring */
110 cycles_t now = get_cycles();
111 uint64_t idle = txdata->idle * 100;
112 uint64_t total = now - txdata->begin;
116 snprintf(sidle, sizeof(sidle), "%3d%%",
119 snprintf(sidle, sizeof(sidle), "N/A");
124 snprintf(name, sizeof(name), "tx_%2d", i);
126 if (cid < WIL6210_MAX_CID)
128 "\n%pM CID %d TID %d 1x%s BACK([%u] %u TU A%s) [%3d|%3d] idle %s\n",
129 wil->sta[cid].addr, cid, tid,
130 txdata->dot1x_open ? "+" : "-",
133 txdata->agg_amsdu ? "+" : "-",
137 "\nBroadcast 1x%s [%3d|%3d] idle %s\n",
138 txdata->dot1x_open ? "+" : "-",
141 wil_print_vring(s, wil, name, vring, '_', 'H');
148 static int wil_vring_seq_open(struct inode *inode, struct file *file)
150 return single_open(file, wil_vring_debugfs_show, inode->i_private);
153 static const struct file_operations fops_vring = {
154 .open = wil_vring_seq_open,
155 .release = single_release,
160 static void wil_seq_hexdump(struct seq_file *s, void *p, int len,
163 seq_hex_dump(s, prefix, DUMP_PREFIX_NONE, 16, 1, p, len, false);
166 static void wil_print_ring(struct seq_file *s, const char *prefix,
169 struct wil6210_priv *wil = s->private;
170 struct wil6210_mbox_ring r;
176 wil_memcpy_fromio_32(&r, off, sizeof(r));
177 wil_mbox_ring_le2cpus(&r);
179 * we just read memory block from NIC. This memory may be
180 * garbage. Check validity before using it.
182 rsize = r.size / sizeof(struct wil6210_mbox_ring_desc);
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);
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));
197 if (!wmi_addr(wil, r.base) ||
198 !wmi_addr(wil, r.tail) ||
199 !wmi_addr(wil, r.head)) {
200 seq_puts(s, " ??? pointers are garbage?\n");
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;
210 wil_memcpy_fromio_32(&d, x, sizeof(d));
212 seq_printf(s, " [%2x] %s %s%s 0x%08x", i,
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);
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) {
224 unsigned char databuf[MAX_MBOXITEM_SIZE];
225 void __iomem *src = wmi_buffer(wil, d.addr) +
226 sizeof(struct wil6210_mbox_hdr);
228 * No need to check @src for validity -
229 * we already validated @d.addr while
232 wil_memcpy_fromio_32(databuf, src, len);
233 wil_seq_hexdump(s, databuf, len, " : ");
241 wil_halp_unvote(wil);
244 static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
246 struct wil6210_priv *wil = s->private;
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));
256 static int wil_mbox_seq_open(struct inode *inode, struct file *file)
258 return single_open(file, wil_mbox_debugfs_show, inode->i_private);
261 static const struct file_operations fops_mbox = {
262 .open = wil_mbox_seq_open,
263 .release = single_release,
268 static int wil_debugfs_iomem_x32_set(void *data, u64 val)
270 writel(val, (void __iomem *)data);
271 wmb(); /* make sure write propagated to HW */
276 static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
278 *val = readl((void __iomem *)data);
283 DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
284 wil_debugfs_iomem_x32_set, "0x%08llx\n");
286 static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
288 struct dentry *parent,
291 return debugfs_create_file(name, mode, parent, value,
295 static int wil_debugfs_ulong_set(void *data, u64 val)
297 *(ulong *)data = val;
301 static int wil_debugfs_ulong_get(void *data, u64 *val)
303 *val = *(ulong *)data;
307 DEFINE_SIMPLE_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get,
308 wil_debugfs_ulong_set, "0x%llx\n");
310 static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode,
311 struct dentry *parent,
314 return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong);
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.
324 * Creates files accordingly to the @tbl.
326 static void wil6210_debugfs_init_offset(struct wil6210_priv *wil,
327 struct dentry *dbg, void *base,
328 const struct dbg_off * const tbl)
332 for (i = 0; tbl[i].name; i++) {
335 switch (tbl[i].type) {
337 f = debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg,
341 f = debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg,
345 f = wil_debugfs_create_ulong(tbl[i].name, tbl[i].mode,
346 dbg, base + tbl[i].off);
349 f = wil_debugfs_create_iomem_x32(tbl[i].name,
354 f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg,
358 f = ERR_PTR(-EINVAL);
360 if (IS_ERR_OR_NULL(f))
361 wil_err(wil, "Create file \"%s\": err %ld\n",
362 tbl[i].name, PTR_ERR(f));
366 static const struct dbg_off isr_off[] = {
367 {"ICC", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICC), doff_io32},
368 {"ICR", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICR), doff_io32},
369 {"ICM", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICM), doff_io32},
370 {"ICS", S_IWUSR, offsetof(struct RGF_ICR, ICS), doff_io32},
371 {"IMV", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, IMV), doff_io32},
372 {"IMS", S_IWUSR, offsetof(struct RGF_ICR, IMS), doff_io32},
373 {"IMC", S_IWUSR, offsetof(struct RGF_ICR, IMC), doff_io32},
377 static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
379 struct dentry *parent, u32 off)
381 struct dentry *d = debugfs_create_dir(name, parent);
383 if (IS_ERR_OR_NULL(d))
386 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr + off,
392 static const struct dbg_off pseudo_isr_off[] = {
393 {"CAUSE", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32},
394 {"MASK_SW", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32},
395 {"MASK_FW", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32},
399 static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
400 struct dentry *parent)
402 struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent);
404 if (IS_ERR_OR_NULL(d))
407 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
413 static const struct dbg_off lgc_itr_cnt_off[] = {
414 {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32},
415 {"DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32},
416 {"CTL", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32},
420 static const struct dbg_off tx_itr_cnt_off[] = {
421 {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_CNT_TRSH),
423 {"DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_CNT_DATA),
425 {"CTL", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_CNT_CTL),
427 {"IDL_TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_TRSH),
429 {"IDL_DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_DATA),
431 {"IDL_CTL", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_CTL),
436 static const struct dbg_off rx_itr_cnt_off[] = {
437 {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_CNT_TRSH),
439 {"DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_CNT_DATA),
441 {"CTL", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_CNT_CTL),
443 {"IDL_TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_TRSH),
445 {"IDL_DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_DATA),
447 {"IDL_CTL", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_CTL),
452 static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
453 struct dentry *parent)
455 struct dentry *d, *dtx, *drx;
457 d = debugfs_create_dir("ITR_CNT", parent);
458 if (IS_ERR_OR_NULL(d))
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))
466 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
469 wil6210_debugfs_init_offset(wil, dtx, (void * __force)wil->csr,
472 wil6210_debugfs_init_offset(wil, drx, (void * __force)wil->csr,
477 static int wil_memread_debugfs_show(struct seq_file *s, void *data)
479 struct wil6210_priv *wil = s->private;
480 void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr));
483 seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, readl(a));
485 seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
490 static int wil_memread_seq_open(struct inode *inode, struct file *file)
492 return single_open(file, wil_memread_debugfs_show, inode->i_private);
495 static const struct file_operations fops_memread = {
496 .open = wil_memread_seq_open,
497 .release = single_release,
502 static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
503 size_t count, loff_t *ppos)
505 enum { max_count = 4096 };
506 struct wil_blob_wrapper *wil_blob = file->private_data;
508 size_t available = wil_blob->blob.size;
515 if (pos >= available || !count)
518 if (count > available - pos)
519 count = available - pos;
520 if (count > max_count)
523 buf = kmalloc(count, GFP_KERNEL);
527 wil_memcpy_fromio_halp_vote(wil_blob->wil, buf,
528 (const volatile void __iomem *)
529 wil_blob->blob.data + pos, count);
531 ret = copy_to_user(user_buf, buf, count);
542 static const struct file_operations fops_ioblob = {
543 .read = wil_read_file_ioblob,
545 .llseek = default_llseek,
549 struct dentry *wil_debugfs_create_ioblob(const char *name,
551 struct dentry *parent,
552 struct wil_blob_wrapper *wil_blob)
554 return debugfs_create_file(name, mode, parent, wil_blob, &fops_ioblob);
558 static ssize_t wil_write_file_reset(struct file *file, const char __user *buf,
559 size_t len, loff_t *ppos)
561 struct wil6210_priv *wil = file->private_data;
562 struct net_device *ndev = wil_to_ndev(wil);
566 * this code does NOT sync device state with the rest of system
567 * use with care, debug only!!!
571 ndev->flags &= ~IFF_UP;
573 wil_reset(wil, true);
578 static const struct file_operations fops_reset = {
579 .write = wil_write_file_reset,
583 /*---write channel 1..4 to rxon for it, 0 to rxoff---*/
584 static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
585 size_t len, loff_t *ppos)
587 struct wil6210_priv *wil = file->private_data;
592 char *kbuf = memdup_user_nul(buf, len);
595 return PTR_ERR(kbuf);
596 rc = kstrtol(kbuf, 0, &channel);
601 if ((channel < 0) || (channel > 4)) {
602 wil_err(wil, "Invalid channel %ld\n", channel);
608 rc = wmi_set_channel(wil, (int)channel);
613 rc = wmi_rxon(wil, on);
620 static const struct file_operations fops_rxon = {
621 .write = wil_write_file_rxon,
625 /* block ack control, write:
626 * - "add <ringid> <agg_size> <timeout>" to trigger ADDBA
627 * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side
628 * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side
630 static ssize_t wil_write_back(struct file *file, const char __user *buf,
631 size_t len, loff_t *ppos)
633 struct wil6210_priv *wil = file->private_data;
635 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
642 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
645 return rc >= 0 ? -EIO : rc;
649 rc = sscanf(kbuf, "%8s %d %d %d", cmd, &p1, &p2, &p3);
657 if (0 == strcmp(cmd, "add")) {
659 wil_err(wil, "BACK: add require at least 2 params\n");
664 wmi_addba(wil, p1, p2, p3);
665 } else if (0 == strcmp(cmd, "del_tx")) {
667 p2 = WLAN_REASON_QSTA_LEAVE_QBSS;
668 wmi_delba_tx(wil, p1, p2);
669 } else if (0 == strcmp(cmd, "del_rx")) {
672 "BACK: del_rx require at least 2 params\n");
676 p3 = WLAN_REASON_QSTA_LEAVE_QBSS;
677 wmi_delba_rx(wil, mk_cidxtid(p1, p2), p3);
679 wil_err(wil, "BACK: Unrecognized command \"%s\"\n", cmd);
686 static ssize_t wil_read_back(struct file *file, char __user *user_buf,
687 size_t count, loff_t *ppos)
689 static const char text[] = "block ack control, write:\n"
690 " - \"add <ringid> <agg_size> <timeout>\" to trigger ADDBA\n"
691 "If missing, <timeout> defaults to 0\n"
692 " - \"del_tx <ringid> <reason>\" to trigger DELBA for Tx side\n"
693 " - \"del_rx <CID> <TID> <reason>\" to trigger DELBA for Rx side\n"
694 "If missing, <reason> set to \"STA_LEAVING\" (36)\n";
696 return simple_read_from_buffer(user_buf, count, ppos, text,
700 static const struct file_operations fops_back = {
701 .read = wil_read_back,
702 .write = wil_write_back,
706 /* pmc control, write:
707 * - "alloc <num descriptors> <descriptor_size>" to allocate PMC
708 * - "free" to release memory allocated for PMC
710 static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
711 size_t len, loff_t *ppos)
713 struct wil6210_priv *wil = file->private_data;
715 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
717 int num_descs, desc_size;
722 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
725 return rc >= 0 ? -EIO : rc;
729 rc = sscanf(kbuf, "%8s %d %d", cmd, &num_descs, &desc_size);
736 wil_err(wil, "pmccfg: no params given\n");
740 if (0 == strcmp(cmd, "alloc")) {
742 wil_err(wil, "pmccfg: alloc requires 2 params\n");
745 wil_pmc_alloc(wil, num_descs, desc_size);
746 } else if (0 == strcmp(cmd, "free")) {
748 wil_err(wil, "pmccfg: free does not have any params\n");
751 wil_pmc_free(wil, true);
753 wil_err(wil, "pmccfg: Unrecognized command \"%s\"\n", cmd);
760 static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
761 size_t count, loff_t *ppos)
763 struct wil6210_priv *wil = file->private_data;
765 char help[] = "pmc control, write:\n"
766 " - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
767 " - \"free\" to free memory allocated for pmc\n";
769 sprintf(text, "Last command status: %d\n\n%s",
770 wil_pmc_last_cmd_status(wil),
773 return simple_read_from_buffer(user_buf, count, ppos, text,
777 static const struct file_operations fops_pmccfg = {
778 .read = wil_read_pmccfg,
779 .write = wil_write_pmccfg,
783 static const struct file_operations fops_pmcdata = {
785 .read = wil_pmc_read,
786 .llseek = wil_pmc_llseek,
790 /* Write mgmt frame to this file to send it */
791 static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
792 size_t len, loff_t *ppos)
794 struct wil6210_priv *wil = file->private_data;
795 struct wiphy *wiphy = wil_to_wiphy(wil);
796 struct wireless_dev *wdev = wil_to_wdev(wil);
797 struct cfg80211_mgmt_tx_params params;
799 void *frame = kmalloc(len, GFP_KERNEL);
804 if (copy_from_user(frame, buf, len)) {
811 params.chan = wdev->preset_chandef.chan;
813 rc = wil_cfg80211_mgmt_tx(wiphy, wdev, ¶ms, NULL);
816 wil_info(wil, "%s() -> %d\n", __func__, rc);
821 static const struct file_operations fops_txmgmt = {
822 .write = wil_write_file_txmgmt,
826 /* Write WMI command (w/o mbox header) to this file to send it
827 * WMI starts from wil6210_mbox_hdr_wmi header
829 static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
830 size_t len, loff_t *ppos)
832 struct wil6210_priv *wil = file->private_data;
833 struct wmi_cmd_hdr *wmi;
835 int cmdlen = len - sizeof(struct wmi_cmd_hdr);
842 wmi = kmalloc(len, GFP_KERNEL);
846 rc = simple_write_to_buffer(wmi, len, ppos, buf, len);
852 cmd = (cmdlen > 0) ? &wmi[1] : NULL;
853 cmdid = le16_to_cpu(wmi->command_id);
855 rc1 = wmi_send(wil, cmdid, cmd, cmdlen);
858 wil_info(wil, "%s(0x%04x[%d]) -> %d\n", __func__, cmdid, cmdlen, rc1);
863 static const struct file_operations fops_wmi = {
864 .write = wil_write_file_wmi,
868 static void wil_seq_print_skb(struct seq_file *s, struct sk_buff *skb)
871 int len = skb_headlen(skb);
873 int nr_frags = skb_shinfo(skb)->nr_frags;
875 seq_printf(s, " len = %d\n", len);
876 wil_seq_hexdump(s, p, len, " : ");
879 seq_printf(s, " nr_frags = %d\n", nr_frags);
880 for (i = 0; i < nr_frags; i++) {
881 const struct skb_frag_struct *frag =
882 &skb_shinfo(skb)->frags[i];
884 len = skb_frag_size(frag);
885 p = skb_frag_address_safe(frag);
886 seq_printf(s, " [%2d] : len = %d\n", i, len);
887 wil_seq_hexdump(s, p, len, " : ");
892 /*---------Tx/Rx descriptor------------*/
893 static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
895 struct wil6210_priv *wil = s->private;
897 bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS);
899 vring = tx ? &wil->vring_tx[dbg_vring_index] : &wil->vring_rx;
903 seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index);
905 seq_puts(s, "No Rx VRING\n");
909 if (dbg_txdesc_index < vring->size) {
910 /* use struct vring_tx_desc for Rx as well,
911 * only field used, .dma.length, is the same
913 volatile struct vring_tx_desc *d =
914 &vring->va[dbg_txdesc_index].tx;
915 volatile u32 *u = (volatile u32 *)d;
916 struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb;
919 seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index,
922 seq_printf(s, "Rx[%3d] = {\n", dbg_txdesc_index);
923 seq_printf(s, " MAC = 0x%08x 0x%08x 0x%08x 0x%08x\n",
924 u[0], u[1], u[2], u[3]);
925 seq_printf(s, " DMA = 0x%08x 0x%08x 0x%08x 0x%08x\n",
926 u[4], u[5], u[6], u[7]);
927 seq_printf(s, " SKB = 0x%p\n", skb);
931 wil_seq_print_skb(s, skb);
937 seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n",
938 dbg_vring_index, dbg_txdesc_index,
941 seq_printf(s, "RxDesc index (%d) >= size (%d)\n",
942 dbg_txdesc_index, vring->size);
948 static int wil_txdesc_seq_open(struct inode *inode, struct file *file)
950 return single_open(file, wil_txdesc_debugfs_show, inode->i_private);
953 static const struct file_operations fops_txdesc = {
954 .open = wil_txdesc_seq_open,
955 .release = single_release,
960 /*---------beamforming------------*/
961 static char *wil_bfstatus_str(u32 status)
975 static bool is_all_zeros(void * const x_, size_t sz)
977 /* if reply is all-0, ignore this CID */
981 for (n = 0; n < sz / sizeof(*x); n++)
988 static int wil_bf_debugfs_show(struct seq_file *s, void *data)
992 struct wil6210_priv *wil = s->private;
993 struct wmi_notify_req_cmd cmd = {
997 struct wmi_cmd_hdr wmi;
998 struct wmi_notify_req_done_event evt;
1001 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
1005 rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
1006 WMI_NOTIFY_REQ_DONE_EVENTID, &reply,
1008 /* if reply is all-0, ignore this CID */
1009 if (rc || is_all_zeros(&reply.evt, sizeof(reply.evt)))
1012 status = le32_to_cpu(reply.evt.status);
1013 seq_printf(s, "CID %d {\n"
1014 " TSF = 0x%016llx\n"
1015 " TxMCS = %2d TxTpt = %4d\n"
1017 " Status = 0x%08x %s\n"
1018 " Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n"
1019 " Goodput(rx:tx) %4d:%4d\n"
1022 le64_to_cpu(reply.evt.tsf),
1023 le16_to_cpu(reply.evt.bf_mcs),
1024 le32_to_cpu(reply.evt.tx_tpt),
1026 status, wil_bfstatus_str(status),
1027 le16_to_cpu(reply.evt.my_rx_sector),
1028 le16_to_cpu(reply.evt.my_tx_sector),
1029 le16_to_cpu(reply.evt.other_rx_sector),
1030 le16_to_cpu(reply.evt.other_tx_sector),
1031 le32_to_cpu(reply.evt.rx_goodput),
1032 le32_to_cpu(reply.evt.tx_goodput));
1037 static int wil_bf_seq_open(struct inode *inode, struct file *file)
1039 return single_open(file, wil_bf_debugfs_show, inode->i_private);
1042 static const struct file_operations fops_bf = {
1043 .open = wil_bf_seq_open,
1044 .release = single_release,
1046 .llseek = seq_lseek,
1049 /*---------SSID------------*/
1050 static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf,
1051 size_t count, loff_t *ppos)
1053 struct wil6210_priv *wil = file->private_data;
1054 struct wireless_dev *wdev = wil_to_wdev(wil);
1056 return simple_read_from_buffer(user_buf, count, ppos,
1057 wdev->ssid, wdev->ssid_len);
1060 static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf,
1061 size_t count, loff_t *ppos)
1063 struct wil6210_priv *wil = file->private_data;
1064 struct wireless_dev *wdev = wil_to_wdev(wil);
1065 struct net_device *ndev = wil_to_ndev(wil);
1068 wil_err(wil, "Unable to set SSID substring from [%d]\n",
1073 if (count > sizeof(wdev->ssid)) {
1074 wil_err(wil, "SSID too long, len = %d\n", (int)count);
1077 if (netif_running(ndev)) {
1078 wil_err(wil, "Unable to change SSID on running interface\n");
1082 wdev->ssid_len = count;
1083 return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos,
1087 static const struct file_operations fops_ssid = {
1088 .read = wil_read_file_ssid,
1089 .write = wil_write_file_ssid,
1090 .open = simple_open,
1093 /*---------temp------------*/
1094 static void print_temp(struct seq_file *s, const char *prefix, s32 t)
1099 seq_printf(s, "%s N/A\n", prefix);
1102 seq_printf(s, "%s %s%d.%03d\n", prefix, (t < 0 ? "-" : ""),
1103 abs(t / 1000), abs(t % 1000));
1108 static int wil_temp_debugfs_show(struct seq_file *s, void *data)
1110 struct wil6210_priv *wil = s->private;
1112 int rc = wmi_get_temperature(wil, &t_m, &t_r);
1115 seq_puts(s, "Failed\n");
1119 print_temp(s, "T_mac =", t_m);
1120 print_temp(s, "T_radio =", t_r);
1125 static int wil_temp_seq_open(struct inode *inode, struct file *file)
1127 return single_open(file, wil_temp_debugfs_show, inode->i_private);
1130 static const struct file_operations fops_temp = {
1131 .open = wil_temp_seq_open,
1132 .release = single_release,
1134 .llseek = seq_lseek,
1137 /*---------freq------------*/
1138 static int wil_freq_debugfs_show(struct seq_file *s, void *data)
1140 struct wil6210_priv *wil = s->private;
1141 struct wireless_dev *wdev = wil_to_wdev(wil);
1142 u16 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0;
1144 seq_printf(s, "Freq = %d\n", freq);
1149 static int wil_freq_seq_open(struct inode *inode, struct file *file)
1151 return single_open(file, wil_freq_debugfs_show, inode->i_private);
1154 static const struct file_operations fops_freq = {
1155 .open = wil_freq_seq_open,
1156 .release = single_release,
1158 .llseek = seq_lseek,
1161 /*---------link------------*/
1162 static int wil_link_debugfs_show(struct seq_file *s, void *data)
1164 struct wil6210_priv *wil = s->private;
1165 struct station_info sinfo;
1168 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
1169 struct wil_sta_info *p = &wil->sta[i];
1170 char *status = "unknown";
1172 switch (p->status) {
1173 case wil_sta_unused:
1176 case wil_sta_conn_pending:
1177 status = "pending ";
1179 case wil_sta_connected:
1180 status = "connected";
1183 seq_printf(s, "[%d] %pM %s\n", i, p->addr, status);
1185 if (p->status == wil_sta_connected) {
1186 rc = wil_cid_fill_sinfo(wil, i, &sinfo);
1190 seq_printf(s, " Tx_mcs = %d\n", sinfo.txrate.mcs);
1191 seq_printf(s, " Rx_mcs = %d\n", sinfo.rxrate.mcs);
1192 seq_printf(s, " SQ = %d\n", sinfo.signal);
1199 static int wil_link_seq_open(struct inode *inode, struct file *file)
1201 return single_open(file, wil_link_debugfs_show, inode->i_private);
1204 static const struct file_operations fops_link = {
1205 .open = wil_link_seq_open,
1206 .release = single_release,
1208 .llseek = seq_lseek,
1211 /*---------info------------*/
1212 static int wil_info_debugfs_show(struct seq_file *s, void *data)
1214 struct wil6210_priv *wil = s->private;
1215 struct net_device *ndev = wil_to_ndev(wil);
1216 int is_ac = power_supply_is_system_supplied();
1217 int rx = atomic_xchg(&wil->isr_count_rx, 0);
1218 int tx = atomic_xchg(&wil->isr_count_tx, 0);
1219 static ulong rxf_old, txf_old;
1220 ulong rxf = ndev->stats.rx_packets;
1221 ulong txf = ndev->stats.tx_packets;
1224 /* >0 : AC; 0 : battery; <0 : error */
1225 seq_printf(s, "AC powered : %d\n", is_ac);
1226 seq_printf(s, "Rx irqs:packets : %8d : %8ld\n", rx, rxf - rxf_old);
1227 seq_printf(s, "Tx irqs:packets : %8d : %8ld\n", tx, txf - txf_old);
1231 #define CHECK_QSTATE(x) (state & BIT(__QUEUE_STATE_ ## x)) ? \
1232 " " __stringify(x) : ""
1234 for (i = 0; i < ndev->num_tx_queues; i++) {
1235 struct netdev_queue *txq = netdev_get_tx_queue(ndev, i);
1236 unsigned long state = txq->state;
1238 seq_printf(s, "Tx queue[%i] state : 0x%lx%s%s%s\n", i, state,
1239 CHECK_QSTATE(DRV_XOFF),
1240 CHECK_QSTATE(STACK_XOFF),
1241 CHECK_QSTATE(FROZEN)
1248 static int wil_info_seq_open(struct inode *inode, struct file *file)
1250 return single_open(file, wil_info_debugfs_show, inode->i_private);
1253 static const struct file_operations fops_info = {
1254 .open = wil_info_seq_open,
1255 .release = single_release,
1257 .llseek = seq_lseek,
1260 /*---------recovery------------*/
1261 /* mode = [manual|auto]
1262 * state = [idle|pending|running]
1264 static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
1265 size_t count, loff_t *ppos)
1267 struct wil6210_priv *wil = file->private_data;
1270 static const char * const sstate[] = {"idle", "pending", "running"};
1272 n = snprintf(buf, sizeof(buf), "mode = %s\nstate = %s\n",
1273 no_fw_recovery ? "manual" : "auto",
1274 sstate[wil->recovery_state]);
1276 n = min_t(int, n, sizeof(buf));
1278 return simple_read_from_buffer(user_buf, count, ppos,
1282 static ssize_t wil_write_file_recovery(struct file *file,
1283 const char __user *buf_,
1284 size_t count, loff_t *ppos)
1286 struct wil6210_priv *wil = file->private_data;
1287 static const char run_command[] = "run";
1288 char buf[sizeof(run_command) + 1]; /* to detect "runx" */
1291 if (wil->recovery_state != fw_recovery_pending) {
1292 wil_err(wil, "No recovery pending\n");
1297 wil_err(wil, "Offset [%d]\n", (int)*ppos);
1301 if (count > sizeof(buf)) {
1302 wil_err(wil, "Input too long, len = %d\n", (int)count);
1306 rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, buf_, count);
1311 if (0 == strcmp(buf, run_command))
1312 wil_set_recovery_state(wil, fw_recovery_running);
1314 wil_err(wil, "Bad recovery command \"%s\"\n", buf);
1319 static const struct file_operations fops_recovery = {
1320 .read = wil_read_file_recovery,
1321 .write = wil_write_file_recovery,
1322 .open = simple_open,
1325 /*---------Station matrix------------*/
1326 static void wil_print_rxtid(struct seq_file *s, struct wil_tid_ampdu_rx *r)
1329 u16 index = ((r->head_seq_num - r->ssn) & 0xfff) % r->buf_size;
1330 unsigned long long drop_dup = r->drop_dup, drop_old = r->drop_old;
1332 seq_printf(s, "([%2d] %3d TU) 0x%03x [", r->buf_size, r->timeout,
1334 for (i = 0; i < r->buf_size; i++) {
1336 seq_printf(s, "%c", r->reorder_buf[i] ? 'O' : '|');
1338 seq_printf(s, "%c", r->reorder_buf[i] ? '*' : '_');
1341 "] total %llu drop %llu (dup %llu + old %llu) last 0x%03x\n",
1342 r->total, drop_dup + drop_old, drop_dup, drop_old,
1346 static void wil_print_rxtid_crypto(struct seq_file *s, int tid,
1347 struct wil_tid_crypto_rx *c)
1351 for (i = 0; i < 4; i++) {
1352 struct wil_tid_crypto_rx_single *cc = &c->key_id[i];
1360 if (tid < WIL_STA_TID_NUM)
1361 seq_printf(s, " [%2d] PN", tid);
1363 seq_puts(s, " [GR] PN");
1365 for (i = 0; i < 4; i++) {
1366 struct wil_tid_crypto_rx_single *cc = &c->key_id[i];
1368 seq_printf(s, " [%i%s]%6phN", i, cc->key_set ? "+" : "-",
1374 static int wil_sta_debugfs_show(struct seq_file *s, void *data)
1375 __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock)
1377 struct wil6210_priv *wil = s->private;
1380 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
1381 struct wil_sta_info *p = &wil->sta[i];
1382 char *status = "unknown";
1384 switch (p->status) {
1385 case wil_sta_unused:
1388 case wil_sta_conn_pending:
1389 status = "pending ";
1391 case wil_sta_connected:
1392 status = "connected";
1395 seq_printf(s, "[%d] %pM %s\n", i, p->addr, status);
1397 if (p->status == wil_sta_connected) {
1398 spin_lock_bh(&p->tid_rx_lock);
1399 for (tid = 0; tid < WIL_STA_TID_NUM; tid++) {
1400 struct wil_tid_ampdu_rx *r = p->tid_rx[tid];
1401 struct wil_tid_crypto_rx *c =
1402 &p->tid_crypto_rx[tid];
1405 seq_printf(s, " [%2d] ", tid);
1406 wil_print_rxtid(s, r);
1409 wil_print_rxtid_crypto(s, tid, c);
1411 wil_print_rxtid_crypto(s, WIL_STA_TID_NUM,
1412 &p->group_crypto_rx);
1413 spin_unlock_bh(&p->tid_rx_lock);
1415 "Rx invalid frame: non-data %lu, short %lu, large %lu, replay %lu\n",
1416 p->stats.rx_non_data_frame,
1417 p->stats.rx_short_frame,
1418 p->stats.rx_large_frame,
1419 p->stats.rx_replay);
1421 seq_puts(s, "Rx/MCS:");
1422 for (mcs = 0; mcs < ARRAY_SIZE(p->stats.rx_per_mcs);
1424 seq_printf(s, " %lld",
1425 p->stats.rx_per_mcs[mcs]);
1433 static int wil_sta_seq_open(struct inode *inode, struct file *file)
1435 return single_open(file, wil_sta_debugfs_show, inode->i_private);
1438 static const struct file_operations fops_sta = {
1439 .open = wil_sta_seq_open,
1440 .release = single_release,
1442 .llseek = seq_lseek,
1445 static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
1446 size_t count, loff_t *ppos)
1451 n = snprintf(buf, sizeof(buf),
1452 "led_id is set to %d, echo 1 to enable, 0 to disable\n",
1455 n = min_t(int, n, sizeof(buf));
1457 return simple_read_from_buffer(user_buf, count, ppos,
1461 static ssize_t wil_write_file_led_cfg(struct file *file,
1462 const char __user *buf_,
1463 size_t count, loff_t *ppos)
1465 struct wil6210_priv *wil = file->private_data;
1469 rc = kstrtoint_from_user(buf_, count, 0, &val);
1471 wil_err(wil, "Invalid argument\n");
1475 wil_info(wil, "%s led %d\n", val ? "Enabling" : "Disabling", led_id);
1476 rc = wmi_led_cfg(wil, val);
1478 wil_info(wil, "%s led %d failed\n",
1479 val ? "Enabling" : "Disabling", led_id);
1486 static const struct file_operations fops_led_cfg = {
1487 .read = wil_read_file_led_cfg,
1488 .write = wil_write_file_led_cfg,
1489 .open = simple_open,
1492 /* led_blink_time, write:
1493 * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast>
1495 static ssize_t wil_write_led_blink_time(struct file *file,
1496 const char __user *buf,
1497 size_t len, loff_t *ppos)
1500 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
1505 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
1508 return rc >= 0 ? -EIO : rc;
1512 rc = sscanf(kbuf, "%d %d %d %d %d %d",
1513 &led_blink_time[WIL_LED_TIME_SLOW].on_ms,
1514 &led_blink_time[WIL_LED_TIME_SLOW].off_ms,
1515 &led_blink_time[WIL_LED_TIME_MED].on_ms,
1516 &led_blink_time[WIL_LED_TIME_MED].off_ms,
1517 &led_blink_time[WIL_LED_TIME_FAST].on_ms,
1518 &led_blink_time[WIL_LED_TIME_FAST].off_ms);
1529 static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
1530 size_t count, loff_t *ppos)
1532 static char text[400];
1534 snprintf(text, sizeof(text),
1535 "To set led blink on/off time variables write:\n"
1536 "<blink_on_slow> <blink_off_slow> <blink_on_med> "
1537 "<blink_off_med> <blink_on_fast> <blink_off_fast>\n"
1538 "The current values are:\n"
1539 "%d %d %d %d %d %d\n",
1540 led_blink_time[WIL_LED_TIME_SLOW].on_ms,
1541 led_blink_time[WIL_LED_TIME_SLOW].off_ms,
1542 led_blink_time[WIL_LED_TIME_MED].on_ms,
1543 led_blink_time[WIL_LED_TIME_MED].off_ms,
1544 led_blink_time[WIL_LED_TIME_FAST].on_ms,
1545 led_blink_time[WIL_LED_TIME_FAST].off_ms);
1547 return simple_read_from_buffer(user_buf, count, ppos, text,
1551 static const struct file_operations fops_led_blink_time = {
1552 .read = wil_read_led_blink_time,
1553 .write = wil_write_led_blink_time,
1554 .open = simple_open,
1557 /*---------FW capabilities------------*/
1558 static int wil_fw_capabilities_debugfs_show(struct seq_file *s, void *data)
1560 struct wil6210_priv *wil = s->private;
1562 seq_printf(s, "fw_capabilities : %*pb\n", WMI_FW_CAPABILITY_MAX,
1563 wil->fw_capabilities);
1568 static int wil_fw_capabilities_seq_open(struct inode *inode, struct file *file)
1570 return single_open(file, wil_fw_capabilities_debugfs_show,
1574 static const struct file_operations fops_fw_capabilities = {
1575 .open = wil_fw_capabilities_seq_open,
1576 .release = single_release,
1578 .llseek = seq_lseek,
1581 /*---------FW version------------*/
1582 static int wil_fw_version_debugfs_show(struct seq_file *s, void *data)
1584 struct wil6210_priv *wil = s->private;
1586 if (wil->fw_version[0])
1587 seq_printf(s, "%s\n", wil->fw_version);
1589 seq_puts(s, "N/A\n");
1594 static int wil_fw_version_seq_open(struct inode *inode, struct file *file)
1596 return single_open(file, wil_fw_version_debugfs_show,
1600 static const struct file_operations fops_fw_version = {
1601 .open = wil_fw_version_seq_open,
1602 .release = single_release,
1604 .llseek = seq_lseek,
1607 /*----------------*/
1608 static void wil6210_debugfs_init_blobs(struct wil6210_priv *wil,
1614 for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) {
1615 struct wil_blob_wrapper *wil_blob = &wil->blobs[i];
1616 struct debugfs_blob_wrapper *blob = &wil_blob->blob;
1617 const struct fw_map *map = &fw_mapping[i];
1622 wil_blob->wil = wil;
1623 blob->data = (void * __force)wil->csr + HOSTADDR(map->host);
1624 blob->size = map->to - map->from;
1625 snprintf(name, sizeof(name), "blob_%s", map->name);
1626 wil_debugfs_create_ioblob(name, S_IRUGO, dbg, wil_blob);
1631 static const struct {
1634 const struct file_operations *fops;
1636 {"mbox", S_IRUGO, &fops_mbox},
1637 {"vrings", S_IRUGO, &fops_vring},
1638 {"stations", S_IRUGO, &fops_sta},
1639 {"desc", S_IRUGO, &fops_txdesc},
1640 {"bf", S_IRUGO, &fops_bf},
1641 {"ssid", S_IRUGO | S_IWUSR, &fops_ssid},
1642 {"mem_val", S_IRUGO, &fops_memread},
1643 {"reset", S_IWUSR, &fops_reset},
1644 {"rxon", S_IWUSR, &fops_rxon},
1645 {"tx_mgmt", S_IWUSR, &fops_txmgmt},
1646 {"wmi_send", S_IWUSR, &fops_wmi},
1647 {"back", S_IRUGO | S_IWUSR, &fops_back},
1648 {"pmccfg", S_IRUGO | S_IWUSR, &fops_pmccfg},
1649 {"pmcdata", S_IRUGO, &fops_pmcdata},
1650 {"temp", S_IRUGO, &fops_temp},
1651 {"freq", S_IRUGO, &fops_freq},
1652 {"link", S_IRUGO, &fops_link},
1653 {"info", S_IRUGO, &fops_info},
1654 {"recovery", S_IRUGO | S_IWUSR, &fops_recovery},
1655 {"led_cfg", S_IRUGO | S_IWUSR, &fops_led_cfg},
1656 {"led_blink_time", S_IRUGO | S_IWUSR, &fops_led_blink_time},
1657 {"fw_capabilities", S_IRUGO, &fops_fw_capabilities},
1658 {"fw_version", S_IRUGO, &fops_fw_version},
1661 static void wil6210_debugfs_init_files(struct wil6210_priv *wil,
1666 for (i = 0; i < ARRAY_SIZE(dbg_files); i++)
1667 debugfs_create_file(dbg_files[i].name, dbg_files[i].mode, dbg,
1668 wil, dbg_files[i].fops);
1671 /* interrupt control blocks */
1672 static const struct {
1676 {"USER_ICR", HOSTADDR(RGF_USER_USER_ICR)},
1677 {"DMA_EP_TX_ICR", HOSTADDR(RGF_DMA_EP_TX_ICR)},
1678 {"DMA_EP_RX_ICR", HOSTADDR(RGF_DMA_EP_RX_ICR)},
1679 {"DMA_EP_MISC_ICR", HOSTADDR(RGF_DMA_EP_MISC_ICR)},
1682 static void wil6210_debugfs_init_isr(struct wil6210_priv *wil,
1687 for (i = 0; i < ARRAY_SIZE(dbg_icr); i++)
1688 wil6210_debugfs_create_ISR(wil, dbg_icr[i].name, dbg,
1689 dbg_icr[i].icr_off);
1692 #define WIL_FIELD(name, mode, type) { __stringify(name), mode, \
1693 offsetof(struct wil6210_priv, name), type}
1695 /* fields in struct wil6210_priv */
1696 static const struct dbg_off dbg_wil_off[] = {
1697 WIL_FIELD(privacy, S_IRUGO, doff_u32),
1698 WIL_FIELD(status[0], S_IRUGO | S_IWUSR, doff_ulong),
1699 WIL_FIELD(hw_version, S_IRUGO, doff_x32),
1700 WIL_FIELD(recovery_count, S_IRUGO, doff_u32),
1701 WIL_FIELD(ap_isolate, S_IRUGO, doff_u32),
1702 WIL_FIELD(discovery_mode, S_IRUGO | S_IWUSR, doff_u8),
1706 static const struct dbg_off dbg_wil_regs[] = {
1707 {"RGF_MAC_MTRL_COUNTER_0", S_IRUGO, HOSTADDR(RGF_MAC_MTRL_COUNTER_0),
1709 {"RGF_USER_USAGE_1", S_IRUGO, HOSTADDR(RGF_USER_USAGE_1), doff_io32},
1713 /* static parameters */
1714 static const struct dbg_off dbg_statics[] = {
1715 {"desc_index", S_IRUGO | S_IWUSR, (ulong)&dbg_txdesc_index, doff_u32},
1716 {"vring_index", S_IRUGO | S_IWUSR, (ulong)&dbg_vring_index, doff_u32},
1717 {"mem_addr", S_IRUGO | S_IWUSR, (ulong)&mem_addr, doff_u32},
1718 {"vring_idle_trsh", S_IRUGO | S_IWUSR, (ulong)&vring_idle_trsh,
1720 {"led_polarity", S_IRUGO | S_IWUSR, (ulong)&led_polarity, doff_u8},
1724 int wil6210_debugfs_init(struct wil6210_priv *wil)
1726 struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
1727 wil_to_wiphy(wil)->debugfsdir);
1729 if (IS_ERR_OR_NULL(dbg))
1734 wil6210_debugfs_init_files(wil, dbg);
1735 wil6210_debugfs_init_isr(wil, dbg);
1736 wil6210_debugfs_init_blobs(wil, dbg);
1737 wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off);
1738 wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr,
1740 wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics);
1742 wil6210_debugfs_create_pseudo_ISR(wil, dbg);
1744 wil6210_debugfs_create_ITR_CNT(wil, dbg);
1749 void wil6210_debugfs_remove(struct wil6210_priv *wil)
1751 debugfs_remove_recursive(wil->debug);
1754 /* free pmc memory without sending command to fw, as it will
1755 * be reset on the way down anyway
1757 wil_pmc_free(wil, false);