1130365Smlaier/* $KAME: altq_rmclass_debug.h,v 1.3 2002/11/29 04:36:24 kjc Exp $ */ 2130365Smlaier 3130365Smlaier/* 4130365Smlaier * Copyright (c) Sun Microsystems, Inc. 1998 All rights reserved. 5130365Smlaier * 6130365Smlaier * Redistribution and use in source and binary forms, with or without 7130365Smlaier * modification, are permitted provided that the following conditions 8130365Smlaier * are met: 9130365Smlaier * 10130365Smlaier * 1. Redistributions of source code must retain the above copyright 11130365Smlaier * notice, this list of conditions and the following disclaimer. 12130365Smlaier * 13130365Smlaier * 2. Redistributions in binary form must reproduce the above copyright 14130365Smlaier * notice, this list of conditions and the following disclaimer in the 15130365Smlaier * documentation and/or other materials provided with the distribution. 16130365Smlaier * 17130365Smlaier * 3. All advertising materials mentioning features or use of this software 18130365Smlaier * must display the following acknowledgement: 19130365Smlaier * This product includes software developed by the SMCC Technology 20130365Smlaier * Development Group at Sun Microsystems, Inc. 21130365Smlaier * 22130365Smlaier * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or 23130365Smlaier * promote products derived from this software without specific prior 24130365Smlaier * written permission. 25130365Smlaier * 26130365Smlaier * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE 27130365Smlaier * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is 28130365Smlaier * provided "as is" without express or implied warranty of any kind. 29130365Smlaier * 30130365Smlaier * These notices must be retained in any copies of any part of this software. 31130365Smlaier */ 32130365Smlaier 33130365Smlaier#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_ 34130365Smlaier#define _ALTQ_ALTQ_RMCLASS_DEBUG_H_ 35130365Smlaier 36130365Smlaier/* #pragma ident "@(#)rm_class_debug.h 1.7 98/05/04 SMI" */ 37130365Smlaier 38130365Smlaier/* 39130365Smlaier * Cbq debugging macros 40130365Smlaier */ 41130365Smlaier 42130365Smlaier#ifdef __cplusplus 43130365Smlaierextern "C" { 44130365Smlaier#endif 45130365Smlaier 46130365Smlaier#ifdef CBQ_TRACE 47130365Smlaier#ifndef NCBQTRACE 48130365Smlaier#define NCBQTRACE (16 * 1024) 49130365Smlaier#endif 50130365Smlaier 51130365Smlaier/* 52130365Smlaier * To view the trace output, using adb, type: 53130365Smlaier * adb -k /dev/ksyms /dev/mem <cr>, then type 54130365Smlaier * cbqtrace_count/D to get the count, then type 55130365Smlaier * cbqtrace_buffer,0tcount/Dp4C" "Xn 56130365Smlaier * This will dump the trace buffer from 0 to count. 57130365Smlaier */ 58130365Smlaier/* 59130365Smlaier * in ALTQ, "call cbqtrace_dump(N)" from DDB to display 20 events 60130365Smlaier * from Nth event in the circular buffer. 61130365Smlaier */ 62130365Smlaier 63130365Smlaierstruct cbqtrace { 64130365Smlaier int count; 65130365Smlaier int function; /* address of function */ 66130365Smlaier int trace_action; /* descriptive 4 characters */ 67130365Smlaier int object; /* object operated on */ 68130365Smlaier}; 69130365Smlaier 70130365Smlaierextern struct cbqtrace cbqtrace_buffer[]; 71130365Smlaierextern struct cbqtrace *cbqtrace_ptr; 72130365Smlaierextern int cbqtrace_count; 73130365Smlaier 74130365Smlaier#define CBQTRACEINIT() { \ 75130365Smlaier if (cbqtrace_ptr == NULL) \ 76130365Smlaier cbqtrace_ptr = cbqtrace_buffer; \ 77130365Smlaier else { \ 78130365Smlaier cbqtrace_ptr = cbqtrace_buffer; \ 79130365Smlaier bzero((void *)cbqtrace_ptr, sizeof(cbqtrace_buffer)); \ 80130365Smlaier cbqtrace_count = 0; \ 81130365Smlaier } \ 82130365Smlaier} 83130365Smlaier 84130365Smlaier#define LOCK_TRACE() splimp() 85130365Smlaier#define UNLOCK_TRACE(x) splx(x) 86130365Smlaier 87130365Smlaier#define CBQTRACE(func, act, obj) { \ 88130365Smlaier int __s = LOCK_TRACE(); \ 89130365Smlaier int *_p = &cbqtrace_ptr->count; \ 90130365Smlaier *_p++ = ++cbqtrace_count; \ 91130365Smlaier *_p++ = (int)(func); \ 92130365Smlaier *_p++ = (int)(act); \ 93130365Smlaier *_p++ = (int)(obj); \ 94130365Smlaier if ((struct cbqtrace *)(void *)_p >= &cbqtrace_buffer[NCBQTRACE])\ 95130365Smlaier cbqtrace_ptr = cbqtrace_buffer; \ 96130365Smlaier else \ 97130365Smlaier cbqtrace_ptr = (struct cbqtrace *)(void *)_p; \ 98130365Smlaier UNLOCK_TRACE(__s); \ 99130365Smlaier } 100130365Smlaier#else 101130365Smlaier 102130365Smlaier/* If no tracing, define no-ops */ 103130365Smlaier#define CBQTRACEINIT() 104130365Smlaier#define CBQTRACE(a, b, c) 105130365Smlaier 106130365Smlaier#endif /* !CBQ_TRACE */ 107130365Smlaier 108130365Smlaier#ifdef __cplusplus 109130365Smlaier} 110130365Smlaier#endif 111130365Smlaier 112130365Smlaier#endif /* _ALTQ_ALTQ_RMCLASS_DEBUG_H_ */ 113