Cleanup: use tabs in ust-abi.h
[deliverable/lttng-ust.git] / include / lttng / ust-abi.h
... / ...
CommitLineData
1#ifndef _LTTNG_UST_ABI_H
2#define _LTTNG_UST_ABI_H
3
4/*
5 * lttng/ust-abi.h
6 *
7 * LTTng-UST ABI header
8 *
9 * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 */
29
30#include <stdint.h>
31#include <lttng/ust-compiler.h>
32
33#ifndef LTTNG_PACKED
34#error "LTTNG_PACKED should be defined"
35#endif
36
37#ifndef __ust_stringify
38#define __ust_stringify1(x) #x
39#define __ust_stringify(x) __ust_stringify1(x)
40#endif /* __ust_stringify */
41
42#define LTTNG_UST_SYM_NAME_LEN 256
43#define LTTNG_UST_ABI_PROCNAME_LEN 16
44
45/* UST comm magic number, used to validate protocol and endianness. */
46#define LTTNG_UST_COMM_MAGIC 0xC57C57C5
47
48/* Version for ABI between liblttng-ust, sessiond, consumerd */
49#define LTTNG_UST_ABI_MAJOR_VERSION 9
50#define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
51#define LTTNG_UST_ABI_MINOR_VERSION 0
52
53enum lttng_ust_instrumentation {
54 LTTNG_UST_TRACEPOINT = 0,
55 LTTNG_UST_PROBE = 1,
56 LTTNG_UST_FUNCTION = 2,
57};
58
59enum lttng_ust_loglevel_type {
60 LTTNG_UST_LOGLEVEL_ALL = 0,
61 LTTNG_UST_LOGLEVEL_RANGE = 1,
62 LTTNG_UST_LOGLEVEL_SINGLE = 2,
63};
64
65enum lttng_ust_output {
66 LTTNG_UST_MMAP = 0,
67};
68
69enum lttng_ust_chan_type {
70 LTTNG_UST_CHAN_PER_CPU = 0,
71 LTTNG_UST_CHAN_METADATA = 1,
72};
73
74struct lttng_ust_tracer_version {
75 uint32_t major;
76 uint32_t minor;
77 uint32_t patchlevel;
78} LTTNG_PACKED;
79
80#define LTTNG_UST_CHANNEL_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
81/*
82 * Given that the consumerd is limited to 64k file descriptors, we
83 * cannot expect much more than 1MB channel structure size. This size is
84 * depends on the number of streams within a channel, which depends on
85 * the number of possible CPUs on the system.
86 */
87#define LTTNG_UST_CHANNEL_DATA_MAX_LEN 1048576U
88struct lttng_ust_channel {
89 uint64_t len;
90 enum lttng_ust_chan_type type;
91 char padding[LTTNG_UST_CHANNEL_PADDING];
92 char data[]; /* variable sized data */
93} LTTNG_PACKED;
94
95#define LTTNG_UST_STREAM_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
96struct lttng_ust_stream {
97 uint64_t len; /* shm len */
98 uint32_t stream_nr; /* stream number */
99 char padding[LTTNG_UST_STREAM_PADDING1];
100 /*
101 * shm_fd and wakeup_fd are send over unix socket as file
102 * descriptors after this structure.
103 */
104} LTTNG_PACKED;
105
106
107enum lttng_ust_counter_arithmetic {
108 LTTNG_UST_COUNTER_ARITHMETIC_MODULAR = 0,
109 LTTNG_UST_COUNTER_ARITHMETIC_SATURATION = 1,
110};
111
112enum lttng_ust_counter_bitness {
113 LTTNG_UST_COUNTER_BITNESS_32BITS = 4,
114 LTTNG_UST_COUNTER_BITNESS_64BITS = 8,
115};
116
117struct lttng_ust_counter_dimension {
118 uint64_t size;
119 uint64_t underflow_index;
120 uint64_t overflow_index;
121 uint8_t has_underflow;
122 uint8_t has_overflow;
123} LTTNG_PACKED;
124
125#define LTTNG_UST_COUNTER_DIMENSION_MAX 8
126struct lttng_ust_counter_conf {
127 uint32_t arithmetic; /* enum lttng_ust_counter_arithmetic */
128 uint32_t bitness; /* enum lttng_ust_counter_bitness */
129 uint32_t number_dimensions;
130 int64_t global_sum_step;
131 struct lttng_ust_counter_dimension dimensions[LTTNG_UST_COUNTER_DIMENSION_MAX];
132} LTTNG_PACKED;
133
134struct lttng_ust_counter_value {
135 uint32_t number_dimensions;
136 uint64_t dimension_indexes[LTTNG_UST_COUNTER_DIMENSION_MAX];
137 int64_t value;
138} LTTNG_PACKED;
139
140#define LTTNG_UST_EVENT_PADDING1 8
141#define LTTNG_UST_EVENT_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
142struct lttng_ust_event {
143 enum lttng_ust_instrumentation instrumentation;
144 char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */
145
146 enum lttng_ust_loglevel_type loglevel_type;
147 int loglevel; /* value, -1: all */
148 uint64_t token; /* User-provided token */
149 char padding[LTTNG_UST_EVENT_PADDING1];
150
151 /* Per instrumentation type configuration */
152 union {
153 char padding[LTTNG_UST_EVENT_PADDING2];
154 } u;
155} LTTNG_PACKED;
156
157#define LTTNG_UST_EVENT_NOTIFIER_PADDING 32
158struct lttng_ust_event_notifier {
159 struct lttng_ust_event event;
160 uint64_t error_counter_index;
161 char padding[LTTNG_UST_EVENT_NOTIFIER_PADDING];
162} LTTNG_PACKED;
163
164#define LTTNG_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
165struct lttng_ust_event_notifier_notification {
166 uint64_t token;
167 uint16_t capture_buf_size;
168 char padding[LTTNG_EVENT_NOTIFIER_NOTIFICATION_PADDING];
169} LTTNG_PACKED;
170
171#define LTTNG_UST_COUNTER_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
172#define LTTNG_UST_COUNTER_DATA_MAX_LEN 4096U
173struct lttng_ust_counter {
174 uint64_t len;
175 char padding[LTTNG_UST_COUNTER_PADDING1];
176 char data[]; /* variable sized data */
177} LTTNG_PACKED;
178
179#define LTTNG_UST_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
180struct lttng_ust_counter_global {
181 uint64_t len; /* shm len */
182 char padding[LTTNG_UST_COUNTER_GLOBAL_PADDING1];
183} LTTNG_PACKED;
184
185#define LTTNG_UST_COUNTER_CPU_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
186struct lttng_ust_counter_cpu {
187 uint64_t len; /* shm len */
188 uint32_t cpu_nr;
189 char padding[LTTNG_UST_COUNTER_CPU_PADDING1];
190} LTTNG_PACKED;
191
192enum lttng_ust_field_type {
193 LTTNG_UST_FIELD_OTHER = 0,
194 LTTNG_UST_FIELD_INTEGER = 1,
195 LTTNG_UST_FIELD_ENUM = 2,
196 LTTNG_UST_FIELD_FLOAT = 3,
197 LTTNG_UST_FIELD_STRING = 4,
198};
199
200#define LTTNG_UST_FIELD_ITER_PADDING (LTTNG_UST_SYM_NAME_LEN + 28)
201struct lttng_ust_field_iter {
202 char event_name[LTTNG_UST_SYM_NAME_LEN];
203 char field_name[LTTNG_UST_SYM_NAME_LEN];
204 enum lttng_ust_field_type type;
205 int loglevel; /* event loglevel */
206 int nowrite;
207 char padding[LTTNG_UST_FIELD_ITER_PADDING];
208} LTTNG_PACKED;
209
210enum lttng_ust_context_type {
211 LTTNG_UST_CONTEXT_VTID = 0,
212 LTTNG_UST_CONTEXT_VPID = 1,
213 LTTNG_UST_CONTEXT_PTHREAD_ID = 2,
214 LTTNG_UST_CONTEXT_PROCNAME = 3,
215 LTTNG_UST_CONTEXT_IP = 4,
216 LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER = 5,
217 LTTNG_UST_CONTEXT_CPU_ID = 6,
218 LTTNG_UST_CONTEXT_APP_CONTEXT = 7,
219 LTTNG_UST_CONTEXT_CGROUP_NS = 8,
220 LTTNG_UST_CONTEXT_IPC_NS = 9,
221 LTTNG_UST_CONTEXT_MNT_NS = 10,
222 LTTNG_UST_CONTEXT_NET_NS = 11,
223 LTTNG_UST_CONTEXT_PID_NS = 12,
224 LTTNG_UST_CONTEXT_USER_NS = 13,
225 LTTNG_UST_CONTEXT_UTS_NS = 14,
226 LTTNG_UST_CONTEXT_VUID = 15,
227 LTTNG_UST_CONTEXT_VEUID = 16,
228 LTTNG_UST_CONTEXT_VSUID = 17,
229 LTTNG_UST_CONTEXT_VGID = 18,
230 LTTNG_UST_CONTEXT_VEGID = 19,
231 LTTNG_UST_CONTEXT_VSGID = 20,
232 LTTNG_UST_CONTEXT_TIME_NS = 21,
233};
234
235struct lttng_ust_perf_counter_ctx {
236 uint32_t type;
237 uint64_t config;
238 char name[LTTNG_UST_SYM_NAME_LEN];
239} LTTNG_PACKED;
240
241#define LTTNG_UST_CONTEXT_PADDING1 16
242#define LTTNG_UST_CONTEXT_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
243struct lttng_ust_context {
244 enum lttng_ust_context_type ctx;
245 char padding[LTTNG_UST_CONTEXT_PADDING1];
246
247 union {
248 struct lttng_ust_perf_counter_ctx perf_counter;
249 struct {
250 /* Includes trailing '\0'. */
251 uint32_t provider_name_len;
252 uint32_t ctx_name_len;
253 } app_ctx;
254 char padding[LTTNG_UST_CONTEXT_PADDING2];
255 } u;
256} LTTNG_PACKED;
257
258/*
259 * Tracer channel attributes.
260 */
261#define LTTNG_UST_CHANNEL_ATTR_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
262struct lttng_ust_channel_attr {
263 uint64_t subbuf_size; /* bytes */
264 uint64_t num_subbuf; /* power of 2 */
265 int overwrite; /* 1: overwrite, 0: discard */
266 unsigned int switch_timer_interval; /* usec */
267 unsigned int read_timer_interval; /* usec */
268 enum lttng_ust_output output; /* splice, mmap */
269 union {
270 struct {
271 int64_t blocking_timeout; /* Blocking timeout (usec) */
272 } s;
273 char padding[LTTNG_UST_CHANNEL_ATTR_PADDING];
274 } u;
275} LTTNG_PACKED;
276
277#define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
278struct lttng_ust_tracepoint_iter {
279 char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */
280 int loglevel;
281 char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING];
282} LTTNG_PACKED;
283
284enum lttng_ust_object_type {
285 LTTNG_UST_OBJECT_TYPE_UNKNOWN = -1,
286 LTTNG_UST_OBJECT_TYPE_CHANNEL = 0,
287 LTTNG_UST_OBJECT_TYPE_STREAM = 1,
288 LTTNG_UST_OBJECT_TYPE_EVENT = 2,
289 LTTNG_UST_OBJECT_TYPE_CONTEXT = 3,
290 LTTNG_UST_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
291 LTTNG_UST_OBJECT_TYPE_EVENT_NOTIFIER = 5,
292 LTTNG_UST_OBJECT_TYPE_COUNTER = 6,
293 LTTNG_UST_OBJECT_TYPE_COUNTER_GLOBAL = 7,
294 LTTNG_UST_OBJECT_TYPE_COUNTER_CPU = 8,
295};
296
297#define LTTNG_UST_OBJECT_DATA_PADDING1 32
298#define LTTNG_UST_OBJECT_DATA_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
299
300struct lttng_ust_object_data {
301 enum lttng_ust_object_type type;
302 int handle;
303 uint64_t size;
304 char padding1[LTTNG_UST_OBJECT_DATA_PADDING1];
305 union {
306 struct {
307 void *data;
308 enum lttng_ust_chan_type type;
309 int wakeup_fd;
310 } channel;
311 struct {
312 int shm_fd;
313 int wakeup_fd;
314 uint32_t stream_nr;
315 } stream;
316 struct {
317 void *data;
318 } counter;
319 struct {
320 int shm_fd;
321 } counter_global;
322 struct {
323 int shm_fd;
324 uint32_t cpu_nr;
325 } counter_cpu;
326 char padding2[LTTNG_UST_OBJECT_DATA_PADDING2];
327 } u;
328} LTTNG_PACKED;
329
330enum lttng_ust_calibrate_type {
331 LTTNG_UST_CALIBRATE_TRACEPOINT,
332};
333
334#define LTTNG_UST_CALIBRATE_PADDING1 16
335#define LTTNG_UST_CALIBRATE_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
336struct lttng_ust_calibrate {
337 enum lttng_ust_calibrate_type type; /* type (input) */
338 char padding[LTTNG_UST_CALIBRATE_PADDING1];
339
340 union {
341 char padding[LTTNG_UST_CALIBRATE_PADDING2];
342 } u;
343} LTTNG_PACKED;
344
345#define FILTER_BYTECODE_MAX_LEN 65536
346#define LTTNG_UST_FILTER_PADDING 32
347struct lttng_ust_filter_bytecode {
348 uint32_t len;
349 uint32_t reloc_offset;
350 uint64_t seqnum;
351 char padding[LTTNG_UST_FILTER_PADDING];
352 char data[0];
353} LTTNG_PACKED;
354
355#define CAPTURE_BYTECODE_MAX_LEN 65536
356#define LTTNG_UST_CAPTURE_PADDING 32
357struct lttng_ust_capture_bytecode {
358 uint32_t len;
359 uint32_t reloc_offset;
360 uint64_t seqnum;
361 char padding[LTTNG_UST_CAPTURE_PADDING];
362 char data[0];
363} LTTNG_PACKED;
364
365#define LTTNG_UST_EXCLUSION_PADDING 32
366struct lttng_ust_event_exclusion {
367 uint32_t count;
368 char padding[LTTNG_UST_EXCLUSION_PADDING];
369 char names[LTTNG_UST_SYM_NAME_LEN][0];
370} LTTNG_PACKED;
371
372#define _UST_CMD(minor) (minor)
373#define _UST_CMDR(minor, type) (minor)
374#define _UST_CMDW(minor, type) (minor)
375
376/* Handled by object descriptor */
377#define LTTNG_UST_RELEASE _UST_CMD(0x1)
378
379/* Handled by object cmd */
380
381/* LTTng-UST commands */
382#define LTTNG_UST_SESSION _UST_CMD(0x40)
383#define LTTNG_UST_TRACER_VERSION \
384 _UST_CMDR(0x41, struct lttng_ust_tracer_version)
385#define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42)
386#define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43)
387#define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44)
388#define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45)
389#define LTTNG_UST_EVENT_NOTIFIER_GROUP_CREATE _UST_CMD(0x46)
390
391/* Session commands */
392#define LTTNG_UST_CHANNEL \
393 _UST_CMDW(0x51, struct lttng_ust_channel)
394#define LTTNG_UST_SESSION_START _UST_CMD(0x52)
395#define LTTNG_UST_SESSION_STOP _UST_CMD(0x53)
396#define LTTNG_UST_SESSION_STATEDUMP _UST_CMD(0x54)
397
398/* Channel commands */
399#define LTTNG_UST_STREAM _UST_CMD(0x60)
400#define LTTNG_UST_EVENT \
401 _UST_CMDW(0x61, struct lttng_ust_event)
402
403/* Event and channel commands */
404#define LTTNG_UST_CONTEXT \
405 _UST_CMDW(0x70, struct lttng_ust_context)
406#define LTTNG_UST_FLUSH_BUFFER \
407 _UST_CMD(0x71)
408
409/* Event, event notifier, channel and session commands */
410#define LTTNG_UST_ENABLE _UST_CMD(0x80)
411#define LTTNG_UST_DISABLE _UST_CMD(0x81)
412
413/* Tracepoint list commands */
414#define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90)
415#define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91)
416
417/* Event and event notifier commands */
418#define LTTNG_UST_FILTER _UST_CMD(0xA0)
419#define LTTNG_UST_EXCLUSION _UST_CMD(0xA1)
420
421/* Event notifier group commands */
422#define LTTNG_UST_EVENT_NOTIFIER_CREATE \
423 _UST_CMDW(0xB0, struct lttng_ust_event_notifier)
424
425/* Event notifier commands */
426#define LTTNG_UST_CAPTURE _UST_CMD(0xB6)
427
428/* Session and event notifier group commands */
429#define LTTNG_UST_COUNTER \
430 _UST_CMDW(0xC0, struct lttng_ust_counter)
431
432/* Counter commands */
433#define LTTNG_UST_COUNTER_GLOBAL \
434 _UST_CMDW(0xD0, struct lttng_ust_counter_global)
435#define LTTNG_UST_COUNTER_CPU \
436 _UST_CMDW(0xD1, struct lttng_ust_counter_cpu)
437
438#define LTTNG_UST_ROOT_HANDLE 0
439
440struct lttng_ust_obj;
441
442union ust_args {
443 struct {
444 void *chan_data;
445 int wakeup_fd;
446 } channel;
447 struct {
448 int shm_fd;
449 int wakeup_fd;
450 } stream;
451 struct {
452 struct lttng_ust_field_iter entry;
453 } field_list;
454 struct {
455 char *ctxname;
456 } app_context;
457 struct {
458 int event_notifier_notif_fd;
459 } event_notifier_handle;
460 struct {
461 void *counter_data;
462 } counter;
463 struct {
464 int shm_fd;
465 } counter_shm;
466};
467
468struct lttng_ust_objd_ops {
469 long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
470 union ust_args *args, void *owner);
471 int (*release)(int objd);
472};
473
474/* Create root handle. Always ID 0. */
475int lttng_abi_create_root_handle(void);
476
477const struct lttng_ust_objd_ops *objd_ops(int id);
478int lttng_ust_objd_unref(int id, int is_owner);
479
480void lttng_ust_abi_exit(void);
481void lttng_ust_events_exit(void);
482void lttng_ust_objd_table_owner_cleanup(void *owner);
483
484#endif /* _LTTNG_UST_ABI_H */
This page took 0.025347 seconds and 5 git commands to generate.