trace.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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_tx,
  166. TP_PROTO(u8 vring, u16 index, unsigned int len, u8 frags),
  167. TP_ARGS(vring, index, len, frags),
  168. TP_STRUCT__entry(
  169. __field(u8, vring)
  170. __field(u8, frags)
  171. __field(u16, index)
  172. __field(unsigned int, len)
  173. ),
  174. TP_fast_assign(
  175. __entry->vring = vring;
  176. __entry->frags = frags;
  177. __entry->index = index;
  178. __entry->len = len;
  179. ),
  180. TP_printk("vring %d index %d len %d frags %d",
  181. __entry->vring, __entry->index, __entry->len, __entry->frags)
  182. );
  183. TRACE_EVENT(wil6210_tx_done,
  184. TP_PROTO(u8 vring, u16 index, unsigned int len, u8 err),
  185. TP_ARGS(vring, index, len, err),
  186. TP_STRUCT__entry(
  187. __field(u8, vring)
  188. __field(u8, err)
  189. __field(u16, index)
  190. __field(unsigned int, len)
  191. ),
  192. TP_fast_assign(
  193. __entry->vring = vring;
  194. __entry->index = index;
  195. __entry->len = len;
  196. __entry->err = err;
  197. ),
  198. TP_printk("vring %d index %d len %d err 0x%02x",
  199. __entry->vring, __entry->index, __entry->len,
  200. __entry->err)
  201. );
  202. #endif /* WIL6210_TRACE_H || TRACE_HEADER_MULTI_READ*/
  203. #if defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__)
  204. /* we don't want to use include/trace/events */
  205. #undef TRACE_INCLUDE_PATH
  206. #define TRACE_INCLUDE_PATH .
  207. #undef TRACE_INCLUDE_FILE
  208. #define TRACE_INCLUDE_FILE trace
  209. /* This part must be outside protection */
  210. #include <trace/define_trace.h>
  211. #endif /* defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__) */