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