Move declarations to global header
[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
MD
18
19/*
20 * ltt_event structure is referred to by the tracing fast path. It must be
21 * kept small.
22 */
23struct ltt_event {
24 unsigned int id;
25 struct ltt_channel *chan;
baf20995 26 void *probe;
4e3c1b9b
MD
27 void *filter;
28 char *name;
baf20995 29 enum instrum_type itype;
4e3c1b9b
MD
30 struct list_head list; /* Event list */
31};
32
11b5a3c2
MD
33struct ltt_channel_ops {
34 struct channel *(*channel_create)(const char *name,
35 struct ltt_session *session,
36 void *buf_addr,
37 size_t subbuf_size, size_t num_subbuf,
38 unsigned int switch_timer_interval,
39 unsigned int read_timer_interval);
40 void (*channel_destroy)(struct channel *chan);
41 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
1c25284c
MD
42 void (*buffer_read_close)(struct lib_ring_buffer *buf);
43 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx);
44 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
e763dbf5
MD
45 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
46 size_t len);
11b5a3c2
MD
47};
48
4e3c1b9b
MD
49struct ltt_channel {
50 struct channel *chan; /* Channel buffers */
51 /* Event ID management */
52 struct ltt_session *session;
d4e1a740 53 struct file *file; /* File associated to channel */
e5382b6d 54 unsigned int free_event_id; /* Next event ID to allocate */
4e3c1b9b 55 struct list_head list; /* Channel list */
653fe716 56 wait_queue_head_t notify_wait; /* Channel addition notif. waitqueue */
11b5a3c2 57 struct ltt_channel_ops *ops;
4e3c1b9b
MD
58};
59
60struct ltt_session {
e5382b6d 61 int active; /* Is trace session active ? */
d4e1a740 62 struct file *file; /* File associated to session */
4e3c1b9b
MD
63 struct list_head chan; /* Channel list head */
64 struct list_head events; /* Event list head */
65 struct list_head list; /* Session list */
4e3c1b9b
MD
66};
67
c0e31d2e
MD
68struct ltt_transport {
69 char *name;
70 struct module *owner;
71 struct list_head node;
11b5a3c2 72 struct ltt_channel_ops ops;
c0e31d2e
MD
73};
74
c0edae1d
MD
75/* Type description */
76
77/* Update the astract_types name table in lttng-types.c along with this enum */
78enum abstract_types {
79 atype_integer,
80 atype_enum,
81 atype_array,
82 atype_sequence,
83 atype_string,
84 NR_ABSTRACT_TYPES,
85};
86
87/* Update the string_encodings name table in lttng-types.c along with this enum */
88enum lttng_string_encodings {
89 lttng_encode_UTF8 = 0,
90 lttng_encode_ASCII = 1,
91 NR_STRING_ENCODINGS,
92};
93
94struct lttng_enum_entry {
95 unsigned long long start, end; /* start and end are inclusive */
96 const char *string;
97};
98
99struct lttng_enum {
100 const struct lttng_enum_entry *entries;
101 unsigned int len;
102};
103
104struct lttng_type {
105 enum abstract_types atype;
106 const char *name;
107 union {
108 struct {
109 unsigned int size; /* in bits */
110 unsigned short alignment; /* in bits */
111 unsigned int signedness:1;
112 unsigned int reverse_byte_order:1;
113 } integer;
114 struct {
115 const char *parent_type;
116 const struct lttng_enum def;
117 } enumeration;
118 struct {
119 const char *elem_type;
120 unsigned int length; /* num. elems. */
121 } array;
122 struct {
123 const char *elem_type;
124 const char *length_type;
125 } sequence;
126 struct {
127 enum lttng_string_encodings encoding;
128 } string;
129 } u;
130} __attribute__((packed));
131
132/* Event field description */
133
134struct lttng_event_field {
135 const char *name;
136 const struct lttng_type type;
137};
138
139struct lttng_event_desc {
140 const struct lttng_event_field *fields;
141 const char *name;
142 void *probe_callback;
143 unsigned int nr_fields;
144};
145
baf20995 146struct ltt_session *ltt_session_create(void);
c0e31d2e
MD
147int ltt_session_start(struct ltt_session *session);
148int ltt_session_stop(struct ltt_session *session);
11b5a3c2 149void ltt_session_destroy(struct ltt_session *session);
4e3c1b9b 150
baf20995 151struct ltt_channel *ltt_channel_create(struct ltt_session *session,
5dbbdb43
MD
152 const char *transport_name,
153 void *buf_addr,
154 size_t subbuf_size, size_t num_subbuf,
155 unsigned int switch_timer_interval,
156 unsigned int read_timer_interval);
157struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
4e3c1b9b
MD
158 int overwrite, void *buf_addr,
159 size_t subbuf_size, size_t num_subbuf,
160 unsigned int switch_timer_interval,
161 unsigned int read_timer_interval);
11b5a3c2 162void _ltt_channel_destroy(struct ltt_channel *chan);
4e3c1b9b 163
653fe716 164struct ltt_event *ltt_event_create(struct ltt_channel *chan,
653fe716 165 char *name,
11b5a3c2
MD
166 enum instrum_type itype,
167 void *probe, void *filter);
dda6a249
MD
168int _ltt_event_unregister(struct ltt_event *event);
169void _ltt_event_destroy(struct ltt_event *event);
c0e31d2e
MD
170
171void ltt_transport_register(struct ltt_transport *transport);
172void ltt_transport_unregister(struct ltt_transport *transport);
11b5a3c2 173
1c25284c
MD
174int ltt_debugfs_abi_init(void);
175void ltt_debugfs_abi_exit(void);
176
02119ee5
MD
177int ltt_probe_register(const char *name, void *cb);
178void ltt_probe_unregister(const char *name);
179void *ltt_probe_get(const char *name);
180void ltt_probe_put(void *cb);
181int ltt_probes_init(void);
182void ltt_probes_exit(void);
183
11b5a3c2 184#endif /* _LTT_EVENTS_H */
This page took 0.030336 seconds and 4 git commands to generate.