trace.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /* SPDX-License-Identifier: ISC */
  2. /*
  3. * Copyright (c) 2013-2016 Qualcomm Atheros, Inc.
  4. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  5. */
  6. #undef TRACE_SYSTEM
  7. #define TRACE_SYSTEM wil6210
  8. #if !defined(WIL6210_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  9. #define WIL6210_TRACE_H
  10. #include <linux/tracepoint.h>
  11. #include "wil6210.h"
  12. #include "txrx.h"
  13. /* create empty functions when tracing is disabled */
  14. #if !defined(CONFIG_WIL6210_TRACING) || defined(__CHECKER__)
  15. #undef TRACE_EVENT
  16. #define TRACE_EVENT(name, proto, ...) \
  17. static inline void trace_ ## name(proto) {}
  18. #undef DECLARE_EVENT_CLASS
  19. #define DECLARE_EVENT_CLASS(...)
  20. #undef DEFINE_EVENT
  21. #define DEFINE_EVENT(evt_class, name, proto, ...) \
  22. static inline void trace_ ## name(proto) {}
  23. #endif /* !CONFIG_WIL6210_TRACING || defined(__CHECKER__) */
  24. DECLARE_EVENT_CLASS(wil6210_wmi,
  25. TP_PROTO(struct wmi_cmd_hdr *wmi, void *buf, u16 buf_len),
  26. TP_ARGS(wmi, buf, buf_len),
  27. TP_STRUCT__entry(
  28. __field(u8, mid)
  29. __field(u16, command_id)
  30. __field(u32, fw_timestamp)
  31. __field(u16, buf_len)
  32. __dynamic_array(u8, buf, buf_len)
  33. ),
  34. TP_fast_assign(
  35. __entry->mid = wmi->mid;
  36. __entry->command_id = le16_to_cpu(wmi->command_id);
  37. __entry->fw_timestamp = le32_to_cpu(wmi->fw_timestamp);
  38. __entry->buf_len = buf_len;
  39. memcpy(__get_dynamic_array(buf), buf, buf_len);
  40. ),
  41. TP_printk(
  42. "MID %d id 0x%04x len %d timestamp %d",
  43. __entry->mid, __entry->command_id, __entry->buf_len,
  44. __entry->fw_timestamp
  45. )
  46. );
  47. DEFINE_EVENT(wil6210_wmi, wil6210_wmi_cmd,
  48. TP_PROTO(struct wmi_cmd_hdr *wmi, void *buf, u16 buf_len),
  49. TP_ARGS(wmi, buf, buf_len)
  50. );
  51. DEFINE_EVENT(wil6210_wmi, wil6210_wmi_event,
  52. TP_PROTO(struct wmi_cmd_hdr *wmi, void *buf, u16 buf_len),
  53. TP_ARGS(wmi, buf, buf_len)
  54. );
  55. #define WIL6210_MSG_MAX (200)
  56. DECLARE_EVENT_CLASS(wil6210_log_event,
  57. TP_PROTO(struct va_format *vaf),
  58. TP_ARGS(vaf),
  59. TP_STRUCT__entry(
  60. __vstring(msg, vaf->fmt, vaf->va)
  61. ),
  62. TP_fast_assign(
  63. __assign_vstr(msg, vaf->fmt, vaf->va);
  64. ),
  65. TP_printk("%s", __get_str(msg))
  66. );
  67. DEFINE_EVENT(wil6210_log_event, wil6210_log_err,
  68. TP_PROTO(struct va_format *vaf),
  69. TP_ARGS(vaf)
  70. );
  71. DEFINE_EVENT(wil6210_log_event, wil6210_log_info,
  72. TP_PROTO(struct va_format *vaf),
  73. TP_ARGS(vaf)
  74. );
  75. DEFINE_EVENT(wil6210_log_event, wil6210_log_dbg,
  76. TP_PROTO(struct va_format *vaf),
  77. TP_ARGS(vaf)
  78. );
  79. #define wil_pseudo_irq_cause(x) __print_flags(x, "|", \
  80. {BIT_DMA_PSEUDO_CAUSE_RX, "Rx" }, \
  81. {BIT_DMA_PSEUDO_CAUSE_TX, "Tx" }, \
  82. {BIT_DMA_PSEUDO_CAUSE_MISC, "Misc" })
  83. TRACE_EVENT(wil6210_irq_pseudo,
  84. TP_PROTO(u32 x),
  85. TP_ARGS(x),
  86. TP_STRUCT__entry(
  87. __field(u32, x)
  88. ),
  89. TP_fast_assign(
  90. __entry->x = x;
  91. ),
  92. TP_printk("cause 0x%08x : %s", __entry->x,
  93. wil_pseudo_irq_cause(__entry->x))
  94. );
  95. DECLARE_EVENT_CLASS(wil6210_irq,
  96. TP_PROTO(u32 x),
  97. TP_ARGS(x),
  98. TP_STRUCT__entry(
  99. __field(u32, x)
  100. ),
  101. TP_fast_assign(
  102. __entry->x = x;
  103. ),
  104. TP_printk("cause 0x%08x", __entry->x)
  105. );
  106. DEFINE_EVENT(wil6210_irq, wil6210_irq_rx,
  107. TP_PROTO(u32 x),
  108. TP_ARGS(x)
  109. );
  110. DEFINE_EVENT(wil6210_irq, wil6210_irq_tx,
  111. TP_PROTO(u32 x),
  112. TP_ARGS(x)
  113. );
  114. DEFINE_EVENT(wil6210_irq, wil6210_irq_misc,
  115. TP_PROTO(u32 x),
  116. TP_ARGS(x)
  117. );
  118. DEFINE_EVENT(wil6210_irq, wil6210_irq_misc_thread,
  119. TP_PROTO(u32 x),
  120. TP_ARGS(x)
  121. );
  122. TRACE_EVENT(wil6210_rx,
  123. TP_PROTO(u16 index, struct vring_rx_desc *d),
  124. TP_ARGS(index, d),
  125. TP_STRUCT__entry(
  126. __field(u16, index)
  127. __field(unsigned int, len)
  128. __field(u8, mid)
  129. __field(u8, cid)
  130. __field(u8, tid)
  131. __field(u8, type)
  132. __field(u8, subtype)
  133. __field(u16, seq)
  134. __field(u8, mcs)
  135. ),
  136. TP_fast_assign(
  137. __entry->index = index;
  138. __entry->len = d->dma.length;
  139. __entry->mid = wil_rxdesc_mid(d);
  140. __entry->cid = wil_rxdesc_cid(d);
  141. __entry->tid = wil_rxdesc_tid(d);
  142. __entry->type = wil_rxdesc_ftype(d);
  143. __entry->subtype = wil_rxdesc_subtype(d);
  144. __entry->seq = wil_rxdesc_seq(d);
  145. __entry->mcs = wil_rxdesc_mcs(d);
  146. ),
  147. TP_printk("index %d len %d mid %d cid (%%8) %d tid %d mcs %d seq 0x%03x"
  148. " type 0x%1x subtype 0x%1x", __entry->index, __entry->len,
  149. __entry->mid, __entry->cid, __entry->tid, __entry->mcs,
  150. __entry->seq, __entry->type, __entry->subtype)
  151. );
  152. TRACE_EVENT(wil6210_rx_status,
  153. TP_PROTO(struct wil6210_priv *wil, u8 use_compressed, u16 buff_id,
  154. void *msg),
  155. TP_ARGS(wil, use_compressed, buff_id, msg),
  156. TP_STRUCT__entry(__field(u8, use_compressed)
  157. __field(u16, buff_id)
  158. __field(unsigned int, len)
  159. __field(u8, mid)
  160. __field(u8, cid)
  161. __field(u8, tid)
  162. __field(u8, type)
  163. __field(u8, subtype)
  164. __field(u16, seq)
  165. __field(u8, mcs)
  166. ),
  167. TP_fast_assign(__entry->use_compressed = use_compressed;
  168. __entry->buff_id = buff_id;
  169. __entry->len = wil_rx_status_get_length(msg);
  170. __entry->mid = wil_rx_status_get_mid(msg);
  171. __entry->cid = wil_rx_status_get_cid(msg);
  172. __entry->tid = wil_rx_status_get_tid(msg);
  173. __entry->type = wil_rx_status_get_frame_type(wil,
  174. msg);
  175. __entry->subtype = wil_rx_status_get_fc1(wil, msg);
  176. __entry->seq = wil_rx_status_get_seq(wil, msg);
  177. __entry->mcs = wil_rx_status_get_mcs(msg);
  178. ),
  179. TP_printk(
  180. "compressed %d buff_id %d len %d mid %d cid %d tid %d mcs %d seq 0x%03x type 0x%1x subtype 0x%1x",
  181. __entry->use_compressed, __entry->buff_id, __entry->len,
  182. __entry->mid, __entry->cid, __entry->tid, __entry->mcs,
  183. __entry->seq, __entry->type, __entry->subtype)
  184. );
  185. TRACE_EVENT(wil6210_tx,
  186. TP_PROTO(u8 vring, u16 index, unsigned int len, u8 frags),
  187. TP_ARGS(vring, index, len, frags),
  188. TP_STRUCT__entry(
  189. __field(u8, vring)
  190. __field(u8, frags)
  191. __field(u16, index)
  192. __field(unsigned int, len)
  193. ),
  194. TP_fast_assign(
  195. __entry->vring = vring;
  196. __entry->frags = frags;
  197. __entry->index = index;
  198. __entry->len = len;
  199. ),
  200. TP_printk("vring %d index %d len %d frags %d",
  201. __entry->vring, __entry->index, __entry->len, __entry->frags)
  202. );
  203. TRACE_EVENT(wil6210_tx_done,
  204. TP_PROTO(u8 vring, u16 index, unsigned int len, u8 err),
  205. TP_ARGS(vring, index, len, err),
  206. TP_STRUCT__entry(
  207. __field(u8, vring)
  208. __field(u8, err)
  209. __field(u16, index)
  210. __field(unsigned int, len)
  211. ),
  212. TP_fast_assign(
  213. __entry->vring = vring;
  214. __entry->index = index;
  215. __entry->len = len;
  216. __entry->err = err;
  217. ),
  218. TP_printk("vring %d index %d len %d err 0x%02x",
  219. __entry->vring, __entry->index, __entry->len,
  220. __entry->err)
  221. );
  222. TRACE_EVENT(wil6210_tx_status,
  223. TP_PROTO(struct wil_ring_tx_status *msg, u16 index,
  224. unsigned int len),
  225. TP_ARGS(msg, index, len),
  226. TP_STRUCT__entry(__field(u16, index)
  227. __field(unsigned int, len)
  228. __field(u8, num_descs)
  229. __field(u8, ring_id)
  230. __field(u8, status)
  231. __field(u8, mcs)
  232. ),
  233. TP_fast_assign(__entry->index = index;
  234. __entry->len = len;
  235. __entry->num_descs = msg->num_descriptors;
  236. __entry->ring_id = msg->ring_id;
  237. __entry->status = msg->status;
  238. __entry->mcs = wil_tx_status_get_mcs(msg);
  239. ),
  240. TP_printk(
  241. "ring_id %d swtail 0x%x len %d num_descs %d status 0x%x mcs %d",
  242. __entry->ring_id, __entry->index, __entry->len,
  243. __entry->num_descs, __entry->status, __entry->mcs)
  244. );
  245. #endif /* WIL6210_TRACE_H || TRACE_HEADER_MULTI_READ*/
  246. #if defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__)
  247. /* we don't want to use include/trace/events */
  248. #undef TRACE_INCLUDE_PATH
  249. #define TRACE_INCLUDE_PATH .
  250. #undef TRACE_INCLUDE_FILE
  251. #define TRACE_INCLUDE_FILE trace
  252. /* This part must be outside protection */
  253. #include <trace/define_trace.h>
  254. #endif /* defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__) */