trace.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. #define CREATE_TRACE_POINTS
  48. #include "trace.h"
  49. u8 ibhdr_exhdr_len(struct hfi1_ib_header *hdr)
  50. {
  51. struct hfi1_other_headers *ohdr;
  52. u8 opcode;
  53. u8 lnh = (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
  54. if (lnh == HFI1_LRH_BTH)
  55. ohdr = &hdr->u.oth;
  56. else
  57. ohdr = &hdr->u.l.oth;
  58. opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
  59. return hdr_len_by_opcode[opcode] == 0 ?
  60. 0 : hdr_len_by_opcode[opcode] - (12 + 8);
  61. }
  62. #define IMM_PRN "imm %d"
  63. #define RETH_PRN "reth vaddr 0x%.16llx rkey 0x%.8x dlen 0x%.8x"
  64. #define AETH_PRN "aeth syn 0x%.2x %s msn 0x%.8x"
  65. #define DETH_PRN "deth qkey 0x%.8x sqpn 0x%.6x"
  66. #define IETH_PRN "ieth rkey 0x%.8x"
  67. #define ATOMICACKETH_PRN "origdata %lld"
  68. #define ATOMICETH_PRN "vaddr 0x%llx rkey 0x%.8x sdata %lld cdata %lld"
  69. #define OP(transport, op) IB_OPCODE_## transport ## _ ## op
  70. static u64 ib_u64_get(__be32 *p)
  71. {
  72. return ((u64)be32_to_cpu(p[0]) << 32) | be32_to_cpu(p[1]);
  73. }
  74. static const char *parse_syndrome(u8 syndrome)
  75. {
  76. switch (syndrome >> 5) {
  77. case 0:
  78. return "ACK";
  79. case 1:
  80. return "RNRNAK";
  81. case 3:
  82. return "NAK";
  83. }
  84. return "";
  85. }
  86. const char *parse_everbs_hdrs(
  87. struct trace_seq *p,
  88. u8 opcode,
  89. void *ehdrs)
  90. {
  91. union ib_ehdrs *eh = ehdrs;
  92. const char *ret = trace_seq_buffer_ptr(p);
  93. switch (opcode) {
  94. /* imm */
  95. case OP(RC, SEND_LAST_WITH_IMMEDIATE):
  96. case OP(UC, SEND_LAST_WITH_IMMEDIATE):
  97. case OP(RC, SEND_ONLY_WITH_IMMEDIATE):
  98. case OP(UC, SEND_ONLY_WITH_IMMEDIATE):
  99. case OP(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE):
  100. case OP(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE):
  101. trace_seq_printf(p, IMM_PRN,
  102. be32_to_cpu(eh->imm_data));
  103. break;
  104. /* reth + imm */
  105. case OP(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE):
  106. case OP(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE):
  107. trace_seq_printf(p, RETH_PRN " " IMM_PRN,
  108. (unsigned long long)ib_u64_get(
  109. (__be32 *)&eh->rc.reth.vaddr),
  110. be32_to_cpu(eh->rc.reth.rkey),
  111. be32_to_cpu(eh->rc.reth.length),
  112. be32_to_cpu(eh->rc.imm_data));
  113. break;
  114. /* reth */
  115. case OP(RC, RDMA_READ_REQUEST):
  116. case OP(RC, RDMA_WRITE_FIRST):
  117. case OP(UC, RDMA_WRITE_FIRST):
  118. case OP(RC, RDMA_WRITE_ONLY):
  119. case OP(UC, RDMA_WRITE_ONLY):
  120. trace_seq_printf(p, RETH_PRN,
  121. (unsigned long long)ib_u64_get(
  122. (__be32 *)&eh->rc.reth.vaddr),
  123. be32_to_cpu(eh->rc.reth.rkey),
  124. be32_to_cpu(eh->rc.reth.length));
  125. break;
  126. case OP(RC, RDMA_READ_RESPONSE_FIRST):
  127. case OP(RC, RDMA_READ_RESPONSE_LAST):
  128. case OP(RC, RDMA_READ_RESPONSE_ONLY):
  129. case OP(RC, ACKNOWLEDGE):
  130. trace_seq_printf(p, AETH_PRN, be32_to_cpu(eh->aeth) >> 24,
  131. parse_syndrome(be32_to_cpu(eh->aeth) >> 24),
  132. be32_to_cpu(eh->aeth) & HFI1_MSN_MASK);
  133. break;
  134. /* aeth + atomicacketh */
  135. case OP(RC, ATOMIC_ACKNOWLEDGE):
  136. trace_seq_printf(p, AETH_PRN " " ATOMICACKETH_PRN,
  137. be32_to_cpu(eh->at.aeth) >> 24,
  138. parse_syndrome(be32_to_cpu(eh->at.aeth) >> 24),
  139. be32_to_cpu(eh->at.aeth) & HFI1_MSN_MASK,
  140. (unsigned long long)
  141. ib_u64_get(eh->at.atomic_ack_eth));
  142. break;
  143. /* atomiceth */
  144. case OP(RC, COMPARE_SWAP):
  145. case OP(RC, FETCH_ADD):
  146. trace_seq_printf(p, ATOMICETH_PRN,
  147. (unsigned long long)ib_u64_get(
  148. eh->atomic_eth.vaddr),
  149. eh->atomic_eth.rkey,
  150. (unsigned long long)ib_u64_get(
  151. (__be32 *)&eh->atomic_eth.swap_data),
  152. (unsigned long long)ib_u64_get(
  153. (__be32 *)&eh->atomic_eth.compare_data));
  154. break;
  155. /* deth */
  156. case OP(UD, SEND_ONLY):
  157. case OP(UD, SEND_ONLY_WITH_IMMEDIATE):
  158. trace_seq_printf(p, DETH_PRN,
  159. be32_to_cpu(eh->ud.deth[0]),
  160. be32_to_cpu(eh->ud.deth[1]) & RVT_QPN_MASK);
  161. break;
  162. /* ieth */
  163. case OP(RC, SEND_LAST_WITH_INVALIDATE):
  164. case OP(RC, SEND_ONLY_WITH_INVALIDATE):
  165. trace_seq_printf(p, IETH_PRN,
  166. be32_to_cpu(eh->ieth));
  167. break;
  168. }
  169. trace_seq_putc(p, 0);
  170. return ret;
  171. }
  172. const char *parse_sdma_flags(
  173. struct trace_seq *p,
  174. u64 desc0, u64 desc1)
  175. {
  176. const char *ret = trace_seq_buffer_ptr(p);
  177. char flags[5] = { 'x', 'x', 'x', 'x', 0 };
  178. flags[0] = (desc1 & SDMA_DESC1_INT_REQ_FLAG) ? 'I' : '-';
  179. flags[1] = (desc1 & SDMA_DESC1_HEAD_TO_HOST_FLAG) ? 'H' : '-';
  180. flags[2] = (desc0 & SDMA_DESC0_FIRST_DESC_FLAG) ? 'F' : '-';
  181. flags[3] = (desc0 & SDMA_DESC0_LAST_DESC_FLAG) ? 'L' : '-';
  182. trace_seq_printf(p, "%s", flags);
  183. if (desc0 & SDMA_DESC0_FIRST_DESC_FLAG)
  184. trace_seq_printf(p, " amode:%u aidx:%u alen:%u",
  185. (u8)((desc1 >> SDMA_DESC1_HEADER_MODE_SHIFT) &
  186. SDMA_DESC1_HEADER_MODE_MASK),
  187. (u8)((desc1 >> SDMA_DESC1_HEADER_INDEX_SHIFT) &
  188. SDMA_DESC1_HEADER_INDEX_MASK),
  189. (u8)((desc1 >> SDMA_DESC1_HEADER_DWS_SHIFT) &
  190. SDMA_DESC1_HEADER_DWS_MASK));
  191. return ret;
  192. }
  193. const char *print_u32_array(
  194. struct trace_seq *p,
  195. u32 *arr, int len)
  196. {
  197. int i;
  198. const char *ret = trace_seq_buffer_ptr(p);
  199. for (i = 0; i < len ; i++)
  200. trace_seq_printf(p, "%s%#x", i == 0 ? "" : " ", arr[i]);
  201. trace_seq_putc(p, 0);
  202. return ret;
  203. }
  204. __hfi1_trace_fn(PKT);
  205. __hfi1_trace_fn(PROC);
  206. __hfi1_trace_fn(SDMA);
  207. __hfi1_trace_fn(LINKVERB);
  208. __hfi1_trace_fn(DEBUG);
  209. __hfi1_trace_fn(SNOOP);
  210. __hfi1_trace_fn(CNTR);
  211. __hfi1_trace_fn(PIO);
  212. __hfi1_trace_fn(DC8051);
  213. __hfi1_trace_fn(FIRMWARE);
  214. __hfi1_trace_fn(RCVCTRL);
  215. __hfi1_trace_fn(TID);
  216. __hfi1_trace_fn(MMU);
  217. __hfi1_trace_fn(IOCTL);