cleanup: Namespace public utils macros
[lttng-ust.git] / include / lttng / ust-ctl.h
CommitLineData
f3105c67 1/*
c0c0989a 2 * SPDX-License-Identifier: GPL-2.0-only
f3105c67 3 *
c0c0989a
MJ
4 * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
5 * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f3105c67
MD
6 */
7
8#ifndef _LTTNG_UST_CTL_H
9#define _LTTNG_UST_CTL_H
10
fb31eb73 11#include <limits.h>
b4051ad8 12#include <stddef.h>
fb31eb73 13#include <stdint.h>
ebabbf58 14#include <stdbool.h>
32ce8569 15#include <sys/types.h>
fb31eb73
FD
16
17#include <lttng/ust-abi.h>
eae3c729 18#include <lttng/ust-utils.h>
74d81a6c
MD
19
20#ifndef LTTNG_UST_UUID_LEN
21#define LTTNG_UST_UUID_LEN 16
22#endif
23
32ce8569
MD
24/* Default unix socket path */
25#define LTTNG_UST_SOCK_FILENAME \
26 "lttng-ust-sock-" \
eae3c729 27 lttng_ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
32ce8569
MD
28
29/*
30 * Shared memory files path are automatically related to shm root, e.g.
31 * /dev/shm under linux.
32 */
33#define LTTNG_UST_WAIT_FILENAME \
34 "lttng-ust-wait-" \
eae3c729 35 lttng_ust_stringify(LTTNG_UST_ABI_MAJOR_VERSION)
32ce8569 36
74d81a6c
MD
37struct lttng_ust_lib_ring_buffer;
38
39struct ustctl_consumer_channel_attr {
fd17d7ce 40 enum lttng_ust_abi_chan_type type;
74d81a6c
MD
41 uint64_t subbuf_size; /* bytes */
42 uint64_t num_subbuf; /* power of 2 */
43 int overwrite; /* 1: overwrite, 0: discard */
44 unsigned int switch_timer_interval; /* usec */
45 unsigned int read_timer_interval; /* usec */
fd17d7ce 46 enum lttng_ust_abi_output output; /* splice, mmap */
6ca18e66 47 uint32_t chan_id; /* channel ID */
74d81a6c 48 unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
b2c5f61a 49 int64_t blocking_timeout; /* Blocking timeout (usec) */
9f5ade14 50} __attribute__((packed));
74d81a6c
MD
51
52/*
53 * API used by sessiond.
54 */
55
53f0df51 56struct lttng_ust_context_attr {
fd17d7ce 57 enum lttng_ust_abi_context_type ctx;
53f0df51 58 union {
fd17d7ce 59 struct lttng_ust_abi_perf_counter_ctx perf_counter;
53f0df51
JG
60 struct {
61 char *provider_name;
62 char *ctx_name;
63 } app_ctx;
64 } u;
65};
66
7bc53e94
MD
67/*
68 * Error values: all the following functions return:
c354a72c 69 * >= 0: Success (LTTNG_UST_OK)
7bc53e94
MD
70 * < 0: error code.
71 */
1c5e467e 72int ustctl_register_done(int sock);
f3105c67 73int ustctl_create_session(int sock);
fd17d7ce
MD
74int ustctl_create_event(int sock, struct lttng_ust_abi_event *ev,
75 struct lttng_ust_abi_object_data *channel_data,
76 struct lttng_ust_abi_object_data **event_data);
53f0df51 77int ustctl_add_context(int sock, struct lttng_ust_context_attr *ctx,
fd17d7ce
MD
78 struct lttng_ust_abi_object_data *obj_data,
79 struct lttng_ust_abi_object_data **context_data);
80int ustctl_set_filter(int sock, struct lttng_ust_abi_filter_bytecode *bytecode,
81 struct lttng_ust_abi_object_data *obj_data);
82int ustctl_set_capture(int sock, struct lttng_ust_abi_capture_bytecode *bytecode,
83 struct lttng_ust_abi_object_data *obj_data);
84int ustctl_set_exclusion(int sock, struct lttng_ust_abi_event_exclusion *exclusion,
85 struct lttng_ust_abi_object_data *obj_data);
86
87int ustctl_enable(int sock, struct lttng_ust_abi_object_data *object);
88int ustctl_disable(int sock, struct lttng_ust_abi_object_data *object);
4a6ca058
MD
89int ustctl_start_session(int sock, int handle);
90int ustctl_stop_session(int sock, int handle);
f3105c67 91
d8d2416d
FD
92/*
93 * ustctl_create_event notifier_group creates a event notifier group. It
94 * establishes the connection with the application by providing a file
95 * descriptor of the pipe to be used by the application when a event notifier
96 * of that group is fired. It returns a handle to be used when creating event
97 * notifier in that group.
98 */
99int ustctl_create_event_notifier_group(int sock, int pipe_fd,
fd17d7ce 100 struct lttng_ust_abi_object_data **event_notifier_group);
d8d2416d
FD
101
102/*
103 * ustctl_create_event notifier creates a event notifier in a event notifier
104 * group giving a event notifier description and a event notifier group handle.
105 * It returns a event notifier handle to be used when enabling the event
106 * notifier, attaching filter, attaching exclusion, and disabling the event
107 * notifier.
108 */
109int ustctl_create_event_notifier(int sock,
fd17d7ce
MD
110 struct lttng_ust_abi_event_notifier *event_notifier,
111 struct lttng_ust_abi_object_data *event_notifier_group,
112 struct lttng_ust_abi_object_data **event_notifier_data);
d8d2416d 113
b115631f
MD
114/*
115 * ustctl_tracepoint_list returns a tracepoint list handle, or negative
116 * error value.
117 */
118int ustctl_tracepoint_list(int sock);
74d81a6c 119
b115631f
MD
120/*
121 * ustctl_tracepoint_list_get is used to iterate on the tp list
7bc53e94
MD
122 * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
123 * returned.
b115631f
MD
124 */
125int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
fd17d7ce 126 struct lttng_ust_abi_tracepoint_iter *iter);
b115631f 127
40003310
MD
128/*
129 * ustctl_tracepoint_field_list returns a tracepoint field list handle,
130 * or negative error value.
131 */
132int ustctl_tracepoint_field_list(int sock);
133
134/*
135 * ustctl_tracepoint_field_list_get is used to iterate on the tp field
7bc53e94
MD
136 * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
137 * returned.
40003310
MD
138 */
139int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
fd17d7ce 140 struct lttng_ust_abi_field_iter *iter);
40003310 141
fd17d7ce 142int ustctl_tracer_version(int sock, struct lttng_ust_abi_tracer_version *v);
f3105c67
MD
143int ustctl_wait_quiescent(int sock);
144
fd17d7ce 145int ustctl_sock_flush_buffer(int sock, struct lttng_ust_abi_object_data *object);
f1fffc57 146
fd17d7ce 147int ustctl_calibrate(int sock, struct lttng_ust_abi_calibrate *calibrate);
f3105c67 148
74d81a6c 149/* Release object created by members of this API. */
fd17d7ce 150int ustctl_release_object(int sock, struct lttng_ust_abi_object_data *data);
74d81a6c
MD
151/* Release handle returned by create session. */
152int ustctl_release_handle(int sock, int handle);
153
154int ustctl_recv_channel_from_consumer(int sock,
fd17d7ce 155 struct lttng_ust_abi_object_data **channel_data);
74d81a6c 156int ustctl_recv_stream_from_consumer(int sock,
fd17d7ce 157 struct lttng_ust_abi_object_data **stream_data);
74d81a6c 158int ustctl_send_channel_to_ust(int sock, int session_handle,
fd17d7ce 159 struct lttng_ust_abi_object_data *channel_data);
74d81a6c 160int ustctl_send_stream_to_ust(int sock,
fd17d7ce
MD
161 struct lttng_ust_abi_object_data *channel_data,
162 struct lttng_ust_abi_object_data *stream_data);
74d81a6c 163
12f3dabc
MD
164/*
165 * ustctl_duplicate_ust_object_data allocated a new object in "dest" if
166 * it succeeds (returns 0). It must be released using
167 * ustctl_release_object() and then freed with free().
168 */
fd17d7ce
MD
169int ustctl_duplicate_ust_object_data(struct lttng_ust_abi_object_data **dest,
170 struct lttng_ust_abi_object_data *src);
12f3dabc 171
f3105c67 172/*
74d81a6c 173 * API used by consumer.
f3105c67 174 */
74d81a6c
MD
175
176struct ustctl_consumer_channel;
177struct ustctl_consumer_stream;
178struct ustctl_consumer_channel_attr;
179
5ea386c3
MD
180int ustctl_get_nr_stream_per_channel(void);
181
74d81a6c 182struct ustctl_consumer_channel *
5ea386c3
MD
183 ustctl_create_channel(struct ustctl_consumer_channel_attr *attr,
184 const int *stream_fds, int nr_stream_fds);
5224b5c8 185/*
74d81a6c
MD
186 * Each stream created needs to be destroyed before calling
187 * ustctl_destroy_channel().
5224b5c8 188 */
74d81a6c 189void ustctl_destroy_channel(struct ustctl_consumer_channel *chan);
f3105c67 190
74d81a6c
MD
191int ustctl_send_channel_to_sessiond(int sock,
192 struct ustctl_consumer_channel *channel);
ff0f5728
MD
193int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan);
194int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan);
195int ustctl_channel_get_wait_fd(struct ustctl_consumer_channel *consumer_chan);
196int ustctl_channel_get_wakeup_fd(struct ustctl_consumer_channel *consumer_chan);
c9023c93
MD
197
198int ustctl_write_metadata_to_channel(
199 struct ustctl_consumer_channel *channel,
200 const char *metadata_str, /* NOT null-terminated */
201 size_t len); /* metadata length */
3ef94b0e
JD
202ssize_t ustctl_write_one_packet_to_channel(
203 struct ustctl_consumer_channel *channel,
204 const char *metadata_str, /* NOT null-terminated */
205 size_t len); /* metadata length */
c9023c93 206
74d81a6c
MD
207/*
208 * Send a NULL stream to finish iteration over all streams of a given
209 * channel.
210 */
211int ustctl_send_stream_to_sessiond(int sock,
212 struct ustctl_consumer_stream *stream);
213int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream);
214int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream);
ff0f5728
MD
215int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream);
216int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream);
f3105c67 217
74d81a6c
MD
218/* Create/destroy stream buffers for read */
219struct ustctl_consumer_stream *
220 ustctl_create_stream(struct ustctl_consumer_channel *channel,
221 int cpu);
222void ustctl_destroy_stream(struct ustctl_consumer_stream *stream);
f3105c67
MD
223
224/* For mmap mode, readable without "get" operation */
74d81a6c 225int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream,
f3105c67 226 unsigned long *len);
74d81a6c 227int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream,
f3105c67
MD
228 unsigned long *len);
229
230/*
231 * For mmap mode, operate on the current packet (between get/put or
232 * get_next/put_next).
233 */
74d81a6c
MD
234void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream);
235int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream,
236 unsigned long *off);
237int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream,
238 unsigned long *len);
239int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream,
240 unsigned long *len);
241int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream);
242int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream);
f3105c67
MD
243
244/* snapshot */
245
74d81a6c 246int ustctl_snapshot(struct ustctl_consumer_stream *stream);
f45930b7 247int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream);
74d81a6c
MD
248int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
249 unsigned long *pos);
250int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream,
251 unsigned long *pos);
252int ustctl_get_subbuf(struct ustctl_consumer_stream *stream,
253 unsigned long *pos);
254int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
5f9d3dbc 255
74d81a6c
MD
256void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
257 int producer_active);
beca55a1 258void ustctl_clear_buffer(struct ustctl_consumer_stream *stream);
f3105c67 259
b2f3252a 260/* index */
82df14e4
MD
261
262/*
263 * Getters which need to be used on the current packet (between get/put
264 * or get_next/put_next.
265 */
266
b2f3252a
JD
267int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
268 uint64_t *timestamp_begin);
269int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
270 uint64_t *timestamp_end);
271int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
272 uint64_t *events_discarded);
273int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
274 uint64_t *content_size);
275int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
276 uint64_t *packet_size);
1ff31389
JD
277int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream,
278 uint64_t *seq);
82df14e4
MD
279
280/*
281 * Getter returning state invariant for the stream, which can be used
282 * without "get" operation.
283 */
284
285int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
286 uint64_t *stream_id);
45a00b05
JD
287int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
288 uint64_t *id);
b2f3252a 289
82df14e4
MD
290/*
291 * Getter returning the current timestamp as perceived from the
292 * tracer.
293 */
294int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
295 uint64_t *ts);
296
57201bb3
MD
297/* returns whether UST has perf counters support. */
298int ustctl_has_perf_counters(void);
299
f53329f3
JD
300/* Regenerate the statedump. */
301int ustctl_regenerate_statedump(int sock, int handle);
302
32ce8569
MD
303/* event registry management */
304
305enum ustctl_socket_type {
306 USTCTL_SOCKET_CMD = 0,
307 USTCTL_SOCKET_NOTIFY = 1,
308};
309
310enum ustctl_notify_cmd {
311 USTCTL_NOTIFY_CMD_EVENT = 0,
312 USTCTL_NOTIFY_CMD_CHANNEL = 1,
c785c634 313 USTCTL_NOTIFY_CMD_ENUM = 2,
32ce8569
MD
314};
315
316enum ustctl_channel_header {
317 USTCTL_CHANNEL_HEADER_UNKNOWN = 0,
318 USTCTL_CHANNEL_HEADER_COMPACT = 1,
319 USTCTL_CHANNEL_HEADER_LARGE = 2,
320};
321
322/* event type structures */
323
324enum ustctl_abstract_types {
325 ustctl_atype_integer,
218deb69
MD
326 ustctl_atype_enum, /* legacy */
327 ustctl_atype_array, /* legacy */
328 ustctl_atype_sequence, /* legacy */
32ce8569
MD
329 ustctl_atype_string,
330 ustctl_atype_float,
218deb69
MD
331 ustctl_atype_variant, /* legacy */
332 ustctl_atype_struct, /* legacy */
333 ustctl_atype_enum_nestable,
334 ustctl_atype_array_nestable,
335 ustctl_atype_sequence_nestable,
336 ustctl_atype_struct_nestable,
337 ustctl_atype_variant_nestable,
32ce8569
MD
338 NR_USTCTL_ABSTRACT_TYPES,
339};
340
341enum ustctl_string_encodings {
342 ustctl_encode_none = 0,
343 ustctl_encode_UTF8 = 1,
344 ustctl_encode_ASCII = 2,
345 NR_USTCTL_STRING_ENCODINGS,
346};
347
348#define USTCTL_UST_INTEGER_TYPE_PADDING 24
349struct ustctl_integer_type {
350 uint32_t size; /* in bits */
351 uint32_t signedness;
352 uint32_t reverse_byte_order;
353 uint32_t base; /* 2, 8, 10, 16, for pretty print */
735ea6a8 354 int32_t encoding; /* enum ustctl_string_encodings */
32ce8569
MD
355 uint16_t alignment; /* in bits */
356 char padding[USTCTL_UST_INTEGER_TYPE_PADDING];
9f5ade14 357} __attribute__((packed));
32ce8569
MD
358
359#define USTCTL_UST_FLOAT_TYPE_PADDING 24
360struct ustctl_float_type {
361 uint32_t exp_dig; /* exponent digits, in bits */
362 uint32_t mant_dig; /* mantissa digits, in bits */
363 uint32_t reverse_byte_order;
364 uint16_t alignment; /* in bits */
365 char padding[USTCTL_UST_FLOAT_TYPE_PADDING];
9f5ade14 366} __attribute__((packed));
32ce8569 367
a6f80644
MD
368#define USTCTL_UST_ENUM_VALUE_PADDING 15
369struct ustctl_enum_value {
370 uint64_t value;
371 uint8_t signedness;
372 char padding[USTCTL_UST_ENUM_VALUE_PADDING];
9f5ade14 373} __attribute__((packed));
a6f80644 374
3e762260
PP
375enum ustctl_ust_enum_entry_options {
376 USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
377};
378
c785c634
MD
379#define USTCTL_UST_ENUM_ENTRY_PADDING 32
380struct ustctl_enum_entry {
a6f80644 381 struct ustctl_enum_value start, end; /* start and end are inclusive */
fd17d7ce 382 char string[LTTNG_UST_ABI_SYM_NAME_LEN];
3e762260
PP
383 union {
384 struct {
385 uint32_t options;
9f5ade14 386 } __attribute__((packed)) extra;
3e762260
PP
387 char padding[USTCTL_UST_ENUM_ENTRY_PADDING];
388 } u;
9f5ade14 389} __attribute__((packed));
c785c634 390
218deb69 391/* legacy */
32ce8569
MD
392#define USTCTL_UST_BASIC_TYPE_PADDING 296
393union _ustctl_basic_type {
394 struct ustctl_integer_type integer;
c785c634 395 struct {
fd17d7ce 396 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
c785c634
MD
397 struct ustctl_integer_type container_type;
398 uint64_t id; /* enum ID in sessiond. */
399 } enumeration;
32ce8569 400 struct {
735ea6a8 401 int32_t encoding; /* enum ustctl_string_encodings */
32ce8569
MD
402 } string;
403 struct ustctl_float_type _float;
404 char padding[USTCTL_UST_BASIC_TYPE_PADDING];
9f5ade14 405} __attribute__((packed));
32ce8569 406
218deb69 407/* legacy */
32ce8569
MD
408struct ustctl_basic_type {
409 enum ustctl_abstract_types atype;
410 union {
411 union _ustctl_basic_type basic;
412 } u;
9f5ade14 413} __attribute__((packed));
32ce8569 414
218deb69
MD
415/*
416 * Padding is derived from largest member: u.legacy.sequence which
417 * contains two basic types, each with USTCTL_UST_BASIC_TYPE_PADDING.
418 */
419#define USTCTL_UST_TYPE_PADDING (2 * USTCTL_UST_BASIC_TYPE_PADDING)
32ce8569
MD
420struct ustctl_type {
421 enum ustctl_abstract_types atype;
422 union {
218deb69
MD
423 struct ustctl_integer_type integer;
424 struct ustctl_float_type _float;
425 struct {
426 int32_t encoding; /* enum ustctl_string_encodings */
427 } string;
428 struct {
fd17d7ce 429 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69
MD
430 uint64_t id; /* enum ID in sessiond. */
431 /* container_type follows after this struct ustctl_field. */
432 } enum_nestable;
32ce8569 433 struct {
32ce8569 434 uint32_t length; /* num. elems. */
218deb69
MD
435 uint32_t alignment;
436 /* elem_type follows after this struct ustctl_field. */
437 } array_nestable;
32ce8569 438 struct {
fd17d7ce 439 char length_name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69
MD
440 uint32_t alignment; /* Alignment before elements. */
441 /* elem_type follows after the length_type. */
442 } sequence_nestable;
443 struct {
444 uint32_t nr_fields;
445 uint32_t alignment;
446 /* Followed by nr_fields struct ustctl_field. */
447 } struct_nestable;
53569322
MD
448 struct {
449 uint32_t nr_choices;
fd17d7ce 450 char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69 451 uint32_t alignment;
53569322 452 /* Followed by nr_choices struct ustctl_field. */
218deb69
MD
453 } variant_nestable;
454
455 /* Legacy ABI */
456 union {
457 union _ustctl_basic_type basic;
458 struct {
459 struct ustctl_basic_type elem_type;
460 uint32_t length; /* num. elems. */
461 } array;
462 struct {
463 struct ustctl_basic_type length_type;
464 struct ustctl_basic_type elem_type;
465 } sequence;
466 struct {
467 uint32_t nr_fields;
468 /* Followed by nr_fields struct ustctl_field. */
469 } _struct;
470 struct {
471 uint32_t nr_choices;
fd17d7ce 472 char tag_name[LTTNG_UST_ABI_SYM_NAME_LEN];
218deb69
MD
473 /* Followed by nr_choices struct ustctl_field. */
474 } variant;
475 } legacy;
32ce8569
MD
476 char padding[USTCTL_UST_TYPE_PADDING];
477 } u;
9f5ade14 478} __attribute__((packed));
32ce8569
MD
479
480#define USTCTL_UST_FIELD_PADDING 28
481struct ustctl_field {
fd17d7ce 482 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
32ce8569
MD
483 struct ustctl_type type;
484 char padding[USTCTL_UST_FIELD_PADDING];
9f5ade14 485} __attribute__((packed));
32ce8569
MD
486
487/*
488 * Returns 0 on success, negative error value on error.
489 * If an error other than -LTTNG_UST_ERR_UNSUP_MAJOR is returned,
490 * the output fields are not populated.
491 */
492int ustctl_recv_reg_msg(int sock,
493 enum ustctl_socket_type *type,
494 uint32_t *major,
495 uint32_t *minor,
496 uint32_t *pid,
497 uint32_t *ppid,
498 uint32_t *uid,
499 uint32_t *gid,
500 uint32_t *bits_per_long,
501 uint32_t *uint8_t_alignment,
502 uint32_t *uint16_t_alignment,
503 uint32_t *uint32_t_alignment,
504 uint32_t *uint64_t_alignment,
505 uint32_t *long_alignment,
506 int *byte_order,
507 char *name); /* size LTTNG_UST_ABI_PROCNAME_LEN */
508
509/*
510 * Returns 0 on success, negative UST or system error value on error.
511 * Receive the notification command. The "notify_cmd" can then be used
512 * by the caller to find out which ustctl_recv_* function should be
513 * called to receive the notification, and which ustctl_reply_* is
514 * appropriate.
515 */
516int ustctl_recv_notify(int sock, enum ustctl_notify_cmd *notify_cmd);
517
518/*
519 * Returns 0 on success, negative UST or system error value on error.
520 */
521int ustctl_recv_register_event(int sock,
522 int *session_objd, /* session descriptor (output) */
523 int *channel_objd, /* channel descriptor (output) */
524 char *event_name, /*
525 * event name (output,
fd17d7ce 526 * size LTTNG_UST_ABI_SYM_NAME_LEN)
32ce8569
MD
527 */
528 int *loglevel,
529 char **signature, /*
530 * event signature
531 * (output, dynamically
532 * allocated, must be free(3)'d
533 * by the caller if function
534 * returns success.)
535 */
536 size_t *nr_fields,
537 struct ustctl_field **fields,
538 char **model_emf_uri);
539
540/*
541 * Returns 0 on success, negative error value on error.
542 */
543int ustctl_reply_register_event(int sock,
544 uint32_t id, /* event id (input) */
545 int ret_code); /* return code. 0 ok, negative error */
546
c785c634
MD
547/*
548 * Returns 0 on success, negative UST or system error value on error.
549 */
550int ustctl_recv_register_enum(int sock,
551 int *session_objd,
552 char *enum_name,
553 struct ustctl_enum_entry **entries,
554 size_t *nr_entries);
555
556/*
557 * Returns 0 on success, negative error value on error.
558 */
559int ustctl_reply_register_enum(int sock,
560 uint64_t id, /* enum id (input) */
561 int ret_code);
562
32ce8569
MD
563/*
564 * Returns 0 on success, negative UST or system error value on error.
565 */
566int ustctl_recv_register_channel(int sock,
567 int *session_objd, /* session descriptor (output) */
568 int *channel_objd, /* channel descriptor (output) */
569 size_t *nr_fields, /* context fields */
570 struct ustctl_field **fields);
571
572/*
573 * Returns 0 on success, negative error value on error.
574 */
575int ustctl_reply_register_channel(int sock,
576 uint32_t chan_id,
577 enum ustctl_channel_header header_type,
578 int ret_code); /* return code. 0 ok, negative error */
579
ebabbf58
MD
580/*
581 * Counter API.
582 */
583
584enum ustctl_counter_bitness {
48dff3ac
MD
585 USTCTL_COUNTER_BITNESS_32 = 0,
586 USTCTL_COUNTER_BITNESS_64 = 1,
ebabbf58
MD
587};
588
589enum ustctl_counter_arithmetic {
590 USTCTL_COUNTER_ARITHMETIC_MODULAR = 0,
591 USTCTL_COUNTER_ARITHMETIC_SATURATION = 1,
592};
593
594/* Used as alloc flags. */
595enum ustctl_counter_alloc {
596 USTCTL_COUNTER_ALLOC_PER_CPU = (1 << 0),
597 USTCTL_COUNTER_ALLOC_GLOBAL = (1 << 1),
598};
599
600struct ustctl_daemon_counter;
601
602int ustctl_get_nr_cpu_per_counter(void);
603
604struct ustctl_counter_dimension {
605 uint64_t size;
606 uint64_t underflow_index;
607 uint64_t overflow_index;
608 uint8_t has_underflow;
609 uint8_t has_overflow;
610};
611
612struct ustctl_daemon_counter *
613 ustctl_create_counter(size_t nr_dimensions,
614 const struct ustctl_counter_dimension *dimensions,
615 int64_t global_sum_step,
616 int global_counter_fd,
617 int nr_counter_cpu_fds,
618 const int *counter_cpu_fds,
619 enum ustctl_counter_bitness bitness,
620 enum ustctl_counter_arithmetic arithmetic,
81bc4972
MD
621 uint32_t alloc_flags,
622 bool coalesce_hits);
ebabbf58
MD
623
624int ustctl_create_counter_data(struct ustctl_daemon_counter *counter,
fd17d7ce 625 struct lttng_ust_abi_object_data **counter_data);
ebabbf58
MD
626
627int ustctl_create_counter_global_data(struct ustctl_daemon_counter *counter,
fd17d7ce 628 struct lttng_ust_abi_object_data **counter_global_data);
ebabbf58 629int ustctl_create_counter_cpu_data(struct ustctl_daemon_counter *counter, int cpu,
fd17d7ce 630 struct lttng_ust_abi_object_data **counter_cpu_data);
ebabbf58
MD
631
632/*
633 * Each counter data and counter cpu data created need to be destroyed
634 * before calling ustctl_destroy_counter().
635 */
636void ustctl_destroy_counter(struct ustctl_daemon_counter *counter);
637
638int ustctl_send_counter_data_to_ust(int sock, int parent_handle,
fd17d7ce 639 struct lttng_ust_abi_object_data *counter_data);
ebabbf58 640int ustctl_send_counter_global_data_to_ust(int sock,
fd17d7ce
MD
641 struct lttng_ust_abi_object_data *counter_data,
642 struct lttng_ust_abi_object_data *counter_global_data);
ebabbf58 643int ustctl_send_counter_cpu_data_to_ust(int sock,
fd17d7ce
MD
644 struct lttng_ust_abi_object_data *counter_data,
645 struct lttng_ust_abi_object_data *counter_cpu_data);
ebabbf58
MD
646
647int ustctl_counter_read(struct ustctl_daemon_counter *counter,
648 const size_t *dimension_indexes,
649 int cpu, int64_t *value,
650 bool *overflow, bool *underflow);
651int ustctl_counter_aggregate(struct ustctl_daemon_counter *counter,
652 const size_t *dimension_indexes,
653 int64_t *value,
654 bool *overflow, bool *underflow);
655int ustctl_counter_clear(struct ustctl_daemon_counter *counter,
656 const size_t *dimension_indexes);
657
f3105c67 658#endif /* _LTTNG_UST_CTL_H */
This page took 0.067021 seconds and 4 git commands to generate.