musb_trace.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * musb_trace.h - MUSB Controller Trace Support
  4. *
  5. * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
  6. *
  7. * Author: Bin Liu <b-liu@ti.com>
  8. */
  9. #undef TRACE_SYSTEM
  10. #define TRACE_SYSTEM musb
  11. #if !defined(__MUSB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  12. #define __MUSB_TRACE_H
  13. #include <linux/types.h>
  14. #include <linux/tracepoint.h>
  15. #include <linux/usb.h>
  16. #include "musb_core.h"
  17. #ifdef CONFIG_USB_TI_CPPI41_DMA
  18. #include "cppi_dma.h"
  19. #endif
  20. #define MUSB_MSG_MAX 500
  21. TRACE_EVENT(musb_log,
  22. TP_PROTO(struct musb *musb, struct va_format *vaf),
  23. TP_ARGS(musb, vaf),
  24. TP_STRUCT__entry(
  25. __string(name, dev_name(musb->controller))
  26. __dynamic_array(char, msg, MUSB_MSG_MAX)
  27. ),
  28. TP_fast_assign(
  29. __assign_str(name, dev_name(musb->controller));
  30. vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va);
  31. ),
  32. TP_printk("%s: %s", __get_str(name), __get_str(msg))
  33. );
  34. DECLARE_EVENT_CLASS(musb_regb,
  35. TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data),
  36. TP_ARGS(caller, addr, offset, data),
  37. TP_STRUCT__entry(
  38. __field(void *, caller)
  39. __field(const void *, addr)
  40. __field(unsigned int, offset)
  41. __field(u8, data)
  42. ),
  43. TP_fast_assign(
  44. __entry->caller = caller;
  45. __entry->addr = addr;
  46. __entry->offset = offset;
  47. __entry->data = data;
  48. ),
  49. TP_printk("%pS: %p + %04x: %02x",
  50. __entry->caller, __entry->addr, __entry->offset, __entry->data)
  51. );
  52. DEFINE_EVENT(musb_regb, musb_readb,
  53. TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data),
  54. TP_ARGS(caller, addr, offset, data)
  55. );
  56. DEFINE_EVENT(musb_regb, musb_writeb,
  57. TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data),
  58. TP_ARGS(caller, addr, offset, data)
  59. );
  60. DECLARE_EVENT_CLASS(musb_regw,
  61. TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data),
  62. TP_ARGS(caller, addr, offset, data),
  63. TP_STRUCT__entry(
  64. __field(void *, caller)
  65. __field(const void *, addr)
  66. __field(unsigned int, offset)
  67. __field(u16, data)
  68. ),
  69. TP_fast_assign(
  70. __entry->caller = caller;
  71. __entry->addr = addr;
  72. __entry->offset = offset;
  73. __entry->data = data;
  74. ),
  75. TP_printk("%pS: %p + %04x: %04x",
  76. __entry->caller, __entry->addr, __entry->offset, __entry->data)
  77. );
  78. DEFINE_EVENT(musb_regw, musb_readw,
  79. TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data),
  80. TP_ARGS(caller, addr, offset, data)
  81. );
  82. DEFINE_EVENT(musb_regw, musb_writew,
  83. TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data),
  84. TP_ARGS(caller, addr, offset, data)
  85. );
  86. DECLARE_EVENT_CLASS(musb_regl,
  87. TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data),
  88. TP_ARGS(caller, addr, offset, data),
  89. TP_STRUCT__entry(
  90. __field(void *, caller)
  91. __field(const void *, addr)
  92. __field(unsigned int, offset)
  93. __field(u32, data)
  94. ),
  95. TP_fast_assign(
  96. __entry->caller = caller;
  97. __entry->addr = addr;
  98. __entry->offset = offset;
  99. __entry->data = data;
  100. ),
  101. TP_printk("%pS: %p + %04x: %08x",
  102. __entry->caller, __entry->addr, __entry->offset, __entry->data)
  103. );
  104. DEFINE_EVENT(musb_regl, musb_readl,
  105. TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data),
  106. TP_ARGS(caller, addr, offset, data)
  107. );
  108. DEFINE_EVENT(musb_regl, musb_writel,
  109. TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data),
  110. TP_ARGS(caller, addr, offset, data)
  111. );
  112. TRACE_EVENT(musb_isr,
  113. TP_PROTO(struct musb *musb),
  114. TP_ARGS(musb),
  115. TP_STRUCT__entry(
  116. __string(name, dev_name(musb->controller))
  117. __field(u8, int_usb)
  118. __field(u16, int_tx)
  119. __field(u16, int_rx)
  120. ),
  121. TP_fast_assign(
  122. __assign_str(name, dev_name(musb->controller));
  123. __entry->int_usb = musb->int_usb;
  124. __entry->int_tx = musb->int_tx;
  125. __entry->int_rx = musb->int_rx;
  126. ),
  127. TP_printk("%s: usb %02x, tx %04x, rx %04x",
  128. __get_str(name), __entry->int_usb,
  129. __entry->int_tx, __entry->int_rx
  130. )
  131. );
  132. DECLARE_EVENT_CLASS(musb_urb,
  133. TP_PROTO(struct musb *musb, struct urb *urb),
  134. TP_ARGS(musb, urb),
  135. TP_STRUCT__entry(
  136. __string(name, dev_name(musb->controller))
  137. __field(struct urb *, urb)
  138. __field(unsigned int, pipe)
  139. __field(int, status)
  140. __field(unsigned int, flag)
  141. __field(u32, buf_len)
  142. __field(u32, actual_len)
  143. ),
  144. TP_fast_assign(
  145. __assign_str(name, dev_name(musb->controller));
  146. __entry->urb = urb;
  147. __entry->pipe = urb->pipe;
  148. __entry->status = urb->status;
  149. __entry->flag = urb->transfer_flags;
  150. __entry->buf_len = urb->transfer_buffer_length;
  151. __entry->actual_len = urb->actual_length;
  152. ),
  153. TP_printk("%s: %p, dev%d ep%d%s, flag 0x%x, len %d/%d, status %d",
  154. __get_str(name), __entry->urb,
  155. usb_pipedevice(__entry->pipe),
  156. usb_pipeendpoint(__entry->pipe),
  157. usb_pipein(__entry->pipe) ? "in" : "out",
  158. __entry->flag,
  159. __entry->actual_len, __entry->buf_len,
  160. __entry->status
  161. )
  162. );
  163. DEFINE_EVENT(musb_urb, musb_urb_start,
  164. TP_PROTO(struct musb *musb, struct urb *urb),
  165. TP_ARGS(musb, urb)
  166. );
  167. DEFINE_EVENT(musb_urb, musb_urb_gb,
  168. TP_PROTO(struct musb *musb, struct urb *urb),
  169. TP_ARGS(musb, urb)
  170. );
  171. DEFINE_EVENT(musb_urb, musb_urb_rx,
  172. TP_PROTO(struct musb *musb, struct urb *urb),
  173. TP_ARGS(musb, urb)
  174. );
  175. DEFINE_EVENT(musb_urb, musb_urb_tx,
  176. TP_PROTO(struct musb *musb, struct urb *urb),
  177. TP_ARGS(musb, urb)
  178. );
  179. DEFINE_EVENT(musb_urb, musb_urb_enq,
  180. TP_PROTO(struct musb *musb, struct urb *urb),
  181. TP_ARGS(musb, urb)
  182. );
  183. DEFINE_EVENT(musb_urb, musb_urb_deq,
  184. TP_PROTO(struct musb *musb, struct urb *urb),
  185. TP_ARGS(musb, urb)
  186. );
  187. DECLARE_EVENT_CLASS(musb_req,
  188. TP_PROTO(struct musb_request *req),
  189. TP_ARGS(req),
  190. TP_STRUCT__entry(
  191. __field(struct usb_request *, req)
  192. __field(u8, is_tx)
  193. __field(u8, epnum)
  194. __field(int, status)
  195. __field(unsigned int, buf_len)
  196. __field(unsigned int, actual_len)
  197. __field(unsigned int, zero)
  198. __field(unsigned int, short_not_ok)
  199. __field(unsigned int, no_interrupt)
  200. ),
  201. TP_fast_assign(
  202. __entry->req = &req->request;
  203. __entry->is_tx = req->tx;
  204. __entry->epnum = req->epnum;
  205. __entry->status = req->request.status;
  206. __entry->buf_len = req->request.length;
  207. __entry->actual_len = req->request.actual;
  208. __entry->zero = req->request.zero;
  209. __entry->short_not_ok = req->request.short_not_ok;
  210. __entry->no_interrupt = req->request.no_interrupt;
  211. ),
  212. TP_printk("%p, ep%d %s, %s%s%s, len %d/%d, status %d",
  213. __entry->req, __entry->epnum,
  214. __entry->is_tx ? "tx/IN" : "rx/OUT",
  215. __entry->zero ? "Z" : "z",
  216. __entry->short_not_ok ? "S" : "s",
  217. __entry->no_interrupt ? "I" : "i",
  218. __entry->actual_len, __entry->buf_len,
  219. __entry->status
  220. )
  221. );
  222. DEFINE_EVENT(musb_req, musb_req_gb,
  223. TP_PROTO(struct musb_request *req),
  224. TP_ARGS(req)
  225. );
  226. DEFINE_EVENT(musb_req, musb_req_tx,
  227. TP_PROTO(struct musb_request *req),
  228. TP_ARGS(req)
  229. );
  230. DEFINE_EVENT(musb_req, musb_req_rx,
  231. TP_PROTO(struct musb_request *req),
  232. TP_ARGS(req)
  233. );
  234. DEFINE_EVENT(musb_req, musb_req_alloc,
  235. TP_PROTO(struct musb_request *req),
  236. TP_ARGS(req)
  237. );
  238. DEFINE_EVENT(musb_req, musb_req_free,
  239. TP_PROTO(struct musb_request *req),
  240. TP_ARGS(req)
  241. );
  242. DEFINE_EVENT(musb_req, musb_req_start,
  243. TP_PROTO(struct musb_request *req),
  244. TP_ARGS(req)
  245. );
  246. DEFINE_EVENT(musb_req, musb_req_enq,
  247. TP_PROTO(struct musb_request *req),
  248. TP_ARGS(req)
  249. );
  250. DEFINE_EVENT(musb_req, musb_req_deq,
  251. TP_PROTO(struct musb_request *req),
  252. TP_ARGS(req)
  253. );
  254. #ifdef CONFIG_USB_TI_CPPI41_DMA
  255. DECLARE_EVENT_CLASS(musb_cppi41,
  256. TP_PROTO(struct cppi41_dma_channel *ch),
  257. TP_ARGS(ch),
  258. TP_STRUCT__entry(
  259. __field(struct cppi41_dma_channel *, ch)
  260. __string(name, dev_name(ch->hw_ep->musb->controller))
  261. __field(u8, hwep)
  262. __field(u8, port)
  263. __field(u8, is_tx)
  264. __field(u32, len)
  265. __field(u32, prog_len)
  266. __field(u32, xferred)
  267. ),
  268. TP_fast_assign(
  269. __entry->ch = ch;
  270. __assign_str(name, dev_name(ch->hw_ep->musb->controller));
  271. __entry->hwep = ch->hw_ep->epnum;
  272. __entry->port = ch->port_num;
  273. __entry->is_tx = ch->is_tx;
  274. __entry->len = ch->total_len;
  275. __entry->prog_len = ch->prog_len;
  276. __entry->xferred = ch->transferred;
  277. ),
  278. TP_printk("%s: %p, hwep%d ch%d%s, prog_len %d, len %d/%d",
  279. __get_str(name), __entry->ch, __entry->hwep,
  280. __entry->port, __entry->is_tx ? "tx" : "rx",
  281. __entry->prog_len, __entry->xferred, __entry->len
  282. )
  283. );
  284. DEFINE_EVENT(musb_cppi41, musb_cppi41_done,
  285. TP_PROTO(struct cppi41_dma_channel *ch),
  286. TP_ARGS(ch)
  287. );
  288. DEFINE_EVENT(musb_cppi41, musb_cppi41_gb,
  289. TP_PROTO(struct cppi41_dma_channel *ch),
  290. TP_ARGS(ch)
  291. );
  292. DEFINE_EVENT(musb_cppi41, musb_cppi41_config,
  293. TP_PROTO(struct cppi41_dma_channel *ch),
  294. TP_ARGS(ch)
  295. );
  296. DEFINE_EVENT(musb_cppi41, musb_cppi41_cont,
  297. TP_PROTO(struct cppi41_dma_channel *ch),
  298. TP_ARGS(ch)
  299. );
  300. DEFINE_EVENT(musb_cppi41, musb_cppi41_alloc,
  301. TP_PROTO(struct cppi41_dma_channel *ch),
  302. TP_ARGS(ch)
  303. );
  304. DEFINE_EVENT(musb_cppi41, musb_cppi41_abort,
  305. TP_PROTO(struct cppi41_dma_channel *ch),
  306. TP_ARGS(ch)
  307. );
  308. DEFINE_EVENT(musb_cppi41, musb_cppi41_free,
  309. TP_PROTO(struct cppi41_dma_channel *ch),
  310. TP_ARGS(ch)
  311. );
  312. #endif /* CONFIG_USB_TI_CPPI41_DMA */
  313. #endif /* __MUSB_TRACE_H */
  314. /* this part has to be here */
  315. #undef TRACE_INCLUDE_PATH
  316. #define TRACE_INCLUDE_PATH .
  317. #undef TRACE_INCLUDE_FILE
  318. #define TRACE_INCLUDE_FILE musb_trace
  319. #include <trace/define_trace.h>