18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Trace files that want to automate creation of all tracepoints defined
48c2ecf20Sopenharmony_ci * in their file should include this file. The following are macros that the
58c2ecf20Sopenharmony_ci * trace file may define:
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * TRACE_SYSTEM defines the system the tracepoint is for
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h
108c2ecf20Sopenharmony_ci *     This macro may be defined to tell define_trace.h what file to include.
118c2ecf20Sopenharmony_ci *     Note, leave off the ".h".
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace
148c2ecf20Sopenharmony_ci *     then this macro can define the path to use. Note, the path is relative to
158c2ecf20Sopenharmony_ci *     define_trace.h, not the file including it. Full path names for out of tree
168c2ecf20Sopenharmony_ci *     modules must be used.
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#ifdef CREATE_TRACE_POINTS
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* Prevent recursion */
228c2ecf20Sopenharmony_ci#undef CREATE_TRACE_POINTS
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <linux/stringify.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#undef TRACE_EVENT
278c2ecf20Sopenharmony_ci#define TRACE_EVENT(name, proto, args, tstruct, assign, print)	\
288c2ecf20Sopenharmony_ci	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#undef TRACE_EVENT_CONDITION
318c2ecf20Sopenharmony_ci#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
328c2ecf20Sopenharmony_ci	TRACE_EVENT(name,						\
338c2ecf20Sopenharmony_ci		PARAMS(proto),						\
348c2ecf20Sopenharmony_ci		PARAMS(args),						\
358c2ecf20Sopenharmony_ci		PARAMS(tstruct),					\
368c2ecf20Sopenharmony_ci		PARAMS(assign),						\
378c2ecf20Sopenharmony_ci		PARAMS(print))
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#undef TRACE_EVENT_FN
408c2ecf20Sopenharmony_ci#define TRACE_EVENT_FN(name, proto, args, tstruct,		\
418c2ecf20Sopenharmony_ci		assign, print, reg, unreg)			\
428c2ecf20Sopenharmony_ci	DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#undef TRACE_EVENT_FN_COND
458c2ecf20Sopenharmony_ci#define TRACE_EVENT_FN_COND(name, proto, args, cond, tstruct,		\
468c2ecf20Sopenharmony_ci		assign, print, reg, unreg)			\
478c2ecf20Sopenharmony_ci	DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#undef TRACE_EVENT_NOP
508c2ecf20Sopenharmony_ci#define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_NOP
538c2ecf20Sopenharmony_ci#define DEFINE_EVENT_NOP(template, name, proto, args)
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#undef DEFINE_EVENT
568c2ecf20Sopenharmony_ci#define DEFINE_EVENT(template, name, proto, args) \
578c2ecf20Sopenharmony_ci	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_FN
608c2ecf20Sopenharmony_ci#define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
618c2ecf20Sopenharmony_ci	DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_PRINT
648c2ecf20Sopenharmony_ci#define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
658c2ecf20Sopenharmony_ci	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_CONDITION
688c2ecf20Sopenharmony_ci#define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
698c2ecf20Sopenharmony_ci	DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#undef DECLARE_TRACE
728c2ecf20Sopenharmony_ci#define DECLARE_TRACE(name, proto, args)	\
738c2ecf20Sopenharmony_ci	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE
768c2ecf20Sopenharmony_ci#undef __TRACE_INCLUDE
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#ifndef TRACE_INCLUDE_FILE
798c2ecf20Sopenharmony_ci# define TRACE_INCLUDE_FILE TRACE_SYSTEM
808c2ecf20Sopenharmony_ci# define UNDEF_TRACE_INCLUDE_FILE
818c2ecf20Sopenharmony_ci#endif
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#ifndef TRACE_INCLUDE_PATH
848c2ecf20Sopenharmony_ci# define __TRACE_INCLUDE(system) <trace/events/system.h>
858c2ecf20Sopenharmony_ci# define UNDEF_TRACE_INCLUDE_PATH
868c2ecf20Sopenharmony_ci#else
878c2ecf20Sopenharmony_ci# define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
888c2ecf20Sopenharmony_ci#endif
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci# define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/* Let the trace headers be reread */
938c2ecf20Sopenharmony_ci#define TRACE_HEADER_MULTI_READ
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/* Make all open coded DECLARE_TRACE nops */
988c2ecf20Sopenharmony_ci#undef DECLARE_TRACE
998c2ecf20Sopenharmony_ci#define DECLARE_TRACE(name, proto, args)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#ifdef TRACEPOINTS_ENABLED
1028c2ecf20Sopenharmony_ci#include <trace/trace_events.h>
1038c2ecf20Sopenharmony_ci#include <trace/perf.h>
1048c2ecf20Sopenharmony_ci#include <trace/bpf_probe.h>
1058c2ecf20Sopenharmony_ci#endif
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#undef TRACE_EVENT
1088c2ecf20Sopenharmony_ci#undef TRACE_EVENT_FN
1098c2ecf20Sopenharmony_ci#undef TRACE_EVENT_FN_COND
1108c2ecf20Sopenharmony_ci#undef TRACE_EVENT_CONDITION
1118c2ecf20Sopenharmony_ci#undef TRACE_EVENT_NOP
1128c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_NOP
1138c2ecf20Sopenharmony_ci#undef DECLARE_EVENT_CLASS
1148c2ecf20Sopenharmony_ci#undef DEFINE_EVENT
1158c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_FN
1168c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_PRINT
1178c2ecf20Sopenharmony_ci#undef DEFINE_EVENT_CONDITION
1188c2ecf20Sopenharmony_ci#undef TRACE_HEADER_MULTI_READ
1198c2ecf20Sopenharmony_ci#undef DECLARE_TRACE
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* Only undef what we defined in this file */
1228c2ecf20Sopenharmony_ci#ifdef UNDEF_TRACE_INCLUDE_FILE
1238c2ecf20Sopenharmony_ci# undef TRACE_INCLUDE_FILE
1248c2ecf20Sopenharmony_ci# undef UNDEF_TRACE_INCLUDE_FILE
1258c2ecf20Sopenharmony_ci#endif
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#ifdef UNDEF_TRACE_INCLUDE_PATH
1288c2ecf20Sopenharmony_ci# undef TRACE_INCLUDE_PATH
1298c2ecf20Sopenharmony_ci# undef UNDEF_TRACE_INCLUDE_PATH
1308c2ecf20Sopenharmony_ci#endif
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/* We may be processing more files */
1338c2ecf20Sopenharmony_ci#define CREATE_TRACE_POINTS
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#endif /* CREATE_TRACE_POINTS */
136