1 /* SPDX-License-Identifier: GPL-2.0 2 * Copyright 2022-2023 NXP 3 */ 4 5 #undef TRACE_SYSTEM 6 #define TRACE_SYSTEM dsa 7 8 #if !defined(_NET_DSA_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 9 #define _NET_DSA_TRACE_H 10 11 #include <net/dsa.h> 12 #include <linux/etherdevice.h> 13 #include <linux/refcount.h> 14 #include <linux/tracepoint.h> 15 16 /* Enough to fit "bridge %s num %d" where num has 3 digits */ 17 #define DSA_DB_BUFSIZ (IFNAMSIZ + 16) 18 19 void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ]); 20 const char *dsa_port_kind(const struct dsa_port *dp); 21 22 DECLARE_EVENT_CLASS(dsa_port_addr_op_hw, 23 24 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid, 25 const struct dsa_db *db, int err), 26 27 TP_ARGS(dp, addr, vid, db, err), 28 29 TP_STRUCT__entry( 30 __string(dev, dev_name(dp->ds->dev)) 31 __string(kind, dsa_port_kind(dp)) 32 __field(int, port) 33 __array(unsigned char, addr, ETH_ALEN) 34 __field(u16, vid) 35 __array(char, db_buf, DSA_DB_BUFSIZ) 36 __field(int, err) 37 ), 38 39 TP_fast_assign( 40 __assign_str(dev, dev_name(dp->ds->dev)); 41 __assign_str(kind, dsa_port_kind(dp)); 42 __entry->port = dp->index; 43 ether_addr_copy(__entry->addr, addr); 44 __entry->vid = vid; 45 dsa_db_print(db, __entry->db_buf); 46 __entry->err = err; 47 ), 48 49 TP_printk("%s %s port %d addr %pM vid %u db \"%s\" err %d", 50 __get_str(dev), __get_str(kind), __entry->port, __entry->addr, 51 __entry->vid, __entry->db_buf, __entry->err) 52 ); 53 54 /* Add unicast/multicast address to hardware, either on user ports 55 * (where no refcounting is kept), or on shared ports when the entry 56 * is first seen and its refcount is 1. 57 */ 58 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_add_hw, 59 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 60 u16 vid, const struct dsa_db *db, int err), 61 TP_ARGS(dp, addr, vid, db, err)); 62 63 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_add_hw, 64 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 65 u16 vid, const struct dsa_db *db, int err), 66 TP_ARGS(dp, addr, vid, db, err)); 67 68 /* Delete unicast/multicast address from hardware, either on user ports or 69 * when the refcount on shared ports reaches 0 70 */ 71 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_del_hw, 72 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 73 u16 vid, const struct dsa_db *db, int err), 74 TP_ARGS(dp, addr, vid, db, err)); 75 76 DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_del_hw, 77 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 78 u16 vid, const struct dsa_db *db, int err), 79 TP_ARGS(dp, addr, vid, db, err)); 80 81 DECLARE_EVENT_CLASS(dsa_port_addr_op_refcount, 82 83 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid, 84 const struct dsa_db *db, const refcount_t *refcount), 85 86 TP_ARGS(dp, addr, vid, db, refcount), 87 88 TP_STRUCT__entry( 89 __string(dev, dev_name(dp->ds->dev)) 90 __string(kind, dsa_port_kind(dp)) 91 __field(int, port) 92 __array(unsigned char, addr, ETH_ALEN) 93 __field(u16, vid) 94 __array(char, db_buf, DSA_DB_BUFSIZ) 95 __field(unsigned int, refcount) 96 ), 97 98 TP_fast_assign( 99 __assign_str(dev, dev_name(dp->ds->dev)); 100 __assign_str(kind, dsa_port_kind(dp)); 101 __entry->port = dp->index; 102 ether_addr_copy(__entry->addr, addr); 103 __entry->vid = vid; 104 dsa_db_print(db, __entry->db_buf); 105 __entry->refcount = refcount_read(refcount); 106 ), 107 108 TP_printk("%s %s port %d addr %pM vid %u db \"%s\" refcount %u", 109 __get_str(dev), __get_str(kind), __entry->port, __entry->addr, 110 __entry->vid, __entry->db_buf, __entry->refcount) 111 ); 112 113 /* Bump the refcount of an existing unicast/multicast address on shared ports */ 114 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_add_bump, 115 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 116 u16 vid, const struct dsa_db *db, 117 const refcount_t *refcount), 118 TP_ARGS(dp, addr, vid, db, refcount)); 119 120 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_add_bump, 121 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 122 u16 vid, const struct dsa_db *db, 123 const refcount_t *refcount), 124 TP_ARGS(dp, addr, vid, db, refcount)); 125 126 /* Drop the refcount of a multicast address that we still keep on 127 * shared ports 128 */ 129 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_del_drop, 130 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 131 u16 vid, const struct dsa_db *db, 132 const refcount_t *refcount), 133 TP_ARGS(dp, addr, vid, db, refcount)); 134 135 DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_del_drop, 136 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 137 u16 vid, const struct dsa_db *db, 138 const refcount_t *refcount), 139 TP_ARGS(dp, addr, vid, db, refcount)); 140 141 DECLARE_EVENT_CLASS(dsa_port_addr_del_not_found, 142 143 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid, 144 const struct dsa_db *db), 145 146 TP_ARGS(dp, addr, vid, db), 147 148 TP_STRUCT__entry( 149 __string(dev, dev_name(dp->ds->dev)) 150 __string(kind, dsa_port_kind(dp)) 151 __field(int, port) 152 __array(unsigned char, addr, ETH_ALEN) 153 __field(u16, vid) 154 __array(char, db_buf, DSA_DB_BUFSIZ) 155 ), 156 157 TP_fast_assign( 158 __assign_str(dev, dev_name(dp->ds->dev)); 159 __assign_str(kind, dsa_port_kind(dp)); 160 __entry->port = dp->index; 161 ether_addr_copy(__entry->addr, addr); 162 __entry->vid = vid; 163 dsa_db_print(db, __entry->db_buf); 164 ), 165 166 TP_printk("%s %s port %d addr %pM vid %u db \"%s\"", 167 __get_str(dev), __get_str(kind), __entry->port, 168 __entry->addr, __entry->vid, __entry->db_buf) 169 ); 170 171 /* Attempt to delete a unicast/multicast address on shared ports for which 172 * the delete operation was called more times than the addition 173 */ 174 DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_fdb_del_not_found, 175 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 176 u16 vid, const struct dsa_db *db), 177 TP_ARGS(dp, addr, vid, db)); 178 179 DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_mdb_del_not_found, 180 TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, 181 u16 vid, const struct dsa_db *db), 182 TP_ARGS(dp, addr, vid, db)); 183 184 TRACE_EVENT(dsa_lag_fdb_add_hw, 185 186 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, 187 u16 vid, const struct dsa_db *db, int err), 188 189 TP_ARGS(lag_dev, addr, vid, db, err), 190 191 TP_STRUCT__entry( 192 __string(dev, lag_dev->name) 193 __array(unsigned char, addr, ETH_ALEN) 194 __field(u16, vid) 195 __array(char, db_buf, DSA_DB_BUFSIZ) 196 __field(int, err) 197 ), 198 199 TP_fast_assign( 200 __assign_str(dev, lag_dev->name); 201 ether_addr_copy(__entry->addr, addr); 202 __entry->vid = vid; 203 dsa_db_print(db, __entry->db_buf); 204 __entry->err = err; 205 ), 206 207 TP_printk("%s addr %pM vid %u db \"%s\" err %d", 208 __get_str(dev), __entry->addr, __entry->vid, 209 __entry->db_buf, __entry->err) 210 ); 211 212 TRACE_EVENT(dsa_lag_fdb_add_bump, 213 214 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, 215 u16 vid, const struct dsa_db *db, const refcount_t *refcount), 216 217 TP_ARGS(lag_dev, addr, vid, db, refcount), 218 219 TP_STRUCT__entry( 220 __string(dev, lag_dev->name) 221 __array(unsigned char, addr, ETH_ALEN) 222 __field(u16, vid) 223 __array(char, db_buf, DSA_DB_BUFSIZ) 224 __field(unsigned int, refcount) 225 ), 226 227 TP_fast_assign( 228 __assign_str(dev, lag_dev->name); 229 ether_addr_copy(__entry->addr, addr); 230 __entry->vid = vid; 231 dsa_db_print(db, __entry->db_buf); 232 __entry->refcount = refcount_read(refcount); 233 ), 234 235 TP_printk("%s addr %pM vid %u db \"%s\" refcount %u", 236 __get_str(dev), __entry->addr, __entry->vid, 237 __entry->db_buf, __entry->refcount) 238 ); 239 240 TRACE_EVENT(dsa_lag_fdb_del_hw, 241 242 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, 243 u16 vid, const struct dsa_db *db, int err), 244 245 TP_ARGS(lag_dev, addr, vid, db, err), 246 247 TP_STRUCT__entry( 248 __string(dev, lag_dev->name) 249 __array(unsigned char, addr, ETH_ALEN) 250 __field(u16, vid) 251 __array(char, db_buf, DSA_DB_BUFSIZ) 252 __field(int, err) 253 ), 254 255 TP_fast_assign( 256 __assign_str(dev, lag_dev->name); 257 ether_addr_copy(__entry->addr, addr); 258 __entry->vid = vid; 259 dsa_db_print(db, __entry->db_buf); 260 __entry->err = err; 261 ), 262 263 TP_printk("%s addr %pM vid %u db \"%s\" err %d", 264 __get_str(dev), __entry->addr, __entry->vid, 265 __entry->db_buf, __entry->err) 266 ); 267 268 TRACE_EVENT(dsa_lag_fdb_del_drop, 269 270 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, 271 u16 vid, const struct dsa_db *db, const refcount_t *refcount), 272 273 TP_ARGS(lag_dev, addr, vid, db, refcount), 274 275 TP_STRUCT__entry( 276 __string(dev, lag_dev->name) 277 __array(unsigned char, addr, ETH_ALEN) 278 __field(u16, vid) 279 __array(char, db_buf, DSA_DB_BUFSIZ) 280 __field(unsigned int, refcount) 281 ), 282 283 TP_fast_assign( 284 __assign_str(dev, lag_dev->name); 285 ether_addr_copy(__entry->addr, addr); 286 __entry->vid = vid; 287 dsa_db_print(db, __entry->db_buf); 288 __entry->refcount = refcount_read(refcount); 289 ), 290 291 TP_printk("%s addr %pM vid %u db \"%s\" refcount %u", 292 __get_str(dev), __entry->addr, __entry->vid, 293 __entry->db_buf, __entry->refcount) 294 ); 295 296 TRACE_EVENT(dsa_lag_fdb_del_not_found, 297 298 TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, 299 u16 vid, const struct dsa_db *db), 300 301 TP_ARGS(lag_dev, addr, vid, db), 302 303 TP_STRUCT__entry( 304 __string(dev, lag_dev->name) 305 __array(unsigned char, addr, ETH_ALEN) 306 __field(u16, vid) 307 __array(char, db_buf, DSA_DB_BUFSIZ) 308 ), 309 310 TP_fast_assign( 311 __assign_str(dev, lag_dev->name); 312 ether_addr_copy(__entry->addr, addr); 313 __entry->vid = vid; 314 dsa_db_print(db, __entry->db_buf); 315 ), 316 317 TP_printk("%s addr %pM vid %u db \"%s\"", 318 __get_str(dev), __entry->addr, __entry->vid, __entry->db_buf) 319 ); 320 321 #endif /* _NET_DSA_TRACE_H */ 322 323 /* We don't want to use include/trace/events */ 324 #undef TRACE_INCLUDE_PATH 325 #define TRACE_INCLUDE_PATH . 326 #undef TRACE_INCLUDE_FILE 327 #define TRACE_INCLUDE_FILE trace 328 /* This part must be outside protection */ 329 #include <trace/define_trace.h> 330