xref: /openbmc/linux/kernel/trace/rv/rv.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1102227b9SDaniel Bristot de Oliveira /* SPDX-License-Identifier: GPL-2.0 */
2102227b9SDaniel Bristot de Oliveira #include <linux/mutex.h>
3102227b9SDaniel Bristot de Oliveira 
4102227b9SDaniel Bristot de Oliveira struct rv_interface {
5102227b9SDaniel Bristot de Oliveira 	struct dentry		*root_dir;
6102227b9SDaniel Bristot de Oliveira 	struct dentry		*monitors_dir;
7102227b9SDaniel Bristot de Oliveira };
8102227b9SDaniel Bristot de Oliveira 
9102227b9SDaniel Bristot de Oliveira #include "../trace.h"
10102227b9SDaniel Bristot de Oliveira #include <linux/tracefs.h>
11102227b9SDaniel Bristot de Oliveira #include <linux/rv.h>
12102227b9SDaniel Bristot de Oliveira 
13102227b9SDaniel Bristot de Oliveira #define RV_MODE_WRITE			TRACE_MODE_WRITE
14102227b9SDaniel Bristot de Oliveira #define RV_MODE_READ			TRACE_MODE_READ
15102227b9SDaniel Bristot de Oliveira 
16102227b9SDaniel Bristot de Oliveira #define rv_create_dir			tracefs_create_dir
17102227b9SDaniel Bristot de Oliveira #define rv_create_file			tracefs_create_file
18102227b9SDaniel Bristot de Oliveira #define rv_remove			tracefs_remove
19102227b9SDaniel Bristot de Oliveira 
20102227b9SDaniel Bristot de Oliveira #define MAX_RV_MONITOR_NAME_SIZE	32
21*04acadcbSDaniel Bristot de Oliveira #define MAX_RV_REACTOR_NAME_SIZE	32
22102227b9SDaniel Bristot de Oliveira 
23102227b9SDaniel Bristot de Oliveira extern struct mutex rv_interface_lock;
24102227b9SDaniel Bristot de Oliveira 
25*04acadcbSDaniel Bristot de Oliveira #ifdef CONFIG_RV_REACTORS
26*04acadcbSDaniel Bristot de Oliveira struct rv_reactor_def {
27*04acadcbSDaniel Bristot de Oliveira 	struct list_head	list;
28*04acadcbSDaniel Bristot de Oliveira 	struct rv_reactor	*reactor;
29*04acadcbSDaniel Bristot de Oliveira 	/* protected by the monitor interface lock */
30*04acadcbSDaniel Bristot de Oliveira 	int			counter;
31*04acadcbSDaniel Bristot de Oliveira };
32*04acadcbSDaniel Bristot de Oliveira #endif
33*04acadcbSDaniel Bristot de Oliveira 
34102227b9SDaniel Bristot de Oliveira struct rv_monitor_def {
35102227b9SDaniel Bristot de Oliveira 	struct list_head	list;
36102227b9SDaniel Bristot de Oliveira 	struct rv_monitor	*monitor;
37102227b9SDaniel Bristot de Oliveira 	struct dentry		*root_d;
38*04acadcbSDaniel Bristot de Oliveira #ifdef CONFIG_RV_REACTORS
39*04acadcbSDaniel Bristot de Oliveira 	struct rv_reactor_def	*rdef;
40*04acadcbSDaniel Bristot de Oliveira 	bool			reacting;
41*04acadcbSDaniel Bristot de Oliveira #endif
42102227b9SDaniel Bristot de Oliveira 	bool			task_monitor;
43102227b9SDaniel Bristot de Oliveira };
44102227b9SDaniel Bristot de Oliveira 
45102227b9SDaniel Bristot de Oliveira struct dentry *get_monitors_root(void);
46102227b9SDaniel Bristot de Oliveira int rv_disable_monitor(struct rv_monitor_def *mdef);
47102227b9SDaniel Bristot de Oliveira int rv_enable_monitor(struct rv_monitor_def *mdef);
48*04acadcbSDaniel Bristot de Oliveira 
49*04acadcbSDaniel Bristot de Oliveira #ifdef CONFIG_RV_REACTORS
50*04acadcbSDaniel Bristot de Oliveira int reactor_populate_monitor(struct rv_monitor_def *mdef);
51*04acadcbSDaniel Bristot de Oliveira void reactor_cleanup_monitor(struct rv_monitor_def *mdef);
52*04acadcbSDaniel Bristot de Oliveira int init_rv_reactors(struct dentry *root_dir);
53*04acadcbSDaniel Bristot de Oliveira #else
reactor_populate_monitor(struct rv_monitor_def * mdef)54*04acadcbSDaniel Bristot de Oliveira static inline int reactor_populate_monitor(struct rv_monitor_def *mdef)
55*04acadcbSDaniel Bristot de Oliveira {
56*04acadcbSDaniel Bristot de Oliveira 	return 0;
57*04acadcbSDaniel Bristot de Oliveira }
58*04acadcbSDaniel Bristot de Oliveira 
reactor_cleanup_monitor(struct rv_monitor_def * mdef)59*04acadcbSDaniel Bristot de Oliveira static inline void reactor_cleanup_monitor(struct rv_monitor_def *mdef)
60*04acadcbSDaniel Bristot de Oliveira {
61*04acadcbSDaniel Bristot de Oliveira 	return;
62*04acadcbSDaniel Bristot de Oliveira }
63*04acadcbSDaniel Bristot de Oliveira 
init_rv_reactors(struct dentry * root_dir)64*04acadcbSDaniel Bristot de Oliveira static inline int init_rv_reactors(struct dentry *root_dir)
65*04acadcbSDaniel Bristot de Oliveira {
66*04acadcbSDaniel Bristot de Oliveira 	return 0;
67*04acadcbSDaniel Bristot de Oliveira }
68*04acadcbSDaniel Bristot de Oliveira #endif
69