Commit | Line | Data |
---|---|---|
99054cee PMF |
1 | #ifndef _LTT_CHANNELS_H |
2 | #define _LTT_CHANNELS_H | |
3 | ||
4 | /* | |
5 | * Copyright (C) 2008 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca) | |
6 | * | |
7 | * Dynamic tracer channel allocation. | |
8fc2d8db PMF |
8 | * |
9 | * This library is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License as published by the Free Software Foundation; either | |
12 | * version 2.1 of the License, or (at your option) any later version. | |
13 | * | |
14 | * This library is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * Lesser General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU Lesser General Public | |
20 | * License along with this library; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
99054cee PMF |
22 | */ |
23 | ||
24 | #include <linux/limits.h> | |
b6bf28ec | 25 | #include <errno.h> |
59b161cd | 26 | |
fbca6b62 | 27 | #include <ust/kernelcompat.h> |
79d4d545 | 28 | #include <kcompat/kref.h> |
99054cee PMF |
29 | |
30 | #define EVENTS_PER_CHANNEL 65536 | |
31 | ||
32 | struct ltt_trace_struct; | |
99054cee | 33 | |
b5b073e2 PMF |
34 | struct ust_buffer; |
35 | ||
36 | struct ust_channel { | |
99054cee PMF |
37 | /* First 32 bytes cache-hot cacheline */ |
38 | struct ltt_trace_struct *trace; | |
39 | void *buf; | |
99054cee PMF |
40 | int overwrite:1; |
41 | int active:1; | |
42 | unsigned int n_subbufs_order; | |
43 | unsigned long commit_count_mask; /* | |
44 | * Commit count mask, removing | |
45 | * the MSBs corresponding to | |
46 | * bits used to represent the | |
47 | * subbuffer index. | |
48 | */ | |
49 | /* End of first 32 bytes cacheline */ | |
50 | ||
51 | /* | |
52 | * buffer_begin - called on buffer-switch to a new sub-buffer | |
53 | * @buf: the channel buffer containing the new sub-buffer | |
54 | */ | |
b5b073e2 | 55 | void (*buffer_begin) (struct ust_buffer *buf, |
99054cee PMF |
56 | u64 tsc, unsigned int subbuf_idx); |
57 | /* | |
58 | * buffer_end - called on buffer-switch to a new sub-buffer | |
59 | * @buf: the channel buffer containing the previous sub-buffer | |
60 | */ | |
b5b073e2 | 61 | void (*buffer_end) (struct ust_buffer *buf, |
99054cee PMF |
62 | u64 tsc, unsigned int offset, unsigned int subbuf_idx); |
63 | struct kref kref; /* Channel transport reference count */ | |
b5b073e2 PMF |
64 | size_t subbuf_size; |
65 | int subbuf_size_order; | |
99054cee PMF |
66 | unsigned int subbuf_cnt; |
67 | const char *channel_name; | |
8cefc145 PMF |
68 | |
69 | int buf_shmid; | |
b5b073e2 PMF |
70 | |
71 | u32 version; | |
72 | size_t alloc_size; | |
73 | struct list_head list; | |
99054cee PMF |
74 | } ____cacheline_aligned; |
75 | ||
76 | struct ltt_channel_setting { | |
77 | unsigned int subbuf_size; | |
78 | unsigned int subbuf_cnt; | |
79 | struct kref kref; /* Number of references to structure content */ | |
80 | struct list_head list; | |
81 | unsigned int index; /* index of channel in trace channel array */ | |
82 | u16 free_event_id; /* Next event ID to allocate */ | |
83 | char name[PATH_MAX]; | |
84 | }; | |
85 | ||
064842c6 PMF |
86 | extern int ltt_channels_register(const char *name); |
87 | extern int ltt_channels_unregister(const char *name); | |
88 | extern int ltt_channels_set_default(const char *name, | |
99054cee PMF |
89 | unsigned int subbuf_size, |
90 | unsigned int subbuf_cnt); | |
064842c6 PMF |
91 | extern const char *ltt_channels_get_name_from_index(unsigned int index); |
92 | extern int ltt_channels_get_index_from_name(const char *name); | |
b5b073e2 | 93 | extern struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels, |
99054cee PMF |
94 | int overwrite, |
95 | int active); | |
b5b073e2 | 96 | extern void ltt_channels_trace_free(struct ust_channel *channels); |
064842c6 PMF |
97 | extern int _ltt_channels_get_event_id(const char *channel, const char *name); |
98 | extern int ltt_channels_get_event_id(const char *channel, const char *name); | |
99054cee PMF |
99 | |
100 | #endif /* _LTT_CHANNELS_H */ |