2 * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
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.h>
13 #include <common/consumer/consumer.h>
20 #ifdef HAVE_LIBLTTNG_UST_CTL
22 int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream
*stream
);
23 int lttng_ustconsumer_sample_snapshot_positions(
24 struct lttng_consumer_stream
*stream
);
26 int lttng_ustconsumer_get_produced_snapshot(
27 struct lttng_consumer_stream
*stream
, unsigned long *pos
);
28 int lttng_ustconsumer_get_consumed_snapshot(
29 struct lttng_consumer_stream
*stream
, unsigned long *pos
);
31 int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data
*ctx
,
32 int sock
, struct pollfd
*consumer_sockpoll
);
34 extern int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel
*chan
);
35 extern void lttng_ustconsumer_del_channel(struct lttng_consumer_channel
*chan
);
36 extern void lttng_ustconsumer_free_channel(struct lttng_consumer_channel
*chan
);
37 extern int lttng_ustconsumer_add_stream(struct lttng_consumer_stream
*stream
);
38 extern void lttng_ustconsumer_del_stream(struct lttng_consumer_stream
*stream
);
40 int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream
*stream
,
41 struct lttng_consumer_local_data
*ctx
);
42 int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream
*stream
);
44 void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream
*stream
);
46 int lttng_ust_flush_buffer(struct lttng_consumer_stream
*stream
,
48 int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream
*stream
,
50 int lttng_ustconsumer_data_pending(struct lttng_consumer_stream
*stream
);
51 void lttng_ustconsumer_close_all_metadata(struct lttng_ht
*ht
);
52 void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel
*metadata
);
53 void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream
*stream
);
54 int lttng_ustconsumer_recv_metadata(int sock
, uint64_t key
, uint64_t offset
,
55 uint64_t len
, uint64_t version
,
56 struct lttng_consumer_channel
*channel
, int timer
, int wait
);
57 int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data
*ctx
,
58 struct lttng_consumer_channel
*channel
, int timer
, int wait
);
59 enum sync_metadata_status
lttng_ustconsumer_sync_metadata(
60 struct lttng_consumer_local_data
*ctx
,
61 struct lttng_consumer_stream
*metadata
);
62 int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream
*stream
,
64 int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream
*stream
);
65 int lttng_ustconsumer_get_current_timestamp(
66 struct lttng_consumer_stream
*stream
, uint64_t *ts
);
67 int lttng_ustconsumer_get_sequence_number(
68 struct lttng_consumer_stream
*stream
, uint64_t *seq
);
69 void lttng_ustconsumer_sigbus_handle(void *addr
);
71 #else /* HAVE_LIBLTTNG_UST_CTL */
74 ssize_t
lttng_ustconsumer_on_read_subbuffer_mmap(
75 struct lttng_consumer_local_data
*ctx
,
76 struct lttng_consumer_stream
*stream
, unsigned long len
,
77 unsigned long padding
)
83 ssize_t
lttng_ustconsumer_on_read_subbuffer_splice(
84 struct lttng_consumer_local_data
*ctx
,
85 struct lttng_consumer_stream
*uststream
, unsigned long len
,
86 unsigned long padding
)
92 int lttng_ustconsumer_take_snapshot(struct lttng_consumer_stream
*stream
)
98 int lttng_ustconsumer_sample_snapshot_positions(
99 struct lttng_consumer_stream
*stream
)
105 int lttng_ustconsumer_get_produced_snapshot(
106 struct lttng_consumer_stream
*stream
, unsigned long *pos
)
112 int lttng_ustconsumer_get_consumed_snapshot(
113 struct lttng_consumer_stream
*stream
, unsigned long *pos
)
119 int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data
*ctx
,
120 int sock
, struct pollfd
*consumer_sockpoll
)
126 int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel
*chan
)
132 void lttng_ustconsumer_del_channel(struct lttng_consumer_channel
*chan
)
137 void lttng_ustconsumer_free_channel(struct lttng_consumer_channel
*chan
)
142 int lttng_ustconsumer_add_stream(struct lttng_consumer_stream
*stream
)
148 void lttng_ustconsumer_del_stream(struct lttng_consumer_stream
*stream
)
153 int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream
*stream
,
154 struct lttng_consumer_local_data
*ctx
)
160 int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream
*stream
)
166 void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream
*stream
)
171 int lttng_ustconsumer_data_pending(struct lttng_consumer_stream
*stream
)
176 int lttng_ust_flush_buffer(struct lttng_consumer_stream
*stream
,
182 void lttng_ustconsumer_close_all_metadata(struct lttng_ht
*ht
)
186 void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel
*metadata
)
190 void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream
*stream
)
194 int lttng_ustconsumer_recv_metadata(int sock
, uint64_t key
, uint64_t offset
,
195 uint64_t len
, uint64_t version
,
196 struct lttng_consumer_channel
*channel
, int timer
)
201 int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data
*ctx
,
202 struct lttng_consumer_channel
*channel
, int timer
, int wait
)
207 enum sync_metadata_status
lttng_ustconsumer_sync_metadata(struct lttng_consumer_local_data
*ctx
,
208 struct lttng_consumer_stream
*metadata
)
210 return SYNC_METADATA_STATUS_ERROR
;
213 int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream
*stream
,
219 int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream
*stream
)
224 int lttng_ustconsumer_get_current_timestamp(
225 struct lttng_consumer_stream
*stream
, uint64_t *ts
)
230 int lttng_ustconsumer_get_sequence_number(
231 struct lttng_consumer_stream
*stream
, uint64_t *seq
)
236 int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream
*stream
,
242 void lttng_ustconsumer_sigbus_handle(void *addr
)
245 #endif /* HAVE_LIBLTTNG_UST_CTL */
251 #endif /* _LTTNG_USTCONSUMER_H */