]> git.saurik.com Git - apple/xnu.git/blob - bsd/netat/debug.h
acf50d81bdd7965a2b20f6931152c31810b84f0b
[apple/xnu.git] / bsd / netat / debug.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Copyright (c) 1988, 1989, 1997 Apple Computer, Inc.
32 */
33
34 /* netat/debug.h */
35
36 #ifndef _NETAT_DEBUG_H_
37 #define _NETAT_DEBUG_H_
38 #include <sys/appleapiopts.h>
39 #ifdef __APPLE_API_OBSOLETE
40 #ifdef PRIVATE
41
42 #define D_L_FATAL 0x00000001
43 #define D_L_ERROR 0x00000002
44 #define D_L_WARNING 0x00000004
45 #define D_L_INFO 0x00000008
46 #define D_L_VERBOSE 0x00000010
47 #define D_L_STARTUP 0x00000020
48 #define D_L_STARTUP_LOW 0x00000040
49 #define D_L_SHUTDN 0x00000080
50 #define D_L_SHUTDN_LOW 0x00000100
51 #define D_L_INPUT 0x00000200
52 #define D_L_OUTPUT 0x00000400
53 #define D_L_STATS 0x00000800
54 #define D_L_STATE_CHG 0x00001000 /* re-aarp, ifState etc. */
55 #define D_L_ROUTING 0x00002000
56 #define D_L_DNSTREAM 0x00004000
57 #define D_L_UPSTREAM 0x00008000
58 #define D_L_STARTUP_INFO 0x00010000
59 #define D_L_SHUTDN_INFO 0x00020000
60 #define D_L_ROUTING_AT 0x00040000 /* atalk address routing */
61 #define D_L_USR1 0x01000000
62 #define D_L_USR2 0x02000000
63 #define D_L_USR3 0x04000000
64 #define D_L_USR4 0x08000000
65 #define D_L_TRACE 0x10000000
66
67
68 #define D_M_PAT 0x00000001
69 #define D_M_PAT_LOW 0x00000002
70 #define D_M_ELAP 0x00000004
71 #define D_M_ELAP_LOW 0x00000008
72 #define D_M_DDP 0x00000010
73 #define D_M_DDP_LOW 0x00000020
74 #define D_M_NBP 0x00000040
75 #define D_M_NBP_LOW 0x00000080
76 #define D_M_ZIP 0x00000100
77 #define D_M_ZIP_LOW 0x00000200
78 #define D_M_RTMP 0x00000400
79 #define D_M_RTMP_LOW 0x00000800
80 #define D_M_ATP 0x00001000
81 #define D_M_ATP_LOW 0x00002000
82 #define D_M_ADSP 0x00004000
83 #define D_M_ADSP_LOW 0x00008000
84 #define D_M_AEP 0x00010000
85 #define D_M_AARP 0x00020000
86 #define D_M_ASP 0x00040000
87 #define D_M_ASP_LOW 0x00080000
88 #define D_M_AURP 0x00100000
89 #define D_M_AURP_LOW 0x00200000
90 #define D_M_TRACE 0x10000000
91
92 /* macros for working with atp data at the lap level.
93 * These are for tracehook performance measurements only!!!
94 * It is assumed that the ddp & atp headers are at the top of the
95 * mblk, occupy contiguous memory and the atp headers are of the
96 * extended type only.
97 */
98
99 typedef struct dbgBits {
100 unsigned long dbgMod; /* debug module bitmap (used in dPrintf) */
101 unsigned long dbgLev; /* debug level bitmap */
102 } dbgBits_t;
103
104 extern dbgBits_t dbgBits;
105
106 /* macros for debugging */
107 #ifdef DEBUG
108 #define dPrintf(mod, lev, p) \
109 if (((mod) & dbgBits.dbgMod) && ((lev) & dbgBits.dbgLev)) {\
110 kprintf p; \
111 }
112 #else
113 #define dPrintf(mod, lev, p)
114 #endif
115 \f
116 /* 8/5/98 LD: Adds MacOSX kernel debugging facility */
117 /* note: kdebug must be added to the "RELEASE" config in conf/MASTER.ppc */
118
119 #include <sys/kdebug.h>
120 #if KDEBUG
121 /*
122 Strings for the "trace/codes" file:
123
124 0x02650004 AT_DDPinput
125
126 0x02680000 AT_ADSP_Misc
127 0x02680004 AT_ADSP_RxData
128 0x02680008 AT_ADSP_SndData
129 0x0268000C AT_ADSP_Read
130 0x02680010 AT_ADSP_Write
131 0x02680014 AT_ADSP_mbuf
132 0x02680018 AT_ADSP_putnext
133 0x0268001c AT_ADSP_ATrw
134
135 */
136
137 /* usage:
138 KERNEL_DEBUG(DBG_AT_DDP_INPUT | DBG_FUNC_START, 0,0,0,0,0);
139 KERNEL_DEBUG(DBG_AT_DDP_INPUT, 0,0,0,0,0);
140 KERNEL_DEBUG(DBG_AT_DDP_INPUT | DBG_FUNC_END, 0,0,0,0,0);
141 */
142
143 #define DBG_AT_DDP_INPUT NETDBG_CODE(DBG_NETDDP, 1)
144 #define DBG_AT_DDP_OUTPUT NETDBG_CODE(DBG_NETDDP, 2)
145
146 #define DBG_ADSP_MISC NETDBG_CODE(DBG_NETADSP, 0)
147 #define DBG_ADSP_RCV NETDBG_CODE(DBG_NETADSP, 1)
148 #define DBG_ADSP_SND NETDBG_CODE(DBG_NETADSP, 2)
149 #define DBG_ADSP_READ NETDBG_CODE(DBG_NETADSP, 3)
150 #define DBG_ADSP_WRITE NETDBG_CODE(DBG_NETADSP, 4)
151 #define DBG_ADSP_MBUF NETDBG_CODE(DBG_NETADSP, 5)
152 #define DBG_ADSP_PNEXT NETDBG_CODE(DBG_NETADSP, 6)
153 #define DBG_ADSP_ATRW NETDBG_CODE(DBG_NETADSP, 7)
154 #endif
155
156 #define trace_mbufs(pri, str, start)\
157 { if (start)\
158 { int i; gbuf_t *tmp;\
159 for (tmp=start, i=0; tmp && i < 10; tmp = gbuf_cont(tmp), i++) {\
160 dPrintf(pri, D_L_TRACE, ("%s=0x%x, len=%d %s\n",\
161 str, tmp, gbuf_len(tmp),\
162 (((struct mbuf *)tmp)->m_flags & M_EXT)?"CL":""));\
163 KERNEL_DEBUG(DBG_ADSP_MBUF, 0, tmp, gbuf_len(tmp), gbuf_next(tmp), \
164 ((struct mbuf *)tmp)->m_flags & M_EXT);\
165 }}}
166
167 /* from h/atlog.h */
168
169 /* These pointers are non-NULL if logging or tracing are activated. */
170 #ifndef LOG_DRIVER
171 extern char *log_errp;
172 extern char *log_trcp;
173 #endif /* LOG_DRIVER */
174
175 /* ATTRACE() macro. Use this routine for calling
176 * streams tracing and logging. If `log' is TRUE, then
177 * this event will also be logged if logging is on.
178 */
179 #if !defined(lint) && defined(AT_DEBUG)
180 #define ATTRACE(mid,sid,level,log,fmt,arg1,arg2,arg3) \
181 if (log_trcp || (log && log_errp)) { \
182 strlog(mid,sid,level,SL_TRACE | \
183 (log ? SL_ERROR : 0) | \
184 (level <= AT_LV_FATAL ? SL_FATAL : 0), \
185 fmt,arg1,arg2,arg3); \
186 }
187 #else
188 #define ATTRACE(mid,sid,level,log,fmt,arg1,arg2,arg3) \
189 /* printf(fmt, arg1, arg2, arg3); */
190
191 #endif
192
193
194 /* Levels for AppleTalk tracing */
195
196 #define AT_LV_FATAL 1
197 #define AT_LV_ERROR 3
198 #define AT_LV_WARNING 5
199 #define AT_LV_INFO 7
200 #define AT_LV_VERBOSE 9
201
202
203 /* Sub-ids for AppleTalk tracing, add more if you can't figure
204 * out where your event belongs.
205 */
206
207 #define AT_SID_INPUT 1 /* Network incoming packets */
208 #define AT_SID_OUTPUT 2 /* Network outgoing packets */
209 #define AT_SID_TIMERS 3 /* Protocol timers */
210 #define AT_SID_FLOWCTRL 4 /* Protocol flow control */
211 #define AT_SID_USERREQ 5 /* User requests */
212 #define AT_SID_RESOURCE 6 /* Resource limitations */
213
214
215
216 /* Module ID's for AppleTalk subsystems */
217
218 #define AT_MID(n) (200+n)
219
220 /*
221 #define AT_MID_MISC AT_MID(0) not used
222 #define AT_MID_LLAP AT_MID(1) not_used
223 #define AT_MID_ELAP 202 moved to lap.h
224 #define AT_MID_DDP 203 moved to ddp.h
225 #define AT_MID_RTMP AT_MID(4) not used
226 #define AT_MID_NBP AT_MID(5) not used
227 #define AT_MID_EP AT_MID(6) not used
228 #define AT_MID_ATP AT_MID(7) not used
229 #define AT_MID_ZIP AT_MID(8) not needed
230 #define AT_MID_PAP AT_MID(9) not used
231 #define AT_MID_ASP AT_MID(10) redefined in adsp.h
232 #define AT_MID_AFP AT_MID(11) not used
233 #define AT_MID_ADSP 212 moved to adsp.h
234 #define AT_MID_NBPD AT_MID(13) not used
235 #define AT_MID_LAP 214 moved to lap.h
236 #define AT_MID_LAST 214
237 */
238
239 #ifdef AT_MID_STRINGS
240 static char *at_mid_strings[] = {
241 "misc",
242 "LLAP",
243 "ELAP",
244 "DDP",
245 "RTMP",
246 "NBP",
247 "EP",
248 "ATP",
249 "ZIP",
250 "PAP",
251 "ASP",
252 "AFP",
253 "ADSP",
254 "NBPD",
255 "LAP"
256 };
257 #endif
258
259
260 #ifndef SL_FATAL
261 /* Don't define these if they're already defined */
262
263 /* Flags for log messages */
264
265 #define SL_FATAL 01 /* indicates fatal error */
266 #define SL_NOTIFY 02 /* logger must notify administrator */
267 #define SL_ERROR 04 /* include on the error log */
268 #define SL_TRACE 010 /* include on the trace log */
269
270 #endif
271
272 #endif /* PRIVATE */
273 #endif /* __APPLE_API_OBSOLETE */
274 #endif /* _NETAT_DEBUG_H_ */
275