• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: LGPL-2.1 */
2 /*
3  * Copyright (C) 2012 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4  *
5  */
6 #ifndef _KBUFFER_H
7 #define _KBUFFER_H
8 
9 #ifndef TS_SHIFT
10 #define TS_SHIFT		27
11 #endif
12 
13 enum kbuffer_endian {
14 	KBUFFER_ENDIAN_BIG,
15 	KBUFFER_ENDIAN_LITTLE,
16 	KBUFFER_ENDIAN_SAME_AS_HOST,
17 };
18 
19 enum kbuffer_long_size {
20 	KBUFFER_LSIZE_4,
21 	KBUFFER_LSIZE_8,
22 	KBUFFER_LSIZE_SAME_AS_HOST,
23 };
24 
25 enum {
26 	KBUFFER_TYPE_PADDING		= 29,
27 	KBUFFER_TYPE_TIME_EXTEND	= 30,
28 	KBUFFER_TYPE_TIME_STAMP		= 31,
29 };
30 
31 struct kbuffer;
32 
33 struct kbuffer *kbuffer_alloc(enum kbuffer_long_size size, enum kbuffer_endian endian);
34 void kbuffer_free(struct kbuffer *kbuf);
35 int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer);
36 void *kbuffer_read_event(struct kbuffer *kbuf, unsigned long long *ts);
37 void *kbuffer_next_event(struct kbuffer *kbuf, unsigned long long *ts);
38 unsigned long long kbuffer_timestamp(struct kbuffer *kbuf);
39 unsigned long long kbuffer_subbuf_timestamp(struct kbuffer *kbuf, void *subbuf);
40 unsigned int kbuffer_ptr_delta(struct kbuffer *kbuf, void *ptr);
41 
42 void *kbuffer_translate_data(int swap, void *data, unsigned int *size);
43 
44 void *kbuffer_read_at_offset(struct kbuffer *kbuf, int offset, unsigned long long *ts);
45 
46 int kbuffer_curr_index(struct kbuffer *kbuf);
47 
48 int kbuffer_curr_offset(struct kbuffer *kbuf);
49 int kbuffer_curr_size(struct kbuffer *kbuf);
50 int kbuffer_event_size(struct kbuffer *kbuf);
51 int kbuffer_missed_events(struct kbuffer *kbuf);
52 int kbuffer_subbuffer_size(struct kbuffer *kbuf);
53 
54 void kbuffer_set_old_format(struct kbuffer *kbuf);
55 int kbuffer_start_of_data(struct kbuffer *kbuf);
56 
57 /* Debugging */
58 
59 struct kbuffer_raw_info {
60 	int			type;
61 	int			length;
62 	unsigned long long	delta;
63 	void			*next;
64 };
65 
66 /* Read raw data */
67 struct kbuffer_raw_info *kbuffer_raw_get(struct kbuffer *kbuf, void *subbuf,
68 					 struct kbuffer_raw_info *info);
69 
70 #endif /* _K_BUFFER_H */
71