Move LTTng-UST buffer ownership from application to consumer
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-ust-ctl.h
CommitLineData
2bdd86d4
MD
1/*
2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
ffe60014 3 * Copyright (C) 2011-2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2bdd86d4 4 *
d14d33bf 5 * This program is free software; you can redistribute it and/or modify
ffe60014
DG
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License only.
2bdd86d4
MD
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
d14d33bf
AM
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2bdd86d4
MD
17 */
18
19#ifndef _LTTNG_UST_CTL_H
20#define _LTTNG_UST_CTL_H
21
ffe60014 22#include <lttng/ust-abi.h>
2bdd86d4 23
ffe60014
DG
24#ifndef LTTNG_PACKED
25#define LTTNG_PACKED __attribute__((packed))
26#endif
27
28#ifndef LTTNG_UST_UUID_LEN
29#define LTTNG_UST_UUID_LEN 16
30#endif
31
32struct lttng_ust_shm_handle;
33struct lttng_ust_lib_ring_buffer;
34
35struct ustctl_consumer_channel_attr {
36 enum lttng_ust_chan_type type;
37 uint64_t subbuf_size; /* bytes */
38 uint64_t num_subbuf; /* power of 2 */
39 int overwrite; /* 1: overwrite, 0: discard */
40 unsigned int switch_timer_interval; /* usec */
41 unsigned int read_timer_interval; /* usec */
42 enum lttng_ust_output output; /* splice, mmap */
43 unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
44} LTTNG_PACKED;
45
46/*
47 * API used by sessiond.
48 */
49
50/*
51 * Error values: all the following functions return:
52 * >= 0: Success (LTTNG_UST_OK)
53 * < 0: error code.
54 */
13161846
DG
55int ustctl_register_done(int sock);
56int ustctl_create_session(int sock);
2bdd86d4 57int ustctl_create_event(int sock, struct lttng_ust_event *ev,
13161846
DG
58 struct lttng_ust_object_data *channel_data,
59 struct lttng_ust_object_data **event_data);
2bdd86d4 60int ustctl_add_context(int sock, struct lttng_ust_context *ctx,
13161846
DG
61 struct lttng_ust_object_data *obj_data,
62 struct lttng_ust_object_data **context_data);
53a80697
MD
63int ustctl_set_filter(int sock, struct lttng_ust_filter_bytecode *bytecode,
64 struct lttng_ust_object_data *obj_data);
2bdd86d4 65
13161846
DG
66int ustctl_enable(int sock, struct lttng_ust_object_data *object);
67int ustctl_disable(int sock, struct lttng_ust_object_data *object);
68int ustctl_start_session(int sock, int handle);
69int ustctl_stop_session(int sock, int handle);
2bdd86d4 70
8ec2d32a
MD
71/*
72 * ustctl_tracepoint_list returns a tracepoint list handle, or negative
73 * error value.
74 */
75int ustctl_tracepoint_list(int sock);
ffe60014 76
8ec2d32a
MD
77/*
78 * ustctl_tracepoint_list_get is used to iterate on the tp list
ffe60014
DG
79 * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
80 * returned.
8ec2d32a
MD
81 */
82int ustctl_tracepoint_list_get(int sock, int tp_list_handle,
177f8533 83 struct lttng_ust_tracepoint_iter *iter);
8ec2d32a 84
f37d259d
MD
85/*
86 * ustctl_tracepoint_field_list returns a tracepoint field list handle,
87 * or negative error value.
88 */
89int ustctl_tracepoint_field_list(int sock);
90
91/*
92 * ustctl_tracepoint_field_list_get is used to iterate on the tp field
ffe60014
DG
93 * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
94 * returned.
f37d259d
MD
95 */
96int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle,
97 struct lttng_ust_field_iter *iter);
98
13161846
DG
99int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v);
100int ustctl_wait_quiescent(int sock);
2bdd86d4 101
6d3686da
DG
102int ustctl_sock_flush_buffer(int sock, struct lttng_ust_object_data *object);
103
13161846 104int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate);
2bdd86d4 105
ffe60014
DG
106/* Release object created by members of this API. */
107int ustctl_release_object(int sock, struct lttng_ust_object_data *data);
108/* Release handle returned by create session. */
109int ustctl_release_handle(int sock, int handle);
110
111int ustctl_recv_channel_from_consumer(int sock,
112 struct lttng_ust_object_data **channel_data);
113int ustctl_recv_stream_from_consumer(int sock,
114 struct lttng_ust_object_data **stream_data);
115int ustctl_send_channel_to_ust(int sock, int session_handle,
116 struct lttng_ust_object_data *channel_data);
117int ustctl_send_stream_to_ust(int sock,
118 struct lttng_ust_object_data *channel_data,
119 struct lttng_ust_object_data *stream_data);
120
2bdd86d4 121/*
ffe60014 122 * API used by consumer.
2bdd86d4 123 */
ffe60014
DG
124
125struct ustctl_consumer_channel;
126struct ustctl_consumer_stream;
127struct ustctl_consumer_channel_attr;
128
129struct ustctl_consumer_channel *
130 ustctl_create_channel(struct ustctl_consumer_channel_attr *attr);
2bdd86d4 131/*
ffe60014
DG
132 * Each stream created needs to be destroyed before calling
133 * ustctl_destroy_channel().
2bdd86d4 134 */
ffe60014 135void ustctl_destroy_channel(struct ustctl_consumer_channel *chan);
2bdd86d4 136
ffe60014
DG
137int ustctl_send_channel_to_sessiond(int sock,
138 struct ustctl_consumer_channel *channel);
139/*
140 * Send a NULL stream to finish iteration over all streams of a given
141 * channel.
142 */
143int ustctl_send_stream_to_sessiond(int sock,
144 struct ustctl_consumer_stream *stream);
145int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream);
2bdd86d4 146
ffe60014
DG
147/* Create/destroy stream buffers for read */
148struct ustctl_consumer_stream *
149 ustctl_create_stream(struct ustctl_consumer_channel *channel,
150 int cpu);
151void ustctl_destroy_stream(struct ustctl_consumer_stream *stream);
2bdd86d4 152
ffe60014
DG
153int ustctl_get_wait_fd(struct ustctl_consumer_stream *stream);
154int ustctl_get_wakeup_fd(struct ustctl_consumer_stream *stream);
2bdd86d4
MD
155
156/* For mmap mode, readable without "get" operation */
ffe60014 157int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream,
13161846 158 unsigned long *len);
ffe60014 159int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream,
13161846 160 unsigned long *len);
2bdd86d4
MD
161
162/*
163 * For mmap mode, operate on the current packet (between get/put or
164 * get_next/put_next).
165 */
ffe60014
DG
166void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream);
167int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream,
168 unsigned long *off);
169int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream,
170 unsigned long *len);
171int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream,
172 unsigned long *len);
173int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream);
174int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream);
2bdd86d4
MD
175
176/* snapshot */
177
ffe60014
DG
178int ustctl_snapshot(struct ustctl_consumer_stream *stream);
179int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
180 unsigned long *pos);
181int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream,
182 unsigned long *pos);
183int ustctl_get_subbuf(struct ustctl_consumer_stream *stream,
184 unsigned long *pos);
185int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
8ec2d32a 186
ffe60014
DG
187void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
188 int producer_active);
2bdd86d4
MD
189
190#endif /* _LTTNG_UST_CTL_H */
This page took 0.043971 seconds and 5 git commands to generate.