Cleanup: apply `include-what-you-use` guideline for `uint*_t`
[lttng-ust.git] / libringbuffer / backend_types.h
... / ...
CommitLineData
1#ifndef _LTTNG_RING_BUFFER_BACKEND_TYPES_H
2#define _LTTNG_RING_BUFFER_BACKEND_TYPES_H
3
4/*
5 * linux/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 <limits.h>
27#include <stdint.h>
28#include "shm_internal.h"
29#include "vatomic.h"
30
31#define RB_BACKEND_PAGES_PADDING 16
32struct lttng_ust_lib_ring_buffer_backend_pages {
33 unsigned long mmap_offset; /* offset of the subbuffer in mmap */
34 union v_atomic records_commit; /* current records committed count */
35 union v_atomic records_unread; /* records to read */
36 unsigned long data_size; /* Amount of data to read from subbuf */
37 DECLARE_SHMP(char, p); /* Backing memory map */
38 char padding[RB_BACKEND_PAGES_PADDING];
39};
40
41struct lttng_ust_lib_ring_buffer_backend_subbuffer {
42 /* Identifier for subbuf backend pages. Exchanged atomically. */
43 unsigned long id; /* backend subbuffer identifier */
44};
45
46struct lttng_ust_lib_ring_buffer_backend_counts {
47 /*
48 * Counter specific to the sub-buffer location within the ring buffer.
49 * The actual sequence number of the packet within the entire ring
50 * buffer can be derived from the formula nr_subbuffers * seq_cnt +
51 * subbuf_idx.
52 */
53 uint64_t seq_cnt; /* packet sequence number */
54};
55
56/*
57 * Forward declaration of frontend-specific channel and ring_buffer.
58 */
59struct channel;
60struct lttng_ust_lib_ring_buffer;
61
62struct lttng_ust_lib_ring_buffer_backend_pages_shmp {
63 DECLARE_SHMP(struct lttng_ust_lib_ring_buffer_backend_pages, shmp);
64};
65
66#define RB_BACKEND_RING_BUFFER_PADDING 64
67struct lttng_ust_lib_ring_buffer_backend {
68 /* Array of ring_buffer_backend_subbuffer for writer */
69 DECLARE_SHMP(struct lttng_ust_lib_ring_buffer_backend_subbuffer, buf_wsb);
70 /* ring_buffer_backend_subbuffer for reader */
71 struct lttng_ust_lib_ring_buffer_backend_subbuffer buf_rsb;
72 /* Array of lib_ring_buffer_backend_counts for the packet counter */
73 DECLARE_SHMP(struct lttng_ust_lib_ring_buffer_backend_counts, buf_cnt);
74 /*
75 * Pointer array of backend pages, for whole buffer.
76 * Indexed by ring_buffer_backend_subbuffer identifier (id) index.
77 */
78 DECLARE_SHMP(struct lttng_ust_lib_ring_buffer_backend_pages_shmp, array);
79 DECLARE_SHMP(char, memory_map); /* memory mapping */
80
81 DECLARE_SHMP(struct channel, chan); /* Associated channel */
82 int cpu; /* This buffer's cpu. -1 if global. */
83 union v_atomic records_read; /* Number of records read */
84 unsigned int allocated:1; /* is buffer allocated ? */
85 char padding[RB_BACKEND_RING_BUFFER_PADDING];
86};
87
88struct lttng_ust_lib_ring_buffer_shmp {
89 DECLARE_SHMP(struct lttng_ust_lib_ring_buffer, shmp); /* Channel per-cpu buffers */
90};
91
92#define RB_BACKEND_CHANNEL_PADDING 64
93struct channel_backend {
94 unsigned long buf_size; /* Size of the buffer */
95 unsigned long subbuf_size; /* Sub-buffer size */
96 unsigned int subbuf_size_order; /* Order of sub-buffer size */
97 unsigned int num_subbuf_order; /*
98 * Order of number of sub-buffers/buffer
99 * for writer.
100 */
101 unsigned int buf_size_order; /* Order of buffer size */
102 unsigned int extra_reader_sb:1; /* has extra reader subbuffer ? */
103 unsigned long num_subbuf; /* Number of sub-buffers for writer */
104 uint64_t start_tsc; /* Channel creation TSC value */
105 DECLARE_SHMP(void *, priv_data);/* Client-specific information */
106 struct lttng_ust_lib_ring_buffer_config config; /* Ring buffer configuration */
107 char name[NAME_MAX]; /* Channel name */
108 char padding[RB_BACKEND_CHANNEL_PADDING];
109 struct lttng_ust_lib_ring_buffer_shmp buf[];
110};
111
112#endif /* _LTTNG_RING_BUFFER_BACKEND_TYPES_H */
This page took 0.022483 seconds and 4 git commands to generate.