2 * Copyright(c) 2015, 2016 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 __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 __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(PKT);
117 __hfi1_trace_def(PROC);
118 __hfi1_trace_def(SDMA);
119 __hfi1_trace_def(LINKVERB);
120 __hfi1_trace_def(DEBUG);
121 __hfi1_trace_def(SNOOP);
122 __hfi1_trace_def(CNTR);
123 __hfi1_trace_def(PIO);
124 __hfi1_trace_def(DC8051);
125 __hfi1_trace_def(FIRMWARE);
126 __hfi1_trace_def(RCVCTRL);
127 __hfi1_trace_def(TID);
128 __hfi1_trace_def(MMU);
129 __hfi1_trace_def(IOCTL);
131 #define hfi1_cdbg(which, fmt, ...) \
132 __hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
134 #define hfi1_dbg(fmt, ...) \
135 hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
138 * Define HFI1_EARLY_DBG at compile time or here to enable early trace
139 * messages. Do not check in an enablement for this.
142 #ifdef HFI1_EARLY_DBG
143 #define hfi1_dbg_early(fmt, ...) \
144 trace_printk(fmt, ##__VA_ARGS__)
146 #define hfi1_dbg_early(fmt, ...)
149 #endif /* __HFI1_TRACE_EXTRA_H */
151 #undef TRACE_INCLUDE_PATH
152 #undef TRACE_INCLUDE_FILE
153 #define TRACE_INCLUDE_PATH .
154 #define TRACE_INCLUDE_FILE trace_dbg
155 #include <trace/define_trace.h>