2 * Copyright 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * SPDX-License-Identifier: MIT
6 * Copied from LTTng-UST lttng/ust-abi.h
12 #ifndef LTTNG_UST_ABI_INTERNAL_H
13 #define LTTNG_UST_ABI_INTERNAL_H
15 #include <common/macros.hpp>
20 #error "LTTNG_PACKED should be defined"
23 #ifndef __ust_stringify
24 #define __ust_stringify1(x) #x
25 #define __ust_stringify(x) __ust_stringify1(x)
26 #endif /* __ust_stringify */
28 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
29 #define LTTNG_UST_ABI_PROCNAME_LEN 16
31 /* UST comm magic number, used to validate protocol and endianness. */
32 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
34 /* Version for ABI between liblttng-ust, sessiond, consumerd */
35 #define LTTNG_UST_ABI_MAJOR_VERSION 9
36 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
37 #define LTTNG_UST_ABI_MINOR_VERSION 0
39 enum lttng_ust_abi_instrumentation {
40 LTTNG_UST_ABI_TRACEPOINT = 0,
41 LTTNG_UST_ABI_PROBE = 1,
42 LTTNG_UST_ABI_FUNCTION = 2,
45 enum lttng_ust_abi_loglevel_type {
46 LTTNG_UST_ABI_LOGLEVEL_ALL = 0,
47 LTTNG_UST_ABI_LOGLEVEL_RANGE = 1,
48 LTTNG_UST_ABI_LOGLEVEL_SINGLE = 2,
51 enum lttng_ust_abi_output {
52 LTTNG_UST_ABI_MMAP = 0,
55 enum lttng_ust_abi_chan_type {
56 LTTNG_UST_ABI_CHAN_PER_CPU = 0,
57 LTTNG_UST_ABI_CHAN_METADATA = 1,
60 struct lttng_ust_abi_tracer_version {
66 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
68 * Given that the consumerd is limited to 64k file descriptors, we
69 * cannot expect much more than 1MB channel structure size. This size is
70 * depends on the number of streams within a channel, which depends on
71 * the number of possible CPUs on the system.
73 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
74 struct lttng_ust_abi_channel {
76 int32_t type; /* enum lttng_ust_abi_chan_type */
77 char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
78 char data[]; /* variable sized data */
81 #define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
82 struct lttng_ust_abi_stream {
83 uint64_t len; /* shm len */
84 uint32_t stream_nr; /* stream number */
85 char padding[LTTNG_UST_ABI_STREAM_PADDING1];
87 * shm_fd and wakeup_fd are send over unix socket as file
88 * descriptors after this structure.
92 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
94 enum lttng_ust_abi_counter_arithmetic {
95 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
96 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
99 enum lttng_ust_abi_counter_bitness {
100 LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
101 LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
104 struct lttng_ust_abi_counter_dimension {
106 uint64_t underflow_index;
107 uint64_t overflow_index;
108 uint8_t has_underflow;
109 uint8_t has_overflow;
112 #define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
113 struct lttng_ust_abi_counter_conf {
114 uint32_t arithmetic; /* enum lttng_ust_abi_counter_arithmetic */
115 uint32_t bitness; /* enum lttng_ust_abi_counter_bitness */
116 uint32_t number_dimensions;
117 int64_t global_sum_step;
118 struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
119 uint8_t coalesce_hits;
120 char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1];
123 struct lttng_ust_abi_counter_value {
124 uint32_t number_dimensions;
125 uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
129 #define LTTNG_UST_ABI_EVENT_PADDING1 8
130 #define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
131 struct lttng_ust_abi_event {
132 int32_t instrumentation; /* enum lttng_ust_abi_instrumentation */
133 char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* event name */
135 int32_t loglevel_type; /* enum lttng_ust_abi_loglevel_type */
136 int32_t loglevel; /* value, -1: all */
137 uint64_t token; /* User-provided token */
138 char padding[LTTNG_UST_ABI_EVENT_PADDING1];
140 /* Per instrumentation type configuration */
142 char padding[LTTNG_UST_ABI_EVENT_PADDING2];
146 #define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
147 struct lttng_ust_abi_event_notifier {
148 struct lttng_ust_abi_event event;
149 uint64_t error_counter_index;
150 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
153 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
154 struct lttng_ust_abi_event_notifier_notification {
156 uint16_t capture_buf_size;
157 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
160 #define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
161 #define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
162 struct lttng_ust_abi_counter {
164 char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
165 char data[]; /* variable sized data */
168 #define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
169 struct lttng_ust_abi_counter_global {
170 uint64_t len; /* shm len */
171 char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1];
174 #define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
175 struct lttng_ust_abi_counter_cpu {
176 uint64_t len; /* shm len */
178 char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
181 enum lttng_ust_abi_field_type {
182 LTTNG_UST_ABI_FIELD_OTHER = 0,
183 LTTNG_UST_ABI_FIELD_INTEGER = 1,
184 LTTNG_UST_ABI_FIELD_ENUM = 2,
185 LTTNG_UST_ABI_FIELD_FLOAT = 3,
186 LTTNG_UST_ABI_FIELD_STRING = 4,
189 #define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
190 struct lttng_ust_abi_field_iter {
191 char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
192 char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
193 int32_t type; /* enum lttng_ust_abi_field_type */
194 int loglevel; /* event loglevel */
196 char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
199 enum lttng_ust_abi_context_type {
200 LTTNG_UST_ABI_CONTEXT_VTID = 0,
201 LTTNG_UST_ABI_CONTEXT_VPID = 1,
202 LTTNG_UST_ABI_CONTEXT_PTHREAD_ID = 2,
203 LTTNG_UST_ABI_CONTEXT_PROCNAME = 3,
204 LTTNG_UST_ABI_CONTEXT_IP = 4,
205 LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER = 5,
206 LTTNG_UST_ABI_CONTEXT_CPU_ID = 6,
207 LTTNG_UST_ABI_CONTEXT_APP_CONTEXT = 7,
208 LTTNG_UST_ABI_CONTEXT_CGROUP_NS = 8,
209 LTTNG_UST_ABI_CONTEXT_IPC_NS = 9,
210 LTTNG_UST_ABI_CONTEXT_MNT_NS = 10,
211 LTTNG_UST_ABI_CONTEXT_NET_NS = 11,
212 LTTNG_UST_ABI_CONTEXT_PID_NS = 12,
213 LTTNG_UST_ABI_CONTEXT_USER_NS = 13,
214 LTTNG_UST_ABI_CONTEXT_UTS_NS = 14,
215 LTTNG_UST_ABI_CONTEXT_VUID = 15,
216 LTTNG_UST_ABI_CONTEXT_VEUID = 16,
217 LTTNG_UST_ABI_CONTEXT_VSUID = 17,
218 LTTNG_UST_ABI_CONTEXT_VGID = 18,
219 LTTNG_UST_ABI_CONTEXT_VEGID = 19,
220 LTTNG_UST_ABI_CONTEXT_VSGID = 20,
221 LTTNG_UST_ABI_CONTEXT_TIME_NS = 21,
224 struct lttng_ust_abi_perf_counter_ctx {
227 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
230 #define LTTNG_UST_ABI_CONTEXT_PADDING1 16
231 #define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
232 struct lttng_ust_abi_context {
233 int32_t ctx; /* enum lttng_ust_abi_context_type */
234 char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
237 struct lttng_ust_abi_perf_counter_ctx perf_counter;
239 /* Includes trailing '\0'. */
240 uint32_t provider_name_len;
241 uint32_t ctx_name_len;
243 char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
248 * Tracer channel attributes.
250 #define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
251 struct lttng_ust_abi_channel_attr {
252 uint64_t subbuf_size; /* bytes */
253 uint64_t num_subbuf; /* power of 2 */
254 int overwrite; /* 1: overwrite, 0: discard */
255 unsigned int switch_timer_interval; /* usec */
256 unsigned int read_timer_interval; /* usec */
257 int32_t output; /* enum lttng_ust_abi_output */
260 int64_t blocking_timeout; /* Blocking timeout (usec) */
262 char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
266 #define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
267 struct lttng_ust_abi_tracepoint_iter {
268 char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* provider:name */
270 char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
273 enum lttng_ust_abi_object_type {
274 LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
275 LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
276 LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
277 LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
278 LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
279 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
280 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
281 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
282 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
283 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
286 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
287 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
289 struct lttng_ust_abi_object_data {
290 int32_t type; /* enum lttng_ust_abi_object_type */
293 char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
297 int32_t type; /* enum lttng_ust_abi_chan_type */
315 char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
319 enum lttng_ust_abi_calibrate_type {
320 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
323 #define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
324 #define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
325 struct lttng_ust_abi_calibrate {
326 enum lttng_ust_abi_calibrate_type type; /* type (input) */
327 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
330 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
334 #define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
335 #define LTTNG_UST_ABI_FILTER_PADDING 32
336 struct lttng_ust_abi_filter_bytecode {
338 uint32_t reloc_offset;
340 char padding[LTTNG_UST_ABI_FILTER_PADDING];
344 #define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
345 #define LTTNG_UST_ABI_CAPTURE_PADDING 32
346 struct lttng_ust_abi_capture_bytecode {
348 uint32_t reloc_offset;
350 char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
354 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
355 struct lttng_ust_abi_event_exclusion {
357 char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
358 char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
361 #define LTTNG_UST_ABI_CMD(minor) (minor)
362 #define LTTNG_UST_ABI_CMDR(minor, type) (minor)
363 #define LTTNG_UST_ABI_CMDW(minor, type) (minor)
365 /* Handled by object descriptor */
366 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
368 /* Handled by object cmd */
370 /* LTTng-UST commands */
371 #define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
372 #define LTTNG_UST_ABI_TRACER_VERSION LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
373 #define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
374 #define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
375 #define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
376 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
377 #define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE LTTNG_UST_ABI_CMD(0x46)
379 /* Session commands */
380 #define LTTNG_UST_ABI_CHANNEL LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
381 #define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
382 #define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
383 #define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
385 /* Channel commands */
386 #define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
387 #define LTTNG_UST_ABI_EVENT LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
389 /* Event and channel commands */
390 #define LTTNG_UST_ABI_CONTEXT LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
391 #define LTTNG_UST_ABI_FLUSH_BUFFER LTTNG_UST_ABI_CMD(0x71)
393 /* Event, event notifier, channel and session commands */
394 #define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
395 #define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
397 /* Tracepoint list commands */
398 #define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
399 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
401 /* Event and event notifier commands */
402 #define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
403 #define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
405 /* Event notifier group commands */
406 #define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
407 LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
409 /* Event notifier commands */
410 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
412 /* Session and event notifier group commands */
413 #define LTTNG_UST_ABI_COUNTER LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
415 /* Counter commands */
416 #define LTTNG_UST_ABI_COUNTER_GLOBAL LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
417 #define LTTNG_UST_ABI_COUNTER_CPU LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
419 #define LTTNG_UST_ABI_ROOT_HANDLE 0
421 #endif /* LTTNG_UST_ABI_INTERNAL_H */