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