Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2/*
  3* Copyright(c) 2015 - 2018 Intel Corporation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  4*/
  5
  6#if !defined(__HFI1_TRACE_EXTRA_H) || defined(TRACE_HEADER_MULTI_READ)
  7#define __HFI1_TRACE_EXTRA_H
  8
  9#include <linux/tracepoint.h>
 10#include <linux/trace_seq.h>
 11
 12#include "hfi.h"
 13
 14/*
 15 * Note:
 16 * This produces a REALLY ugly trace in the console output when the string is
 17 * too long.
 18 */
 19
 20#undef TRACE_SYSTEM
 21#define TRACE_SYSTEM hfi1_dbg
 22
 23#define MAX_MSG_LEN 512
 24
 25#pragma GCC diagnostic push
 26#ifndef __clang__
 27#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
 28#endif
 29
 30DECLARE_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)
 35				     ),
 36		    TP_fast_assign(__assign_str(function, function);
 37				   __assign_vstr(msg, vaf->fmt, vaf->va);
 
 
 
 
 38				   ),
 39		    TP_printk("(%s) %s",
 40			      __get_str(function),
 41			      __get_str(msg))
 42);
 43
 44#pragma GCC diagnostic pop
 45
 46/*
 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.
 49 */
 50#define __hfi1_trace_def(lvl) \
 51void __printf(2, 3) __hfi1_trace_##lvl(const char *funct, char *fmt, ...); \
 52									\
 53DEFINE_EVENT(hfi1_trace_template, hfi1_ ##lvl,				\
 54	TP_PROTO(const char *function, struct va_format *vaf),		\
 55	TP_ARGS(function, vaf))
 56
 57#define __hfi1_trace_fn(lvl) \
 58void __printf(2, 3) __hfi1_trace_##lvl(const char *func, char *fmt, ...)\
 59{									\
 60	struct va_format vaf = {					\
 61		.fmt = fmt,						\
 62	};								\
 63	va_list args;							\
 64									\
 65	va_start(args, fmt);						\
 66	vaf.va = &args;							\
 67	trace_hfi1_ ##lvl(func, &vaf);					\
 68	va_end(args);							\
 69	return;								\
 70}
 71
 72/*
 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
 76 * the debugfs stuff.
 77 */
 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);
 93
 94#define hfi1_cdbg(which, fmt, ...) \
 95	__hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
 96
 97#define hfi1_dbg(fmt, ...) \
 98	hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
 99
100/*
101 * Define HFI1_EARLY_DBG at compile time or here to enable early trace
102 * messages. Do not check in an enablement for this.
103 */
104
105#ifdef HFI1_EARLY_DBG
106#define hfi1_dbg_early(fmt, ...) \
107	trace_printk(fmt, ##__VA_ARGS__)
108#else
109#define hfi1_dbg_early(fmt, ...)
110#endif
111
112#endif /* __HFI1_TRACE_EXTRA_H */
113
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>
v5.4
 
  1/*
  2* Copyright(c) 2015 - 2018 Intel Corporation.
  3*
  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.
  6*
  7* GPL LICENSE SUMMARY
  8*
  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.
 12*
 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.
 17*
 18* BSD LICENSE
 19*
 20* Redistribution and use in source and binary forms, with or without
 21* modification, are permitted provided that the following conditions
 22* are met:
 23*
 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
 29*    distribution.
 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.
 33*
 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.
 45*
 46*/
 
 47#if !defined(__HFI1_TRACE_EXTRA_H) || defined(TRACE_HEADER_MULTI_READ)
 48#define __HFI1_TRACE_EXTRA_H
 49
 50#include <linux/tracepoint.h>
 51#include <linux/trace_seq.h>
 52
 53#include "hfi.h"
 54
 55/*
 56 * Note:
 57 * This produces a REALLY ugly trace in the console output when the string is
 58 * too long.
 59 */
 60
 61#undef TRACE_SYSTEM
 62#define TRACE_SYSTEM hfi1_dbg
 63
 64#define MAX_MSG_LEN 512
 65
 
 
 
 
 
 66DECLARE_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)
 71				     ),
 72		    TP_fast_assign(__assign_str(function, function);
 73				   WARN_ON_ONCE(vsnprintf
 74						(__get_dynamic_array(msg),
 75						 MAX_MSG_LEN, vaf->fmt,
 76						 *vaf->va) >=
 77						MAX_MSG_LEN);
 78				   ),
 79		    TP_printk("(%s) %s",
 80			      __get_str(function),
 81			      __get_str(msg))
 82);
 
 
 83
 84/*
 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.
 87 */
 88#define __hfi1_trace_def(lvl) \
 89void __printf(2, 3) __hfi1_trace_##lvl(const char *funct, char *fmt, ...); \
 90									\
 91DEFINE_EVENT(hfi1_trace_template, hfi1_ ##lvl,				\
 92	TP_PROTO(const char *function, struct va_format *vaf),		\
 93	TP_ARGS(function, vaf))
 94
 95#define __hfi1_trace_fn(lvl) \
 96void __printf(2, 3) __hfi1_trace_##lvl(const char *func, char *fmt, ...)\
 97{									\
 98	struct va_format vaf = {					\
 99		.fmt = fmt,						\
100	};								\
101	va_list args;							\
102									\
103	va_start(args, fmt);						\
104	vaf.va = &args;							\
105	trace_hfi1_ ##lvl(func, &vaf);					\
106	va_end(args);							\
107	return;								\
108}
109
110/*
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
114 * the debugfs stuff.
115 */
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);
131
132#define hfi1_cdbg(which, fmt, ...) \
133	__hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
134
135#define hfi1_dbg(fmt, ...) \
136	hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
137
138/*
139 * Define HFI1_EARLY_DBG at compile time or here to enable early trace
140 * messages. Do not check in an enablement for this.
141 */
142
143#ifdef HFI1_EARLY_DBG
144#define hfi1_dbg_early(fmt, ...) \
145	trace_printk(fmt, ##__VA_ARGS__)
146#else
147#define hfi1_dbg_early(fmt, ...)
148#endif
149
150#endif /* __HFI1_TRACE_EXTRA_H */
151
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>