2 * Copyright (c) 2007-2011 Broadcom Corporation. All rights reserved.
4 * Gary Zambrano <zambrano@broadcom.com>
5 * David Christensen <davidch@broadcom.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Broadcom Corporation nor the name of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written consent.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
38 extern uint32_t bxe_debug;
41 * Debugging macros and definitions.
44 #define BXE_CP_LOAD 0x00000001
45 #define BXE_CP_SEND 0x00000002
46 #define BXE_CP_RECV 0x00000004
47 #define BXE_CP_INTR 0x00000008
48 #define BXE_CP_UNLOAD 0x00000010
49 #define BXE_CP_RESET 0x00000020
50 #define BXE_CP_IOCTL 0x00000040
51 #define BXE_CP_STATS 0x00000080
52 #define BXE_CP_MISC 0x00000100
53 #define BXE_CP_PHY 0x00000200
54 #define BXE_CP_RAMROD 0x00000400
55 #define BXE_CP_NVRAM 0x00000800
56 #define BXE_CP_REGS 0x00001000
57 #define BXE_CP_TPA 0x00002000
58 #define BXE_CP_ALL 0x00FFFFFF
59 #define BXE_CP_MASK 0x00FFFFFF
61 #define BXE_LEVEL_FATAL 0x00000000
62 #define BXE_LEVEL_WARN 0x01000000
63 #define BXE_LEVEL_INFO 0x02000000
64 #define BXE_LEVEL_VERBOSE 0x03000000
65 #define BXE_LEVEL_EXTREME 0x04000000
66 #define BXE_LEVEL_INSANE 0x05000000
68 #define BXE_LEVEL_MASK 0xFF000000
70 #define BXE_WARN_LOAD (BXE_CP_LOAD | BXE_LEVEL_WARN)
71 #define BXE_INFO_LOAD (BXE_CP_LOAD | BXE_LEVEL_INFO)
72 #define BXE_VERBOSE_LOAD (BXE_CP_LOAD | BXE_LEVEL_VERBOSE)
73 #define BXE_EXTREME_LOAD (BXE_CP_LOAD | BXE_LEVEL_EXTREME)
74 #define BXE_INSANE_LOAD (BXE_CP_LOAD | BXE_LEVEL_INSANE)
76 #define BXE_WARN_SEND (BXE_CP_SEND | BXE_LEVEL_WARN)
77 #define BXE_INFO_SEND (BXE_CP_SEND | BXE_LEVEL_INFO)
78 #define BXE_VERBOSE_SEND (BXE_CP_SEND | BXE_LEVEL_VERBOSE)
79 #define BXE_EXTREME_SEND (BXE_CP_SEND | BXE_LEVEL_EXTREME)
80 #define BXE_INSANE_SEND (BXE_CP_SEND | BXE_LEVEL_INSANE)
82 #define BXE_WARN_RECV (BXE_CP_RECV | BXE_LEVEL_WARN)
83 #define BXE_INFO_RECV (BXE_CP_RECV | BXE_LEVEL_INFO)
84 #define BXE_VERBOSE_RECV (BXE_CP_RECV | BXE_LEVEL_VERBOSE)
85 #define BXE_EXTREME_RECV (BXE_CP_RECV | BXE_LEVEL_EXTREME)
86 #define BXE_INSANE_RECV (BXE_CP_RECV | BXE_LEVEL_INSANE)
88 #define BXE_WARN_INTR (BXE_CP_INTR | BXE_LEVEL_WARN)
89 #define BXE_INFO_INTR (BXE_CP_INTR | BXE_LEVEL_INFO)
90 #define BXE_VERBOSE_INTR (BXE_CP_INTR | BXE_LEVEL_VERBOSE)
91 #define BXE_EXTREME_INTR (BXE_CP_INTR | BXE_LEVEL_EXTREME)
92 #define BXE_INSANE_INTR (BXE_CP_INTR | BXE_LEVEL_INSANE)
94 #define BXE_WARN_UNLOAD (BXE_CP_UNLOAD | BXE_LEVEL_WARN)
95 #define BXE_INFO_UNLOAD (BXE_CP_UNLOAD | BXE_LEVEL_INFO)
96 #define BXE_VERBOSE_UNLOAD (BXE_CP_UNLOAD | BXE_LEVEL_VERBOSE)
97 #define BXE_EXTREME_UNLOAD (BXE_CP_UNLOAD | BXE_LEVEL_EXTREME)
98 #define BXE_INSANE_UNLOAD (BXE_CP_UNLOAD | BXE_LEVEL_INSANE)
100 #define BXE_WARN_RESET (BXE_CP_RESET | BXE_LEVEL_WARN)
101 #define BXE_INFO_RESET (BXE_CP_RESET | BXE_LEVEL_INFO)
102 #define BXE_VERBOSE_RESET (BXE_CP_RESET | BXE_LEVEL_VERBOSE)
103 #define BXE_EXTREME_RESET (BXE_CP_RESET | BXE_LEVEL_EXTREME)
104 #define BXE_INSANE_RESET (BXE_CP_RESET | BXE_LEVEL_INSANE)
106 #define BXE_WARN_IOCTL (BXE_CP_IOCTL | BXE_LEVEL_WARN)
107 #define BXE_INFO_IOCTL (BXE_CP_IOCTL | BXE_LEVEL_INFO)
108 #define BXE_VERBOSE_IOCTL (BXE_CP_IOCTL | BXE_LEVEL_VERBOSE)
109 #define BXE_EXTREME_IOCTL (BXE_CP_IOCTL | BXE_LEVEL_EXTREME)
110 #define BXE_INSANE_IOCTL (BXE_CP_IOCTL | BXE_LEVEL_INSANE)
112 #define BXE_WARN_STATS (BXE_CP_STATS | BXE_LEVEL_WARN)
113 #define BXE_INFO_STATS (BXE_CP_STATS | BXE_LEVEL_INFO)
114 #define BXE_VERBOSE_STATS (BXE_CP_STATS | BXE_LEVEL_VERBOSE)
115 #define BXE_EXTREME_STATS (BXE_CP_STATS | BXE_LEVEL_EXTREME)
116 #define BXE_INSANE_STATS (BXE_CP_STATS | BXE_LEVEL_INSANE)
118 #define BXE_WARN_MISC (BXE_CP_MISC | BXE_LEVEL_WARN)
119 #define BXE_INFO_MISC (BXE_CP_MISC | BXE_LEVEL_INFO)
120 #define BXE_VERBOSE_MISC (BXE_CP_MISC | BXE_LEVEL_VERBOSE)
121 #define BXE_EXTREME_MISC (BXE_CP_MISC | BXE_LEVEL_EXTREME)
122 #define BXE_INSANE_MISC (BXE_CP_MISC | BXE_LEVEL_INSANE)
124 #define BXE_WARN_PHY (BXE_CP_PHY | BXE_LEVEL_WARN)
125 #define BXE_INFO_PHY (BXE_CP_PHY | BXE_LEVEL_INFO)
126 #define BXE_VERBOSE_PHY (BXE_CP_PHY | BXE_LEVEL_VERBOSE)
127 #define BXE_EXTREME_PHY (BXE_CP_PHY | BXE_LEVEL_EXTREME)
128 #define BXE_INSANE_PHY (BXE_CP_PHY | BXE_LEVEL_INSANE)
130 #define BXE_WARN_RAMROD (BXE_CP_RAMROD | BXE_LEVEL_WARN)
131 #define BXE_INFO_RAMROD (BXE_CP_RAMROD | BXE_LEVEL_INFO)
132 #define BXE_VERBOSE_RAMROD (BXE_CP_RAMROD | BXE_LEVEL_VERBOSE)
133 #define BXE_EXTREME_RAMROD (BXE_CP_RAMROD | BXE_LEVEL_EXTREME)
134 #define BXE_INSANE_RAMROD (BXE_CP_RAMROD | BXE_LEVEL_INSANE)
136 #define BXE_WARN_NVRAM (BXE_CP_NVRAM | BXE_LEVEL_WARN)
137 #define BXE_INFO_NVRAM (BXE_CP_NVRAM | BXE_LEVEL_INFO)
138 #define BXE_VERBOSE_NVRAM (BXE_CP_NVRAM | BXE_LEVEL_VERBOSE)
139 #define BXE_EXTREME_NVRAM (BXE_CP_NVRAM | BXE_LEVEL_EXTREME)
140 #define BXE_INSANE_NVRAM (BXE_CP_NVRAM | BXE_LEVEL_INSANE)
142 #define BXE_WARN_REGS (BXE_CP_REGS | BXE_LEVEL_WARN)
143 #define BXE_INFO_REGS (BXE_CP_REGS | BXE_LEVEL_INFO)
144 #define BXE_VERBOSE_REGS (BXE_CP_REGS | BXE_LEVEL_VERBOSE)
145 #define BXE_EXTREME_REGS (BXE_CP_REGS | BXE_LEVEL_EXTREME)
146 #define BXE_INSANE_REGS (BXE_CP_REGS | BXE_LEVEL_INSANE)
148 #define BXE_WARN_TPA (BXE_CP_TPA | BXE_LEVEL_WARN)
149 #define BXE_INFO_TPA (BXE_CP_TPA | BXE_LEVEL_INFO)
150 #define BXE_VERBOSE_TPA (BXE_CP_TPA | BXE_LEVEL_VERBOSE)
151 #define BXE_EXTREME_TPA (BXE_CP_TPA | BXE_LEVEL_EXTREME)
152 #define BXE_INSANE_TPA (BXE_CP_TPA | BXE_LEVEL_INSANE)
154 #define BXE_FATAL (BXE_CP_ALL | BXE_LEVEL_FATAL)
155 #define BXE_WARN (BXE_CP_ALL | BXE_LEVEL_WARN)
156 #define BXE_INFO (BXE_CP_ALL | BXE_LEVEL_INFO)
157 #define BXE_VERBOSE (BXE_CP_ALL | BXE_LEVEL_VERBOSE)
158 #define BXE_EXTREME (BXE_CP_ALL | BXE_LEVEL_EXTREME)
159 #define BXE_INSANE (BXE_CP_ALL | BXE_LEVEL_INSANE)
161 #define BXE_CODE_PATH(cp) ((cp & BXE_CP_MASK) & bxe_debug)
162 #define BXE_MSG_LEVEL(lv) ((lv & BXE_LEVEL_MASK) <= (bxe_debug & BXE_LEVEL_MASK))
163 #define BXE_LOG_MSG(m) (BXE_CODE_PATH(m) && BXE_MSG_LEVEL(m))
168 /* Print a message based on the logging level and code path. */
169 #define DBPRINT(sc, level, format, args...) \
171 if (BXE_LOG_MSG(level)) { \
172 device_printf(sc->dev, format, ## args); \
176 /* Runs a particular command when debugging is enabled. */
177 #define DBRUN(args...) \
182 /* Runs a particular command based on the logging level. */
183 #define DBRUNLV(level, args...) \
184 if (BXE_MSG_LEVEL(level)) { \
188 /* Runs a particular command based on the code path. */
189 #define DBRUNCP(cp, args...) \
190 if (BXE_CODE_PATH(cp)) { \
194 /* Runs a particular command based on a condition. */
195 #define DBRUNIF(cond, args...) \
200 /* Runs a particular command based on the logging level and code path. */
201 #define DBRUNMSG(msg, args...) \
202 if (BXE_LOG_MSG(msg)) { \
206 /* Announces function entry. */
207 #define DBENTER(cond) \
208 DBPRINT(sc, (cond), "%s(enter:%d)\n", __FUNCTION__, curcpu)
210 /* Announces function exit. */
211 #define DBEXIT(cond) \
212 DBPRINT(sc, (cond), "%s(exit:%d)\n", __FUNCTION__, curcpu)
214 /* Needed for random() function which is only used in debugging. */
215 #include <sys/random.h>
217 /* Returns FALSE in "defects" per 2^31 - 1 calls, otherwise returns TRUE. */
218 #define DB_RANDOMFALSE(defects) (random() > defects)
219 #define DB_OR_RANDOMFALSE(defects) || (random() > defects)
220 #define DB_AND_RANDOMFALSE(defects) && (random() > defects)
222 /* Returns TRUE in "defects" per 2^31 - 1 calls, otherwise returns FALSE. */
223 #define DB_RANDOMTRUE(defects) (random() < defects)
224 #define DB_OR_RANDOMTRUE(defects) || (random() < defects)
225 #define DB_AND_RANDOMTRUE(defects) && (random() < defects)
234 #define DBRUNMSG(...)
236 #define DBENTER_UNLOCKED(...)
238 #define DBEXIT_UNLOCKED(...)
239 #define DB_RANDOMFALSE(...)
240 #define DB_OR_RANDOMFALSE(...)
241 #define DB_AND_RANDOMFALSE(...)
242 #define DB_RANDOMTRUE(...)
243 #define DB_OR_RANDOMTRUE(...)
244 #define DB_AND_RANDOMTRUE(...)
246 #endif /* BXE_DEBUG */
248 /* Generic bit decoding for printf("%b"). */
249 #define BXE_DWORD_PRINTFB \
284 /* Supported link settings bit decoding for printf("%b"). */
285 #define BXE_SUPPORTED_PRINTFB \
302 "\02110000BaseT-Full" \
303 "\0202500BaseX-Full" \
312 "\0071000BaseT-Full" \
313 "\0061000BaseT-Half" \
314 "\005100BaseTX-Full" \
315 "\004100BaseTX-Half" \
320 /* Transmit BD TCP flags bit decoding for printf("%b"). */
321 #define BXE_ETH_TX_PARSE_BD_TCP_FLAGS_PRINTFB \
332 /* Parsing BD global data bit decoding for printf("%b"). */
333 #define BXE_ETH_TX_PARSE_BD_GLOBAL_DATA_PRINTFB \
337 "\06PSEUDO_CS_WO_LEN" \
340 /* Transmit BD flags bit decoding for printf("%b"). */
341 #define BXE_ETH_TX_BD_FLAGS_PRINTFB \
352 /* Receive CQE error flags bit decoding for printf("%b"). */
353 #define BXE_ETH_FAST_PATH_RX_CQE_ERROR_FLAGS_PRINTFB \
361 "\02PHY_DECODE_ERR" \
364 #endif /* _BXE_DEBUG_H */