trace.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. #if !defined(_ATH6KL_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  2. #include <net/cfg80211.h>
  3. #include <linux/skbuff.h>
  4. #include <linux/tracepoint.h>
  5. #include "wmi.h"
  6. #include "hif.h"
  7. #if !defined(_ATH6KL_TRACE_H)
  8. static inline unsigned int ath6kl_get_wmi_id(void *buf, size_t buf_len)
  9. {
  10. struct wmi_cmd_hdr *hdr = buf;
  11. if (buf_len < sizeof(*hdr))
  12. return 0;
  13. return le16_to_cpu(hdr->cmd_id);
  14. }
  15. #endif /* __ATH6KL_TRACE_H */
  16. #define _ATH6KL_TRACE_H
  17. /* create empty functions when tracing is disabled */
  18. #if !defined(CONFIG_ATH6KL_TRACING)
  19. #undef TRACE_EVENT
  20. #define TRACE_EVENT(name, proto, ...) \
  21. static inline void trace_ ## name(proto) {}
  22. #undef DECLARE_EVENT_CLASS
  23. #define DECLARE_EVENT_CLASS(...)
  24. #undef DEFINE_EVENT
  25. #define DEFINE_EVENT(evt_class, name, proto, ...) \
  26. static inline void trace_ ## name(proto) {}
  27. #endif /* !CONFIG_ATH6KL_TRACING || __CHECKER__ */
  28. #undef TRACE_SYSTEM
  29. #define TRACE_SYSTEM ath6kl
  30. TRACE_EVENT(ath6kl_wmi_cmd,
  31. TP_PROTO(void *buf, size_t buf_len),
  32. TP_ARGS(buf, buf_len),
  33. TP_STRUCT__entry(
  34. __field(unsigned int, id)
  35. __field(size_t, buf_len)
  36. __dynamic_array(u8, buf, buf_len)
  37. ),
  38. TP_fast_assign(
  39. __entry->id = ath6kl_get_wmi_id(buf, buf_len);
  40. __entry->buf_len = buf_len;
  41. memcpy(__get_dynamic_array(buf), buf, buf_len);
  42. ),
  43. TP_printk(
  44. "id %d len %zd",
  45. __entry->id, __entry->buf_len
  46. )
  47. );
  48. TRACE_EVENT(ath6kl_wmi_event,
  49. TP_PROTO(void *buf, size_t buf_len),
  50. TP_ARGS(buf, buf_len),
  51. TP_STRUCT__entry(
  52. __field(unsigned int, id)
  53. __field(size_t, buf_len)
  54. __dynamic_array(u8, buf, buf_len)
  55. ),
  56. TP_fast_assign(
  57. __entry->id = ath6kl_get_wmi_id(buf, buf_len);
  58. __entry->buf_len = buf_len;
  59. memcpy(__get_dynamic_array(buf), buf, buf_len);
  60. ),
  61. TP_printk(
  62. "id %d len %zd",
  63. __entry->id, __entry->buf_len
  64. )
  65. );
  66. TRACE_EVENT(ath6kl_sdio,
  67. TP_PROTO(unsigned int addr, int flags,
  68. void *buf, size_t buf_len),
  69. TP_ARGS(addr, flags, buf, buf_len),
  70. TP_STRUCT__entry(
  71. __field(unsigned int, tx)
  72. __field(unsigned int, addr)
  73. __field(int, flags)
  74. __field(size_t, buf_len)
  75. __dynamic_array(u8, buf, buf_len)
  76. ),
  77. TP_fast_assign(
  78. __entry->addr = addr;
  79. __entry->flags = flags;
  80. __entry->buf_len = buf_len;
  81. memcpy(__get_dynamic_array(buf), buf, buf_len);
  82. if (flags & HIF_WRITE)
  83. __entry->tx = 1;
  84. else
  85. __entry->tx = 0;
  86. ),
  87. TP_printk(
  88. "%s addr 0x%x flags 0x%x len %zd\n",
  89. __entry->tx ? "tx" : "rx",
  90. __entry->addr,
  91. __entry->flags,
  92. __entry->buf_len
  93. )
  94. );
  95. TRACE_EVENT(ath6kl_sdio_scat,
  96. TP_PROTO(unsigned int addr, int flags, unsigned int total_len,
  97. unsigned int entries, struct hif_scatter_item *list),
  98. TP_ARGS(addr, flags, total_len, entries, list),
  99. TP_STRUCT__entry(
  100. __field(unsigned int, tx)
  101. __field(unsigned int, addr)
  102. __field(int, flags)
  103. __field(unsigned int, entries)
  104. __field(size_t, total_len)
  105. __dynamic_array(unsigned int, len_array, entries)
  106. __dynamic_array(u8, data, total_len)
  107. ),
  108. TP_fast_assign(
  109. unsigned int *len_array;
  110. int i, offset = 0;
  111. size_t len;
  112. __entry->addr = addr;
  113. __entry->flags = flags;
  114. __entry->entries = entries;
  115. __entry->total_len = total_len;
  116. if (flags & HIF_WRITE)
  117. __entry->tx = 1;
  118. else
  119. __entry->tx = 0;
  120. len_array = __get_dynamic_array(len_array);
  121. for (i = 0; i < entries; i++) {
  122. len = list[i].len;
  123. memcpy((u8 *) __get_dynamic_array(data) + offset,
  124. list[i].buf, len);
  125. len_array[i] = len;
  126. offset += len;
  127. }
  128. ),
  129. TP_printk(
  130. "%s addr 0x%x flags 0x%x entries %d total_len %zd\n",
  131. __entry->tx ? "tx" : "rx",
  132. __entry->addr,
  133. __entry->flags,
  134. __entry->entries,
  135. __entry->total_len
  136. )
  137. );
  138. TRACE_EVENT(ath6kl_sdio_irq,
  139. TP_PROTO(void *buf, size_t buf_len),
  140. TP_ARGS(buf, buf_len),
  141. TP_STRUCT__entry(
  142. __field(size_t, buf_len)
  143. __dynamic_array(u8, buf, buf_len)
  144. ),
  145. TP_fast_assign(
  146. __entry->buf_len = buf_len;
  147. memcpy(__get_dynamic_array(buf), buf, buf_len);
  148. ),
  149. TP_printk(
  150. "irq len %zd\n", __entry->buf_len
  151. )
  152. );
  153. TRACE_EVENT(ath6kl_htc_rx,
  154. TP_PROTO(int status, int endpoint, void *buf,
  155. size_t buf_len),
  156. TP_ARGS(status, endpoint, buf, buf_len),
  157. TP_STRUCT__entry(
  158. __field(int, status)
  159. __field(int, endpoint)
  160. __field(size_t, buf_len)
  161. __dynamic_array(u8, buf, buf_len)
  162. ),
  163. TP_fast_assign(
  164. __entry->status = status;
  165. __entry->endpoint = endpoint;
  166. __entry->buf_len = buf_len;
  167. memcpy(__get_dynamic_array(buf), buf, buf_len);
  168. ),
  169. TP_printk(
  170. "status %d endpoint %d len %zd\n",
  171. __entry->status,
  172. __entry->endpoint,
  173. __entry->buf_len
  174. )
  175. );
  176. TRACE_EVENT(ath6kl_htc_tx,
  177. TP_PROTO(int status, int endpoint, void *buf,
  178. size_t buf_len),
  179. TP_ARGS(status, endpoint, buf, buf_len),
  180. TP_STRUCT__entry(
  181. __field(int, status)
  182. __field(int, endpoint)
  183. __field(size_t, buf_len)
  184. __dynamic_array(u8, buf, buf_len)
  185. ),
  186. TP_fast_assign(
  187. __entry->status = status;
  188. __entry->endpoint = endpoint;
  189. __entry->buf_len = buf_len;
  190. memcpy(__get_dynamic_array(buf), buf, buf_len);
  191. ),
  192. TP_printk(
  193. "status %d endpoint %d len %zd\n",
  194. __entry->status,
  195. __entry->endpoint,
  196. __entry->buf_len
  197. )
  198. );
  199. #define ATH6KL_MSG_MAX 200
  200. DECLARE_EVENT_CLASS(ath6kl_log_event,
  201. TP_PROTO(struct va_format *vaf),
  202. TP_ARGS(vaf),
  203. TP_STRUCT__entry(
  204. __dynamic_array(char, msg, ATH6KL_MSG_MAX)
  205. ),
  206. TP_fast_assign(
  207. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  208. ATH6KL_MSG_MAX,
  209. vaf->fmt,
  210. *vaf->va) >= ATH6KL_MSG_MAX);
  211. ),
  212. TP_printk("%s", __get_str(msg))
  213. );
  214. DEFINE_EVENT(ath6kl_log_event, ath6kl_log_err,
  215. TP_PROTO(struct va_format *vaf),
  216. TP_ARGS(vaf)
  217. );
  218. DEFINE_EVENT(ath6kl_log_event, ath6kl_log_warn,
  219. TP_PROTO(struct va_format *vaf),
  220. TP_ARGS(vaf)
  221. );
  222. DEFINE_EVENT(ath6kl_log_event, ath6kl_log_info,
  223. TP_PROTO(struct va_format *vaf),
  224. TP_ARGS(vaf)
  225. );
  226. TRACE_EVENT(ath6kl_log_dbg,
  227. TP_PROTO(unsigned int level, struct va_format *vaf),
  228. TP_ARGS(level, vaf),
  229. TP_STRUCT__entry(
  230. __field(unsigned int, level)
  231. __dynamic_array(char, msg, ATH6KL_MSG_MAX)
  232. ),
  233. TP_fast_assign(
  234. __entry->level = level;
  235. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  236. ATH6KL_MSG_MAX,
  237. vaf->fmt,
  238. *vaf->va) >= ATH6KL_MSG_MAX);
  239. ),
  240. TP_printk("%s", __get_str(msg))
  241. );
  242. TRACE_EVENT(ath6kl_log_dbg_dump,
  243. TP_PROTO(const char *msg, const char *prefix,
  244. const void *buf, size_t buf_len),
  245. TP_ARGS(msg, prefix, buf, buf_len),
  246. TP_STRUCT__entry(
  247. __string(msg, msg)
  248. __string(prefix, prefix)
  249. __field(size_t, buf_len)
  250. __dynamic_array(u8, buf, buf_len)
  251. ),
  252. TP_fast_assign(
  253. __assign_str(msg, msg);
  254. __assign_str(prefix, prefix);
  255. __entry->buf_len = buf_len;
  256. memcpy(__get_dynamic_array(buf), buf, buf_len);
  257. ),
  258. TP_printk(
  259. "%s/%s\n", __get_str(prefix), __get_str(msg)
  260. )
  261. );
  262. #endif /* _ ATH6KL_TRACE_H || TRACE_HEADER_MULTI_READ*/
  263. /* we don't want to use include/trace/events */
  264. #undef TRACE_INCLUDE_PATH
  265. #define TRACE_INCLUDE_PATH .
  266. #undef TRACE_INCLUDE_FILE
  267. #define TRACE_INCLUDE_FILE trace
  268. /* This part must be outside protection */
  269. #include <trace/define_trace.h>