Loading...
1/*
2 * Wireless Host Controller (WHC) debug.
3 *
4 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include <linux/slab.h>
19#include <linux/kernel.h>
20#include <linux/debugfs.h>
21#include <linux/seq_file.h>
22
23#include "../../wusbcore/wusbhc.h"
24
25#include "whcd.h"
26
27struct whc_dbg {
28 struct dentry *di_f;
29 struct dentry *asl_f;
30 struct dentry *pzl_f;
31};
32
33static void qset_print(struct seq_file *s, struct whc_qset *qset)
34{
35 static const char *qh_type[] = {
36 "ctrl", "isoc", "bulk", "intr", "rsvd", "rsvd", "rsvd", "lpintr", };
37 struct whc_std *std;
38 struct urb *urb = NULL;
39 int i;
40
41 seq_printf(s, "qset %08x", (u32)qset->qset_dma);
42 if (&qset->list_node == qset->whc->async_list.prev) {
43 seq_printf(s, " (dummy)\n");
44 } else {
45 seq_printf(s, " ep%d%s-%s maxpkt: %d\n",
46 qset->qh.info1 & 0x0f,
47 (qset->qh.info1 >> 4) & 0x1 ? "in" : "out",
48 qh_type[(qset->qh.info1 >> 5) & 0x7],
49 (qset->qh.info1 >> 16) & 0xffff);
50 }
51 seq_printf(s, " -> %08x\n", (u32)qset->qh.link);
52 seq_printf(s, " info: %08x %08x %08x\n",
53 qset->qh.info1, qset->qh.info2, qset->qh.info3);
54 seq_printf(s, " sts: %04x errs: %d curwin: %08x\n",
55 qset->qh.status, qset->qh.err_count, qset->qh.cur_window);
56 seq_printf(s, " TD: sts: %08x opts: %08x\n",
57 qset->qh.overlay.qtd.status, qset->qh.overlay.qtd.options);
58
59 for (i = 0; i < WHCI_QSET_TD_MAX; i++) {
60 seq_printf(s, " %c%c TD[%d]: sts: %08x opts: %08x ptr: %08x\n",
61 i == qset->td_start ? 'S' : ' ',
62 i == qset->td_end ? 'E' : ' ',
63 i, qset->qtd[i].status, qset->qtd[i].options,
64 (u32)qset->qtd[i].page_list_ptr);
65 }
66 seq_printf(s, " ntds: %d\n", qset->ntds);
67 list_for_each_entry(std, &qset->stds, list_node) {
68 if (urb != std->urb) {
69 urb = std->urb;
70 seq_printf(s, " urb %p transferred: %d bytes\n", urb,
71 urb->actual_length);
72 }
73 if (std->qtd)
74 seq_printf(s, " sTD[%td]: %zu bytes @ %08x\n",
75 std->qtd - &qset->qtd[0],
76 std->len, std->num_pointers ?
77 (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
78 else
79 seq_printf(s, " sTD[-]: %zd bytes @ %08x\n",
80 std->len, std->num_pointers ?
81 (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
82 }
83}
84
85static int di_print(struct seq_file *s, void *p)
86{
87 struct whc *whc = s->private;
88 char buf[72];
89 int d;
90
91 for (d = 0; d < whc->n_devices; d++) {
92 struct di_buf_entry *di = &whc->di_buf[d];
93
94 bitmap_scnprintf(buf, sizeof(buf),
95 (unsigned long *)di->availability_info, UWB_NUM_MAS);
96
97 seq_printf(s, "DI[%d]\n", d);
98 seq_printf(s, " availability: %s\n", buf);
99 seq_printf(s, " %c%c key idx: %d dev addr: %d\n",
100 (di->addr_sec_info & WHC_DI_SECURE) ? 'S' : ' ',
101 (di->addr_sec_info & WHC_DI_DISABLE) ? 'D' : ' ',
102 (di->addr_sec_info & WHC_DI_KEY_IDX_MASK) >> 8,
103 (di->addr_sec_info & WHC_DI_DEV_ADDR_MASK));
104 }
105 return 0;
106}
107
108static int asl_print(struct seq_file *s, void *p)
109{
110 struct whc *whc = s->private;
111 struct whc_qset *qset;
112
113 list_for_each_entry(qset, &whc->async_list, list_node) {
114 qset_print(s, qset);
115 }
116
117 return 0;
118}
119
120static int pzl_print(struct seq_file *s, void *p)
121{
122 struct whc *whc = s->private;
123 struct whc_qset *qset;
124 int period;
125
126 for (period = 0; period < 5; period++) {
127 seq_printf(s, "Period %d\n", period);
128 list_for_each_entry(qset, &whc->periodic_list[period], list_node) {
129 qset_print(s, qset);
130 }
131 }
132 return 0;
133}
134
135static int di_open(struct inode *inode, struct file *file)
136{
137 return single_open(file, di_print, inode->i_private);
138}
139
140static int asl_open(struct inode *inode, struct file *file)
141{
142 return single_open(file, asl_print, inode->i_private);
143}
144
145static int pzl_open(struct inode *inode, struct file *file)
146{
147 return single_open(file, pzl_print, inode->i_private);
148}
149
150static const struct file_operations di_fops = {
151 .open = di_open,
152 .read = seq_read,
153 .llseek = seq_lseek,
154 .release = single_release,
155 .owner = THIS_MODULE,
156};
157
158static const struct file_operations asl_fops = {
159 .open = asl_open,
160 .read = seq_read,
161 .llseek = seq_lseek,
162 .release = single_release,
163 .owner = THIS_MODULE,
164};
165
166static const struct file_operations pzl_fops = {
167 .open = pzl_open,
168 .read = seq_read,
169 .llseek = seq_lseek,
170 .release = single_release,
171 .owner = THIS_MODULE,
172};
173
174void whc_dbg_init(struct whc *whc)
175{
176 if (whc->wusbhc.pal.debugfs_dir == NULL)
177 return;
178
179 whc->dbg = kzalloc(sizeof(struct whc_dbg), GFP_KERNEL);
180 if (whc->dbg == NULL)
181 return;
182
183 whc->dbg->di_f = debugfs_create_file("di", 0444,
184 whc->wusbhc.pal.debugfs_dir, whc,
185 &di_fops);
186 whc->dbg->asl_f = debugfs_create_file("asl", 0444,
187 whc->wusbhc.pal.debugfs_dir, whc,
188 &asl_fops);
189 whc->dbg->pzl_f = debugfs_create_file("pzl", 0444,
190 whc->wusbhc.pal.debugfs_dir, whc,
191 &pzl_fops);
192}
193
194void whc_dbg_clean_up(struct whc *whc)
195{
196 if (whc->dbg) {
197 debugfs_remove(whc->dbg->pzl_f);
198 debugfs_remove(whc->dbg->asl_f);
199 debugfs_remove(whc->dbg->di_f);
200 kfree(whc->dbg);
201 }
202}
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Wireless Host Controller (WHC) debug.
4 *
5 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
6 */
7#include <linux/slab.h>
8#include <linux/kernel.h>
9#include <linux/debugfs.h>
10#include <linux/seq_file.h>
11#include <linux/export.h>
12
13#include "../../wusbcore/wusbhc.h"
14
15#include "whcd.h"
16
17struct whc_dbg {
18 struct dentry *di_f;
19 struct dentry *asl_f;
20 struct dentry *pzl_f;
21};
22
23static void qset_print(struct seq_file *s, struct whc_qset *qset)
24{
25 static const char *qh_type[] = {
26 "ctrl", "isoc", "bulk", "intr", "rsvd", "rsvd", "rsvd", "lpintr", };
27 struct whc_std *std;
28 struct urb *urb = NULL;
29 int i;
30
31 seq_printf(s, "qset %08x", (u32)qset->qset_dma);
32 if (&qset->list_node == qset->whc->async_list.prev) {
33 seq_printf(s, " (dummy)\n");
34 } else {
35 seq_printf(s, " ep%d%s-%s maxpkt: %d\n",
36 qset->qh.info1 & 0x0f,
37 (qset->qh.info1 >> 4) & 0x1 ? "in" : "out",
38 qh_type[(qset->qh.info1 >> 5) & 0x7],
39 (qset->qh.info1 >> 16) & 0xffff);
40 }
41 seq_printf(s, " -> %08x\n", (u32)qset->qh.link);
42 seq_printf(s, " info: %08x %08x %08x\n",
43 qset->qh.info1, qset->qh.info2, qset->qh.info3);
44 seq_printf(s, " sts: %04x errs: %d curwin: %08x\n",
45 qset->qh.status, qset->qh.err_count, qset->qh.cur_window);
46 seq_printf(s, " TD: sts: %08x opts: %08x\n",
47 qset->qh.overlay.qtd.status, qset->qh.overlay.qtd.options);
48
49 for (i = 0; i < WHCI_QSET_TD_MAX; i++) {
50 seq_printf(s, " %c%c TD[%d]: sts: %08x opts: %08x ptr: %08x\n",
51 i == qset->td_start ? 'S' : ' ',
52 i == qset->td_end ? 'E' : ' ',
53 i, qset->qtd[i].status, qset->qtd[i].options,
54 (u32)qset->qtd[i].page_list_ptr);
55 }
56 seq_printf(s, " ntds: %d\n", qset->ntds);
57 list_for_each_entry(std, &qset->stds, list_node) {
58 if (urb != std->urb) {
59 urb = std->urb;
60 seq_printf(s, " urb %p transferred: %d bytes\n", urb,
61 urb->actual_length);
62 }
63 if (std->qtd)
64 seq_printf(s, " sTD[%td]: %zu bytes @ %08x\n",
65 std->qtd - &qset->qtd[0],
66 std->len, std->num_pointers ?
67 (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
68 else
69 seq_printf(s, " sTD[-]: %zd bytes @ %08x\n",
70 std->len, std->num_pointers ?
71 (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
72 }
73}
74
75static int di_show(struct seq_file *s, void *p)
76{
77 struct whc *whc = s->private;
78 int d;
79
80 for (d = 0; d < whc->n_devices; d++) {
81 struct di_buf_entry *di = &whc->di_buf[d];
82
83 seq_printf(s, "DI[%d]\n", d);
84 seq_printf(s, " availability: %*pb\n",
85 UWB_NUM_MAS, (unsigned long *)di->availability_info);
86 seq_printf(s, " %c%c key idx: %d dev addr: %d\n",
87 (di->addr_sec_info & WHC_DI_SECURE) ? 'S' : ' ',
88 (di->addr_sec_info & WHC_DI_DISABLE) ? 'D' : ' ',
89 (di->addr_sec_info & WHC_DI_KEY_IDX_MASK) >> 8,
90 (di->addr_sec_info & WHC_DI_DEV_ADDR_MASK));
91 }
92 return 0;
93}
94DEFINE_SHOW_ATTRIBUTE(di);
95
96static int asl_show(struct seq_file *s, void *p)
97{
98 struct whc *whc = s->private;
99 struct whc_qset *qset;
100
101 list_for_each_entry(qset, &whc->async_list, list_node) {
102 qset_print(s, qset);
103 }
104
105 return 0;
106}
107DEFINE_SHOW_ATTRIBUTE(asl);
108
109static int pzl_show(struct seq_file *s, void *p)
110{
111 struct whc *whc = s->private;
112 struct whc_qset *qset;
113 int period;
114
115 for (period = 0; period < 5; period++) {
116 seq_printf(s, "Period %d\n", period);
117 list_for_each_entry(qset, &whc->periodic_list[period], list_node) {
118 qset_print(s, qset);
119 }
120 }
121 return 0;
122}
123DEFINE_SHOW_ATTRIBUTE(pzl);
124
125void whc_dbg_init(struct whc *whc)
126{
127 if (whc->wusbhc.pal.debugfs_dir == NULL)
128 return;
129
130 whc->dbg = kzalloc(sizeof(struct whc_dbg), GFP_KERNEL);
131 if (whc->dbg == NULL)
132 return;
133
134 whc->dbg->di_f = debugfs_create_file("di", 0444,
135 whc->wusbhc.pal.debugfs_dir, whc,
136 &di_fops);
137 whc->dbg->asl_f = debugfs_create_file("asl", 0444,
138 whc->wusbhc.pal.debugfs_dir, whc,
139 &asl_fops);
140 whc->dbg->pzl_f = debugfs_create_file("pzl", 0444,
141 whc->wusbhc.pal.debugfs_dir, whc,
142 &pzl_fops);
143}
144
145void whc_dbg_clean_up(struct whc *whc)
146{
147 if (whc->dbg) {
148 debugfs_remove(whc->dbg->pzl_f);
149 debugfs_remove(whc->dbg->asl_f);
150 debugfs_remove(whc->dbg->di_f);
151 kfree(whc->dbg);
152 }
153}