2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 #ifndef _LTTNG_UST_ABI_H
10 #define _LTTNG_UST_ABI_H
13 #include <lttng/ust-compiler.h>
16 #error "LTTNG_PACKED should be defined"
19 #ifndef __ust_stringify
20 #define __ust_stringify1(x) #x
21 #define __ust_stringify(x) __ust_stringify1(x)
22 #endif /* __ust_stringify */
24 #define LTTNG_UST_SYM_NAME_LEN 256
25 #define LTTNG_UST_ABI_PROCNAME_LEN 16
27 /* UST comm magic number, used to validate protocol and endianness. */
28 #define LTTNG_UST_COMM_MAGIC 0xC57C57C5
30 /* Version for ABI between liblttng-ust, sessiond, consumerd */
31 #define LTTNG_UST_ABI_MAJOR_VERSION 9
32 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
33 #define LTTNG_UST_ABI_MINOR_VERSION 0
35 enum lttng_ust_instrumentation
{
36 LTTNG_UST_TRACEPOINT
= 0,
38 LTTNG_UST_FUNCTION
= 2,
41 enum lttng_ust_loglevel_type
{
42 LTTNG_UST_LOGLEVEL_ALL
= 0,
43 LTTNG_UST_LOGLEVEL_RANGE
= 1,
44 LTTNG_UST_LOGLEVEL_SINGLE
= 2,
47 enum lttng_ust_output
{
51 enum lttng_ust_chan_type
{
52 LTTNG_UST_CHAN_PER_CPU
= 0,
53 LTTNG_UST_CHAN_METADATA
= 1,
56 struct lttng_ust_tracer_version
{
62 #define LTTNG_UST_CHANNEL_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
64 * Given that the consumerd is limited to 64k file descriptors, we
65 * cannot expect much more than 1MB channel structure size. This size is
66 * depends on the number of streams within a channel, which depends on
67 * the number of possible CPUs on the system.
69 #define LTTNG_UST_CHANNEL_DATA_MAX_LEN 1048576U
70 struct lttng_ust_channel
{
72 enum lttng_ust_chan_type type
;
73 char padding
[LTTNG_UST_CHANNEL_PADDING
];
74 char data
[]; /* variable sized data */
77 #define LTTNG_UST_STREAM_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
78 struct lttng_ust_stream
{
79 uint64_t len
; /* shm len */
80 uint32_t stream_nr
; /* stream number */
81 char padding
[LTTNG_UST_STREAM_PADDING1
];
83 * shm_fd and wakeup_fd are send over unix socket as file
84 * descriptors after this structure.
88 #define LTTNG_UST_EVENT_PADDING1 8
89 #define LTTNG_UST_EVENT_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
90 struct lttng_ust_event
{
91 enum lttng_ust_instrumentation instrumentation
;
92 char name
[LTTNG_UST_SYM_NAME_LEN
]; /* event name */
94 enum lttng_ust_loglevel_type loglevel_type
;
95 int loglevel
; /* value, -1: all */
96 uint64_t token
; /* User-provided token */
97 char padding
[LTTNG_UST_EVENT_PADDING1
];
99 /* Per instrumentation type configuration */
101 char padding
[LTTNG_UST_EVENT_PADDING2
];
105 #define LTTNG_UST_EVENT_NOTIFIER_PADDING 32
106 struct lttng_ust_event_notifier
{
107 struct lttng_ust_event event
;
108 uint64_t error_counter_index
;
110 char padding
[LTTNG_UST_EVENT_NOTIFIER_PADDING
];
113 #define LTTNG_UST_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
114 struct lttng_ust_event_notifier_notification
{
116 uint16_t capture_buf_size
;
117 char padding
[LTTNG_UST_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
120 enum lttng_ust_key_token_type
{
121 LTTNG_UST_KEY_TOKEN_STRING
= 0, /* arg: strtab_offset. */
122 LTTNG_UST_KEY_TOKEN_EVENT_NAME
= 1, /* no arg. */
123 LTTNG_UST_KEY_TOKEN_PROVIDER_NAME
= 2, /* no arg. */
126 #define LTTNG_UST_KEY_ARG_PADDING1 256
127 #define LTTNG_UST_KEY_TOKEN_STRING_LEN_MAX 256
128 struct lttng_ust_key_token
{
129 uint32_t type
; /* enum lttng_ust_key_token_type */
131 char string
[LTTNG_UST_KEY_TOKEN_STRING_LEN_MAX
];
132 char padding
[LTTNG_UST_KEY_ARG_PADDING1
];
136 #define LTTNG_UST_NR_KEY_TOKEN 4
137 struct lttng_ust_counter_key_dimension
{
138 uint32_t nr_key_tokens
;
139 struct lttng_ust_key_token key_tokens
[LTTNG_UST_NR_KEY_TOKEN
];
142 #define LTTNG_UST_COUNTER_DIMENSION_MAX 4
143 struct lttng_ust_counter_key
{
144 uint32_t nr_dimensions
;
145 struct lttng_ust_counter_key_dimension key_dimensions
[LTTNG_UST_COUNTER_DIMENSION_MAX
];
148 #define LTTNG_UST_COUNTER_EVENT_PADDING1 16
149 struct lttng_ust_counter_event
{
150 struct lttng_ust_event event
;
151 struct lttng_ust_counter_key key
;
152 char padding
[LTTNG_UST_COUNTER_EVENT_PADDING1
];
155 enum lttng_ust_counter_arithmetic
{
156 LTTNG_UST_COUNTER_ARITHMETIC_MODULAR
= 0,
157 LTTNG_UST_COUNTER_ARITHMETIC_SATURATION
= 1,
160 enum lttng_ust_counter_bitness
{
161 LTTNG_UST_COUNTER_BITNESS_32
= 0,
162 LTTNG_UST_COUNTER_BITNESS_64
= 1,
165 struct lttng_ust_counter_dimension
{
167 uint64_t underflow_index
;
168 uint64_t overflow_index
;
169 uint8_t has_underflow
;
170 uint8_t has_overflow
;
173 #define LTTNG_UST_COUNTER_CONF_PADDING1 67
174 struct lttng_ust_counter_conf
{
175 uint32_t arithmetic
; /* enum lttng_ust_counter_arithmetic */
176 uint32_t bitness
; /* enum lttng_ust_counter_bitness */
177 uint32_t number_dimensions
;
178 int64_t global_sum_step
;
179 struct lttng_ust_counter_dimension dimensions
[LTTNG_UST_COUNTER_DIMENSION_MAX
];
180 uint8_t coalesce_hits
;
181 char padding
[LTTNG_UST_COUNTER_CONF_PADDING1
];
184 struct lttng_ust_counter_value
{
185 uint32_t number_dimensions
;
186 uint64_t dimension_indexes
[LTTNG_UST_COUNTER_DIMENSION_MAX
];
190 #define LTTNG_UST_COUNTER_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
191 #define LTTNG_UST_COUNTER_DATA_MAX_LEN 4096U
192 struct lttng_ust_counter
{
194 char padding
[LTTNG_UST_COUNTER_PADDING1
];
195 char data
[]; /* variable sized data */
198 #define LTTNG_UST_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
199 struct lttng_ust_counter_global
{
200 uint64_t len
; /* shm len */
201 char padding
[LTTNG_UST_COUNTER_GLOBAL_PADDING1
];
204 #define LTTNG_UST_COUNTER_CPU_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
205 struct lttng_ust_counter_cpu
{
206 uint64_t len
; /* shm len */
208 char padding
[LTTNG_UST_COUNTER_CPU_PADDING1
];
211 enum lttng_ust_field_type
{
212 LTTNG_UST_FIELD_OTHER
= 0,
213 LTTNG_UST_FIELD_INTEGER
= 1,
214 LTTNG_UST_FIELD_ENUM
= 2,
215 LTTNG_UST_FIELD_FLOAT
= 3,
216 LTTNG_UST_FIELD_STRING
= 4,
219 #define LTTNG_UST_FIELD_ITER_PADDING (LTTNG_UST_SYM_NAME_LEN + 28)
220 struct lttng_ust_field_iter
{
221 char event_name
[LTTNG_UST_SYM_NAME_LEN
];
222 char field_name
[LTTNG_UST_SYM_NAME_LEN
];
223 enum lttng_ust_field_type type
;
224 int loglevel
; /* event loglevel */
226 char padding
[LTTNG_UST_FIELD_ITER_PADDING
];
229 enum lttng_ust_context_type
{
230 LTTNG_UST_CONTEXT_VTID
= 0,
231 LTTNG_UST_CONTEXT_VPID
= 1,
232 LTTNG_UST_CONTEXT_PTHREAD_ID
= 2,
233 LTTNG_UST_CONTEXT_PROCNAME
= 3,
234 LTTNG_UST_CONTEXT_IP
= 4,
235 LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER
= 5,
236 LTTNG_UST_CONTEXT_CPU_ID
= 6,
237 LTTNG_UST_CONTEXT_APP_CONTEXT
= 7,
238 LTTNG_UST_CONTEXT_CGROUP_NS
= 8,
239 LTTNG_UST_CONTEXT_IPC_NS
= 9,
240 LTTNG_UST_CONTEXT_MNT_NS
= 10,
241 LTTNG_UST_CONTEXT_NET_NS
= 11,
242 LTTNG_UST_CONTEXT_PID_NS
= 12,
243 LTTNG_UST_CONTEXT_USER_NS
= 13,
244 LTTNG_UST_CONTEXT_UTS_NS
= 14,
245 LTTNG_UST_CONTEXT_VUID
= 15,
246 LTTNG_UST_CONTEXT_VEUID
= 16,
247 LTTNG_UST_CONTEXT_VSUID
= 17,
248 LTTNG_UST_CONTEXT_VGID
= 18,
249 LTTNG_UST_CONTEXT_VEGID
= 19,
250 LTTNG_UST_CONTEXT_VSGID
= 20,
251 LTTNG_UST_CONTEXT_TIME_NS
= 21,
254 struct lttng_ust_perf_counter_ctx
{
257 char name
[LTTNG_UST_SYM_NAME_LEN
];
260 #define LTTNG_UST_CONTEXT_PADDING1 16
261 #define LTTNG_UST_CONTEXT_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
262 struct lttng_ust_context
{
263 enum lttng_ust_context_type ctx
;
264 char padding
[LTTNG_UST_CONTEXT_PADDING1
];
267 struct lttng_ust_perf_counter_ctx perf_counter
;
269 /* Includes trailing '\0'. */
270 uint32_t provider_name_len
;
271 uint32_t ctx_name_len
;
273 char padding
[LTTNG_UST_CONTEXT_PADDING2
];
278 * Tracer channel attributes.
280 #define LTTNG_UST_CHANNEL_ATTR_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
281 struct lttng_ust_channel_attr
{
282 uint64_t subbuf_size
; /* bytes */
283 uint64_t num_subbuf
; /* power of 2 */
284 int overwrite
; /* 1: overwrite, 0: discard */
285 unsigned int switch_timer_interval
; /* usec */
286 unsigned int read_timer_interval
; /* usec */
287 enum lttng_ust_output output
; /* splice, mmap */
290 int64_t blocking_timeout
; /* Blocking timeout (usec) */
292 char padding
[LTTNG_UST_CHANNEL_ATTR_PADDING
];
296 #define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
297 struct lttng_ust_tracepoint_iter
{
298 char name
[LTTNG_UST_SYM_NAME_LEN
]; /* provider:name */
300 char padding
[LTTNG_UST_TRACEPOINT_ITER_PADDING
];
303 enum lttng_ust_object_type
{
304 LTTNG_UST_OBJECT_TYPE_UNKNOWN
= -1,
305 LTTNG_UST_OBJECT_TYPE_CHANNEL
= 0,
306 LTTNG_UST_OBJECT_TYPE_STREAM
= 1,
307 LTTNG_UST_OBJECT_TYPE_EVENT
= 2,
308 LTTNG_UST_OBJECT_TYPE_CONTEXT
= 3,
309 LTTNG_UST_OBJECT_TYPE_EVENT_NOTIFIER_GROUP
= 4,
310 LTTNG_UST_OBJECT_TYPE_EVENT_NOTIFIER
= 5,
311 LTTNG_UST_OBJECT_TYPE_COUNTER
= 6,
312 LTTNG_UST_OBJECT_TYPE_COUNTER_GLOBAL
= 7,
313 LTTNG_UST_OBJECT_TYPE_COUNTER_CPU
= 8,
314 LTTNG_UST_OBJECT_TYPE_COUNTER_EVENT
= 9,
317 #define LTTNG_UST_OBJECT_DATA_PADDING1 32
318 #define LTTNG_UST_OBJECT_DATA_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
320 struct lttng_ust_object_data
{
321 enum lttng_ust_object_type type
;
324 char padding1
[LTTNG_UST_OBJECT_DATA_PADDING1
];
328 enum lttng_ust_chan_type type
;
346 char padding2
[LTTNG_UST_OBJECT_DATA_PADDING2
];
350 enum lttng_ust_calibrate_type
{
351 LTTNG_UST_CALIBRATE_TRACEPOINT
,
354 #define LTTNG_UST_CALIBRATE_PADDING1 16
355 #define LTTNG_UST_CALIBRATE_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
356 struct lttng_ust_calibrate
{
357 enum lttng_ust_calibrate_type type
; /* type (input) */
358 char padding
[LTTNG_UST_CALIBRATE_PADDING1
];
361 char padding
[LTTNG_UST_CALIBRATE_PADDING2
];
365 #define FILTER_BYTECODE_MAX_LEN 65536
366 #define LTTNG_UST_FILTER_PADDING 32
367 struct lttng_ust_filter_bytecode
{
369 uint32_t reloc_offset
;
371 char padding
[LTTNG_UST_FILTER_PADDING
];
375 #define CAPTURE_BYTECODE_MAX_LEN 65536
376 #define LTTNG_UST_CAPTURE_PADDING 32
377 struct lttng_ust_capture_bytecode
{
379 uint32_t reloc_offset
;
381 char padding
[LTTNG_UST_CAPTURE_PADDING
];
385 #define LTTNG_UST_EXCLUSION_PADDING 32
386 struct lttng_ust_event_exclusion
{
388 char padding
[LTTNG_UST_EXCLUSION_PADDING
];
389 char names
[LTTNG_UST_SYM_NAME_LEN
][0];
392 #define _UST_CMD(minor) (minor)
393 #define _UST_CMDR(minor, type) (minor)
394 #define _UST_CMDW(minor, type) (minor)
396 /* Handled by object descriptor */
397 #define LTTNG_UST_RELEASE _UST_CMD(0x1)
399 /* Handled by object cmd */
401 /* LTTng-UST commands */
402 #define LTTNG_UST_SESSION _UST_CMD(0x40)
403 #define LTTNG_UST_TRACER_VERSION \
404 _UST_CMDR(0x41, struct lttng_ust_tracer_version)
405 #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42)
406 #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43)
407 #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44)
408 #define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45)
409 #define LTTNG_UST_EVENT_NOTIFIER_GROUP_CREATE _UST_CMD(0x46)
411 /* Session commands */
412 #define LTTNG_UST_CHANNEL \
413 _UST_CMDW(0x51, struct lttng_ust_channel)
414 #define LTTNG_UST_SESSION_START _UST_CMD(0x52)
415 #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53)
416 #define LTTNG_UST_SESSION_STATEDUMP _UST_CMD(0x54)
418 /* Channel commands */
419 #define LTTNG_UST_STREAM _UST_CMD(0x60)
420 #define LTTNG_UST_EVENT \
421 _UST_CMDW(0x61, struct lttng_ust_event)
423 /* Event and channel commands */
424 #define LTTNG_UST_CONTEXT \
425 _UST_CMDW(0x70, struct lttng_ust_context)
426 #define LTTNG_UST_FLUSH_BUFFER \
429 /* Event, event notifier, channel and session commands */
430 #define LTTNG_UST_ENABLE _UST_CMD(0x80)
431 #define LTTNG_UST_DISABLE _UST_CMD(0x81)
433 /* Tracepoint list commands */
434 #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90)
435 #define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91)
437 /* Event and event notifier commands */
438 #define LTTNG_UST_FILTER _UST_CMD(0xA0)
439 #define LTTNG_UST_EXCLUSION _UST_CMD(0xA1)
441 /* Event notifier group commands */
442 #define LTTNG_UST_EVENT_NOTIFIER_CREATE \
443 _UST_CMDW(0xB0, struct lttng_ust_event_notifier)
445 /* Event notifier commands */
446 #define LTTNG_UST_CAPTURE _UST_CMD(0xB6)
448 /* Session and event notifier group commands */
449 #define LTTNG_UST_COUNTER \
450 _UST_CMDW(0xC0, struct lttng_ust_counter)
452 /* Counter commands */
453 #define LTTNG_UST_COUNTER_GLOBAL \
454 _UST_CMDW(0xD0, struct lttng_ust_counter_global)
455 #define LTTNG_UST_COUNTER_CPU \
456 _UST_CMDW(0xD1, struct lttng_ust_counter_cpu)
457 #define LTTNG_UST_COUNTER_EVENT \
458 _UST_CMDW(0xD2, struct lttng_ust_counter_event)
460 #define LTTNG_UST_ROOT_HANDLE 0
462 struct lttng_ust_obj
;
474 struct lttng_ust_field_iter entry
;
480 int event_notifier_notif_fd
;
481 } event_notifier_handle
;
490 struct lttng_ust_objd_ops
{
491 long (*cmd
)(int objd
, unsigned int cmd
, unsigned long arg
,
492 union ust_args
*args
, void *owner
);
493 int (*release
)(int objd
);
496 /* Create root handle. Always ID 0. */
497 int lttng_abi_create_root_handle(void);
499 const struct lttng_ust_objd_ops
*objd_ops(int id
);
500 int lttng_ust_objd_unref(int id
, int is_owner
);
502 void lttng_ust_abi_exit(void);
503 void lttng_ust_events_exit(void);
504 void lttng_ust_objd_table_owner_cleanup(void *owner
);
506 #endif /* _LTTNG_UST_ABI_H */