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