| 1 | #ifndef _LTTNG_RING_BUFFER_ABI_H |
| 2 | #define _LTTNG_RING_BUFFER_ABI_H |
| 3 | |
| 4 | /* |
| 5 | * lttng/ringbuffer-abi.h |
| 6 | * |
| 7 | * (C) Copyright 2005-2012 - 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 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 15 | * of this software and associated documentation files (the "Software"), to deal |
| 16 | * in the Software without restriction, including without limitation the rights |
| 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 18 | * copies of the Software, and to permit persons to whom the Software is |
| 19 | * furnished to do so, subject to the following conditions: |
| 20 | * |
| 21 | * The above copyright notice and this permission notice shall be included in |
| 22 | * all copies or substantial portions of the Software. |
| 23 | * |
| 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 30 | * SOFTWARE. |
| 31 | */ |
| 32 | |
| 33 | #define _UST_CMD(minor) (minor) |
| 34 | #define _UST_CMDR(minor, type) (minor) |
| 35 | #define _UST_CMDW(minor, type) (minor) |
| 36 | |
| 37 | /* |
| 38 | * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and |
| 39 | * consume sub-buffers sequentially. |
| 40 | * |
| 41 | * Reading sub-buffers without consuming them can be performed with: |
| 42 | * |
| 43 | * RING_BUFFER_SNAPSHOT |
| 44 | * RING_BUFFER_SNAPSHOT_GET_CONSUMED |
| 45 | * RING_BUFFER_SNAPSHOT_GET_PRODUCED |
| 46 | * |
| 47 | * to get the offset range to consume, and then by passing each sub-buffer |
| 48 | * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it |
| 49 | * with RING_BUFFER_PUT_SUBBUF. |
| 50 | * |
| 51 | * Note that the "snapshot" API can be used to read the sub-buffer in reverse |
| 52 | * order, which is useful for flight recorder snapshots. |
| 53 | */ |
| 54 | |
| 55 | /* Get a snapshot of the current ring buffer producer and consumer positions */ |
| 56 | #define RING_BUFFER_SNAPSHOT _UST_CMD(0x00) |
| 57 | /* Get the consumer position (iteration start) */ |
| 58 | #define RING_BUFFER_SNAPSHOT_GET_CONSUMED _UST_CMDR(0x01, unsigned long) |
| 59 | /* Get the producer position (iteration end) */ |
| 60 | #define RING_BUFFER_SNAPSHOT_GET_PRODUCED _UST_CMDR(0x02, unsigned long) |
| 61 | /* Get exclusive read access to the specified sub-buffer position */ |
| 62 | #define RING_BUFFER_GET_SUBBUF _UST_CMDW(0x03, unsigned long) |
| 63 | /* Release exclusive sub-buffer access */ |
| 64 | #define RING_BUFFER_PUT_SUBBUF _UST_CMD(0x04) |
| 65 | |
| 66 | /* Get exclusive read access to the next sub-buffer that can be read. */ |
| 67 | #define RING_BUFFER_GET_NEXT_SUBBUF _UST_CMD(0x05) |
| 68 | /* Release exclusive sub-buffer access, move consumer forward. */ |
| 69 | #define RING_BUFFER_PUT_NEXT_SUBBUF _UST_CMD(0x06) |
| 70 | /* returns the size of the current sub-buffer, without padding (for mmap). */ |
| 71 | #define RING_BUFFER_GET_SUBBUF_SIZE _UST_CMDR(0x07, unsigned long) |
| 72 | /* returns the size of the current sub-buffer, with padding (for splice). */ |
| 73 | #define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _UST_CMDR(0x08, unsigned long) |
| 74 | /* returns the maximum size for sub-buffers. */ |
| 75 | #define RING_BUFFER_GET_MAX_SUBBUF_SIZE _UST_CMDR(0x09, unsigned long) |
| 76 | /* returns the length to mmap. */ |
| 77 | #define RING_BUFFER_GET_MMAP_LEN _UST_CMDR(0x0A, unsigned long) |
| 78 | /* returns the offset of the subbuffer belonging to the mmap reader. */ |
| 79 | #define RING_BUFFER_GET_MMAP_READ_OFFSET _UST_CMDR(0x0B, unsigned long) |
| 80 | /* flush the current sub-buffer */ |
| 81 | #define RING_BUFFER_FLUSH _UST_CMD(0x0C) |
| 82 | |
| 83 | #endif /* _LTTNG_RING_BUFFER_ABI_H */ |