1 /* SPDX-License-Identifier: GPL-2.0
2 * Copyright 2022-2023 NXP
6 #define TRACE_SYSTEM dsa
8 #if !defined(_NET_DSA_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
9 #define _NET_DSA_TRACE_H
12 #include <net/switchdev.h>
13 #include <linux/etherdevice.h>
14 #include <linux/if_bridge.h>
15 #include <linux/refcount.h>
16 #include <linux/tracepoint.h>
18 /* Enough to fit "bridge %s num %d" where num has 3 digits */
19 #define DSA_DB_BUFSIZ (IFNAMSIZ + 16)
21 void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ]);
22 const char *dsa_port_kind(const struct dsa_port *dp);
24 DECLARE_EVENT_CLASS(dsa_port_addr_op_hw,
26 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid,
27 const struct dsa_db *db, int err),
29 TP_ARGS(dp, addr, vid, db, err),
32 __string(dev, dev_name(dp->ds->dev))
33 __string(kind, dsa_port_kind(dp))
35 __array(unsigned char, addr, ETH_ALEN)
37 __array(char, db_buf, DSA_DB_BUFSIZ)
42 __assign_str(dev, dev_name(dp->ds->dev));
43 __assign_str(kind, dsa_port_kind(dp));
44 __entry->port = dp->index;
45 ether_addr_copy(__entry->addr, addr);
47 dsa_db_print(db, __entry->db_buf);
51 TP_printk("%s %s port %d addr %pM vid %u db \"%s\" err %d",
52 __get_str(dev), __get_str(kind), __entry->port, __entry->addr,
53 __entry->vid, __entry->db_buf, __entry->err)
56 /* Add unicast/multicast address to hardware, either on user ports
57 * (where no refcounting is kept), or on shared ports when the entry
58 * is first seen and its refcount is 1.
60 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_add_hw,
61 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
62 u16 vid, const struct dsa_db *db, int err),
63 TP_ARGS(dp, addr, vid, db, err));
65 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_add_hw,
66 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
67 u16 vid, const struct dsa_db *db, int err),
68 TP_ARGS(dp, addr, vid, db, err));
70 /* Delete unicast/multicast address from hardware, either on user ports or
71 * when the refcount on shared ports reaches 0
73 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_del_hw,
74 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
75 u16 vid, const struct dsa_db *db, int err),
76 TP_ARGS(dp, addr, vid, db, err));
78 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_del_hw,
79 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
80 u16 vid, const struct dsa_db *db, int err),
81 TP_ARGS(dp, addr, vid, db, err));
83 DECLARE_EVENT_CLASS(dsa_port_addr_op_refcount,
85 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid,
86 const struct dsa_db *db, const refcount_t *refcount),
88 TP_ARGS(dp, addr, vid, db, refcount),
91 __string(dev, dev_name(dp->ds->dev))
92 __string(kind, dsa_port_kind(dp))
94 __array(unsigned char, addr, ETH_ALEN)
96 __array(char, db_buf, DSA_DB_BUFSIZ)
97 __field(unsigned int, refcount)
101 __assign_str(dev, dev_name(dp->ds->dev));
102 __assign_str(kind, dsa_port_kind(dp));
103 __entry->port = dp->index;
104 ether_addr_copy(__entry->addr, addr);
106 dsa_db_print(db, __entry->db_buf);
107 __entry->refcount = refcount_read(refcount);
110 TP_printk("%s %s port %d addr %pM vid %u db \"%s\" refcount %u",
111 __get_str(dev), __get_str(kind), __entry->port, __entry->addr,
112 __entry->vid, __entry->db_buf, __entry->refcount)
115 /* Bump the refcount of an existing unicast/multicast address on shared ports */
116 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_add_bump,
117 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
118 u16 vid, const struct dsa_db *db,
119 const refcount_t *refcount),
120 TP_ARGS(dp, addr, vid, db, refcount));
122 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_add_bump,
123 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
124 u16 vid, const struct dsa_db *db,
125 const refcount_t *refcount),
126 TP_ARGS(dp, addr, vid, db, refcount));
128 /* Drop the refcount of a multicast address that we still keep on
131 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_del_drop,
132 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
133 u16 vid, const struct dsa_db *db,
134 const refcount_t *refcount),
135 TP_ARGS(dp, addr, vid, db, refcount));
137 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_del_drop,
138 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
139 u16 vid, const struct dsa_db *db,
140 const refcount_t *refcount),
141 TP_ARGS(dp, addr, vid, db, refcount));
143 DECLARE_EVENT_CLASS(dsa_port_addr_del_not_found,
145 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid,
146 const struct dsa_db *db),
148 TP_ARGS(dp, addr, vid, db),
151 __string(dev, dev_name(dp->ds->dev))
152 __string(kind, dsa_port_kind(dp))
154 __array(unsigned char, addr, ETH_ALEN)
156 __array(char, db_buf, DSA_DB_BUFSIZ)
160 __assign_str(dev, dev_name(dp->ds->dev));
161 __assign_str(kind, dsa_port_kind(dp));
162 __entry->port = dp->index;
163 ether_addr_copy(__entry->addr, addr);
165 dsa_db_print(db, __entry->db_buf);
168 TP_printk("%s %s port %d addr %pM vid %u db \"%s\"",
169 __get_str(dev), __get_str(kind), __entry->port,
170 __entry->addr, __entry->vid, __entry->db_buf)
173 /* Attempt to delete a unicast/multicast address on shared ports for which
174 * the delete operation was called more times than the addition
176 DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_fdb_del_not_found,
177 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
178 u16 vid, const struct dsa_db *db),
179 TP_ARGS(dp, addr, vid, db));
181 DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_mdb_del_not_found,
182 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr,
183 u16 vid, const struct dsa_db *db),
184 TP_ARGS(dp, addr, vid, db));
186 TRACE_EVENT(dsa_lag_fdb_add_hw,
188 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
189 u16 vid, const struct dsa_db *db, int err),
191 TP_ARGS(lag_dev, addr, vid, db, err),
194 __string(dev, lag_dev->name)
195 __array(unsigned char, addr, ETH_ALEN)
197 __array(char, db_buf, DSA_DB_BUFSIZ)
202 __assign_str(dev, lag_dev->name);
203 ether_addr_copy(__entry->addr, addr);
205 dsa_db_print(db, __entry->db_buf);
209 TP_printk("%s addr %pM vid %u db \"%s\" err %d",
210 __get_str(dev), __entry->addr, __entry->vid,
211 __entry->db_buf, __entry->err)
214 TRACE_EVENT(dsa_lag_fdb_add_bump,
216 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
217 u16 vid, const struct dsa_db *db, const refcount_t *refcount),
219 TP_ARGS(lag_dev, addr, vid, db, refcount),
222 __string(dev, lag_dev->name)
223 __array(unsigned char, addr, ETH_ALEN)
225 __array(char, db_buf, DSA_DB_BUFSIZ)
226 __field(unsigned int, refcount)
230 __assign_str(dev, lag_dev->name);
231 ether_addr_copy(__entry->addr, addr);
233 dsa_db_print(db, __entry->db_buf);
234 __entry->refcount = refcount_read(refcount);
237 TP_printk("%s addr %pM vid %u db \"%s\" refcount %u",
238 __get_str(dev), __entry->addr, __entry->vid,
239 __entry->db_buf, __entry->refcount)
242 TRACE_EVENT(dsa_lag_fdb_del_hw,
244 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
245 u16 vid, const struct dsa_db *db, int err),
247 TP_ARGS(lag_dev, addr, vid, db, err),
250 __string(dev, lag_dev->name)
251 __array(unsigned char, addr, ETH_ALEN)
253 __array(char, db_buf, DSA_DB_BUFSIZ)
258 __assign_str(dev, lag_dev->name);
259 ether_addr_copy(__entry->addr, addr);
261 dsa_db_print(db, __entry->db_buf);
265 TP_printk("%s addr %pM vid %u db \"%s\" err %d",
266 __get_str(dev), __entry->addr, __entry->vid,
267 __entry->db_buf, __entry->err)
270 TRACE_EVENT(dsa_lag_fdb_del_drop,
272 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
273 u16 vid, const struct dsa_db *db, const refcount_t *refcount),
275 TP_ARGS(lag_dev, addr, vid, db, refcount),
278 __string(dev, lag_dev->name)
279 __array(unsigned char, addr, ETH_ALEN)
281 __array(char, db_buf, DSA_DB_BUFSIZ)
282 __field(unsigned int, refcount)
286 __assign_str(dev, lag_dev->name);
287 ether_addr_copy(__entry->addr, addr);
289 dsa_db_print(db, __entry->db_buf);
290 __entry->refcount = refcount_read(refcount);
293 TP_printk("%s addr %pM vid %u db \"%s\" refcount %u",
294 __get_str(dev), __entry->addr, __entry->vid,
295 __entry->db_buf, __entry->refcount)
298 TRACE_EVENT(dsa_lag_fdb_del_not_found,
300 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr,
301 u16 vid, const struct dsa_db *db),
303 TP_ARGS(lag_dev, addr, vid, db),
306 __string(dev, lag_dev->name)
307 __array(unsigned char, addr, ETH_ALEN)
309 __array(char, db_buf, DSA_DB_BUFSIZ)
313 __assign_str(dev, lag_dev->name);
314 ether_addr_copy(__entry->addr, addr);
316 dsa_db_print(db, __entry->db_buf);
319 TP_printk("%s addr %pM vid %u db \"%s\"",
320 __get_str(dev), __entry->addr, __entry->vid, __entry->db_buf)
323 DECLARE_EVENT_CLASS(dsa_vlan_op_hw,
325 TP_PROTO(const struct dsa_port *dp,
326 const struct switchdev_obj_port_vlan *vlan, int err),
328 TP_ARGS(dp, vlan, err),
331 __string(dev, dev_name(dp->ds->dev))
332 __string(kind, dsa_port_kind(dp))
336 __field(bool, changed)
341 __assign_str(dev, dev_name(dp->ds->dev));
342 __assign_str(kind, dsa_port_kind(dp));
343 __entry->port = dp->index;
344 __entry->vid = vlan->vid;
345 __entry->flags = vlan->flags;
346 __entry->changed = vlan->changed;
350 TP_printk("%s %s port %d vid %u%s%s%s",
351 __get_str(dev), __get_str(kind), __entry->port, __entry->vid,
352 __entry->flags & BRIDGE_VLAN_INFO_PVID ? " pvid" : "",
353 __entry->flags & BRIDGE_VLAN_INFO_UNTAGGED ? " untagged" : "",
354 __entry->changed ? " (changed)" : "")
357 DEFINE_EVENT(dsa_vlan_op_hw, dsa_vlan_add_hw,
358 TP_PROTO(const struct dsa_port *dp,
359 const struct switchdev_obj_port_vlan *vlan, int err),
360 TP_ARGS(dp, vlan, err));
362 DEFINE_EVENT(dsa_vlan_op_hw, dsa_vlan_del_hw,
363 TP_PROTO(const struct dsa_port *dp,
364 const struct switchdev_obj_port_vlan *vlan, int err),
365 TP_ARGS(dp, vlan, err));
367 DECLARE_EVENT_CLASS(dsa_vlan_op_refcount,
369 TP_PROTO(const struct dsa_port *dp,
370 const struct switchdev_obj_port_vlan *vlan,
371 const refcount_t *refcount),
373 TP_ARGS(dp, vlan, refcount),
376 __string(dev, dev_name(dp->ds->dev))
377 __string(kind, dsa_port_kind(dp))
381 __field(bool, changed)
382 __field(unsigned int, refcount)
386 __assign_str(dev, dev_name(dp->ds->dev));
387 __assign_str(kind, dsa_port_kind(dp));
388 __entry->port = dp->index;
389 __entry->vid = vlan->vid;
390 __entry->flags = vlan->flags;
391 __entry->changed = vlan->changed;
392 __entry->refcount = refcount_read(refcount);
395 TP_printk("%s %s port %d vid %u%s%s%s refcount %u",
396 __get_str(dev), __get_str(kind), __entry->port, __entry->vid,
397 __entry->flags & BRIDGE_VLAN_INFO_PVID ? " pvid" : "",
398 __entry->flags & BRIDGE_VLAN_INFO_UNTAGGED ? " untagged" : "",
399 __entry->changed ? " (changed)" : "", __entry->refcount)
402 DEFINE_EVENT(dsa_vlan_op_refcount, dsa_vlan_add_bump,
403 TP_PROTO(const struct dsa_port *dp,
404 const struct switchdev_obj_port_vlan *vlan,
405 const refcount_t *refcount),
406 TP_ARGS(dp, vlan, refcount));
408 DEFINE_EVENT(dsa_vlan_op_refcount, dsa_vlan_del_drop,
409 TP_PROTO(const struct dsa_port *dp,
410 const struct switchdev_obj_port_vlan *vlan,
411 const refcount_t *refcount),
412 TP_ARGS(dp, vlan, refcount));
414 TRACE_EVENT(dsa_vlan_del_not_found,
416 TP_PROTO(const struct dsa_port *dp,
417 const struct switchdev_obj_port_vlan *vlan),
422 __string(dev, dev_name(dp->ds->dev))
423 __string(kind, dsa_port_kind(dp))
429 __assign_str(dev, dev_name(dp->ds->dev));
430 __assign_str(kind, dsa_port_kind(dp));
431 __entry->port = dp->index;
432 __entry->vid = vlan->vid;
435 TP_printk("%s %s port %d vid %u",
436 __get_str(dev), __get_str(kind), __entry->port, __entry->vid)
439 #endif /* _NET_DSA_TRACE_H */
441 /* We don't want to use include/trace/events */
442 #undef TRACE_INCLUDE_PATH
443 #define TRACE_INCLUDE_PATH .
444 #undef TRACE_INCLUDE_FILE
445 #define TRACE_INCLUDE_FILE trace
446 /* This part must be outside protection */
447 #include <trace/define_trace.h>