xref: /illumos-gate/usr/src/uts/common/sys/fibre-channel/fca/qlc/ql_debug.h (revision 374858d291554c199353841e2900bc130463934a)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /* Copyright 2009 QLogic Corporation */
23 
24 /*
25  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #ifndef	_QL_DEBUG_H
30 #define	_QL_DEBUG_H
31 
32 /*
33  * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver header file.
34  *
35  * ***********************************************************************
36  * *									**
37  * *				NOTICE					**
38  * *		COPYRIGHT (C) 1996-2009 QLOGIC CORPORATION		**
39  * *			ALL RIGHTS RESERVED				**
40  * *									**
41  * ***********************************************************************
42  *
43  */
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * Driver debug definitions in makefile.
51  *
52  * QL_DEBUG_LEVEL_1=0x1
53  * QL_DEBUG_LEVEL_2=0x2		Output error msgs.
54  * QL_DEBUG_LEVEL_3=0x4		Output function trace msgs.
55  * QL_DEBUG_LEVEL_4=0x8		Output NVRAM trace msgs.
56  * QL_DEBUG_LEVEL_5=0x10	Output ring trace msgs.
57  * QL_DEBUG_LEVEL_6=0x20	Output WATCHDOG timer trace.
58  * QL_DEBUG_LEVEL_7=0x40
59  * QL_DEBUG_LEVEL_8=0x80	Output ring staturation msgs.
60  * QL_DEBUG_LEVEL_9=0x100	Output IOCTL trace.
61  * QL_DEBUG_LEVEL_10=0x200
62  * QL_DEBUG_LEVEL_11=0x400
63  * QL_DEBUG_LEVEL_12=0x1000
64  * QL_DEBUG_LEVEL_13=0x2000
65  * QL_DEBUG_LEVEL_14=0x4000
66  * QL_DEBUG_LEVEL_15=0x8000
67  */
68 
69 void ql_dump_buffer(uint8_t *, uint8_t, uint32_t);
70 void ql_el_msg(ql_adapter_state_t *, const char *, int, ...);
71 void ql_dbg_msg(const char *, int, ...);
72 int ql_flash_errlog(ql_adapter_state_t *, uint16_t, uint16_t, uint16_t,
73     uint16_t);
74 void ql_dump_el_trace_buffer(ql_adapter_state_t *);
75 
76 #if (QL_DEBUG & 0xffff)
77 #define	QL_DEBUG_ROUTINES
78 #define	QL_BANG
79 #define	QL_QUESTION
80 #define	QL_CAROT
81 #else
82 #define	QL_BANG		"!"
83 #define	QL_QUESTION	"?"
84 #define	QL_CAROT	"^"
85 #endif
86 
87 /*
88  * Macros.
89  */
90 #define	GLOBAL_EL_LOCK()	mutex_enter(&ql_global_el_mutex)
91 #define	GLOBAL_EL_UNLOCK()	mutex_exit(&ql_global_el_mutex)
92 
93 #define	TRACE_BUFFER_LOCK(ha)	mutex_enter(&ha->el_trace_desc->mutex)
94 #define	TRACE_BUFFER_UNLOCK(ha)	mutex_exit(&ha->el_trace_desc->mutex)
95 
96 #define	EL(ha, ...) 		ql_el_msg(ha, __func__, CE_CONT, __VA_ARGS__);
97 
98 #define	ER(s)			cmn_err(CE_CONT, QL_BANG "%s", s);
99 #define	ERV(s, ...)		cmn_err(CE_CONT, QL_BANG s, __VA_ARGS__);
100 
101 #define	EL_BUFFER_RESERVE	256
102 #define	DEBUG_STK_DEPTH		24
103 
104 #if QL_DEBUG & 1
105 #define	QL_DEBUG_LEVEL_1
106 #define	QL_PRINT_1(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
107 #define	QL_DUMP_1(bp, wdsize, count) \
108 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
109 #else
110 #define	QL_PRINT_1(...)
111 #define	QL_DUMP_1(bp, wdsize, count)
112 #endif
113 
114 #ifdef QL_DEBUG_ROUTINES
115 #define	QL_DEBUG_LEVEL_2
116 #define	QL_PRINT_2(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
117 #define	QL_DUMP_2(bp, wdsize, count) \
118 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
119 #else
120 #define	QL_PRINT_2(...)
121 #define	QL_DUMP_2(bp, wdsize, count)
122 #endif
123 
124 #if QL_DEBUG & 4
125 #define	QL_DEBUG_LEVEL_3
126 #define	QL_PRINT_3(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
127 #define	QL_DUMP_3(bp, wdsize, count) \
128 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
129 #else
130 #define	QL_PRINT_3(...)
131 #define	QL_DUMP_3(bp, wdsize, count)
132 #endif
133 
134 #if QL_DEBUG & 8
135 #define	QL_DEBUG_LEVEL_4
136 #define	QL_PRINT_4(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
137 #define	QL_DUMP_4(bp, wdsize, count) \
138 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
139 #else
140 #define	QL_PRINT_4(...)
141 #define	QL_DUMP_4(bp, wdsize, count)
142 #endif
143 
144 #if QL_DEBUG & 0x10
145 #define	QL_DEBUG_LEVEL_5
146 #define	QL_PRINT_5(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
147 #define	QL_DUMP_5(bp, wdsize, count) \
148 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
149 #else
150 #define	QL_PRINT_5(...)
151 #define	QL_DUMP_5(bp, wdsize, count)
152 #endif
153 
154 #if QL_DEBUG & 0x20
155 #define	QL_DEBUG_LEVEL_6
156 #define	QL_PRINT_6(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
157 #define	QL_DUMP_6(bp, wdsize, count) \
158 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
159 #else
160 #define	QL_PRINT_6(...)
161 #define	QL_DUMP_6(bp, wdsize, count)
162 #endif
163 
164 #if QL_DEBUG & 0x40
165 #define	QL_DEBUG_LEVEL_7
166 #define	QL_PRINT_7(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
167 #define	QL_DUMP_7(bp, wdsize, count) \
168 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
169 #else
170 #define	QL_PRINT_7(...)
171 #define	QL_DUMP_7(bp, wdsize, count)
172 #endif
173 
174 #if QL_DEBUG & 0x80
175 #define	QL_DEBUG_LEVEL_8
176 #define	QL_PRINT_8(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
177 #define	QL_DUMP_8(bp, wdsize, count) \
178 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
179 #else
180 #define	QL_PRINT_8(...)
181 #define	QL_DUMP_8(bp, wdsize, count)
182 #endif
183 
184 #if QL_DEBUG & 0x104
185 #define	QL_PRINT_9(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
186 #define	QL_DUMP_9(bp, wdsize, count) \
187 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
188 #else
189 #define	QL_PRINT_9(...)
190 #define	QL_DUMP_9(bp, wdsize, count)
191 #endif
192 
193 #if QL_DEBUG & 0x200
194 #define	QL_DEBUG_LEVEL_10
195 #define	QL_PRINT_10(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
196 #define	QL_DUMP_10(bp, wdsize, count) \
197 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
198 #else
199 #define	QL_PRINT_10(...)
200 #define	QL_DUMP_10(bp, wdsize, count)
201 #endif
202 
203 #if QL_DEBUG & 0x400
204 #define	QL_DEBUG_LEVEL_11
205 #define	QL_PRINT_11(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
206 #define	QL_DUMP_11(bp, wdsize, count) \
207 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
208 #else
209 #define	QL_PRINT_11(...)
210 #define	QL_DUMP_11(bp, wdsize, count)
211 #endif
212 
213 #if QL_DEBUG & 0x800
214 #define	QL_DEBUG_LEVEL_12
215 #define	QL_PRINT_12(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
216 #define	QL_DUMP_12(bp, wdsize, count) \
217 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
218 #else
219 #define	QL_PRINT_12(...)
220 #define	QL_DUMP_12(bp, wdsize, count)
221 #endif
222 
223 #if QL_DEBUG & 0x1000
224 #define	QL_DEBUG_LEVEL_13
225 #define	QL_PRINT_13(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
226 #define	QL_DUMP_13(bp, wdsize, count) \
227 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
228 #else
229 #define	QL_PRINT_13(...)
230 #define	QL_DUMP_13(bp, wdsize, count)
231 #endif
232 
233 #if QL_DEBUG & 0x2000
234 #define	QL_DEBUG_LEVEL_14
235 #define	QL_PRINT_14(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
236 #define	QL_DUMP_14(bp, wdsize, count) \
237 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
238 #else
239 #define	QL_PRINT_14(...)
240 #define	QL_DUMP_14(bp, wdsize, count)
241 #endif
242 
243 #if QL_DEBUG & 0x4000
244 #define	QL_DEBUG_LEVEL_15
245 #define	QL_PRINT_15(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
246 #define	QL_DUMP_15(bp, wdsize, count) \
247 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
248 #else
249 #define	QL_PRINT_15(...)
250 #define	QL_DUMP_15(bp, wdsize, count)
251 #endif
252 
253 #if QL_DEBUG & 0x8000
254 #define	QL_DEBUG_LEVEL_16
255 #define	QL_PRINT_16(ce, ...)	ql_dbg_msg(__func__, ce, __VA_ARGS__)
256 #define	QL_DUMP_16(bp, wdsize, count) \
257 	ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
258 #else
259 #define	QL_PRINT_16(...)
260 #define	QL_DUMP_16(bp, wdsize, count)
261 #endif
262 
263 #ifdef	__cplusplus
264 }
265 #endif
266 
267 #endif /* _QL_DEBUG_H */
268