1*da8ae05dSGleb Smirnoff /*- 2772e66a6SGleb Smirnoff * Copyright (c) Sun Microsystems, Inc. 1998 All rights reserved. 3772e66a6SGleb Smirnoff * 4772e66a6SGleb Smirnoff * Redistribution and use in source and binary forms, with or without 5772e66a6SGleb Smirnoff * modification, are permitted provided that the following conditions 6772e66a6SGleb Smirnoff * are met: 7772e66a6SGleb Smirnoff * 8772e66a6SGleb Smirnoff * 1. Redistributions of source code must retain the above copyright 9772e66a6SGleb Smirnoff * notice, this list of conditions and the following disclaimer. 10772e66a6SGleb Smirnoff * 11772e66a6SGleb Smirnoff * 2. Redistributions in binary form must reproduce the above copyright 12772e66a6SGleb Smirnoff * notice, this list of conditions and the following disclaimer in the 13772e66a6SGleb Smirnoff * documentation and/or other materials provided with the distribution. 14772e66a6SGleb Smirnoff * 15772e66a6SGleb Smirnoff * 3. All advertising materials mentioning features or use of this software 16772e66a6SGleb Smirnoff * must display the following acknowledgement: 17772e66a6SGleb Smirnoff * This product includes software developed by the SMCC Technology 18772e66a6SGleb Smirnoff * Development Group at Sun Microsystems, Inc. 19772e66a6SGleb Smirnoff * 20772e66a6SGleb Smirnoff * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or 21772e66a6SGleb Smirnoff * promote products derived from this software without specific prior 22772e66a6SGleb Smirnoff * written permission. 23772e66a6SGleb Smirnoff * 24772e66a6SGleb Smirnoff * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE 25772e66a6SGleb Smirnoff * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is 26772e66a6SGleb Smirnoff * provided "as is" without express or implied warranty of any kind. 27772e66a6SGleb Smirnoff * 28772e66a6SGleb Smirnoff * These notices must be retained in any copies of any part of this software. 29*da8ae05dSGleb Smirnoff * 30*da8ae05dSGleb Smirnoff * $KAME: altq_rmclass_debug.h,v 1.3 2002/11/29 04:36:24 kjc Exp $ 31772e66a6SGleb Smirnoff */ 32772e66a6SGleb Smirnoff 33772e66a6SGleb Smirnoff #ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_ 34772e66a6SGleb Smirnoff #define _ALTQ_ALTQ_RMCLASS_DEBUG_H_ 35772e66a6SGleb Smirnoff 36772e66a6SGleb Smirnoff /* 37772e66a6SGleb Smirnoff * Cbq debugging macros 38772e66a6SGleb Smirnoff */ 39772e66a6SGleb Smirnoff 40772e66a6SGleb Smirnoff #ifdef __cplusplus 41772e66a6SGleb Smirnoff extern "C" { 42772e66a6SGleb Smirnoff #endif 43772e66a6SGleb Smirnoff 44772e66a6SGleb Smirnoff #ifdef CBQ_TRACE 45772e66a6SGleb Smirnoff #ifndef NCBQTRACE 46772e66a6SGleb Smirnoff #define NCBQTRACE (16 * 1024) 47772e66a6SGleb Smirnoff #endif 48772e66a6SGleb Smirnoff 49772e66a6SGleb Smirnoff /* 50772e66a6SGleb Smirnoff * To view the trace output, using adb, type: 51772e66a6SGleb Smirnoff * adb -k /dev/ksyms /dev/mem <cr>, then type 52772e66a6SGleb Smirnoff * cbqtrace_count/D to get the count, then type 53772e66a6SGleb Smirnoff * cbqtrace_buffer,0tcount/Dp4C" "Xn 54772e66a6SGleb Smirnoff * This will dump the trace buffer from 0 to count. 55772e66a6SGleb Smirnoff */ 56772e66a6SGleb Smirnoff /* 57772e66a6SGleb Smirnoff * in ALTQ, "call cbqtrace_dump(N)" from DDB to display 20 events 58772e66a6SGleb Smirnoff * from Nth event in the circular buffer. 59772e66a6SGleb Smirnoff */ 60772e66a6SGleb Smirnoff 61772e66a6SGleb Smirnoff struct cbqtrace { 62772e66a6SGleb Smirnoff int count; 63772e66a6SGleb Smirnoff int function; /* address of function */ 64772e66a6SGleb Smirnoff int trace_action; /* descriptive 4 characters */ 65772e66a6SGleb Smirnoff int object; /* object operated on */ 66772e66a6SGleb Smirnoff }; 67772e66a6SGleb Smirnoff 68772e66a6SGleb Smirnoff extern struct cbqtrace cbqtrace_buffer[]; 69772e66a6SGleb Smirnoff extern struct cbqtrace *cbqtrace_ptr; 70772e66a6SGleb Smirnoff extern int cbqtrace_count; 71772e66a6SGleb Smirnoff 72772e66a6SGleb Smirnoff #define CBQTRACEINIT() { \ 73772e66a6SGleb Smirnoff if (cbqtrace_ptr == NULL) \ 74772e66a6SGleb Smirnoff cbqtrace_ptr = cbqtrace_buffer; \ 75772e66a6SGleb Smirnoff else { \ 76772e66a6SGleb Smirnoff cbqtrace_ptr = cbqtrace_buffer; \ 77772e66a6SGleb Smirnoff bzero((void *)cbqtrace_ptr, sizeof(cbqtrace_buffer)); \ 78772e66a6SGleb Smirnoff cbqtrace_count = 0; \ 79772e66a6SGleb Smirnoff } \ 80772e66a6SGleb Smirnoff } 81772e66a6SGleb Smirnoff 82772e66a6SGleb Smirnoff #define LOCK_TRACE() splimp() 83772e66a6SGleb Smirnoff #define UNLOCK_TRACE(x) splx(x) 84772e66a6SGleb Smirnoff 85772e66a6SGleb Smirnoff #define CBQTRACE(func, act, obj) { \ 86772e66a6SGleb Smirnoff int __s = LOCK_TRACE(); \ 87772e66a6SGleb Smirnoff int *_p = &cbqtrace_ptr->count; \ 88772e66a6SGleb Smirnoff *_p++ = ++cbqtrace_count; \ 89772e66a6SGleb Smirnoff *_p++ = (int)(func); \ 90772e66a6SGleb Smirnoff *_p++ = (int)(act); \ 91772e66a6SGleb Smirnoff *_p++ = (int)(obj); \ 92772e66a6SGleb Smirnoff if ((struct cbqtrace *)(void *)_p >= &cbqtrace_buffer[NCBQTRACE])\ 93772e66a6SGleb Smirnoff cbqtrace_ptr = cbqtrace_buffer; \ 94772e66a6SGleb Smirnoff else \ 95772e66a6SGleb Smirnoff cbqtrace_ptr = (struct cbqtrace *)(void *)_p; \ 96772e66a6SGleb Smirnoff UNLOCK_TRACE(__s); \ 97772e66a6SGleb Smirnoff } 98772e66a6SGleb Smirnoff #else 99772e66a6SGleb Smirnoff 100772e66a6SGleb Smirnoff /* If no tracing, define no-ops */ 101772e66a6SGleb Smirnoff #define CBQTRACEINIT() 102772e66a6SGleb Smirnoff #define CBQTRACE(a, b, c) 103772e66a6SGleb Smirnoff 104772e66a6SGleb Smirnoff #endif /* !CBQ_TRACE */ 105772e66a6SGleb Smirnoff 106772e66a6SGleb Smirnoff #ifdef __cplusplus 107772e66a6SGleb Smirnoff } 108772e66a6SGleb Smirnoff #endif 109772e66a6SGleb Smirnoff 110772e66a6SGleb Smirnoff #endif /* _ALTQ_ALTQ_RMCLASS_DEBUG_H_ */ 111