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