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