Commit | Line | Data |
---|---|---|
9f3fdbc6 MD |
1 | #ifndef _UST_RING_BUFFER_ABI_H |
2 | #define _UST_RING_BUFFER_ABI_H | |
3 | ||
4 | /* | |
5 | * ust/ringbuffer-abi.h | |
6 | * | |
7 | * (C) Copyright 2005-2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8 | * | |
9 | * Wait-free ring buffer ABI. | |
10 | * | |
11 | * Author: | |
12 | * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
13 | * | |
14 | * Dual LGPL v2.1/GPL v2 license. | |
15 | */ | |
16 | ||
17 | #define _UST_CMD(minor) (minor) | |
18 | #define _UST_CMDR(minor, type) (minor) | |
19 | #define _UST_CMDW(minor, type) (minor) | |
20 | ||
21 | /* | |
22 | * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and | |
23 | * consume sub-buffers sequentially. | |
24 | * | |
25 | * Reading sub-buffers without consuming them can be performed with: | |
26 | * | |
27 | * RING_BUFFER_SNAPSHOT | |
28 | * RING_BUFFER_SNAPSHOT_GET_CONSUMED | |
29 | * RING_BUFFER_SNAPSHOT_GET_PRODUCED | |
30 | * | |
31 | * to get the offset range to consume, and then by passing each sub-buffer | |
32 | * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it | |
33 | * with RING_BUFFER_PUT_SUBBUF. | |
34 | * | |
35 | * Note that the "snapshot" API can be used to read the sub-buffer in reverse | |
36 | * order, which is useful for flight recorder snapshots. | |
37 | */ | |
38 | ||
39 | /* Get a snapshot of the current ring buffer producer and consumer positions */ | |
40 | #define RING_BUFFER_SNAPSHOT _UST_CMD(0x00) | |
41 | /* Get the consumer position (iteration start) */ | |
42 | #define RING_BUFFER_SNAPSHOT_GET_CONSUMED _UST_CMDR(0x01, unsigned long) | |
43 | /* Get the producer position (iteration end) */ | |
44 | #define RING_BUFFER_SNAPSHOT_GET_PRODUCED _UST_CMDR(0x02, unsigned long) | |
45 | /* Get exclusive read access to the specified sub-buffer position */ | |
46 | #define RING_BUFFER_GET_SUBBUF _UST_CMDW(0x03, unsigned long) | |
47 | /* Release exclusive sub-buffer access */ | |
48 | #define RING_BUFFER_PUT_SUBBUF _UST_CMD(0x04) | |
49 | ||
50 | /* Get exclusive read access to the next sub-buffer that can be read. */ | |
51 | #define RING_BUFFER_GET_NEXT_SUBBUF _UST_CMD(0x05) | |
52 | /* Release exclusive sub-buffer access, move consumer forward. */ | |
53 | #define RING_BUFFER_PUT_NEXT_SUBBUF _UST_CMD(0x06) | |
54 | /* returns the size of the current sub-buffer, without padding (for mmap). */ | |
55 | #define RING_BUFFER_GET_SUBBUF_SIZE _UST_CMDR(0x07, unsigned long) | |
56 | /* returns the size of the current sub-buffer, with padding (for splice). */ | |
57 | #define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _UST_CMDR(0x08, unsigned long) | |
58 | /* returns the maximum size for sub-buffers. */ | |
59 | #define RING_BUFFER_GET_MAX_SUBBUF_SIZE _UST_CMDR(0x09, unsigned long) | |
60 | /* returns the length to mmap. */ | |
61 | #define RING_BUFFER_GET_MMAP_LEN _UST_CMDR(0x0A, unsigned long) | |
62 | /* returns the offset of the subbuffer belonging to the mmap reader. */ | |
63 | #define RING_BUFFER_GET_MMAP_READ_OFFSET _UST_CMDR(0x0B, unsigned long) | |
64 | /* flush the current sub-buffer */ | |
65 | #define RING_BUFFER_FLUSH _UST_CMD(0x0C) | |
66 | ||
67 | #endif /* _UST_RING_BUFFER_ABI_H */ |