trace_ibhdrs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Copyright(c) 2015, 2016 Intel Corporation.
  3. *
  4. * This file is provided under a dual BSD/GPLv2 license. When using or
  5. * redistributing this file, you may do so under either license.
  6. *
  7. * GPL LICENSE SUMMARY
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * BSD LICENSE
  19. *
  20. * Redistribution and use in source and binary forms, with or without
  21. * modification, are permitted provided that the following conditions
  22. * are met:
  23. *
  24. * - Redistributions of source code must retain the above copyright
  25. * notice, this list of conditions and the following disclaimer.
  26. * - Redistributions in binary form must reproduce the above copyright
  27. * notice, this list of conditions and the following disclaimer in
  28. * the documentation and/or other materials provided with the
  29. * distribution.
  30. * - Neither the name of Intel Corporation nor the names of its
  31. * contributors may be used to endorse or promote products derived
  32. * from this software without specific prior written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  35. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  37. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  38. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  39. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  40. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  41. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  42. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  43. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  44. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. *
  46. */
  47. #if !defined(__HFI1_TRACE_IBHDRS_H) || defined(TRACE_HEADER_MULTI_READ)
  48. #define __HFI1_TRACE_IBHDRS_H
  49. #include <linux/tracepoint.h>
  50. #include <linux/trace_seq.h>
  51. #include "hfi.h"
  52. #undef TRACE_SYSTEM
  53. #define TRACE_SYSTEM hfi1_ibhdrs
  54. #define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode }
  55. #define show_ib_opcode(opcode) \
  56. __print_symbolic(opcode, \
  57. ib_opcode_name(RC_SEND_FIRST), \
  58. ib_opcode_name(RC_SEND_MIDDLE), \
  59. ib_opcode_name(RC_SEND_LAST), \
  60. ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE), \
  61. ib_opcode_name(RC_SEND_ONLY), \
  62. ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE), \
  63. ib_opcode_name(RC_RDMA_WRITE_FIRST), \
  64. ib_opcode_name(RC_RDMA_WRITE_MIDDLE), \
  65. ib_opcode_name(RC_RDMA_WRITE_LAST), \
  66. ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  67. ib_opcode_name(RC_RDMA_WRITE_ONLY), \
  68. ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  69. ib_opcode_name(RC_RDMA_READ_REQUEST), \
  70. ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST), \
  71. ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE), \
  72. ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST), \
  73. ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY), \
  74. ib_opcode_name(RC_ACKNOWLEDGE), \
  75. ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE), \
  76. ib_opcode_name(RC_COMPARE_SWAP), \
  77. ib_opcode_name(RC_FETCH_ADD), \
  78. ib_opcode_name(UC_SEND_FIRST), \
  79. ib_opcode_name(UC_SEND_MIDDLE), \
  80. ib_opcode_name(UC_SEND_LAST), \
  81. ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE), \
  82. ib_opcode_name(UC_SEND_ONLY), \
  83. ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE), \
  84. ib_opcode_name(UC_RDMA_WRITE_FIRST), \
  85. ib_opcode_name(UC_RDMA_WRITE_MIDDLE), \
  86. ib_opcode_name(UC_RDMA_WRITE_LAST), \
  87. ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  88. ib_opcode_name(UC_RDMA_WRITE_ONLY), \
  89. ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  90. ib_opcode_name(UD_SEND_ONLY), \
  91. ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE), \
  92. ib_opcode_name(CNP))
  93. const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
  94. u8 hfi1_trace_ib_hdr_len(struct ib_header *hdr);
  95. const char *hfi1_trace_get_packet_str(struct hfi1_packet *packet);
  96. void hfi1_trace_parse_bth(struct ib_other_headers *ohdr,
  97. u8 *ack, u8 *becn, u8 *fecn, u8 *mig,
  98. u8 *se, u8 *pad, u8 *opcode, u8 *tver,
  99. u16 *pkey, u32 *psn, u32 *qpn);
  100. void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5,
  101. struct ib_other_headers **ohdr,
  102. u8 *lnh, u8 *lver, u8 *sl, u8 *sc,
  103. u16 *len, u32 *dlid, u32 *slid);
  104. #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
  105. #define lrh_name(lrh) { HFI1_##lrh, #lrh }
  106. #define show_lnh(lrh) \
  107. __print_symbolic(lrh, \
  108. lrh_name(LRH_BTH), \
  109. lrh_name(LRH_GRH))
  110. #define LRH_PRN "len:%d sc:%d dlid:0x%.4x slid:0x%.4x"
  111. #define LRH_9B_PRN "lnh:%d,%s lver:%d sl:%d "
  112. #define BTH_PRN \
  113. "op:0x%.2x,%s se:%d m:%d pad:%d tver:%d pkey:0x%.4x " \
  114. "f:%d b:%d qpn:0x%.6x a:%d psn:0x%.8x"
  115. #define EHDR_PRN "hlen:%d %s"
  116. DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template,
  117. TP_PROTO(struct hfi1_devdata *dd,
  118. struct hfi1_packet *packet,
  119. bool sc5),
  120. TP_ARGS(dd, packet, sc5),
  121. TP_STRUCT__entry(
  122. DD_DEV_ENTRY(dd)
  123. __field(u8, lnh)
  124. __field(u8, lver)
  125. __field(u8, sl)
  126. __field(u16, len)
  127. __field(u32, dlid)
  128. __field(u8, sc)
  129. __field(u32, slid)
  130. __field(u8, opcode)
  131. __field(u8, se)
  132. __field(u8, mig)
  133. __field(u8, pad)
  134. __field(u8, tver)
  135. __field(u16, pkey)
  136. __field(u8, fecn)
  137. __field(u8, becn)
  138. __field(u32, qpn)
  139. __field(u8, ack)
  140. __field(u32, psn)
  141. /* extended headers */
  142. __dynamic_array(u8, ehdrs,
  143. hfi1_trace_ib_hdr_len(packet->hdr))
  144. ),
  145. TP_fast_assign(
  146. struct ib_other_headers *ohdr;
  147. DD_DEV_ASSIGN(dd);
  148. hfi1_trace_parse_9b_hdr(packet->hdr, sc5,
  149. &ohdr,
  150. &__entry->lnh,
  151. &__entry->lver,
  152. &__entry->sl,
  153. &__entry->sc,
  154. &__entry->len,
  155. &__entry->dlid,
  156. &__entry->slid);
  157. hfi1_trace_parse_bth(ohdr, &__entry->ack,
  158. &__entry->becn, &__entry->fecn,
  159. &__entry->mig, &__entry->se,
  160. &__entry->pad, &__entry->opcode,
  161. &__entry->tver, &__entry->pkey,
  162. &__entry->psn, &__entry->qpn);
  163. /* extended headers */
  164. memcpy(__get_dynamic_array(ehdrs), &ohdr->u,
  165. __get_dynamic_array_len(ehdrs));
  166. ),
  167. TP_printk("[%s] (IB) " LRH_PRN " " LRH_9B_PRN " "
  168. BTH_PRN " " EHDR_PRN,
  169. __get_str(dev),
  170. __entry->len,
  171. __entry->sc,
  172. __entry->dlid,
  173. __entry->slid,
  174. __entry->lnh, show_lnh(__entry->lnh),
  175. __entry->lver,
  176. __entry->sl,
  177. /* BTH */
  178. __entry->opcode, show_ib_opcode(__entry->opcode),
  179. __entry->se,
  180. __entry->mig,
  181. __entry->pad,
  182. __entry->tver,
  183. __entry->pkey,
  184. __entry->fecn,
  185. __entry->becn,
  186. __entry->qpn,
  187. __entry->ack,
  188. __entry->psn,
  189. /* extended headers */
  190. __get_dynamic_array_len(ehdrs),
  191. __parse_ib_ehdrs(
  192. __entry->opcode,
  193. (void *)__get_dynamic_array(ehdrs))
  194. )
  195. );
  196. DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
  197. TP_PROTO(struct hfi1_devdata *dd,
  198. struct hfi1_packet *packet, bool sc5),
  199. TP_ARGS(dd, packet, sc5));
  200. DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
  201. TP_PROTO(struct hfi1_devdata *dd,
  202. struct ib_header *hdr,
  203. bool sc5),
  204. TP_ARGS(dd, hdr, sc5),
  205. TP_STRUCT__entry(
  206. DD_DEV_ENTRY(dd)
  207. __field(u8, lnh)
  208. __field(u8, lver)
  209. __field(u8, sl)
  210. __field(u16, len)
  211. __field(u32, dlid)
  212. __field(u8, sc)
  213. __field(u32, slid)
  214. __field(u8, opcode)
  215. __field(u8, se)
  216. __field(u8, mig)
  217. __field(u8, pad)
  218. __field(u8, tver)
  219. __field(u16, pkey)
  220. __field(u8, fecn)
  221. __field(u8, becn)
  222. __field(u32, qpn)
  223. __field(u8, ack)
  224. __field(u32, psn)
  225. /* extended headers */
  226. __dynamic_array(u8, ehdrs,
  227. hfi1_trace_ib_hdr_len(hdr))
  228. ),
  229. TP_fast_assign(
  230. struct ib_other_headers *ohdr;
  231. DD_DEV_ASSIGN(dd);
  232. hfi1_trace_parse_9b_hdr(hdr, sc5,
  233. &ohdr, &__entry->lnh,
  234. &__entry->lver, &__entry->sl,
  235. &__entry->sc, &__entry->len,
  236. &__entry->dlid, &__entry->slid);
  237. hfi1_trace_parse_bth(ohdr, &__entry->ack,
  238. &__entry->becn, &__entry->fecn,
  239. &__entry->mig, &__entry->se,
  240. &__entry->pad, &__entry->opcode,
  241. &__entry->tver, &__entry->pkey,
  242. &__entry->psn, &__entry->qpn);
  243. /* extended headers */
  244. memcpy(__get_dynamic_array(ehdrs),
  245. &ohdr->u, __get_dynamic_array_len(ehdrs));
  246. ),
  247. TP_printk("[%s] (IB) " LRH_PRN " " LRH_9B_PRN " "
  248. BTH_PRN " " EHDR_PRN,
  249. __get_str(dev),
  250. __entry->len,
  251. __entry->sc,
  252. __entry->dlid,
  253. __entry->slid,
  254. __entry->lnh, show_lnh(__entry->lnh),
  255. __entry->lver,
  256. __entry->sl,
  257. /* BTH */
  258. __entry->opcode, show_ib_opcode(__entry->opcode),
  259. __entry->se,
  260. __entry->mig,
  261. __entry->pad,
  262. __entry->tver,
  263. __entry->pkey,
  264. __entry->fecn,
  265. __entry->becn,
  266. __entry->qpn,
  267. __entry->ack,
  268. __entry->psn,
  269. /* extended headers */
  270. __get_dynamic_array_len(ehdrs),
  271. __parse_ib_ehdrs(
  272. __entry->opcode,
  273. (void *)__get_dynamic_array(ehdrs))
  274. )
  275. );
  276. DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
  277. TP_PROTO(struct hfi1_devdata *dd,
  278. struct ib_header *hdr, bool sc5),
  279. TP_ARGS(dd, hdr, sc5));
  280. DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
  281. TP_PROTO(struct hfi1_devdata *dd,
  282. struct ib_header *hdr, bool sc5),
  283. TP_ARGS(dd, hdr, sc5));
  284. DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
  285. TP_PROTO(struct hfi1_devdata *dd,
  286. struct ib_header *hdr, bool sc5),
  287. TP_ARGS(dd, hdr, sc5));
  288. #endif /* __HFI1_TRACE_IBHDRS_H */
  289. #undef TRACE_INCLUDE_PATH
  290. #undef TRACE_INCLUDE_FILE
  291. #define TRACE_INCLUDE_PATH .
  292. #define TRACE_INCLUDE_FILE trace_ibhdrs
  293. #include <trace/define_trace.h>