Home | History | Annotate | Line # | Download | only in altq
altq_rmclass_debug.h revision 1.2.2.3
      1  1.2.2.3  bouyer /*	$NetBSD: altq_rmclass_debug.h,v 1.2.2.3 2001/04/21 17:46:12 bouyer Exp $	*/
      2  1.2.2.2  bouyer /*	$KAME: altq_rmclass_debug.h,v 1.2 2000/02/22 14:00:35 itojun Exp $	*/
      3  1.2.2.2  bouyer 
      4  1.2.2.2  bouyer /*
      5  1.2.2.2  bouyer  * Copyright (c) Sun Microsystems, Inc. 1998 All rights reserved.
      6  1.2.2.2  bouyer  *
      7  1.2.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
      8  1.2.2.2  bouyer  * modification, are permitted provided that the following conditions
      9  1.2.2.2  bouyer  * are met:
     10  1.2.2.2  bouyer  *
     11  1.2.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     12  1.2.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     13  1.2.2.2  bouyer  *
     14  1.2.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.2.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     16  1.2.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     17  1.2.2.2  bouyer  *
     18  1.2.2.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.2.2.2  bouyer  *    must display the following acknowledgement:
     20  1.2.2.2  bouyer  *      This product includes software developed by the SMCC Technology
     21  1.2.2.2  bouyer  *      Development Group at Sun Microsystems, Inc.
     22  1.2.2.2  bouyer  *
     23  1.2.2.2  bouyer  * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or
     24  1.2.2.2  bouyer  *      promote products derived from this software without specific prior
     25  1.2.2.2  bouyer  *      written permission.
     26  1.2.2.2  bouyer  *
     27  1.2.2.2  bouyer  * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE
     28  1.2.2.2  bouyer  * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software is
     29  1.2.2.2  bouyer  * provided "as is" without express or implied warranty of any kind.
     30  1.2.2.2  bouyer  *
     31  1.2.2.2  bouyer  * These notices must be retained in any copies of any part of this software.
     32  1.2.2.2  bouyer  */
     33  1.2.2.2  bouyer 
     34  1.2.2.2  bouyer #ifndef _ALTQ_ALTQ_RMCLASS_DEBUG_H_
     35  1.2.2.2  bouyer #define	_ALTQ_ALTQ_RMCLASS_DEBUG_H_
     36  1.2.2.2  bouyer 
     37  1.2.2.2  bouyer /* #pragma ident	"@(#)rm_class_debug.h	1.7	98/05/04 SMI" */
     38  1.2.2.2  bouyer 
     39  1.2.2.2  bouyer /*
     40  1.2.2.2  bouyer  * Cbq debugging macros
     41  1.2.2.2  bouyer  */
     42  1.2.2.2  bouyer 
     43  1.2.2.2  bouyer #ifdef __cplusplus
     44  1.2.2.2  bouyer extern "C" {
     45  1.2.2.2  bouyer #endif
     46  1.2.2.2  bouyer 
     47  1.2.2.2  bouyer #ifdef	CBQ_TRACE
     48  1.2.2.2  bouyer #ifndef NCBQTRACE
     49  1.2.2.2  bouyer #define	NCBQTRACE (16 * 1024)
     50  1.2.2.2  bouyer #endif
     51  1.2.2.2  bouyer 
     52  1.2.2.2  bouyer /*
     53  1.2.2.2  bouyer  * To view the trace output, using adb, type:
     54  1.2.2.2  bouyer  *	adb -k /dev/ksyms /dev/mem <cr>, then type
     55  1.2.2.2  bouyer  *	cbqtrace_count/D to get the count, then type
     56  1.2.2.2  bouyer  *	cbqtrace_buffer,0tcount/Dp4C" "Xn
     57  1.2.2.2  bouyer  *	This will dump the trace buffer from 0 to count.
     58  1.2.2.2  bouyer  */
     59  1.2.2.2  bouyer /*
     60  1.2.2.2  bouyer  * in ALTQ, "call cbqtrace_dump(N)" from DDB to display 20 events
     61  1.2.2.2  bouyer  * from Nth event in the circular buffer.
     62  1.2.2.2  bouyer  */
     63  1.2.2.2  bouyer 
     64  1.2.2.2  bouyer struct cbqtrace {
     65  1.2.2.2  bouyer 	int count;
     66  1.2.2.2  bouyer 	int function;		/* address of function */
     67  1.2.2.2  bouyer 	int trace_action;	/* descriptive 4 characters */
     68  1.2.2.2  bouyer 	int object;		/* object operated on */
     69  1.2.2.2  bouyer };
     70  1.2.2.2  bouyer 
     71  1.2.2.2  bouyer extern struct cbqtrace cbqtrace_buffer[];
     72  1.2.2.2  bouyer extern struct cbqtrace *cbqtrace_ptr;
     73  1.2.2.2  bouyer extern int cbqtrace_count;
     74  1.2.2.2  bouyer 
     75  1.2.2.2  bouyer #define	CBQTRACEINIT() {				\
     76  1.2.2.2  bouyer 	if (cbqtrace_ptr == NULL)		\
     77  1.2.2.2  bouyer 		cbqtrace_ptr = cbqtrace_buffer; \
     78  1.2.2.2  bouyer 	else { \
     79  1.2.2.2  bouyer 		cbqtrace_ptr = cbqtrace_buffer; \
     80  1.2.2.2  bouyer 		bzero((void *)cbqtrace_ptr, sizeof(cbqtrace_buffer)); \
     81  1.2.2.2  bouyer 		cbqtrace_count = 0; \
     82  1.2.2.2  bouyer 	} \
     83  1.2.2.2  bouyer }
     84  1.2.2.2  bouyer 
     85  1.2.2.3  bouyer #define	LOCK_TRACE()	splnet()
     86  1.2.2.2  bouyer #define	UNLOCK_TRACE(x)	splx(x)
     87  1.2.2.2  bouyer 
     88  1.2.2.2  bouyer #define	CBQTRACE(func, act, obj) {		\
     89  1.2.2.2  bouyer 	int __s = LOCK_TRACE();			\
     90  1.2.2.2  bouyer 	int *_p = &cbqtrace_ptr->count;	\
     91  1.2.2.2  bouyer 	*_p++ = ++cbqtrace_count;		\
     92  1.2.2.2  bouyer 	*_p++ = (int)(func);			\
     93  1.2.2.2  bouyer 	*_p++ = (int)(act);			\
     94  1.2.2.2  bouyer 	*_p++ = (int)(obj);			\
     95  1.2.2.2  bouyer 	if ((struct cbqtrace *)(void *)_p >= &cbqtrace_buffer[NCBQTRACE])\
     96  1.2.2.2  bouyer 		cbqtrace_ptr = cbqtrace_buffer; \
     97  1.2.2.2  bouyer 	else					\
     98  1.2.2.2  bouyer 		cbqtrace_ptr = (struct cbqtrace *)(void *)_p; \
     99  1.2.2.2  bouyer 	UNLOCK_TRACE(__s);			\
    100  1.2.2.2  bouyer 	}
    101  1.2.2.2  bouyer #else
    102  1.2.2.2  bouyer 
    103  1.2.2.2  bouyer /* If no tracing, define no-ops */
    104  1.2.2.2  bouyer #define	CBQTRACEINIT()
    105  1.2.2.2  bouyer #define	CBQTRACE(a, b, c)
    106  1.2.2.2  bouyer 
    107  1.2.2.2  bouyer #endif	/* !CBQ_TRACE */
    108  1.2.2.2  bouyer 
    109  1.2.2.2  bouyer #ifdef __cplusplus
    110  1.2.2.2  bouyer }
    111  1.2.2.2  bouyer #endif
    112  1.2.2.2  bouyer 
    113  1.2.2.2  bouyer #endif	/* _ALTQ_ALTQ_RMCLASS_DEBUG_H_ */
    114