trace.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. * Copyright (c) 2013 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(u16 id, void *buf, u16 buf_len),
  36. TP_ARGS(id, buf, buf_len),
  37. TP_STRUCT__entry(
  38. __field(u16, id)
  39. __field(u16, buf_len)
  40. __dynamic_array(u8, buf, buf_len)
  41. ),
  42. TP_fast_assign(
  43. __entry->id = id;
  44. __entry->buf_len = buf_len;
  45. memcpy(__get_dynamic_array(buf), buf, buf_len);
  46. ),
  47. TP_printk(
  48. "id 0x%04x len %d",
  49. __entry->id, __entry->buf_len
  50. )
  51. );
  52. DEFINE_EVENT(wil6210_wmi, wil6210_wmi_cmd,
  53. TP_PROTO(u16 id, void *buf, u16 buf_len),
  54. TP_ARGS(id, buf, buf_len)
  55. );
  56. DEFINE_EVENT(wil6210_wmi, wil6210_wmi_event,
  57. TP_PROTO(u16 id, void *buf, u16 buf_len),
  58. TP_ARGS(id, buf, buf_len)
  59. );
  60. #define WIL6210_MSG_MAX (200)
  61. DECLARE_EVENT_CLASS(wil6210_log_event,
  62. TP_PROTO(struct va_format *vaf),
  63. TP_ARGS(vaf),
  64. TP_STRUCT__entry(
  65. __dynamic_array(char, msg, WIL6210_MSG_MAX)
  66. ),
  67. TP_fast_assign(
  68. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  69. WIL6210_MSG_MAX,
  70. vaf->fmt,
  71. *vaf->va) >= WIL6210_MSG_MAX);
  72. ),
  73. TP_printk("%s", __get_str(msg))
  74. );
  75. DEFINE_EVENT(wil6210_log_event, wil6210_log_err,
  76. TP_PROTO(struct va_format *vaf),
  77. TP_ARGS(vaf)
  78. );
  79. DEFINE_EVENT(wil6210_log_event, wil6210_log_info,
  80. TP_PROTO(struct va_format *vaf),
  81. TP_ARGS(vaf)
  82. );
  83. DEFINE_EVENT(wil6210_log_event, wil6210_log_dbg,
  84. TP_PROTO(struct va_format *vaf),
  85. TP_ARGS(vaf)
  86. );
  87. #define wil_pseudo_irq_cause(x) __print_flags(x, "|", \
  88. {BIT_DMA_PSEUDO_CAUSE_RX, "Rx" }, \
  89. {BIT_DMA_PSEUDO_CAUSE_TX, "Tx" }, \
  90. {BIT_DMA_PSEUDO_CAUSE_MISC, "Misc" })
  91. TRACE_EVENT(wil6210_irq_pseudo,
  92. TP_PROTO(u32 x),
  93. TP_ARGS(x),
  94. TP_STRUCT__entry(
  95. __field(u32, x)
  96. ),
  97. TP_fast_assign(
  98. __entry->x = x;
  99. ),
  100. TP_printk("cause 0x%08x : %s", __entry->x,
  101. wil_pseudo_irq_cause(__entry->x))
  102. );
  103. DECLARE_EVENT_CLASS(wil6210_irq,
  104. TP_PROTO(u32 x),
  105. TP_ARGS(x),
  106. TP_STRUCT__entry(
  107. __field(u32, x)
  108. ),
  109. TP_fast_assign(
  110. __entry->x = x;
  111. ),
  112. TP_printk("cause 0x%08x", __entry->x)
  113. );
  114. DEFINE_EVENT(wil6210_irq, wil6210_irq_rx,
  115. TP_PROTO(u32 x),
  116. TP_ARGS(x)
  117. );
  118. DEFINE_EVENT(wil6210_irq, wil6210_irq_tx,
  119. TP_PROTO(u32 x),
  120. TP_ARGS(x)
  121. );
  122. DEFINE_EVENT(wil6210_irq, wil6210_irq_misc,
  123. TP_PROTO(u32 x),
  124. TP_ARGS(x)
  125. );
  126. DEFINE_EVENT(wil6210_irq, wil6210_irq_misc_thread,
  127. TP_PROTO(u32 x),
  128. TP_ARGS(x)
  129. );
  130. TRACE_EVENT(wil6210_rx,
  131. TP_PROTO(u16 index, struct vring_rx_desc *d),
  132. TP_ARGS(index, d),
  133. TP_STRUCT__entry(
  134. __field(u16, index)
  135. __field(unsigned int, len)
  136. __field(u8, mid)
  137. __field(u8, cid)
  138. __field(u8, tid)
  139. __field(u8, type)
  140. __field(u8, subtype)
  141. __field(u16, seq)
  142. __field(u8, mcs)
  143. ),
  144. TP_fast_assign(
  145. __entry->index = index;
  146. __entry->len = d->dma.length;
  147. __entry->mid = wil_rxdesc_mid(d);
  148. __entry->cid = wil_rxdesc_cid(d);
  149. __entry->tid = wil_rxdesc_tid(d);
  150. __entry->type = wil_rxdesc_ftype(d);
  151. __entry->subtype = wil_rxdesc_subtype(d);
  152. __entry->seq = wil_rxdesc_seq(d);
  153. __entry->mcs = wil_rxdesc_mcs(d);
  154. ),
  155. TP_printk("index %d len %d mid %d cid %d tid %d mcs %d seq 0x%03x"
  156. " type 0x%1x subtype 0x%1x", __entry->index, __entry->len,
  157. __entry->mid, __entry->cid, __entry->tid, __entry->mcs,
  158. __entry->seq, __entry->type, __entry->subtype)
  159. );
  160. TRACE_EVENT(wil6210_tx,
  161. TP_PROTO(u8 vring, u16 index, unsigned int len, u8 frags),
  162. TP_ARGS(vring, index, len, frags),
  163. TP_STRUCT__entry(
  164. __field(u8, vring)
  165. __field(u8, frags)
  166. __field(u16, index)
  167. __field(unsigned int, len)
  168. ),
  169. TP_fast_assign(
  170. __entry->vring = vring;
  171. __entry->frags = frags;
  172. __entry->index = index;
  173. __entry->len = len;
  174. ),
  175. TP_printk("vring %d index %d len %d frags %d",
  176. __entry->vring, __entry->index, __entry->len, __entry->frags)
  177. );
  178. TRACE_EVENT(wil6210_tx_done,
  179. TP_PROTO(u8 vring, u16 index, unsigned int len, u8 err),
  180. TP_ARGS(vring, index, len, err),
  181. TP_STRUCT__entry(
  182. __field(u8, vring)
  183. __field(u8, err)
  184. __field(u16, index)
  185. __field(unsigned int, len)
  186. ),
  187. TP_fast_assign(
  188. __entry->vring = vring;
  189. __entry->index = index;
  190. __entry->len = len;
  191. __entry->err = err;
  192. ),
  193. TP_printk("vring %d index %d len %d err 0x%02x",
  194. __entry->vring, __entry->index, __entry->len,
  195. __entry->err)
  196. );
  197. #endif /* WIL6210_TRACE_H || TRACE_HEADER_MULTI_READ*/
  198. #if defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__)
  199. /* we don't want to use include/trace/events */
  200. #undef TRACE_INCLUDE_PATH
  201. #define TRACE_INCLUDE_PATH .
  202. #undef TRACE_INCLUDE_FILE
  203. #define TRACE_INCLUDE_FILE trace
  204. /* This part must be outside protection */
  205. #include <trace/define_trace.h>
  206. #endif /* defined(CONFIG_WIL6210_TRACING) && !defined(__CHECKER__) */