trace_ibhdrs.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. u8 ibhdr_exhdr_len(struct ib_header *hdr);
  55. const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
  56. #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
  57. #define lrh_name(lrh) { HFI1_##lrh, #lrh }
  58. #define show_lnh(lrh) \
  59. __print_symbolic(lrh, \
  60. lrh_name(LRH_BTH), \
  61. lrh_name(LRH_GRH))
  62. #define LRH_PRN "vl %d lver %d sl %d lnh %d,%s dlid %.4x len %d slid %.4x"
  63. #define BTH_PRN \
  64. "op 0x%.2x,%s se %d m %d pad %d tver %d pkey 0x%.4x " \
  65. "f %d b %d qpn 0x%.6x a %d psn 0x%.8x"
  66. #define EHDR_PRN "%s"
  67. DECLARE_EVENT_CLASS(hfi1_ibhdr_template,
  68. TP_PROTO(struct hfi1_devdata *dd,
  69. struct ib_header *hdr),
  70. TP_ARGS(dd, hdr),
  71. TP_STRUCT__entry(
  72. DD_DEV_ENTRY(dd)
  73. /* LRH */
  74. __field(u8, vl)
  75. __field(u8, lver)
  76. __field(u8, sl)
  77. __field(u8, lnh)
  78. __field(u16, dlid)
  79. __field(u16, len)
  80. __field(u16, slid)
  81. /* BTH */
  82. __field(u8, opcode)
  83. __field(u8, se)
  84. __field(u8, m)
  85. __field(u8, pad)
  86. __field(u8, tver)
  87. __field(u16, pkey)
  88. __field(u8, f)
  89. __field(u8, b)
  90. __field(u32, qpn)
  91. __field(u8, a)
  92. __field(u32, psn)
  93. /* extended headers */
  94. __dynamic_array(u8, ehdrs, ibhdr_exhdr_len(hdr))
  95. ),
  96. TP_fast_assign(
  97. struct ib_other_headers *ohdr;
  98. DD_DEV_ASSIGN(dd);
  99. /* LRH */
  100. __entry->vl =
  101. (u8)(be16_to_cpu(hdr->lrh[0]) >> 12);
  102. __entry->lver =
  103. (u8)(be16_to_cpu(hdr->lrh[0]) >> 8) & 0xf;
  104. __entry->sl =
  105. (u8)(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xf;
  106. __entry->lnh =
  107. (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
  108. __entry->dlid =
  109. be16_to_cpu(hdr->lrh[1]);
  110. /* allow for larger len */
  111. __entry->len =
  112. be16_to_cpu(hdr->lrh[2]);
  113. __entry->slid =
  114. be16_to_cpu(hdr->lrh[3]);
  115. /* BTH */
  116. if (__entry->lnh == HFI1_LRH_BTH)
  117. ohdr = &hdr->u.oth;
  118. else
  119. ohdr = &hdr->u.l.oth;
  120. __entry->opcode =
  121. (be32_to_cpu(ohdr->bth[0]) >> 24) & 0xff;
  122. __entry->se =
  123. (be32_to_cpu(ohdr->bth[0]) >> 23) & 1;
  124. __entry->m =
  125. (be32_to_cpu(ohdr->bth[0]) >> 22) & 1;
  126. __entry->pad =
  127. (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
  128. __entry->tver =
  129. (be32_to_cpu(ohdr->bth[0]) >> 16) & 0xf;
  130. __entry->pkey =
  131. be32_to_cpu(ohdr->bth[0]) & 0xffff;
  132. __entry->f =
  133. (be32_to_cpu(ohdr->bth[1]) >> HFI1_FECN_SHIFT) &
  134. HFI1_FECN_MASK;
  135. __entry->b =
  136. (be32_to_cpu(ohdr->bth[1]) >> HFI1_BECN_SHIFT) &
  137. HFI1_BECN_MASK;
  138. __entry->qpn =
  139. be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
  140. __entry->a =
  141. (be32_to_cpu(ohdr->bth[2]) >> 31) & 1;
  142. /* allow for larger PSN */
  143. __entry->psn =
  144. be32_to_cpu(ohdr->bth[2]) & 0x7fffffff;
  145. /* extended headers */
  146. memcpy(__get_dynamic_array(ehdrs), &ohdr->u,
  147. ibhdr_exhdr_len(hdr));
  148. ),
  149. TP_printk("[%s] " LRH_PRN " " BTH_PRN " " EHDR_PRN,
  150. __get_str(dev),
  151. /* LRH */
  152. __entry->vl,
  153. __entry->lver,
  154. __entry->sl,
  155. __entry->lnh, show_lnh(__entry->lnh),
  156. __entry->dlid,
  157. __entry->len,
  158. __entry->slid,
  159. /* BTH */
  160. __entry->opcode, show_ib_opcode(__entry->opcode),
  161. __entry->se,
  162. __entry->m,
  163. __entry->pad,
  164. __entry->tver,
  165. __entry->pkey,
  166. __entry->f,
  167. __entry->b,
  168. __entry->qpn,
  169. __entry->a,
  170. __entry->psn,
  171. /* extended headers */
  172. __parse_ib_ehdrs(
  173. __entry->opcode,
  174. (void *)__get_dynamic_array(ehdrs))
  175. )
  176. );
  177. DEFINE_EVENT(hfi1_ibhdr_template, input_ibhdr,
  178. TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
  179. TP_ARGS(dd, hdr));
  180. DEFINE_EVENT(hfi1_ibhdr_template, pio_output_ibhdr,
  181. TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
  182. TP_ARGS(dd, hdr));
  183. DEFINE_EVENT(hfi1_ibhdr_template, ack_output_ibhdr,
  184. TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
  185. TP_ARGS(dd, hdr));
  186. DEFINE_EVENT(hfi1_ibhdr_template, sdma_output_ibhdr,
  187. TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
  188. TP_ARGS(dd, hdr));
  189. #endif /* __HFI1_TRACE_IBHDRS_H */
  190. #undef TRACE_INCLUDE_PATH
  191. #undef TRACE_INCLUDE_FILE
  192. #define TRACE_INCLUDE_PATH .
  193. #define TRACE_INCLUDE_FILE trace_ibhdrs
  194. #include <trace/define_trace.h>