xref: /linux/net/batman-adv/trace.h (revision bd628c1bed7902ec1f24ba0fe70758949146abbe)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2010-2018  B.A.T.M.A.N. contributors:
3  *
4  * Sven Eckelmann
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #if !defined(_NET_BATMAN_ADV_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
20 #define _NET_BATMAN_ADV_TRACE_H_
21 
22 #include "main.h"
23 
24 #include <linux/bug.h>
25 #include <linux/kernel.h>
26 #include <linux/netdevice.h>
27 #include <linux/percpu.h>
28 #include <linux/printk.h>
29 #include <linux/tracepoint.h>
30 #include <linux/types.h>
31 
32 #undef TRACE_SYSTEM
33 #define TRACE_SYSTEM batadv
34 
35 /* provide dummy function when tracing is disabled */
36 #if !defined(CONFIG_BATMAN_ADV_TRACING)
37 
38 #undef TRACE_EVENT
39 #define TRACE_EVENT(name, proto, ...) \
40 	static inline void trace_ ## name(proto) {}
41 
42 #endif /* CONFIG_BATMAN_ADV_TRACING */
43 
44 #define BATADV_MAX_MSG_LEN	256
45 
46 TRACE_EVENT(batadv_dbg,
47 
48 	    TP_PROTO(struct batadv_priv *bat_priv,
49 		     struct va_format *vaf),
50 
51 	    TP_ARGS(bat_priv, vaf),
52 
53 	    TP_STRUCT__entry(
54 		    __string(device, bat_priv->soft_iface->name)
55 		    __string(driver, KBUILD_MODNAME)
56 		    __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
57 	    ),
58 
59 	    TP_fast_assign(
60 		    __assign_str(device, bat_priv->soft_iface->name);
61 		    __assign_str(driver, KBUILD_MODNAME);
62 		    WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
63 					   BATADV_MAX_MSG_LEN,
64 					   vaf->fmt,
65 					   *vaf->va) >= BATADV_MAX_MSG_LEN);
66 	    ),
67 
68 	    TP_printk(
69 		    "%s %s %s",
70 		    __get_str(driver),
71 		    __get_str(device),
72 		    __get_str(msg)
73 	    )
74 );
75 
76 #endif /* _NET_BATMAN_ADV_TRACE_H_ || TRACE_HEADER_MULTI_READ */
77 
78 #undef TRACE_INCLUDE_PATH
79 #define TRACE_INCLUDE_PATH .
80 #undef TRACE_INCLUDE_FILE
81 #define TRACE_INCLUDE_FILE trace
82 
83 /* This part must be outside protection */
84 #include <trace/define_trace.h>
85