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