Commit | Line | Data |
---|---|---|
779e6e1c JG |
1 | /* |
2 | * drivers/s390/cio/qdio_debug.c | |
3 | * | |
3f09bb89 | 4 | * Copyright IBM Corp. 2008,2009 |
779e6e1c JG |
5 | * |
6 | * Author: Jan Glauber (jang@linux.vnet.ibm.com) | |
7 | */ | |
779e6e1c JG |
8 | #include <linux/seq_file.h> |
9 | #include <linux/debugfs.h> | |
779e6e1c JG |
10 | #include <asm/debug.h> |
11 | #include "qdio_debug.h" | |
12 | #include "qdio.h" | |
13 | ||
14 | debug_info_t *qdio_dbf_setup; | |
22f99347 | 15 | debug_info_t *qdio_dbf_error; |
779e6e1c JG |
16 | |
17 | static struct dentry *debugfs_root; | |
3f09bb89 | 18 | #define QDIO_DEBUGFS_NAME_LEN 10 |
779e6e1c | 19 | |
22f99347 JG |
20 | void qdio_allocate_dbf(struct qdio_initialize *init_data, |
21 | struct qdio_irq *irq_ptr) | |
779e6e1c | 22 | { |
22f99347 JG |
23 | char text[20]; |
24 | ||
25 | DBF_EVENT("qfmt:%1d", init_data->q_format); | |
26 | DBF_HEX(init_data->adapter_name, 8); | |
27 | DBF_EVENT("qpff%4x", init_data->qib_param_field_format); | |
28 | DBF_HEX(&init_data->qib_param_field, sizeof(void *)); | |
29 | DBF_HEX(&init_data->input_slib_elements, sizeof(void *)); | |
30 | DBF_HEX(&init_data->output_slib_elements, sizeof(void *)); | |
31 | DBF_EVENT("niq:%1d noq:%1d", init_data->no_input_qs, | |
32 | init_data->no_output_qs); | |
33 | DBF_HEX(&init_data->input_handler, sizeof(void *)); | |
34 | DBF_HEX(&init_data->output_handler, sizeof(void *)); | |
35 | DBF_HEX(&init_data->int_parm, sizeof(long)); | |
36 | DBF_HEX(&init_data->flags, sizeof(long)); | |
37 | DBF_HEX(&init_data->input_sbal_addr_array, sizeof(void *)); | |
38 | DBF_HEX(&init_data->output_sbal_addr_array, sizeof(void *)); | |
39 | DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); | |
40 | ||
41 | /* allocate trace view for the interface */ | |
42 | snprintf(text, 20, "qdio_%s", dev_name(&init_data->cdev->dev)); | |
43 | irq_ptr->debug_area = debug_register(text, 2, 1, 16); | |
44 | debug_register_view(irq_ptr->debug_area, &debug_hex_ascii_view); | |
45 | debug_set_level(irq_ptr->debug_area, DBF_WARN); | |
46 | DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created"); | |
779e6e1c JG |
47 | } |
48 | ||
49 | static int qstat_show(struct seq_file *m, void *v) | |
50 | { | |
51 | unsigned char state; | |
52 | struct qdio_q *q = m->private; | |
53 | int i; | |
54 | ||
55 | if (!q) | |
56 | return 0; | |
57 | ||
50f769df | 58 | seq_printf(m, "device state indicator: %d\n", *(u32 *)q->irq_ptr->dsci); |
779e6e1c JG |
59 | seq_printf(m, "nr_used: %d\n", atomic_read(&q->nr_buf_used)); |
60 | seq_printf(m, "ftc: %d\n", q->first_to_check); | |
e85dea0e | 61 | seq_printf(m, "last_move: %d\n", q->last_move); |
779e6e1c | 62 | seq_printf(m, "polling: %d\n", q->u.in.polling); |
e85dea0e | 63 | seq_printf(m, "ack start: %d\n", q->u.in.ack_start); |
50f769df | 64 | seq_printf(m, "ack count: %d\n", q->u.in.ack_count); |
779e6e1c | 65 | seq_printf(m, "slsb buffer states:\n"); |
50f769df | 66 | seq_printf(m, "|0 |8 |16 |24 |32 |40 |48 |56 63|\n"); |
779e6e1c | 67 | |
779e6e1c | 68 | for (i = 0; i < QDIO_MAX_BUFFERS_PER_Q; i++) { |
60b5df2f | 69 | debug_get_buf_state(q, i, &state); |
779e6e1c JG |
70 | switch (state) { |
71 | case SLSB_P_INPUT_NOT_INIT: | |
72 | case SLSB_P_OUTPUT_NOT_INIT: | |
73 | seq_printf(m, "N"); | |
74 | break; | |
75 | case SLSB_P_INPUT_PRIMED: | |
76 | case SLSB_CU_OUTPUT_PRIMED: | |
77 | seq_printf(m, "+"); | |
78 | break; | |
79 | case SLSB_P_INPUT_ACK: | |
80 | seq_printf(m, "A"); | |
81 | break; | |
82 | case SLSB_P_INPUT_ERROR: | |
83 | case SLSB_P_OUTPUT_ERROR: | |
84 | seq_printf(m, "x"); | |
85 | break; | |
86 | case SLSB_CU_INPUT_EMPTY: | |
87 | case SLSB_P_OUTPUT_EMPTY: | |
88 | seq_printf(m, "-"); | |
89 | break; | |
90 | case SLSB_P_INPUT_HALTED: | |
91 | case SLSB_P_OUTPUT_HALTED: | |
92 | seq_printf(m, "."); | |
93 | break; | |
94 | default: | |
95 | seq_printf(m, "?"); | |
96 | } | |
97 | if (i == 63) | |
98 | seq_printf(m, "\n"); | |
99 | } | |
100 | seq_printf(m, "\n"); | |
50f769df | 101 | seq_printf(m, "|64 |72 |80 |88 |96 |104 |112 | 127|\n"); |
779e6e1c JG |
102 | return 0; |
103 | } | |
104 | ||
105 | static ssize_t qstat_seq_write(struct file *file, const char __user *buf, | |
106 | size_t count, loff_t *off) | |
107 | { | |
108 | struct seq_file *seq = file->private_data; | |
109 | struct qdio_q *q = seq->private; | |
110 | ||
111 | if (!q) | |
112 | return 0; | |
113 | ||
114 | if (q->is_input_q) | |
115 | xchg(q->irq_ptr->dsci, 1); | |
116 | local_bh_disable(); | |
117 | tasklet_schedule(&q->tasklet); | |
118 | local_bh_enable(); | |
119 | return count; | |
120 | } | |
121 | ||
122 | static int qstat_seq_open(struct inode *inode, struct file *filp) | |
123 | { | |
124 | return single_open(filp, qstat_show, | |
125 | filp->f_path.dentry->d_inode->i_private); | |
126 | } | |
127 | ||
779e6e1c JG |
128 | static struct file_operations debugfs_fops = { |
129 | .owner = THIS_MODULE, | |
130 | .open = qstat_seq_open, | |
131 | .read = seq_read, | |
132 | .write = qstat_seq_write, | |
133 | .llseek = seq_lseek, | |
134 | .release = single_release, | |
135 | }; | |
136 | ||
137 | static void setup_debugfs_entry(struct qdio_q *q, struct ccw_device *cdev) | |
138 | { | |
2c780914 | 139 | char name[QDIO_DEBUGFS_NAME_LEN]; |
779e6e1c | 140 | |
3f09bb89 | 141 | snprintf(name, QDIO_DEBUGFS_NAME_LEN, "%s_%d", |
2c780914 JG |
142 | q->is_input_q ? "input" : "output", |
143 | q->nr); | |
3f09bb89 JG |
144 | q->debugfs_q = debugfs_create_file(name, S_IFREG | S_IRUGO | S_IWUSR, |
145 | q->irq_ptr->debugfs_dev, q, &debugfs_fops); | |
146 | if (IS_ERR(q->debugfs_q)) | |
147 | q->debugfs_q = NULL; | |
779e6e1c JG |
148 | } |
149 | ||
150 | void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, struct ccw_device *cdev) | |
151 | { | |
152 | struct qdio_q *q; | |
153 | int i; | |
154 | ||
3f09bb89 JG |
155 | irq_ptr->debugfs_dev = debugfs_create_dir(dev_name(&cdev->dev), |
156 | debugfs_root); | |
157 | if (IS_ERR(irq_ptr->debugfs_dev)) | |
158 | irq_ptr->debugfs_dev = NULL; | |
779e6e1c JG |
159 | for_each_input_queue(irq_ptr, q, i) |
160 | setup_debugfs_entry(q, cdev); | |
161 | for_each_output_queue(irq_ptr, q, i) | |
162 | setup_debugfs_entry(q, cdev); | |
779e6e1c JG |
163 | } |
164 | ||
165 | void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr, struct ccw_device *cdev) | |
166 | { | |
167 | struct qdio_q *q; | |
168 | int i; | |
169 | ||
779e6e1c | 170 | for_each_input_queue(irq_ptr, q, i) |
3f09bb89 | 171 | debugfs_remove(q->debugfs_q); |
779e6e1c | 172 | for_each_output_queue(irq_ptr, q, i) |
3f09bb89 JG |
173 | debugfs_remove(q->debugfs_q); |
174 | debugfs_remove(irq_ptr->debugfs_dev); | |
779e6e1c JG |
175 | } |
176 | ||
177 | int __init qdio_debug_init(void) | |
178 | { | |
3f09bb89 | 179 | debugfs_root = debugfs_create_dir("qdio", NULL); |
22f99347 JG |
180 | |
181 | qdio_dbf_setup = debug_register("qdio_setup", 16, 1, 16); | |
182 | debug_register_view(qdio_dbf_setup, &debug_hex_ascii_view); | |
183 | debug_set_level(qdio_dbf_setup, DBF_INFO); | |
184 | DBF_EVENT("dbf created\n"); | |
185 | ||
186 | qdio_dbf_error = debug_register("qdio_error", 4, 1, 16); | |
187 | debug_register_view(qdio_dbf_error, &debug_hex_ascii_view); | |
188 | debug_set_level(qdio_dbf_error, DBF_INFO); | |
189 | DBF_ERROR("dbf created\n"); | |
190 | return 0; | |
779e6e1c JG |
191 | } |
192 | ||
193 | void qdio_debug_exit(void) | |
194 | { | |
195 | debugfs_remove(debugfs_root); | |
22f99347 JG |
196 | if (qdio_dbf_setup) |
197 | debug_unregister(qdio_dbf_setup); | |
198 | if (qdio_dbf_error) | |
199 | debug_unregister(qdio_dbf_error); | |
779e6e1c | 200 | } |