2 * drivers/s390/cio/qdio_debug.c
4 * Copyright IBM Corp. 2008,2009
6 * Author: Jan Glauber (jang@linux.vnet.ibm.com)
8 #include <linux/seq_file.h>
9 #include <linux/debugfs.h>
10 #include <asm/debug.h>
11 #include "qdio_debug.h"
14 debug_info_t
*qdio_dbf_setup
;
15 debug_info_t
*qdio_dbf_error
;
17 static struct dentry
*debugfs_root
;
18 #define QDIO_DEBUGFS_NAME_LEN 10
20 void qdio_allocate_dbf(struct qdio_initialize
*init_data
,
21 struct qdio_irq
*irq_ptr
)
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
->input_sbal_addr_array
, sizeof(void *));
37 DBF_HEX(&init_data
->output_sbal_addr_array
, sizeof(void *));
38 DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr
);
40 /* allocate trace view for the interface */
41 snprintf(text
, 20, "qdio_%s", dev_name(&init_data
->cdev
->dev
));
42 irq_ptr
->debug_area
= debug_register(text
, 2, 1, 16);
43 debug_register_view(irq_ptr
->debug_area
, &debug_hex_ascii_view
);
44 debug_set_level(irq_ptr
->debug_area
, DBF_WARN
);
45 DBF_DEV_EVENT(DBF_ERR
, irq_ptr
, "dbf created");
48 static int qstat_show(struct seq_file
*m
, void *v
)
51 struct qdio_q
*q
= m
->private;
57 seq_printf(m
, "DSCI: %d nr_used: %d\n",
58 *(u32
*)q
->irq_ptr
->dsci
, atomic_read(&q
->nr_buf_used
));
59 seq_printf(m
, "ftc: %d last_move: %d\n",
60 q
->first_to_check
, q
->last_move
);
62 seq_printf(m
, "polling: %d ack start: %d ack count: %d\n",
63 q
->u
.in
.polling
, q
->u
.in
.ack_start
,
65 seq_printf(m
, "IRQs disabled: %u\n",
66 test_bit(QDIO_QUEUE_IRQS_DISABLED
,
67 &q
->u
.in
.queue_irq_state
));
69 seq_printf(m
, "SBAL states:\n");
70 seq_printf(m
, "|0 |8 |16 |24 |32 |40 |48 |56 63|\n");
72 for (i
= 0; i
< QDIO_MAX_BUFFERS_PER_Q
; i
++) {
73 debug_get_buf_state(q
, i
, &state
);
75 case SLSB_P_INPUT_NOT_INIT
:
76 case SLSB_P_OUTPUT_NOT_INIT
:
79 case SLSB_P_INPUT_PRIMED
:
80 case SLSB_CU_OUTPUT_PRIMED
:
83 case SLSB_P_INPUT_ACK
:
86 case SLSB_P_INPUT_ERROR
:
87 case SLSB_P_OUTPUT_ERROR
:
90 case SLSB_CU_INPUT_EMPTY
:
91 case SLSB_P_OUTPUT_EMPTY
:
94 case SLSB_P_INPUT_HALTED
:
95 case SLSB_P_OUTPUT_HALTED
:
105 seq_printf(m
, "|64 |72 |80 |88 |96 |104 |112 | 127|\n");
107 seq_printf(m
, "\nSBAL statistics:");
108 if (!q
->irq_ptr
->perf_stat_enabled
) {
109 seq_printf(m
, " disabled\n");
113 seq_printf(m
, "\n1 2.. 4.. 8.. "
114 "16.. 32.. 64.. 127\n");
115 for (i
= 0; i
< ARRAY_SIZE(q
->q_stats
.nr_sbals
); i
++)
116 seq_printf(m
, "%-10u ", q
->q_stats
.nr_sbals
[i
]);
117 seq_printf(m
, "\nError NOP Total\n%-10u %-10u %-10u\n\n",
118 q
->q_stats
.nr_sbal_error
, q
->q_stats
.nr_sbal_nop
,
119 q
->q_stats
.nr_sbal_total
);
123 static int qstat_seq_open(struct inode
*inode
, struct file
*filp
)
125 return single_open(filp
, qstat_show
,
126 filp
->f_path
.dentry
->d_inode
->i_private
);
129 static const struct file_operations debugfs_fops
= {
130 .owner
= THIS_MODULE
,
131 .open
= qstat_seq_open
,
134 .release
= single_release
,
137 static char *qperf_names
[] = {
138 "Assumed adapter interrupts",
141 "Inbound tasklet runs",
142 "Inbound tasklet resched",
143 "Inbound tasklet resched2",
144 "Outbound tasklet runs",
150 "Inbound stop_polling",
151 "Inbound queue full",
154 "Outbound queue full",
155 "Outbound fast_requeue",
156 "Outbound target_full",
158 "QEBSM eqbs partial",
160 "QEBSM sqbs partial",
161 "Discarded interrupts"
164 static int qperf_show(struct seq_file
*m
, void *v
)
166 struct qdio_irq
*irq_ptr
= m
->private;
172 if (!irq_ptr
->perf_stat_enabled
) {
173 seq_printf(m
, "disabled\n");
176 stat
= (unsigned int *)&irq_ptr
->perf_stat
;
178 for (i
= 0; i
< ARRAY_SIZE(qperf_names
); i
++)
179 seq_printf(m
, "%26s:\t%u\n",
180 qperf_names
[i
], *(stat
+ i
));
184 static ssize_t
qperf_seq_write(struct file
*file
, const char __user
*ubuf
,
185 size_t count
, loff_t
*off
)
187 struct seq_file
*seq
= file
->private_data
;
188 struct qdio_irq
*irq_ptr
= seq
->private;
196 if (count
>= sizeof(buf
))
198 if (copy_from_user(&buf
, ubuf
, count
))
202 ret
= strict_strtoul(buf
, 10, &val
);
208 irq_ptr
->perf_stat_enabled
= 0;
209 memset(&irq_ptr
->perf_stat
, 0, sizeof(irq_ptr
->perf_stat
));
210 for_each_input_queue(irq_ptr
, q
, i
)
211 memset(&q
->q_stats
, 0, sizeof(q
->q_stats
));
212 for_each_output_queue(irq_ptr
, q
, i
)
213 memset(&q
->q_stats
, 0, sizeof(q
->q_stats
));
216 irq_ptr
->perf_stat_enabled
= 1;
222 static int qperf_seq_open(struct inode
*inode
, struct file
*filp
)
224 return single_open(filp
, qperf_show
,
225 filp
->f_path
.dentry
->d_inode
->i_private
);
228 static struct file_operations debugfs_perf_fops
= {
229 .owner
= THIS_MODULE
,
230 .open
= qperf_seq_open
,
232 .write
= qperf_seq_write
,
234 .release
= single_release
,
236 static void setup_debugfs_entry(struct qdio_q
*q
, struct ccw_device
*cdev
)
238 char name
[QDIO_DEBUGFS_NAME_LEN
];
240 snprintf(name
, QDIO_DEBUGFS_NAME_LEN
, "%s_%d",
241 q
->is_input_q
? "input" : "output",
243 q
->debugfs_q
= debugfs_create_file(name
, S_IFREG
| S_IRUGO
| S_IWUSR
,
244 q
->irq_ptr
->debugfs_dev
, q
, &debugfs_fops
);
245 if (IS_ERR(q
->debugfs_q
))
249 void qdio_setup_debug_entries(struct qdio_irq
*irq_ptr
, struct ccw_device
*cdev
)
254 irq_ptr
->debugfs_dev
= debugfs_create_dir(dev_name(&cdev
->dev
),
256 if (IS_ERR(irq_ptr
->debugfs_dev
))
257 irq_ptr
->debugfs_dev
= NULL
;
259 irq_ptr
->debugfs_perf
= debugfs_create_file("statistics",
260 S_IFREG
| S_IRUGO
| S_IWUSR
,
261 irq_ptr
->debugfs_dev
, irq_ptr
,
263 if (IS_ERR(irq_ptr
->debugfs_perf
))
264 irq_ptr
->debugfs_perf
= NULL
;
266 for_each_input_queue(irq_ptr
, q
, i
)
267 setup_debugfs_entry(q
, cdev
);
268 for_each_output_queue(irq_ptr
, q
, i
)
269 setup_debugfs_entry(q
, cdev
);
272 void qdio_shutdown_debug_entries(struct qdio_irq
*irq_ptr
, struct ccw_device
*cdev
)
277 for_each_input_queue(irq_ptr
, q
, i
)
278 debugfs_remove(q
->debugfs_q
);
279 for_each_output_queue(irq_ptr
, q
, i
)
280 debugfs_remove(q
->debugfs_q
);
281 debugfs_remove(irq_ptr
->debugfs_perf
);
282 debugfs_remove(irq_ptr
->debugfs_dev
);
285 int __init
qdio_debug_init(void)
287 debugfs_root
= debugfs_create_dir("qdio", NULL
);
289 qdio_dbf_setup
= debug_register("qdio_setup", 16, 1, 16);
290 debug_register_view(qdio_dbf_setup
, &debug_hex_ascii_view
);
291 debug_set_level(qdio_dbf_setup
, DBF_INFO
);
292 DBF_EVENT("dbf created\n");
294 qdio_dbf_error
= debug_register("qdio_error", 4, 1, 16);
295 debug_register_view(qdio_dbf_error
, &debug_hex_ascii_view
);
296 debug_set_level(qdio_dbf_error
, DBF_INFO
);
297 DBF_ERROR("dbf created\n");
301 void qdio_debug_exit(void)
303 debugfs_remove(debugfs_root
);
305 debug_unregister(qdio_dbf_setup
);
307 debug_unregister(qdio_dbf_error
);