xref: /titanic_44/usr/src/uts/common/tnf/tnf_trace.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  *	Copyright (c) 1994, by Sun Microsytems, Inc.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #ifndef _TNF_TRACE_H
27*7c478bd9Sstevel@tonic-gate #define	_TNF_TRACE_H
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/time.h>
33*7c478bd9Sstevel@tonic-gate #include <sys/tnf_probe.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/thread.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/processor.h>
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #include "tnf_buf.h"
38*7c478bd9Sstevel@tonic-gate #include "tnf_types.h"
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate  * Minimum and default size of trace file
42*7c478bd9Sstevel@tonic-gate  */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #define	TNF_TRACE_FILE_MIN	(128 * 1024)
45*7c478bd9Sstevel@tonic-gate #define	TNF_TRACE_FILE_DEFAULT	(1 * 1024 * 1024)
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * Specification of index field of probe control block
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_TYPE_MASK	0x3
52*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_MEM_PTR	0x0	/* index is a normal memory ptr */
53*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_FILE_PTR	0x1	/* index is a file abs ptr */
54*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_LOW_MASK	0xffff0000
55*7c478bd9Sstevel@tonic-gate #define	PROBE_INDEX_SHIFT	16
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define	PROBE_IS_FILE_PTR(x)	\
58*7c478bd9Sstevel@tonic-gate 	(((x) & PROBE_INDEX_TYPE_MASK) == PROBE_INDEX_FILE_PTR)
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate #define	ATTR_SEPARATOR		';'
61*7c478bd9Sstevel@tonic-gate #define	VAL_SEPARATOR		' '
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * Flags in proc struct
65*7c478bd9Sstevel@tonic-gate  */
66*7c478bd9Sstevel@tonic-gate #define	PROC_F_FILTER	0x1
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	PROC_IS_FILTER(pp)	((pp)->p_tnf_flags & PROC_F_FILTER)
69*7c478bd9Sstevel@tonic-gate #define	PROC_FILTER_SET(pp)	((pp)->p_tnf_flags |= PROC_F_FILTER)
70*7c478bd9Sstevel@tonic-gate #define	PROC_FILTER_CLR(pp)	((pp)->p_tnf_flags &= ~PROC_F_FILTER)
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate  * In-memory scheduling info, maintained per thread
74*7c478bd9Sstevel@tonic-gate  */
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate typedef struct {
77*7c478bd9Sstevel@tonic-gate 	tnf_record_p		record_p;
78*7c478bd9Sstevel@tonic-gate 	tnf_uint32_t		record_gen;
79*7c478bd9Sstevel@tonic-gate 	hrtime_t		time_base;
80*7c478bd9Sstevel@tonic-gate 	processorid_t		cpuid;
81*7c478bd9Sstevel@tonic-gate } tnf_schedule_t;
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /*
84*7c478bd9Sstevel@tonic-gate  * Per-thread tracing operations and state
85*7c478bd9Sstevel@tonic-gate  */
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate struct _tnf_ops {
88*7c478bd9Sstevel@tonic-gate 	char		mode;		/* allocation mode */
89*7c478bd9Sstevel@tonic-gate 	tnf_byte_lock_t	busy;		/* currently in a probe */
90*7c478bd9Sstevel@tonic-gate 	TNFW_B_WCB	wcb;		/* write control info */
91*7c478bd9Sstevel@tonic-gate 	tnf_schedule_t	schedule;	/* scheduling info */
92*7c478bd9Sstevel@tonic-gate };
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*
95*7c478bd9Sstevel@tonic-gate  * File layout of a kernel schedule record
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate typedef struct {
99*7c478bd9Sstevel@tonic-gate 	tnf_tag_t		tag;
100*7c478bd9Sstevel@tonic-gate 	tnf_kthread_id_t	tid;
101*7c478bd9Sstevel@tonic-gate 	tnf_lwpid_t		lwpid;
102*7c478bd9Sstevel@tonic-gate 	tnf_pid_t		pid;
103*7c478bd9Sstevel@tonic-gate 	/*
104*7c478bd9Sstevel@tonic-gate 	 * time base should be on a double word boundary to avoid pads
105*7c478bd9Sstevel@tonic-gate 	 */
106*7c478bd9Sstevel@tonic-gate 	tnf_time_base_t		time_base;
107*7c478bd9Sstevel@tonic-gate 	tnf_cpuid_t		cpuid;
108*7c478bd9Sstevel@tonic-gate } tnf_schedule_prototype_t;
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * File layout of a probe (event tag) record
112*7c478bd9Sstevel@tonic-gate  */
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate typedef struct {
115*7c478bd9Sstevel@tonic-gate 	tnf_tag_t		tag;
116*7c478bd9Sstevel@tonic-gate 	tnf_name_t		name;
117*7c478bd9Sstevel@tonic-gate 	tnf_properties_t	properties;
118*7c478bd9Sstevel@tonic-gate 	tnf_slot_types_t	slot_types;
119*7c478bd9Sstevel@tonic-gate 	tnf_type_size_t		type_size;
120*7c478bd9Sstevel@tonic-gate 	tnf_slot_names_t	slot_names;
121*7c478bd9Sstevel@tonic-gate 	tnf_string_t		string;	/* XXX detail */
122*7c478bd9Sstevel@tonic-gate } tnf_probe_prototype_t;
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate /*
125*7c478bd9Sstevel@tonic-gate  * Tag data variables
126*7c478bd9Sstevel@tonic-gate  */
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_probe_type_tag_data;
129*7c478bd9Sstevel@tonic-gate extern tnf_tag_data_t	*tnf_kernel_schedule_tag_data;
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /*
132*7c478bd9Sstevel@tonic-gate  *
133*7c478bd9Sstevel@tonic-gate  */
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate extern size_t tnf_trace_file_size;
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate /*
138*7c478bd9Sstevel@tonic-gate  * Function prototypes
139*7c478bd9Sstevel@tonic-gate  */
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /* Encoder functions */
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate tnf_record_p tnf_kernel_schedule(tnf_ops_t *, tnf_schedule_t *);
144*7c478bd9Sstevel@tonic-gate uintptr_t tnf_probe_tag(tnf_ops_t *, tnf_probe_control_t *);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate /* Trace functions */
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate void *tnf_trace_alloc(tnf_ops_t *, tnf_probe_control_t *, tnf_probe_setup_t *);
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate void tnf_trace_commit(tnf_probe_setup_t *);
151*7c478bd9Sstevel@tonic-gate void tnf_trace_rollback(tnf_probe_setup_t *);
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate /* Trace control functions */
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate void tnf_trace_init(void);
156*7c478bd9Sstevel@tonic-gate void tnf_trace_on(void);
157*7c478bd9Sstevel@tonic-gate void tnf_trace_off(void);
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #endif /* _TNF_TRACE_H */
160