2 * Copyright (C) 2011 EfficiOS Inc.
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * SPDX-License-Identifier: GPL-2.0-only
9 #ifndef _LTTNG_USTCONSUMER_H
10 #define _LTTNG_USTCONSUMER_H
12 #include <common/compat/errno.hpp>
13 #include <common/consumer/consumer.hpp>
17 #ifdef HAVE_LIBLTTNG_UST_CTL
19 int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream *stream);
20 int lttng_ustconsumer_sample_snapshot_positions(struct lttng_consumer_stream *stream);
22 int lttng_ustconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream,
24 int lttng_ustconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream,
27 int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
29 struct pollfd *consumer_sockpoll);
31 extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan);
32 extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan);
33 extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream);
34 extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream);
36 int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
37 struct lttng_consumer_local_data *ctx);
38 int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
40 void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream);
42 int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream, int producer_active);
43 int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream, uint64_t *stream_id);
44 int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream);
45 void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht);
46 void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata);
47 void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream);
48 int lttng_ustconsumer_recv_metadata(int sock,
53 struct lttng_consumer_channel *channel,
56 int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
57 struct lttng_consumer_channel *channel,
60 enum sync_metadata_status lttng_ustconsumer_sync_metadata(struct lttng_consumer_local_data *ctx,
61 struct lttng_consumer_stream *metadata);
62 int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream, int producer);
63 int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
64 int lttng_ustconsumer_get_current_timestamp(struct lttng_consumer_stream *stream, uint64_t *ts);
65 int lttng_ustconsumer_get_sequence_number(struct lttng_consumer_stream *stream, uint64_t *seq);
66 void lttng_ustconsumer_sigbus_handle(void *addr);
68 #else /* HAVE_LIBLTTNG_UST_CTL */
70 static inline ssize_t lttng_ustconsumer_on_read_subbuffer_mmap(
71 struct lttng_consumer_local_data *ctx __attribute__((unused)),
72 struct lttng_consumer_stream *stream __attribute__((unused)),
73 unsigned long len __attribute__((unused)),
74 unsigned long padding __attribute__((unused)))
79 static inline ssize_t lttng_ustconsumer_on_read_subbuffer_splice(
80 struct lttng_consumer_local_data *ctx __attribute__((unused)),
81 struct lttng_consumer_stream *uststream __attribute__((unused)),
82 unsigned long len __attribute__((unused)),
83 unsigned long padding __attribute__((unused)))
88 static inline int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream *stream
89 __attribute__((unused)))
94 static inline int lttng_ustconsumer_sample_snapshot_positions(struct lttng_consumer_stream *stream
95 __attribute__((unused)))
100 static inline int lttng_ustconsumer_get_produced_snapshot(struct lttng_consumer_stream *stream
101 __attribute__((unused)),
103 __attribute__((unused)))
108 static inline int lttng_ustconsumer_get_consumed_snapshot(struct lttng_consumer_stream *stream
109 __attribute__((unused)),
111 __attribute__((unused)))
116 static inline int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx
117 __attribute__((unused)),
118 int sock __attribute__((unused)),
119 struct pollfd *consumer_sockpoll
120 __attribute__((unused)))
125 static inline void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan
126 __attribute__((unused)))
130 static inline void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan
131 __attribute__((unused)))
135 static inline int lttng_ustconsumer_add_stream(struct lttng_consumer_stream *stream
136 __attribute__((unused)))
141 static inline void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream
142 __attribute__((unused)))
146 static inline int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream
147 __attribute__((unused)),
148 struct lttng_consumer_local_data *ctx
149 __attribute__((unused)))
154 static inline int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream
155 __attribute__((unused)))
160 static inline void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream
161 __attribute__((unused)))
165 static inline int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream
166 __attribute__((unused)))
171 static inline int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream
172 __attribute__((unused)),
173 int producer_active __attribute__((unused)))
178 static inline void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht __attribute__((unused)))
182 static inline void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata
183 __attribute__((unused)))
186 static inline void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream
187 __attribute__((unused)))
191 static inline int lttng_ustconsumer_recv_metadata(int sock __attribute__((unused)),
192 uint64_t key __attribute__((unused)),
193 uint64_t offset __attribute__((unused)),
194 uint64_t len __attribute__((unused)),
195 uint64_t version __attribute__((unused)),
196 struct lttng_consumer_channel *channel
197 __attribute__((unused)),
198 int timer __attribute__((unused)))
203 static inline int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx
204 __attribute__((unused)),
205 struct lttng_consumer_channel *channel
206 __attribute__((unused)),
207 int timer __attribute__((unused)),
208 int wait __attribute__((unused)))
213 static inline enum sync_metadata_status
214 lttng_ustconsumer_sync_metadata(struct lttng_consumer_local_data *ctx __attribute__((unused)),
215 struct lttng_consumer_stream *metadata __attribute__((unused)))
217 return SYNC_METADATA_STATUS_ERROR;
220 static inline int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream
221 __attribute__((unused)),
222 int producer __attribute__((unused)))
227 static inline int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream
228 __attribute__((unused)))
233 static inline int lttng_ustconsumer_get_current_timestamp(struct lttng_consumer_stream *stream
234 __attribute__((unused)),
235 uint64_t *ts __attribute__((unused)))
240 static inline int lttng_ustconsumer_get_sequence_number(struct lttng_consumer_stream *stream
241 __attribute__((unused)),
242 uint64_t *seq __attribute__((unused)))
247 static inline int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream
248 __attribute__((unused)),
249 uint64_t *stream_id __attribute__((unused)))
254 static inline void lttng_ustconsumer_sigbus_handle(void *addr __attribute__((unused)))
257 #endif /* HAVE_LIBLTTNG_UST_CTL */
259 #endif /* _LTTNG_USTCONSUMER_H */