trace.h 13 KB

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