xref: /illumos-gate/usr/src/uts/common/io/e1000g/e1000g_debug.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
108057504Sxy150489 /*
208057504Sxy150489  * This file is provided under a CDDLv1 license.  When using or
308057504Sxy150489  * redistributing this file, you may do so under this license.
408057504Sxy150489  * In redistributing this file this license must be included
508057504Sxy150489  * and no other modification of this header file is permitted.
608057504Sxy150489  *
708057504Sxy150489  * CDDL LICENSE SUMMARY
808057504Sxy150489  *
9*592a4d85Scc210113  * Copyright(c) 1999 - 2008 Intel Corporation. All rights reserved.
1008057504Sxy150489  *
1108057504Sxy150489  * The contents of this file are subject to the terms of Version
1208057504Sxy150489  * 1.0 of the Common Development and Distribution License (the "License").
1308057504Sxy150489  *
1408057504Sxy150489  * You should have received a copy of the License with this software.
1508057504Sxy150489  * You can obtain a copy of the License at
1608057504Sxy150489  *	http://www.opensolaris.org/os/licensing.
1708057504Sxy150489  * See the License for the specific language governing permissions
1808057504Sxy150489  * and limitations under the License.
1908057504Sxy150489  */
2008057504Sxy150489 
2108057504Sxy150489 /*
22*592a4d85Scc210113  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2308057504Sxy150489  * Use is subject to license terms of the CDDLv1.
2408057504Sxy150489  */
2508057504Sxy150489 
2608057504Sxy150489 #ifndef _E1000G_DEBUG_H
2708057504Sxy150489 #define	_E1000G_DEBUG_H
2808057504Sxy150489 
2908057504Sxy150489 #ifdef __cplusplus
3008057504Sxy150489 extern "C" {
3108057504Sxy150489 #endif
3208057504Sxy150489 
3308057504Sxy150489 /*
3408057504Sxy150489  * Debug message control
3508057504Sxy150489  * Debug Levels:
3608057504Sxy150489  *	0x000 - (0)   no messages
3708057504Sxy150489  *	0x001 - (1)   Errors
3808057504Sxy150489  *	0x002 - (2)   Warnings
3908057504Sxy150489  *	0x004 - (4)   Information
4008057504Sxy150489  *	0x008 - (8)   Subroutine calls and control flow
4108057504Sxy150489  *	0x010 - (16)  I/O Data (verbose!)
4208057504Sxy150489  * Variables can be set with entries in the /etc/system file with
4308057504Sxy150489  *	"set e1000g:e1000g_debug=<value>"
4425f2d433Sxy150489  *	"set e1000g:e1000g_log_mode=<value>"
4508057504Sxy150489  * The /etc/system file is read only once at boot time, if you change
4608057504Sxy150489  * it you must reboot for the change to take effect.
4708057504Sxy150489  *
4808057504Sxy150489  * It turns on diagnostics if DEBUG is defined (DEBUG also
4908057504Sxy150489  * enables other debugging code as ASSERT statements...
5008057504Sxy150489  */
5108057504Sxy150489 
52*592a4d85Scc210113 #include <sys/types.h>
53*592a4d85Scc210113 
5425f2d433Sxy150489 #ifdef DEBUG
5525f2d433Sxy150489 #define	E1000G_DEBUG
5625f2d433Sxy150489 #endif
5708057504Sxy150489 
5825f2d433Sxy150489 /*
5925f2d433Sxy150489  * By default it will print only to log
6025f2d433Sxy150489  */
6125f2d433Sxy150489 #define	E1000G_LOG_DISPLAY	0x1
6225f2d433Sxy150489 #define	E1000G_LOG_PRINT	0x2
6325f2d433Sxy150489 #define	E1000G_LOG_ALL		0x3
6408057504Sxy150489 
6525f2d433Sxy150489 #ifdef E1000G_DEBUG
6608057504Sxy150489 
6725f2d433Sxy150489 #define	E1000G_ERRS_LEVEL	0x001	/* (1)	Errors */
6825f2d433Sxy150489 #define	E1000G_WARN_LEVEL	0x002	/* (2)	Warnings */
6925f2d433Sxy150489 #define	E1000G_INFO_LEVEL	0x004	/* (4)	Information */
7025f2d433Sxy150489 #define	E1000G_TRACE_LEVEL	0x008	/* (8)	Subroutine calls */
7125f2d433Sxy150489 #define	E1000G_VERBOSE_LEVEL	0x010	/* (16)	I/O Data (verbose!) */
7225f2d433Sxy150489 
7325f2d433Sxy150489 #define	E1000G_DEBUGLOG_0(Adapter, Level, fmt)	\
7408057504Sxy150489 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt))
7508057504Sxy150489 
7625f2d433Sxy150489 #define	E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1)	\
7708057504Sxy150489 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1))
7808057504Sxy150489 
7925f2d433Sxy150489 #define	E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)	\
8008057504Sxy150489 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2))
8108057504Sxy150489 
8225f2d433Sxy150489 #define	E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)	\
8308057504Sxy150489 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
8408057504Sxy150489 		(d2), (d3))
8508057504Sxy150489 
8625f2d433Sxy150489 #define	E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)	\
8708057504Sxy150489 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
8808057504Sxy150489 		(d2), (d3), (d4))
8908057504Sxy150489 
9025f2d433Sxy150489 #define	E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)	\
9108057504Sxy150489 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
9208057504Sxy150489 		(d2), (d3), (d4), (d5))
9308057504Sxy150489 
9425f2d433Sxy150489 #define	E1000G_DEBUG_STAT_COND(val, cond)	if (cond) (val)++;
9525f2d433Sxy150489 #define	E1000G_DEBUG_STAT(val)			(val)++;
9608057504Sxy150489 
9708057504Sxy150489 #else
9808057504Sxy150489 
9925f2d433Sxy150489 #define	E1000G_DEBUGLOG_0(Adapter, Level, fmt)
10025f2d433Sxy150489 #define	E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1)
10125f2d433Sxy150489 #define	E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)
10225f2d433Sxy150489 #define	E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)
10325f2d433Sxy150489 #define	E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)
10425f2d433Sxy150489 #define	E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)
10508057504Sxy150489 
10625f2d433Sxy150489 #define	E1000G_DEBUG_STAT_COND(val, cond)
10725f2d433Sxy150489 #define	E1000G_DEBUG_STAT(val)
10808057504Sxy150489 
10925f2d433Sxy150489 #endif	/* E1000G_DEBUG */
11008057504Sxy150489 
11108057504Sxy150489 #define	NAMELEN		31
11208057504Sxy150489 #define	BUFSZ		256
11308057504Sxy150489 
11425f2d433Sxy150489 #define	E1000G_STAT(val)	(val)++;
11508057504Sxy150489 
1164914a7d0Syy150190 void e1000g_log(void *, int, char *, ...);
1174914a7d0Syy150190 
1184914a7d0Syy150190 #ifdef E1000G_DEBUG
1194914a7d0Syy150190 void eeprom_dump(void *);
1204914a7d0Syy150190 void phy_dump(void *);
1214914a7d0Syy150190 void mac_dump(void *);
1224914a7d0Syy150190 void pciconfig_dump(void *);
123*592a4d85Scc210113 void pciconfig_bar(void *, uint32_t, char *);
1244914a7d0Syy150190 #endif
12525f2d433Sxy150489 
12625f2d433Sxy150489 #ifdef E1000G_DEBUG
12725f2d433Sxy150489 extern int e1000g_debug;
12825f2d433Sxy150489 #endif
12925f2d433Sxy150489 extern int e1000g_log_mode;
1307941757cSxy150489 
13108057504Sxy150489 #ifdef __cplusplus
13208057504Sxy150489 }
13308057504Sxy150489 #endif
13408057504Sxy150489 
13508057504Sxy150489 #endif	/* _E1000G_DEBUG_H */
136