trace.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. __dynamic_array(char, str, DWC3_MSG_MAX)
  57. ),
  58. TP_fast_assign(
  59. __entry->event = event;
  60. __entry->ep0state = dwc->ep0state;
  61. ),
  62. TP_printk("event (%08x): %s", __entry->event,
  63. dwc3_decode_event(__get_str(str), __entry->event,
  64. __entry->ep0state))
  65. );
  66. DEFINE_EVENT(dwc3_log_event, dwc3_event,
  67. TP_PROTO(u32 event, struct dwc3 *dwc),
  68. TP_ARGS(event, dwc)
  69. );
  70. DECLARE_EVENT_CLASS(dwc3_log_ctrl,
  71. TP_PROTO(struct usb_ctrlrequest *ctrl),
  72. TP_ARGS(ctrl),
  73. TP_STRUCT__entry(
  74. __field(__u8, bRequestType)
  75. __field(__u8, bRequest)
  76. __field(__u16, wValue)
  77. __field(__u16, wIndex)
  78. __field(__u16, wLength)
  79. __dynamic_array(char, str, DWC3_MSG_MAX)
  80. ),
  81. TP_fast_assign(
  82. __entry->bRequestType = ctrl->bRequestType;
  83. __entry->bRequest = ctrl->bRequest;
  84. __entry->wValue = le16_to_cpu(ctrl->wValue);
  85. __entry->wIndex = le16_to_cpu(ctrl->wIndex);
  86. __entry->wLength = le16_to_cpu(ctrl->wLength);
  87. ),
  88. TP_printk("%s", dwc3_decode_ctrl(__get_str(str), __entry->bRequestType,
  89. __entry->bRequest, __entry->wValue,
  90. __entry->wIndex, __entry->wLength)
  91. )
  92. );
  93. DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
  94. TP_PROTO(struct usb_ctrlrequest *ctrl),
  95. TP_ARGS(ctrl)
  96. );
  97. DECLARE_EVENT_CLASS(dwc3_log_request,
  98. TP_PROTO(struct dwc3_request *req),
  99. TP_ARGS(req),
  100. TP_STRUCT__entry(
  101. __string(name, req->dep->name)
  102. __field(struct dwc3_request *, req)
  103. __field(unsigned, actual)
  104. __field(unsigned, length)
  105. __field(int, status)
  106. __field(int, zero)
  107. __field(int, short_not_ok)
  108. __field(int, no_interrupt)
  109. ),
  110. TP_fast_assign(
  111. __assign_str(name, req->dep->name);
  112. __entry->req = req;
  113. __entry->actual = req->request.actual;
  114. __entry->length = req->request.length;
  115. __entry->status = req->request.status;
  116. __entry->zero = req->request.zero;
  117. __entry->short_not_ok = req->request.short_not_ok;
  118. __entry->no_interrupt = req->request.no_interrupt;
  119. ),
  120. TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
  121. __get_str(name), __entry->req, __entry->actual, __entry->length,
  122. __entry->zero ? "Z" : "z",
  123. __entry->short_not_ok ? "S" : "s",
  124. __entry->no_interrupt ? "i" : "I",
  125. __entry->status
  126. )
  127. );
  128. DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
  129. TP_PROTO(struct dwc3_request *req),
  130. TP_ARGS(req)
  131. );
  132. DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
  133. TP_PROTO(struct dwc3_request *req),
  134. TP_ARGS(req)
  135. );
  136. DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
  137. TP_PROTO(struct dwc3_request *req),
  138. TP_ARGS(req)
  139. );
  140. DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
  141. TP_PROTO(struct dwc3_request *req),
  142. TP_ARGS(req)
  143. );
  144. DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
  145. TP_PROTO(struct dwc3_request *req),
  146. TP_ARGS(req)
  147. );
  148. DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
  149. TP_PROTO(unsigned int cmd, u32 param, int status),
  150. TP_ARGS(cmd, param, status),
  151. TP_STRUCT__entry(
  152. __field(unsigned int, cmd)
  153. __field(u32, param)
  154. __field(int, status)
  155. ),
  156. TP_fast_assign(
  157. __entry->cmd = cmd;
  158. __entry->param = param;
  159. __entry->status = status;
  160. ),
  161. TP_printk("cmd '%s' [%x] param %08x --> status: %s",
  162. dwc3_gadget_generic_cmd_string(__entry->cmd),
  163. __entry->cmd, __entry->param,
  164. dwc3_gadget_generic_cmd_status_string(__entry->status)
  165. )
  166. );
  167. DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
  168. TP_PROTO(unsigned int cmd, u32 param, int status),
  169. TP_ARGS(cmd, param, status)
  170. );
  171. DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
  172. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  173. struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
  174. TP_ARGS(dep, cmd, params, cmd_status),
  175. TP_STRUCT__entry(
  176. __string(name, dep->name)
  177. __field(unsigned int, cmd)
  178. __field(u32, param0)
  179. __field(u32, param1)
  180. __field(u32, param2)
  181. __field(int, cmd_status)
  182. ),
  183. TP_fast_assign(
  184. __assign_str(name, dep->name);
  185. __entry->cmd = cmd;
  186. __entry->param0 = params->param0;
  187. __entry->param1 = params->param1;
  188. __entry->param2 = params->param2;
  189. __entry->cmd_status = cmd_status;
  190. ),
  191. TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
  192. __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
  193. __entry->cmd, __entry->param0,
  194. __entry->param1, __entry->param2,
  195. dwc3_ep_cmd_status_string(__entry->cmd_status)
  196. )
  197. );
  198. DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
  199. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  200. struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
  201. TP_ARGS(dep, cmd, params, cmd_status)
  202. );
  203. DECLARE_EVENT_CLASS(dwc3_log_trb,
  204. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  205. TP_ARGS(dep, trb),
  206. TP_STRUCT__entry(
  207. __string(name, dep->name)
  208. __field(struct dwc3_trb *, trb)
  209. __field(u32, allocated)
  210. __field(u32, queued)
  211. __field(u32, bpl)
  212. __field(u32, bph)
  213. __field(u32, size)
  214. __field(u32, ctrl)
  215. __field(u32, type)
  216. ),
  217. TP_fast_assign(
  218. __assign_str(name, dep->name);
  219. __entry->trb = trb;
  220. __entry->allocated = dep->allocated_requests;
  221. __entry->queued = dep->queued_requests;
  222. __entry->bpl = trb->bpl;
  223. __entry->bph = trb->bph;
  224. __entry->size = trb->size;
  225. __entry->ctrl = trb->ctrl;
  226. __entry->type = usb_endpoint_type(dep->endpoint.desc);
  227. ),
  228. TP_printk("%s: %d/%d trb %p buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)",
  229. __get_str(name), __entry->queued, __entry->allocated,
  230. __entry->trb, __entry->bph, __entry->bpl,
  231. ({char *s;
  232. int pcm = ((__entry->size >> 24) & 3) + 1;
  233. switch (__entry->type) {
  234. case USB_ENDPOINT_XFER_INT:
  235. case USB_ENDPOINT_XFER_ISOC:
  236. switch (pcm) {
  237. case 1:
  238. s = "1x ";
  239. break;
  240. case 2:
  241. s = "2x ";
  242. break;
  243. case 3:
  244. s = "3x ";
  245. break;
  246. }
  247. default:
  248. s = "";
  249. } s; }),
  250. DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl,
  251. __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
  252. __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
  253. __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
  254. __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
  255. __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
  256. __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
  257. dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))
  258. )
  259. );
  260. DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
  261. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  262. TP_ARGS(dep, trb)
  263. );
  264. DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
  265. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  266. TP_ARGS(dep, trb)
  267. );
  268. DECLARE_EVENT_CLASS(dwc3_log_ep,
  269. TP_PROTO(struct dwc3_ep *dep),
  270. TP_ARGS(dep),
  271. TP_STRUCT__entry(
  272. __string(name, dep->name)
  273. __field(unsigned, maxpacket)
  274. __field(unsigned, maxpacket_limit)
  275. __field(unsigned, max_streams)
  276. __field(unsigned, maxburst)
  277. __field(unsigned, flags)
  278. __field(unsigned, direction)
  279. __field(u8, trb_enqueue)
  280. __field(u8, trb_dequeue)
  281. ),
  282. TP_fast_assign(
  283. __assign_str(name, dep->name);
  284. __entry->maxpacket = dep->endpoint.maxpacket;
  285. __entry->maxpacket_limit = dep->endpoint.maxpacket_limit;
  286. __entry->max_streams = dep->endpoint.max_streams;
  287. __entry->maxburst = dep->endpoint.maxburst;
  288. __entry->flags = dep->flags;
  289. __entry->direction = dep->direction;
  290. __entry->trb_enqueue = dep->trb_enqueue;
  291. __entry->trb_dequeue = dep->trb_dequeue;
  292. ),
  293. TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c%c:%c:%c",
  294. __get_str(name), __entry->maxpacket,
  295. __entry->maxpacket_limit, __entry->max_streams,
  296. __entry->maxburst, __entry->trb_enqueue,
  297. __entry->trb_dequeue,
  298. __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',
  299. __entry->flags & DWC3_EP_STALL ? 'S' : 's',
  300. __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',
  301. __entry->flags & DWC3_EP_BUSY ? 'B' : 'b',
  302. __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
  303. __entry->flags & DWC3_EP_MISSED_ISOC ? 'M' : 'm',
  304. __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e',
  305. __entry->direction ? '<' : '>'
  306. )
  307. );
  308. DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable,
  309. TP_PROTO(struct dwc3_ep *dep),
  310. TP_ARGS(dep)
  311. );
  312. DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable,
  313. TP_PROTO(struct dwc3_ep *dep),
  314. TP_ARGS(dep)
  315. );
  316. #endif /* __DWC3_TRACE_H */
  317. /* this part has to be here */
  318. #undef TRACE_INCLUDE_PATH
  319. #define TRACE_INCLUDE_PATH .
  320. #undef TRACE_INCLUDE_FILE
  321. #define TRACE_INCLUDE_FILE trace
  322. #include <trace/define_trace.h>