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