1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if IS_ENABLED(CONFIG_NET_DEVLINK)
3 
4 #undef TRACE_SYSTEM
5 #define TRACE_SYSTEM devlink
6 
7 #if !defined(_TRACE_DEVLINK_H) || defined(TRACE_HEADER_MULTI_READ)
8 #define _TRACE_DEVLINK_H
9 
10 #include <linux/device.h>
11 #include <net/devlink.h>
12 #include <linux/tracepoint.h>
13 
14 /*
15  * Tracepoint for devlink hardware message:
16  */
17 TRACE_EVENT(devlink_hwmsg,
18 	TP_PROTO(const struct devlink *devlink, bool incoming,
19 		 unsigned long type, const u8 *buf, size_t len),
20 
21 	TP_ARGS(devlink, incoming, type, buf, len),
22 
23 	TP_STRUCT__entry(
24 		__string(bus_name, devlink->dev->bus->name)
25 		__string(dev_name, dev_name(devlink->dev))
26 		__string(driver_name, devlink->dev->driver->name)
27 		__field(bool, incoming)
28 		__field(unsigned long, type)
29 		__dynamic_array(u8, buf, len)
30 		__field(size_t, len)
31 	),
32 
33 	TP_fast_assign(
34 		__assign_str(bus_name, devlink->dev->bus->name);
35 		__assign_str(dev_name, dev_name(devlink->dev));
36 		__assign_str(driver_name, devlink->dev->driver->name);
37 		__entry->incoming = incoming;
38 		__entry->type = type;
39 		memcpy(__get_dynamic_array(buf), buf, len);
40 		__entry->len = len;
41 	),
42 
43 	TP_printk("bus_name=%s dev_name=%s driver_name=%s incoming=%d type=%lu buf=0x[%*phD] len=%zu",
44 		  __get_str(bus_name), __get_str(dev_name),
45 		  __get_str(driver_name), __entry->incoming, __entry->type,
46 		  (int) __entry->len, __get_dynamic_array(buf), __entry->len)
47 );
48 
49 #endif /* _TRACE_DEVLINK_H */
50 
51 /* This part must be outside protection */
52 #include <trace/define_trace.h>
53 
54 #else /* CONFIG_NET_DEVLINK */
55 
56 #if !defined(_TRACE_DEVLINK_H)
57 #define _TRACE_DEVLINK_H
58 
59 #include <net/devlink.h>
60 
trace_devlink_hwmsg(const struct devlink * devlink,bool incoming,unsigned long type,const u8 * buf,size_t len)61 static inline void trace_devlink_hwmsg(const struct devlink *devlink,
62 				       bool incoming, unsigned long type,
63 				       const u8 *buf, size_t len)
64 {
65 }
66 
67 #endif /* _TRACE_DEVLINK_H */
68 
69 #endif
70