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