ACPI: simplify acpi_pci_irq_add_prt() API
[linux-2.6/linux-acpi-2.6.git] / include / linux / ring_buffer.h
blobe1b7b2173885f8f14f4a8da3979d0a6eff08e186
1 #ifndef _LINUX_RING_BUFFER_H
2 #define _LINUX_RING_BUFFER_H
4 #include <linux/mm.h>
5 #include <linux/seq_file.h>
7 struct ring_buffer;
8 struct ring_buffer_iter;
11 * Don't refer to this struct directly, use functions below.
13 struct ring_buffer_event {
14 u32 type:2, len:3, time_delta:27;
15 u32 array[];
18 /**
19 * enum ring_buffer_type - internal ring buffer types
21 * @RINGBUF_TYPE_PADDING: Left over page padding or discarded event
22 * If time_delta is 0:
23 * array is ignored
24 * size is variable depending on how much
25 * padding is needed
26 * If time_delta is non zero:
27 * everything else same as RINGBUF_TYPE_DATA
29 * @RINGBUF_TYPE_TIME_EXTEND: Extend the time delta
30 * array[0] = time delta (28 .. 59)
31 * size = 8 bytes
33 * @RINGBUF_TYPE_TIME_STAMP: Sync time stamp with external clock
34 * array[0] = tv_nsec
35 * array[1..2] = tv_sec
36 * size = 16 bytes
38 * @RINGBUF_TYPE_DATA: Data record
39 * If len is zero:
40 * array[0] holds the actual length
41 * array[1..(length+3)/4] holds data
42 * size = 4 + 4 + length (bytes)
43 * else
44 * length = len << 2
45 * array[0..(length+3)/4-1] holds data
46 * size = 4 + length (bytes)
48 enum ring_buffer_type {
49 RINGBUF_TYPE_PADDING,
50 RINGBUF_TYPE_TIME_EXTEND,
51 /* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */
52 RINGBUF_TYPE_TIME_STAMP,
53 RINGBUF_TYPE_DATA,
56 unsigned ring_buffer_event_length(struct ring_buffer_event *event);
57 void *ring_buffer_event_data(struct ring_buffer_event *event);
59 /**
60 * ring_buffer_event_time_delta - return the delta timestamp of the event
61 * @event: the event to get the delta timestamp of
63 * The delta timestamp is the 27 bit timestamp since the last event.
65 static inline unsigned
66 ring_buffer_event_time_delta(struct ring_buffer_event *event)
68 return event->time_delta;
71 void ring_buffer_event_discard(struct ring_buffer_event *event);
74 * size is in bytes for each per CPU buffer.
76 struct ring_buffer *
77 ring_buffer_alloc(unsigned long size, unsigned flags);
78 void ring_buffer_free(struct ring_buffer *buffer);
80 int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size);
82 struct ring_buffer_event *ring_buffer_lock_reserve(struct ring_buffer *buffer,
83 unsigned long length);
84 int ring_buffer_unlock_commit(struct ring_buffer *buffer,
85 struct ring_buffer_event *event);
86 int ring_buffer_write(struct ring_buffer *buffer,
87 unsigned long length, void *data);
89 struct ring_buffer_event *
90 ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts);
91 struct ring_buffer_event *
92 ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts);
94 struct ring_buffer_iter *
95 ring_buffer_read_start(struct ring_buffer *buffer, int cpu);
96 void ring_buffer_read_finish(struct ring_buffer_iter *iter);
98 struct ring_buffer_event *
99 ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts);
100 struct ring_buffer_event *
101 ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts);
102 void ring_buffer_iter_reset(struct ring_buffer_iter *iter);
103 int ring_buffer_iter_empty(struct ring_buffer_iter *iter);
105 unsigned long ring_buffer_size(struct ring_buffer *buffer);
107 void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu);
108 void ring_buffer_reset(struct ring_buffer *buffer);
110 int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
111 struct ring_buffer *buffer_b, int cpu);
113 int ring_buffer_empty(struct ring_buffer *buffer);
114 int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
116 void ring_buffer_record_disable(struct ring_buffer *buffer);
117 void ring_buffer_record_enable(struct ring_buffer *buffer);
118 void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);
119 void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
121 unsigned long ring_buffer_entries(struct ring_buffer *buffer);
122 unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
123 unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);
124 unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);
126 u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu);
127 void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer,
128 int cpu, u64 *ts);
129 void ring_buffer_set_clock(struct ring_buffer *buffer,
130 u64 (*clock)(void));
132 size_t ring_buffer_page_len(void *page);
135 void *ring_buffer_alloc_read_page(struct ring_buffer *buffer);
136 void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data);
137 int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page,
138 size_t len, int cpu, int full);
140 enum ring_buffer_flags {
141 RB_FL_OVERWRITE = 1 << 0,
144 #endif /* _LINUX_RING_BUFFER_H */