| 1 | /* |
| 2 | * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca> |
| 3 | * Copyright (C) 2011-2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | * |
| 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. |
| 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 | * |
| 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. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _LTTNG_UST_CTL_H |
| 20 | #define _LTTNG_UST_CTL_H |
| 21 | |
| 22 | #include <lttng/ust-abi.h> |
| 23 | |
| 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 | |
| 32 | struct lttng_ust_shm_handle; |
| 33 | struct lttng_ust_lib_ring_buffer; |
| 34 | |
| 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 */ |
| 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 | */ |
| 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); |
| 65 | |
| 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); |
| 70 | |
| 71 | /* |
| 72 | * ustctl_tracepoint_list returns a tracepoint list handle, or negative |
| 73 | * error value. |
| 74 | */ |
| 75 | int ustctl_tracepoint_list(int sock); |
| 76 | |
| 77 | /* |
| 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 |
| 80 | * returned. |
| 81 | */ |
| 82 | int ustctl_tracepoint_list_get(int sock, int tp_list_handle, |
| 83 | struct lttng_ust_tracepoint_iter *iter); |
| 84 | |
| 85 | /* |
| 86 | * ustctl_tracepoint_field_list returns a tracepoint field list handle, |
| 87 | * or negative error value. |
| 88 | */ |
| 89 | int ustctl_tracepoint_field_list(int sock); |
| 90 | |
| 91 | /* |
| 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 |
| 94 | * returned. |
| 95 | */ |
| 96 | int ustctl_tracepoint_field_list_get(int sock, int tp_field_list_handle, |
| 97 | struct lttng_ust_field_iter *iter); |
| 98 | |
| 99 | int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v); |
| 100 | int ustctl_wait_quiescent(int sock); |
| 101 | |
| 102 | int ustctl_sock_flush_buffer(int sock, struct lttng_ust_object_data *object); |
| 103 | |
| 104 | int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate); |
| 105 | |
| 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); |
| 110 | |
| 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); |
| 120 | |
| 121 | /* |
| 122 | * API used by consumer. |
| 123 | */ |
| 124 | |
| 125 | struct ustctl_consumer_channel; |
| 126 | struct ustctl_consumer_stream; |
| 127 | struct ustctl_consumer_channel_attr; |
| 128 | |
| 129 | struct ustctl_consumer_channel * |
| 130 | ustctl_create_channel(struct ustctl_consumer_channel_attr *attr); |
| 131 | /* |
| 132 | * Each stream created needs to be destroyed before calling |
| 133 | * ustctl_destroy_channel(). |
| 134 | */ |
| 135 | void ustctl_destroy_channel(struct ustctl_consumer_channel *chan); |
| 136 | |
| 137 | int ustctl_send_channel_to_sessiond(int sock, |
| 138 | struct ustctl_consumer_channel *channel); |
| 139 | int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan); |
| 140 | int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan); |
| 141 | int ustctl_channel_get_wait_fd(struct ustctl_consumer_channel *consumer_chan); |
| 142 | int ustctl_channel_get_wakeup_fd(struct ustctl_consumer_channel *consumer_chan); |
| 143 | |
| 144 | /* |
| 145 | * Send a NULL stream to finish iteration over all streams of a given |
| 146 | * channel. |
| 147 | */ |
| 148 | int ustctl_send_stream_to_sessiond(int sock, |
| 149 | struct ustctl_consumer_stream *stream); |
| 150 | int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream); |
| 151 | int ustctl_stream_close_wakeup_fd(struct ustctl_consumer_stream *stream); |
| 152 | int ustctl_stream_get_wait_fd(struct ustctl_consumer_stream *stream); |
| 153 | int ustctl_stream_get_wakeup_fd(struct ustctl_consumer_stream *stream); |
| 154 | |
| 155 | /* Create/destroy stream buffers for read */ |
| 156 | struct ustctl_consumer_stream * |
| 157 | ustctl_create_stream(struct ustctl_consumer_channel *channel, |
| 158 | int cpu); |
| 159 | void ustctl_destroy_stream(struct ustctl_consumer_stream *stream); |
| 160 | |
| 161 | /* For mmap mode, readable without "get" operation */ |
| 162 | int ustctl_get_mmap_len(struct ustctl_consumer_stream *stream, |
| 163 | unsigned long *len); |
| 164 | int ustctl_get_max_subbuf_size(struct ustctl_consumer_stream *stream, |
| 165 | unsigned long *len); |
| 166 | |
| 167 | /* |
| 168 | * For mmap mode, operate on the current packet (between get/put or |
| 169 | * get_next/put_next). |
| 170 | */ |
| 171 | void *ustctl_get_mmap_base(struct ustctl_consumer_stream *stream); |
| 172 | int ustctl_get_mmap_read_offset(struct ustctl_consumer_stream *stream, |
| 173 | unsigned long *off); |
| 174 | int ustctl_get_subbuf_size(struct ustctl_consumer_stream *stream, |
| 175 | unsigned long *len); |
| 176 | int ustctl_get_padded_subbuf_size(struct ustctl_consumer_stream *stream, |
| 177 | unsigned long *len); |
| 178 | int ustctl_get_next_subbuf(struct ustctl_consumer_stream *stream); |
| 179 | int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream); |
| 180 | |
| 181 | /* snapshot */ |
| 182 | |
| 183 | int ustctl_snapshot(struct ustctl_consumer_stream *stream); |
| 184 | int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream, |
| 185 | unsigned long *pos); |
| 186 | int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream, |
| 187 | unsigned long *pos); |
| 188 | int ustctl_get_subbuf(struct ustctl_consumer_stream *stream, |
| 189 | unsigned long *pos); |
| 190 | int ustctl_put_subbuf(struct ustctl_consumer_stream *stream); |
| 191 | |
| 192 | void ustctl_flush_buffer(struct ustctl_consumer_stream *stream, |
| 193 | int producer_active); |
| 194 | |
| 195 | #endif /* _LTTNG_UST_CTL_H */ |