trace.h 9.6 KB

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