1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2001, 2007
4 * Authors: Peter Tiedemann (ptiedem@de.ibm.com)
12 * Debug Facility stuff
15 #include <asm/debug.h>
23 #define do_debug_ccw 1
26 #define do_debug_ccw 0
29 #define do_debug_data 1
31 #define do_debug_data 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 */
52 CTCM_DBF_INFOS /* must be last element */
55 struct ctcm_dbf_info {
56 char name[DEBUG_MAX_NAME_LEN];
64 extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS];
66 int ctcm_register_dbf_views(void);
67 void ctcm_unregister_dbf_views(void);
69 void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *text, ...);
71 static inline const char *strtail(const char *s, int n)
74 return (l > n) ? s + (l - n) : s;
77 #define CTCM_FUNTAIL strtail((char *)__func__, 16)
79 #define CTCM_DBF_TEXT(name, level, text) \
81 debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \
84 #define CTCM_DBF_HEX(name, level, addr, len) \
86 debug_event(ctcm_dbf[CTCM_DBF_##name].id, \
87 level, (void *)(addr), len); \
90 #define CTCM_DBF_TEXT_(name, level, text...) \
91 ctcm_dbf_longtext(CTCM_DBF_##name, level, text)
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.
98 #define CTCM_DBF_DEV_NAME(cat, dev, text) \
100 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) :- %s", \
101 CTCM_FUNTAIL, dev->name, text); \
104 #define MPC_DBF_DEV_NAME(cat, dev, text) \
106 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) := %s", \
107 CTCM_FUNTAIL, dev->name, text); \
110 #define CTCMY_DBF_DEV_NAME(cat, dev, text) \
112 if (IS_MPCDEV(dev)) \
113 MPC_DBF_DEV_NAME(cat, dev, text); \
115 CTCM_DBF_DEV_NAME(cat, dev, text); \
119 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
121 * text: any text string.
123 #define CTCM_DBF_DEV(cat, dev, text) \
125 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) :-: %s", \
126 CTCM_FUNTAIL, dev, text); \
129 #define MPC_DBF_DEV(cat, dev, text) \
131 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) :=: %s", \
132 CTCM_FUNTAIL, dev, text); \
135 #define CTCMY_DBF_DEV(cat, dev, text) \
137 if (IS_MPCDEV(dev)) \
138 MPC_DBF_DEV(cat, dev, text); \
140 CTCM_DBF_DEV(cat, dev, text); \