xref: /openbmc/linux/drivers/s390/cio/qdio_debug.h (revision 79f08d9e)
1 /*
2  *  Copyright IBM Corp. 2008
3  *
4  *  Author: Jan Glauber (jang@linux.vnet.ibm.com)
5  */
6 #ifndef QDIO_DEBUG_H
7 #define QDIO_DEBUG_H
8 
9 #include <asm/debug.h>
10 #include <asm/qdio.h>
11 #include "qdio.h"
12 
13 /* that gives us 15 characters in the text event views */
14 #define QDIO_DBF_LEN	16
15 
16 extern debug_info_t *qdio_dbf_setup;
17 extern debug_info_t *qdio_dbf_error;
18 
19 #define DBF_ERR		3	/* error conditions	*/
20 #define DBF_WARN	4	/* warning conditions	*/
21 #define DBF_INFO	6	/* informational	*/
22 
23 #undef DBF_EVENT
24 #undef DBF_ERROR
25 #undef DBF_DEV_EVENT
26 
27 #define DBF_EVENT(text...) \
28 	do { \
29 		char debug_buffer[QDIO_DBF_LEN]; \
30 		snprintf(debug_buffer, QDIO_DBF_LEN, text); \
31 		debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \
32 	} while (0)
33 
34 static inline void DBF_HEX(void *addr, int len)
35 {
36 	while (len > 0) {
37 		debug_event(qdio_dbf_setup, DBF_ERR, addr, len);
38 		len -= qdio_dbf_setup->buf_size;
39 		addr += qdio_dbf_setup->buf_size;
40 	}
41 }
42 
43 #define DBF_ERROR(text...) \
44 	do { \
45 		char debug_buffer[QDIO_DBF_LEN]; \
46 		snprintf(debug_buffer, QDIO_DBF_LEN, text); \
47 		debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \
48 	} while (0)
49 
50 static inline void DBF_ERROR_HEX(void *addr, int len)
51 {
52 	while (len > 0) {
53 		debug_event(qdio_dbf_error, DBF_ERR, addr, len);
54 		len -= qdio_dbf_error->buf_size;
55 		addr += qdio_dbf_error->buf_size;
56 	}
57 }
58 
59 #define DBF_DEV_EVENT(level, device, text...) \
60 	do { \
61 		char debug_buffer[QDIO_DBF_LEN]; \
62 		if (debug_level_enabled(device->debug_area, level)) { \
63 			snprintf(debug_buffer, QDIO_DBF_LEN, text); \
64 			debug_text_event(device->debug_area, level, debug_buffer); \
65 		} \
66 	} while (0)
67 
68 static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr,
69 			       int len, int level)
70 {
71 	while (len > 0) {
72 		debug_event(dev->debug_area, level, addr, len);
73 		len -= dev->debug_area->buf_size;
74 		addr += dev->debug_area->buf_size;
75 	}
76 }
77 
78 void qdio_allocate_dbf(struct qdio_initialize *init_data,
79 		       struct qdio_irq *irq_ptr);
80 void qdio_setup_debug_entries(struct qdio_irq *irq_ptr,
81 			      struct ccw_device *cdev);
82 void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr);
83 int qdio_debug_init(void);
84 void qdio_debug_exit(void);
85 
86 #endif
87