blob: b5e16e438448f26bbba255b11f610835ad9a671b [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Chunyan Zhang478409d2016-11-21 15:57:18 +08002#ifndef _LINUX_TRACE_H
3#define _LINUX_TRACE_H
4
Tingwei Zhang8438f522020-10-05 10:13:13 +03005#define TRACE_EXPORT_FUNCTION BIT(0)
Tingwei Zhang8ab7a2b2020-10-05 10:13:14 +03006#define TRACE_EXPORT_EVENT BIT(1)
Tingwei Zhang458999c2020-10-05 10:13:15 +03007#define TRACE_EXPORT_MARKER BIT(2)
Tingwei Zhang8438f522020-10-05 10:13:13 +03008
Chunyan Zhang478409d2016-11-21 15:57:18 +08009/*
10 * The trace export - an export of Ftrace output. The trace_export
11 * can process traces and export them to a registered destination as
12 * an addition to the current only output of Ftrace - i.e. ring buffer.
13 *
14 * If you want traces to be sent to some other place rather than ring
15 * buffer only, just need to register a new trace_export and implement
16 * its own .write() function for writing traces to the storage.
17 *
18 * next - pointer to the next trace_export
19 * write - copy traces which have been delt with ->commit() to
20 * the destination
Tingwei Zhang8438f522020-10-05 10:13:13 +030021 * flags - which ftrace to be exported
Chunyan Zhang478409d2016-11-21 15:57:18 +080022 */
23struct trace_export {
24 struct trace_export __rcu *next;
Felipe Balbia773d412017-06-02 13:20:25 +030025 void (*write)(struct trace_export *, const void *, unsigned int);
Tingwei Zhang8438f522020-10-05 10:13:13 +030026 int flags;
Chunyan Zhang478409d2016-11-21 15:57:18 +080027};
28
Arun Easi1a77dd12022-09-07 16:33:08 -070029#ifdef CONFIG_TRACING
30
Chunyan Zhang478409d2016-11-21 15:57:18 +080031int register_ftrace_export(struct trace_export *export);
32int unregister_ftrace_export(struct trace_export *export);
33
Divya Indi2d6425a2019-08-14 10:55:23 -070034struct trace_array;
35
36void trace_printk_init_buffers(void);
Tom Rixbd0c9702020-12-21 08:27:15 -080037__printf(3, 4)
Divya Indi2d6425a2019-08-14 10:55:23 -070038int trace_array_printk(struct trace_array *tr, unsigned long ip,
Tom Rixbd0c9702020-12-21 08:27:15 -080039 const char *fmt, ...);
Steven Rostedt (VMware)38ce2a92020-08-06 12:46:49 -040040int trace_array_init_printk(struct trace_array *tr);
Divya Indi28879782019-11-20 11:08:38 -080041void trace_array_put(struct trace_array *tr);
42struct trace_array *trace_array_get_by_name(const char *name);
Divya Indi2d6425a2019-08-14 10:55:23 -070043int trace_array_destroy(struct trace_array *tr);
Daniel Bristot de Oliveirabce29ac2021-06-22 16:42:27 +020044
45/* For osnoise tracer */
46int osnoise_arch_register(void);
47void osnoise_arch_unregister(void);
Daniel Bristot de Oliveiraf7d9f632021-06-28 11:45:47 +020048void osnoise_trace_irq_entry(int id);
49void osnoise_trace_irq_exit(int id, const char *desc);
Daniel Bristot de Oliveirabce29ac2021-06-22 16:42:27 +020050
Arun Easi1a77dd12022-09-07 16:33:08 -070051#else /* CONFIG_TRACING */
52static inline int register_ftrace_export(struct trace_export *export)
53{
54 return -EINVAL;
55}
56static inline int unregister_ftrace_export(struct trace_export *export)
57{
58 return 0;
59}
60static inline void trace_printk_init_buffers(void)
61{
62}
63static inline int trace_array_printk(struct trace_array *tr, unsigned long ip,
64 const char *fmt, ...)
65{
66 return 0;
67}
68static inline int trace_array_init_printk(struct trace_array *tr)
69{
70 return -EINVAL;
71}
72static inline void trace_array_put(struct trace_array *tr)
73{
74}
75static inline struct trace_array *trace_array_get_by_name(const char *name)
76{
77 return NULL;
78}
79static inline int trace_array_destroy(struct trace_array *tr)
80{
81 return 0;
82}
Chunyan Zhang478409d2016-11-21 15:57:18 +080083#endif /* CONFIG_TRACING */
84
85#endif /* _LINUX_TRACE_H */