trace_ibhdrs.h 15 KB

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