trace_ibhdrs.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. u8 ibhdr_exhdr_len(struct ib_header *hdr);
  94. const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
  95. u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opah);
  96. u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet);
  97. const char *hfi1_trace_get_packet_type_str(u8 l4);
  98. const char *hfi1_trace_get_packet_str(struct hfi1_packet *packet);
  99. void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr,
  100. u8 *ack, u8 *becn, u8 *fecn, u8 *mig,
  101. u8 *se, u8 *pad, u8 *opcode, u8 *tver,
  102. u16 *pkey, u32 *psn, u32 *qpn);
  103. void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5,
  104. u8 *lnh, u8 *lver, u8 *sl, u8 *sc,
  105. u16 *len, u32 *dlid, u32 *slid);
  106. void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr,
  107. u8 *ack, u8 *mig, u8 *opcode,
  108. u8 *pad, u8 *se, u8 *tver,
  109. u32 *psn, u32 *qpn);
  110. void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr,
  111. u8 *age, u8 *becn, u8 *fecn,
  112. u8 *l4, u8 *rc, u8 *sc,
  113. u16 *entropy, u16 *len, u16 *pkey,
  114. u32 *dlid, u32 *slid);
  115. const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass,
  116. u8 age, u8 becn, u8 fecn, u8 l4,
  117. u8 lnh, const char *lnh_name, u8 lver,
  118. u8 rc, u8 sc, u8 sl, u16 entropy,
  119. u16 len, u16 pkey, u32 dlid, u32 slid);
  120. const char *hfi1_trace_fmt_bth(struct trace_seq *p, bool bypass,
  121. u8 ack, u8 becn, u8 fecn, u8 mig,
  122. u8 se, u8 pad, u8 opcode, const char *opname,
  123. u8 tver, u16 pkey, u32 psn, u32 qpn);
  124. #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
  125. #define lrh_name(lrh) { HFI1_##lrh, #lrh }
  126. #define show_lnh(lrh) \
  127. __print_symbolic(lrh, \
  128. lrh_name(LRH_BTH), \
  129. lrh_name(LRH_GRH))
  130. #define PKT_ENTRY(pkt) __string(ptype, hfi1_trace_get_packet_str(packet))
  131. #define PKT_ASSIGN(pkt) __assign_str(ptype, hfi1_trace_get_packet_str(packet))
  132. DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template,
  133. TP_PROTO(struct hfi1_devdata *dd,
  134. struct hfi1_packet *packet,
  135. bool sc5),
  136. TP_ARGS(dd, packet, sc5),
  137. TP_STRUCT__entry(
  138. DD_DEV_ENTRY(dd)
  139. PKT_ENTRY(packet)
  140. __field(bool, bypass)
  141. __field(u8, ack)
  142. __field(u8, age)
  143. __field(u8, becn)
  144. __field(u8, fecn)
  145. __field(u8, l4)
  146. __field(u8, lnh)
  147. __field(u8, lver)
  148. __field(u8, mig)
  149. __field(u8, opcode)
  150. __field(u8, pad)
  151. __field(u8, rc)
  152. __field(u8, sc)
  153. __field(u8, se)
  154. __field(u8, sl)
  155. __field(u8, tver)
  156. __field(u16, entropy)
  157. __field(u16, len)
  158. __field(u16, pkey)
  159. __field(u32, dlid)
  160. __field(u32, psn)
  161. __field(u32, qpn)
  162. __field(u32, slid)
  163. /* extended headers */
  164. __dynamic_array(u8, ehdrs,
  165. hfi1_trace_packet_hdr_len(packet))
  166. ),
  167. TP_fast_assign(
  168. DD_DEV_ASSIGN(dd);
  169. PKT_ASSIGN(packet);
  170. if (packet->etype == RHF_RCV_TYPE_BYPASS) {
  171. __entry->bypass = true;
  172. hfi1_trace_parse_16b_hdr(packet->hdr,
  173. &__entry->age,
  174. &__entry->becn,
  175. &__entry->fecn,
  176. &__entry->l4,
  177. &__entry->rc,
  178. &__entry->sc,
  179. &__entry->entropy,
  180. &__entry->len,
  181. &__entry->pkey,
  182. &__entry->dlid,
  183. &__entry->slid);
  184. hfi1_trace_parse_16b_bth(packet->ohdr,
  185. &__entry->ack,
  186. &__entry->mig,
  187. &__entry->opcode,
  188. &__entry->pad,
  189. &__entry->se,
  190. &__entry->tver,
  191. &__entry->psn,
  192. &__entry->qpn);
  193. } else {
  194. __entry->bypass = false;
  195. hfi1_trace_parse_9b_hdr(packet->hdr, sc5,
  196. &__entry->lnh,
  197. &__entry->lver,
  198. &__entry->sl,
  199. &__entry->sc,
  200. &__entry->len,
  201. &__entry->dlid,
  202. &__entry->slid);
  203. hfi1_trace_parse_9b_bth(packet->ohdr,
  204. &__entry->ack,
  205. &__entry->becn,
  206. &__entry->fecn,
  207. &__entry->mig,
  208. &__entry->se,
  209. &__entry->pad,
  210. &__entry->opcode,
  211. &__entry->tver,
  212. &__entry->pkey,
  213. &__entry->psn,
  214. &__entry->qpn);
  215. }
  216. /* extended headers */
  217. memcpy(__get_dynamic_array(ehdrs),
  218. &packet->ohdr->u,
  219. __get_dynamic_array_len(ehdrs));
  220. ),
  221. TP_printk("[%s] (%s) %s %s hlen:%d %s",
  222. __get_str(dev),
  223. __get_str(ptype),
  224. hfi1_trace_fmt_lrh(p,
  225. __entry->bypass,
  226. __entry->age,
  227. __entry->becn,
  228. __entry->fecn,
  229. __entry->l4,
  230. __entry->lnh,
  231. show_lnh(__entry->lnh),
  232. __entry->lver,
  233. __entry->rc,
  234. __entry->sc,
  235. __entry->sl,
  236. __entry->entropy,
  237. __entry->len,
  238. __entry->pkey,
  239. __entry->dlid,
  240. __entry->slid),
  241. hfi1_trace_fmt_bth(p,
  242. __entry->bypass,
  243. __entry->ack,
  244. __entry->becn,
  245. __entry->fecn,
  246. __entry->mig,
  247. __entry->se,
  248. __entry->pad,
  249. __entry->opcode,
  250. show_ib_opcode(__entry->opcode),
  251. __entry->tver,
  252. __entry->pkey,
  253. __entry->psn,
  254. __entry->qpn),
  255. /* extended headers */
  256. __get_dynamic_array_len(ehdrs),
  257. __parse_ib_ehdrs(
  258. __entry->opcode,
  259. (void *)__get_dynamic_array(ehdrs))
  260. )
  261. );
  262. DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
  263. TP_PROTO(struct hfi1_devdata *dd,
  264. struct hfi1_packet *packet, bool sc5),
  265. TP_ARGS(dd, packet, sc5));
  266. DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
  267. TP_PROTO(struct hfi1_devdata *dd,
  268. struct hfi1_opa_header *opah, bool sc5),
  269. TP_ARGS(dd, opah, sc5),
  270. TP_STRUCT__entry(
  271. DD_DEV_ENTRY(dd)
  272. __field(bool, bypass)
  273. __field(u8, ack)
  274. __field(u8, age)
  275. __field(u8, becn)
  276. __field(u8, fecn)
  277. __field(u8, l4)
  278. __field(u8, lnh)
  279. __field(u8, lver)
  280. __field(u8, mig)
  281. __field(u8, opcode)
  282. __field(u8, pad)
  283. __field(u8, rc)
  284. __field(u8, sc)
  285. __field(u8, se)
  286. __field(u8, sl)
  287. __field(u8, tver)
  288. __field(u16, entropy)
  289. __field(u16, len)
  290. __field(u16, pkey)
  291. __field(u32, dlid)
  292. __field(u32, psn)
  293. __field(u32, qpn)
  294. __field(u32, slid)
  295. /* extended headers */
  296. __dynamic_array(u8, ehdrs,
  297. hfi1_trace_opa_hdr_len(opah))
  298. ),
  299. TP_fast_assign(
  300. struct ib_other_headers *ohdr;
  301. DD_DEV_ASSIGN(dd);
  302. if (opah->hdr_type) {
  303. __entry->bypass = true;
  304. hfi1_trace_parse_16b_hdr(&opah->opah,
  305. &__entry->age,
  306. &__entry->becn,
  307. &__entry->fecn,
  308. &__entry->l4,
  309. &__entry->rc,
  310. &__entry->sc,
  311. &__entry->entropy,
  312. &__entry->len,
  313. &__entry->pkey,
  314. &__entry->dlid,
  315. &__entry->slid);
  316. if (entry->l4 == OPA_16B_L4_IB_LOCAL)
  317. ohdr = &opah->opah.u.oth;
  318. else
  319. ohdr = &opah->opah.u.l.oth;
  320. hfi1_trace_parse_16b_bth(ohdr,
  321. &__entry->ack,
  322. &__entry->mig,
  323. &__entry->opcode,
  324. &__entry->pad,
  325. &__entry->se,
  326. &__entry->tver,
  327. &__entry->psn,
  328. &__entry->qpn);
  329. } else {
  330. __entry->bypass = false;
  331. hfi1_trace_parse_9b_hdr(&opah->ibh, sc5,
  332. &__entry->lnh,
  333. &__entry->lver,
  334. &__entry->sl,
  335. &__entry->sc,
  336. &__entry->len,
  337. &__entry->dlid,
  338. &__entry->slid);
  339. if (entry->lnh == HFI1_LRH_BTH)
  340. ohdr = &opah->ibh.u.oth;
  341. else
  342. ohdr = &opah->ibh.u.l.oth;
  343. hfi1_trace_parse_9b_bth(ohdr,
  344. &__entry->ack,
  345. &__entry->becn,
  346. &__entry->fecn,
  347. &__entry->mig,
  348. &__entry->se,
  349. &__entry->pad,
  350. &__entry->opcode,
  351. &__entry->tver,
  352. &__entry->pkey,
  353. &__entry->psn,
  354. &__entry->qpn);
  355. }
  356. /* extended headers */
  357. memcpy(__get_dynamic_array(ehdrs),
  358. &ohdr->u, __get_dynamic_array_len(ehdrs));
  359. ),
  360. TP_printk("[%s] (%s) %s %s hlen:%d %s",
  361. __get_str(dev),
  362. hfi1_trace_get_packet_type_str(__entry->l4),
  363. hfi1_trace_fmt_lrh(p,
  364. __entry->bypass,
  365. __entry->age,
  366. __entry->becn,
  367. __entry->fecn,
  368. __entry->l4,
  369. __entry->lnh,
  370. show_lnh(__entry->lnh),
  371. __entry->lver,
  372. __entry->rc,
  373. __entry->sc,
  374. __entry->sl,
  375. __entry->entropy,
  376. __entry->len,
  377. __entry->pkey,
  378. __entry->dlid,
  379. __entry->slid),
  380. hfi1_trace_fmt_bth(p,
  381. __entry->bypass,
  382. __entry->ack,
  383. __entry->becn,
  384. __entry->fecn,
  385. __entry->mig,
  386. __entry->se,
  387. __entry->pad,
  388. __entry->opcode,
  389. show_ib_opcode(__entry->opcode),
  390. __entry->tver,
  391. __entry->pkey,
  392. __entry->psn,
  393. __entry->qpn),
  394. /* extended headers */
  395. __get_dynamic_array_len(ehdrs),
  396. __parse_ib_ehdrs(
  397. __entry->opcode,
  398. (void *)__get_dynamic_array(ehdrs))
  399. )
  400. );
  401. DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
  402. TP_PROTO(struct hfi1_devdata *dd,
  403. struct hfi1_opa_header *opah, bool sc5),
  404. TP_ARGS(dd, opah, sc5));
  405. DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
  406. TP_PROTO(struct hfi1_devdata *dd,
  407. struct hfi1_opa_header *opah, bool sc5),
  408. TP_ARGS(dd, opah, sc5));
  409. DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
  410. TP_PROTO(struct hfi1_devdata *dd,
  411. struct hfi1_opa_header *opah, bool sc5),
  412. TP_ARGS(dd, opah, sc5));
  413. #endif /* __HFI1_TRACE_IBHDRS_H */
  414. #undef TRACE_INCLUDE_PATH
  415. #undef TRACE_INCLUDE_FILE
  416. #define TRACE_INCLUDE_PATH .
  417. #define TRACE_INCLUDE_FILE trace_ibhdrs
  418. #include <trace/define_trace.h>