Namespace LTTng modules ABI with lttng_kernel_abi_ prefix
[lttng-modules.git] / include / ringbuffer / vfs.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
9f36eaed 2 *
24591303 3 * ringbuffer/vfs.h
f3bc08c5
MD
4 *
5 * Wait-free ring buffer VFS file operations.
6 *
886d51a3 7 * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f3bc08c5
MD
8 */
9
9f36eaed
MJ
10#ifndef _LIB_RING_BUFFER_VFS_H
11#define _LIB_RING_BUFFER_VFS_H
12
f3bc08c5
MD
13#include <linux/fs.h>
14#include <linux/poll.h>
15
16/* VFS API */
17
18extern const struct file_operations lib_ring_buffer_file_operations;
19
20/*
21 * Internal file operations.
22 */
23
d83004aa
JD
24struct lib_ring_buffer;
25
26int lib_ring_buffer_open(struct inode *inode, struct file *file,
27 struct lib_ring_buffer *buf);
28int lib_ring_buffer_release(struct inode *inode, struct file *file,
29 struct lib_ring_buffer *buf);
30unsigned int lib_ring_buffer_poll(struct file *filp, poll_table *wait,
31 struct lib_ring_buffer *buf);
f3bc08c5 32ssize_t lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
d83004aa
JD
33 struct pipe_inode_info *pipe, size_t len,
34 unsigned int flags, struct lib_ring_buffer *buf);
35int lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma,
36 struct lib_ring_buffer *buf);
f3bc08c5
MD
37
38/* Ring Buffer ioctl() and ioctl numbers */
d83004aa
JD
39long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd,
40 unsigned long arg, struct lib_ring_buffer *buf);
f3bc08c5
MD
41#ifdef CONFIG_COMPAT
42long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
d83004aa 43 unsigned long arg, struct lib_ring_buffer *buf);
f3bc08c5
MD
44#endif
45
d83004aa
JD
46ssize_t vfs_lib_ring_buffer_file_splice_read(struct file *in, loff_t *ppos,
47 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
48loff_t vfs_lib_ring_buffer_no_llseek(struct file *file, loff_t offset,
49 int origin);
50int vfs_lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma);
51ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
52 struct pipe_inode_info *pipe, size_t len,
53 unsigned int flags);
54
f3bc08c5 55/*
606828e4 56 * Use LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF / LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF to read and
f3bc08c5
MD
57 * consume sub-buffers sequentially.
58 *
59 * Reading sub-buffers without consuming them can be performed with:
60 *
606828e4
MD
61 * LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT
62 * LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED
63 * LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED
f3bc08c5
MD
64 *
65 * to get the offset range to consume, and then by passing each sub-buffer
66 * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it
67 * with RING_BUFFER_PUT_SUBBUF.
68 *
69 * Note that the "snapshot" API can be used to read the sub-buffer in reverse
70 * order, which is useful for flight recorder snapshots.
71 */
72
73/* Get a snapshot of the current ring buffer producer and consumer positions */
606828e4 74#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT _IO(0xF6, 0x00)
f3bc08c5 75/* Get the consumer position (iteration start) */
606828e4 76#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_CONSUMED _IOR(0xF6, 0x01, unsigned long)
76447e2f 77/* Get the producer position (iteration end) */
606828e4 78#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_GET_PRODUCED _IOR(0xF6, 0x02, unsigned long)
76447e2f 79/* Get exclusive read access to the specified sub-buffer position */
606828e4 80#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF _IOW(0xF6, 0x03, unsigned long)
76447e2f 81/* Release exclusive sub-buffer access */
606828e4 82#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_SUBBUF _IO(0xF6, 0x04)
76447e2f
JD
83
84/* Get exclusive read access to the next sub-buffer that can be read. */
606828e4 85#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF _IO(0xF6, 0x05)
76447e2f 86/* Release exclusive sub-buffer access, move consumer forward. */
606828e4 87#define LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF _IO(0xF6, 0x06)
76447e2f 88/* returns the size of the current sub-buffer, without padding (for mmap). */
606828e4 89#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, unsigned long)
76447e2f 90/* returns the size of the current sub-buffer, with padding (for splice). */
606828e4 91#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_PADDED_SUBBUF_SIZE _IOR(0xF6, 0x08, unsigned long)
76447e2f 92/* returns the maximum size for sub-buffers. */
606828e4 93#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, unsigned long)
76447e2f 94/* returns the length to mmap. */
606828e4 95#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_LEN _IOR(0xF6, 0x0A, unsigned long)
76447e2f 96/* returns the offset of the subbuffer belonging to the mmap reader. */
606828e4 97#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, unsigned long)
c6f05468 98/* Flush the current sub-buffer, if non-empty. */
606828e4 99#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH _IO(0xF6, 0x0C)
9616f0bf 100/* Get the current version of the metadata cache (after a get_next). */
606828e4 101#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION _IOR(0xF6, 0x0D, uint64_t)
4dce5a48
JG
102/*
103 * Get a snapshot of the current ring buffer producer and consumer positions,
104 * regardless of whether or not the two positions are contained within the same
105 * sub-buffer.
106 */
606828e4 107#define LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS _IO(0xF6, 0x0E)
c6f05468 108/* Flush the current sub-buffer, even if empty. */
606828e4 109#define LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY _IO(0xF6, 0x0F)
d1344afa
JD
110/*
111 * Reset the position of what has been consumed from the metadata cache to 0
112 * so it can be read again.
113 */
606828e4 114#define LTTNG_KERNEL_ABI_RING_BUFFER_METADATA_CACHE_DUMP _IO(0xF6, 0x10)
c245d0d3 115/* Clear ring buffer content. */
606828e4 116#define LTTNG_KERNEL_ABI_RING_BUFFER_CLEAR _IO(0xF6, 0x11)
8b97fd42
MD
117/*
118 * Get next metadata subbuffer, returning a flag indicating whether the
119 * metadata is guaranteed to be in a consistent state at the end of this
120 * sub-buffer (can be parsed).
121 */
606828e4 122#define LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK _IOR(0xF6, 0x12, uint32_t)
76447e2f
JD
123
124#ifdef CONFIG_COMPAT
125/* Get a snapshot of the current ring buffer producer and consumer positions */
606828e4 126#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_SNAPSHOT LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT
76447e2f 127/* Get the consumer position (iteration start) */
606828e4 128#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_SNAPSHOT_GET_CONSUMED \
216f7feb 129 _IOR(0xF6, 0x01, compat_ulong_t)
f3bc08c5 130/* Get the producer position (iteration end) */
606828e4 131#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_SNAPSHOT_GET_PRODUCED \
216f7feb 132 _IOR(0xF6, 0x02, compat_ulong_t)
f3bc08c5 133/* Get exclusive read access to the specified sub-buffer position */
606828e4 134#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_SUBBUF _IOW(0xF6, 0x03, compat_ulong_t)
f3bc08c5 135/* Release exclusive sub-buffer access */
606828e4 136#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_PUT_SUBBUF LTTNG_KERNEL_ABI_RING_BUFFER_PUT_SUBBUF
f3bc08c5
MD
137
138/* Get exclusive read access to the next sub-buffer that can be read. */
606828e4 139#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_NEXT_SUBBUF LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF
f3bc08c5 140/* Release exclusive sub-buffer access, move consumer forward. */
606828e4 141#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_PUT_NEXT_SUBBUF LTTNG_KERNEL_ABI_RING_BUFFER_PUT_NEXT_SUBBUF
f3bc08c5 142/* returns the size of the current sub-buffer, without padding (for mmap). */
606828e4 143#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, compat_ulong_t)
f3bc08c5 144/* returns the size of the current sub-buffer, with padding (for splice). */
606828e4 145#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_PADDED_SUBBUF_SIZE \
216f7feb 146 _IOR(0xF6, 0x08, compat_ulong_t)
f3bc08c5 147/* returns the maximum size for sub-buffers. */
606828e4 148#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, compat_ulong_t)
f3bc08c5 149/* returns the length to mmap. */
606828e4 150#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_MMAP_LEN _IOR(0xF6, 0x0A, compat_ulong_t)
f3bc08c5 151/* returns the offset of the subbuffer belonging to the mmap reader. */
606828e4 152#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, compat_ulong_t)
c6f05468 153/* Flush the current sub-buffer, if non-empty. */
606828e4 154#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_FLUSH LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH
9616f0bf 155/* Get the current version of the metadata cache (after a get_next). */
606828e4 156#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_METADATA_VERSION LTTNG_KERNEL_ABI_RING_BUFFER_GET_METADATA_VERSION
4dce5a48
JG
157/*
158 * Get a snapshot of the current ring buffer producer and consumer positions,
159 * regardless of whether or not the two positions are contained within the same
160 * sub-buffer.
161 */
606828e4
MD
162#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_SNAPSHOT_SAMPLE_POSITIONS \
163 LTTNG_KERNEL_ABI_RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS
c6f05468 164/* Flush the current sub-buffer, even if empty. */
606828e4
MD
165#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_FLUSH_EMPTY \
166 LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY
c245d0d3 167/* Clear ring buffer content. */
606828e4
MD
168#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_CLEAR \
169 LTTNG_KERNEL_ABI_RING_BUFFER_CLEAR
8b97fd42
MD
170/*
171 * Get next metadata subbuffer, returning a flag indicating whether the
172 * metadata is guaranteed to be in a consistent state at the end of this
173 * sub-buffer (can be parsed).
174 */
606828e4
MD
175#define LTTNG_KERNEL_ABI_RING_BUFFER_COMPAT_GET_NEXT_SUBBUF_METADATA_CHECK \
176 LTTNG_KERNEL_ABI_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
76447e2f 177#endif /* CONFIG_COMPAT */
f3bc08c5 178
606828e4 179#endif /* _LIB_LTTNG_KERNEL_ABI_RING_BUFFER_VFS_H */
This page took 0.051273 seconds and 4 git commands to generate.