Add metadata channel, basic test passes
[lttng-modules.git] / ltt-events.h
CommitLineData
11b5a3c2
MD
1#ifndef _LTT_EVENTS_H
2#define _LTT_EVENTS_H
3
4e3c1b9b
MD
4/*
5 * ltt-events.h
6 *
7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Holds LTTng per-session event registry.
10 */
11
12#include <linux/list.h>
11b5a3c2 13#include "ltt-debugfs-abi.h"
4e3c1b9b
MD
14
15struct ltt_channel;
16struct ltt_session;
1c25284c 17struct lib_ring_buffer_ctx;
4e3c1b9b 18
c0edae1d
MD
19/* Type description */
20
21/* Update the astract_types name table in lttng-types.c along with this enum */
22enum abstract_types {
23 atype_integer,
24 atype_enum,
25 atype_array,
26 atype_sequence,
27 atype_string,
28 NR_ABSTRACT_TYPES,
29};
30
31/* Update the string_encodings name table in lttng-types.c along with this enum */
32enum lttng_string_encodings {
33 lttng_encode_UTF8 = 0,
34 lttng_encode_ASCII = 1,
35 NR_STRING_ENCODINGS,
36};
37
38struct lttng_enum_entry {
39 unsigned long long start, end; /* start and end are inclusive */
40 const char *string;
41};
42
c099397a
MD
43#define __type_integer(_type, _byte_order) \
44 { \
45 .atype = atype_integer, \
46 .u.basic.integer = \
47 { \
48 .size = sizeof(_type), \
49 .alignment = __alignof__(_type), \
50 .signedness = is_signed_type(_type), \
51 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
52 }, \
53 } \
54
55struct lttng_integer_type {
56 unsigned int size; /* in bits */
57 unsigned short alignment; /* in bits */
58 unsigned int signedness:1;
59 unsigned int reverse_byte_order:1;
60};
61
62union _lttng_basic_type {
63 struct lttng_integer_type integer;
64 struct {
65 const char *name;
66 } enumeration;
67 struct {
68 enum lttng_string_encodings encoding;
69 } string;
70};
71
72struct lttng_basic_type {
73 enum abstract_types atype;
74 union {
75 union _lttng_basic_type basic;
76 } u;
c0edae1d
MD
77};
78
79struct lttng_type {
80 enum abstract_types atype;
c0edae1d 81 union {
c099397a 82 union _lttng_basic_type basic;
c0edae1d 83 struct {
c099397a 84 struct lttng_basic_type elem_type;
c0edae1d
MD
85 unsigned int length; /* num. elems. */
86 } array;
87 struct {
c099397a
MD
88 struct lttng_basic_type length_type;
89 struct lttng_basic_type elem_type;
c0edae1d 90 } sequence;
c0edae1d 91 } u;
c099397a
MD
92};
93
94struct lttng_enum {
95 const char *name;
96 struct lttng_type container_type;
97 const struct lttng_enum_entry *entries;
98 unsigned int len;
99};
c0edae1d
MD
100
101/* Event field description */
102
103struct lttng_event_field {
104 const char *name;
105 const struct lttng_type type;
106};
107
108struct lttng_event_desc {
109 const struct lttng_event_field *fields;
110 const char *name;
111 void *probe_callback;
112 unsigned int nr_fields;
113};
114
85a9ca7f
MD
115struct lttng_probe_desc {
116 const struct lttng_event_desc *event_desc;
117 unsigned int nr_events;
118 struct list_head head; /* chain registered probes */
119};
120
121/*
122 * ltt_event structure is referred to by the tracing fast path. It must be
123 * kept small.
124 */
125struct ltt_event {
126 unsigned int id;
127 struct ltt_channel *chan;
128 const struct lttng_event_desc *desc;
129 void *filter;
130 enum instrum_type itype;
131 struct list_head list; /* Event list */
c099397a 132 int metadata_dumped:1;
85a9ca7f
MD
133};
134
135struct ltt_channel_ops {
136 struct channel *(*channel_create)(const char *name,
137 struct ltt_session *session,
138 void *buf_addr,
139 size_t subbuf_size, size_t num_subbuf,
140 unsigned int switch_timer_interval,
141 unsigned int read_timer_interval);
142 void (*channel_destroy)(struct channel *chan);
143 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
144 void (*buffer_read_close)(struct lib_ring_buffer *buf);
145 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx);
146 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
147 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
148 size_t len);
c099397a 149 wait_queue_head_t *(*get_reader_wait_queue)(struct ltt_channel *chan);
85a9ca7f
MD
150};
151
152struct ltt_channel {
c099397a 153 unsigned int id;
85a9ca7f
MD
154 struct channel *chan; /* Channel buffers */
155 /* Event ID management */
156 struct ltt_session *session;
157 struct file *file; /* File associated to channel */
158 unsigned int free_event_id; /* Next event ID to allocate */
159 struct list_head list; /* Channel list */
160 wait_queue_head_t notify_wait; /* Channel addition notif. waitqueue */
161 struct ltt_channel_ops *ops;
c099397a
MD
162 int metadata_dumped:1;
163 int header_type:2; /* 0: unset, 1: compact, 2: large */
85a9ca7f
MD
164};
165
166struct ltt_session {
167 int active; /* Is trace session active ? */
168 struct file *file; /* File associated to session */
c099397a 169 struct ltt_channel *metadata; /* Metadata channel */
85a9ca7f
MD
170 struct list_head chan; /* Channel list head */
171 struct list_head events; /* Event list head */
172 struct list_head list; /* Session list */
c099397a
MD
173 unsigned int free_chan_id; /* Next chan ID to allocate */
174 int metadata_dumped:1;
85a9ca7f
MD
175};
176
177struct ltt_transport {
178 char *name;
179 struct module *owner;
180 struct list_head node;
181 struct ltt_channel_ops ops;
182};
183
baf20995 184struct ltt_session *ltt_session_create(void);
c0e31d2e
MD
185int ltt_session_start(struct ltt_session *session);
186int ltt_session_stop(struct ltt_session *session);
11b5a3c2 187void ltt_session_destroy(struct ltt_session *session);
4e3c1b9b 188
baf20995 189struct ltt_channel *ltt_channel_create(struct ltt_session *session,
5dbbdb43
MD
190 const char *transport_name,
191 void *buf_addr,
192 size_t subbuf_size, size_t num_subbuf,
193 unsigned int switch_timer_interval,
194 unsigned int read_timer_interval);
195struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
4e3c1b9b
MD
196 int overwrite, void *buf_addr,
197 size_t subbuf_size, size_t num_subbuf,
198 unsigned int switch_timer_interval,
199 unsigned int read_timer_interval);
11b5a3c2 200void _ltt_channel_destroy(struct ltt_channel *chan);
4e3c1b9b 201
653fe716 202struct ltt_event *ltt_event_create(struct ltt_channel *chan,
653fe716 203 char *name,
11b5a3c2 204 enum instrum_type itype,
85a9ca7f
MD
205 const struct lttng_event_desc *event_desc,
206 void *filter);
dda6a249
MD
207int _ltt_event_unregister(struct ltt_event *event);
208void _ltt_event_destroy(struct ltt_event *event);
c0e31d2e
MD
209
210void ltt_transport_register(struct ltt_transport *transport);
211void ltt_transport_unregister(struct ltt_transport *transport);
11b5a3c2 212
1c25284c
MD
213int ltt_debugfs_abi_init(void);
214void ltt_debugfs_abi_exit(void);
215
85a9ca7f
MD
216int ltt_probe_register(struct lttng_probe_desc *desc);
217void ltt_probe_unregister(struct lttng_probe_desc *desc);
218const struct lttng_event_desc *ltt_event_get(const char *name);
219void ltt_event_put(const struct lttng_event_desc *desc);
cd4bd11f
MD
220int ltt_probes_init(void);
221void ltt_probes_exit(void);
02119ee5 222
11b5a3c2 223#endif /* _LTT_EVENTS_H */
This page took 0.032592 seconds and 4 git commands to generate.