xref: /linux/tools/tracing/rtla/src/osnoise.h (revision 5525aebd4e0c6f7d92ec1cb074218bbcf3d46f13)
1 // SPDX-License-Identifier: GPL-2.0
2 #pragma once
3 
4 #include "common.h"
5 
6 enum osnoise_mode {
7 	MODE_OSNOISE = 0,
8 	MODE_HWNOISE
9 };
10 
11 struct osnoise_params {
12 	struct common_params	common;
13 	unsigned long long	runtime;
14 	unsigned long long	period;
15 	long long		threshold;
16 	enum osnoise_mode	mode;
17 };
18 
19 #define to_osnoise_params(ptr) container_of(ptr, struct osnoise_params, common)
20 
21 /*
22  * *_INIT_VALs are also invalid values, they are used to
23  * communicate errors.
24  */
25 #define OSNOISE_OPTION_INIT_VAL	(-1)
26 #define OSNOISE_TIME_INIT_VAL	(0)
27 
28 struct osnoise_context *osnoise_context_alloc(void);
29 int osnoise_get_context(struct osnoise_context *context);
30 void osnoise_put_context(struct osnoise_context *context);
31 
32 int osnoise_set_runtime_period(struct osnoise_context *context,
33 			       unsigned long long runtime,
34 			       unsigned long long period);
35 void osnoise_restore_runtime_period(struct osnoise_context *context);
36 
37 void osnoise_restore_stop_us(struct osnoise_context *context);
38 void osnoise_restore_stop_total_us(struct osnoise_context *context);
39 
40 int osnoise_set_timerlat_period_us(struct osnoise_context *context,
41 				   long long timerlat_period_us);
42 void osnoise_restore_timerlat_period_us(struct osnoise_context *context);
43 
44 int osnoise_set_tracing_thresh(struct osnoise_context *context,
45 			       long long tracing_thresh);
46 void osnoise_restore_tracing_thresh(struct osnoise_context *context);
47 
48 void osnoise_restore_print_stack(struct osnoise_context *context);
49 int osnoise_set_print_stack(struct osnoise_context *context,
50 			    long long print_stack);
51 
52 int osnoise_set_irq_disable(struct osnoise_context *context, bool onoff);
53 void osnoise_report_missed_events(struct osnoise_tool *tool);
54 int osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params);
55 
56 int osnoise_enable(struct osnoise_tool *tool);
57 int osnoise_main(int argc, char **argv);
58 int hwnoise_main(int argc, char **argv);
59 
60 extern struct tool_ops timerlat_top_ops, timerlat_hist_ops;
61 extern struct tool_ops osnoise_top_ops, osnoise_hist_ops;
62 
63 int run_tool(struct tool_ops *ops, int argc, char *argv[]);
64