xref: /titanic_41/usr/src/uts/common/sys/ib/mgt/ibmf/ibmf_trace.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_IB_MGT_IBMF_IBMF_TRACE_H
28 #define	_SYS_IB_MGT_IBMF_IBMF_TRACE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * This file contains the IBMF trace/debug macros.
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/tnf_probe.h>
41 
42 #define	IBMF_TNF_ERROR		"ibmf ibmf_error"
43 #define	IBMF_TNF_TRACE		"ibmf ibmf_trace"
44 
45 /*
46  * Trace levels for printing
47  */
48 #define	DPRINT_L0	0	/* no messages */
49 #define	DPRINT_L1	1	/* major errors */
50 #define	DPRINT_L2	2	/* minor errors */
51 #define	DPRINT_L3	3	/* general debug */
52 #define	DPRINT_L4	4	/* general trace */
53 
54 /*
55  * Trace probe macros
56  */
57 #define	IBMF_TNF_NODEBUG	0
58 #define	IBMF_TNF_DEBUG		1
59 
60 #ifdef NPROBE /* NPROBE */
61 
62 #define	IBMF_TRACE_0(debug, trlevel, arg01, arg02, arg03, arg04)	\
63 	if (ibmf_trace_level > 0) {				\
64 		ibmf_dprintf(trlevel, arg04);			\
65 	}
66 
67 /* CSTYLED */
68 #define	IBMF_TRACE_1(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13)								\
69 	if (ibmf_trace_level > 0) {				\
70 		ibmf_dprintf(trlevel, arg04, arg13);		\
71 	}
72 
73 /* CSTYLED */
74 #define	IBMF_TRACE_2(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23)					\
75 	if (ibmf_trace_level > 0) {				\
76 		ibmf_dprintf(trlevel, arg04, arg13, arg23);	\
77 	}
78 
79 /* CSTYLED */
80 #define	IBMF_TRACE_3(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23, arg31, arg32, arg33)			\
81 	if (ibmf_trace_level > 0) {				\
82 		ibmf_dprintf(trlevel, arg04, arg13, arg23, arg33);	\
83 	}
84 
85 /* CSTYLED */
86 #define	IBMF_TRACE_4(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23, arg31, arg32, arg33, arg41, arg42, arg43)	\
87 	if (ibmf_trace_level > 0) {				\
88 		ibmf_dprintf(trlevel, arg04, arg13, arg23, arg33, arg43);\
89 	}
90 
91 /* CSTYLED */
92 #define	IBMF_TRACE_5(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23, arg31, arg32, arg33, arg41, arg42, arg43, arg51, arg52, arg53)	\
93 	if (ibmf_trace_level > 0) {				\
94 		ibmf_dprintf(trlevel, arg04, arg13, arg23, arg33, \
95 		    arg43, arg53);				\
96 	}
97 
98 #else
99 
100 #define	IBMF_TRACE_0(debug, trlevel, arg01, arg02, arg03, arg04)	\
101 {								\
102 	boolean_t	use_debug = debug;			\
103 	if (use_debug) {					\
104 		TNF_PROBE_0_DEBUG(arg01, arg02, arg03);		\
105 	} else {						\
106 		TNF_PROBE_0(arg01, arg02, arg03);		\
107 	}							\
108 	if (ibmf_trace_level > 0) {				\
109 		ibmf_dprintf(trlevel, arg04);			\
110 	}							\
111 }
112 
113 /* CSTYLED */
114 #define	IBMF_TRACE_1(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13) 								\
115 {								\
116 	boolean_t	use_debug = debug;			\
117 	if (use_debug) {					\
118 		TNF_PROBE_1_DEBUG(arg01, arg02, arg03, arg11, arg12, arg13);\
119 	} else {						\
120 		TNF_PROBE_1(arg01, arg02, arg03, arg11, arg12, arg13);	\
121 	}							\
122 	if (ibmf_trace_level > 0) {				\
123 		ibmf_dprintf(trlevel, arg04, arg13);		\
124 	}							\
125 }
126 
127 /* CSTYLED */
128 #define	IBMF_TRACE_2(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23) 					\
129 {								\
130 	boolean_t	use_debug = debug;			\
131 	if (use_debug) {					\
132 		TNF_PROBE_2_DEBUG(arg01, arg02, arg03, arg11, arg12, \
133 		    arg13, arg21, arg22, arg23);		\
134 	} else {						\
135 		TNF_PROBE_2(arg01, arg02, arg03, arg11, arg12, arg13, \
136 		    arg21, arg22, arg23);			\
137 	}							\
138 	if (ibmf_trace_level > 0) {				\
139 		ibmf_dprintf(trlevel, arg04, arg13, arg23);	\
140 	}							\
141 }
142 
143 /* CSTYLED */
144 #define	IBMF_TRACE_3(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23, arg31, arg32, arg33) 		\
145 {								\
146 	boolean_t	use_debug = debug;			\
147 	if (use_debug) {					\
148 		TNF_PROBE_3_DEBUG(arg01, arg02, arg03, arg11, arg12, arg13, \
149 		    arg21, arg22, arg23, arg31, arg32, arg33);	\
150 	} else {						\
151 		TNF_PROBE_3(arg01, arg02, arg03, arg11, arg12, arg13, arg21, \
152 		    arg22, arg23, arg31, arg32, arg33);		\
153 	}							\
154 	if (ibmf_trace_level > 0) {				\
155 		ibmf_dprintf(trlevel, arg04, arg13, arg23, arg33);	\
156 	}							\
157 }
158 
159 /* CSTYLED */
160 #define	IBMF_TRACE_4(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23, arg31, arg32, arg33, arg41, arg42, arg43) \
161 {								\
162 	boolean_t	use_debug = debug;			\
163 	if (use_debug) {					\
164 		TNF_PROBE_4_DEBUG(arg01, arg02, arg03, arg11, arg12, arg13, \
165 		    arg21, arg22, arg23, arg31, arg32, arg33, arg41, arg42, \
166 		    arg43);						\
167 	} else {						\
168 		TNF_PROBE_4(arg01, arg02, arg03, arg11, arg12, arg13, arg21, \
169 		    arg22, arg23, arg31, arg32, arg33, arg41, arg42, arg43); \
170 	}							\
171 	if (ibmf_trace_level > 0) {				\
172 		ibmf_dprintf(trlevel, arg04, arg13, arg23, arg33, arg43);\
173 	}							\
174 }
175 
176 /* CSTYLED */
177 #define	IBMF_TRACE_5(debug, trlevel, arg01, arg02, arg03, arg04, arg11, arg12, arg13, arg21, arg22, arg23, arg31, arg32, arg33, arg41, arg42, arg43, arg51, arg52, arg53) 							\
178 {								\
179 	boolean_t	use_debug = debug;			\
180 	if (use_debug) {					\
181 		TNF_PROBE_5_DEBUG(arg01, arg02, arg03, arg11, arg12, arg13, \
182 		    arg21, arg22, arg23, arg31, arg32, arg33, arg41, arg42, \
183 		    arg43, arg51, arg52, arg53);		\
184 	} else {						\
185 		TNF_PROBE_5(arg01, arg02, arg03, arg11, arg12, arg13, arg21, \
186 		    arg22, arg23, arg31, arg32, arg33, arg41, arg42, arg43, \
187 		    arg51, arg52, arg53);			\
188 	}							\
189 	if (ibmf_trace_level > 0) {				\
190 		ibmf_dprintf(trlevel, arg04, arg13, arg23, arg33, arg43, \
191 		    arg53);					\
192 	}							\
193 }
194 
195 #endif
196 
197 void
198 ibmf_dprintf(int l, const char *fmt, ...);
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* _SYS_IB_MGT_IBMF_IBMF_TRACE_H */
205