blob: a2b522093cfdde4e4e05052f8b6af052321524f6 [file] [log] [blame]
Steven Rostedt (VMware)4e59ab932020-07-02 14:53:58 -04001/* SPDX-License-Identifier: LGPL-2.1 */
Namhyung Kimd6c25222013-06-04 14:20:21 +09002/*
3 * Copyright (C) 2012 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4 *
Namhyung Kimd6c25222013-06-04 14:20:21 +09005 */
6#ifndef _KBUFFER_H
7#define _KBUFFER_H
8
9#ifndef TS_SHIFT
10#define TS_SHIFT 27
11#endif
12
13enum kbuffer_endian {
14 KBUFFER_ENDIAN_BIG,
15 KBUFFER_ENDIAN_LITTLE,
16};
17
18enum kbuffer_long_size {
19 KBUFFER_LSIZE_4,
20 KBUFFER_LSIZE_8,
21};
22
23enum {
24 KBUFFER_TYPE_PADDING = 29,
25 KBUFFER_TYPE_TIME_EXTEND = 30,
26 KBUFFER_TYPE_TIME_STAMP = 31,
27};
28
29struct kbuffer;
30
31struct kbuffer *kbuffer_alloc(enum kbuffer_long_size size, enum kbuffer_endian endian);
32void kbuffer_free(struct kbuffer *kbuf);
33int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer);
34void *kbuffer_read_event(struct kbuffer *kbuf, unsigned long long *ts);
35void *kbuffer_next_event(struct kbuffer *kbuf, unsigned long long *ts);
36unsigned long long kbuffer_timestamp(struct kbuffer *kbuf);
Steven Rostedt (Red Hat)374855c2020-07-02 14:53:45 -040037unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf);
38unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr);
Namhyung Kimd6c25222013-06-04 14:20:21 +090039
40void *kbuffer_translate_data(int swap, void *data, unsigned int *size);
41
42void *kbuffer_read_at_offset(struct kbuffer *kbuf, int offset, unsigned long long *ts);
43
44int kbuffer_curr_index(struct kbuffer *kbuf);
45
46int kbuffer_curr_offset(struct kbuffer *kbuf);
47int kbuffer_curr_size(struct kbuffer *kbuf);
48int kbuffer_event_size(struct kbuffer *kbuf);
49int kbuffer_missed_events(struct kbuffer *kbuf);
50int kbuffer_subbuffer_size(struct kbuffer *kbuf);
51
52void kbuffer_set_old_format(struct kbuffer *kbuf);
Steven Rostedt (Red Hat)82ac9522015-03-24 09:57:56 -040053int kbuffer_start_of_data(struct kbuffer *kbuf);
Namhyung Kimd6c25222013-06-04 14:20:21 +090054
Steven Rostedt (Red Hat)70df6a72019-04-01 12:43:09 -040055/* Debugging */
56
57struct kbuffer_raw_info {
58 int type;
59 int length;
60 unsigned long long delta;
61 void *next;
62};
63
64/* Read raw data */
65struct kbuffer_raw_info *kbuffer_raw_get(struct kbuffer *kbuf, void *subbuf,
66 struct kbuffer_raw_info *info);
67
Namhyung Kimd6c25222013-06-04 14:20:21 +090068#endif /* _K_BUFFER_H */