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