Commit | Line | Data |
---|---|---|
f3105c67 MD |
1 | /* |
2 | * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca> | |
3 | * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License | |
7 | * as published by the Free Software Foundation; only version 2 | |
8 | * of the License. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | */ | |
19 | ||
20 | #ifndef _LTTNG_UST_CTL_H | |
21 | #define _LTTNG_UST_CTL_H | |
22 | ||
23 | #include <ust/lttng-ust-abi.h> | |
24 | ||
25 | /* | |
26 | * Tracer channel attributes. | |
27 | */ | |
28 | struct lttng_ust_channel_attr { | |
29 | int overwrite; /* 1: overwrite, 0: discard */ | |
30 | uint64_t subbuf_size; /* bytes */ | |
31 | uint64_t num_subbuf; /* power of 2 */ | |
32 | unsigned int switch_timer_interval; /* usec */ | |
33 | unsigned int read_timer_interval; /* usec */ | |
34 | enum lttng_ust_output output; /* splice, mmap */ | |
35 | }; | |
36 | ||
37 | struct object_data { | |
38 | int handle; | |
39 | int shm_fd; | |
40 | int wait_fd; | |
41 | uint64_t memory_map_size; | |
42 | }; | |
43 | ||
44 | int ustctl_create_session(int sock); | |
45 | int ustctl_open_metadata(int sock, int session_handle, | |
46 | struct lttng_ust_channel_attr *chops, | |
47 | struct object_data **metadata_data); | |
48 | int ustctl_create_channel(int sock, int session_handle, | |
49 | struct lttng_ust_channel_attr *chops, | |
50 | struct object_data **channel_data); | |
51 | int ustctl_create_stream(int sock, struct object_data *channel_data, | |
52 | struct object_data **stream_data); | |
53 | int ustctl_create_event(int sock, struct lttng_ust_event *ev, | |
54 | struct object_data *channel_data, | |
55 | struct object_data **event_data); | |
56 | int ustctl_add_context(int sock, struct lttng_ust_context *ctx, | |
57 | struct object_data *channel_data, | |
58 | struct object_data **context_data); | |
59 | ||
60 | int ustctl_enable(int sock, struct object_data *object); | |
61 | int ustctl_disable(int sock, struct object_data *object); | |
62 | int ustctl_start_session(int sock, struct object_data *object); | |
63 | int ustctl_stop_session(int sock, struct object_data *object); | |
64 | ||
65 | int ustctl_tracepoint_list(int sock); /* not implemented yet */ | |
66 | int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v); | |
67 | int ustctl_wait_quiescent(int sock); | |
68 | ||
69 | /* not implemented yet */ | |
70 | struct lttng_ust_calibrate; | |
71 | int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate); | |
72 | ||
f3105c67 MD |
73 | /* |
74 | * Map channel shm_handle and add streams. Typically performed by the | |
75 | * consumer to map the objects into its memory space. | |
76 | */ | |
77 | struct shm_handle *ustctl_map_channel(struct object_data *chan_data); | |
78 | int ustctl_add_stream(struct shm_handle *shm_handle, | |
79 | struct object_data *stream_data); | |
5224b5c8 MD |
80 | /* |
81 | * Note: the object_data from which the shm_handle is derived can only | |
82 | * be released after unmapping the handle. | |
83 | */ | |
84 | void ustctl_unmap_channel(struct shm_handle *shm_handle); | |
f3105c67 MD |
85 | |
86 | /* Buffer operations */ | |
87 | ||
88 | struct shm_handle; | |
89 | struct lib_ring_buffer; | |
90 | ||
9095efe9 MD |
91 | void *ustctl_get_mmap_base(struct shm_handle *handle, |
92 | struct lib_ring_buffer *buf); | |
93 | ||
6e922b24 MD |
94 | /* Open/close stream buffers for read */ |
95 | struct lib_ring_buffer *ustctl_open_stream_read(struct shm_handle *handle, | |
96 | int cpu); | |
97 | void ustctl_close_stream_read(struct shm_handle *handle, | |
98 | struct lib_ring_buffer *buf); | |
99 | ||
f3105c67 MD |
100 | /* For mmap mode, readable without "get" operation */ |
101 | int ustctl_get_mmap_len(struct shm_handle *handle, | |
102 | struct lib_ring_buffer *buf, | |
103 | unsigned long *len); | |
104 | int ustctl_get_max_subbuf_size(struct shm_handle *handle, | |
105 | struct lib_ring_buffer *buf, | |
106 | unsigned long *len); | |
107 | ||
108 | /* | |
109 | * For mmap mode, operate on the current packet (between get/put or | |
110 | * get_next/put_next). | |
111 | */ | |
9095efe9 MD |
112 | void *ustctl_get_mmap_base(struct shm_handle *handle, |
113 | struct lib_ring_buffer *buf); | |
f3105c67 MD |
114 | int ustctl_get_mmap_read_offset(struct shm_handle *handle, |
115 | struct lib_ring_buffer *buf, unsigned long *off); | |
116 | int ustctl_get_subbuf_size(struct shm_handle *handle, | |
117 | struct lib_ring_buffer *buf, unsigned long *len); | |
118 | int ustctl_get_padded_subbuf_size(struct shm_handle *handle, | |
119 | struct lib_ring_buffer *buf, unsigned long *len); | |
120 | int ustctl_get_next_subbuf(struct shm_handle *handle, | |
121 | struct lib_ring_buffer *buf); | |
122 | int ustctl_put_next_subbuf(struct shm_handle *handle, | |
123 | struct lib_ring_buffer *buf); | |
124 | ||
125 | /* snapshot */ | |
126 | ||
127 | int ustctl_snapshot(struct shm_handle *handle, | |
128 | struct lib_ring_buffer *buf); | |
129 | int ustctl_snapshot_get_consumed(struct shm_handle *handle, | |
130 | struct lib_ring_buffer *buf, unsigned long *pos); | |
131 | int ustctl_snapshot_get_produced(struct shm_handle *handle, | |
132 | struct lib_ring_buffer *buf, unsigned long *pos); | |
133 | int ustctl_get_subbuf(struct shm_handle *handle, | |
134 | struct lib_ring_buffer *buf, unsigned long *pos); | |
135 | int ustctl_put_subbuf(struct shm_handle *handle, | |
136 | struct lib_ring_buffer *buf); | |
137 | ||
138 | /* Release object created by members of this API */ | |
139 | void release_object(int sock, struct object_data *data); | |
140 | ||
141 | #endif /* _LTTNG_UST_CTL_H */ |