2 * Copyright (c) 2012-2017 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>
28 /* Nasty hack. Better have per device instances */
30 static u32 dbg_txdesc_index;
31 static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
46 enum dbg_off_type type;
49 static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
50 const char *name, struct vring *vring,
53 void __iomem *x = wmi_addr(wil, vring->hwtail);
56 seq_printf(s, "VRING %s = {\n", name);
57 seq_printf(s, " pa = %pad\n", &vring->pa);
58 seq_printf(s, " va = 0x%p\n", vring->va);
59 seq_printf(s, " size = %d\n", vring->size);
60 seq_printf(s, " swtail = %d\n", vring->swtail);
61 seq_printf(s, " swhead = %d\n", vring->swhead);
62 seq_printf(s, " hwtail = [0x%08x] -> ", vring->hwtail);
65 seq_printf(s, "0x%08x = %d\n", v, v);
70 if (vring->va && (vring->size <= (1 << WIL_RING_SIZE_ORDER_MAX))) {
73 for (i = 0; i < vring->size; i++) {
74 volatile struct vring_tx_desc *d = &vring->va[i].tx;
76 if ((i % 128) == 0 && (i != 0))
78 seq_printf(s, "%c", (d->dma.status & BIT(0)) ?
79 _s : (vring->ctx[i].skb ? _h : 'h'));
86 static int wil_vring_debugfs_show(struct seq_file *s, void *data)
89 struct wil6210_priv *wil = s->private;
91 wil_print_vring(s, wil, "rx", &wil->vring_rx, 'S', '_');
93 for (i = 0; i < ARRAY_SIZE(wil->vring_tx); i++) {
94 struct vring *vring = &wil->vring_tx[i];
95 struct vring_tx_data *txdata = &wil->vring_tx_data[i];
98 int cid = wil->vring2cid_tid[i][0];
99 int tid = wil->vring2cid_tid[i][1];
100 u32 swhead = vring->swhead;
101 u32 swtail = vring->swtail;
102 int used = (vring->size + swhead - swtail)
104 int avail = vring->size - used - 1;
107 /* performance monitoring */
108 cycles_t now = get_cycles();
109 uint64_t idle = txdata->idle * 100;
110 uint64_t total = now - txdata->begin;
114 snprintf(sidle, sizeof(sidle), "%3d%%",
117 snprintf(sidle, sizeof(sidle), "N/A");
122 snprintf(name, sizeof(name), "tx_%2d", i);
124 if (cid < WIL6210_MAX_CID)
126 "\n%pM CID %d TID %d 1x%s BACK([%u] %u TU A%s) [%3d|%3d] idle %s\n",
127 wil->sta[cid].addr, cid, tid,
128 txdata->dot1x_open ? "+" : "-",
131 txdata->agg_amsdu ? "+" : "-",
135 "\nBroadcast 1x%s [%3d|%3d] idle %s\n",
136 txdata->dot1x_open ? "+" : "-",
139 wil_print_vring(s, wil, name, vring, '_', 'H');
146 static int wil_vring_seq_open(struct inode *inode, struct file *file)
148 return single_open(file, wil_vring_debugfs_show, inode->i_private);
151 static const struct file_operations fops_vring = {
152 .open = wil_vring_seq_open,
153 .release = single_release,
158 static void wil_seq_hexdump(struct seq_file *s, void *p, int len,
161 seq_hex_dump(s, prefix, DUMP_PREFIX_NONE, 16, 1, p, len, false);
164 static void wil_print_ring(struct seq_file *s, const char *prefix,
167 struct wil6210_priv *wil = s->private;
168 struct wil6210_mbox_ring r;
174 wil_memcpy_fromio_32(&r, off, sizeof(r));
175 wil_mbox_ring_le2cpus(&r);
177 * we just read memory block from NIC. This memory may be
178 * garbage. Check validity before using it.
180 rsize = r.size / sizeof(struct wil6210_mbox_ring_desc);
182 seq_printf(s, "ring %s = {\n", prefix);
183 seq_printf(s, " base = 0x%08x\n", r.base);
184 seq_printf(s, " size = 0x%04x bytes -> %d entries\n", r.size, rsize);
185 seq_printf(s, " tail = 0x%08x\n", r.tail);
186 seq_printf(s, " head = 0x%08x\n", r.head);
187 seq_printf(s, " entry size = %d\n", r.entry_size);
189 if (r.size % sizeof(struct wil6210_mbox_ring_desc)) {
190 seq_printf(s, " ??? size is not multiple of %zd, garbage?\n",
191 sizeof(struct wil6210_mbox_ring_desc));
195 if (!wmi_addr(wil, r.base) ||
196 !wmi_addr(wil, r.tail) ||
197 !wmi_addr(wil, r.head)) {
198 seq_puts(s, " ??? pointers are garbage?\n");
202 for (i = 0; i < rsize; i++) {
203 struct wil6210_mbox_ring_desc d;
204 struct wil6210_mbox_hdr hdr;
205 size_t delta = i * sizeof(d);
206 void __iomem *x = wil->csr + HOSTADDR(r.base) + delta;
208 wil_memcpy_fromio_32(&d, x, sizeof(d));
210 seq_printf(s, " [%2x] %s %s%s 0x%08x", i,
212 (r.tail - r.base == delta) ? "t" : " ",
213 (r.head - r.base == delta) ? "h" : " ",
214 le32_to_cpu(d.addr));
215 if (0 == wmi_read_hdr(wil, d.addr, &hdr)) {
216 u16 len = le16_to_cpu(hdr.len);
218 seq_printf(s, " -> %04x %04x %04x %02x\n",
219 le16_to_cpu(hdr.seq), len,
220 le16_to_cpu(hdr.type), hdr.flags);
221 if (len <= MAX_MBOXITEM_SIZE) {
222 unsigned char databuf[MAX_MBOXITEM_SIZE];
223 void __iomem *src = wmi_buffer(wil, d.addr) +
224 sizeof(struct wil6210_mbox_hdr);
226 * No need to check @src for validity -
227 * we already validated @d.addr while
230 wil_memcpy_fromio_32(databuf, src, len);
231 wil_seq_hexdump(s, databuf, len, " : ");
239 wil_halp_unvote(wil);
242 static int wil_mbox_debugfs_show(struct seq_file *s, void *data)
244 struct wil6210_priv *wil = s->private;
246 wil_print_ring(s, "tx", wil->csr + HOST_MBOX +
247 offsetof(struct wil6210_mbox_ctl, tx));
248 wil_print_ring(s, "rx", wil->csr + HOST_MBOX +
249 offsetof(struct wil6210_mbox_ctl, rx));
254 static int wil_mbox_seq_open(struct inode *inode, struct file *file)
256 return single_open(file, wil_mbox_debugfs_show, inode->i_private);
259 static const struct file_operations fops_mbox = {
260 .open = wil_mbox_seq_open,
261 .release = single_release,
266 static int wil_debugfs_iomem_x32_set(void *data, u64 val)
268 writel(val, (void __iomem *)data);
269 wmb(); /* make sure write propagated to HW */
274 static int wil_debugfs_iomem_x32_get(void *data, u64 *val)
276 *val = readl((void __iomem *)data);
281 DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
282 wil_debugfs_iomem_x32_set, "0x%08llx\n");
284 static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
286 struct dentry *parent,
289 return debugfs_create_file(name, mode, parent, value,
293 static int wil_debugfs_ulong_set(void *data, u64 val)
295 *(ulong *)data = val;
299 static int wil_debugfs_ulong_get(void *data, u64 *val)
301 *val = *(ulong *)data;
305 DEFINE_SIMPLE_ATTRIBUTE(wil_fops_ulong, wil_debugfs_ulong_get,
306 wil_debugfs_ulong_set, "0x%llx\n");
308 static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode,
309 struct dentry *parent,
312 return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong);
316 * wil6210_debugfs_init_offset - create set of debugfs files
317 * @wil - driver's context, used for printing
318 * @dbg - directory on the debugfs, where files will be created
319 * @base - base address used in address calculation
320 * @tbl - table with file descriptions. Should be terminated with empty element.
322 * Creates files accordingly to the @tbl.
324 static void wil6210_debugfs_init_offset(struct wil6210_priv *wil,
325 struct dentry *dbg, void *base,
326 const struct dbg_off * const tbl)
330 for (i = 0; tbl[i].name; i++) {
333 switch (tbl[i].type) {
335 f = debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg,
339 f = debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg,
343 f = wil_debugfs_create_ulong(tbl[i].name, tbl[i].mode,
344 dbg, base + tbl[i].off);
347 f = wil_debugfs_create_iomem_x32(tbl[i].name,
352 f = debugfs_create_u8(tbl[i].name, tbl[i].mode, dbg,
356 f = ERR_PTR(-EINVAL);
358 if (IS_ERR_OR_NULL(f))
359 wil_err(wil, "Create file \"%s\": err %ld\n",
360 tbl[i].name, PTR_ERR(f));
364 static const struct dbg_off isr_off[] = {
365 {"ICC", 0644, offsetof(struct RGF_ICR, ICC), doff_io32},
366 {"ICR", 0644, offsetof(struct RGF_ICR, ICR), doff_io32},
367 {"ICM", 0644, offsetof(struct RGF_ICR, ICM), doff_io32},
368 {"ICS", 0244, offsetof(struct RGF_ICR, ICS), doff_io32},
369 {"IMV", 0644, offsetof(struct RGF_ICR, IMV), doff_io32},
370 {"IMS", 0244, offsetof(struct RGF_ICR, IMS), doff_io32},
371 {"IMC", 0244, offsetof(struct RGF_ICR, IMC), doff_io32},
375 static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
377 struct dentry *parent, u32 off)
379 struct dentry *d = debugfs_create_dir(name, parent);
381 if (IS_ERR_OR_NULL(d))
384 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr + off,
390 static const struct dbg_off pseudo_isr_off[] = {
391 {"CAUSE", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32},
392 {"MASK_SW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32},
393 {"MASK_FW", 0444, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32},
397 static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
398 struct dentry *parent)
400 struct dentry *d = debugfs_create_dir("PSEUDO_ISR", parent);
402 if (IS_ERR_OR_NULL(d))
405 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
411 static const struct dbg_off lgc_itr_cnt_off[] = {
412 {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32},
413 {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32},
414 {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32},
418 static const struct dbg_off tx_itr_cnt_off[] = {
419 {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_TRSH),
421 {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_DATA),
423 {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_TX_CNT_CTL),
425 {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_TRSH),
427 {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_DATA),
429 {"IDL_CTL", 0644, HOSTADDR(RGF_DMA_ITR_TX_IDL_CNT_CTL),
434 static const struct dbg_off rx_itr_cnt_off[] = {
435 {"TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_TRSH),
437 {"DATA", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_DATA),
439 {"CTL", 0644, HOSTADDR(RGF_DMA_ITR_RX_CNT_CTL),
441 {"IDL_TRSH", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_TRSH),
443 {"IDL_DATA", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_DATA),
445 {"IDL_CTL", 0644, HOSTADDR(RGF_DMA_ITR_RX_IDL_CNT_CTL),
450 static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
451 struct dentry *parent)
453 struct dentry *d, *dtx, *drx;
455 d = debugfs_create_dir("ITR_CNT", parent);
456 if (IS_ERR_OR_NULL(d))
459 dtx = debugfs_create_dir("TX", d);
460 drx = debugfs_create_dir("RX", d);
461 if (IS_ERR_OR_NULL(dtx) || IS_ERR_OR_NULL(drx))
464 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
467 wil6210_debugfs_init_offset(wil, dtx, (void * __force)wil->csr,
470 wil6210_debugfs_init_offset(wil, drx, (void * __force)wil->csr,
475 static int wil_memread_debugfs_show(struct seq_file *s, void *data)
477 struct wil6210_priv *wil = s->private;
478 void __iomem *a = wmi_buffer(wil, cpu_to_le32(mem_addr));
481 seq_printf(s, "[0x%08x] = 0x%08x\n", mem_addr, readl(a));
483 seq_printf(s, "[0x%08x] = INVALID\n", mem_addr);
488 static int wil_memread_seq_open(struct inode *inode, struct file *file)
490 return single_open(file, wil_memread_debugfs_show, inode->i_private);
493 static const struct file_operations fops_memread = {
494 .open = wil_memread_seq_open,
495 .release = single_release,
500 static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
501 size_t count, loff_t *ppos)
503 enum { max_count = 4096 };
504 struct wil_blob_wrapper *wil_blob = file->private_data;
506 size_t available = wil_blob->blob.size;
510 if (test_bit(wil_status_suspending, wil_blob->wil->status) ||
511 test_bit(wil_status_suspended, wil_blob->wil->status))
517 if (pos >= available || !count)
520 if (count > available - pos)
521 count = available - pos;
522 if (count > max_count)
525 buf = kmalloc(count, GFP_KERNEL);
529 wil_memcpy_fromio_32(buf, (const void __iomem *)
530 wil_blob->blob.data + pos, count);
532 ret = copy_to_user(user_buf, buf, count);
543 static const struct file_operations fops_ioblob = {
544 .read = wil_read_file_ioblob,
546 .llseek = default_llseek,
550 struct dentry *wil_debugfs_create_ioblob(const char *name,
552 struct dentry *parent,
553 struct wil_blob_wrapper *wil_blob)
555 return debugfs_create_file(name, mode, parent, wil_blob, &fops_ioblob);
559 static ssize_t wil_write_file_reset(struct file *file, const char __user *buf,
560 size_t len, loff_t *ppos)
562 struct wil6210_priv *wil = file->private_data;
563 struct net_device *ndev = wil_to_ndev(wil);
567 * this code does NOT sync device state with the rest of system
568 * use with care, debug only!!!
572 ndev->flags &= ~IFF_UP;
574 wil_reset(wil, true);
579 static const struct file_operations fops_reset = {
580 .write = wil_write_file_reset,
584 /*---write channel 1..4 to rxon for it, 0 to rxoff---*/
585 static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
586 size_t len, loff_t *ppos)
588 struct wil6210_priv *wil = file->private_data;
593 char *kbuf = memdup_user_nul(buf, len);
596 return PTR_ERR(kbuf);
597 rc = kstrtol(kbuf, 0, &channel);
602 if ((channel < 0) || (channel > 4)) {
603 wil_err(wil, "Invalid channel %ld\n", channel);
609 rc = wmi_set_channel(wil, (int)channel);
614 rc = wmi_rxon(wil, on);
621 static const struct file_operations fops_rxon = {
622 .write = wil_write_file_rxon,
626 /* block ack control, write:
627 * - "add <ringid> <agg_size> <timeout>" to trigger ADDBA
628 * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side
629 * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side
631 static ssize_t wil_write_back(struct file *file, const char __user *buf,
632 size_t len, loff_t *ppos)
634 struct wil6210_priv *wil = file->private_data;
636 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
643 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
646 return rc >= 0 ? -EIO : rc;
650 rc = sscanf(kbuf, "%8s %d %d %d", cmd, &p1, &p2, &p3);
658 if (0 == strcmp(cmd, "add")) {
660 wil_err(wil, "BACK: add require at least 2 params\n");
665 wmi_addba(wil, p1, p2, p3);
666 } else if (0 == strcmp(cmd, "del_tx")) {
668 p2 = WLAN_REASON_QSTA_LEAVE_QBSS;
669 wmi_delba_tx(wil, p1, p2);
670 } else if (0 == strcmp(cmd, "del_rx")) {
673 "BACK: del_rx require at least 2 params\n");
677 p3 = WLAN_REASON_QSTA_LEAVE_QBSS;
678 wmi_delba_rx(wil, mk_cidxtid(p1, p2), p3);
680 wil_err(wil, "BACK: Unrecognized command \"%s\"\n", cmd);
687 static ssize_t wil_read_back(struct file *file, char __user *user_buf,
688 size_t count, loff_t *ppos)
690 static const char text[] = "block ack control, write:\n"
691 " - \"add <ringid> <agg_size> <timeout>\" to trigger ADDBA\n"
692 "If missing, <timeout> defaults to 0\n"
693 " - \"del_tx <ringid> <reason>\" to trigger DELBA for Tx side\n"
694 " - \"del_rx <CID> <TID> <reason>\" to trigger DELBA for Rx side\n"
695 "If missing, <reason> set to \"STA_LEAVING\" (36)\n";
697 return simple_read_from_buffer(user_buf, count, ppos, text,
701 static const struct file_operations fops_back = {
702 .read = wil_read_back,
703 .write = wil_write_back,
707 /* pmc control, write:
708 * - "alloc <num descriptors> <descriptor_size>" to allocate PMC
709 * - "free" to release memory allocated for PMC
711 static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
712 size_t len, loff_t *ppos)
714 struct wil6210_priv *wil = file->private_data;
716 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
718 int num_descs, desc_size;
723 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
726 return rc >= 0 ? -EIO : rc;
730 rc = sscanf(kbuf, "%8s %d %d", cmd, &num_descs, &desc_size);
737 wil_err(wil, "pmccfg: no params given\n");
741 if (0 == strcmp(cmd, "alloc")) {
743 wil_err(wil, "pmccfg: alloc requires 2 params\n");
746 wil_pmc_alloc(wil, num_descs, desc_size);
747 } else if (0 == strcmp(cmd, "free")) {
749 wil_err(wil, "pmccfg: free does not have any params\n");
752 wil_pmc_free(wil, true);
754 wil_err(wil, "pmccfg: Unrecognized command \"%s\"\n", cmd);
761 static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
762 size_t count, loff_t *ppos)
764 struct wil6210_priv *wil = file->private_data;
766 char help[] = "pmc control, write:\n"
767 " - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
768 " - \"free\" to free memory allocated for pmc\n";
770 sprintf(text, "Last command status: %d\n\n%s",
771 wil_pmc_last_cmd_status(wil),
774 return simple_read_from_buffer(user_buf, count, ppos, text,
778 static const struct file_operations fops_pmccfg = {
779 .read = wil_read_pmccfg,
780 .write = wil_write_pmccfg,
784 static const struct file_operations fops_pmcdata = {
786 .read = wil_pmc_read,
787 .llseek = wil_pmc_llseek,
791 /* Write mgmt frame to this file to send it */
792 static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
793 size_t len, loff_t *ppos)
795 struct wil6210_priv *wil = file->private_data;
796 struct wiphy *wiphy = wil_to_wiphy(wil);
797 struct wireless_dev *wdev = wil_to_wdev(wil);
798 struct cfg80211_mgmt_tx_params params;
805 frame = memdup_user(buf, len);
807 return PTR_ERR(frame);
811 params.chan = wdev->preset_chandef.chan;
813 rc = wil_cfg80211_mgmt_tx(wiphy, wdev, ¶ms, NULL);
816 wil_info(wil, "-> %d\n", 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, "0x%04x[%d] -> %d\n", 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"
1018 " Status = 0x%08x %s\n"
1019 " Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n"
1020 " Goodput(rx:tx) %4d:%4d\n"
1023 le64_to_cpu(reply.evt.tsf),
1024 le16_to_cpu(reply.evt.bf_mcs),
1025 le32_to_cpu(reply.evt.tx_tpt),
1028 status, wil_bfstatus_str(status),
1029 le16_to_cpu(reply.evt.my_rx_sector),
1030 le16_to_cpu(reply.evt.my_tx_sector),
1031 le16_to_cpu(reply.evt.other_rx_sector),
1032 le16_to_cpu(reply.evt.other_tx_sector),
1033 le32_to_cpu(reply.evt.rx_goodput),
1034 le32_to_cpu(reply.evt.tx_goodput));
1039 static int wil_bf_seq_open(struct inode *inode, struct file *file)
1041 return single_open(file, wil_bf_debugfs_show, inode->i_private);
1044 static const struct file_operations fops_bf = {
1045 .open = wil_bf_seq_open,
1046 .release = single_release,
1048 .llseek = seq_lseek,
1051 /*---------SSID------------*/
1052 static ssize_t wil_read_file_ssid(struct file *file, char __user *user_buf,
1053 size_t count, loff_t *ppos)
1055 struct wil6210_priv *wil = file->private_data;
1056 struct wireless_dev *wdev = wil_to_wdev(wil);
1058 return simple_read_from_buffer(user_buf, count, ppos,
1059 wdev->ssid, wdev->ssid_len);
1062 static ssize_t wil_write_file_ssid(struct file *file, const char __user *buf,
1063 size_t count, loff_t *ppos)
1065 struct wil6210_priv *wil = file->private_data;
1066 struct wireless_dev *wdev = wil_to_wdev(wil);
1067 struct net_device *ndev = wil_to_ndev(wil);
1070 wil_err(wil, "Unable to set SSID substring from [%d]\n",
1075 if (count > sizeof(wdev->ssid)) {
1076 wil_err(wil, "SSID too long, len = %d\n", (int)count);
1079 if (netif_running(ndev)) {
1080 wil_err(wil, "Unable to change SSID on running interface\n");
1084 wdev->ssid_len = count;
1085 return simple_write_to_buffer(wdev->ssid, wdev->ssid_len, ppos,
1089 static const struct file_operations fops_ssid = {
1090 .read = wil_read_file_ssid,
1091 .write = wil_write_file_ssid,
1092 .open = simple_open,
1095 /*---------temp------------*/
1096 static void print_temp(struct seq_file *s, const char *prefix, s32 t)
1101 seq_printf(s, "%s N/A\n", prefix);
1104 seq_printf(s, "%s %s%d.%03d\n", prefix, (t < 0 ? "-" : ""),
1105 abs(t / 1000), abs(t % 1000));
1110 static int wil_temp_debugfs_show(struct seq_file *s, void *data)
1112 struct wil6210_priv *wil = s->private;
1114 int rc = wmi_get_temperature(wil, &t_m, &t_r);
1117 seq_puts(s, "Failed\n");
1121 print_temp(s, "T_mac =", t_m);
1122 print_temp(s, "T_radio =", t_r);
1127 static int wil_temp_seq_open(struct inode *inode, struct file *file)
1129 return single_open(file, wil_temp_debugfs_show, inode->i_private);
1132 static const struct file_operations fops_temp = {
1133 .open = wil_temp_seq_open,
1134 .release = single_release,
1136 .llseek = seq_lseek,
1139 /*---------freq------------*/
1140 static int wil_freq_debugfs_show(struct seq_file *s, void *data)
1142 struct wil6210_priv *wil = s->private;
1143 struct wireless_dev *wdev = wil_to_wdev(wil);
1144 u16 freq = wdev->chandef.chan ? wdev->chandef.chan->center_freq : 0;
1146 seq_printf(s, "Freq = %d\n", freq);
1151 static int wil_freq_seq_open(struct inode *inode, struct file *file)
1153 return single_open(file, wil_freq_debugfs_show, inode->i_private);
1156 static const struct file_operations fops_freq = {
1157 .open = wil_freq_seq_open,
1158 .release = single_release,
1160 .llseek = seq_lseek,
1163 /*---------link------------*/
1164 static int wil_link_debugfs_show(struct seq_file *s, void *data)
1166 struct wil6210_priv *wil = s->private;
1167 struct station_info sinfo;
1170 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
1171 struct wil_sta_info *p = &wil->sta[i];
1172 char *status = "unknown";
1174 switch (p->status) {
1175 case wil_sta_unused:
1178 case wil_sta_conn_pending:
1179 status = "pending ";
1181 case wil_sta_connected:
1182 status = "connected";
1185 seq_printf(s, "[%d] %pM %s\n", i, p->addr, status);
1187 if (p->status == wil_sta_connected) {
1188 rc = wil_cid_fill_sinfo(wil, i, &sinfo);
1192 seq_printf(s, " Tx_mcs = %d\n", sinfo.txrate.mcs);
1193 seq_printf(s, " Rx_mcs = %d\n", sinfo.rxrate.mcs);
1194 seq_printf(s, " SQ = %d\n", sinfo.signal);
1201 static int wil_link_seq_open(struct inode *inode, struct file *file)
1203 return single_open(file, wil_link_debugfs_show, inode->i_private);
1206 static const struct file_operations fops_link = {
1207 .open = wil_link_seq_open,
1208 .release = single_release,
1210 .llseek = seq_lseek,
1213 /*---------info------------*/
1214 static int wil_info_debugfs_show(struct seq_file *s, void *data)
1216 struct wil6210_priv *wil = s->private;
1217 struct net_device *ndev = wil_to_ndev(wil);
1218 int is_ac = power_supply_is_system_supplied();
1219 int rx = atomic_xchg(&wil->isr_count_rx, 0);
1220 int tx = atomic_xchg(&wil->isr_count_tx, 0);
1221 static ulong rxf_old, txf_old;
1222 ulong rxf = ndev->stats.rx_packets;
1223 ulong txf = ndev->stats.tx_packets;
1226 /* >0 : AC; 0 : battery; <0 : error */
1227 seq_printf(s, "AC powered : %d\n", is_ac);
1228 seq_printf(s, "Rx irqs:packets : %8d : %8ld\n", rx, rxf - rxf_old);
1229 seq_printf(s, "Tx irqs:packets : %8d : %8ld\n", tx, txf - txf_old);
1233 #define CHECK_QSTATE(x) (state & BIT(__QUEUE_STATE_ ## x)) ? \
1234 " " __stringify(x) : ""
1236 for (i = 0; i < ndev->num_tx_queues; i++) {
1237 struct netdev_queue *txq = netdev_get_tx_queue(ndev, i);
1238 unsigned long state = txq->state;
1240 seq_printf(s, "Tx queue[%i] state : 0x%lx%s%s%s\n", i, state,
1241 CHECK_QSTATE(DRV_XOFF),
1242 CHECK_QSTATE(STACK_XOFF),
1243 CHECK_QSTATE(FROZEN)
1250 static int wil_info_seq_open(struct inode *inode, struct file *file)
1252 return single_open(file, wil_info_debugfs_show, inode->i_private);
1255 static const struct file_operations fops_info = {
1256 .open = wil_info_seq_open,
1257 .release = single_release,
1259 .llseek = seq_lseek,
1262 /*---------recovery------------*/
1263 /* mode = [manual|auto]
1264 * state = [idle|pending|running]
1266 static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
1267 size_t count, loff_t *ppos)
1269 struct wil6210_priv *wil = file->private_data;
1272 static const char * const sstate[] = {"idle", "pending", "running"};
1274 n = snprintf(buf, sizeof(buf), "mode = %s\nstate = %s\n",
1275 no_fw_recovery ? "manual" : "auto",
1276 sstate[wil->recovery_state]);
1278 n = min_t(int, n, sizeof(buf));
1280 return simple_read_from_buffer(user_buf, count, ppos,
1284 static ssize_t wil_write_file_recovery(struct file *file,
1285 const char __user *buf_,
1286 size_t count, loff_t *ppos)
1288 struct wil6210_priv *wil = file->private_data;
1289 static const char run_command[] = "run";
1290 char buf[sizeof(run_command) + 1]; /* to detect "runx" */
1293 if (wil->recovery_state != fw_recovery_pending) {
1294 wil_err(wil, "No recovery pending\n");
1299 wil_err(wil, "Offset [%d]\n", (int)*ppos);
1303 if (count > sizeof(buf)) {
1304 wil_err(wil, "Input too long, len = %d\n", (int)count);
1308 rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, buf_, count);
1313 if (0 == strcmp(buf, run_command))
1314 wil_set_recovery_state(wil, fw_recovery_running);
1316 wil_err(wil, "Bad recovery command \"%s\"\n", buf);
1321 static const struct file_operations fops_recovery = {
1322 .read = wil_read_file_recovery,
1323 .write = wil_write_file_recovery,
1324 .open = simple_open,
1327 /*---------Station matrix------------*/
1328 static void wil_print_rxtid(struct seq_file *s, struct wil_tid_ampdu_rx *r)
1331 u16 index = ((r->head_seq_num - r->ssn) & 0xfff) % r->buf_size;
1332 unsigned long long drop_dup = r->drop_dup, drop_old = r->drop_old;
1334 seq_printf(s, "([%2d] %3d TU) 0x%03x [", r->buf_size, r->timeout,
1336 for (i = 0; i < r->buf_size; i++) {
1338 seq_printf(s, "%c", r->reorder_buf[i] ? 'O' : '|');
1340 seq_printf(s, "%c", r->reorder_buf[i] ? '*' : '_');
1343 "] total %llu drop %llu (dup %llu + old %llu) last 0x%03x\n",
1344 r->total, drop_dup + drop_old, drop_dup, drop_old,
1348 static void wil_print_rxtid_crypto(struct seq_file *s, int tid,
1349 struct wil_tid_crypto_rx *c)
1353 for (i = 0; i < 4; i++) {
1354 struct wil_tid_crypto_rx_single *cc = &c->key_id[i];
1362 if (tid < WIL_STA_TID_NUM)
1363 seq_printf(s, " [%2d] PN", tid);
1365 seq_puts(s, " [GR] PN");
1367 for (i = 0; i < 4; i++) {
1368 struct wil_tid_crypto_rx_single *cc = &c->key_id[i];
1370 seq_printf(s, " [%i%s]%6phN", i, cc->key_set ? "+" : "-",
1376 static int wil_sta_debugfs_show(struct seq_file *s, void *data)
1377 __acquires(&p->tid_rx_lock) __releases(&p->tid_rx_lock)
1379 struct wil6210_priv *wil = s->private;
1382 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
1383 struct wil_sta_info *p = &wil->sta[i];
1384 char *status = "unknown";
1387 switch (p->status) {
1388 case wil_sta_unused:
1391 case wil_sta_conn_pending:
1392 status = "pending ";
1394 case wil_sta_connected:
1395 status = "connected";
1399 seq_printf(s, "[%d] %pM %s AID %d\n", i, p->addr, status, aid);
1401 if (p->status == wil_sta_connected) {
1402 spin_lock_bh(&p->tid_rx_lock);
1403 for (tid = 0; tid < WIL_STA_TID_NUM; tid++) {
1404 struct wil_tid_ampdu_rx *r = p->tid_rx[tid];
1405 struct wil_tid_crypto_rx *c =
1406 &p->tid_crypto_rx[tid];
1409 seq_printf(s, " [%2d] ", tid);
1410 wil_print_rxtid(s, r);
1413 wil_print_rxtid_crypto(s, tid, c);
1415 wil_print_rxtid_crypto(s, WIL_STA_TID_NUM,
1416 &p->group_crypto_rx);
1417 spin_unlock_bh(&p->tid_rx_lock);
1419 "Rx invalid frame: non-data %lu, short %lu, large %lu, replay %lu\n",
1420 p->stats.rx_non_data_frame,
1421 p->stats.rx_short_frame,
1422 p->stats.rx_large_frame,
1423 p->stats.rx_replay);
1425 seq_puts(s, "Rx/MCS:");
1426 for (mcs = 0; mcs < ARRAY_SIZE(p->stats.rx_per_mcs);
1428 seq_printf(s, " %lld",
1429 p->stats.rx_per_mcs[mcs]);
1437 static int wil_sta_seq_open(struct inode *inode, struct file *file)
1439 return single_open(file, wil_sta_debugfs_show, inode->i_private);
1442 static const struct file_operations fops_sta = {
1443 .open = wil_sta_seq_open,
1444 .release = single_release,
1446 .llseek = seq_lseek,
1449 static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
1450 size_t count, loff_t *ppos)
1455 n = snprintf(buf, sizeof(buf),
1456 "led_id is set to %d, echo 1 to enable, 0 to disable\n",
1459 n = min_t(int, n, sizeof(buf));
1461 return simple_read_from_buffer(user_buf, count, ppos,
1465 static ssize_t wil_write_file_led_cfg(struct file *file,
1466 const char __user *buf_,
1467 size_t count, loff_t *ppos)
1469 struct wil6210_priv *wil = file->private_data;
1473 rc = kstrtoint_from_user(buf_, count, 0, &val);
1475 wil_err(wil, "Invalid argument\n");
1479 wil_info(wil, "%s led %d\n", val ? "Enabling" : "Disabling", led_id);
1480 rc = wmi_led_cfg(wil, val);
1482 wil_info(wil, "%s led %d failed\n",
1483 val ? "Enabling" : "Disabling", led_id);
1490 static const struct file_operations fops_led_cfg = {
1491 .read = wil_read_file_led_cfg,
1492 .write = wil_write_file_led_cfg,
1493 .open = simple_open,
1496 /* led_blink_time, write:
1497 * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast>
1499 static ssize_t wil_write_led_blink_time(struct file *file,
1500 const char __user *buf,
1501 size_t len, loff_t *ppos)
1504 char *kbuf = kmalloc(len + 1, GFP_KERNEL);
1509 rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
1512 return rc >= 0 ? -EIO : rc;
1516 rc = sscanf(kbuf, "%d %d %d %d %d %d",
1517 &led_blink_time[WIL_LED_TIME_SLOW].on_ms,
1518 &led_blink_time[WIL_LED_TIME_SLOW].off_ms,
1519 &led_blink_time[WIL_LED_TIME_MED].on_ms,
1520 &led_blink_time[WIL_LED_TIME_MED].off_ms,
1521 &led_blink_time[WIL_LED_TIME_FAST].on_ms,
1522 &led_blink_time[WIL_LED_TIME_FAST].off_ms);
1533 static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
1534 size_t count, loff_t *ppos)
1536 static char text[400];
1538 snprintf(text, sizeof(text),
1539 "To set led blink on/off time variables write:\n"
1540 "<blink_on_slow> <blink_off_slow> <blink_on_med> "
1541 "<blink_off_med> <blink_on_fast> <blink_off_fast>\n"
1542 "The current values are:\n"
1543 "%d %d %d %d %d %d\n",
1544 led_blink_time[WIL_LED_TIME_SLOW].on_ms,
1545 led_blink_time[WIL_LED_TIME_SLOW].off_ms,
1546 led_blink_time[WIL_LED_TIME_MED].on_ms,
1547 led_blink_time[WIL_LED_TIME_MED].off_ms,
1548 led_blink_time[WIL_LED_TIME_FAST].on_ms,
1549 led_blink_time[WIL_LED_TIME_FAST].off_ms);
1551 return simple_read_from_buffer(user_buf, count, ppos, text,
1555 static const struct file_operations fops_led_blink_time = {
1556 .read = wil_read_led_blink_time,
1557 .write = wil_write_led_blink_time,
1558 .open = simple_open,
1561 /*---------FW capabilities------------*/
1562 static int wil_fw_capabilities_debugfs_show(struct seq_file *s, void *data)
1564 struct wil6210_priv *wil = s->private;
1566 seq_printf(s, "fw_capabilities : %*pb\n", WMI_FW_CAPABILITY_MAX,
1567 wil->fw_capabilities);
1572 static int wil_fw_capabilities_seq_open(struct inode *inode, struct file *file)
1574 return single_open(file, wil_fw_capabilities_debugfs_show,
1578 static const struct file_operations fops_fw_capabilities = {
1579 .open = wil_fw_capabilities_seq_open,
1580 .release = single_release,
1582 .llseek = seq_lseek,
1585 /*---------FW version------------*/
1586 static int wil_fw_version_debugfs_show(struct seq_file *s, void *data)
1588 struct wil6210_priv *wil = s->private;
1590 if (wil->fw_version[0])
1591 seq_printf(s, "%s\n", wil->fw_version);
1593 seq_puts(s, "N/A\n");
1598 static int wil_fw_version_seq_open(struct inode *inode, struct file *file)
1600 return single_open(file, wil_fw_version_debugfs_show,
1604 static const struct file_operations fops_fw_version = {
1605 .open = wil_fw_version_seq_open,
1606 .release = single_release,
1608 .llseek = seq_lseek,
1611 /*---------suspend_stats---------*/
1612 static ssize_t wil_write_suspend_stats(struct file *file,
1613 const char __user *buf,
1614 size_t len, loff_t *ppos)
1616 struct wil6210_priv *wil = file->private_data;
1618 memset(&wil->suspend_stats, 0, sizeof(wil->suspend_stats));
1619 wil->suspend_stats.min_suspend_time = ULONG_MAX;
1620 wil->suspend_stats.collection_start = ktime_get();
1625 static ssize_t wil_read_suspend_stats(struct file *file,
1626 char __user *user_buf,
1627 size_t count, loff_t *ppos)
1629 struct wil6210_priv *wil = file->private_data;
1630 static char text[400];
1632 unsigned long long stats_collection_time =
1633 ktime_to_us(ktime_sub(ktime_get(),
1634 wil->suspend_stats.collection_start));
1636 n = snprintf(text, sizeof(text),
1637 "Suspend statistics:\n"
1638 "successful suspends:%ld failed suspends:%ld\n"
1639 "successful resumes:%ld failed resumes:%ld\n"
1640 "rejected by host:%ld rejected by device:%ld\n"
1641 "total suspend time:%lld min suspend time:%lld\n"
1642 "max suspend time:%lld stats collection time: %lld\n",
1643 wil->suspend_stats.successful_suspends,
1644 wil->suspend_stats.failed_suspends,
1645 wil->suspend_stats.successful_resumes,
1646 wil->suspend_stats.failed_resumes,
1647 wil->suspend_stats.rejected_by_host,
1648 wil->suspend_stats.rejected_by_device,
1649 wil->suspend_stats.total_suspend_time,
1650 wil->suspend_stats.min_suspend_time,
1651 wil->suspend_stats.max_suspend_time,
1652 stats_collection_time);
1654 n = min_t(int, n, sizeof(text));
1656 return simple_read_from_buffer(user_buf, count, ppos, text, n);
1659 static const struct file_operations fops_suspend_stats = {
1660 .read = wil_read_suspend_stats,
1661 .write = wil_write_suspend_stats,
1662 .open = simple_open,
1665 /*----------------*/
1666 static void wil6210_debugfs_init_blobs(struct wil6210_priv *wil,
1672 for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) {
1673 struct wil_blob_wrapper *wil_blob = &wil->blobs[i];
1674 struct debugfs_blob_wrapper *blob = &wil_blob->blob;
1675 const struct fw_map *map = &fw_mapping[i];
1680 wil_blob->wil = wil;
1681 blob->data = (void * __force)wil->csr + HOSTADDR(map->host);
1682 blob->size = map->to - map->from;
1683 snprintf(name, sizeof(name), "blob_%s", map->name);
1684 wil_debugfs_create_ioblob(name, 0444, dbg, wil_blob);
1689 static const struct {
1692 const struct file_operations *fops;
1694 {"mbox", 0444, &fops_mbox},
1695 {"vrings", 0444, &fops_vring},
1696 {"stations", 0444, &fops_sta},
1697 {"desc", 0444, &fops_txdesc},
1698 {"bf", 0444, &fops_bf},
1699 {"ssid", 0644, &fops_ssid},
1700 {"mem_val", 0644, &fops_memread},
1701 {"reset", 0244, &fops_reset},
1702 {"rxon", 0244, &fops_rxon},
1703 {"tx_mgmt", 0244, &fops_txmgmt},
1704 {"wmi_send", 0244, &fops_wmi},
1705 {"back", 0644, &fops_back},
1706 {"pmccfg", 0644, &fops_pmccfg},
1707 {"pmcdata", 0444, &fops_pmcdata},
1708 {"temp", 0444, &fops_temp},
1709 {"freq", 0444, &fops_freq},
1710 {"link", 0444, &fops_link},
1711 {"info", 0444, &fops_info},
1712 {"recovery", 0644, &fops_recovery},
1713 {"led_cfg", 0644, &fops_led_cfg},
1714 {"led_blink_time", 0644, &fops_led_blink_time},
1715 {"fw_capabilities", 0444, &fops_fw_capabilities},
1716 {"fw_version", 0444, &fops_fw_version},
1717 {"suspend_stats", 0644, &fops_suspend_stats},
1720 static void wil6210_debugfs_init_files(struct wil6210_priv *wil,
1725 for (i = 0; i < ARRAY_SIZE(dbg_files); i++)
1726 debugfs_create_file(dbg_files[i].name, dbg_files[i].mode, dbg,
1727 wil, dbg_files[i].fops);
1730 /* interrupt control blocks */
1731 static const struct {
1735 {"USER_ICR", HOSTADDR(RGF_USER_USER_ICR)},
1736 {"DMA_EP_TX_ICR", HOSTADDR(RGF_DMA_EP_TX_ICR)},
1737 {"DMA_EP_RX_ICR", HOSTADDR(RGF_DMA_EP_RX_ICR)},
1738 {"DMA_EP_MISC_ICR", HOSTADDR(RGF_DMA_EP_MISC_ICR)},
1741 static void wil6210_debugfs_init_isr(struct wil6210_priv *wil,
1746 for (i = 0; i < ARRAY_SIZE(dbg_icr); i++)
1747 wil6210_debugfs_create_ISR(wil, dbg_icr[i].name, dbg,
1748 dbg_icr[i].icr_off);
1751 #define WIL_FIELD(name, mode, type) { __stringify(name), mode, \
1752 offsetof(struct wil6210_priv, name), type}
1754 /* fields in struct wil6210_priv */
1755 static const struct dbg_off dbg_wil_off[] = {
1756 WIL_FIELD(privacy, 0444, doff_u32),
1757 WIL_FIELD(status[0], 0644, doff_ulong),
1758 WIL_FIELD(hw_version, 0444, doff_x32),
1759 WIL_FIELD(recovery_count, 0444, doff_u32),
1760 WIL_FIELD(ap_isolate, 0444, doff_u32),
1761 WIL_FIELD(discovery_mode, 0644, doff_u8),
1762 WIL_FIELD(chip_revision, 0444, doff_u8),
1763 WIL_FIELD(abft_len, 0644, doff_u8),
1764 WIL_FIELD(wakeup_trigger, 0644, doff_u8),
1765 WIL_FIELD(vring_idle_trsh, 0644, doff_u32),
1769 static const struct dbg_off dbg_wil_regs[] = {
1770 {"RGF_MAC_MTRL_COUNTER_0", 0444, HOSTADDR(RGF_MAC_MTRL_COUNTER_0),
1772 {"RGF_USER_USAGE_1", 0444, HOSTADDR(RGF_USER_USAGE_1), doff_io32},
1776 /* static parameters */
1777 static const struct dbg_off dbg_statics[] = {
1778 {"desc_index", 0644, (ulong)&dbg_txdesc_index, doff_u32},
1779 {"vring_index", 0644, (ulong)&dbg_vring_index, doff_u32},
1780 {"mem_addr", 0644, (ulong)&mem_addr, doff_u32},
1781 {"led_polarity", 0644, (ulong)&led_polarity, doff_u8},
1785 int wil6210_debugfs_init(struct wil6210_priv *wil)
1787 struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
1788 wil_to_wiphy(wil)->debugfsdir);
1790 if (IS_ERR_OR_NULL(dbg))
1795 wil6210_debugfs_init_files(wil, dbg);
1796 wil6210_debugfs_init_isr(wil, dbg);
1797 wil6210_debugfs_init_blobs(wil, dbg);
1798 wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off);
1799 wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr,
1801 wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics);
1803 wil6210_debugfs_create_pseudo_ISR(wil, dbg);
1805 wil6210_debugfs_create_ITR_CNT(wil, dbg);
1807 wil->suspend_stats.collection_start = ktime_get();
1812 void wil6210_debugfs_remove(struct wil6210_priv *wil)
1814 debugfs_remove_recursive(wil->debug);
1817 /* free pmc memory without sending command to fw, as it will
1818 * be reset on the way down anyway
1820 wil_pmc_free(wil, false);