aboutsummaryrefslogtreecommitdiff
path: root/drivers/s390/net/ctcm_dbug.h
blob: fdff34fe59a2e994edb39260a89233e3d876f855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
 *	drivers/s390/net/ctcm_dbug.h
 *
 *	Copyright IBM Corp. 2001, 2007
 *	Authors:	Peter Tiedemann (ptiedem@de.ibm.com)
 *
 */

#ifndef _CTCM_DBUG_H_
#define _CTCM_DBUG_H_

/*
 * Debug Facility stuff
 */

#include <asm/debug.h>

#ifdef DEBUG
 #define do_debug 1
#else
 #define do_debug 0
#endif
#ifdef DEBUGDATA
 #define do_debug_data 1
#else
 #define do_debug_data 0
#endif
#ifdef DEBUGCCW
 #define do_debug_ccw 1
#else
 #define do_debug_ccw 0
#endif

/* define dbf debug levels similar to kernel msg levels */
#define	CTC_DBF_ALWAYS	0	/* always print this 			*/
#define	CTC_DBF_EMERG	0	/* system is unusable			*/
#define	CTC_DBF_ALERT	1	/* action must be taken immediately	*/
#define	CTC_DBF_CRIT	2	/* critical conditions			*/
#define	CTC_DBF_ERROR	3	/* error conditions			*/
#define	CTC_DBF_WARN	4	/* warning conditions			*/
#define	CTC_DBF_NOTICE	5	/* normal but significant condition	*/
#define	CTC_DBF_INFO	5	/* informational			*/
#define	CTC_DBF_DEBUG	6	/* debug-level messages			*/

DECLARE_PER_CPU(char[256], ctcm_dbf_txt_buf);

enum ctcm_dbf_names {
	CTCM_DBF_SETUP,
	CTCM_DBF_ERROR,
	CTCM_DBF_TRACE,
	CTCM_DBF_MPC_SETUP,
	CTCM_DBF_MPC_ERROR,
	CTCM_DBF_MPC_TRACE,
	CTCM_DBF_INFOS	/* must be last element */
};

struct ctcm_dbf_info {
	char name[DEBUG_MAX_NAME_LEN];
	int pages;
	int areas;
	int len;
	int level;
	debug_info_t *id;
};

extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS];

int ctcm_register_dbf_views(void);
void ctcm_unregister_dbf_views(void);

static inline const char *strtail(const char *s, int n)
{
	int l = strlen(s);
	return (l > n) ? s + (l - n) : s;
}

/* sort out levels early to avoid unnecessary sprintfs */
static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level)
{
	return (dbf_grp->level >= level);
}

#define CTCM_FUNTAIL strtail((char *)__func__, 16)

#define CTCM_DBF_TEXT(name, level, text) \
	do { \
		debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \
	} while (0)

#define CTCM_DBF_HEX(name, level, addr, len) \
	do { \
		debug_event(ctcm_dbf[CTCM_DBF_##name].id, \
					level, (void *)(addr), len); \
	} while (0)

#define CTCM_DBF_TEXT_(name, level, text...) \
	do { \
		if (ctcm_dbf_passes(ctcm_dbf[CTCM_DBF_##name].id, level)) { \
			char *ctcm_dbf_txt_buf = \
					 get_cpu_var(ctcm_dbf_txt_buf); \
			sprintf(ctcm_dbf_txt_buf, text); \
			debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, \
					level, ctcm_dbf_txt_buf); \
			put_cpu_var(ctcm_dbf_txt_buf); \
		} \
	} while (0)

/*
 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
 * dev : netdevice with valid name field.
 * text: any text string.
 */
#define CTCM_DBF_DEV_NAME(cat, dev, text) \
	do { \
		CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) : %s", \
			CTCM_FUNTAIL, dev->name, text); \
	} while (0)

#define MPC_DBF_DEV_NAME(cat, dev, text) \
	do { \
		CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) : %s", \
			CTCM_FUNTAIL, dev->name, text); \
	} while (0)

#define CTCMY_DBF_DEV_NAME(cat, dev, text) \
	do { \
		if (IS_MPCDEV(dev)) \
			MPC_DBF_DEV_NAME(cat, dev, text); \
		else \
			CTCM_DBF_DEV_NAME(cat, dev, text); \
	} while (0)

/*
 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
 * dev : netdevice.
 * text: any text string.
 */
#define CTCM_DBF_DEV(cat, dev, text) \
	do { \
		CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) : %s", \
			CTCM_FUNTAIL, dev, text); \
	} while (0)

#define MPC_DBF_DEV(cat, dev, text) \
	do { \
		CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) : %s", \
			CTCM_FUNTAIL, dev, text); \
	} while (0)

#define CTCMY_DBF_DEV(cat, dev, text) \
	do { \
		if (IS_MPCDEV(dev)) \
			MPC_DBF_DEV(cat, dev, text); \
		else \
			CTCM_DBF_DEV(cat, dev, text); \
	} while (0)

#endif