xref: /titanic_41/usr/src/uts/common/io/e1000g/e1000g_debug.h (revision 4a7ceb24cfcc0a97f96d86cfe5852ae445b50e57)
1 /*
2  * This file is provided under a CDDLv1 license.  When using or
3  * redistributing this file, you may do so under this license.
4  * In redistributing this file this license must be included
5  * and no other modification of this header file is permitted.
6  *
7  * CDDL LICENSE SUMMARY
8  *
9  * Copyright(c) 1999 - 2007 Intel Corporation. All rights reserved.
10  *
11  * The contents of this file are subject to the terms of Version
12  * 1.0 of the Common Development and Distribution License (the "License").
13  *
14  * You should have received a copy of the License with this software.
15  * You can obtain a copy of the License at
16  *	http://www.opensolaris.org/os/licensing.
17  * See the License for the specific language governing permissions
18  * and limitations under the License.
19  */
20 
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms of the CDDLv1.
24  */
25 
26 #ifndef _E1000G_DEBUG_H
27 #define	_E1000G_DEBUG_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Debug message control
37  * Debug Levels:
38  *	0x000 - (0)   no messages
39  *	0x001 - (1)   Errors
40  *	0x002 - (2)   Warnings
41  *	0x004 - (4)   Information
42  *	0x008 - (8)   Subroutine calls and control flow
43  *	0x010 - (16)  I/O Data (verbose!)
44  * Variables can be set with entries in the /etc/system file with
45  *	"set e1000g:e1000g_debug=<value>"
46  *	"set e1000g:e1000g_log_mode=<value>"
47  * The /etc/system file is read only once at boot time, if you change
48  * it you must reboot for the change to take effect.
49  *
50  * It turns on diagnostics if DEBUG is defined (DEBUG also
51  * enables other debugging code as ASSERT statements...
52  */
53 
54 #ifdef DEBUG
55 #define	E1000G_DEBUG
56 #endif
57 
58 /*
59  * By default it will print only to log
60  */
61 #define	E1000G_LOG_DISPLAY	0x1
62 #define	E1000G_LOG_PRINT	0x2
63 #define	E1000G_LOG_ALL		0x3
64 
65 #ifdef E1000G_DEBUG
66 
67 #define	E1000G_ERRS_LEVEL	0x001	/* (1)	Errors */
68 #define	E1000G_WARN_LEVEL	0x002	/* (2)	Warnings */
69 #define	E1000G_INFO_LEVEL	0x004	/* (4)	Information */
70 #define	E1000G_TRACE_LEVEL	0x008	/* (8)	Subroutine calls */
71 #define	E1000G_VERBOSE_LEVEL	0x010	/* (16)	I/O Data (verbose!) */
72 
73 #define	E1000G_DEBUGLOG_0(Adapter, Level, fmt)	\
74 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt))
75 
76 #define	E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1)	\
77 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1))
78 
79 #define	E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)	\
80 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2))
81 
82 #define	E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)	\
83 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
84 		(d2), (d3))
85 
86 #define	E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)	\
87 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
88 		(d2), (d3), (d4))
89 
90 #define	E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)	\
91 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
92 		(d2), (d3), (d4), (d5))
93 
94 #define	E1000G_DEBUG_STAT_COND(val, cond)	if (cond) (val)++;
95 #define	E1000G_DEBUG_STAT(val)			(val)++;
96 
97 #else
98 
99 #define	E1000G_DEBUGLOG_0(Adapter, Level, fmt)
100 #define	E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1)
101 #define	E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)
102 #define	E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)
103 #define	E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)
104 #define	E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)
105 
106 #define	E1000G_DEBUG_STAT_COND(val, cond)
107 #define	E1000G_DEBUG_STAT(val)
108 
109 #endif	/* E1000G_DEBUG */
110 
111 #define	NAMELEN		31
112 #define	BUFSZ		256
113 
114 #define	E1000G_STAT(val)	(val)++;
115 
116 void e1000g_log(void *, int, char *, ...);
117 
118 #ifdef E1000G_DEBUG
119 void eeprom_dump(void *);
120 void phy_dump(void *);
121 void mac_dump(void *);
122 void pciconfig_dump(void *);
123 #endif
124 
125 #ifdef E1000G_DEBUG
126 extern int e1000g_debug;
127 #endif
128 extern int e1000g_log_mode;
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif	/* _E1000G_DEBUG_H */
135