/*-1* Copyright (c) Sun Microsystems, Inc. 1998 All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9*10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* 3. All advertising materials mentioning features or use of this software15* must display the following acknowledgement:16* This product includes software developed by the SMCC Technology17* Development Group at Sun Microsystems, Inc.18*19* 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or20* promote products derived from this software without specific prior21* written permission.22*23* SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE24* SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is25* provided "as is" without express or implied warranty of any kind.26*27* These notices must be retained in any copies of any part of this software.28*29* $KAME: altq_rmclass_debug.h,v 1.3 2002/11/29 04:36:24 kjc Exp $30*/3132#ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_33#define _ALTQ_ALTQ_RMCLASS_DEBUG_H_3435/*36* Cbq debugging macros37*/3839#ifdef __cplusplus40extern "C" {41#endif4243#ifdef CBQ_TRACE44#ifndef NCBQTRACE45#define NCBQTRACE (16 * 1024)46#endif4748/*49* To view the trace output, using adb, type:50* adb -k /dev/ksyms /dev/mem <cr>, then type51* cbqtrace_count/D to get the count, then type52* cbqtrace_buffer,0tcount/Dp4C" "Xn53* This will dump the trace buffer from 0 to count.54*/55/*56* in ALTQ, "call cbqtrace_dump(N)" from DDB to display 20 events57* from Nth event in the circular buffer.58*/5960struct cbqtrace {61int count;62int function; /* address of function */63int trace_action; /* descriptive 4 characters */64int object; /* object operated on */65};6667extern struct cbqtrace cbqtrace_buffer[];68extern struct cbqtrace *cbqtrace_ptr;69extern int cbqtrace_count;7071#define CBQTRACEINIT() { \72if (cbqtrace_ptr == NULL) \73cbqtrace_ptr = cbqtrace_buffer; \74else { \75cbqtrace_ptr = cbqtrace_buffer; \76bzero((void *)cbqtrace_ptr, sizeof(cbqtrace_buffer)); \77cbqtrace_count = 0; \78} \79}8081#define LOCK_TRACE() splimp()82#define UNLOCK_TRACE(x) splx(x)8384#define CBQTRACE(func, act, obj) { \85int __s = LOCK_TRACE(); \86int *_p = &cbqtrace_ptr->count; \87*_p++ = ++cbqtrace_count; \88*_p++ = (int)(func); \89*_p++ = (int)(act); \90*_p++ = (int)(obj); \91if ((struct cbqtrace *)(void *)_p >= &cbqtrace_buffer[NCBQTRACE])\92cbqtrace_ptr = cbqtrace_buffer; \93else \94cbqtrace_ptr = (struct cbqtrace *)(void *)_p; \95UNLOCK_TRACE(__s); \96}97#else9899/* If no tracing, define no-ops */100#define CBQTRACEINIT()101#define CBQTRACE(a, b, c)102103#endif /* !CBQ_TRACE */104105#ifdef __cplusplus106}107#endif108109#endif /* _ALTQ_ALTQ_RMCLASS_DEBUG_H_ */110111112