trace.h 8.2 KB

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