16875 ndpd/ipmgmtd addrconf race
[illumos-gate.git] / usr / src / uts / common / io / bnxe / bnxe_debug.c
blob1411045f2ccefa897d3c48a12e3964c08a3ed2d4
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
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.
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.
35 #include "bnxe.h"
37 #define BNXE_LOG_LEN 256
40 #ifdef DBG
42 void DbgMessageFunc(void * pDev,
43 int level,
44 char * pFmt,
45 ...)
47 um_device_t * pUM = (um_device_t *)pDev;
48 va_list argp;
49 int ce;
51 if ((pUM != NULL) &&
52 (((pUM->devParams.debug_level & level & CP_ALL) != (level & CP_ALL)) ||
53 ((pUM->devParams.debug_level & LV_MASK) < (level & LV_MASK))))
55 return;
58 ce = (((level & LV_VERBOSE) == LV_VERBOSE) ? CE_NOTE :
59 ((level & LV_INFORM) == LV_INFORM) ? CE_NOTE :
60 ((level & LV_WARN) == LV_WARN) ? CE_WARN :
61 CE_PANIC);
63 va_start(argp, pFmt);
64 vcmn_err(ce, pFmt, argp);
65 va_end(argp);
68 #endif /* DBG */
71 void elink_cb_dbg(struct elink_dev * bp, char * fmt)
73 um_device_t * pUM = (um_device_t *)bp;
74 char buf[BNXE_LOG_LEN];
76 #ifdef DBG
77 if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
79 return;
82 snprintf(buf, sizeof(buf), fmt);
83 cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
84 #endif
88 void elink_cb_dbg1(struct elink_dev * bp, char * fmt, u32 arg1)
90 um_device_t * pUM = (um_device_t *)bp;
91 char buf[BNXE_LOG_LEN];
93 #ifdef DBG
94 if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
96 return;
99 snprintf(buf, sizeof(buf), fmt, arg1);
100 cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
101 #endif
105 void elink_cb_dbg2(struct elink_dev * bp, char * fmt, u32 arg1, u32 arg2)
107 um_device_t * pUM = (um_device_t *)bp;
108 char buf[BNXE_LOG_LEN];
110 #ifdef DBG
111 if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
113 return;
116 snprintf(buf, sizeof(buf), fmt, arg1, arg2);
117 cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
118 #endif
122 void elink_cb_dbg3(struct elink_dev * bp, char * fmt, u32 arg1, u32 arg2, u32 arg3)
124 um_device_t * pUM = (um_device_t *)bp;
125 char buf[BNXE_LOG_LEN];
127 #ifdef DBG
128 if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
130 return;
133 snprintf(buf, sizeof(buf), fmt, arg1, arg2, arg3);
134 cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
135 #endif
139 void BnxeLogInfo(void * pDev,
140 char * pFmt,
141 ...)
143 um_device_t * pUM = (um_device_t *)pDev;
144 char buf[BNXE_LOG_LEN];
145 va_list argp;
148 * Info message are logged to syslog only if logEnable is
149 * turned on. They are never logged to the console. If
150 * pUM is NULL then the log is allowed through as if logEnable
151 * was turned on.
154 if (pUM && !pUM->devParams.logEnable)
156 return;
158 /* if !pUM then let the log through */
160 va_start(argp, pFmt);
161 vsnprintf(buf, sizeof(buf), pFmt, argp);
162 va_end(argp);
164 cmn_err(CE_NOTE, "!%s: %s", BnxeDevName(pUM), buf);
168 void BnxeLogWarn(void * pDev,
169 char * pFmt,
170 ...)
172 um_device_t * pUM = (um_device_t *)pDev;
173 char buf[BNXE_LOG_LEN];
174 va_list argp;
177 * Warning message are always logged to syslog. They are
178 * never logged to the console.
181 va_start(argp, pFmt);
182 vsnprintf(buf, sizeof(buf), pFmt, argp);
183 va_end(argp);
185 cmn_err(CE_WARN, "!%s: %s", BnxeDevName(pUM), buf);
189 #ifdef DBG
191 void BnxeLogDbg(void * pDev,
192 char * pFmt,
193 ...)
195 um_device_t * pUM = (um_device_t *)pDev;
196 char buf[BNXE_LOG_LEN];
197 va_list argp;
200 * Debug message are always logged to syslog. They are
201 * never logged to the console. Debug messages are only
202 * available when the DEBUG compile time flag is turned on.
205 va_start(argp, pFmt);
206 vsnprintf(buf, sizeof(buf), pFmt, argp);
207 va_end(argp);
209 cmn_err(CE_WARN, "!%s: %s", BnxeDevName(pUM), buf);
212 #endif /* DBG */
215 void BnxeDumpMem(um_device_t * pUM,
216 char * pTag,
217 u8_t * pMem,
218 u32_t len)
220 char buf[256];
221 char c[32];
222 int xx;
224 mutex_enter(&bnxeLoaderMutex);
226 cmn_err(CE_WARN, "!%s ++++++++++++ %s", BnxeDevName(pUM), pTag);
227 strcpy(buf, "!** 000: ");
229 for (xx = 0; xx < len; xx++)
231 if ((xx != 0) && (xx % 16 == 0))
233 cmn_err(CE_WARN, buf);
234 strcpy(buf, "!** ");
235 snprintf(c, sizeof(c), "%03x", xx);
236 strcat(buf, c);
237 strcat(buf, ": ");
240 snprintf(c, sizeof(c), "%02x ", *pMem);
241 strcat(buf, c);
243 pMem++;
246 cmn_err(CE_WARN, buf);
247 cmn_err(CE_WARN, "!%s ------------ %s", BnxeDevName(pUM), pTag);
249 mutex_exit(&bnxeLoaderMutex);
253 void BnxeDumpPkt(um_device_t * pUM,
254 char * pTag,
255 mblk_t * pMblk,
256 boolean_t contents)
258 char buf[256];
259 char c[32];
260 u8_t * pMem;
261 int i, xx = 0;
263 mutex_enter(&bnxeLoaderMutex);
265 cmn_err(CE_WARN, "!%s ++++++++++++ %s", BnxeDevName(pUM), pTag);
267 while (pMblk)
269 pMem = pMblk->b_rptr;
270 strcpy(buf, "!** > ");
271 snprintf(c, sizeof(c), "%03x", xx);
272 strcat(buf, c);
273 strcat(buf, ": ");
275 if (contents)
277 for (i = 0; i < MBLKL(pMblk); i++)
279 if ((xx != 0) && (xx % 16 == 0))
281 cmn_err(CE_WARN, buf);
282 strcpy(buf, "!** ");
283 snprintf(c, sizeof(c), "%03x", xx);
284 strcat(buf, c);
285 strcat(buf, ": ");
288 snprintf(c, sizeof(c), "%02x ", *pMem);
289 strcat(buf, c);
291 pMem++;
292 xx++;
295 else
297 snprintf(c, sizeof(c), "%d", (int)MBLKL(pMblk));
298 strcat(buf, c);
299 xx += MBLKL(pMblk);
302 cmn_err(CE_WARN, buf);
303 pMblk = pMblk->b_cont;
306 cmn_err(CE_WARN, "!%s ------------ %s", BnxeDevName(pUM), pTag);
308 mutex_exit(&bnxeLoaderMutex);