xref: /openbmc/linux/drivers/s390/net/ctcm_dbug.h (revision 93dc544c)
1 /*
2  *	drivers/s390/net/ctcm_dbug.h
3  *
4  *	Copyright IBM Corp. 2001, 2007
5  *	Authors:	Peter Tiedemann (ptiedem@de.ibm.com)
6  *
7  */
8 
9 #ifndef _CTCM_DBUG_H_
10 #define _CTCM_DBUG_H_
11 
12 /*
13  * Debug Facility stuff
14  */
15 
16 #include <asm/debug.h>
17 
18 #ifdef DEBUG
19  #define do_debug 1
20 #else
21  #define do_debug 0
22 #endif
23 #ifdef DEBUGCCW
24  #define do_debug_ccw 1
25  #define DEBUGDATA 1
26 #else
27  #define do_debug_ccw 0
28 #endif
29 #ifdef DEBUGDATA
30  #define do_debug_data 1
31 #else
32  #define do_debug_data 0
33 #endif
34 
35 /* define dbf debug levels similar to kernel msg levels */
36 #define	CTC_DBF_ALWAYS	0	/* always print this 			*/
37 #define	CTC_DBF_EMERG	0	/* system is unusable			*/
38 #define	CTC_DBF_ALERT	1	/* action must be taken immediately	*/
39 #define	CTC_DBF_CRIT	2	/* critical conditions			*/
40 #define	CTC_DBF_ERROR	3	/* error conditions			*/
41 #define	CTC_DBF_WARN	4	/* warning conditions			*/
42 #define	CTC_DBF_NOTICE	5	/* normal but significant condition	*/
43 #define	CTC_DBF_INFO	5	/* informational			*/
44 #define	CTC_DBF_DEBUG	6	/* debug-level messages			*/
45 
46 enum ctcm_dbf_names {
47 	CTCM_DBF_SETUP,
48 	CTCM_DBF_ERROR,
49 	CTCM_DBF_TRACE,
50 	CTCM_DBF_MPC_SETUP,
51 	CTCM_DBF_MPC_ERROR,
52 	CTCM_DBF_MPC_TRACE,
53 	CTCM_DBF_INFOS	/* must be last element */
54 };
55 
56 struct ctcm_dbf_info {
57 	char name[DEBUG_MAX_NAME_LEN];
58 	int pages;
59 	int areas;
60 	int len;
61 	int level;
62 	debug_info_t *id;
63 };
64 
65 extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS];
66 
67 int ctcm_register_dbf_views(void);
68 void ctcm_unregister_dbf_views(void);
69 void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *text, ...);
70 
71 static inline const char *strtail(const char *s, int n)
72 {
73 	int l = strlen(s);
74 	return (l > n) ? s + (l - n) : s;
75 }
76 
77 #define CTCM_FUNTAIL strtail((char *)__func__, 16)
78 
79 #define CTCM_DBF_TEXT(name, level, text) \
80 	do { \
81 		debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \
82 	} while (0)
83 
84 #define CTCM_DBF_HEX(name, level, addr, len) \
85 	do { \
86 		debug_event(ctcm_dbf[CTCM_DBF_##name].id, \
87 					level, (void *)(addr), len); \
88 	} while (0)
89 
90 #define CTCM_DBF_TEXT_(name, level, text...) \
91 	ctcm_dbf_longtext(CTCM_DBF_##name, level, text)
92 
93 /*
94  * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
95  * dev : netdevice with valid name field.
96  * text: any text string.
97  */
98 #define CTCM_DBF_DEV_NAME(cat, dev, text) \
99 	do { \
100 		CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) :- %s", \
101 			CTCM_FUNTAIL, dev->name, text); \
102 	} while (0)
103 
104 #define MPC_DBF_DEV_NAME(cat, dev, text) \
105 	do { \
106 		CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) := %s", \
107 			CTCM_FUNTAIL, dev->name, text); \
108 	} while (0)
109 
110 #define CTCMY_DBF_DEV_NAME(cat, dev, text) \
111 	do { \
112 		if (IS_MPCDEV(dev)) \
113 			MPC_DBF_DEV_NAME(cat, dev, text); \
114 		else \
115 			CTCM_DBF_DEV_NAME(cat, dev, text); \
116 	} while (0)
117 
118 /*
119  * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
120  * dev : netdevice.
121  * text: any text string.
122  */
123 #define CTCM_DBF_DEV(cat, dev, text) \
124 	do { \
125 		CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) :-: %s", \
126 			CTCM_FUNTAIL, dev, text); \
127 	} while (0)
128 
129 #define MPC_DBF_DEV(cat, dev, text) \
130 	do { \
131 		CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) :=: %s", \
132 			CTCM_FUNTAIL, dev, text); \
133 	} while (0)
134 
135 #define CTCMY_DBF_DEV(cat, dev, text) \
136 	do { \
137 		if (IS_MPCDEV(dev)) \
138 			MPC_DBF_DEV(cat, dev, text); \
139 		else \
140 			CTCM_DBF_DEV(cat, dev, text); \
141 	} while (0)
142 
143 #endif
144