Import lib ring buffer into LTTng modules
[lttng-modules.git] / lib / ringbuffer / vfs.h
1 #ifndef _LINUX_RING_BUFFER_VFS_H
2 #define _LINUX_RING_BUFFER_VFS_H
3
4 /*
5 * linux/ringbuffer/vfs.h
6 *
7 * (C) Copyright 2005-2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Wait-free ring buffer VFS file operations.
10 *
11 * Author:
12 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 *
14 * Dual LGPL v2.1/GPL v2 license.
15 */
16
17 #include <linux/fs.h>
18 #include <linux/poll.h>
19
20 /* VFS API */
21
22 extern const struct file_operations lib_ring_buffer_file_operations;
23
24 /*
25 * Internal file operations.
26 */
27
28 int lib_ring_buffer_open(struct inode *inode, struct file *file);
29 int lib_ring_buffer_release(struct inode *inode, struct file *file);
30 unsigned int lib_ring_buffer_poll(struct file *filp, poll_table *wait);
31 ssize_t lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
32 struct pipe_inode_info *pipe, size_t len,
33 unsigned int flags);
34 int lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma);
35
36 /* Ring Buffer ioctl() and ioctl numbers */
37 long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
38 #ifdef CONFIG_COMPAT
39 long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
40 unsigned long arg);
41 #endif
42
43 /*
44 * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and
45 * consume sub-buffers sequentially.
46 *
47 * Reading sub-buffers without consuming them can be performed with:
48 *
49 * RING_BUFFER_SNAPSHOT
50 * RING_BUFFER_SNAPSHOT_GET_CONSUMED
51 * RING_BUFFER_SNAPSHOT_GET_PRODUCED
52 *
53 * to get the offset range to consume, and then by passing each sub-buffer
54 * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it
55 * with RING_BUFFER_PUT_SUBBUF.
56 *
57 * Note that the "snapshot" API can be used to read the sub-buffer in reverse
58 * order, which is useful for flight recorder snapshots.
59 */
60
61 /* Get a snapshot of the current ring buffer producer and consumer positions */
62 #define RING_BUFFER_SNAPSHOT _IO(0xF6, 0x00)
63 /* Get the consumer position (iteration start) */
64 #define RING_BUFFER_SNAPSHOT_GET_CONSUMED _IOR(0xF6, 0x01, unsigned long)
65 /* Get the producer position (iteration end) */
66 #define RING_BUFFER_SNAPSHOT_GET_PRODUCED _IOR(0xF6, 0x02, unsigned long)
67 /* Get exclusive read access to the specified sub-buffer position */
68 #define RING_BUFFER_GET_SUBBUF _IOW(0xF6, 0x03, unsigned long)
69 /* Release exclusive sub-buffer access */
70 #define RING_BUFFER_PUT_SUBBUF _IO(0xF6, 0x04)
71
72 /* Get exclusive read access to the next sub-buffer that can be read. */
73 #define RING_BUFFER_GET_NEXT_SUBBUF _IO(0xF6, 0x05)
74 /* Release exclusive sub-buffer access, move consumer forward. */
75 #define RING_BUFFER_PUT_NEXT_SUBBUF _IO(0xF6, 0x06)
76 /* returns the size of the current sub-buffer, without padding (for mmap). */
77 #define RING_BUFFER_GET_SUBBUF_SIZE _IOR(0xF6, 0x07, unsigned long)
78 /* returns the size of the current sub-buffer, with padding (for splice). */
79 #define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _IOR(0xF6, 0x08, unsigned long)
80 /* returns the maximum size for sub-buffers. */
81 #define RING_BUFFER_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, unsigned long)
82 /* returns the length to mmap. */
83 #define RING_BUFFER_GET_MMAP_LEN _IOR(0xF6, 0x0A, unsigned long)
84 /* returns the offset of the subbuffer belonging to the mmap reader. */
85 #define RING_BUFFER_GET_MMAP_READ_OFFSET _IOR(0xF6, 0x0B, unsigned long)
86
87 #endif /* _LINUX_RING_BUFFER_VFS_H */
This page took 0.034398 seconds and 5 git commands to generate.