xref: /linux/tools/tracing/rtla/src/timerlat_bpf.h (revision b4ada0618eed0fbd1b1630f73deb048c592b06a1)
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 #ifdef HAVE_BPF_SKEL
16 int timerlat_bpf_init(struct timerlat_params *params);
17 int timerlat_bpf_attach(void);
18 void timerlat_bpf_detach(void);
19 void timerlat_bpf_destroy(void);
20 int timerlat_bpf_wait(int timeout);
21 int timerlat_bpf_restart_tracing(void);
22 int timerlat_bpf_get_hist_value(int key,
23 				long long *value_irq,
24 				long long *value_thread,
25 				long long *value_user,
26 				int cpus);
27 int timerlat_bpf_get_summary_value(enum summary_field key,
28 				   long long *value_irq,
29 				   long long *value_thread,
30 				   long long *value_user,
31 				   int cpus);
32 
33 static inline int have_libbpf_support(void) { return 1; }
34 #else
35 static inline int timerlat_bpf_init(struct timerlat_params *params)
36 {
37 	return -1;
38 }
39 static inline int timerlat_bpf_attach(void) { return -1; }
40 static inline void timerlat_bpf_detach(void) { };
41 static inline void timerlat_bpf_destroy(void) { };
42 static inline int timerlat_bpf_wait(int timeout) { return -1; }
43 static inline int timerlat_bpf_restart_tracing(void) { return -1; };
44 static inline int timerlat_bpf_get_hist_value(int key,
45 					      long long *value_irq,
46 					      long long *value_thread,
47 					      long long *value_user,
48 					      int cpus)
49 {
50 	return -1;
51 }
52 static inline int timerlat_bpf_get_summary_value(enum summary_field key,
53 						 long long *value_irq,
54 						 long long *value_thread,
55 						 long long *value_user,
56 						 int cpus)
57 {
58 	return -1;
59 }
60 static inline int have_libbpf_support(void) { return 0; }
61 #endif /* HAVE_BPF_SKEL */
62 #endif /* __bpf__ */
63