trace.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. __field(int, zero)
  107. __field(int, short_not_ok)
  108. __field(int, no_interrupt)
  109. ),
  110. TP_fast_assign(
  111. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", 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),
  150. TP_ARGS(cmd, param),
  151. TP_STRUCT__entry(
  152. __field(unsigned int, cmd)
  153. __field(u32, param)
  154. ),
  155. TP_fast_assign(
  156. __entry->cmd = cmd;
  157. __entry->param = param;
  158. ),
  159. TP_printk("cmd '%s' [%d] param %08x",
  160. dwc3_gadget_generic_cmd_string(__entry->cmd),
  161. __entry->cmd, __entry->param
  162. )
  163. );
  164. DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
  165. TP_PROTO(unsigned int cmd, u32 param),
  166. TP_ARGS(cmd, param)
  167. );
  168. DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
  169. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  170. struct dwc3_gadget_ep_cmd_params *params),
  171. TP_ARGS(dep, cmd, params),
  172. TP_STRUCT__entry(
  173. __dynamic_array(char, name, DWC3_MSG_MAX)
  174. __field(unsigned int, cmd)
  175. __field(u32, param0)
  176. __field(u32, param1)
  177. __field(u32, param2)
  178. ),
  179. TP_fast_assign(
  180. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
  181. __entry->cmd = cmd;
  182. __entry->param0 = params->param0;
  183. __entry->param1 = params->param1;
  184. __entry->param2 = params->param2;
  185. ),
  186. TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x",
  187. __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
  188. __entry->cmd, __entry->param0,
  189. __entry->param1, __entry->param2
  190. )
  191. );
  192. DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
  193. TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
  194. struct dwc3_gadget_ep_cmd_params *params),
  195. TP_ARGS(dep, cmd, params)
  196. );
  197. DECLARE_EVENT_CLASS(dwc3_log_trb,
  198. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  199. TP_ARGS(dep, trb),
  200. TP_STRUCT__entry(
  201. __dynamic_array(char, name, DWC3_MSG_MAX)
  202. __field(struct dwc3_trb *, trb)
  203. __field(u32, bpl)
  204. __field(u32, bph)
  205. __field(u32, size)
  206. __field(u32, ctrl)
  207. ),
  208. TP_fast_assign(
  209. snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
  210. __entry->trb = trb;
  211. __entry->bpl = trb->bpl;
  212. __entry->bph = trb->bph;
  213. __entry->size = trb->size;
  214. __entry->ctrl = trb->ctrl;
  215. ),
  216. TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x",
  217. __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
  218. __entry->size, __entry->ctrl
  219. )
  220. );
  221. DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
  222. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  223. TP_ARGS(dep, trb)
  224. );
  225. DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
  226. TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
  227. TP_ARGS(dep, trb)
  228. );
  229. #endif /* __DWC3_TRACE_H */
  230. /* this part has to be here */
  231. #undef TRACE_INCLUDE_PATH
  232. #define TRACE_INCLUDE_PATH .
  233. #undef TRACE_INCLUDE_FILE
  234. #define TRACE_INCLUDE_FILE trace
  235. #include <trace/define_trace.h>