trace.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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_msg,
  27. TP_PROTO(struct va_format *vaf),
  28. TP_ARGS(vaf),
  29. TP_STRUCT__entry(__dynamic_array(char, msg, DWC3_MSG_MAX)),
  30. TP_fast_assign(
  31. vsnprintf(__get_str(msg), DWC3_MSG_MAX, vaf->fmt, *vaf->va);
  32. ),
  33. TP_printk("%s", __get_str(msg))
  34. );
  35. DEFINE_EVENT(dwc3_log_msg, dwc3_readl,
  36. TP_PROTO(struct va_format *vaf),
  37. TP_ARGS(vaf)
  38. );
  39. DEFINE_EVENT(dwc3_log_msg, dwc3_writel,
  40. TP_PROTO(struct va_format *vaf),
  41. TP_ARGS(vaf)
  42. );
  43. DEFINE_EVENT(dwc3_log_msg, dwc3_gadget,
  44. TP_PROTO(struct va_format *vaf),
  45. TP_ARGS(vaf)
  46. );
  47. DEFINE_EVENT(dwc3_log_msg, dwc3_core,
  48. TP_PROTO(struct va_format *vaf),
  49. TP_ARGS(vaf)
  50. );
  51. DEFINE_EVENT(dwc3_log_msg, dwc3_ep0,
  52. TP_PROTO(struct va_format *vaf),
  53. TP_ARGS(vaf)
  54. );
  55. DECLARE_EVENT_CLASS(dwc3_log_event,
  56. TP_PROTO(u32 event),
  57. TP_ARGS(event),
  58. TP_STRUCT__entry(
  59. __field(u32, event)
  60. ),
  61. TP_fast_assign(
  62. __entry->event = event;
  63. ),
  64. TP_printk("event (%08x): %s", __entry->event,
  65. dwc3_decode_event(__entry->event))
  66. );
  67. DEFINE_EVENT(dwc3_log_event, dwc3_event,
  68. TP_PROTO(u32 event),
  69. TP_ARGS(event)
  70. );
  71. DECLARE_EVENT_CLASS(dwc3_log_ctrl,
  72. TP_PROTO(struct usb_ctrlrequest *ctrl),
  73. TP_ARGS(ctrl),
  74. TP_STRUCT__entry(
  75. __field(__u8, bRequestType)
  76. __field(__u8, bRequest)
  77. __field(__u16, wValue)
  78. __field(__u16, wIndex)
  79. __field(__u16, wLength)
  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("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
  89. __entry->bRequestType, __entry->bRequest,
  90. __entry->wValue, __entry->wIndex,
  91. __entry->wLength
  92. )
  93. );
  94. DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
  95. TP_PROTO(struct usb_ctrlrequest *ctrl),
  96. TP_ARGS(ctrl)
  97. );
  98. DECLARE_EVENT_CLASS(dwc3_log_request,
  99. TP_PROTO(struct dwc3_request *req),
  100. TP_ARGS(req),
  101. TP_STRUCT__entry(
  102. __dynamic_array(char, name, DWC3_MSG_MAX)
  103. __field(struct dwc3_request *, req)
  104. __field(unsigned, actual)
  105. __field(unsigned, length)
  106. __field(int, status)
  107. __field(int, zero)
  108. __field(int, short_not_ok)
  109. __field(int, no_interrupt)
  110. ),
  111. TP_fast_assign(
  112. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
  113. __entry->req = req;
  114. __entry->actual = req->request.actual;
  115. __entry->length = req->request.length;
  116. __entry->status = req->request.status;
  117. __entry->zero = req->request.zero;
  118. __entry->short_not_ok = req->request.short_not_ok;
  119. __entry->no_interrupt = req->request.no_interrupt;
  120. ),
  121. TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
  122. __get_str(name), __entry->req, __entry->actual, __entry->length,
  123. __entry->zero ? "Z" : "z",
  124. __entry->short_not_ok ? "S" : "s",
  125. __entry->no_interrupt ? "i" : "I",
  126. __entry->status
  127. )
  128. );
  129. DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
  130. TP_PROTO(struct dwc3_request *req),
  131. TP_ARGS(req)
  132. );
  133. DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
  134. TP_PROTO(struct dwc3_request *req),
  135. TP_ARGS(req)
  136. );
  137. DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
  138. TP_PROTO(struct dwc3_request *req),
  139. TP_ARGS(req)
  140. );
  141. DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
  142. TP_PROTO(struct dwc3_request *req),
  143. TP_ARGS(req)
  144. );
  145. DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
  146. TP_PROTO(struct dwc3_request *req),
  147. TP_ARGS(req)
  148. );
  149. DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
  150. TP_PROTO(unsigned int cmd, u32 param, int status),
  151. TP_ARGS(cmd, param, status),
  152. TP_STRUCT__entry(
  153. __field(unsigned int, cmd)
  154. __field(u32, param)
  155. __field(int, status)
  156. ),
  157. TP_fast_assign(
  158. __entry->cmd = cmd;
  159. __entry->param = param;
  160. __entry->status = status;
  161. ),
  162. TP_printk("cmd '%s' [%d] param %08x --> status: %s",
  163. dwc3_gadget_generic_cmd_string(__entry->cmd),
  164. __entry->cmd, __entry->param,
  165. dwc3_gadget_generic_cmd_status_string(__entry->status)
  166. )
  167. );
  168. DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
  169. TP_PROTO(unsigned int cmd, u32 param, int status),
  170. TP_ARGS(cmd, param, status)
  171. );
  172. DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
  173. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  174. struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
  175. TP_ARGS(dep, cmd, params, cmd_status),
  176. TP_STRUCT__entry(
  177. __dynamic_array(char, name, DWC3_MSG_MAX)
  178. __field(unsigned int, cmd)
  179. __field(u32, param0)
  180. __field(u32, param1)
  181. __field(u32, param2)
  182. __field(int, cmd_status)
  183. ),
  184. TP_fast_assign(
  185. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
  186. __entry->cmd = cmd;
  187. __entry->param0 = params->param0;
  188. __entry->param1 = params->param1;
  189. __entry->param2 = params->param2;
  190. __entry->cmd_status = cmd_status;
  191. ),
  192. TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
  193. __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
  194. __entry->cmd, __entry->param0,
  195. __entry->param1, __entry->param2,
  196. dwc3_ep_cmd_status_string(__entry->cmd_status)
  197. )
  198. );
  199. DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
  200. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  201. struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
  202. TP_ARGS(dep, cmd, params, cmd_status)
  203. );
  204. DECLARE_EVENT_CLASS(dwc3_log_trb,
  205. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  206. TP_ARGS(dep, trb),
  207. TP_STRUCT__entry(
  208. __dynamic_array(char, name, DWC3_MSG_MAX)
  209. __field(struct dwc3_trb *, trb)
  210. __field(u32, allocated)
  211. __field(u32, queued)
  212. __field(u32, bpl)
  213. __field(u32, bph)
  214. __field(u32, size)
  215. __field(u32, ctrl)
  216. ),
  217. TP_fast_assign(
  218. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", 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. ),
  227. TP_printk("%s: %d/%d trb %p buf %08x%08x size %d ctrl %08x (%c%c%c%c:%c%c:%s)",
  228. __get_str(name), __entry->queued, __entry->allocated,
  229. __entry->trb, __entry->bph, __entry->bpl,
  230. __entry->size, __entry->ctrl,
  231. __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
  232. __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
  233. __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
  234. __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
  235. __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
  236. __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
  237. ({char *s;
  238. switch (__entry->ctrl & 0x3f0) {
  239. case DWC3_TRBCTL_NORMAL:
  240. s = "normal";
  241. break;
  242. case DWC3_TRBCTL_CONTROL_SETUP:
  243. s = "setup";
  244. break;
  245. case DWC3_TRBCTL_CONTROL_STATUS2:
  246. s = "status2";
  247. break;
  248. case DWC3_TRBCTL_CONTROL_STATUS3:
  249. s = "status3";
  250. break;
  251. case DWC3_TRBCTL_CONTROL_DATA:
  252. s = "data";
  253. break;
  254. case DWC3_TRBCTL_ISOCHRONOUS_FIRST:
  255. s = "isoc-first";
  256. break;
  257. case DWC3_TRBCTL_ISOCHRONOUS:
  258. s = "isoc";
  259. break;
  260. case DWC3_TRBCTL_LINK_TRB:
  261. s = "link";
  262. break;
  263. default:
  264. s = "UNKNOWN";
  265. break;
  266. } s; })
  267. )
  268. );
  269. DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
  270. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  271. TP_ARGS(dep, trb)
  272. );
  273. DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
  274. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  275. TP_ARGS(dep, trb)
  276. );
  277. #endif /* __DWC3_TRACE_H */
  278. /* this part has to be here */
  279. #undef TRACE_INCLUDE_PATH
  280. #define TRACE_INCLUDE_PATH .
  281. #undef TRACE_INCLUDE_FILE
  282. #define TRACE_INCLUDE_FILE trace
  283. #include <trace/define_trace.h>