xref: /illumos-gate/usr/src/uts/common/io/bnxe/bnxe_debug.h (revision 3ba944265c4ae1fcf23ef758537c2e4f4feec16e)
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 /*
23  * Copyright 2014 QLogic Corporation
24  * The contents of this file are subject to the terms of the
25  * QLogic End User License (the "License").
26  * You may not use this file except in compliance with the License.
27  *
28  * You can obtain a copy of the License at
29  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
30  * QLogic_End_User_Software_License.txt
31  * See the License for the specific language governing permissions
32  * and limitations under the License.
33  */
34 
35 /* This file is included by lmdev/include/debug.h */
36 
37 #ifndef __BNXE_DEBUG_H__
38 #define __BNXE_DEBUG_H__
39 
40 #include <sys/types.h>
41 #include <sys/cmn_err.h>
42 #include <sys/ddi.h>
43 #include <sys/sunddi.h>
44 #include <sys/varargs.h>
45 #undef u /* see bnxe.h for explanation */
46 
47 extern char * BnxeDevName(void *);
48 
49 
50 #ifdef DBG
51 
52 /********************************************/
53 /* all DbgXXX() routines are used by the LM */
54 /********************************************/
55 
56 /*
57  * Don't use the __FILE_STRIPPED macro as it will eat up too much read-only
58  * data and dtrace will fail to load on SPARC. Use __BASENAME__ passed to the
59  * compiler in the Makefile.
60  */
61 #if 0
62 #undef __FILE_STRIPPED__
63 #define __FILE_STRIPPED__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
64 #endif
65 
66 void DbgMessageFunc(void * pDev,
67                     int    level,
68                     char * pFmt,
69                     ...);
70 
71 #define DbgMessageXX(_c, _m, _s, ...)                  \
72     DbgMessageFunc(_c, _m, "!%s <0x%08x> %s(%d): " _s, \
73                    BnxeDevName((void *)_c),            \
74                    _m,                                 \
75                    __BASENAME__,                       \
76                    __LINE__,                           \
77                    ##__VA_ARGS__)
78 
79 #define DbgMessage DbgMessageXX
80 
81 #define DbgBreak() cmn_err(CE_PANIC, "%s(%d): DbgBreak!", \
82                            __BASENAME__,                  \
83                            __LINE__)
84 
85 #define DbgBreakMsg(_s) cmn_err(CE_PANIC, "%s(%d): " _s, \
86                                 __BASENAME__,            \
87                                 __LINE__)
88 
89 #define DbgBreakIf(_cond)                                              \
90     if (_cond)                                                         \
91     {                                                                  \
92         cmn_err(CE_PANIC, "%s(%d): Condition Failed! - if ("#_cond")", \
93                 __BASENAME__,                                          \
94                 __LINE__);                                             \
95     }
96 
97 #define DbgBreakFastPath()      DbgBreak()
98 #define DbgBreakMsgFastPath(_s) DbgBreakMsg(_s)
99 #define DbgBreakIfFastPath(_c)  DbgBreakIf(_c)
100 
101 #define dbg_out(_c, _m, _s, _d1) DbgMessageXX(_c, _m, _s, _d1)
102 
103 #endif /* DBG */
104 
105 
106 /*****************************************************************/
107 /* all BnxeDbgXXX() and BnxeLogXXX() routines are used by the UM */
108 /*****************************************************************/
109 
110 #define BnxeDbgBreak(_c) cmn_err(CE_PANIC, "%s: %s(%d): DbgBreak!", \
111                                  BnxeDevName(_c),                   \
112                                  __BASENAME__,                      \
113                                  __LINE__)
114 
115 #define BnxeDbgBreakMsg(_c, _s) cmn_err(CE_PANIC, "%s: %s(%d): " _s, \
116                                         BnxeDevName(_c),             \
117                                         __BASENAME__,                \
118                                         __LINE__)
119 
120 #define BnxeDbgBreakIf(_c, _cond)                                          \
121     if (_cond)                                                             \
122     {                                                                      \
123         cmn_err(CE_PANIC, "%s: %s(%d): Condition Failed! - if ("#_cond")", \
124                 BnxeDevName(_c),                                           \
125                 __BASENAME__,                                              \
126                 __LINE__);                                                 \
127     }
128 
129 #define BnxeDbgBreakFastPath(_c)           BnxeDbgBreak(_c)
130 #define BnxeDbgBreakMsgFastPath(_c, _s)    BnxeDbgBreakMsg(_c, _s)
131 #define BnxeDbgBreakIfFastPath(_c, _cond)  BnxeDbgBreakIf(_c, _cond)
132 
133 void BnxeLogInfo(void * pDev, char * pFmt, ...);
134 void BnxeLogWarn(void * pDev, char * pFmt, ...);
135 /* for CE_PANIC use one of the BnxeDbgBreak macros above */
136 
137 #ifdef DEBUG
138 void BnxeLogDbg(void * pDev, char * pFmt, ...);
139 #else
140 #define BnxeLogDbg
141 #endif
142 
143 #endif /* __BNXE_DEBUG_H__ */
144 
145