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 
29dc0cb1cdSDale Ghent /*
30dc0cb1cdSDale Ghent  * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
31*63efadf0SRyan Zezeski  * Copyright 2017 Joyent, Inc.
32dc0cb1cdSDale Ghent  */
33dc0cb1cdSDale Ghent 
349da57d7bSbt #ifndef	_IXGBE_DEBUG_H
359da57d7bSbt #define	_IXGBE_DEBUG_H
369da57d7bSbt 
379da57d7bSbt #ifdef __cplusplus
389da57d7bSbt extern "C" {
399da57d7bSbt #endif
409da57d7bSbt 
419da57d7bSbt 
429da57d7bSbt #ifdef DEBUG
439da57d7bSbt #define	IXGBE_DEBUG
449da57d7bSbt #endif
459da57d7bSbt 
469da57d7bSbt #ifdef IXGBE_DEBUG
479da57d7bSbt 
489da57d7bSbt #define	IXGBE_DEBUGLOG_0(adapter, fmt)	\
499da57d7bSbt 	ixgbe_log((adapter), (fmt))
509da57d7bSbt #define	IXGBE_DEBUGLOG_1(adapter, fmt, d1)	\
519da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1))
529da57d7bSbt #define	IXGBE_DEBUGLOG_2(adapter, fmt, d1, d2)	\
539da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1), (d2))
549da57d7bSbt #define	IXGBE_DEBUGLOG_3(adapter, fmt, d1, d2, d3)	\
559da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1), (d2), (d3))
569da57d7bSbt #define	IXGBE_DEBUGLOG_6(adapter, fmt, d1, d2, d3, d4, d5, d6)	\
579da57d7bSbt 	ixgbe_log((adapter), (fmt), (d1), (d2), (d3), (d4), (d5), (d6))
589da57d7bSbt 
599da57d7bSbt #else
609da57d7bSbt 
619da57d7bSbt #define	IXGBE_DEBUGLOG_0(adapter, fmt)
629da57d7bSbt #define	IXGBE_DEBUGLOG_1(adapter, fmt, d1)
639da57d7bSbt #define	IXGBE_DEBUGLOG_2(adapter, fmt, d1, d2)
649da57d7bSbt #define	IXGBE_DEBUGLOG_3(adapter, fmt, d1, d2, d3)
659da57d7bSbt #define	IXGBE_DEBUGLOG_6(adapter, fmt, d1, d2, d3, d4, d5, d6)
669da57d7bSbt 
679da57d7bSbt #endif	/* IXGBE_DEBUG */
689da57d7bSbt 
699da57d7bSbt #ifdef IXGBE_DEBUG
709da57d7bSbt void ixgbe_pci_dump(void *);
719da57d7bSbt void ixgbe_dump_interrupt(void *, char *);
729da57d7bSbt void ixgbe_dump_addr(void *, char *, const uint8_t *);
739da57d7bSbt 
7473cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT(S)	\
7573cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_0(NULL, S)
7673cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT1(S, A)	\
7773cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_1(NULL, S, A)
7873cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT2(S, A, B)	\
7973cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_2(NULL, S, A, B)
8073cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT3(S, A, B, C)	\
8173cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_3(NULL, S, A, B, C)
8273cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT6(S, A, B, C, D, E, F)	\
8373cd555cSBin Tu - Sun Microsystems - Beijing China 	IXGBE_DEBUGLOG_6(NULL, S, A, B, C, D, E, F)
8473cd555cSBin Tu - Sun Microsystems - Beijing China 
85dc0cb1cdSDale Ghent #define	IXGBE_ERROR_INVALID_STATE	"INVALID STATE"
86dc0cb1cdSDale Ghent #define	IXGBE_ERROR_POLLING		"POLLING ERROR"
87dc0cb1cdSDale Ghent #define	IXGBE_ERROR_CAUTION		"CAUTION"
88dc0cb1cdSDale Ghent #define	IXGBE_ERROR_SOFTWARE		"SOFTWARE ERROR"
89dc0cb1cdSDale Ghent #define	IXGBE_ERROR_ARGUMENT		"BAD ARGUMENT"
90dc0cb1cdSDale Ghent #define	IXGBE_ERROR_UNSUPPORTED		"UNSUPPORTED"
91dc0cb1cdSDale Ghent 
92dc0cb1cdSDale Ghent #define	ERROR_REPORT1(S, A)		DEBUGOUT(S ":" A)
93dc0cb1cdSDale Ghent #define	ERROR_REPORT2(S, A, B)		DEBUGOUT1(S ":" A, B)
94dc0cb1cdSDale Ghent #define	ERROR_REPORT3(S, A, B, C)	DEBUGOUT2(S ":" A, B, C)
9573cd555cSBin Tu - Sun Microsystems - Beijing China 
9673cd555cSBin Tu - Sun Microsystems - Beijing China #else
9773cd555cSBin Tu - Sun Microsystems - Beijing China 
9873cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT(S)
9973cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT1(S, A)
10073cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT2(S, A, B)
10173cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT3(S, A, B, C)
10273cd555cSBin Tu - Sun Microsystems - Beijing China #define	DEBUGOUT6(S, A, B, C, D, E, F)
10373cd555cSBin Tu - Sun Microsystems - Beijing China 
104dc0cb1cdSDale Ghent #define	ERROR_REPORT1(S, A)
105dc0cb1cdSDale Ghent #define	ERROR_REPORT2(S, A, B)
106dc0cb1cdSDale Ghent #define	ERROR_REPORT3(S, A, B, C)
10773cd555cSBin Tu - Sun Microsystems - Beijing China 
10873cd555cSBin Tu - Sun Microsystems - Beijing China #endif	/* IXGBE_DEBUG */
10973cd555cSBin Tu - Sun Microsystems - Beijing China 
110dc0cb1cdSDale Ghent /*
111dc0cb1cdSDale Ghent  * DEBUGFUNC() is used to print the function call information, however since
112dc0cb1cdSDale Ghent  * DTrace in illumos can be used to trace function calls, this function is
113dc0cb1cdSDale Ghent  * not useful in illumos, and DEBUGFUNC() can spam a large number of
114dc0cb1cdSDale Ghent  * function call system logs (see CR6918426). We sould eliminate
115dc0cb1cdSDale Ghent  * DEBUGFUNC(), but since DEBUGFUNC() is used by the shared code
116dc0cb1cdSDale Ghent  * (maintained by Intel) which is used and shared by ixgbe drivers in
117dc0cb1cdSDale Ghent  * different OSes, we can not remove it, so in illumos just simply define
118dc0cb1cdSDale Ghent  * it as blank.
119dc0cb1cdSDale Ghent  */
120dc0cb1cdSDale Ghent #define	DEBUGFUNC(F)
121dc0cb1cdSDale Ghent 
1229da57d7bSbt extern void ixgbe_log(void *, const char *, ...);
1239da57d7bSbt 
1249da57d7bSbt #ifdef __cplusplus
1259da57d7bSbt }
1269da57d7bSbt #endif
1279da57d7bSbt 
1289da57d7bSbt #endif	/* _IXGBE_DEBUG_H */
129