162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _LINUX_TRACE_H 362306a36Sopenharmony_ci#define _LINUX_TRACE_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#define TRACE_EXPORT_FUNCTION BIT(0) 662306a36Sopenharmony_ci#define TRACE_EXPORT_EVENT BIT(1) 762306a36Sopenharmony_ci#define TRACE_EXPORT_MARKER BIT(2) 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* 1062306a36Sopenharmony_ci * The trace export - an export of Ftrace output. The trace_export 1162306a36Sopenharmony_ci * can process traces and export them to a registered destination as 1262306a36Sopenharmony_ci * an addition to the current only output of Ftrace - i.e. ring buffer. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * If you want traces to be sent to some other place rather than ring 1562306a36Sopenharmony_ci * buffer only, just need to register a new trace_export and implement 1662306a36Sopenharmony_ci * its own .write() function for writing traces to the storage. 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * next - pointer to the next trace_export 1962306a36Sopenharmony_ci * write - copy traces which have been delt with ->commit() to 2062306a36Sopenharmony_ci * the destination 2162306a36Sopenharmony_ci * flags - which ftrace to be exported 2262306a36Sopenharmony_ci */ 2362306a36Sopenharmony_cistruct trace_export { 2462306a36Sopenharmony_ci struct trace_export __rcu *next; 2562306a36Sopenharmony_ci void (*write)(struct trace_export *, const void *, unsigned int); 2662306a36Sopenharmony_ci int flags; 2762306a36Sopenharmony_ci}; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cistruct trace_array; 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#ifdef CONFIG_TRACING 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciint register_ftrace_export(struct trace_export *export); 3462306a36Sopenharmony_ciint unregister_ftrace_export(struct trace_export *export); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/** 3762306a36Sopenharmony_ci * trace_array_puts - write a constant string into the trace buffer. 3862306a36Sopenharmony_ci * @tr: The trace array to write to 3962306a36Sopenharmony_ci * @str: The constant string to write 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci#define trace_array_puts(tr, str) \ 4262306a36Sopenharmony_ci ({ \ 4362306a36Sopenharmony_ci str ? __trace_array_puts(tr, _THIS_IP_, str, strlen(str)) : -1; \ 4462306a36Sopenharmony_ci }) 4562306a36Sopenharmony_ciint __trace_array_puts(struct trace_array *tr, unsigned long ip, 4662306a36Sopenharmony_ci const char *str, int size); 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_civoid trace_printk_init_buffers(void); 4962306a36Sopenharmony_ci__printf(3, 4) 5062306a36Sopenharmony_ciint trace_array_printk(struct trace_array *tr, unsigned long ip, 5162306a36Sopenharmony_ci const char *fmt, ...); 5262306a36Sopenharmony_ciint trace_array_init_printk(struct trace_array *tr); 5362306a36Sopenharmony_civoid trace_array_put(struct trace_array *tr); 5462306a36Sopenharmony_cistruct trace_array *trace_array_get_by_name(const char *name); 5562306a36Sopenharmony_ciint trace_array_destroy(struct trace_array *tr); 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* For osnoise tracer */ 5862306a36Sopenharmony_ciint osnoise_arch_register(void); 5962306a36Sopenharmony_civoid osnoise_arch_unregister(void); 6062306a36Sopenharmony_civoid osnoise_trace_irq_entry(int id); 6162306a36Sopenharmony_civoid osnoise_trace_irq_exit(int id, const char *desc); 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#else /* CONFIG_TRACING */ 6462306a36Sopenharmony_cistatic inline int register_ftrace_export(struct trace_export *export) 6562306a36Sopenharmony_ci{ 6662306a36Sopenharmony_ci return -EINVAL; 6762306a36Sopenharmony_ci} 6862306a36Sopenharmony_cistatic inline int unregister_ftrace_export(struct trace_export *export) 6962306a36Sopenharmony_ci{ 7062306a36Sopenharmony_ci return 0; 7162306a36Sopenharmony_ci} 7262306a36Sopenharmony_cistatic inline void trace_printk_init_buffers(void) 7362306a36Sopenharmony_ci{ 7462306a36Sopenharmony_ci} 7562306a36Sopenharmony_cistatic inline int trace_array_printk(struct trace_array *tr, unsigned long ip, 7662306a36Sopenharmony_ci const char *fmt, ...) 7762306a36Sopenharmony_ci{ 7862306a36Sopenharmony_ci return 0; 7962306a36Sopenharmony_ci} 8062306a36Sopenharmony_cistatic inline int trace_array_init_printk(struct trace_array *tr) 8162306a36Sopenharmony_ci{ 8262306a36Sopenharmony_ci return -EINVAL; 8362306a36Sopenharmony_ci} 8462306a36Sopenharmony_cistatic inline void trace_array_put(struct trace_array *tr) 8562306a36Sopenharmony_ci{ 8662306a36Sopenharmony_ci} 8762306a36Sopenharmony_cistatic inline struct trace_array *trace_array_get_by_name(const char *name) 8862306a36Sopenharmony_ci{ 8962306a36Sopenharmony_ci return NULL; 9062306a36Sopenharmony_ci} 9162306a36Sopenharmony_cistatic inline int trace_array_destroy(struct trace_array *tr) 9262306a36Sopenharmony_ci{ 9362306a36Sopenharmony_ci return 0; 9462306a36Sopenharmony_ci} 9562306a36Sopenharmony_ci#endif /* CONFIG_TRACING */ 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci#endif /* _LINUX_TRACE_H */ 98