xref: /linux/net/ieee802154/trace.h (revision 36ec807b627b4c0a0a382f0ae48eac7187d14b2b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Based on net/wireless/trace.h */
3 
4 #undef TRACE_SYSTEM
5 #define TRACE_SYSTEM cfg802154
6 
7 #if !defined(__RDEV_CFG802154_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ)
8 #define __RDEV_CFG802154_OPS_TRACE
9 
10 #include <linux/tracepoint.h>
11 
12 #include <net/cfg802154.h>
13 
14 #define MAXNAME		32
15 #define WPAN_PHY_ENTRY	__array(char, wpan_phy_name, MAXNAME)
16 #define WPAN_PHY_ASSIGN	strscpy(__entry->wpan_phy_name,	 \
17 				wpan_phy_name(wpan_phy), \
18 				MAXNAME)
19 #define WPAN_PHY_PR_FMT	"%s"
20 #define WPAN_PHY_PR_ARG	__entry->wpan_phy_name
21 
22 #define WPAN_DEV_ENTRY	__field(u32, identifier)
23 #define WPAN_DEV_ASSIGN	(__entry->identifier) = (!IS_ERR_OR_NULL(wpan_dev) \
24 					 ? wpan_dev->identifier : 0)
25 #define WPAN_DEV_PR_FMT	"wpan_dev(%u)"
26 #define WPAN_DEV_PR_ARG	(__entry->identifier)
27 
28 #define WPAN_CCA_ENTRY	__field(enum nl802154_cca_modes, cca_mode) \
29 			__field(enum nl802154_cca_opts, cca_opt)
30 #define WPAN_CCA_ASSIGN \
31 	do {					 \
32 		(__entry->cca_mode) = cca->mode; \
33 		(__entry->cca_opt) = cca->opt;	 \
34 	} while (0)
35 #define WPAN_CCA_PR_FMT	"cca_mode: %d, cca_opt: %d"
36 #define WPAN_CCA_PR_ARG __entry->cca_mode, __entry->cca_opt
37 
38 #define BOOL_TO_STR(bo) (bo) ? "true" : "false"
39 
40 /*************************************************************
41  *			rdev->ops traces		     *
42  *************************************************************/
43 
44 DECLARE_EVENT_CLASS(wpan_phy_only_evt,
45 	TP_PROTO(struct wpan_phy *wpan_phy),
46 	TP_ARGS(wpan_phy),
47 	TP_STRUCT__entry(
48 		WPAN_PHY_ENTRY
49 	),
50 	TP_fast_assign(
51 		WPAN_PHY_ASSIGN;
52 	),
53 	TP_printk(WPAN_PHY_PR_FMT, WPAN_PHY_PR_ARG)
54 );
55 
56 DEFINE_EVENT(wpan_phy_only_evt, 802154_rdev_suspend,
57 	TP_PROTO(struct wpan_phy *wpan_phy),
58 	TP_ARGS(wpan_phy)
59 );
60 
61 DEFINE_EVENT(wpan_phy_only_evt, 802154_rdev_resume,
62 	TP_PROTO(struct wpan_phy *wpan_phy),
63 	TP_ARGS(wpan_phy)
64 );
65 
66 TRACE_EVENT(802154_rdev_add_virtual_intf,
67 	TP_PROTO(struct wpan_phy *wpan_phy, char *name,
68 		 enum nl802154_iftype type, __le64 extended_addr),
69 	TP_ARGS(wpan_phy, name, type, extended_addr),
70 	TP_STRUCT__entry(
71 		WPAN_PHY_ENTRY
72 		__string(vir_intf_name, name ? name : "<noname>")
73 		__field(enum nl802154_iftype, type)
74 		__field(__le64, extended_addr)
75 	),
76 	TP_fast_assign(
77 		WPAN_PHY_ASSIGN;
78 		__assign_str(vir_intf_name);
79 		__entry->type = type;
80 		__entry->extended_addr = extended_addr;
81 	),
82 	TP_printk(WPAN_PHY_PR_FMT ", virtual intf name: %s, type: %d, extended addr: 0x%llx",
83 		  WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
84 		  __le64_to_cpu(__entry->extended_addr))
85 );
86 
87 TRACE_EVENT(802154_rdev_del_virtual_intf,
88 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
89 	TP_ARGS(wpan_phy, wpan_dev),
90 	TP_STRUCT__entry(
91 		WPAN_PHY_ENTRY
92 		WPAN_DEV_ENTRY
93 	),
94 	TP_fast_assign(
95 		WPAN_PHY_ASSIGN;
96 		WPAN_DEV_ASSIGN;
97 	),
98 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT, WPAN_PHY_PR_ARG,
99 		  WPAN_DEV_PR_ARG)
100 );
101 
102 TRACE_EVENT(802154_rdev_set_channel,
103 	TP_PROTO(struct wpan_phy *wpan_phy, u8 page, u8 channel),
104 	TP_ARGS(wpan_phy, page, channel),
105 	TP_STRUCT__entry(
106 		WPAN_PHY_ENTRY
107 		__field(u8, page)
108 		__field(u8, channel)
109 	),
110 	TP_fast_assign(
111 		WPAN_PHY_ASSIGN;
112 		__entry->page = page;
113 		__entry->channel = channel;
114 	),
115 	TP_printk(WPAN_PHY_PR_FMT ", page: %d, channel: %d", WPAN_PHY_PR_ARG,
116 		  __entry->page, __entry->channel)
117 );
118 
119 TRACE_EVENT(802154_rdev_set_tx_power,
120 	TP_PROTO(struct wpan_phy *wpan_phy, s32 power),
121 	TP_ARGS(wpan_phy, power),
122 	TP_STRUCT__entry(
123 		WPAN_PHY_ENTRY
124 		__field(s32, power)
125 	),
126 	TP_fast_assign(
127 		WPAN_PHY_ASSIGN;
128 		__entry->power = power;
129 	),
130 	TP_printk(WPAN_PHY_PR_FMT ", mbm: %d", WPAN_PHY_PR_ARG,
131 		  __entry->power)
132 );
133 
134 TRACE_EVENT(802154_rdev_set_cca_mode,
135 	TP_PROTO(struct wpan_phy *wpan_phy, const struct wpan_phy_cca *cca),
136 	TP_ARGS(wpan_phy, cca),
137 	TP_STRUCT__entry(
138 		WPAN_PHY_ENTRY
139 		WPAN_CCA_ENTRY
140 	),
141 	TP_fast_assign(
142 		WPAN_PHY_ASSIGN;
143 		WPAN_CCA_ASSIGN;
144 	),
145 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_CCA_PR_FMT, WPAN_PHY_PR_ARG,
146 		  WPAN_CCA_PR_ARG)
147 );
148 
149 TRACE_EVENT(802154_rdev_set_cca_ed_level,
150 	TP_PROTO(struct wpan_phy *wpan_phy, s32 ed_level),
151 	TP_ARGS(wpan_phy, ed_level),
152 	TP_STRUCT__entry(
153 		WPAN_PHY_ENTRY
154 		__field(s32, ed_level)
155 	),
156 	TP_fast_assign(
157 		WPAN_PHY_ASSIGN;
158 		__entry->ed_level = ed_level;
159 	),
160 	TP_printk(WPAN_PHY_PR_FMT ", ed level: %d", WPAN_PHY_PR_ARG,
161 		  __entry->ed_level)
162 );
163 
164 DECLARE_EVENT_CLASS(802154_le16_template,
165 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
166 		 __le16 le16arg),
167 	TP_ARGS(wpan_phy, wpan_dev, le16arg),
168 	TP_STRUCT__entry(
169 		WPAN_PHY_ENTRY
170 		WPAN_DEV_ENTRY
171 		__field(__le16, le16arg)
172 	),
173 	TP_fast_assign(
174 		WPAN_PHY_ASSIGN;
175 		WPAN_DEV_ASSIGN;
176 		__entry->le16arg = le16arg;
177 	),
178 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x",
179 		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
180 		  __le16_to_cpu(__entry->le16arg))
181 );
182 
183 DEFINE_EVENT(802154_le16_template, 802154_rdev_set_pan_id,
184 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
185 		 __le16 le16arg),
186 	TP_ARGS(wpan_phy, wpan_dev, le16arg)
187 );
188 
189 DEFINE_EVENT_PRINT(802154_le16_template, 802154_rdev_set_short_addr,
190 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
191 		 __le16 le16arg),
192 	TP_ARGS(wpan_phy, wpan_dev, le16arg),
193 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", short addr: 0x%04x",
194 		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
195 		  __le16_to_cpu(__entry->le16arg))
196 );
197 
198 TRACE_EVENT(802154_rdev_set_backoff_exponent,
199 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
200 		 u8 min_be, u8 max_be),
201 	TP_ARGS(wpan_phy, wpan_dev, min_be, max_be),
202 	TP_STRUCT__entry(
203 		WPAN_PHY_ENTRY
204 		WPAN_DEV_ENTRY
205 		__field(u8, min_be)
206 		__field(u8, max_be)
207 	),
208 	TP_fast_assign(
209 		WPAN_PHY_ASSIGN;
210 		WPAN_DEV_ASSIGN;
211 		__entry->min_be = min_be;
212 		__entry->max_be = max_be;
213 	),
214 
215 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
216 		  ", min be: %d, max be: %d", WPAN_PHY_PR_ARG,
217 		  WPAN_DEV_PR_ARG, __entry->min_be, __entry->max_be)
218 );
219 
220 TRACE_EVENT(802154_rdev_set_csma_backoffs,
221 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
222 		 u8 max_csma_backoffs),
223 	TP_ARGS(wpan_phy, wpan_dev, max_csma_backoffs),
224 	TP_STRUCT__entry(
225 		WPAN_PHY_ENTRY
226 		WPAN_DEV_ENTRY
227 		__field(u8, max_csma_backoffs)
228 	),
229 	TP_fast_assign(
230 		WPAN_PHY_ASSIGN;
231 		WPAN_DEV_ASSIGN;
232 		__entry->max_csma_backoffs = max_csma_backoffs;
233 	),
234 
235 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
236 		  ", max csma backoffs: %d", WPAN_PHY_PR_ARG,
237 		  WPAN_DEV_PR_ARG, __entry->max_csma_backoffs)
238 );
239 
240 TRACE_EVENT(802154_rdev_set_max_frame_retries,
241 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
242 		 s8 max_frame_retries),
243 	TP_ARGS(wpan_phy, wpan_dev, max_frame_retries),
244 	TP_STRUCT__entry(
245 		WPAN_PHY_ENTRY
246 		WPAN_DEV_ENTRY
247 		__field(s8, max_frame_retries)
248 	),
249 	TP_fast_assign(
250 		WPAN_PHY_ASSIGN;
251 		WPAN_DEV_ASSIGN;
252 		__entry->max_frame_retries = max_frame_retries;
253 	),
254 
255 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
256 		  ", max frame retries: %d", WPAN_PHY_PR_ARG,
257 		  WPAN_DEV_PR_ARG, __entry->max_frame_retries)
258 );
259 
260 TRACE_EVENT(802154_rdev_set_lbt_mode,
261 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
262 		 bool mode),
263 	TP_ARGS(wpan_phy, wpan_dev, mode),
264 	TP_STRUCT__entry(
265 		WPAN_PHY_ENTRY
266 		WPAN_DEV_ENTRY
267 		__field(bool, mode)
268 	),
269 	TP_fast_assign(
270 		WPAN_PHY_ASSIGN;
271 		WPAN_DEV_ASSIGN;
272 		__entry->mode = mode;
273 	),
274 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
275 		", lbt mode: %s", WPAN_PHY_PR_ARG,
276 		WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode))
277 );
278 
279 TRACE_EVENT(802154_rdev_set_ackreq_default,
280 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
281 		 bool ackreq),
282 	TP_ARGS(wpan_phy, wpan_dev, ackreq),
283 	TP_STRUCT__entry(
284 		WPAN_PHY_ENTRY
285 		WPAN_DEV_ENTRY
286 		__field(bool, ackreq)
287 	),
288 	TP_fast_assign(
289 		WPAN_PHY_ASSIGN;
290 		WPAN_DEV_ASSIGN;
291 		__entry->ackreq = ackreq;
292 	),
293 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
294 		", ackreq default: %s", WPAN_PHY_PR_ARG,
295 		WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->ackreq))
296 );
297 
298 TRACE_EVENT(802154_rdev_trigger_scan,
299 	TP_PROTO(struct wpan_phy *wpan_phy,
300 		 struct cfg802154_scan_request *request),
301 	TP_ARGS(wpan_phy, request),
302 	TP_STRUCT__entry(
303 		WPAN_PHY_ENTRY
304 		__field(u8, page)
305 		__field(u32, channels)
306 		__field(u8, duration)
307 	),
308 	TP_fast_assign(
309 		WPAN_PHY_ASSIGN;
310 		__entry->page = request->page;
311 		__entry->channels = request->channels;
312 		__entry->duration = request->duration;
313 	),
314 	TP_printk(WPAN_PHY_PR_FMT ", scan, page: %d, channels: %x, duration %d",
315 		  WPAN_PHY_PR_ARG, __entry->page, __entry->channels, __entry->duration)
316 );
317 
318 TRACE_EVENT(802154_rdev_send_beacons,
319 	TP_PROTO(struct wpan_phy *wpan_phy,
320 		 struct cfg802154_beacon_request *request),
321 	TP_ARGS(wpan_phy, request),
322 	TP_STRUCT__entry(
323 		WPAN_PHY_ENTRY
324 		__field(u8, interval)
325 	),
326 	TP_fast_assign(
327 		WPAN_PHY_ASSIGN;
328 		__entry->interval = request->interval;
329 	),
330 	TP_printk(WPAN_PHY_PR_FMT ", sending beacons (interval order: %d)",
331 		  WPAN_PHY_PR_ARG, __entry->interval)
332 );
333 
334 DECLARE_EVENT_CLASS(802154_wdev_template,
335 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
336 	TP_ARGS(wpan_phy, wpan_dev),
337 	TP_STRUCT__entry(
338 		WPAN_PHY_ENTRY
339 		WPAN_DEV_ENTRY
340 	),
341 	TP_fast_assign(
342 		WPAN_PHY_ASSIGN;
343 		WPAN_DEV_ASSIGN;
344 	),
345 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT,
346 		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG)
347 );
348 
349 DEFINE_EVENT(802154_wdev_template, 802154_rdev_abort_scan,
350 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
351 	TP_ARGS(wpan_phy, wpan_dev)
352 );
353 
354 DEFINE_EVENT(802154_wdev_template, 802154_rdev_stop_beacons,
355 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
356 	TP_ARGS(wpan_phy, wpan_dev)
357 );
358 
359 TRACE_EVENT(802154_rdev_associate,
360 	TP_PROTO(struct wpan_phy *wpan_phy,
361 		 struct wpan_dev *wpan_dev,
362 		 struct ieee802154_addr *coord),
363 	TP_ARGS(wpan_phy, wpan_dev, coord),
364 	TP_STRUCT__entry(
365 		WPAN_PHY_ENTRY
366 		WPAN_DEV_ENTRY
367 		__field(__le64, addr)
368 	),
369 	TP_fast_assign(
370 		WPAN_PHY_ASSIGN;
371 		WPAN_DEV_ASSIGN;
372 		__entry->addr = coord->extended_addr;
373 	),
374 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", associating with: 0x%llx",
375 		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG, __entry->addr)
376 );
377 
378 TRACE_EVENT(802154_rdev_disassociate,
379 	TP_PROTO(struct wpan_phy *wpan_phy,
380 		 struct wpan_dev *wpan_dev,
381 		 struct ieee802154_addr *target),
382 	TP_ARGS(wpan_phy, wpan_dev, target),
383 	TP_STRUCT__entry(
384 		WPAN_PHY_ENTRY
385 		WPAN_DEV_ENTRY
386 		__field(__le64, addr)
387 	),
388 	TP_fast_assign(
389 		WPAN_PHY_ASSIGN;
390 		WPAN_DEV_ASSIGN;
391 		__entry->addr = target->extended_addr;
392 	),
393 	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", disassociating with: 0x%llx",
394 		  WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG, __entry->addr)
395 );
396 
397 TRACE_EVENT(802154_rdev_return_int,
398 	TP_PROTO(struct wpan_phy *wpan_phy, int ret),
399 	TP_ARGS(wpan_phy, ret),
400 	TP_STRUCT__entry(
401 		WPAN_PHY_ENTRY
402 		__field(int, ret)
403 	),
404 	TP_fast_assign(
405 		WPAN_PHY_ASSIGN;
406 		__entry->ret = ret;
407 	),
408 	TP_printk(WPAN_PHY_PR_FMT ", returned: %d", WPAN_PHY_PR_ARG,
409 		  __entry->ret)
410 );
411 
412 #endif /* !__RDEV_CFG802154_OPS_TRACE || TRACE_HEADER_MULTI_READ */
413 
414 #undef TRACE_INCLUDE_PATH
415 #define TRACE_INCLUDE_PATH .
416 #undef TRACE_INCLUDE_FILE
417 #define TRACE_INCLUDE_FILE trace
418 #include <trace/define_trace.h>
419