xref: /titanic_50/usr/src/uts/common/io/bnxe/bnxe_debug.c (revision d14abf155341d55053c76eeec58b787a456b753b)
1*d14abf15SRobert Mustacchi /*
2*d14abf15SRobert Mustacchi  * CDDL HEADER START
3*d14abf15SRobert Mustacchi  *
4*d14abf15SRobert Mustacchi  * The contents of this file are subject to the terms of the
5*d14abf15SRobert Mustacchi  * Common Development and Distribution License (the "License").
6*d14abf15SRobert Mustacchi  * You may not use this file except in compliance with the License.
7*d14abf15SRobert Mustacchi  *
8*d14abf15SRobert Mustacchi  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*d14abf15SRobert Mustacchi  * or http://www.opensolaris.org/os/licensing.
10*d14abf15SRobert Mustacchi  * See the License for the specific language governing permissions
11*d14abf15SRobert Mustacchi  * and limitations under the License.
12*d14abf15SRobert Mustacchi  *
13*d14abf15SRobert Mustacchi  * When distributing Covered Code, include this CDDL HEADER in each
14*d14abf15SRobert Mustacchi  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*d14abf15SRobert Mustacchi  * If applicable, add the following below this CDDL HEADER, with the
16*d14abf15SRobert Mustacchi  * fields enclosed by brackets "[]" replaced with your own identifying
17*d14abf15SRobert Mustacchi  * information: Portions Copyright [yyyy] [name of copyright owner]
18*d14abf15SRobert Mustacchi  *
19*d14abf15SRobert Mustacchi  * CDDL HEADER END
20*d14abf15SRobert Mustacchi  */
21*d14abf15SRobert Mustacchi 
22*d14abf15SRobert Mustacchi /*
23*d14abf15SRobert Mustacchi  * Copyright 2014 QLogic Corporation
24*d14abf15SRobert Mustacchi  * The contents of this file are subject to the terms of the
25*d14abf15SRobert Mustacchi  * QLogic End User License (the "License").
26*d14abf15SRobert Mustacchi  * You may not use this file except in compliance with the License.
27*d14abf15SRobert Mustacchi  *
28*d14abf15SRobert Mustacchi  * You can obtain a copy of the License at
29*d14abf15SRobert Mustacchi  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
30*d14abf15SRobert Mustacchi  * QLogic_End_User_Software_License.txt
31*d14abf15SRobert Mustacchi  * See the License for the specific language governing permissions
32*d14abf15SRobert Mustacchi  * and limitations under the License.
33*d14abf15SRobert Mustacchi  */
34*d14abf15SRobert Mustacchi 
35*d14abf15SRobert Mustacchi #include "bnxe.h"
36*d14abf15SRobert Mustacchi 
37*d14abf15SRobert Mustacchi #define BNXE_LOG_LEN 256
38*d14abf15SRobert Mustacchi 
39*d14abf15SRobert Mustacchi 
40*d14abf15SRobert Mustacchi #ifdef DBG
41*d14abf15SRobert Mustacchi 
DbgMessageFunc(void * pDev,int level,char * pFmt,...)42*d14abf15SRobert Mustacchi void DbgMessageFunc(void * pDev,
43*d14abf15SRobert Mustacchi                     int    level,
44*d14abf15SRobert Mustacchi                     char * pFmt,
45*d14abf15SRobert Mustacchi                     ...)
46*d14abf15SRobert Mustacchi {
47*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)pDev;
48*d14abf15SRobert Mustacchi     va_list argp;
49*d14abf15SRobert Mustacchi     int ce;
50*d14abf15SRobert Mustacchi 
51*d14abf15SRobert Mustacchi     if ((pUM != NULL) &&
52*d14abf15SRobert Mustacchi         (((pUM->devParams.debug_level & level & CP_ALL) != (level & CP_ALL)) ||
53*d14abf15SRobert Mustacchi          ((pUM->devParams.debug_level & LV_MASK) < (level & LV_MASK))))
54*d14abf15SRobert Mustacchi     {
55*d14abf15SRobert Mustacchi         return;
56*d14abf15SRobert Mustacchi     }
57*d14abf15SRobert Mustacchi 
58*d14abf15SRobert Mustacchi     ce = (((level & LV_VERBOSE) == LV_VERBOSE) ? CE_NOTE :
59*d14abf15SRobert Mustacchi           ((level & LV_INFORM) == LV_INFORM)   ? CE_NOTE :
60*d14abf15SRobert Mustacchi           ((level & LV_WARN) == LV_WARN)       ? CE_WARN :
61*d14abf15SRobert Mustacchi                                                  CE_PANIC);
62*d14abf15SRobert Mustacchi 
63*d14abf15SRobert Mustacchi     va_start(argp, pFmt);
64*d14abf15SRobert Mustacchi     vcmn_err(ce, pFmt, argp);
65*d14abf15SRobert Mustacchi     va_end(argp);
66*d14abf15SRobert Mustacchi }
67*d14abf15SRobert Mustacchi 
68*d14abf15SRobert Mustacchi #endif /* DBG */
69*d14abf15SRobert Mustacchi 
70*d14abf15SRobert Mustacchi 
elink_cb_dbg(struct elink_dev * bp,char * fmt)71*d14abf15SRobert Mustacchi void elink_cb_dbg(struct elink_dev * bp, char * fmt)
72*d14abf15SRobert Mustacchi {
73*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)bp;
74*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
75*d14abf15SRobert Mustacchi 
76*d14abf15SRobert Mustacchi #ifdef DBG
77*d14abf15SRobert Mustacchi     if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
78*d14abf15SRobert Mustacchi     {
79*d14abf15SRobert Mustacchi         return;
80*d14abf15SRobert Mustacchi     }
81*d14abf15SRobert Mustacchi 
82*d14abf15SRobert Mustacchi     snprintf(buf, sizeof(buf), fmt);
83*d14abf15SRobert Mustacchi     cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
84*d14abf15SRobert Mustacchi #endif
85*d14abf15SRobert Mustacchi }
86*d14abf15SRobert Mustacchi 
87*d14abf15SRobert Mustacchi 
elink_cb_dbg1(struct elink_dev * bp,char * fmt,u32 arg1)88*d14abf15SRobert Mustacchi void elink_cb_dbg1(struct elink_dev * bp, char * fmt, u32 arg1)
89*d14abf15SRobert Mustacchi {
90*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)bp;
91*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
92*d14abf15SRobert Mustacchi 
93*d14abf15SRobert Mustacchi #ifdef DBG
94*d14abf15SRobert Mustacchi     if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
95*d14abf15SRobert Mustacchi     {
96*d14abf15SRobert Mustacchi         return;
97*d14abf15SRobert Mustacchi     }
98*d14abf15SRobert Mustacchi 
99*d14abf15SRobert Mustacchi     snprintf(buf, sizeof(buf), fmt, arg1);
100*d14abf15SRobert Mustacchi     cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
101*d14abf15SRobert Mustacchi #endif
102*d14abf15SRobert Mustacchi }
103*d14abf15SRobert Mustacchi 
104*d14abf15SRobert Mustacchi 
elink_cb_dbg2(struct elink_dev * bp,char * fmt,u32 arg1,u32 arg2)105*d14abf15SRobert Mustacchi void elink_cb_dbg2(struct elink_dev * bp, char * fmt, u32 arg1, u32 arg2)
106*d14abf15SRobert Mustacchi {
107*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)bp;
108*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
109*d14abf15SRobert Mustacchi 
110*d14abf15SRobert Mustacchi #ifdef DBG
111*d14abf15SRobert Mustacchi     if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
112*d14abf15SRobert Mustacchi     {
113*d14abf15SRobert Mustacchi         return;
114*d14abf15SRobert Mustacchi     }
115*d14abf15SRobert Mustacchi 
116*d14abf15SRobert Mustacchi     snprintf(buf, sizeof(buf), fmt, arg1, arg2);
117*d14abf15SRobert Mustacchi     cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
118*d14abf15SRobert Mustacchi #endif
119*d14abf15SRobert Mustacchi }
120*d14abf15SRobert Mustacchi 
121*d14abf15SRobert Mustacchi 
elink_cb_dbg3(struct elink_dev * bp,char * fmt,u32 arg1,u32 arg2,u32 arg3)122*d14abf15SRobert Mustacchi void elink_cb_dbg3(struct elink_dev * bp, char * fmt, u32 arg1, u32 arg2, u32 arg3)
123*d14abf15SRobert Mustacchi {
124*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)bp;
125*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
126*d14abf15SRobert Mustacchi 
127*d14abf15SRobert Mustacchi #ifdef DBG
128*d14abf15SRobert Mustacchi     if ((pUM->devParams.debug_level & LV_MASK) < LV_WARN)
129*d14abf15SRobert Mustacchi     {
130*d14abf15SRobert Mustacchi         return;
131*d14abf15SRobert Mustacchi     }
132*d14abf15SRobert Mustacchi 
133*d14abf15SRobert Mustacchi     snprintf(buf, sizeof(buf), fmt, arg1, arg2, arg3);
134*d14abf15SRobert Mustacchi     cmn_err(CE_NOTE, "!%s: ELINK %s", BnxeDevName(pUM), buf);
135*d14abf15SRobert Mustacchi #endif
136*d14abf15SRobert Mustacchi }
137*d14abf15SRobert Mustacchi 
138*d14abf15SRobert Mustacchi 
BnxeLogInfo(void * pDev,char * pFmt,...)139*d14abf15SRobert Mustacchi void BnxeLogInfo(void * pDev,
140*d14abf15SRobert Mustacchi                  char * pFmt,
141*d14abf15SRobert Mustacchi                  ...)
142*d14abf15SRobert Mustacchi {
143*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)pDev;
144*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
145*d14abf15SRobert Mustacchi     va_list argp;
146*d14abf15SRobert Mustacchi 
147*d14abf15SRobert Mustacchi     /*
148*d14abf15SRobert Mustacchi      * Info message are logged to syslog only if logEnable is
149*d14abf15SRobert Mustacchi      * turned on.  They are never logged to the console.  If
150*d14abf15SRobert Mustacchi      * pUM is NULL then the log is allowed through as if logEnable
151*d14abf15SRobert Mustacchi      * was turned on.
152*d14abf15SRobert Mustacchi      */
153*d14abf15SRobert Mustacchi 
154*d14abf15SRobert Mustacchi     if (pUM && !pUM->devParams.logEnable)
155*d14abf15SRobert Mustacchi     {
156*d14abf15SRobert Mustacchi         return;
157*d14abf15SRobert Mustacchi     }
158*d14abf15SRobert Mustacchi     /* if !pUM then let the log through */
159*d14abf15SRobert Mustacchi 
160*d14abf15SRobert Mustacchi     va_start(argp, pFmt);
161*d14abf15SRobert Mustacchi     vsnprintf(buf, sizeof(buf), pFmt, argp);
162*d14abf15SRobert Mustacchi     va_end(argp);
163*d14abf15SRobert Mustacchi 
164*d14abf15SRobert Mustacchi     cmn_err(CE_NOTE, "!%s: %s", BnxeDevName(pUM), buf);
165*d14abf15SRobert Mustacchi }
166*d14abf15SRobert Mustacchi 
167*d14abf15SRobert Mustacchi 
BnxeLogWarn(void * pDev,char * pFmt,...)168*d14abf15SRobert Mustacchi void BnxeLogWarn(void * pDev,
169*d14abf15SRobert Mustacchi                  char * pFmt,
170*d14abf15SRobert Mustacchi                  ...)
171*d14abf15SRobert Mustacchi {
172*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)pDev;
173*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
174*d14abf15SRobert Mustacchi     va_list argp;
175*d14abf15SRobert Mustacchi 
176*d14abf15SRobert Mustacchi     /*
177*d14abf15SRobert Mustacchi      * Warning message are always logged to syslog.  They are
178*d14abf15SRobert Mustacchi      * never logged to the console.
179*d14abf15SRobert Mustacchi      */
180*d14abf15SRobert Mustacchi 
181*d14abf15SRobert Mustacchi     va_start(argp, pFmt);
182*d14abf15SRobert Mustacchi     vsnprintf(buf, sizeof(buf), pFmt, argp);
183*d14abf15SRobert Mustacchi     va_end(argp);
184*d14abf15SRobert Mustacchi 
185*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, "!%s: %s", BnxeDevName(pUM), buf);
186*d14abf15SRobert Mustacchi }
187*d14abf15SRobert Mustacchi 
188*d14abf15SRobert Mustacchi 
189*d14abf15SRobert Mustacchi #ifdef DBG
190*d14abf15SRobert Mustacchi 
BnxeLogDbg(void * pDev,char * pFmt,...)191*d14abf15SRobert Mustacchi void BnxeLogDbg(void * pDev,
192*d14abf15SRobert Mustacchi                 char * pFmt,
193*d14abf15SRobert Mustacchi                 ...)
194*d14abf15SRobert Mustacchi {
195*d14abf15SRobert Mustacchi     um_device_t * pUM = (um_device_t *)pDev;
196*d14abf15SRobert Mustacchi     char buf[BNXE_LOG_LEN];
197*d14abf15SRobert Mustacchi     va_list argp;
198*d14abf15SRobert Mustacchi 
199*d14abf15SRobert Mustacchi     /*
200*d14abf15SRobert Mustacchi      * Debug message are always logged to syslog.  They are
201*d14abf15SRobert Mustacchi      * never logged to the console.  Debug messages are only
202*d14abf15SRobert Mustacchi      * available when the DEBUG compile time flag is turned on.
203*d14abf15SRobert Mustacchi      */
204*d14abf15SRobert Mustacchi 
205*d14abf15SRobert Mustacchi     va_start(argp, pFmt);
206*d14abf15SRobert Mustacchi     vsnprintf(buf, sizeof(buf), pFmt, argp);
207*d14abf15SRobert Mustacchi     va_end(argp);
208*d14abf15SRobert Mustacchi 
209*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, "!%s: %s", BnxeDevName(pUM), buf);
210*d14abf15SRobert Mustacchi }
211*d14abf15SRobert Mustacchi 
212*d14abf15SRobert Mustacchi #endif /* DBG */
213*d14abf15SRobert Mustacchi 
214*d14abf15SRobert Mustacchi 
BnxeDumpMem(um_device_t * pUM,char * pTag,u8_t * pMem,u32_t len)215*d14abf15SRobert Mustacchi void BnxeDumpMem(um_device_t * pUM,
216*d14abf15SRobert Mustacchi                  char *        pTag,
217*d14abf15SRobert Mustacchi                  u8_t *        pMem,
218*d14abf15SRobert Mustacchi                  u32_t         len)
219*d14abf15SRobert Mustacchi {
220*d14abf15SRobert Mustacchi     char buf[256];
221*d14abf15SRobert Mustacchi     char c[32];
222*d14abf15SRobert Mustacchi     int  xx;
223*d14abf15SRobert Mustacchi 
224*d14abf15SRobert Mustacchi     mutex_enter(&bnxeLoaderMutex);
225*d14abf15SRobert Mustacchi 
226*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, "!%s ++++++++++++ %s", BnxeDevName(pUM), pTag);
227*d14abf15SRobert Mustacchi     strcpy(buf, "!** 000: ");
228*d14abf15SRobert Mustacchi 
229*d14abf15SRobert Mustacchi     for (xx = 0; xx < len; xx++)
230*d14abf15SRobert Mustacchi     {
231*d14abf15SRobert Mustacchi         if ((xx != 0) && (xx % 16 == 0))
232*d14abf15SRobert Mustacchi         {
233*d14abf15SRobert Mustacchi             cmn_err(CE_WARN, buf);
234*d14abf15SRobert Mustacchi             strcpy(buf, "!** ");
235*d14abf15SRobert Mustacchi             snprintf(c, sizeof(c), "%03x", xx);
236*d14abf15SRobert Mustacchi             strcat(buf, c);
237*d14abf15SRobert Mustacchi             strcat(buf, ": ");
238*d14abf15SRobert Mustacchi         }
239*d14abf15SRobert Mustacchi 
240*d14abf15SRobert Mustacchi         snprintf(c, sizeof(c), "%02x ", *pMem);
241*d14abf15SRobert Mustacchi         strcat(buf, c);
242*d14abf15SRobert Mustacchi 
243*d14abf15SRobert Mustacchi         pMem++;
244*d14abf15SRobert Mustacchi     }
245*d14abf15SRobert Mustacchi 
246*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, buf);
247*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, "!%s ------------ %s", BnxeDevName(pUM), pTag);
248*d14abf15SRobert Mustacchi 
249*d14abf15SRobert Mustacchi     mutex_exit(&bnxeLoaderMutex);
250*d14abf15SRobert Mustacchi }
251*d14abf15SRobert Mustacchi 
252*d14abf15SRobert Mustacchi 
BnxeDumpPkt(um_device_t * pUM,char * pTag,mblk_t * pMblk,boolean_t contents)253*d14abf15SRobert Mustacchi void BnxeDumpPkt(um_device_t * pUM,
254*d14abf15SRobert Mustacchi                  char *        pTag,
255*d14abf15SRobert Mustacchi                  mblk_t *      pMblk,
256*d14abf15SRobert Mustacchi                  boolean_t     contents)
257*d14abf15SRobert Mustacchi {
258*d14abf15SRobert Mustacchi     char buf[256];
259*d14abf15SRobert Mustacchi     char c[32];
260*d14abf15SRobert Mustacchi     u8_t * pMem;
261*d14abf15SRobert Mustacchi     int  i, xx = 0;
262*d14abf15SRobert Mustacchi 
263*d14abf15SRobert Mustacchi     mutex_enter(&bnxeLoaderMutex);
264*d14abf15SRobert Mustacchi 
265*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, "!%s ++++++++++++ %s", BnxeDevName(pUM), pTag);
266*d14abf15SRobert Mustacchi 
267*d14abf15SRobert Mustacchi     while (pMblk)
268*d14abf15SRobert Mustacchi     {
269*d14abf15SRobert Mustacchi         pMem = pMblk->b_rptr;
270*d14abf15SRobert Mustacchi         strcpy(buf, "!** > ");
271*d14abf15SRobert Mustacchi         snprintf(c, sizeof(c), "%03x", xx);
272*d14abf15SRobert Mustacchi         strcat(buf, c);
273*d14abf15SRobert Mustacchi         strcat(buf, ": ");
274*d14abf15SRobert Mustacchi 
275*d14abf15SRobert Mustacchi         if (contents)
276*d14abf15SRobert Mustacchi         {
277*d14abf15SRobert Mustacchi             for (i = 0; i < MBLKL(pMblk); i++)
278*d14abf15SRobert Mustacchi             {
279*d14abf15SRobert Mustacchi                 if ((xx != 0) && (xx % 16 == 0))
280*d14abf15SRobert Mustacchi                 {
281*d14abf15SRobert Mustacchi                     cmn_err(CE_WARN, buf);
282*d14abf15SRobert Mustacchi                     strcpy(buf, "!**   ");
283*d14abf15SRobert Mustacchi                     snprintf(c, sizeof(c), "%03x", xx);
284*d14abf15SRobert Mustacchi                     strcat(buf, c);
285*d14abf15SRobert Mustacchi                     strcat(buf, ": ");
286*d14abf15SRobert Mustacchi                 }
287*d14abf15SRobert Mustacchi 
288*d14abf15SRobert Mustacchi                 snprintf(c, sizeof(c), "%02x ", *pMem);
289*d14abf15SRobert Mustacchi                 strcat(buf, c);
290*d14abf15SRobert Mustacchi 
291*d14abf15SRobert Mustacchi                 pMem++;
292*d14abf15SRobert Mustacchi                 xx++;
293*d14abf15SRobert Mustacchi             }
294*d14abf15SRobert Mustacchi         }
295*d14abf15SRobert Mustacchi         else
296*d14abf15SRobert Mustacchi         {
297*d14abf15SRobert Mustacchi             snprintf(c, sizeof(c), "%d", (int)MBLKL(pMblk));
298*d14abf15SRobert Mustacchi             strcat(buf, c);
299*d14abf15SRobert Mustacchi             xx += MBLKL(pMblk);
300*d14abf15SRobert Mustacchi         }
301*d14abf15SRobert Mustacchi 
302*d14abf15SRobert Mustacchi         cmn_err(CE_WARN, buf);
303*d14abf15SRobert Mustacchi         pMblk = pMblk->b_cont;
304*d14abf15SRobert Mustacchi     }
305*d14abf15SRobert Mustacchi 
306*d14abf15SRobert Mustacchi     cmn_err(CE_WARN, "!%s ------------ %s", BnxeDevName(pUM), pTag);
307*d14abf15SRobert Mustacchi 
308*d14abf15SRobert Mustacchi     mutex_exit(&bnxeLoaderMutex);
309*d14abf15SRobert Mustacchi }
310