2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Copyright (C) 2011-2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * This program is free software; you can redistribute it and/or modify
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.
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.
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.
19 #ifndef _LTTNG_UST_CTL_H
20 #define _LTTNG_UST_CTL_H
22 #include <lttng/ust-abi.h>
25 #define LTTNG_PACKED __attribute__((packed))
28 #ifndef LTTNG_UST_UUID_LEN
29 #define LTTNG_UST_UUID_LEN 16
32 struct lttng_ust_shm_handle
;
33 struct lttng_ust_lib_ring_buffer
;
35 struct 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 */
47 * API used by sessiond.
51 * Error values: all the following functions return:
52 * >= 0: Success (LTTNG_UST_OK)
55 int ustctl_register_done(int sock
);
56 int ustctl_create_session(int sock
);
57 int ustctl_create_event(int sock
, struct lttng_ust_event
*ev
,
58 struct lttng_ust_object_data
*channel_data
,
59 struct lttng_ust_object_data
**event_data
);
60 int ustctl_add_context(int sock
, struct lttng_ust_context
*ctx
,
61 struct lttng_ust_object_data
*obj_data
,
62 struct lttng_ust_object_data
**context_data
);
63 int ustctl_set_filter(int sock
, struct lttng_ust_filter_bytecode
*bytecode
,
64 struct lttng_ust_object_data
*obj_data
);
66 int ustctl_enable(int sock
, struct lttng_ust_object_data
*object
);
67 int ustctl_disable(int sock
, struct lttng_ust_object_data
*object
);
68 int ustctl_start_session(int sock
, int handle
);
69 int ustctl_stop_session(int sock
, int handle
);
72 * ustctl_tracepoint_list returns a tracepoint list handle, or negative
75 int ustctl_tracepoint_list(int sock
);
78 * ustctl_tracepoint_list_get is used to iterate on the tp list
79 * handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
82 int ustctl_tracepoint_list_get(int sock
, int tp_list_handle
,
83 struct lttng_ust_tracepoint_iter
*iter
);
86 * ustctl_tracepoint_field_list returns a tracepoint field list handle,
87 * or negative error value.
89 int ustctl_tracepoint_field_list(int sock
);
92 * ustctl_tracepoint_field_list_get is used to iterate on the tp field
93 * list handle. End is iteration is reached when -LTTNG_UST_ERR_NOENT is
96 int ustctl_tracepoint_field_list_get(int sock
, int tp_field_list_handle
,
97 struct lttng_ust_field_iter
*iter
);
99 int ustctl_tracer_version(int sock
, struct lttng_ust_tracer_version
*v
);
100 int ustctl_wait_quiescent(int sock
);
102 int ustctl_sock_flush_buffer(int sock
, struct lttng_ust_object_data
*object
);
104 int ustctl_calibrate(int sock
, struct lttng_ust_calibrate
*calibrate
);
106 /* Release object created by members of this API. */
107 int ustctl_release_object(int sock
, struct lttng_ust_object_data
*data
);
108 /* Release handle returned by create session. */
109 int ustctl_release_handle(int sock
, int handle
);
111 int ustctl_recv_channel_from_consumer(int sock
,
112 struct lttng_ust_object_data
**channel_data
);
113 int ustctl_recv_stream_from_consumer(int sock
,
114 struct lttng_ust_object_data
**stream_data
);
115 int ustctl_send_channel_to_ust(int sock
, int session_handle
,
116 struct lttng_ust_object_data
*channel_data
);
117 int ustctl_send_stream_to_ust(int sock
,
118 struct lttng_ust_object_data
*channel_data
,
119 struct lttng_ust_object_data
*stream_data
);
122 * API used by consumer.
125 struct ustctl_consumer_channel
;
126 struct ustctl_consumer_stream
;
127 struct ustctl_consumer_channel_attr
;
129 struct ustctl_consumer_channel
*
130 ustctl_create_channel(struct ustctl_consumer_channel_attr
*attr
);
132 * Each stream created needs to be destroyed before calling
133 * ustctl_destroy_channel().
135 void ustctl_destroy_channel(struct ustctl_consumer_channel
*chan
);
137 int ustctl_send_channel_to_sessiond(int sock
,
138 struct ustctl_consumer_channel
*channel
);
140 * Send a NULL stream to finish iteration over all streams of a given
143 int ustctl_send_stream_to_sessiond(int sock
,
144 struct ustctl_consumer_stream
*stream
);
145 int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream
*stream
);
146 int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream
*stream
);
148 /* Create/destroy stream buffers for read */
149 struct ustctl_consumer_stream
*
150 ustctl_create_stream(struct ustctl_consumer_channel
*channel
,
152 void ustctl_destroy_stream(struct ustctl_consumer_stream
*stream
);
154 int ustctl_get_wait_fd(struct ustctl_consumer_stream
*stream
);
155 int ustctl_get_wakeup_fd(struct ustctl_consumer_stream
*stream
);
157 /* For mmap mode, readable without "get" operation */
158 int ustctl_get_mmap_len(struct ustctl_consumer_stream
*stream
,
160 int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream
*stream
,
164 * For mmap mode, operate on the current packet (between get/put or
165 * get_next/put_next).
167 void *ustctl_get_mmap_base(struct ustctl_consumer_stream
*stream
);
168 int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream
*stream
,
170 int ustctl_get_subbuf_size(struct ustctl_consumer_stream
*stream
,
172 int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream
*stream
,
174 int ustctl_get_next_subbuf(struct ustctl_consumer_stream
*stream
);
175 int ustctl_put_next_subbuf(struct ustctl_consumer_stream
*stream
);
179 int ustctl_snapshot(struct ustctl_consumer_stream
*stream
);
180 int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream
*stream
,
182 int ustctl_snapshot_get_produced(struct ustctl_consumer_stream
*stream
,
184 int ustctl_get_subbuf(struct ustctl_consumer_stream
*stream
,
186 int ustctl_put_subbuf(struct ustctl_consumer_stream
*stream
);
188 void ustctl_flush_buffer(struct ustctl_consumer_stream
*stream
,
189 int producer_active
);
191 #endif /* _LTTNG_UST_CTL_H */