Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
0002 /*
0003 * Copyright(c) 2015 - 2018 Intel Corporation.
0004 */
0005 
0006 #if !defined(__HFI1_TRACE_EXTRA_H) || defined(TRACE_HEADER_MULTI_READ)
0007 #define __HFI1_TRACE_EXTRA_H
0008 
0009 #include <linux/tracepoint.h>
0010 #include <linux/trace_seq.h>
0011 
0012 #include "hfi.h"
0013 
0014 /*
0015  * Note:
0016  * This produces a REALLY ugly trace in the console output when the string is
0017  * too long.
0018  */
0019 
0020 #undef TRACE_SYSTEM
0021 #define TRACE_SYSTEM hfi1_dbg
0022 
0023 #define MAX_MSG_LEN 512
0024 
0025 DECLARE_EVENT_CLASS(hfi1_trace_template,
0026             TP_PROTO(const char *function, struct va_format *vaf),
0027             TP_ARGS(function, vaf),
0028             TP_STRUCT__entry(__string(function, function)
0029                      __vstring(msg, vaf->fmt, vaf->va)
0030                      ),
0031             TP_fast_assign(__assign_str(function, function);
0032                    __assign_vstr(msg, vaf->fmt, vaf->va);
0033                    ),
0034             TP_printk("(%s) %s",
0035                   __get_str(function),
0036                   __get_str(msg))
0037 );
0038 
0039 /*
0040  * It may be nice to macroize the __hfi1_trace but the va_* stuff requires an
0041  * actual function to work and can not be in a macro.
0042  */
0043 #define __hfi1_trace_def(lvl) \
0044 void __printf(2, 3) __hfi1_trace_##lvl(const char *funct, char *fmt, ...); \
0045                                     \
0046 DEFINE_EVENT(hfi1_trace_template, hfi1_ ##lvl,              \
0047     TP_PROTO(const char *function, struct va_format *vaf),      \
0048     TP_ARGS(function, vaf))
0049 
0050 #define __hfi1_trace_fn(lvl) \
0051 void __printf(2, 3) __hfi1_trace_##lvl(const char *func, char *fmt, ...)\
0052 {                                   \
0053     struct va_format vaf = {                    \
0054         .fmt = fmt,                     \
0055     };                              \
0056     va_list args;                           \
0057                                     \
0058     va_start(args, fmt);                        \
0059     vaf.va = &args;                         \
0060     trace_hfi1_ ##lvl(func, &vaf);                  \
0061     va_end(args);                           \
0062     return;                             \
0063 }
0064 
0065 /*
0066  * To create a new trace level simply define it below and as a __hfi1_trace_fn
0067  * in trace.c. This will create all the hooks for calling
0068  * hfi1_cdbg(LVL, fmt, ...); as well as take care of all
0069  * the debugfs stuff.
0070  */
0071 __hfi1_trace_def(AFFINITY);
0072 __hfi1_trace_def(PKT);
0073 __hfi1_trace_def(PROC);
0074 __hfi1_trace_def(SDMA);
0075 __hfi1_trace_def(LINKVERB);
0076 __hfi1_trace_def(DEBUG);
0077 __hfi1_trace_def(SNOOP);
0078 __hfi1_trace_def(CNTR);
0079 __hfi1_trace_def(PIO);
0080 __hfi1_trace_def(DC8051);
0081 __hfi1_trace_def(FIRMWARE);
0082 __hfi1_trace_def(RCVCTRL);
0083 __hfi1_trace_def(TID);
0084 __hfi1_trace_def(MMU);
0085 __hfi1_trace_def(IOCTL);
0086 
0087 #define hfi1_cdbg(which, fmt, ...) \
0088     __hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
0089 
0090 #define hfi1_dbg(fmt, ...) \
0091     hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
0092 
0093 /*
0094  * Define HFI1_EARLY_DBG at compile time or here to enable early trace
0095  * messages. Do not check in an enablement for this.
0096  */
0097 
0098 #ifdef HFI1_EARLY_DBG
0099 #define hfi1_dbg_early(fmt, ...) \
0100     trace_printk(fmt, ##__VA_ARGS__)
0101 #else
0102 #define hfi1_dbg_early(fmt, ...)
0103 #endif
0104 
0105 #endif /* __HFI1_TRACE_EXTRA_H */
0106 
0107 #undef TRACE_INCLUDE_PATH
0108 #undef TRACE_INCLUDE_FILE
0109 #define TRACE_INCLUDE_PATH .
0110 #define TRACE_INCLUDE_FILE trace_dbg
0111 #include <trace/define_trace.h>