accel/qaic: Add AIC200 support
[drm/drm-misc.git] / include / linux / fprobe.h
blobf3986958811751c3956be23495ad08b7ee72e031
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Simple ftrace probe wrapper */
3 #ifndef _LINUX_FPROBE_H
4 #define _LINUX_FPROBE_H
6 #include <linux/compiler.h>
7 #include <linux/ftrace.h>
8 #include <linux/rethook.h>
10 struct fprobe;
12 typedef int (*fprobe_entry_cb)(struct fprobe *fp, unsigned long entry_ip,
13 unsigned long ret_ip, struct pt_regs *regs,
14 void *entry_data);
16 typedef void (*fprobe_exit_cb)(struct fprobe *fp, unsigned long entry_ip,
17 unsigned long ret_ip, struct pt_regs *regs,
18 void *entry_data);
20 /**
21 * struct fprobe - ftrace based probe.
22 * @ops: The ftrace_ops.
23 * @nmissed: The counter for missing events.
24 * @flags: The status flag.
25 * @rethook: The rethook data structure. (internal data)
26 * @entry_data_size: The private data storage size.
27 * @nr_maxactive: The max number of active functions.
28 * @entry_handler: The callback function for function entry.
29 * @exit_handler: The callback function for function exit.
31 struct fprobe {
32 #ifdef CONFIG_FUNCTION_TRACER
34 * If CONFIG_FUNCTION_TRACER is not set, CONFIG_FPROBE is disabled too.
35 * But user of fprobe may keep embedding the struct fprobe on their own
36 * code. To avoid build error, this will keep the fprobe data structure
37 * defined here, but remove ftrace_ops data structure.
39 struct ftrace_ops ops;
40 #endif
41 unsigned long nmissed;
42 unsigned int flags;
43 struct rethook *rethook;
44 size_t entry_data_size;
45 int nr_maxactive;
47 fprobe_entry_cb entry_handler;
48 fprobe_exit_cb exit_handler;
51 /* This fprobe is soft-disabled. */
52 #define FPROBE_FL_DISABLED 1
55 * This fprobe handler will be shared with kprobes.
56 * This flag must be set before registering.
58 #define FPROBE_FL_KPROBE_SHARED 2
60 static inline bool fprobe_disabled(struct fprobe *fp)
62 return (fp) ? fp->flags & FPROBE_FL_DISABLED : false;
65 static inline bool fprobe_shared_with_kprobes(struct fprobe *fp)
67 return (fp) ? fp->flags & FPROBE_FL_KPROBE_SHARED : false;
70 #ifdef CONFIG_FPROBE
71 int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter);
72 int register_fprobe_ips(struct fprobe *fp, unsigned long *addrs, int num);
73 int register_fprobe_syms(struct fprobe *fp, const char **syms, int num);
74 int unregister_fprobe(struct fprobe *fp);
75 bool fprobe_is_registered(struct fprobe *fp);
76 #else
77 static inline int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter)
79 return -EOPNOTSUPP;
81 static inline int register_fprobe_ips(struct fprobe *fp, unsigned long *addrs, int num)
83 return -EOPNOTSUPP;
85 static inline int register_fprobe_syms(struct fprobe *fp, const char **syms, int num)
87 return -EOPNOTSUPP;
89 static inline int unregister_fprobe(struct fprobe *fp)
91 return -EOPNOTSUPP;
93 static inline bool fprobe_is_registered(struct fprobe *fp)
95 return false;
97 #endif
99 /**
100 * disable_fprobe() - Disable fprobe
101 * @fp: The fprobe to be disabled.
103 * This will soft-disable @fp. Note that this doesn't remove the ftrace
104 * hooks from the function entry.
106 static inline void disable_fprobe(struct fprobe *fp)
108 if (fp)
109 fp->flags |= FPROBE_FL_DISABLED;
113 * enable_fprobe() - Enable fprobe
114 * @fp: The fprobe to be enabled.
116 * This will soft-enable @fp.
118 static inline void enable_fprobe(struct fprobe *fp)
120 if (fp)
121 fp->flags &= ~FPROBE_FL_DISABLED;
124 #endif