summaryrefslogtreecommitdiff
path: root/net/dsa/trace.h
blob: 567f29a397072af917ab3940e764eefc0f516764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
/* SPDX-License-Identifier: GPL-2.0
 * Copyright 2022-2023 NXP
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM	dsa

#if !defined(_NET_DSA_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define _NET_DSA_TRACE_H

#include <net/dsa.h>
#include <net/switchdev.h>
#include <linux/etherdevice.h>
#include <linux/if_bridge.h>
#include <linux/refcount.h>
#include <linux/tracepoint.h>

/* Enough to fit "bridge %s num %d" where num has 3 digits */
#define DSA_DB_BUFSIZ	(IFNAMSIZ + 16)

void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ]);
const char *dsa_port_kind(const struct dsa_port *dp);

DECLARE_EVENT_CLASS(dsa_port_addr_op_hw,

	TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid,
		 const struct dsa_db *db, int err),

	TP_ARGS(dp, addr, vid, db, err),

	TP_STRUCT__entry(
		__string(dev, dev_name(dp->ds->dev))
		__string(kind, dsa_port_kind(dp))
		__field(int, port)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
		__field(int, err)
	),

	TP_fast_assign(
		__assign_str(dev, dev_name(dp->ds->dev));
		__assign_str(kind, dsa_port_kind(dp));
		__entry->port = dp->index;
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
		__entry->err = err;
	),

	TP_printk("%s %s port %d addr %pM vid %u db \"%s\" err %d",
		  __get_str(dev), __get_str(kind), __entry->port, __entry->addr,
		  __entry->vid, __entry->db_buf, __entry->err)
);

/* Add unicast/multicast address to hardware, either on user ports
 * (where no refcounting is kept), or on shared ports when the entry
 * is first seen and its refcount is 1.
 */
DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_add_hw,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db, int err),
	     TP_ARGS(dp, addr, vid, db, err));

DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_add_hw,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db, int err),
	     TP_ARGS(dp, addr, vid, db, err));

/* Delete unicast/multicast address from hardware, either on user ports or
 * when the refcount on shared ports reaches 0
 */
DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_del_hw,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db, int err),
	     TP_ARGS(dp, addr, vid, db, err));

DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_del_hw,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db, int err),
	     TP_ARGS(dp, addr, vid, db, err));

DECLARE_EVENT_CLASS(dsa_port_addr_op_refcount,

	TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid,
		 const struct dsa_db *db, const refcount_t *refcount),

	TP_ARGS(dp, addr, vid, db, refcount),

	TP_STRUCT__entry(
		__string(dev, dev_name(dp->ds->dev))
		__string(kind, dsa_port_kind(dp))
		__field(int, port)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
		__field(unsigned int, refcount)
	),

	TP_fast_assign(
		__assign_str(dev, dev_name(dp->ds->dev));
		__assign_str(kind, dsa_port_kind(dp));
		__entry->port = dp->index;
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
		__entry->refcount = refcount_read(refcount);
	),

	TP_printk("%s %s port %d addr %pM vid %u db \"%s\" refcount %u",
		  __get_str(dev), __get_str(kind), __entry->port, __entry->addr,
		  __entry->vid, __entry->db_buf, __entry->refcount)
);

/* Bump the refcount of an existing unicast/multicast address on shared ports */
DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_add_bump,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db,
		      const refcount_t *refcount),
	     TP_ARGS(dp, addr, vid, db, refcount));

DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_add_bump,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db,
		      const refcount_t *refcount),
	     TP_ARGS(dp, addr, vid, db, refcount));

/* Drop the refcount of a multicast address that we still keep on
 * shared ports
 */
DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_del_drop,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db,
		      const refcount_t *refcount),
	     TP_ARGS(dp, addr, vid, db, refcount));

DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_del_drop,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db,
		      const refcount_t *refcount),
	     TP_ARGS(dp, addr, vid, db, refcount));

DECLARE_EVENT_CLASS(dsa_port_addr_del_not_found,

	TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid,
		 const struct dsa_db *db),

	TP_ARGS(dp, addr, vid, db),

	TP_STRUCT__entry(
		__string(dev, dev_name(dp->ds->dev))
		__string(kind, dsa_port_kind(dp))
		__field(int, port)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
	),

	TP_fast_assign(
		__assign_str(dev, dev_name(dp->ds->dev));
		__assign_str(kind, dsa_port_kind(dp));
		__entry->port = dp->index;
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
	),

	TP_printk("%s %s port %d addr %pM vid %u db \"%s\"",
		  __get_str(dev), __get_str(kind), __entry->port,
		  __entry->addr, __entry->vid, __entry->db_buf)
);

/* Attempt to delete a unicast/multicast address on shared ports for which
 * the delete operation was called more times than the addition
 */
DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_fdb_del_not_found,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db),
	     TP_ARGS(dp, addr, vid, db));

DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_mdb_del_not_found,
	     TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
		      u16 vid, const struct dsa_db *db),
	     TP_ARGS(dp, addr, vid, db));

TRACE_EVENT(dsa_lag_fdb_add_hw,

	TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
		 u16 vid, const struct dsa_db *db, int err),

	TP_ARGS(lag_dev, addr, vid, db, err),

	TP_STRUCT__entry(
		__string(dev, lag_dev->name)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
		__field(int, err)
	),

	TP_fast_assign(
		__assign_str(dev, lag_dev->name);
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
		__entry->err = err;
	),

	TP_printk("%s addr %pM vid %u db \"%s\" err %d",
		  __get_str(dev), __entry->addr, __entry->vid,
		  __entry->db_buf, __entry->err)
);

TRACE_EVENT(dsa_lag_fdb_add_bump,

	TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
		 u16 vid, const struct dsa_db *db, const refcount_t *refcount),

	TP_ARGS(lag_dev, addr, vid, db, refcount),

	TP_STRUCT__entry(
		__string(dev, lag_dev->name)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
		__field(unsigned int, refcount)
	),

	TP_fast_assign(
		__assign_str(dev, lag_dev->name);
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
		__entry->refcount = refcount_read(refcount);
	),

	TP_printk("%s addr %pM vid %u db \"%s\" refcount %u",
		  __get_str(dev), __entry->addr, __entry->vid,
		  __entry->db_buf, __entry->refcount)
);

TRACE_EVENT(dsa_lag_fdb_del_hw,

	TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
		 u16 vid, const struct dsa_db *db, int err),

	TP_ARGS(lag_dev, addr, vid, db, err),

	TP_STRUCT__entry(
		__string(dev, lag_dev->name)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
		__field(int, err)
	),

	TP_fast_assign(
		__assign_str(dev, lag_dev->name);
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
		__entry->err = err;
	),

	TP_printk("%s addr %pM vid %u db \"%s\" err %d",
		  __get_str(dev), __entry->addr, __entry->vid,
		  __entry->db_buf, __entry->err)
);

TRACE_EVENT(dsa_lag_fdb_del_drop,

	TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
		 u16 vid, const struct dsa_db *db, const refcount_t *refcount),

	TP_ARGS(lag_dev, addr, vid, db, refcount),

	TP_STRUCT__entry(
		__string(dev, lag_dev->name)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
		__field(unsigned int, refcount)
	),

	TP_fast_assign(
		__assign_str(dev, lag_dev->name);
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
		__entry->refcount = refcount_read(refcount);
	),

	TP_printk("%s addr %pM vid %u db \"%s\" refcount %u",
		  __get_str(dev), __entry->addr, __entry->vid,
		  __entry->db_buf, __entry->refcount)
);

TRACE_EVENT(dsa_lag_fdb_del_not_found,

	TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
		 u16 vid, const struct dsa_db *db),

	TP_ARGS(lag_dev, addr, vid, db),

	TP_STRUCT__entry(
		__string(dev, lag_dev->name)
		__array(unsigned char, addr, ETH_ALEN)
		__field(u16, vid)
		__array(char, db_buf, DSA_DB_BUFSIZ)
	),

	TP_fast_assign(
		__assign_str(dev, lag_dev->name);
		ether_addr_copy(__entry->addr, addr);
		__entry->vid = vid;
		dsa_db_print(db, __entry->db_buf);
	),

	TP_printk("%s addr %pM vid %u db \"%s\"",
		  __get_str(dev), __entry->addr, __entry->vid, __entry->db_buf)
);

DECLARE_EVENT_CLASS(dsa_vlan_op_hw,

	TP_PROTO(const struct dsa_port *dp,
		 const struct switchdev_obj_port_vlan *vlan, int err),

	TP_ARGS(dp, vlan, err),

	TP_STRUCT__entry(
		__string(dev, dev_name(dp->ds->dev))
		__string(kind, dsa_port_kind(dp))
		__field(int, port)
		__field(u16, vid)
		__field(u16, flags)
		__field(bool, changed)
		__field(int, err)
	),

	TP_fast_assign(
		__assign_str(dev, dev_name(dp->ds->dev));
		__assign_str(kind, dsa_port_kind(dp));
		__entry->port = dp->index;
		__entry->vid = vlan->vid;
		__entry->flags = vlan->flags;
		__entry->changed = vlan->changed;
		__entry->err = err;
	),

	TP_printk("%s %s port %d vid %u%s%s%s",
		  __get_str(dev), __get_str(kind), __entry->port, __entry->vid,
		  __entry->flags & BRIDGE_VLAN_INFO_PVID ? " pvid" : "",
		  __entry->flags & BRIDGE_VLAN_INFO_UNTAGGED ? " untagged" : "",
		  __entry->changed ? " (changed)" : "")
);

DEFINE_EVENT(dsa_vlan_op_hw, dsa_vlan_add_hw,
	     TP_PROTO(const struct dsa_port *dp,
		      const struct switchdev_obj_port_vlan *vlan, int err),
	     TP_ARGS(dp, vlan, err));

DEFINE_EVENT(dsa_vlan_op_hw, dsa_vlan_del_hw,
	     TP_PROTO(const struct dsa_port *dp,
		      const struct switchdev_obj_port_vlan *vlan, int err),
	     TP_ARGS(dp, vlan, err));

DECLARE_EVENT_CLASS(dsa_vlan_op_refcount,

	TP_PROTO(const struct dsa_port *dp,
		 const struct switchdev_obj_port_vlan *vlan,
		 const refcount_t *refcount),

	TP_ARGS(dp, vlan, refcount),

	TP_STRUCT__entry(
		__string(dev, dev_name(dp->ds->dev))
		__string(kind, dsa_port_kind(dp))
		__field(int, port)
		__field(u16, vid)
		__field(u16, flags)
		__field(bool, changed)
		__field(unsigned int, refcount)
	),

	TP_fast_assign(
		__assign_str(dev, dev_name(dp->ds->dev));
		__assign_str(kind, dsa_port_kind(dp));
		__entry->port = dp->index;
		__entry->vid = vlan->vid;
		__entry->flags = vlan->flags;
		__entry->changed = vlan->changed;
		__entry->refcount = refcount_read(refcount);
	),

	TP_printk("%s %s port %d vid %u%s%s%s refcount %u",
		  __get_str(dev), __get_str(kind), __entry->port, __entry->vid,
		  __entry->flags & BRIDGE_VLAN_INFO_PVID ? " pvid" : "",
		  __entry->flags & BRIDGE_VLAN_INFO_UNTAGGED ? " untagged" : "",
		  __entry->changed ? " (changed)" : "", __entry->refcount)
);

DEFINE_EVENT(dsa_vlan_op_refcount, dsa_vlan_add_bump,
	     TP_PROTO(const struct dsa_port *dp,
		      const struct switchdev_obj_port_vlan *vlan,
		      const refcount_t *refcount),
	     TP_ARGS(dp, vlan, refcount));

DEFINE_EVENT(dsa_vlan_op_refcount, dsa_vlan_del_drop,
	     TP_PROTO(const struct dsa_port *dp,
		      const struct switchdev_obj_port_vlan *vlan,
		      const refcount_t *refcount),
	     TP_ARGS(dp, vlan, refcount));

TRACE_EVENT(dsa_vlan_del_not_found,

	TP_PROTO(const struct dsa_port *dp,
		 const struct switchdev_obj_port_vlan *vlan),

	TP_ARGS(dp, vlan),

	TP_STRUCT__entry(
		__string(dev, dev_name(dp->ds->dev))
		__string(kind, dsa_port_kind(dp))
		__field(int, port)
		__field(u16, vid)
	),

	TP_fast_assign(
		__assign_str(dev, dev_name(dp->ds->dev));
		__assign_str(kind, dsa_port_kind(dp));
		__entry->port = dp->index;
		__entry->vid = vlan->vid;
	),

	TP_printk("%s %s port %d vid %u",
		  __get_str(dev), __get_str(kind), __entry->port, __entry->vid)
);

#endif /* _NET_DSA_TRACE_H */

/* We don't want to use include/trace/events */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE	trace
/* This part must be outside protection */
#include <trace/define_trace.h>