xref: /linux/tools/tracing/rtla/src/timerlat_bpf.h (revision 8cd0f08ac72e25e2a048c72d76730676ab0106f3)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #pragma once
3 
4 enum summary_field {
5 	SUMMARY_CURRENT,
6 	SUMMARY_MIN,
7 	SUMMARY_MAX,
8 	SUMMARY_COUNT,
9 	SUMMARY_SUM,
10 	SUMMARY_OVERFLOW,
11 	SUMMARY_FIELD_N
12 };
13 
14 #ifndef __bpf__
15 #include <bpf/libbpf.h>
16 #ifdef HAVE_BPF_SKEL
17 int timerlat_bpf_init(struct timerlat_params *params);
18 int timerlat_bpf_attach(void);
19 void timerlat_bpf_detach(void);
20 void timerlat_bpf_destroy(void);
21 int timerlat_bpf_wait(int timeout);
22 int timerlat_bpf_restart_tracing(void);
23 int timerlat_bpf_get_hist_value(int key,
24 				long long *value_irq,
25 				long long *value_thread,
26 				long long *value_user,
27 				int cpus);
28 int timerlat_bpf_get_summary_value(enum summary_field key,
29 				   long long *value_irq,
30 				   long long *value_thread,
31 				   long long *value_user,
32 				   int cpus);
33 
34 static inline int have_libbpf_support(void) { return 1; }
35 #else
36 static inline int timerlat_bpf_init(struct timerlat_params *params)
37 {
38 	return -1;
39 }
40 static inline int timerlat_bpf_attach(void) { return -1; }
41 static inline void timerlat_bpf_detach(void) { };
42 static inline void timerlat_bpf_destroy(void) { };
43 static inline int timerlat_bpf_wait(int timeout) { return -1; }
44 static inline int timerlat_bpf_restart_tracing(void) { return -1; };
45 static inline int timerlat_bpf_get_hist_value(int key,
46 					      long long *value_irq,
47 					      long long *value_thread,
48 					      long long *value_user,
49 					      int cpus)
50 {
51 	return -1;
52 }
53 static inline int timerlat_bpf_get_summary_value(enum summary_field key,
54 						 long long *value_irq,
55 						 long long *value_thread,
56 						 long long *value_user,
57 						 int cpus)
58 {
59 	return -1;
60 }
61 static inline int have_libbpf_support(void) { return 0; }
62 #endif /* HAVE_BPF_SKEL */
63 #endif /* __bpf__ */
64