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