xref: /titanic_51/usr/src/uts/common/io/e1000g/e1000g_debug.h (revision fe598cdcd847f8359013532d5c691bb6190378c0)
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_debug_hw = 1;
85 
86 #define	e1000g_ERRS_LEVEL	0x001	/* (1)	Errors */
87 #define	e1000g_WARN_LEVEL	0x002	/* (2)	Warnings */
88 #define	e1000g_INFO_LEVEL	0x004	/* (4)	Information */
89 #define	e1000g_CALLTRACE_LEVEL	0x008	/* (8)	Subroutine calls and */
90 					/*	control flow */
91 #define	e1000g_VERBOSE_LEVEL	0x010	/* (16)	I/O Data (verbose!) */
92 #define	e1000g_RECV_LEVEL	0x020	/* (32)	Receive Debug Info */
93 #define	e1000g_SEND_LEVEL	0x040	/* (64)	Send Debug Info */
94 #define	e1000g_INT_LEVEL	0x080	/* (128) Interrupt Debug Info */
95 #define	e1000g_DDI_LEVEL	0x100	/* (256) DDI Debug Info */
96 
97 #define	e1000g_DEBUGLOG_0(Adapter, Level, fmt)	\
98 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt))
99 
100 #define	e1000g_DEBUGLOG_1(Adapter, Level, fmt, d1)	\
101 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1))
102 
103 #define	e1000g_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)	\
104 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1), (d2))
105 
106 #define	e1000g_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)	\
107 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
108 		(d2), (d3))
109 
110 #define	e1000g_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)	\
111 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
112 		(d2), (d3), (d4))
113 
114 #define	e1000g_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)	\
115 	if (e1000g_debug) e1000g_log((Adapter), (Level), (fmt), (d1),\
116 		(d2), (d3), (d4), (d5))
117 
118 #define	e1000g_HW_DEBUGLOG	if (e1000g_debug_hw) e1000g_log_hw
119 
120 #else
121 
122 static int e1000g_debug = 0;
123 static int e1000g_debug_hw = 0;
124 
125 #define	e1000g_DEBUGLOG_0(Adapter, Level, fmt)
126 #define	e1000g_DEBUGLOG_1(Adapter, Level, fmt, d1)
127 #define	e1000g_DEBUGLOG_2(Adapter, Level, fmt, d1, d2)
128 #define	e1000g_DEBUGLOG_3(Adapter, Level, fmt, d1, d2, d3)
129 #define	e1000g_DEBUGLOG_4(Adapter, Level, fmt, d1, d2, d3, d4)
130 #define	e1000g_DEBUGLOG_5(Adapter, Level, fmt, d1, d2, d3, d4, d5)
131 #define	e1000g_HW_DEBUGLOG
132 
133 #endif	/* e1000g_DEBUG */
134 
135 #define	NAMELEN		31
136 #define	BUFSZ		256
137 
138 void e1000g_log(struct e1000g *Adapter, int level, char *fmt, ...);
139 void e1000g_log_hw(char *msg, void *cptr, int length);
140 
141 static int e1000g_display_only = DEFAULTDISPLAYONLY;
142 static int e1000g_print_only = DEFAULTPRINTONLY;
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
148 #endif	/* _E1000G_DEBUG_H */
149