trace_ibhdrs.h 14 KB

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