trace.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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", __entry->event)
  65. );
  66. DEFINE_EVENT(dwc3_log_event, dwc3_event,
  67. TP_PROTO(u32 event),
  68. TP_ARGS(event)
  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(__le16, wValue)
  77. __field(__le16, wIndex)
  78. __field(__le16, wLength)
  79. ),
  80. TP_fast_assign(
  81. __entry->bRequestType = ctrl->bRequestType;
  82. __entry->bRequest = ctrl->bRequest;
  83. __entry->wValue = ctrl->wValue;
  84. __entry->wIndex = ctrl->wIndex;
  85. __entry->wLength = ctrl->wLength;
  86. ),
  87. TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
  88. __entry->bRequestType, __entry->bRequest,
  89. le16_to_cpu(__entry->wValue), le16_to_cpu(__entry->wIndex),
  90. le16_to_cpu(__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. __dynamic_array(char, name, DWC3_MSG_MAX)
  102. __field(struct dwc3_request *, req)
  103. __field(unsigned, actual)
  104. __field(unsigned, length)
  105. __field(int, status)
  106. ),
  107. TP_fast_assign(
  108. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
  109. __entry->req = req;
  110. __entry->actual = req->request.actual;
  111. __entry->length = req->request.length;
  112. __entry->status = req->request.status;
  113. ),
  114. TP_printk("%s: req %p length %u/%u ==> %d",
  115. __get_str(name), __entry->req, __entry->actual, __entry->length,
  116. __entry->status
  117. )
  118. );
  119. DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
  120. TP_PROTO(struct dwc3_request *req),
  121. TP_ARGS(req)
  122. );
  123. DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
  124. TP_PROTO(struct dwc3_request *req),
  125. TP_ARGS(req)
  126. );
  127. DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
  128. TP_PROTO(struct dwc3_request *req),
  129. TP_ARGS(req)
  130. );
  131. DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
  132. TP_PROTO(struct dwc3_request *req),
  133. TP_ARGS(req)
  134. );
  135. DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
  136. TP_PROTO(struct dwc3_request *req),
  137. TP_ARGS(req)
  138. );
  139. DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
  140. TP_PROTO(unsigned int cmd, u32 param),
  141. TP_ARGS(cmd, param),
  142. TP_STRUCT__entry(
  143. __field(unsigned int, cmd)
  144. __field(u32, param)
  145. ),
  146. TP_fast_assign(
  147. __entry->cmd = cmd;
  148. __entry->param = param;
  149. ),
  150. TP_printk("cmd '%s' [%d] param %08x",
  151. dwc3_gadget_generic_cmd_string(__entry->cmd),
  152. __entry->cmd, __entry->param
  153. )
  154. );
  155. DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
  156. TP_PROTO(unsigned int cmd, u32 param),
  157. TP_ARGS(cmd, param)
  158. );
  159. DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
  160. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  161. struct dwc3_gadget_ep_cmd_params *params),
  162. TP_ARGS(dep, cmd, params),
  163. TP_STRUCT__entry(
  164. __dynamic_array(char, name, DWC3_MSG_MAX)
  165. __field(unsigned int, cmd)
  166. __field(u32, param0)
  167. __field(u32, param1)
  168. __field(u32, param2)
  169. ),
  170. TP_fast_assign(
  171. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
  172. __entry->cmd = cmd;
  173. __entry->param0 = params->param0;
  174. __entry->param1 = params->param1;
  175. __entry->param2 = params->param2;
  176. ),
  177. TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x",
  178. __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
  179. __entry->cmd, __entry->param0,
  180. __entry->param1, __entry->param2
  181. )
  182. );
  183. DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
  184. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  185. struct dwc3_gadget_ep_cmd_params *params),
  186. TP_ARGS(dep, cmd, params)
  187. );
  188. DECLARE_EVENT_CLASS(dwc3_log_trb,
  189. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  190. TP_ARGS(dep, trb),
  191. TP_STRUCT__entry(
  192. __dynamic_array(char, name, DWC3_MSG_MAX)
  193. __field(struct dwc3_trb *, trb)
  194. __field(u32, bpl)
  195. __field(u32, bph)
  196. __field(u32, size)
  197. __field(u32, ctrl)
  198. ),
  199. TP_fast_assign(
  200. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
  201. __entry->trb = trb;
  202. __entry->bpl = trb->bpl;
  203. __entry->bph = trb->bph;
  204. __entry->size = trb->size;
  205. __entry->ctrl = trb->ctrl;
  206. ),
  207. TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x",
  208. __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
  209. __entry->size, __entry->ctrl
  210. )
  211. );
  212. DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
  213. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  214. TP_ARGS(dep, trb)
  215. );
  216. DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
  217. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  218. TP_ARGS(dep, trb)
  219. );
  220. #endif /* __DWC3_TRACE_H */
  221. /* this part has to be here */
  222. #undef TRACE_INCLUDE_PATH
  223. #define TRACE_INCLUDE_PATH .
  224. #undef TRACE_INCLUDE_FILE
  225. #define TRACE_INCLUDE_FILE trace
  226. #include <trace/define_trace.h>