19da57d7bSbt /*
29da57d7bSbt  * CDDL HEADER START
39da57d7bSbt  *
419843f01SPaul Guo  * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
59da57d7bSbt  * The contents of this file are subject to the terms of the
69da57d7bSbt  * Common Development and Distribution License (the "License").
79da57d7bSbt  * You may not use this file except in compliance with the License.
89da57d7bSbt  *
99da57d7bSbt  * You can obtain a copy of the license at:
109da57d7bSbt  *      http://www.opensolaris.org/os/licensing.
119da57d7bSbt  * See the License for the specific language governing permissions
129da57d7bSbt  * and limitations under the License.
139da57d7bSbt  *
149da57d7bSbt  * When using or redistributing this file, you may do so under the
159da57d7bSbt  * License only. No other modification of this header is permitted.
169da57d7bSbt  *
179da57d7bSbt  * If applicable, add the following below this CDDL HEADER, with the
189da57d7bSbt  * fields enclosed by brackets "[]" replaced with your own identifying
199da57d7bSbt  * information: Portions Copyright [yyyy] [name of copyright owner]
209da57d7bSbt  *
219da57d7bSbt  * CDDL HEADER END
229da57d7bSbt  */
239da57d7bSbt 
249da57d7bSbt /*
2519843f01SPaul Guo  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2673cd555cSBin Tu - Sun Microsystems - Beijing China  * Use is subject to license terms.
279da57d7bSbt  */
289da57d7bSbt 
29*dc0cb1cdSDale Ghent /*
30*dc0cb1cdSDale Ghent  * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
31*dc0cb1cdSDale Ghent  */
32*dc0cb1cdSDale Ghent 
339da57d7bSbt #ifndef	_IXGBE_DEBUG_H
349da57d7bSbt #define	_IXGBE_DEBUG_H
359da57d7bSbt 
369da57d7bSbt #ifdef __cplusplus
379da57d7bSbt extern "C" {
389da57d7bSbt #endif
399da57d7bSbt 
409da57d7bSbt 
419da57d7bSbt #ifdef DEBUG
429da57d7bSbt #define	IXGBE_DEBUG
439da57d7bSbt #endif
449da57d7bSbt 
459da57d7bSbt #ifdef IXGBE_DEBUG
469da57d7bSbt 
479da57d7bSbt #define	IXGBE_DEBUGLOG_0(adapter, fmt)	\
489da57d7bSbt 	ixgbe_log((adapter), (fmt))
499da57d7bSbt #define	IXGBE_DEBUGLOG_1(adapter, fmt, d1)	\
509da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1))
519da57d7bSbt #define	IXGBE_DEBUGLOG_2(adapter, fmt, d1, d2)	\
529da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1), (d2))
539da57d7bSbt #define	IXGBE_DEBUGLOG_3(adapter, fmt, d1, d2, d3)	\
549da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1), (d2), (d3))
559da57d7bSbt #define	IXGBE_DEBUGLOG_6(adapter, fmt, d1, d2, d3, d4, d5, d6)	\
569da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1), (d2), (d3), (d4), (d5), (d6))
579da57d7bSbt 
589da57d7bSbt #define	IXGBE_DEBUG_STAT_COND(val, cond)	if (cond) (val)++;
599da57d7bSbt #define	IXGBE_DEBUG_STAT(val)		(val)++;
609da57d7bSbt 
619da57d7bSbt #else
629da57d7bSbt 
639da57d7bSbt #define	IXGBE_DEBUGLOG_0(adapter, fmt)
649da57d7bSbt #define	IXGBE_DEBUGLOG_1(adapter, fmt, d1)
659da57d7bSbt #define	IXGBE_DEBUGLOG_2(adapter, fmt, d1, d2)
669da57d7bSbt #define	IXGBE_DEBUGLOG_3(adapter, fmt, d1, d2, d3)
679da57d7bSbt #define	IXGBE_DEBUGLOG_6(adapter, fmt, d1, d2, d3, d4, d5, d6)
689da57d7bSbt 
699da57d7bSbt #define	IXGBE_DEBUG_STAT_COND(val, cond)
709da57d7bSbt #define	IXGBE_DEBUG_STAT(val)
719da57d7bSbt 
729da57d7bSbt #endif	/* IXGBE_DEBUG */
739da57d7bSbt 
749da57d7bSbt #ifdef IXGBE_DEBUG
759da57d7bSbt void ixgbe_pci_dump(void *);
769da57d7bSbt void ixgbe_dump_interrupt(void *, char *);
779da57d7bSbt void ixgbe_dump_addr(void *, char *, const uint8_t *);
789da57d7bSbt 
7973cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT(S)	\
8073cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_0(NULL, S)
8173cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT1(S, A)	\
8273cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_1(NULL, S, A)
8373cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT2(S, A, B)	\
8473cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_2(NULL, S, A, B)
8573cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT3(S, A, B, C)	\
8673cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_3(NULL, S, A, B, C)
8773cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT6(S, A, B, C, D, E, F)	\
8873cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_6(NULL, S, A, B, C, D, E, F)
8973cd555cSBin Tu - Sun Microsystems - Beijing China 
90*dc0cb1cdSDale Ghent #define	IXGBE_ERROR_INVALID_STATE	"INVALID STATE"
91*dc0cb1cdSDale Ghent #define	IXGBE_ERROR_POLLING		"POLLING ERROR"
92*dc0cb1cdSDale Ghent #define	IXGBE_ERROR_CAUTION		"CAUTION"
93*dc0cb1cdSDale Ghent #define	IXGBE_ERROR_SOFTWARE		"SOFTWARE ERROR"
94*dc0cb1cdSDale Ghent #define	IXGBE_ERROR_ARGUMENT		"BAD ARGUMENT"
95*dc0cb1cdSDale Ghent #define	IXGBE_ERROR_UNSUPPORTED		"UNSUPPORTED"
96*dc0cb1cdSDale Ghent 
97*dc0cb1cdSDale Ghent #define	ERROR_REPORT1(S, A)		DEBUGOUT(S ":" A)
98*dc0cb1cdSDale Ghent #define	ERROR_REPORT2(S, A, B)		DEBUGOUT1(S ":" A, B)
99*dc0cb1cdSDale Ghent #define	ERROR_REPORT3(S, A, B, C)	DEBUGOUT2(S ":" A, B, C)
10073cd555cSBin Tu - Sun Microsystems - Beijing China 
10173cd555cSBin Tu - Sun Microsystems - Beijing China #else
10273cd555cSBin Tu - Sun Microsystems - Beijing China 
10373cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT(S)
10473cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT1(S, A)
10573cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT2(S, A, B)
10673cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT3(S, A, B, C)
10773cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT6(S, A, B, C, D, E, F)
10873cd555cSBin Tu - Sun Microsystems - Beijing China 
109*dc0cb1cdSDale Ghent #define	ERROR_REPORT1(S, A)
110*dc0cb1cdSDale Ghent #define	ERROR_REPORT2(S, A, B)
111*dc0cb1cdSDale Ghent #define	ERROR_REPORT3(S, A, B, C)
11273cd555cSBin Tu - Sun Microsystems - Beijing China 
11373cd555cSBin Tu - Sun Microsystems - Beijing China #endif	/* IXGBE_DEBUG */
11473cd555cSBin Tu - Sun Microsystems - Beijing China 
115*dc0cb1cdSDale Ghent /*
116*dc0cb1cdSDale Ghent  * DEBUGFUNC() is used to print the function call information, however since
117*dc0cb1cdSDale Ghent  * DTrace in illumos can be used to trace function calls, this function is
118*dc0cb1cdSDale Ghent  * not useful in illumos, and DEBUGFUNC() can spam a large number of
119*dc0cb1cdSDale Ghent  * function call system logs (see CR6918426). We sould eliminate
120*dc0cb1cdSDale Ghent  * DEBUGFUNC(), but since DEBUGFUNC() is used by the shared code
121*dc0cb1cdSDale Ghent  * (maintained by Intel) which is used and shared by ixgbe drivers in
122*dc0cb1cdSDale Ghent  * different OSes, we can not remove it, so in illumos just simply define
123*dc0cb1cdSDale Ghent  * it as blank.
124*dc0cb1cdSDale Ghent  */
125*dc0cb1cdSDale Ghent #define	DEBUGFUNC(F)
126*dc0cb1cdSDale Ghent 
127*dc0cb1cdSDale Ghent #define	IXGBE_STAT(val)		(val)++;
128*dc0cb1cdSDale Ghent 
1299da57d7bSbt extern void ixgbe_log(void *, const char *, ...);
1309da57d7bSbt 
1319da57d7bSbt #ifdef __cplusplus
1329da57d7bSbt }
1339da57d7bSbt #endif
1349da57d7bSbt 
1359da57d7bSbt #endif	/* _IXGBE_DEBUG_H */
136