1 #ifndef _LIB_RING_BUFFER_BACKEND_TYPES_H
2 #define _LIB_RING_BUFFER_BACKEND_TYPES_H
5 * lib/ringbuffer/backend_types.h
7 * Ring buffer backend (types).
9 * Copyright (C) 2008-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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.
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
26 #include <linux/cpumask.h>
27 #include <linux/types.h>
29 struct lib_ring_buffer_backend_page
{
30 void *virt
; /* page virtual address (cached) */
31 struct page
*page
; /* pointer to page structure */
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
[];
42 struct lib_ring_buffer_backend_subbuffer
{
43 /* Identifier for subbuf backend pages. Exchanged atomically. */
44 unsigned long id
; /* backend subbuffer identifier */
48 * Forward declaration of frontend-specific channel and ring_buffer.
51 struct lib_ring_buffer
;
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
;
59 * Pointer array of backend pages, for whole buffer.
60 * Indexed by ring_buffer_backend_subbuffer identifier (id) index.
62 struct lib_ring_buffer_backend_pages
**array
;
63 unsigned int num_pages_per_subbuf
;
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 */
68 unsigned int allocated
:1; /* is buffer allocated ? */
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
79 unsigned int buf_size_order
; /* Order of buffer size */
80 unsigned int extra_reader_sb
:1; /* has extra reader subbuffer ? */
81 struct lib_ring_buffer
*buf
; /* Channel per-cpu buffers */
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 */
86 struct notifier_block cpu_hp_notifier
; /* CPU hotplug notifier */
88 * We need to copy config because the module containing the
89 * source config can vanish before the last reference to this
90 * channel's streams is released.
92 struct lib_ring_buffer_config config
; /* Ring buffer configuration */
93 cpumask_var_t cpumask
; /* Allocated per-cpu buffers cpumask */
94 char name
[NAME_MAX
]; /* Channel name */
97 #endif /* _LIB_RING_BUFFER_BACKEND_TYPES_H */