trace.h 6.1 KB

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