6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / uts / common / sys / strft.h
blob150bbf01f56cb76676dcf44ff4ee6e6710de1191
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_STRFT_H
27 #define _SYS_STRFT_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
34 * The flow trace subsystem is used to trace the flow of STREAMS messages
35 * through a stream.
37 * WARNING: this is a private subsystem and subject to change at any time!
40 #include <sys/time.h>
41 #include <sys/types.h>
42 #include <sys/stream.h>
45 * Some evnt defines, values 0..N are reserved for internal use,
46 * (N+1)..0x1FFF are available for arbitrary module/drvier use,
47 * 0x8000 (RD/WR q marker) and 0x4000 (thread cs marker) are or'ed
48 * flag bits reserved for internal use.
50 #define FTEV_MASK 0x1FFF
51 #define FTEV_ISWR 0x8000
52 #define FTEV_CS 0x4000
53 #define FTEV_PS 0x2000
55 #define FTEV_QMASK 0x1F00
57 #define FTEV_ALLOCMASK 0x1FF8
58 #define FTEV_ALLOCB 0x0000
59 #define FTEV_ESBALLOC 0x0001
60 #define FTEV_DESBALLOC 0x0002
61 #define FTEV_ESBALLOCA 0x0003
62 #define FTEV_DESBALLOCA 0x0004
63 #define FTEV_ALLOCBIG 0x0005
64 #define FTEV_ALLOCBW 0x0006
65 #define FTEV_BCALLOCB 0x0007
66 #define FTEV_FREEB 0x0008
67 #define FTEV_DUPB 0x0009
68 #define FTEV_COPYB 0x000A
70 #define FTEV_CALLER 0x000F
72 #define FTEV_PUT 0x0100
73 #define FTEV_PUTQ 0x0105
74 #define FTEV_GETQ 0x0106
75 #define FTEV_RMVQ 0x0107
76 #define FTEV_INSQ 0x0108
77 #define FTEV_PUTBQ 0x0109
78 #define FTEV_FLUSHQ 0x010A
79 #define FTEV_PUTNEXT 0x010D
80 #define FTEV_RWNEXT 0x010E
82 #define FTBLK_EVNTS 9
83 #define FTSTK_DEPTH 15
86 * Stack information for each flow trace event; recorded when str_ftstack
87 * is non-zero.
89 typedef struct ftstk {
90 uint_t fs_depth;
91 pc_t fs_stk[FTSTK_DEPTH];
92 } ftstk_t;
95 * Data structure that contains the timestamp, module/driver name, next
96 * module/driver name, optional callstack, event and event data (not certain
97 * as to its use yet: RSF). There is one per event. Every time str_ftevent()
98 * is called, one of the indices is filled in with this data.
100 typedef struct ftevnt {
101 hrtime_t ts; /* event timestamp, per gethrtime() */
102 char *mid; /* module/driver name */
103 char *midnext; /* next module/driver name */
104 ushort_t evnt; /* FTEV_* value above */
105 ushort_t data; /* event data */
106 ftstk_t *stk; /* optional event callstack */
107 } ftevnt_t;
110 * A linked list of ftevnt arrays.
112 typedef struct ftblk {
113 struct ftblk *nxt; /* next ftblk (or NULL if none) */
114 int ix; /* index of next free ev[] */
115 struct ftevnt ev[FTBLK_EVNTS];
116 } ftblk_t;
119 * The flow trace header (start of event list). It consists of the
120 * current writable block (tail)
121 * a hash value (for recovering trace information)
122 * The last thread to process an event
123 * The last cpu to process an event
124 * The start of the list
125 * This structure is attached to a dblk, and traces a message through
126 * a flow.
128 typedef struct fthdr {
129 struct ftblk *tail;
130 uint_t hash; /* accumulated hash value (sum of mid's) */
131 void *thread;
132 int cpu_seqid;
133 struct ftblk first;
134 } fthdr_t;
136 #ifdef _KERNEL
138 struct datab;
140 extern void str_ftevent(fthdr_t *, void *, ushort_t, ushort_t);
141 extern void str_ftfree(struct datab *);
142 extern int str_ftnever, str_ftstack;
145 * Allocate flow-trace information and record an allocation event.
147 #define STR_FTALLOC(hpp, e, d) { \
148 if (str_ftnever == 0) { \
149 fthdr_t *_hp = *(hpp); \
151 ASSERT(_hp == NULL); \
152 _hp = kmem_cache_alloc(fthdr_cache, KM_NOSLEEP); \
153 if ((*hpp = _hp) != NULL) { \
154 _hp->tail = &_hp->first; \
155 _hp->hash = 0; \
156 _hp->thread = curthread; \
157 _hp->cpu_seqid = CPU->cpu_seqid; \
158 _hp->first.nxt = NULL; \
159 _hp->first.ix = 0; \
160 str_ftevent(_hp, caller(), (e), (d)); \
166 * Add a flow-trace event to the passed-in mblk_t and any other mblk_t's
167 * chained off of b_cont.
169 #define STR_FTEVENT_MSG(mp, p, e, d) { \
170 if (str_ftnever == 0) { \
171 mblk_t *_mp; \
172 fthdr_t *_hp; \
174 for (_mp = (mp); _mp != NULL; _mp = _mp->b_cont) { \
175 if ((_hp = DB_FTHDR(_mp)) != NULL) \
176 str_ftevent(_hp, (p), (e), (d)); \
182 * Add a flow-trace event to *just* the passed-in mblk_t.
184 #define STR_FTEVENT_MBLK(mp, p, e, d) { \
185 if (str_ftnever == 0) { \
186 fthdr_t *_hp; \
188 if ((mp) != NULL && ((_hp = DB_FTHDR(mp)) != NULL)) \
189 str_ftevent(_hp, (p), (e), (d)); \
193 #endif /* _KERNEL */
195 #ifdef __cplusplus
197 #endif
199 #endif /* _SYS_STRFT_H */