2 * Copyright(c) 2015 - 2018 Intel Corporation.
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
24 * - Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * - Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
30 * - Neither the name of Intel Corporation nor the names of its
31 * contributors may be used to endorse or promote products derived
32 * from this software without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 #if !defined(__HFI1_TRACE_EXTRA_H) || defined(TRACE_HEADER_MULTI_READ)
48 #define __HFI1_TRACE_EXTRA_H
50 #include <linux/tracepoint.h>
51 #include <linux/trace_seq.h>
57 * This produces a REALLY ugly trace in the console output when the string is
62 #define TRACE_SYSTEM hfi1_dbg
64 #define MAX_MSG_LEN 512
66 DECLARE_EVENT_CLASS(hfi1_trace_template
,
67 TP_PROTO(const char *function
, struct va_format
*vaf
),
68 TP_ARGS(function
, vaf
),
69 TP_STRUCT__entry(__string(function
, function
)
70 __dynamic_array(char, msg
, MAX_MSG_LEN
)
72 TP_fast_assign(__assign_str(function
, function
);
73 WARN_ON_ONCE(vsnprintf
74 (__get_dynamic_array(msg
),
75 MAX_MSG_LEN
, vaf
->fmt
,
85 * It may be nice to macroize the __hfi1_trace but the va_* stuff requires an
86 * actual function to work and can not be in a macro.
88 #define __hfi1_trace_def(lvl) \
89 void __printf(2, 3) __hfi1_trace_##lvl(const char *funct, char *fmt, ...); \
91 DEFINE_EVENT(hfi1_trace_template, hfi1_ ##lvl, \
92 TP_PROTO(const char *function, struct va_format *vaf), \
93 TP_ARGS(function, vaf))
95 #define __hfi1_trace_fn(lvl) \
96 void __printf(2, 3) __hfi1_trace_##lvl(const char *func, char *fmt, ...)\
98 struct va_format vaf = { \
103 va_start(args, fmt); \
105 trace_hfi1_ ##lvl(func, &vaf); \
111 * To create a new trace level simply define it below and as a __hfi1_trace_fn
112 * in trace.c. This will create all the hooks for calling
113 * hfi1_cdbg(LVL, fmt, ...); as well as take care of all
116 __hfi1_trace_def(AFFINITY
);
117 __hfi1_trace_def(PKT
);
118 __hfi1_trace_def(PROC
);
119 __hfi1_trace_def(SDMA
);
120 __hfi1_trace_def(LINKVERB
);
121 __hfi1_trace_def(DEBUG
);
122 __hfi1_trace_def(SNOOP
);
123 __hfi1_trace_def(CNTR
);
124 __hfi1_trace_def(PIO
);
125 __hfi1_trace_def(DC8051
);
126 __hfi1_trace_def(FIRMWARE
);
127 __hfi1_trace_def(RCVCTRL
);
128 __hfi1_trace_def(TID
);
129 __hfi1_trace_def(MMU
);
130 __hfi1_trace_def(IOCTL
);
132 #define hfi1_cdbg(which, fmt, ...) \
133 __hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
135 #define hfi1_dbg(fmt, ...) \
136 hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
139 * Define HFI1_EARLY_DBG at compile time or here to enable early trace
140 * messages. Do not check in an enablement for this.
143 #ifdef HFI1_EARLY_DBG
144 #define hfi1_dbg_early(fmt, ...) \
145 trace_printk(fmt, ##__VA_ARGS__)
147 #define hfi1_dbg_early(fmt, ...)
150 #endif /* __HFI1_TRACE_EXTRA_H */
152 #undef TRACE_INCLUDE_PATH
153 #undef TRACE_INCLUDE_FILE
154 #define TRACE_INCLUDE_PATH .
155 #define TRACE_INCLUDE_FILE trace_dbg
156 #include <trace/define_trace.h>