xref: /titanic_44/usr/src/uts/common/io/e1000g/e1000g_debug.h (revision 62a1b812a0c45c0d4c10ef645dda42bf71080108)
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  * **********************************************************************
37  *									*
38  * Module Name:								*
39  *   e1000g_debug.h							*
40  *									*
41  * Abstract:								*
42  *									*
43  *   This driver runs on the following hardware:			*
44  *   - Wiseman based PCI gigabit ethernet adapters			*
45  *									*
46  * Environment:								*
47  *   Kernel Mode -							*
48  *									*
49  * **********************************************************************
50  */
51 
52 /*
53  * Debug message control
54  * Debug Levels:
55  *	0x000 - (0)   no messages
56  *	0x001 - (1)   Errors
57  *	0x002 - (2)   Warnings
58  *	0x004 - (4)   Information
59  *	0x008 - (8)   Subroutine calls and control flow
60  *	0x010 - (16)  I/O Data (verbose!)
61  * Speacialised Debug Levels:
62  *	0x020 - (32)  Receive Debug Info
63  *	0x040 - (64)  Send Debug Info
64  *	0x080 - (128) Interrupt Debug Info
65  *	0x100 - (256) DDI Debug Info
66  * Variables can be set with entries in the /etc/system file with
67  * "set e1000g:e1000g_debug=<value>"
68  * "set e1000g:e1000g_debug_hw=<value>"
69  * "set e1000g:e1000g_display_only=<value>"
70  * "set e1000g:e1000g_print_only=<value>"
71  * Alternatively, you can use adb to set variables and debug as
72  * follows:
73  * # adb -kw /dev/ksyms /dev/mem
74  * The /etc/system file is read only once at boot time, if you change
75  * it you must reboot for the change to take effect.
76  *
77  * It turns on diagnostics if DEBUG is defined (DEBUG also
78  * enables other debugging code as ASSERT statements...
79  */
80 
81 #ifdef e1000g_DEBUG
82 
83 static int e1000g_debug = DEFAULTDEBUGLEVEL;
84 static int e1000g_display_only = DEFAULTDISPLAYONLY;
85 static int e1000g_print_only = DEFAULTPRINTONLY;
86 static int e1000g_debug_hw = 1;
87 
88 #define	e1000g_ERRS_LEVEL	0x001	/* (1)	Errors */
89 #define	e1000g_WARN_LEVEL	0x002	/* (2)	Warnings */
90 #define	e1000g_INFO_LEVEL	0x004	/* (4)	Information */
91 #define	e1000g_CALLTRACE_LEVEL	0x008	/* (8)	Subroutine calls and */
92 					/*	control flow */
93 #define	e1000g_VERBOSE_LEVEL	0x010	/* (16)	I/O Data (verbose!) */
94 #define	e1000g_RECV_LEVEL	0x020	/* (32)	Receive Debug Info */
95 #define	e1000g_SEND_LEVEL	0x040	/* (64)	Send Debug Info */
96 #define	e1000g_INT_LEVEL	0x080	/* (128) Interrupt Debug Info */
97 #define	e1000g_DDI_LEVEL	0x100	/* (256) DDI Debug Info */
98 
99 #define	e1000g_DEBUGLOG_0(Adapter, Level, fmt)	\
100 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt))
101 
102 #define	e1000g_DEBUGLOG_1(Adapter, Level, fmt, d1)	\
103 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1))
104 
105 #define	e1000g_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)	\
106 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2))
107 
108 #define	e1000g_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)	\
109 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
110 		(d2), (d3))
111 
112 #define	e1000g_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)	\
113 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
114 		(d2), (d3), (d4))
115 
116 #define	e1000g_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)	\
117 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
118 		(d2), (d3), (d4), (d5))
119 
120 #define	e1000g_HW_DEBUGLOG	if (e1000g_debug_hw) e1000g_log_hw
121 
122 #else
123 
124 static int e1000g_debug = 0;
125 static int e1000g_display_only = 1;	/* 1 - Yes Display, */
126 					/* 0 - Don't Display */
127 static int e1000g_print_only = 1;	/* 1 - Yes Print to Msg Log, */
128 					/* 0 - Don't Print to Msg Log */
129 static int e1000g_debug_hw = 0;
130 
131 #define	e1000g_DEBUGLOG_0(Adapter, Level, fmt)
132 #define	e1000g_DEBUGLOG_1(Adapter, Level, fmt, d1)
133 #define	e1000g_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)
134 #define	e1000g_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)
135 #define	e1000g_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)
136 #define	e1000g_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)
137 #define	e1000g_HW_DEBUGLOG
138 
139 #endif	/* e1000g_DEBUG */
140 
141 #define	NAMELEN		31
142 #define	BUFSZ		256
143 
144 void e1000g_log(struct e1000g *Adapter, int level, char *fmt, ...);
145 void e1000g_log_hw(char *msg, void *cptr, int length);
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif	/* _E1000G_DEBUG_H */
152