xref: /openbmc/linux/net/batman-adv/trace.h (revision cb1aaebe)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2010-2019  B.A.T.M.A.N. contributors:
3  *
4  * Sven Eckelmann
5  */
6 
7 #if !defined(_NET_BATMAN_ADV_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
8 #define _NET_BATMAN_ADV_TRACE_H_
9 
10 #include "main.h"
11 
12 #include <linux/bug.h>
13 #include <linux/kernel.h>
14 #include <linux/netdevice.h>
15 #include <linux/percpu.h>
16 #include <linux/printk.h>
17 #include <linux/tracepoint.h>
18 #include <linux/types.h>
19 
20 #undef TRACE_SYSTEM
21 #define TRACE_SYSTEM batadv
22 
23 /* provide dummy function when tracing is disabled */
24 #if !defined(CONFIG_BATMAN_ADV_TRACING)
25 
26 #undef TRACE_EVENT
27 #define TRACE_EVENT(name, proto, ...) \
28 	static inline void trace_ ## name(proto) {}
29 
30 #endif /* CONFIG_BATMAN_ADV_TRACING */
31 
32 #define BATADV_MAX_MSG_LEN	256
33 
34 TRACE_EVENT(batadv_dbg,
35 
36 	    TP_PROTO(struct batadv_priv *bat_priv,
37 		     struct va_format *vaf),
38 
39 	    TP_ARGS(bat_priv, vaf),
40 
41 	    TP_STRUCT__entry(
42 		    __string(device, bat_priv->soft_iface->name)
43 		    __string(driver, KBUILD_MODNAME)
44 		    __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
45 	    ),
46 
47 	    TP_fast_assign(
48 		    __assign_str(device, bat_priv->soft_iface->name);
49 		    __assign_str(driver, KBUILD_MODNAME);
50 		    WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
51 					   BATADV_MAX_MSG_LEN,
52 					   vaf->fmt,
53 					   *vaf->va) >= BATADV_MAX_MSG_LEN);
54 	    ),
55 
56 	    TP_printk(
57 		    "%s %s %s",
58 		    __get_str(driver),
59 		    __get_str(device),
60 		    __get_str(msg)
61 	    )
62 );
63 
64 #endif /* _NET_BATMAN_ADV_TRACE_H_ || TRACE_HEADER_MULTI_READ */
65 
66 #undef TRACE_INCLUDE_PATH
67 #define TRACE_INCLUDE_PATH .
68 #undef TRACE_INCLUDE_FILE
69 #define TRACE_INCLUDE_FILE trace
70 
71 /* This part must be outside protection */
72 #include <trace/define_trace.h>
73