Commit | Line | Data |
---|---|---|
886d51a3 MD |
1 | #ifndef _LIB_RING_BUFFER_BACKEND_TYPES_H |
2 | #define _LIB_RING_BUFFER_BACKEND_TYPES_H | |
f3bc08c5 MD |
3 | |
4 | /* | |
886d51a3 | 5 | * lib/ringbuffer/backend_types.h |
f3bc08c5 MD |
6 | * |
7 | * Ring buffer backend (types). | |
8 | * | |
886d51a3 MD |
9 | * Copyright (C) 2008-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
10 | * | |
11 | * This library is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU Lesser General Public | |
13 | * License as published by the Free Software Foundation; only | |
14 | * version 2.1 of the License. | |
15 | * | |
16 | * This library is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | * Lesser General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU Lesser General Public | |
22 | * License along with this library; if not, write to the Free Software | |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
f3bc08c5 MD |
24 | */ |
25 | ||
26 | #include <linux/cpumask.h> | |
27 | #include <linux/types.h> | |
1e367326 MD |
28 | #include <lttng-kernel-version.h> |
29 | #include <lttng-cpuhotplug.h> | |
f3bc08c5 MD |
30 | |
31 | struct lib_ring_buffer_backend_page { | |
32 | void *virt; /* page virtual address (cached) */ | |
0112cb7b | 33 | unsigned long pfn; /* page frame number */ |
f3bc08c5 MD |
34 | }; |
35 | ||
36 | struct lib_ring_buffer_backend_pages { | |
37 | unsigned long mmap_offset; /* offset of the subbuffer in mmap */ | |
38 | union v_atomic records_commit; /* current records committed count */ | |
39 | union v_atomic records_unread; /* records to read */ | |
40 | unsigned long data_size; /* Amount of data to read from subbuf */ | |
41 | struct lib_ring_buffer_backend_page p[]; | |
42 | }; | |
43 | ||
44 | struct lib_ring_buffer_backend_subbuffer { | |
45 | /* Identifier for subbuf backend pages. Exchanged atomically. */ | |
46 | unsigned long id; /* backend subbuffer identifier */ | |
47 | }; | |
48 | ||
5b3cf4f9 JD |
49 | struct lib_ring_buffer_backend_counts { |
50 | /* | |
51 | * Counter specific to the sub-buffer location within the ring buffer. | |
52 | * The actual sequence number of the packet within the entire ring | |
53 | * buffer can be derived from the formula nr_subbuffers * seq_cnt + | |
54 | * subbuf_idx. | |
55 | */ | |
56 | uint64_t seq_cnt; /* packet sequence number */ | |
57 | }; | |
58 | ||
f3bc08c5 MD |
59 | /* |
60 | * Forward declaration of frontend-specific channel and ring_buffer. | |
61 | */ | |
62 | struct channel; | |
63 | struct lib_ring_buffer; | |
64 | ||
65 | struct lib_ring_buffer_backend { | |
66 | /* Array of ring_buffer_backend_subbuffer for writer */ | |
67 | struct lib_ring_buffer_backend_subbuffer *buf_wsb; | |
68 | /* ring_buffer_backend_subbuffer for reader */ | |
69 | struct lib_ring_buffer_backend_subbuffer buf_rsb; | |
5b3cf4f9 JD |
70 | /* Array of lib_ring_buffer_backend_counts for the packet counter */ |
71 | struct lib_ring_buffer_backend_counts *buf_cnt; | |
f3bc08c5 MD |
72 | /* |
73 | * Pointer array of backend pages, for whole buffer. | |
74 | * Indexed by ring_buffer_backend_subbuffer identifier (id) index. | |
75 | */ | |
76 | struct lib_ring_buffer_backend_pages **array; | |
77 | unsigned int num_pages_per_subbuf; | |
78 | ||
79 | struct channel *chan; /* Associated channel */ | |
80 | int cpu; /* This buffer's cpu. -1 if global. */ | |
81 | union v_atomic records_read; /* Number of records read */ | |
9cccf98a | 82 | unsigned int allocated:1; /* is buffer allocated ? */ |
f3bc08c5 MD |
83 | }; |
84 | ||
85 | struct channel_backend { | |
86 | unsigned long buf_size; /* Size of the buffer */ | |
87 | unsigned long subbuf_size; /* Sub-buffer size */ | |
88 | unsigned int subbuf_size_order; /* Order of sub-buffer size */ | |
89 | unsigned int num_subbuf_order; /* | |
90 | * Order of number of sub-buffers/buffer | |
91 | * for writer. | |
92 | */ | |
93 | unsigned int buf_size_order; /* Order of buffer size */ | |
9cccf98a | 94 | unsigned int extra_reader_sb:1; /* has extra reader subbuffer ? */ |
f3bc08c5 MD |
95 | struct lib_ring_buffer *buf; /* Channel per-cpu buffers */ |
96 | ||
97 | unsigned long num_subbuf; /* Number of sub-buffers for writer */ | |
98 | u64 start_tsc; /* Channel creation TSC value */ | |
99 | void *priv; /* Client-specific information */ | |
dd5a0db3 MD |
100 | void *priv_ops; /* Client-specific ops pointer */ |
101 | void (*release_priv_ops)(void *priv_ops); | |
1e367326 MD |
102 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) |
103 | struct lttng_cpuhp_node cpuhp_prepare; /* CPU hotplug prepare */ | |
104 | #else | |
f3bc08c5 | 105 | struct notifier_block cpu_hp_notifier; /* CPU hotplug notifier */ |
1e367326 | 106 | #endif |
5a8fd222 MD |
107 | /* |
108 | * We need to copy config because the module containing the | |
109 | * source config can vanish before the last reference to this | |
110 | * channel's streams is released. | |
111 | */ | |
112 | struct lib_ring_buffer_config config; /* Ring buffer configuration */ | |
f3bc08c5 MD |
113 | cpumask_var_t cpumask; /* Allocated per-cpu buffers cpumask */ |
114 | char name[NAME_MAX]; /* Channel name */ | |
115 | }; | |
116 | ||
886d51a3 | 117 | #endif /* _LIB_RING_BUFFER_BACKEND_TYPES_H */ |