2 * drivers/s390/net/ctcm_dbug.h
4 * Copyright IBM Corp. 2001, 2007
5 * Authors: Peter Tiedemann (ptiedem@de.ibm.com)
13 * Debug Facility stuff
16 #include <asm/debug.h>
24 #define do_debug_data 1
26 #define do_debug_data 0
29 #define do_debug_ccw 1
31 #define do_debug_ccw 0
34 /* define dbf debug levels similar to kernel msg levels */
35 #define CTC_DBF_ALWAYS 0 /* always print this */
36 #define CTC_DBF_EMERG 0 /* system is unusable */
37 #define CTC_DBF_ALERT 1 /* action must be taken immediately */
38 #define CTC_DBF_CRIT 2 /* critical conditions */
39 #define CTC_DBF_ERROR 3 /* error conditions */
40 #define CTC_DBF_WARN 4 /* warning conditions */
41 #define CTC_DBF_NOTICE 5 /* normal but significant condition */
42 #define CTC_DBF_INFO 5 /* informational */
43 #define CTC_DBF_DEBUG 6 /* debug-level messages */
45 DECLARE_PER_CPU(char[256], ctcm_dbf_txt_buf
);
54 CTCM_DBF_INFOS
/* must be last element */
57 struct ctcm_dbf_info
{
58 char name
[DEBUG_MAX_NAME_LEN
];
66 extern struct ctcm_dbf_info ctcm_dbf
[CTCM_DBF_INFOS
];
68 int ctcm_register_dbf_views(void);
69 void ctcm_unregister_dbf_views(void);
71 static inline const char *strtail(const char *s
, int n
)
74 return (l
> n
) ? s
+ (l
- n
) : s
;
77 /* sort out levels early to avoid unnecessary sprintfs */
78 static inline int ctcm_dbf_passes(debug_info_t
*dbf_grp
, int level
)
80 return (dbf_grp
->level
>= level
);
83 #define CTCM_FUNTAIL strtail((char *)__func__, 16)
85 #define CTCM_DBF_TEXT(name, level, text) \
87 debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \
90 #define CTCM_DBF_HEX(name, level, addr, len) \
92 debug_event(ctcm_dbf[CTCM_DBF_##name].id, \
93 level, (void *)(addr), len); \
96 #define CTCM_DBF_TEXT_(name, level, text...) \
98 if (ctcm_dbf_passes(ctcm_dbf[CTCM_DBF_##name].id, level)) { \
99 char *ctcm_dbf_txt_buf = \
100 get_cpu_var(ctcm_dbf_txt_buf); \
101 sprintf(ctcm_dbf_txt_buf, text); \
102 debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, \
103 level, ctcm_dbf_txt_buf); \
104 put_cpu_var(ctcm_dbf_txt_buf); \
109 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
110 * dev : netdevice with valid name field.
111 * text: any text string.
113 #define CTCM_DBF_DEV_NAME(cat, dev, text) \
115 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) : %s", \
116 CTCM_FUNTAIL, dev->name, text); \
119 #define MPC_DBF_DEV_NAME(cat, dev, text) \
121 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) : %s", \
122 CTCM_FUNTAIL, dev->name, text); \
125 #define CTCMY_DBF_DEV_NAME(cat, dev, text) \
127 if (IS_MPCDEV(dev)) \
128 MPC_DBF_DEV_NAME(cat, dev, text); \
130 CTCM_DBF_DEV_NAME(cat, dev, text); \
134 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
136 * text: any text string.
138 #define CTCM_DBF_DEV(cat, dev, text) \
140 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) : %s", \
141 CTCM_FUNTAIL, dev, text); \
144 #define MPC_DBF_DEV(cat, dev, text) \
146 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) : %s", \
147 CTCM_FUNTAIL, dev, text); \
150 #define CTCMY_DBF_DEV(cat, dev, text) \
152 if (IS_MPCDEV(dev)) \
153 MPC_DBF_DEV(cat, dev, text); \
155 CTCM_DBF_DEV(cat, dev, text); \