1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if IS_ENABLED(CONFIG_NET_DEVLINK)
5 #define TRACE_SYSTEM devlink
7 #if !defined(_TRACE_DEVLINK_H) || defined(TRACE_HEADER_MULTI_READ)
8 #define _TRACE_DEVLINK_H
10 #include <linux/device.h>
11 #include <net/devlink.h>
12 #include <linux/tracepoint.h>
15 * Tracepoint for devlink hardware message:
17 TRACE_EVENT(devlink_hwmsg
,
18 TP_PROTO(const struct devlink
*devlink
, bool incoming
,
19 unsigned long type
, const u8
*buf
, size_t len
),
21 TP_ARGS(devlink
, incoming
, type
, buf
, len
),
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
)
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
;
39 memcpy(__get_dynamic_array(buf
), buf
, len
);
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
)
50 * Tracepoint for devlink hardware error:
52 TRACE_EVENT(devlink_hwerr
,
53 TP_PROTO(const struct devlink
*devlink
, int err
, const char *msg
),
55 TP_ARGS(devlink
, err
, msg
),
58 __string(bus_name
, devlink
->dev
->bus
->name
)
59 __string(dev_name
, dev_name(devlink
->dev
))
60 __string(driver_name
, devlink
->dev
->driver
->name
)
66 __assign_str(bus_name
, devlink
->dev
->bus
->name
);
67 __assign_str(dev_name
, dev_name(devlink
->dev
));
68 __assign_str(driver_name
, devlink
->dev
->driver
->name
);
70 __assign_str(msg
, msg
);
73 TP_printk("bus_name=%s dev_name=%s driver_name=%s err=%d %s",
74 __get_str(bus_name
), __get_str(dev_name
),
75 __get_str(driver_name
), __entry
->err
, __get_str(msg
))
79 * Tracepoint for devlink health message:
81 TRACE_EVENT(devlink_health_report
,
82 TP_PROTO(const struct devlink
*devlink
, const char *reporter_name
,
85 TP_ARGS(devlink
, reporter_name
, msg
),
88 __string(bus_name
, devlink
->dev
->bus
->name
)
89 __string(dev_name
, dev_name(devlink
->dev
))
90 __string(driver_name
, devlink
->dev
->driver
->name
)
91 __string(reporter_name
, msg
)
96 __assign_str(bus_name
, devlink
->dev
->bus
->name
);
97 __assign_str(dev_name
, dev_name(devlink
->dev
));
98 __assign_str(driver_name
, devlink
->dev
->driver
->name
);
99 __assign_str(reporter_name
, reporter_name
);
100 __assign_str(msg
, msg
);
103 TP_printk("bus_name=%s dev_name=%s driver_name=%s reporter_name=%s: %s",
104 __get_str(bus_name
), __get_str(dev_name
),
105 __get_str(driver_name
), __get_str(reporter_name
),
110 * Tracepoint for devlink health recover aborted message:
112 TRACE_EVENT(devlink_health_recover_aborted
,
113 TP_PROTO(const struct devlink
*devlink
, const char *reporter_name
,
114 bool health_state
, u64 time_since_last_recover
),
116 TP_ARGS(devlink
, reporter_name
, health_state
, time_since_last_recover
),
119 __string(bus_name
, devlink
->dev
->bus
->name
)
120 __string(dev_name
, dev_name(devlink
->dev
))
121 __string(driver_name
, devlink
->dev
->driver
->name
)
122 __string(reporter_name
, reporter_name
)
123 __field(bool, health_state
)
124 __field(u64
, time_since_last_recover
)
128 __assign_str(bus_name
, devlink
->dev
->bus
->name
);
129 __assign_str(dev_name
, dev_name(devlink
->dev
));
130 __assign_str(driver_name
, devlink
->dev
->driver
->name
);
131 __assign_str(reporter_name
, reporter_name
);
132 __entry
->health_state
= health_state
;
133 __entry
->time_since_last_recover
= time_since_last_recover
;
136 TP_printk("bus_name=%s dev_name=%s driver_name=%s reporter_name=%s: health_state=%d time_since_last_recover=%llu recover aborted",
137 __get_str(bus_name
), __get_str(dev_name
),
138 __get_str(driver_name
), __get_str(reporter_name
),
139 __entry
->health_state
,
140 __entry
->time_since_last_recover
)
144 * Tracepoint for devlink health reporter state update:
146 TRACE_EVENT(devlink_health_reporter_state_update
,
147 TP_PROTO(const struct devlink
*devlink
, const char *reporter_name
,
150 TP_ARGS(devlink
, reporter_name
, new_state
),
153 __string(bus_name
, devlink
->dev
->bus
->name
)
154 __string(dev_name
, dev_name(devlink
->dev
))
155 __string(driver_name
, devlink
->dev
->driver
->name
)
156 __string(reporter_name
, reporter_name
)
157 __field(u8
, new_state
)
161 __assign_str(bus_name
, devlink
->dev
->bus
->name
);
162 __assign_str(dev_name
, dev_name(devlink
->dev
));
163 __assign_str(driver_name
, devlink
->dev
->driver
->name
);
164 __assign_str(reporter_name
, reporter_name
);
165 __entry
->new_state
= new_state
;
168 TP_printk("bus_name=%s dev_name=%s driver_name=%s reporter_name=%s: new_state=%d",
169 __get_str(bus_name
), __get_str(dev_name
),
170 __get_str(driver_name
), __get_str(reporter_name
),
175 * Tracepoint for devlink packet trap:
177 TRACE_EVENT(devlink_trap_report
,
178 TP_PROTO(const struct devlink
*devlink
, struct sk_buff
*skb
,
179 const struct devlink_trap_metadata
*metadata
),
181 TP_ARGS(devlink
, skb
, metadata
),
184 __string(bus_name
, devlink
->dev
->bus
->name
)
185 __string(dev_name
, dev_name(devlink
->dev
))
186 __string(driver_name
, devlink
->dev
->driver
->name
)
187 __string(trap_name
, metadata
->trap_name
)
188 __string(trap_group_name
, metadata
->trap_group_name
)
189 __dynamic_array(char, input_dev_name
, IFNAMSIZ
)
193 struct net_device
*input_dev
= metadata
->input_dev
;
195 __assign_str(bus_name
, devlink
->dev
->bus
->name
);
196 __assign_str(dev_name
, dev_name(devlink
->dev
));
197 __assign_str(driver_name
, devlink
->dev
->driver
->name
);
198 __assign_str(trap_name
, metadata
->trap_name
);
199 __assign_str(trap_group_name
, metadata
->trap_group_name
);
200 __assign_str(input_dev_name
,
201 (input_dev
? input_dev
->name
: "NULL"));
204 TP_printk("bus_name=%s dev_name=%s driver_name=%s trap_name=%s "
205 "trap_group_name=%s input_dev_name=%s", __get_str(bus_name
),
206 __get_str(dev_name
), __get_str(driver_name
),
207 __get_str(trap_name
), __get_str(trap_group_name
),
208 __get_str(input_dev_name
))
211 #endif /* _TRACE_DEVLINK_H */
213 /* This part must be outside protection */
214 #include <trace/define_trace.h>
216 #else /* CONFIG_NET_DEVLINK */
218 #if !defined(_TRACE_DEVLINK_H)
219 #define _TRACE_DEVLINK_H
221 #include <net/devlink.h>
223 static inline void trace_devlink_hwmsg(const struct devlink
*devlink
,
224 bool incoming
, unsigned long type
,
225 const u8
*buf
, size_t len
)
229 static inline void trace_devlink_hwerr(const struct devlink
*devlink
,
230 int err
, const char *msg
)
233 #endif /* _TRACE_DEVLINK_H */