Commit | Line | Data |
---|---|---|
9f3fdbc6 MD |
1 | #ifndef _LTTNG_UST_ABI_H |
2 | #define _LTTNG_UST_ABI_H | |
3 | ||
4 | /* | |
4318ae1b | 5 | * lttng/ust-abi.h |
9f3fdbc6 MD |
6 | * |
7 | * Copyright 2010-2011 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8 | * | |
9 | * LTTng-UST ABI header | |
10 | * | |
a60d70e6 MD |
11 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
12 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
13 | * | |
14 | * Permission is hereby granted to use or copy this program | |
15 | * for any purpose, provided the above notices are retained on all copies. | |
16 | * Permission to modify the code and to distribute modified code is granted, | |
17 | * provided the above notices are retained, and a notice that the code was | |
18 | * modified is included with the above copyright notice. | |
9f3fdbc6 MD |
19 | */ |
20 | ||
0a42beb6 MD |
21 | #include <stdint.h> |
22 | ||
f56cd1d5 | 23 | #define LTTNG_UST_SYM_NAME_LEN 256 |
9f3fdbc6 | 24 | |
1332bb04 MD |
25 | #define LTTNG_UST_COMM_VERSION_MAJOR 2 |
26 | #define LTTNG_UST_COMM_VERSION_MINOR 0 | |
b35d179d | 27 | |
9f3fdbc6 | 28 | enum lttng_ust_instrumentation { |
df854e41 MD |
29 | LTTNG_UST_TRACEPOINT = 0, |
30 | LTTNG_UST_PROBE = 1, | |
31 | LTTNG_UST_FUNCTION = 2, | |
6b0e60f1 MD |
32 | }; |
33 | ||
34 | enum lttng_ust_loglevel_type { | |
882a56d7 MD |
35 | LTTNG_UST_LOGLEVEL_ALL = 0, |
36 | LTTNG_UST_LOGLEVEL_RANGE = 1, | |
37 | LTTNG_UST_LOGLEVEL_SINGLE = 2, | |
9f3fdbc6 MD |
38 | }; |
39 | ||
9f3fdbc6 | 40 | enum lttng_ust_output { |
b35d179d | 41 | LTTNG_UST_MMAP = 0, |
9f3fdbc6 MD |
42 | }; |
43 | ||
b35d179d | 44 | struct lttng_ust_tracer_version { |
b728d87e MD |
45 | uint32_t major; |
46 | uint32_t minor; | |
b35d179d | 47 | uint32_t patchlevel; |
b35d179d | 48 | }; |
9f3fdbc6 | 49 | |
1332bb04 | 50 | #define LTTNG_UST_CHANNEL_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
9f3fdbc6 MD |
51 | struct lttng_ust_channel { |
52 | int overwrite; /* 1: overwrite, 0: discard */ | |
53 | uint64_t subbuf_size; /* in bytes */ | |
54 | uint64_t num_subbuf; | |
55 | unsigned int switch_timer_interval; /* usecs */ | |
56 | unsigned int read_timer_interval; /* usecs */ | |
b35d179d | 57 | enum lttng_ust_output output; /* output mode */ |
1332bb04 | 58 | char padding[LTTNG_UST_CHANNEL_PADDING]; |
9f3fdbc6 MD |
59 | }; |
60 | ||
1332bb04 MD |
61 | #define LTTNG_UST_STREAM_PADDING1 16 |
62 | #define LTTNG_UST_STREAM_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
381c0f1e | 63 | struct lttng_ust_stream { |
1332bb04 MD |
64 | char padding[LTTNG_UST_STREAM_PADDING1]; |
65 | ||
66 | union { | |
67 | char padding[LTTNG_UST_STREAM_PADDING2]; | |
68 | } u; | |
381c0f1e MD |
69 | }; |
70 | ||
1332bb04 MD |
71 | #define LTTNG_UST_EVENT_PADDING1 16 |
72 | #define LTTNG_UST_EVENT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
9f3fdbc6 | 73 | struct lttng_ust_event { |
9f3fdbc6 | 74 | enum lttng_ust_instrumentation instrumentation; |
6b0e60f1 MD |
75 | char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ |
76 | ||
77 | enum lttng_ust_loglevel_type loglevel_type; | |
882a56d7 | 78 | int loglevel; /* value, -1: all */ |
1332bb04 | 79 | char padding[LTTNG_UST_EVENT_PADDING1]; |
6b0e60f1 | 80 | |
9f3fdbc6 MD |
81 | /* Per instrumentation type configuration */ |
82 | union { | |
1332bb04 | 83 | char padding[LTTNG_UST_EVENT_PADDING2]; |
9f3fdbc6 MD |
84 | } u; |
85 | }; | |
86 | ||
9f3fdbc6 | 87 | enum lttng_ust_context_type { |
3b402b40 | 88 | LTTNG_UST_CONTEXT_VTID = 0, |
c1ef86f0 MD |
89 | LTTNG_UST_CONTEXT_VPID = 1, |
90 | LTTNG_UST_CONTEXT_PTHREAD_ID = 2, | |
4847e9bb | 91 | LTTNG_UST_CONTEXT_PROCNAME = 3, |
9f3fdbc6 MD |
92 | }; |
93 | ||
1332bb04 MD |
94 | #define LTTNG_UST_CONTEXT_PADDING1 16 |
95 | #define LTTNG_UST_CONTEXT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
9f3fdbc6 MD |
96 | struct lttng_ust_context { |
97 | enum lttng_ust_context_type ctx; | |
1332bb04 MD |
98 | char padding[LTTNG_UST_CONTEXT_PADDING1]; |
99 | ||
9f3fdbc6 | 100 | union { |
1332bb04 | 101 | char padding[LTTNG_UST_CONTEXT_PADDING2]; |
9f3fdbc6 MD |
102 | } u; |
103 | }; | |
104 | ||
92462b01 MD |
105 | /* |
106 | * Tracer channel attributes. | |
107 | */ | |
1332bb04 | 108 | #define LTTNG_UST_CHANNEL_ATTR_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
92462b01 MD |
109 | struct lttng_ust_channel_attr { |
110 | int overwrite; /* 1: overwrite, 0: discard */ | |
111 | uint64_t subbuf_size; /* bytes */ | |
112 | uint64_t num_subbuf; /* power of 2 */ | |
113 | unsigned int switch_timer_interval; /* usec */ | |
114 | unsigned int read_timer_interval; /* usec */ | |
115 | enum lttng_ust_output output; /* splice, mmap */ | |
1332bb04 | 116 | char padding[LTTNG_UST_CHANNEL_ATTR_PADDING]; |
92462b01 MD |
117 | }; |
118 | ||
1332bb04 | 119 | #define LTTNG_UST_TRACEPOINT_ITER_PADDING 16 |
cbef6901 MD |
120 | struct lttng_ust_tracepoint_iter { |
121 | char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */ | |
882a56d7 | 122 | int loglevel; |
1332bb04 | 123 | char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING]; |
cbef6901 MD |
124 | }; |
125 | ||
1332bb04 | 126 | #define LTTNG_UST_OBJECT_DATA_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
92462b01 MD |
127 | struct lttng_ust_object_data { |
128 | int handle; | |
129 | int shm_fd; | |
130 | int wait_fd; | |
131 | uint64_t memory_map_size; | |
1332bb04 | 132 | char padding[LTTNG_UST_OBJECT_DATA_PADDING]; |
92462b01 MD |
133 | }; |
134 | ||
d9a9a33b MD |
135 | enum lttng_ust_calibrate_type { |
136 | LTTNG_UST_CALIBRATE_TRACEPOINT, | |
137 | }; | |
138 | ||
1332bb04 MD |
139 | #define LTTNG_UST_CALIBRATE_PADDING1 16 |
140 | #define LTTNG_UST_CALIBRATE_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
d9a9a33b MD |
141 | struct lttng_ust_calibrate { |
142 | enum lttng_ust_calibrate_type type; /* type (input) */ | |
1332bb04 MD |
143 | char padding[LTTNG_UST_CALIBRATE_PADDING1]; |
144 | ||
145 | union { | |
146 | char padding[LTTNG_UST_CALIBRATE_PADDING2]; | |
147 | } u; | |
d9a9a33b MD |
148 | }; |
149 | ||
9f3fdbc6 MD |
150 | #define _UST_CMD(minor) (minor) |
151 | #define _UST_CMDR(minor, type) (minor) | |
152 | #define _UST_CMDW(minor, type) (minor) | |
153 | ||
46050b1a MD |
154 | /* Handled by object descriptor */ |
155 | #define LTTNG_UST_RELEASE _UST_CMD(0x1) | |
156 | ||
157 | /* Handled by object cmd */ | |
158 | ||
9f3fdbc6 MD |
159 | /* LTTng-UST commands */ |
160 | #define LTTNG_UST_SESSION _UST_CMD(0x40) | |
161 | #define LTTNG_UST_TRACER_VERSION \ | |
162 | _UST_CMDR(0x41, struct lttng_ust_tracer_version) | |
163 | #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42) | |
164 | #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43) | |
11ff9c7d | 165 | #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44) |
9f3fdbc6 | 166 | |
46050b1a | 167 | /* Session FD commands */ |
9f3fdbc6 MD |
168 | #define LTTNG_UST_METADATA \ |
169 | _UST_CMDW(0x50, struct lttng_ust_channel) | |
170 | #define LTTNG_UST_CHANNEL \ | |
171 | _UST_CMDW(0x51, struct lttng_ust_channel) | |
172 | #define LTTNG_UST_SESSION_START _UST_CMD(0x52) | |
173 | #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53) | |
174 | ||
46050b1a | 175 | /* Channel FD commands */ |
9f3fdbc6 MD |
176 | #define LTTNG_UST_STREAM _UST_CMD(0x60) |
177 | #define LTTNG_UST_EVENT \ | |
178 | _UST_CMDW(0x61, struct lttng_ust_event) | |
179 | ||
46050b1a | 180 | /* Event and Channel FD commands */ |
9f3fdbc6 MD |
181 | #define LTTNG_UST_CONTEXT \ |
182 | _UST_CMDW(0x70, struct lttng_ust_context) | |
43d330a4 | 183 | #define LTTNG_UST_FLUSH_BUFFER \ |
43861eab | 184 | _UST_CMD(0x71) |
9f3fdbc6 | 185 | |
46050b1a | 186 | /* Event, Channel and Session commands */ |
9f3fdbc6 MD |
187 | #define LTTNG_UST_ENABLE _UST_CMD(0x80) |
188 | #define LTTNG_UST_DISABLE _UST_CMD(0x81) | |
189 | ||
51489cad MD |
190 | /* Tracepoint list commands */ |
191 | #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90) | |
192 | ||
46050b1a MD |
193 | #define LTTNG_UST_ROOT_HANDLE 0 |
194 | ||
b61ce3b2 | 195 | struct lttng_ust_obj; |
46050b1a | 196 | |
ef9ff354 MD |
197 | union ust_args { |
198 | struct { | |
199 | int *shm_fd; | |
200 | int *wait_fd; | |
201 | uint64_t *memory_map_size; | |
202 | } channel; | |
203 | struct { | |
204 | int *shm_fd; | |
205 | int *wait_fd; | |
206 | uint64_t *memory_map_size; | |
207 | } stream; | |
208 | }; | |
209 | ||
b61ce3b2 | 210 | struct lttng_ust_objd_ops { |
ef9ff354 MD |
211 | long (*cmd)(int objd, unsigned int cmd, unsigned long arg, |
212 | union ust_args *args); | |
46050b1a MD |
213 | int (*release)(int objd); |
214 | }; | |
215 | ||
216 | /* Create root handle. Always ID 0. */ | |
217 | int lttng_abi_create_root_handle(void); | |
218 | ||
b61ce3b2 | 219 | const struct lttng_ust_objd_ops *objd_ops(int id); |
d4419b81 | 220 | int lttng_ust_objd_unref(int id); |
46050b1a MD |
221 | |
222 | void lttng_ust_abi_exit(void); | |
003fedf4 | 223 | void lttng_ust_events_exit(void); |
b35d179d | 224 | |
9f3fdbc6 | 225 | #endif /* _LTTNG_UST_ABI_H */ |