xref: /titanic_41/usr/src/uts/common/io/e1000g/e1000g_debug.h (revision e0724c534a46ca4754330bc022bf1e2a68f5bb93)
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 - 2008 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 2008 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 #include <sys/types.h>
55 
56 #ifdef DEBUG
57 #define	E1000G_DEBUG
58 #endif
59 
60 /*
61  * By default it will print only to log
62  */
63 #define	E1000G_LOG_DISPLAY	0x1
64 #define	E1000G_LOG_PRINT	0x2
65 #define	E1000G_LOG_ALL		0x3
66 
67 #ifdef E1000G_DEBUG
68 
69 #define	E1000G_ERRS_LEVEL	0x001	/* (1)	Errors */
70 #define	E1000G_WARN_LEVEL	0x002	/* (2)	Warnings */
71 #define	E1000G_INFO_LEVEL	0x004	/* (4)	Information */
72 #define	E1000G_TRACE_LEVEL	0x008	/* (8)	Subroutine calls */
73 #define	E1000G_VERBOSE_LEVEL	0x010	/* (16)	I/O Data (verbose!) */
74 
75 #define	E1000G_DEBUGLOG_0(Adapter, Level, fmt)	\
76 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt))
77 
78 #define	E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1)	\
79 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1))
80 
81 #define	E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)	\
82 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2))
83 
84 #define	E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)	\
85 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
86 		(d2), (d3))
87 
88 #define	E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)	\
89 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
90 		(d2), (d3), (d4))
91 
92 #define	E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)	\
93 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
94 		(d2), (d3), (d4), (d5))
95 
96 #define	E1000G_DEBUG_STAT_COND(val, cond)	if (cond) (val)++;
97 #define	E1000G_DEBUG_STAT(val)			(val)++;
98 
99 #else
100 
101 #define	E1000G_DEBUGLOG_0(Adapter, Level, fmt)
102 #define	E1000G_DEBUGLOG_1(Adapter, Level, fmt, d1)
103 #define	E1000G_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)
104 #define	E1000G_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)
105 #define	E1000G_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)
106 #define	E1000G_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)
107 
108 #define	E1000G_DEBUG_STAT_COND(val, cond)
109 #define	E1000G_DEBUG_STAT(val)
110 
111 #endif	/* E1000G_DEBUG */
112 
113 #define	NAMELEN		31
114 #define	BUFSZ		256
115 
116 #define	E1000G_STAT(val)	(val)++;
117 
118 void e1000g_log(void *, int, char *, ...);
119 
120 #ifdef E1000G_DEBUG
121 void eeprom_dump(void *);
122 void phy_dump(void *);
123 void mac_dump(void *);
124 void pciconfig_dump(void *);
125 void pciconfig_bar(void *, uint32_t, char *);
126 #endif
127 
128 #ifdef E1000G_DEBUG
129 extern int e1000g_debug;
130 #endif
131 extern int e1000g_log_mode;
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif	/* _E1000G_DEBUG_H */
138