| 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 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
| 15 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. |
| 16 | * |
| 17 | * Permission is hereby granted to use or copy this program |
| 18 | * for any purpose, provided the above notices are retained on all copies. |
| 19 | * Permission to modify the code and to distribute modified code is granted, |
| 20 | * provided the above notices are retained, and a notice that the code was |
| 21 | * modified is included with the above copyright notice. |
| 22 | */ |
| 23 | |
| 24 | #define _UST_CMD(minor) (minor) |
| 25 | #define _UST_CMDR(minor, type) (minor) |
| 26 | #define _UST_CMDW(minor, type) (minor) |
| 27 | |
| 28 | /* |
| 29 | * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and |
| 30 | * consume sub-buffers sequentially. |
| 31 | * |
| 32 | * Reading sub-buffers without consuming them can be performed with: |
| 33 | * |
| 34 | * RING_BUFFER_SNAPSHOT |
| 35 | * RING_BUFFER_SNAPSHOT_GET_CONSUMED |
| 36 | * RING_BUFFER_SNAPSHOT_GET_PRODUCED |
| 37 | * |
| 38 | * to get the offset range to consume, and then by passing each sub-buffer |
| 39 | * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it |
| 40 | * with RING_BUFFER_PUT_SUBBUF. |
| 41 | * |
| 42 | * Note that the "snapshot" API can be used to read the sub-buffer in reverse |
| 43 | * order, which is useful for flight recorder snapshots. |
| 44 | */ |
| 45 | |
| 46 | /* Get a snapshot of the current ring buffer producer and consumer positions */ |
| 47 | #define RING_BUFFER_SNAPSHOT _UST_CMD(0x00) |
| 48 | /* Get the consumer position (iteration start) */ |
| 49 | #define RING_BUFFER_SNAPSHOT_GET_CONSUMED _UST_CMDR(0x01, unsigned long) |
| 50 | /* Get the producer position (iteration end) */ |
| 51 | #define RING_BUFFER_SNAPSHOT_GET_PRODUCED _UST_CMDR(0x02, unsigned long) |
| 52 | /* Get exclusive read access to the specified sub-buffer position */ |
| 53 | #define RING_BUFFER_GET_SUBBUF _UST_CMDW(0x03, unsigned long) |
| 54 | /* Release exclusive sub-buffer access */ |
| 55 | #define RING_BUFFER_PUT_SUBBUF _UST_CMD(0x04) |
| 56 | |
| 57 | /* Get exclusive read access to the next sub-buffer that can be read. */ |
| 58 | #define RING_BUFFER_GET_NEXT_SUBBUF _UST_CMD(0x05) |
| 59 | /* Release exclusive sub-buffer access, move consumer forward. */ |
| 60 | #define RING_BUFFER_PUT_NEXT_SUBBUF _UST_CMD(0x06) |
| 61 | /* returns the size of the current sub-buffer, without padding (for mmap). */ |
| 62 | #define RING_BUFFER_GET_SUBBUF_SIZE _UST_CMDR(0x07, unsigned long) |
| 63 | /* returns the size of the current sub-buffer, with padding (for splice). */ |
| 64 | #define RING_BUFFER_GET_PADDED_SUBBUF_SIZE _UST_CMDR(0x08, unsigned long) |
| 65 | /* returns the maximum size for sub-buffers. */ |
| 66 | #define RING_BUFFER_GET_MAX_SUBBUF_SIZE _UST_CMDR(0x09, unsigned long) |
| 67 | /* returns the length to mmap. */ |
| 68 | #define RING_BUFFER_GET_MMAP_LEN _UST_CMDR(0x0A, unsigned long) |
| 69 | /* returns the offset of the subbuffer belonging to the mmap reader. */ |
| 70 | #define RING_BUFFER_GET_MMAP_READ_OFFSET _UST_CMDR(0x0B, unsigned long) |
| 71 | /* flush the current sub-buffer */ |
| 72 | #define RING_BUFFER_FLUSH _UST_CMD(0x0C) |
| 73 | |
| 74 | #endif /* _UST_RING_BUFFER_ABI_H */ |