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
16 #include <common/macros.h>
19 #error "LTTNG_PACKED should be defined"
22 #ifndef __ust_stringify
23 #define __ust_stringify1(x) #x
24 #define __ust_stringify(x) __ust_stringify1(x)
25 #endif /* __ust_stringify */
27 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
28 #define LTTNG_UST_ABI_PROCNAME_LEN 16
30 /* UST comm magic number, used to validate protocol and endianness. */
31 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
33 /* Version for ABI between liblttng-ust, sessiond, consumerd */
34 #define LTTNG_UST_ABI_MAJOR_VERSION 9
35 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
36 #define LTTNG_UST_ABI_MINOR_VERSION 0
38 enum lttng_ust_abi_instrumentation
{
39 LTTNG_UST_ABI_TRACEPOINT
= 0,
40 LTTNG_UST_ABI_PROBE
= 1,
41 LTTNG_UST_ABI_FUNCTION
= 2,
44 enum lttng_ust_abi_loglevel_type
{
45 LTTNG_UST_ABI_LOGLEVEL_ALL
= 0,
46 LTTNG_UST_ABI_LOGLEVEL_RANGE
= 1,
47 LTTNG_UST_ABI_LOGLEVEL_SINGLE
= 2,
50 enum lttng_ust_abi_output
{
51 LTTNG_UST_ABI_MMAP
= 0,
54 enum lttng_ust_abi_chan_type
{
55 LTTNG_UST_ABI_CHAN_PER_CPU
= 0,
56 LTTNG_UST_ABI_CHAN_METADATA
= 1,
59 struct lttng_ust_abi_tracer_version
{
65 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
67 * Given that the consumerd is limited to 64k file descriptors, we
68 * cannot expect much more than 1MB channel structure size. This size is
69 * depends on the number of streams within a channel, which depends on
70 * the number of possible CPUs on the system.
72 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
73 struct lttng_ust_abi_channel
{
75 int32_t type
; /* enum lttng_ust_abi_chan_type */
76 char padding
[LTTNG_UST_ABI_CHANNEL_PADDING
];
77 char data
[]; /* variable sized data */
80 #define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
81 struct lttng_ust_abi_stream
{
82 uint64_t len
; /* shm len */
83 uint32_t stream_nr
; /* stream number */
84 char padding
[LTTNG_UST_ABI_STREAM_PADDING1
];
86 * shm_fd and wakeup_fd are send over unix socket as file
87 * descriptors after this structure.
91 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
93 enum lttng_ust_abi_counter_arithmetic
{
94 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR
= 0,
95 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION
= 1,
98 enum lttng_ust_abi_counter_bitness
{
99 LTTNG_UST_ABI_COUNTER_BITNESS_32
= 0,
100 LTTNG_UST_ABI_COUNTER_BITNESS_64
= 1,
103 struct lttng_ust_abi_counter_dimension
{
105 uint64_t underflow_index
;
106 uint64_t overflow_index
;
107 uint8_t has_underflow
;
108 uint8_t has_overflow
;
111 #define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
112 struct lttng_ust_abi_counter_conf
{
113 uint32_t arithmetic
; /* enum lttng_ust_abi_counter_arithmetic */
114 uint32_t bitness
; /* enum lttng_ust_abi_counter_bitness */
115 uint32_t number_dimensions
;
116 int64_t global_sum_step
;
117 struct lttng_ust_abi_counter_dimension dimensions
[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX
];
118 uint8_t coalesce_hits
;
119 char padding
[LTTNG_UST_ABI_COUNTER_CONF_PADDING1
];
122 struct lttng_ust_abi_counter_value
{
123 uint32_t number_dimensions
;
124 uint64_t dimension_indexes
[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX
];
128 #define LTTNG_UST_ABI_EVENT_PADDING1 8
129 #define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
130 struct lttng_ust_abi_event
{
131 int32_t instrumentation
; /* enum lttng_ust_abi_instrumentation */
132 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
]; /* event name */
134 int32_t loglevel_type
; /* enum lttng_ust_abi_loglevel_type */
135 int32_t loglevel
; /* value, -1: all */
136 uint64_t token
; /* User-provided token */
137 char padding
[LTTNG_UST_ABI_EVENT_PADDING1
];
139 /* Per instrumentation type configuration */
141 char padding
[LTTNG_UST_ABI_EVENT_PADDING2
];
145 #define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
146 struct lttng_ust_abi_event_notifier
{
147 struct lttng_ust_abi_event event
;
148 uint64_t error_counter_index
;
149 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING
];
152 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
153 struct lttng_ust_abi_event_notifier_notification
{
155 uint16_t capture_buf_size
;
156 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
159 #define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
160 #define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
161 struct lttng_ust_abi_counter
{
163 char padding
[LTTNG_UST_ABI_COUNTER_PADDING1
];
164 char data
[]; /* variable sized data */
167 #define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
168 struct lttng_ust_abi_counter_global
{
169 uint64_t len
; /* shm len */
170 char padding
[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1
];
173 #define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
174 struct lttng_ust_abi_counter_cpu
{
175 uint64_t len
; /* shm len */
177 char padding
[LTTNG_UST_ABI_COUNTER_CPU_PADDING1
];
180 enum lttng_ust_abi_field_type
{
181 LTTNG_UST_ABI_FIELD_OTHER
= 0,
182 LTTNG_UST_ABI_FIELD_INTEGER
= 1,
183 LTTNG_UST_ABI_FIELD_ENUM
= 2,
184 LTTNG_UST_ABI_FIELD_FLOAT
= 3,
185 LTTNG_UST_ABI_FIELD_STRING
= 4,
188 #define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
189 struct lttng_ust_abi_field_iter
{
190 char event_name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
191 char field_name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
192 int32_t type
; /* enum lttng_ust_abi_field_type */
193 int loglevel
; /* event loglevel */
195 char padding
[LTTNG_UST_ABI_FIELD_ITER_PADDING
];
198 enum lttng_ust_abi_context_type
{
199 LTTNG_UST_ABI_CONTEXT_VTID
= 0,
200 LTTNG_UST_ABI_CONTEXT_VPID
= 1,
201 LTTNG_UST_ABI_CONTEXT_PTHREAD_ID
= 2,
202 LTTNG_UST_ABI_CONTEXT_PROCNAME
= 3,
203 LTTNG_UST_ABI_CONTEXT_IP
= 4,
204 LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER
= 5,
205 LTTNG_UST_ABI_CONTEXT_CPU_ID
= 6,
206 LTTNG_UST_ABI_CONTEXT_APP_CONTEXT
= 7,
207 LTTNG_UST_ABI_CONTEXT_CGROUP_NS
= 8,
208 LTTNG_UST_ABI_CONTEXT_IPC_NS
= 9,
209 LTTNG_UST_ABI_CONTEXT_MNT_NS
= 10,
210 LTTNG_UST_ABI_CONTEXT_NET_NS
= 11,
211 LTTNG_UST_ABI_CONTEXT_PID_NS
= 12,
212 LTTNG_UST_ABI_CONTEXT_USER_NS
= 13,
213 LTTNG_UST_ABI_CONTEXT_UTS_NS
= 14,
214 LTTNG_UST_ABI_CONTEXT_VUID
= 15,
215 LTTNG_UST_ABI_CONTEXT_VEUID
= 16,
216 LTTNG_UST_ABI_CONTEXT_VSUID
= 17,
217 LTTNG_UST_ABI_CONTEXT_VGID
= 18,
218 LTTNG_UST_ABI_CONTEXT_VEGID
= 19,
219 LTTNG_UST_ABI_CONTEXT_VSGID
= 20,
220 LTTNG_UST_ABI_CONTEXT_TIME_NS
= 21,
223 struct lttng_ust_abi_perf_counter_ctx
{
226 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
229 #define LTTNG_UST_ABI_CONTEXT_PADDING1 16
230 #define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
231 struct lttng_ust_abi_context
{
232 int32_t ctx
; /* enum lttng_ust_abi_context_type */
233 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING1
];
236 struct lttng_ust_abi_perf_counter_ctx perf_counter
;
238 /* Includes trailing '\0'. */
239 uint32_t provider_name_len
;
240 uint32_t ctx_name_len
;
242 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING2
];
247 * Tracer channel attributes.
249 #define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
250 struct lttng_ust_abi_channel_attr
{
251 uint64_t subbuf_size
; /* bytes */
252 uint64_t num_subbuf
; /* power of 2 */
253 int overwrite
; /* 1: overwrite, 0: discard */
254 unsigned int switch_timer_interval
; /* usec */
255 unsigned int read_timer_interval
; /* usec */
256 int32_t output
; /* enum lttng_ust_abi_output */
259 int64_t blocking_timeout
; /* Blocking timeout (usec) */
261 char padding
[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING
];
265 #define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
266 struct lttng_ust_abi_tracepoint_iter
{
267 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
]; /* provider:name */
269 char padding
[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING
];
272 enum lttng_ust_abi_object_type
{
273 LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN
= -1,
274 LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL
= 0,
275 LTTNG_UST_ABI_OBJECT_TYPE_STREAM
= 1,
276 LTTNG_UST_ABI_OBJECT_TYPE_EVENT
= 2,
277 LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT
= 3,
278 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP
= 4,
279 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER
= 5,
280 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER
= 6,
281 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL
= 7,
282 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU
= 8,
285 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
286 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
288 struct lttng_ust_abi_object_data
{
289 int32_t type
; /* enum lttng_ust_abi_object_type */
292 char padding1
[LTTNG_UST_ABI_OBJECT_DATA_PADDING1
];
296 int32_t type
; /* enum lttng_ust_abi_chan_type */
314 char padding2
[LTTNG_UST_ABI_OBJECT_DATA_PADDING2
];
318 enum lttng_ust_abi_calibrate_type
{
319 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT
,
322 #define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
323 #define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
324 struct lttng_ust_abi_calibrate
{
325 enum lttng_ust_abi_calibrate_type type
; /* type (input) */
326 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING1
];
329 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING2
];
333 #define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
334 #define LTTNG_UST_ABI_FILTER_PADDING 32
335 struct lttng_ust_abi_filter_bytecode
{
337 uint32_t reloc_offset
;
339 char padding
[LTTNG_UST_ABI_FILTER_PADDING
];
343 #define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
344 #define LTTNG_UST_ABI_CAPTURE_PADDING 32
345 struct lttng_ust_abi_capture_bytecode
{
347 uint32_t reloc_offset
;
349 char padding
[LTTNG_UST_ABI_CAPTURE_PADDING
];
353 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
354 struct lttng_ust_abi_event_exclusion
{
356 char padding
[LTTNG_UST_ABI_EXCLUSION_PADDING
];
357 char names
[LTTNG_UST_ABI_SYM_NAME_LEN
][0];
360 #define LTTNG_UST_ABI_CMD(minor) (minor)
361 #define LTTNG_UST_ABI_CMDR(minor, type) (minor)
362 #define LTTNG_UST_ABI_CMDW(minor, type) (minor)
364 /* Handled by object descriptor */
365 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
367 /* Handled by object cmd */
369 /* LTTng-UST commands */
370 #define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
371 #define LTTNG_UST_ABI_TRACER_VERSION \
372 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 \
378 LTTNG_UST_ABI_CMD(0x46)
380 /* Session commands */
381 #define LTTNG_UST_ABI_CHANNEL \
382 LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
383 #define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
384 #define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
385 #define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
387 /* Channel commands */
388 #define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
389 #define LTTNG_UST_ABI_EVENT \
390 LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
392 /* Event and channel commands */
393 #define LTTNG_UST_ABI_CONTEXT \
394 LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
395 #define LTTNG_UST_ABI_FLUSH_BUFFER \
396 LTTNG_UST_ABI_CMD(0x71)
398 /* Event, event notifier, channel and session commands */
399 #define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
400 #define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
402 /* Tracepoint list commands */
403 #define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
404 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
406 /* Event and event notifier commands */
407 #define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
408 #define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
410 /* Event notifier group commands */
411 #define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
412 LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
414 /* Event notifier commands */
415 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
417 /* Session and event notifier group commands */
418 #define LTTNG_UST_ABI_COUNTER \
419 LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
421 /* Counter commands */
422 #define LTTNG_UST_ABI_COUNTER_GLOBAL \
423 LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
424 #define LTTNG_UST_ABI_COUNTER_CPU \
425 LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
427 #define LTTNG_UST_ABI_ROOT_HANDLE 0
429 #endif /* LTTNG_UST_ABI_INTERNAL_H */