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