1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_RING_BUFFER_TYPES_H 3 #define _LINUX_RING_BUFFER_TYPES_H 4 5 #include <asm/local.h> 6 7 #define TS_SHIFT 27 8 #define TS_MASK ((1ULL << TS_SHIFT) - 1) 9 #define TS_DELTA_TEST (~TS_MASK) 10 11 /* 12 * We need to fit the time_stamp delta into 27 bits. 13 */ test_time_stamp(u64 delta)14static inline bool test_time_stamp(u64 delta) 15 { 16 return !!(delta & TS_DELTA_TEST); 17 } 18 19 #define BUF_PAGE_HDR_SIZE offsetof(struct buffer_data_page, data) 20 21 #define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array)) 22 #define RB_ALIGNMENT 4U 23 #define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX) 24 #define RB_EVNT_MIN_SIZE 8U /* two 32bit words */ 25 26 #ifndef CONFIG_HAVE_64BIT_ALIGNED_ACCESS 27 # define RB_FORCE_8BYTE_ALIGNMENT 0 28 # define RB_ARCH_ALIGNMENT RB_ALIGNMENT 29 #else 30 # define RB_FORCE_8BYTE_ALIGNMENT 1 31 # define RB_ARCH_ALIGNMENT 8U 32 #endif 33 34 #define RB_ALIGN_DATA __aligned(RB_ARCH_ALIGNMENT) 35 36 struct buffer_data_page { 37 u64 time_stamp; /* page time stamp */ 38 local_t commit; /* write committed index */ 39 unsigned char data[] RB_ALIGN_DATA; /* data of buffer page */ 40 }; 41 #endif 42