trace.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Based on net/wireless/trace.h */
  3. #undef TRACE_SYSTEM
  4. #define TRACE_SYSTEM cfg802154
  5. #if !defined(__RDEV_CFG802154_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ)
  6. #define __RDEV_CFG802154_OPS_TRACE
  7. #include <linux/tracepoint.h>
  8. #include <net/cfg802154.h>
  9. #define MAXNAME 32
  10. #define WPAN_PHY_ENTRY __array(char, wpan_phy_name, MAXNAME)
  11. #define WPAN_PHY_ASSIGN strlcpy(__entry->wpan_phy_name, \
  12. wpan_phy_name(wpan_phy), \
  13. MAXNAME)
  14. #define WPAN_PHY_PR_FMT "%s"
  15. #define WPAN_PHY_PR_ARG __entry->wpan_phy_name
  16. #define WPAN_DEV_ENTRY __field(u32, identifier)
  17. #define WPAN_DEV_ASSIGN (__entry->identifier) = (!IS_ERR_OR_NULL(wpan_dev) \
  18. ? wpan_dev->identifier : 0)
  19. #define WPAN_DEV_PR_FMT "wpan_dev(%u)"
  20. #define WPAN_DEV_PR_ARG (__entry->identifier)
  21. #define WPAN_CCA_ENTRY __field(enum nl802154_cca_modes, cca_mode) \
  22. __field(enum nl802154_cca_opts, cca_opt)
  23. #define WPAN_CCA_ASSIGN \
  24. do { \
  25. (__entry->cca_mode) = cca->mode; \
  26. (__entry->cca_opt) = cca->opt; \
  27. } while (0)
  28. #define WPAN_CCA_PR_FMT "cca_mode: %d, cca_opt: %d"
  29. #define WPAN_CCA_PR_ARG __entry->cca_mode, __entry->cca_opt
  30. #define BOOL_TO_STR(bo) (bo) ? "true" : "false"
  31. /*************************************************************
  32. * rdev->ops traces *
  33. *************************************************************/
  34. DECLARE_EVENT_CLASS(wpan_phy_only_evt,
  35. TP_PROTO(struct wpan_phy *wpan_phy),
  36. TP_ARGS(wpan_phy),
  37. TP_STRUCT__entry(
  38. WPAN_PHY_ENTRY
  39. ),
  40. TP_fast_assign(
  41. WPAN_PHY_ASSIGN;
  42. ),
  43. TP_printk(WPAN_PHY_PR_FMT, WPAN_PHY_PR_ARG)
  44. );
  45. DEFINE_EVENT(wpan_phy_only_evt, 802154_rdev_suspend,
  46. TP_PROTO(struct wpan_phy *wpan_phy),
  47. TP_ARGS(wpan_phy)
  48. );
  49. DEFINE_EVENT(wpan_phy_only_evt, 802154_rdev_resume,
  50. TP_PROTO(struct wpan_phy *wpan_phy),
  51. TP_ARGS(wpan_phy)
  52. );
  53. TRACE_EVENT(802154_rdev_add_virtual_intf,
  54. TP_PROTO(struct wpan_phy *wpan_phy, char *name,
  55. enum nl802154_iftype type, __le64 extended_addr),
  56. TP_ARGS(wpan_phy, name, type, extended_addr),
  57. TP_STRUCT__entry(
  58. WPAN_PHY_ENTRY
  59. __string(vir_intf_name, name ? name : "<noname>")
  60. __field(enum nl802154_iftype, type)
  61. __field(__le64, extended_addr)
  62. ),
  63. TP_fast_assign(
  64. WPAN_PHY_ASSIGN;
  65. __assign_str(vir_intf_name, name ? name : "<noname>");
  66. __entry->type = type;
  67. __entry->extended_addr = extended_addr;
  68. ),
  69. TP_printk(WPAN_PHY_PR_FMT ", virtual intf name: %s, type: %d, extended addr: 0x%llx",
  70. WPAN_PHY_PR_ARG, __get_str(vir_intf_name), __entry->type,
  71. __le64_to_cpu(__entry->extended_addr))
  72. );
  73. TRACE_EVENT(802154_rdev_del_virtual_intf,
  74. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev),
  75. TP_ARGS(wpan_phy, wpan_dev),
  76. TP_STRUCT__entry(
  77. WPAN_PHY_ENTRY
  78. WPAN_DEV_ENTRY
  79. ),
  80. TP_fast_assign(
  81. WPAN_PHY_ASSIGN;
  82. WPAN_DEV_ASSIGN;
  83. ),
  84. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT, WPAN_PHY_PR_ARG,
  85. WPAN_DEV_PR_ARG)
  86. );
  87. TRACE_EVENT(802154_rdev_set_channel,
  88. TP_PROTO(struct wpan_phy *wpan_phy, u8 page, u8 channel),
  89. TP_ARGS(wpan_phy, page, channel),
  90. TP_STRUCT__entry(
  91. WPAN_PHY_ENTRY
  92. __field(u8, page)
  93. __field(u8, channel)
  94. ),
  95. TP_fast_assign(
  96. WPAN_PHY_ASSIGN;
  97. __entry->page = page;
  98. __entry->channel = channel;
  99. ),
  100. TP_printk(WPAN_PHY_PR_FMT ", page: %d, channel: %d", WPAN_PHY_PR_ARG,
  101. __entry->page, __entry->channel)
  102. );
  103. TRACE_EVENT(802154_rdev_set_tx_power,
  104. TP_PROTO(struct wpan_phy *wpan_phy, s32 power),
  105. TP_ARGS(wpan_phy, power),
  106. TP_STRUCT__entry(
  107. WPAN_PHY_ENTRY
  108. __field(s32, power)
  109. ),
  110. TP_fast_assign(
  111. WPAN_PHY_ASSIGN;
  112. __entry->power = power;
  113. ),
  114. TP_printk(WPAN_PHY_PR_FMT ", mbm: %d", WPAN_PHY_PR_ARG,
  115. __entry->power)
  116. );
  117. TRACE_EVENT(802154_rdev_set_cca_mode,
  118. TP_PROTO(struct wpan_phy *wpan_phy, const struct wpan_phy_cca *cca),
  119. TP_ARGS(wpan_phy, cca),
  120. TP_STRUCT__entry(
  121. WPAN_PHY_ENTRY
  122. WPAN_CCA_ENTRY
  123. ),
  124. TP_fast_assign(
  125. WPAN_PHY_ASSIGN;
  126. WPAN_CCA_ASSIGN;
  127. ),
  128. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_CCA_PR_FMT, WPAN_PHY_PR_ARG,
  129. WPAN_CCA_PR_ARG)
  130. );
  131. TRACE_EVENT(802154_rdev_set_cca_ed_level,
  132. TP_PROTO(struct wpan_phy *wpan_phy, s32 ed_level),
  133. TP_ARGS(wpan_phy, ed_level),
  134. TP_STRUCT__entry(
  135. WPAN_PHY_ENTRY
  136. __field(s32, ed_level)
  137. ),
  138. TP_fast_assign(
  139. WPAN_PHY_ASSIGN;
  140. __entry->ed_level = ed_level;
  141. ),
  142. TP_printk(WPAN_PHY_PR_FMT ", ed level: %d", WPAN_PHY_PR_ARG,
  143. __entry->ed_level)
  144. );
  145. DECLARE_EVENT_CLASS(802154_le16_template,
  146. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  147. __le16 le16arg),
  148. TP_ARGS(wpan_phy, wpan_dev, le16arg),
  149. TP_STRUCT__entry(
  150. WPAN_PHY_ENTRY
  151. WPAN_DEV_ENTRY
  152. __field(__le16, le16arg)
  153. ),
  154. TP_fast_assign(
  155. WPAN_PHY_ASSIGN;
  156. WPAN_DEV_ASSIGN;
  157. __entry->le16arg = le16arg;
  158. ),
  159. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", pan id: 0x%04x",
  160. WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
  161. __le16_to_cpu(__entry->le16arg))
  162. );
  163. DEFINE_EVENT(802154_le16_template, 802154_rdev_set_pan_id,
  164. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  165. __le16 le16arg),
  166. TP_ARGS(wpan_phy, wpan_dev, le16arg)
  167. );
  168. DEFINE_EVENT_PRINT(802154_le16_template, 802154_rdev_set_short_addr,
  169. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  170. __le16 le16arg),
  171. TP_ARGS(wpan_phy, wpan_dev, le16arg),
  172. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT ", short addr: 0x%04x",
  173. WPAN_PHY_PR_ARG, WPAN_DEV_PR_ARG,
  174. __le16_to_cpu(__entry->le16arg))
  175. );
  176. TRACE_EVENT(802154_rdev_set_backoff_exponent,
  177. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  178. u8 min_be, u8 max_be),
  179. TP_ARGS(wpan_phy, wpan_dev, min_be, max_be),
  180. TP_STRUCT__entry(
  181. WPAN_PHY_ENTRY
  182. WPAN_DEV_ENTRY
  183. __field(u8, min_be)
  184. __field(u8, max_be)
  185. ),
  186. TP_fast_assign(
  187. WPAN_PHY_ASSIGN;
  188. WPAN_DEV_ASSIGN;
  189. __entry->min_be = min_be;
  190. __entry->max_be = max_be;
  191. ),
  192. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
  193. ", min be: %d, max be: %d", WPAN_PHY_PR_ARG,
  194. WPAN_DEV_PR_ARG, __entry->min_be, __entry->max_be)
  195. );
  196. TRACE_EVENT(802154_rdev_set_csma_backoffs,
  197. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  198. u8 max_csma_backoffs),
  199. TP_ARGS(wpan_phy, wpan_dev, max_csma_backoffs),
  200. TP_STRUCT__entry(
  201. WPAN_PHY_ENTRY
  202. WPAN_DEV_ENTRY
  203. __field(u8, max_csma_backoffs)
  204. ),
  205. TP_fast_assign(
  206. WPAN_PHY_ASSIGN;
  207. WPAN_DEV_ASSIGN;
  208. __entry->max_csma_backoffs = max_csma_backoffs;
  209. ),
  210. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
  211. ", max csma backoffs: %d", WPAN_PHY_PR_ARG,
  212. WPAN_DEV_PR_ARG, __entry->max_csma_backoffs)
  213. );
  214. TRACE_EVENT(802154_rdev_set_max_frame_retries,
  215. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  216. s8 max_frame_retries),
  217. TP_ARGS(wpan_phy, wpan_dev, max_frame_retries),
  218. TP_STRUCT__entry(
  219. WPAN_PHY_ENTRY
  220. WPAN_DEV_ENTRY
  221. __field(s8, max_frame_retries)
  222. ),
  223. TP_fast_assign(
  224. WPAN_PHY_ASSIGN;
  225. WPAN_DEV_ASSIGN;
  226. __entry->max_frame_retries = max_frame_retries;
  227. ),
  228. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
  229. ", max frame retries: %d", WPAN_PHY_PR_ARG,
  230. WPAN_DEV_PR_ARG, __entry->max_frame_retries)
  231. );
  232. TRACE_EVENT(802154_rdev_set_lbt_mode,
  233. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  234. bool mode),
  235. TP_ARGS(wpan_phy, wpan_dev, mode),
  236. TP_STRUCT__entry(
  237. WPAN_PHY_ENTRY
  238. WPAN_DEV_ENTRY
  239. __field(bool, mode)
  240. ),
  241. TP_fast_assign(
  242. WPAN_PHY_ASSIGN;
  243. WPAN_DEV_ASSIGN;
  244. __entry->mode = mode;
  245. ),
  246. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
  247. ", lbt mode: %s", WPAN_PHY_PR_ARG,
  248. WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode))
  249. );
  250. TRACE_EVENT(802154_rdev_set_ackreq_default,
  251. TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  252. bool ackreq),
  253. TP_ARGS(wpan_phy, wpan_dev, ackreq),
  254. TP_STRUCT__entry(
  255. WPAN_PHY_ENTRY
  256. WPAN_DEV_ENTRY
  257. __field(bool, ackreq)
  258. ),
  259. TP_fast_assign(
  260. WPAN_PHY_ASSIGN;
  261. WPAN_DEV_ASSIGN;
  262. __entry->ackreq = ackreq;
  263. ),
  264. TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
  265. ", ackreq default: %s", WPAN_PHY_PR_ARG,
  266. WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->ackreq))
  267. );
  268. TRACE_EVENT(802154_rdev_return_int,
  269. TP_PROTO(struct wpan_phy *wpan_phy, int ret),
  270. TP_ARGS(wpan_phy, ret),
  271. TP_STRUCT__entry(
  272. WPAN_PHY_ENTRY
  273. __field(int, ret)
  274. ),
  275. TP_fast_assign(
  276. WPAN_PHY_ASSIGN;
  277. __entry->ret = ret;
  278. ),
  279. TP_printk(WPAN_PHY_PR_FMT ", returned: %d", WPAN_PHY_PR_ARG,
  280. __entry->ret)
  281. );
  282. #endif /* !__RDEV_CFG802154_OPS_TRACE || TRACE_HEADER_MULTI_READ */
  283. #undef TRACE_INCLUDE_PATH
  284. #define TRACE_INCLUDE_PATH .
  285. #undef TRACE_INCLUDE_FILE
  286. #define TRACE_INCLUDE_FILE trace
  287. #include <trace/define_trace.h>