01ed63b9349aac0a71f25d4912774c7f946e9854
[lttng-modules.git] / lib / ringbuffer / backend_types.h
1 #ifndef _LIB_RING_BUFFER_BACKEND_TYPES_H
2 #define _LIB_RING_BUFFER_BACKEND_TYPES_H
3
4 /*
5 * lib/ringbuffer/backend_types.h
6 *
7 * Ring buffer backend (types).
8 *
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
24 */
25
26 #include <linux/cpumask.h>
27 #include <linux/types.h>
28 #include <lttng-kernel-version.h>
29 #include <lttng-cpuhotplug.h>
30
31 struct lib_ring_buffer_backend_page {
32 void *virt; /* page virtual address (cached) */
33 unsigned long pfn; /* page frame number */
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
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
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;
70 /* Array of lib_ring_buffer_backend_counts for the packet counter */
71 struct lib_ring_buffer_backend_counts *buf_cnt;
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 */
82 unsigned int allocated:1; /* is buffer allocated ? */
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 */
94 unsigned int extra_reader_sb:1; /* has extra reader subbuffer ? */
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 */
100 void *priv_ops; /* Client-specific ops pointer */
101 void (*release_priv_ops)(void *priv_ops);
102 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
103 struct lttng_cpuhp_node cpuhp_prepare; /* CPU hotplug prepare */
104 #else
105 struct notifier_block cpu_hp_notifier; /* CPU hotplug notifier */
106 #endif
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 */
113 cpumask_var_t cpumask; /* Allocated per-cpu buffers cpumask */
114 char name[NAME_MAX]; /* Channel name */
115 };
116
117 #endif /* _LIB_RING_BUFFER_BACKEND_TYPES_H */
This page took 0.03175 seconds and 3 git commands to generate.