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> | |
28 | ||
29 | struct lib_ring_buffer_backend_page { | |
30 | void *virt; /* page virtual address (cached) */ | |
31 | struct page *page; /* pointer to page structure */ | |
32 | }; | |
33 | ||
34 | struct lib_ring_buffer_backend_pages { | |
35 | unsigned long mmap_offset; /* offset of the subbuffer in mmap */ | |
36 | union v_atomic records_commit; /* current records committed count */ | |
37 | union v_atomic records_unread; /* records to read */ | |
38 | unsigned long data_size; /* Amount of data to read from subbuf */ | |
39 | struct lib_ring_buffer_backend_page p[]; | |
40 | }; | |
41 | ||
42 | struct lib_ring_buffer_backend_subbuffer { | |
43 | /* Identifier for subbuf backend pages. Exchanged atomically. */ | |
44 | unsigned long id; /* backend subbuffer identifier */ | |
45 | }; | |
46 | ||
47 | /* | |
48 | * Forward declaration of frontend-specific channel and ring_buffer. | |
49 | */ | |
50 | struct channel; | |
51 | struct lib_ring_buffer; | |
52 | ||
53 | struct lib_ring_buffer_backend { | |
54 | /* Array of ring_buffer_backend_subbuffer for writer */ | |
55 | struct lib_ring_buffer_backend_subbuffer *buf_wsb; | |
56 | /* ring_buffer_backend_subbuffer for reader */ | |
57 | struct lib_ring_buffer_backend_subbuffer buf_rsb; | |
58 | /* | |
59 | * Pointer array of backend pages, for whole buffer. | |
60 | * Indexed by ring_buffer_backend_subbuffer identifier (id) index. | |
61 | */ | |
62 | struct lib_ring_buffer_backend_pages **array; | |
63 | unsigned int num_pages_per_subbuf; | |
64 | ||
65 | struct channel *chan; /* Associated channel */ | |
66 | int cpu; /* This buffer's cpu. -1 if global. */ | |
67 | union v_atomic records_read; /* Number of records read */ | |
9cccf98a | 68 | unsigned int allocated:1; /* is buffer allocated ? */ |
f3bc08c5 MD |
69 | }; |
70 | ||
71 | struct channel_backend { | |
72 | unsigned long buf_size; /* Size of the buffer */ | |
73 | unsigned long subbuf_size; /* Sub-buffer size */ | |
74 | unsigned int subbuf_size_order; /* Order of sub-buffer size */ | |
75 | unsigned int num_subbuf_order; /* | |
76 | * Order of number of sub-buffers/buffer | |
77 | * for writer. | |
78 | */ | |
79 | unsigned int buf_size_order; /* Order of buffer size */ | |
9cccf98a | 80 | unsigned int extra_reader_sb:1; /* has extra reader subbuffer ? */ |
f3bc08c5 MD |
81 | struct lib_ring_buffer *buf; /* Channel per-cpu buffers */ |
82 | ||
83 | unsigned long num_subbuf; /* Number of sub-buffers for writer */ | |
84 | u64 start_tsc; /* Channel creation TSC value */ | |
85 | void *priv; /* Client-specific information */ | |
dd5a0db3 MD |
86 | void *priv_ops; /* Client-specific ops pointer */ |
87 | void (*release_priv_ops)(void *priv_ops); | |
f3bc08c5 | 88 | struct notifier_block cpu_hp_notifier; /* CPU hotplug notifier */ |
5a8fd222 MD |
89 | /* |
90 | * We need to copy config because the module containing the | |
91 | * source config can vanish before the last reference to this | |
92 | * channel's streams is released. | |
93 | */ | |
94 | struct lib_ring_buffer_config config; /* Ring buffer configuration */ | |
f3bc08c5 MD |
95 | cpumask_var_t cpumask; /* Allocated per-cpu buffers cpumask */ |
96 | char name[NAME_MAX]; /* Channel name */ | |
97 | }; | |
98 | ||
886d51a3 | 99 | #endif /* _LIB_RING_BUFFER_BACKEND_TYPES_H */ |