1 #ifndef _LINUX_RING_BUFFER_H
2 #define _LINUX_RING_BUFFER_H
5 #include <linux/seq_file.h>
8 struct ring_buffer_iter
;
11 * Don't reference this struct directly, use functions below.
13 struct ring_buffer_event
{
14 u32 type
:2, len
:3, time_delta
:27;
19 * enum ring_buffer_type - internal ring buffer types
21 * @RINGBUF_TYPE_PADDING: Left over page padding
23 * size is variable depending on how much
26 * @RINGBUF_TYPE_TIME_EXTEND: Extend the time delta
27 * array[0] = time delta (28 .. 59)
30 * @RINGBUF_TYPE_TIME_STAMP: Sync time stamp with external clock
35 * @RINGBUF_TYPE_DATA: Data record
37 * array[0] holds the actual length
38 * array[1..(length+3)/4-1] holds data
41 * array[0..(length+3)/4] holds data
43 enum ring_buffer_type
{
45 RINGBUF_TYPE_TIME_EXTEND
,
46 /* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */
47 RINGBUF_TYPE_TIME_STAMP
,
51 unsigned ring_buffer_event_length(struct ring_buffer_event
*event
);
52 void *ring_buffer_event_data(struct ring_buffer_event
*event
);
55 * ring_buffer_event_time_delta - return the delta timestamp of the event
56 * @event: the event to get the delta timestamp of
58 * The delta timestamp is the 27 bit timestamp since the last event.
60 static inline unsigned
61 ring_buffer_event_time_delta(struct ring_buffer_event
*event
)
63 return event
->time_delta
;
67 * size is in bytes for each per CPU buffer.
70 ring_buffer_alloc(unsigned long size
, unsigned flags
);
71 void ring_buffer_free(struct ring_buffer
*buffer
);
73 int ring_buffer_resize(struct ring_buffer
*buffer
, unsigned long size
);
75 struct ring_buffer_event
*
76 ring_buffer_lock_reserve(struct ring_buffer
*buffer
,
78 unsigned long *flags
);
79 int ring_buffer_unlock_commit(struct ring_buffer
*buffer
,
80 struct ring_buffer_event
*event
,
82 int ring_buffer_write(struct ring_buffer
*buffer
,
83 unsigned long length
, void *data
);
85 struct ring_buffer_event
*
86 ring_buffer_peek(struct ring_buffer
*buffer
, int cpu
, u64
*ts
);
87 struct ring_buffer_event
*
88 ring_buffer_consume(struct ring_buffer
*buffer
, int cpu
, u64
*ts
);
90 struct ring_buffer_iter
*
91 ring_buffer_read_start(struct ring_buffer
*buffer
, int cpu
);
92 void ring_buffer_read_finish(struct ring_buffer_iter
*iter
);
94 struct ring_buffer_event
*
95 ring_buffer_iter_peek(struct ring_buffer_iter
*iter
, u64
*ts
);
96 struct ring_buffer_event
*
97 ring_buffer_read(struct ring_buffer_iter
*iter
, u64
*ts
);
98 void ring_buffer_iter_reset(struct ring_buffer_iter
*iter
);
99 int ring_buffer_iter_empty(struct ring_buffer_iter
*iter
);
101 unsigned long ring_buffer_size(struct ring_buffer
*buffer
);
103 void ring_buffer_reset_cpu(struct ring_buffer
*buffer
, int cpu
);
104 void ring_buffer_reset(struct ring_buffer
*buffer
);
106 int ring_buffer_swap_cpu(struct ring_buffer
*buffer_a
,
107 struct ring_buffer
*buffer_b
, int cpu
);
109 int ring_buffer_empty(struct ring_buffer
*buffer
);
110 int ring_buffer_empty_cpu(struct ring_buffer
*buffer
, int cpu
);
112 void ring_buffer_record_disable(struct ring_buffer
*buffer
);
113 void ring_buffer_record_enable(struct ring_buffer
*buffer
);
114 void ring_buffer_record_disable_cpu(struct ring_buffer
*buffer
, int cpu
);
115 void ring_buffer_record_enable_cpu(struct ring_buffer
*buffer
, int cpu
);
117 unsigned long ring_buffer_entries(struct ring_buffer
*buffer
);
118 unsigned long ring_buffer_overruns(struct ring_buffer
*buffer
);
120 u64
ring_buffer_time_stamp(int cpu
);
121 void ring_buffer_normalize_time_stamp(int cpu
, u64
*ts
);
123 void tracing_on(void);
124 void tracing_off(void);
126 enum ring_buffer_flags
{
127 RB_FL_OVERWRITE
= 1 << 0,
130 #endif /* _LINUX_RING_BUFFER_H */