trace.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. // SPDX-License-Identifier: GPL-2.0
  2. /**
  3. * trace.h - DesignWare USB3 DRD Controller Trace Support
  4. *
  5. * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
  6. *
  7. * Author: Felipe Balbi <balbi@ti.com>
  8. */
  9. #undef TRACE_SYSTEM
  10. #define TRACE_SYSTEM dwc3
  11. #if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  12. #define __DWC3_TRACE_H
  13. #include <linux/types.h>
  14. #include <linux/tracepoint.h>
  15. #include <asm/byteorder.h>
  16. #include "core.h"
  17. #include "debug.h"
  18. DECLARE_EVENT_CLASS(dwc3_log_io,
  19. TP_PROTO(void *base, u32 offset, u32 value),
  20. TP_ARGS(base, offset, value),
  21. TP_STRUCT__entry(
  22. __field(void *, base)
  23. __field(u32, offset)
  24. __field(u32, value)
  25. ),
  26. TP_fast_assign(
  27. __entry->base = base;
  28. __entry->offset = offset;
  29. __entry->value = value;
  30. ),
  31. TP_printk("addr %p value %08x", __entry->base + __entry->offset,
  32. __entry->value)
  33. );
  34. DEFINE_EVENT(dwc3_log_io, dwc3_readl,
  35. TP_PROTO(void __iomem *base, u32 offset, u32 value),
  36. TP_ARGS(base, offset, value)
  37. );
  38. DEFINE_EVENT(dwc3_log_io, dwc3_writel,
  39. TP_PROTO(void __iomem *base, u32 offset, u32 value),
  40. TP_ARGS(base, offset, value)
  41. );
  42. DECLARE_EVENT_CLASS(dwc3_log_event,
  43. TP_PROTO(u32 event, struct dwc3 *dwc),
  44. TP_ARGS(event, dwc),
  45. TP_STRUCT__entry(
  46. __field(u32, event)
  47. __field(u32, ep0state)
  48. __dynamic_array(char, str, DWC3_MSG_MAX)
  49. ),
  50. TP_fast_assign(
  51. __entry->event = event;
  52. __entry->ep0state = dwc->ep0state;
  53. ),
  54. TP_printk("event (%08x): %s", __entry->event,
  55. dwc3_decode_event(__get_str(str), __entry->event,
  56. __entry->ep0state))
  57. );
  58. DEFINE_EVENT(dwc3_log_event, dwc3_event,
  59. TP_PROTO(u32 event, struct dwc3 *dwc),
  60. TP_ARGS(event, dwc)
  61. );
  62. DECLARE_EVENT_CLASS(dwc3_log_ctrl,
  63. TP_PROTO(struct usb_ctrlrequest *ctrl),
  64. TP_ARGS(ctrl),
  65. TP_STRUCT__entry(
  66. __field(__u8, bRequestType)
  67. __field(__u8, bRequest)
  68. __field(__u16, wValue)
  69. __field(__u16, wIndex)
  70. __field(__u16, wLength)
  71. __dynamic_array(char, str, DWC3_MSG_MAX)
  72. ),
  73. TP_fast_assign(
  74. __entry->bRequestType = ctrl->bRequestType;
  75. __entry->bRequest = ctrl->bRequest;
  76. __entry->wValue = le16_to_cpu(ctrl->wValue);
  77. __entry->wIndex = le16_to_cpu(ctrl->wIndex);
  78. __entry->wLength = le16_to_cpu(ctrl->wLength);
  79. ),
  80. TP_printk("%s", dwc3_decode_ctrl(__get_str(str), __entry->bRequestType,
  81. __entry->bRequest, __entry->wValue,
  82. __entry->wIndex, __entry->wLength)
  83. )
  84. );
  85. DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
  86. TP_PROTO(struct usb_ctrlrequest *ctrl),
  87. TP_ARGS(ctrl)
  88. );
  89. DECLARE_EVENT_CLASS(dwc3_log_request,
  90. TP_PROTO(struct dwc3_request *req),
  91. TP_ARGS(req),
  92. TP_STRUCT__entry(
  93. __string(name, req->dep->name)
  94. __field(struct dwc3_request *, req)
  95. __field(unsigned, actual)
  96. __field(unsigned, length)
  97. __field(int, status)
  98. __field(int, zero)
  99. __field(int, short_not_ok)
  100. __field(int, no_interrupt)
  101. ),
  102. TP_fast_assign(
  103. __assign_str(name, req->dep->name);
  104. __entry->req = req;
  105. __entry->actual = req->request.actual;
  106. __entry->length = req->request.length;
  107. __entry->status = req->request.status;
  108. __entry->zero = req->request.zero;
  109. __entry->short_not_ok = req->request.short_not_ok;
  110. __entry->no_interrupt = req->request.no_interrupt;
  111. ),
  112. TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
  113. __get_str(name), __entry->req, __entry->actual, __entry->length,
  114. __entry->zero ? "Z" : "z",
  115. __entry->short_not_ok ? "S" : "s",
  116. __entry->no_interrupt ? "i" : "I",
  117. __entry->status
  118. )
  119. );
  120. DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
  121. TP_PROTO(struct dwc3_request *req),
  122. TP_ARGS(req)
  123. );
  124. DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
  125. TP_PROTO(struct dwc3_request *req),
  126. TP_ARGS(req)
  127. );
  128. DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
  129. TP_PROTO(struct dwc3_request *req),
  130. TP_ARGS(req)
  131. );
  132. DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
  133. TP_PROTO(struct dwc3_request *req),
  134. TP_ARGS(req)
  135. );
  136. DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
  137. TP_PROTO(struct dwc3_request *req),
  138. TP_ARGS(req)
  139. );
  140. DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
  141. TP_PROTO(unsigned int cmd, u32 param, int status),
  142. TP_ARGS(cmd, param, status),
  143. TP_STRUCT__entry(
  144. __field(unsigned int, cmd)
  145. __field(u32, param)
  146. __field(int, status)
  147. ),
  148. TP_fast_assign(
  149. __entry->cmd = cmd;
  150. __entry->param = param;
  151. __entry->status = status;
  152. ),
  153. TP_printk("cmd '%s' [%x] param %08x --> status: %s",
  154. dwc3_gadget_generic_cmd_string(__entry->cmd),
  155. __entry->cmd, __entry->param,
  156. dwc3_gadget_generic_cmd_status_string(__entry->status)
  157. )
  158. );
  159. DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
  160. TP_PROTO(unsigned int cmd, u32 param, int status),
  161. TP_ARGS(cmd, param, status)
  162. );
  163. DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
  164. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  165. struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
  166. TP_ARGS(dep, cmd, params, cmd_status),
  167. TP_STRUCT__entry(
  168. __string(name, dep->name)
  169. __field(unsigned int, cmd)
  170. __field(u32, param0)
  171. __field(u32, param1)
  172. __field(u32, param2)
  173. __field(int, cmd_status)
  174. ),
  175. TP_fast_assign(
  176. __assign_str(name, dep->name);
  177. __entry->cmd = cmd;
  178. __entry->param0 = params->param0;
  179. __entry->param1 = params->param1;
  180. __entry->param2 = params->param2;
  181. __entry->cmd_status = cmd_status;
  182. ),
  183. TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
  184. __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
  185. __entry->cmd, __entry->param0,
  186. __entry->param1, __entry->param2,
  187. dwc3_ep_cmd_status_string(__entry->cmd_status)
  188. )
  189. );
  190. DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
  191. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  192. struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
  193. TP_ARGS(dep, cmd, params, cmd_status)
  194. );
  195. DECLARE_EVENT_CLASS(dwc3_log_trb,
  196. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  197. TP_ARGS(dep, trb),
  198. TP_STRUCT__entry(
  199. __string(name, dep->name)
  200. __field(struct dwc3_trb *, trb)
  201. __field(u32, allocated)
  202. __field(u32, queued)
  203. __field(u32, bpl)
  204. __field(u32, bph)
  205. __field(u32, size)
  206. __field(u32, ctrl)
  207. __field(u32, type)
  208. ),
  209. TP_fast_assign(
  210. __assign_str(name, dep->name);
  211. __entry->trb = trb;
  212. __entry->bpl = trb->bpl;
  213. __entry->bph = trb->bph;
  214. __entry->size = trb->size;
  215. __entry->ctrl = trb->ctrl;
  216. __entry->type = usb_endpoint_type(dep->endpoint.desc);
  217. ),
  218. TP_printk("%s: trb %p buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)",
  219. __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
  220. ({char *s;
  221. int pcm = ((__entry->size >> 24) & 3) + 1;
  222. switch (__entry->type) {
  223. case USB_ENDPOINT_XFER_INT:
  224. case USB_ENDPOINT_XFER_ISOC:
  225. switch (pcm) {
  226. case 1:
  227. s = "1x ";
  228. break;
  229. case 2:
  230. s = "2x ";
  231. break;
  232. case 3:
  233. default:
  234. s = "3x ";
  235. break;
  236. }
  237. break;
  238. default:
  239. s = "";
  240. } s; }),
  241. DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl,
  242. __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
  243. __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
  244. __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
  245. __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
  246. __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
  247. __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
  248. dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))
  249. )
  250. );
  251. DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
  252. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  253. TP_ARGS(dep, trb)
  254. );
  255. DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
  256. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  257. TP_ARGS(dep, trb)
  258. );
  259. DECLARE_EVENT_CLASS(dwc3_log_ep,
  260. TP_PROTO(struct dwc3_ep *dep),
  261. TP_ARGS(dep),
  262. TP_STRUCT__entry(
  263. __string(name, dep->name)
  264. __field(unsigned, maxpacket)
  265. __field(unsigned, maxpacket_limit)
  266. __field(unsigned, max_streams)
  267. __field(unsigned, maxburst)
  268. __field(unsigned, flags)
  269. __field(unsigned, direction)
  270. __field(u8, trb_enqueue)
  271. __field(u8, trb_dequeue)
  272. ),
  273. TP_fast_assign(
  274. __assign_str(name, dep->name);
  275. __entry->maxpacket = dep->endpoint.maxpacket;
  276. __entry->maxpacket_limit = dep->endpoint.maxpacket_limit;
  277. __entry->max_streams = dep->endpoint.max_streams;
  278. __entry->maxburst = dep->endpoint.maxburst;
  279. __entry->flags = dep->flags;
  280. __entry->direction = dep->direction;
  281. __entry->trb_enqueue = dep->trb_enqueue;
  282. __entry->trb_dequeue = dep->trb_dequeue;
  283. ),
  284. TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c:%c",
  285. __get_str(name), __entry->maxpacket,
  286. __entry->maxpacket_limit, __entry->max_streams,
  287. __entry->maxburst, __entry->trb_enqueue,
  288. __entry->trb_dequeue,
  289. __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',
  290. __entry->flags & DWC3_EP_STALL ? 'S' : 's',
  291. __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',
  292. __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b',
  293. __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
  294. __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e',
  295. __entry->direction ? '<' : '>'
  296. )
  297. );
  298. DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable,
  299. TP_PROTO(struct dwc3_ep *dep),
  300. TP_ARGS(dep)
  301. );
  302. DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable,
  303. TP_PROTO(struct dwc3_ep *dep),
  304. TP_ARGS(dep)
  305. );
  306. #endif /* __DWC3_TRACE_H */
  307. /* this part has to be here */
  308. #undef TRACE_INCLUDE_PATH
  309. #define TRACE_INCLUDE_PATH .
  310. #undef TRACE_INCLUDE_FILE
  311. #define TRACE_INCLUDE_FILE trace
  312. #include <trace/define_trace.h>