1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright(c) 2015 - 2018 Intel Corporation.
6 #if !defined(__HFI1_TRACE_EXTRA_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define __HFI1_TRACE_EXTRA_H
9 #include <linux/tracepoint.h>
10 #include <linux/trace_seq.h>
16 * This produces a REALLY ugly trace in the console output when the string is
21 #define TRACE_SYSTEM hfi1_dbg
23 #define MAX_MSG_LEN 512
25 #pragma GCC diagnostic push
27 #pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
30 DECLARE_EVENT_CLASS(hfi1_trace_template
,
31 TP_PROTO(const char *function
, struct va_format
*vaf
),
32 TP_ARGS(function
, vaf
),
33 TP_STRUCT__entry(__string(function
, function
)
34 __vstring(msg
, vaf
->fmt
, vaf
->va
)
36 TP_fast_assign(__assign_str(function
);
37 __assign_vstr(msg
, vaf
->fmt
, vaf
->va
);
44 #pragma GCC diagnostic pop
47 * It may be nice to macroize the __hfi1_trace but the va_* stuff requires an
48 * actual function to work and can not be in a macro.
50 #define __hfi1_trace_def(lvl) \
51 void __printf(2, 3) __hfi1_trace_##lvl(const char *funct, char *fmt, ...); \
53 DEFINE_EVENT(hfi1_trace_template, hfi1_ ##lvl, \
54 TP_PROTO(const char *function, struct va_format *vaf), \
55 TP_ARGS(function, vaf))
57 #define __hfi1_trace_fn(lvl) \
58 void __printf(2, 3) __hfi1_trace_##lvl(const char *func, char *fmt, ...)\
60 struct va_format vaf = { \
65 va_start(args, fmt); \
67 trace_hfi1_ ##lvl(func, &vaf); \
73 * To create a new trace level simply define it below and as a __hfi1_trace_fn
74 * in trace.c. This will create all the hooks for calling
75 * hfi1_cdbg(LVL, fmt, ...); as well as take care of all
78 __hfi1_trace_def(AFFINITY
);
79 __hfi1_trace_def(PKT
);
80 __hfi1_trace_def(PROC
);
81 __hfi1_trace_def(SDMA
);
82 __hfi1_trace_def(LINKVERB
);
83 __hfi1_trace_def(DEBUG
);
84 __hfi1_trace_def(SNOOP
);
85 __hfi1_trace_def(CNTR
);
86 __hfi1_trace_def(PIO
);
87 __hfi1_trace_def(DC8051
);
88 __hfi1_trace_def(FIRMWARE
);
89 __hfi1_trace_def(RCVCTRL
);
90 __hfi1_trace_def(TID
);
91 __hfi1_trace_def(MMU
);
92 __hfi1_trace_def(IOCTL
);
94 #define hfi1_cdbg(which, fmt, ...) \
95 __hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
97 #define hfi1_dbg(fmt, ...) \
98 hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
101 * Define HFI1_EARLY_DBG at compile time or here to enable early trace
102 * messages. Do not check in an enablement for this.
105 #ifdef HFI1_EARLY_DBG
106 #define hfi1_dbg_early(fmt, ...) \
107 trace_printk(fmt, ##__VA_ARGS__)
109 #define hfi1_dbg_early(fmt, ...)
112 #endif /* __HFI1_TRACE_EXTRA_H */
114 #undef TRACE_INCLUDE_PATH
115 #undef TRACE_INCLUDE_FILE
116 #define TRACE_INCLUDE_PATH .
117 #define TRACE_INCLUDE_FILE trace_dbg
118 #include <trace/define_trace.h>