trace.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Based on net/mac80211/trace.h */
  3. #undef TRACE_SYSTEM
  4. #define TRACE_SYSTEM mac802154
  5. #if !defined(__MAC802154_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ)
  6. #define __MAC802154_DRIVER_TRACE
  7. #include <linux/tracepoint.h>
  8. #include <net/mac802154.h>
  9. #include "ieee802154_i.h"
  10. #define MAXNAME 32
  11. #define LOCAL_ENTRY __array(char, wpan_phy_name, MAXNAME)
  12. #define LOCAL_ASSIGN strlcpy(__entry->wpan_phy_name, \
  13. wpan_phy_name(local->hw.phy), MAXNAME)
  14. #define LOCAL_PR_FMT "%s"
  15. #define LOCAL_PR_ARG __entry->wpan_phy_name
  16. #define CCA_ENTRY __field(enum nl802154_cca_modes, cca_mode) \
  17. __field(enum nl802154_cca_opts, cca_opt)
  18. #define CCA_ASSIGN \
  19. do { \
  20. (__entry->cca_mode) = cca->mode; \
  21. (__entry->cca_opt) = cca->opt; \
  22. } while (0)
  23. #define CCA_PR_FMT "cca_mode: %d, cca_opt: %d"
  24. #define CCA_PR_ARG __entry->cca_mode, __entry->cca_opt
  25. #define BOOL_TO_STR(bo) (bo) ? "true" : "false"
  26. /* Tracing for driver callbacks */
  27. DECLARE_EVENT_CLASS(local_only_evt4,
  28. TP_PROTO(struct ieee802154_local *local),
  29. TP_ARGS(local),
  30. TP_STRUCT__entry(
  31. LOCAL_ENTRY
  32. ),
  33. TP_fast_assign(
  34. LOCAL_ASSIGN;
  35. ),
  36. TP_printk(LOCAL_PR_FMT, LOCAL_PR_ARG)
  37. );
  38. DEFINE_EVENT(local_only_evt4, 802154_drv_return_void,
  39. TP_PROTO(struct ieee802154_local *local),
  40. TP_ARGS(local)
  41. );
  42. TRACE_EVENT(802154_drv_return_int,
  43. TP_PROTO(struct ieee802154_local *local, int ret),
  44. TP_ARGS(local, ret),
  45. TP_STRUCT__entry(
  46. LOCAL_ENTRY
  47. __field(int, ret)
  48. ),
  49. TP_fast_assign(
  50. LOCAL_ASSIGN;
  51. __entry->ret = ret;
  52. ),
  53. TP_printk(LOCAL_PR_FMT ", returned: %d", LOCAL_PR_ARG,
  54. __entry->ret)
  55. );
  56. DEFINE_EVENT(local_only_evt4, 802154_drv_start,
  57. TP_PROTO(struct ieee802154_local *local),
  58. TP_ARGS(local)
  59. );
  60. DEFINE_EVENT(local_only_evt4, 802154_drv_stop,
  61. TP_PROTO(struct ieee802154_local *local),
  62. TP_ARGS(local)
  63. );
  64. TRACE_EVENT(802154_drv_set_channel,
  65. TP_PROTO(struct ieee802154_local *local, u8 page, u8 channel),
  66. TP_ARGS(local, page, channel),
  67. TP_STRUCT__entry(
  68. LOCAL_ENTRY
  69. __field(u8, page)
  70. __field(u8, channel)
  71. ),
  72. TP_fast_assign(
  73. LOCAL_ASSIGN;
  74. __entry->page = page;
  75. __entry->channel = channel;
  76. ),
  77. TP_printk(LOCAL_PR_FMT ", page: %d, channel: %d", LOCAL_PR_ARG,
  78. __entry->page, __entry->channel)
  79. );
  80. TRACE_EVENT(802154_drv_set_cca_mode,
  81. TP_PROTO(struct ieee802154_local *local,
  82. const struct wpan_phy_cca *cca),
  83. TP_ARGS(local, cca),
  84. TP_STRUCT__entry(
  85. LOCAL_ENTRY
  86. CCA_ENTRY
  87. ),
  88. TP_fast_assign(
  89. LOCAL_ASSIGN;
  90. CCA_ASSIGN;
  91. ),
  92. TP_printk(LOCAL_PR_FMT ", " CCA_PR_FMT, LOCAL_PR_ARG,
  93. CCA_PR_ARG)
  94. );
  95. TRACE_EVENT(802154_drv_set_cca_ed_level,
  96. TP_PROTO(struct ieee802154_local *local, s32 mbm),
  97. TP_ARGS(local, mbm),
  98. TP_STRUCT__entry(
  99. LOCAL_ENTRY
  100. __field(s32, mbm)
  101. ),
  102. TP_fast_assign(
  103. LOCAL_ASSIGN;
  104. __entry->mbm = mbm;
  105. ),
  106. TP_printk(LOCAL_PR_FMT ", ed level: %d", LOCAL_PR_ARG,
  107. __entry->mbm)
  108. );
  109. TRACE_EVENT(802154_drv_set_tx_power,
  110. TP_PROTO(struct ieee802154_local *local, s32 power),
  111. TP_ARGS(local, power),
  112. TP_STRUCT__entry(
  113. LOCAL_ENTRY
  114. __field(s32, power)
  115. ),
  116. TP_fast_assign(
  117. LOCAL_ASSIGN;
  118. __entry->power = power;
  119. ),
  120. TP_printk(LOCAL_PR_FMT ", mbm: %d", LOCAL_PR_ARG,
  121. __entry->power)
  122. );
  123. TRACE_EVENT(802154_drv_set_lbt_mode,
  124. TP_PROTO(struct ieee802154_local *local, bool mode),
  125. TP_ARGS(local, mode),
  126. TP_STRUCT__entry(
  127. LOCAL_ENTRY
  128. __field(bool, mode)
  129. ),
  130. TP_fast_assign(
  131. LOCAL_ASSIGN;
  132. __entry->mode = mode;
  133. ),
  134. TP_printk(LOCAL_PR_FMT ", lbt mode: %s", LOCAL_PR_ARG,
  135. BOOL_TO_STR(__entry->mode))
  136. );
  137. TRACE_EVENT(802154_drv_set_short_addr,
  138. TP_PROTO(struct ieee802154_local *local, __le16 short_addr),
  139. TP_ARGS(local, short_addr),
  140. TP_STRUCT__entry(
  141. LOCAL_ENTRY
  142. __field(__le16, short_addr)
  143. ),
  144. TP_fast_assign(
  145. LOCAL_ASSIGN;
  146. __entry->short_addr = short_addr;
  147. ),
  148. TP_printk(LOCAL_PR_FMT ", short addr: 0x%04x", LOCAL_PR_ARG,
  149. le16_to_cpu(__entry->short_addr))
  150. );
  151. TRACE_EVENT(802154_drv_set_pan_id,
  152. TP_PROTO(struct ieee802154_local *local, __le16 pan_id),
  153. TP_ARGS(local, pan_id),
  154. TP_STRUCT__entry(
  155. LOCAL_ENTRY
  156. __field(__le16, pan_id)
  157. ),
  158. TP_fast_assign(
  159. LOCAL_ASSIGN;
  160. __entry->pan_id = pan_id;
  161. ),
  162. TP_printk(LOCAL_PR_FMT ", pan id: 0x%04x", LOCAL_PR_ARG,
  163. le16_to_cpu(__entry->pan_id))
  164. );
  165. TRACE_EVENT(802154_drv_set_extended_addr,
  166. TP_PROTO(struct ieee802154_local *local, __le64 extended_addr),
  167. TP_ARGS(local, extended_addr),
  168. TP_STRUCT__entry(
  169. LOCAL_ENTRY
  170. __field(__le64, extended_addr)
  171. ),
  172. TP_fast_assign(
  173. LOCAL_ASSIGN;
  174. __entry->extended_addr = extended_addr;
  175. ),
  176. TP_printk(LOCAL_PR_FMT ", extended addr: 0x%llx", LOCAL_PR_ARG,
  177. le64_to_cpu(__entry->extended_addr))
  178. );
  179. TRACE_EVENT(802154_drv_set_pan_coord,
  180. TP_PROTO(struct ieee802154_local *local, bool is_coord),
  181. TP_ARGS(local, is_coord),
  182. TP_STRUCT__entry(
  183. LOCAL_ENTRY
  184. __field(bool, is_coord)
  185. ),
  186. TP_fast_assign(
  187. LOCAL_ASSIGN;
  188. __entry->is_coord = is_coord;
  189. ),
  190. TP_printk(LOCAL_PR_FMT ", is_coord: %s", LOCAL_PR_ARG,
  191. BOOL_TO_STR(__entry->is_coord))
  192. );
  193. TRACE_EVENT(802154_drv_set_csma_params,
  194. TP_PROTO(struct ieee802154_local *local, u8 min_be, u8 max_be,
  195. u8 max_csma_backoffs),
  196. TP_ARGS(local, min_be, max_be, max_csma_backoffs),
  197. TP_STRUCT__entry(
  198. LOCAL_ENTRY
  199. __field(u8, min_be)
  200. __field(u8, max_be)
  201. __field(u8, max_csma_backoffs)
  202. ),
  203. TP_fast_assign(
  204. LOCAL_ASSIGN,
  205. __entry->min_be = min_be;
  206. __entry->max_be = max_be;
  207. __entry->max_csma_backoffs = max_csma_backoffs;
  208. ),
  209. TP_printk(LOCAL_PR_FMT ", min be: %d, max be: %d, max csma backoffs: %d",
  210. LOCAL_PR_ARG, __entry->min_be, __entry->max_be,
  211. __entry->max_csma_backoffs)
  212. );
  213. TRACE_EVENT(802154_drv_set_max_frame_retries,
  214. TP_PROTO(struct ieee802154_local *local, s8 max_frame_retries),
  215. TP_ARGS(local, max_frame_retries),
  216. TP_STRUCT__entry(
  217. LOCAL_ENTRY
  218. __field(s8, max_frame_retries)
  219. ),
  220. TP_fast_assign(
  221. LOCAL_ASSIGN;
  222. __entry->max_frame_retries = max_frame_retries;
  223. ),
  224. TP_printk(LOCAL_PR_FMT ", max frame retries: %d", LOCAL_PR_ARG,
  225. __entry->max_frame_retries)
  226. );
  227. TRACE_EVENT(802154_drv_set_promiscuous_mode,
  228. TP_PROTO(struct ieee802154_local *local, bool on),
  229. TP_ARGS(local, on),
  230. TP_STRUCT__entry(
  231. LOCAL_ENTRY
  232. __field(bool, on)
  233. ),
  234. TP_fast_assign(
  235. LOCAL_ASSIGN;
  236. __entry->on = on;
  237. ),
  238. TP_printk(LOCAL_PR_FMT ", promiscuous mode: %s", LOCAL_PR_ARG,
  239. BOOL_TO_STR(__entry->on))
  240. );
  241. #endif /* !__MAC802154_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
  242. #undef TRACE_INCLUDE_PATH
  243. #define TRACE_INCLUDE_PATH .
  244. #undef TRACE_INCLUDE_FILE
  245. #define TRACE_INCLUDE_FILE trace
  246. #include <trace/define_trace.h>