Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright(c) 2015 - 2018 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 | |
| 50 | static u8 __get_ib_hdr_len(struct ib_header *hdr) |
| 51 | { |
| 52 | struct ib_other_headers *ohdr; |
| 53 | u8 opcode; |
| 54 | |
| 55 | if (ib_get_lnh(hdr) == HFI1_LRH_BTH) |
| 56 | ohdr = &hdr->u.oth; |
| 57 | else |
| 58 | ohdr = &hdr->u.l.oth; |
| 59 | opcode = ib_bth_get_opcode(ohdr); |
| 60 | return hdr_len_by_opcode[opcode] == 0 ? |
| 61 | 0 : hdr_len_by_opcode[opcode] - (12 + 8); |
| 62 | } |
| 63 | |
| 64 | static u8 __get_16b_hdr_len(struct hfi1_16b_header *hdr) |
| 65 | { |
| 66 | struct ib_other_headers *ohdr = NULL; |
| 67 | u8 opcode; |
| 68 | u8 l4 = hfi1_16B_get_l4(hdr); |
| 69 | |
| 70 | if (l4 == OPA_16B_L4_FM) { |
| 71 | opcode = IB_OPCODE_UD_SEND_ONLY; |
| 72 | return (8 + 8); /* No BTH */ |
| 73 | } |
| 74 | |
| 75 | if (l4 == OPA_16B_L4_IB_LOCAL) |
| 76 | ohdr = &hdr->u.oth; |
| 77 | else |
| 78 | ohdr = &hdr->u.l.oth; |
| 79 | |
| 80 | opcode = ib_bth_get_opcode(ohdr); |
| 81 | return hdr_len_by_opcode[opcode] == 0 ? |
| 82 | 0 : hdr_len_by_opcode[opcode] - (12 + 8 + 8); |
| 83 | } |
| 84 | |
| 85 | u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet) |
| 86 | { |
| 87 | if (packet->etype != RHF_RCV_TYPE_BYPASS) |
| 88 | return __get_ib_hdr_len(packet->hdr); |
| 89 | else |
| 90 | return __get_16b_hdr_len(packet->hdr); |
| 91 | } |
| 92 | |
| 93 | u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opa_hdr) |
| 94 | { |
| 95 | if (!opa_hdr->hdr_type) |
| 96 | return __get_ib_hdr_len(&opa_hdr->ibh); |
| 97 | else |
| 98 | return __get_16b_hdr_len(&opa_hdr->opah); |
| 99 | } |
| 100 | |
| 101 | const char *hfi1_trace_get_packet_l4_str(u8 l4) |
| 102 | { |
| 103 | if (l4) |
| 104 | return "16B"; |
| 105 | else |
| 106 | return "9B"; |
| 107 | } |
| 108 | |
| 109 | const char *hfi1_trace_get_packet_l2_str(u8 l2) |
| 110 | { |
| 111 | switch (l2) { |
| 112 | case 0: |
| 113 | return "0"; |
| 114 | case 1: |
| 115 | return "1"; |
| 116 | case 2: |
| 117 | return "16B"; |
| 118 | case 3: |
| 119 | return "9B"; |
| 120 | } |
| 121 | return ""; |
| 122 | } |
| 123 | |
| 124 | #define IMM_PRN "imm:%d" |
| 125 | #define RETH_PRN "reth vaddr:0x%.16llx rkey:0x%.8x dlen:0x%.8x" |
| 126 | #define AETH_PRN "aeth syn:0x%.2x %s msn:0x%.8x" |
| 127 | #define DETH_PRN "deth qkey:0x%.8x sqpn:0x%.6x" |
| 128 | #define IETH_PRN "ieth rkey:0x%.8x" |
| 129 | #define ATOMICACKETH_PRN "origdata:%llx" |
| 130 | #define ATOMICETH_PRN "vaddr:0x%llx rkey:0x%.8x sdata:%llx cdata:%llx" |
| 131 | |
| 132 | #define OP(transport, op) IB_OPCODE_## transport ## _ ## op |
| 133 | |
| 134 | static const char *parse_syndrome(u8 syndrome) |
| 135 | { |
| 136 | switch (syndrome >> 5) { |
| 137 | case 0: |
| 138 | return "ACK"; |
| 139 | case 1: |
| 140 | return "RNRNAK"; |
| 141 | case 3: |
| 142 | return "NAK"; |
| 143 | } |
| 144 | return ""; |
| 145 | } |
| 146 | |
| 147 | void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr, |
| 148 | u8 *ack, bool *becn, bool *fecn, u8 *mig, |
| 149 | u8 *se, u8 *pad, u8 *opcode, u8 *tver, |
| 150 | u16 *pkey, u32 *psn, u32 *qpn) |
| 151 | { |
| 152 | *ack = ib_bth_get_ackreq(ohdr); |
| 153 | *becn = ib_bth_get_becn(ohdr); |
| 154 | *fecn = ib_bth_get_fecn(ohdr); |
| 155 | *mig = ib_bth_get_migreq(ohdr); |
| 156 | *se = ib_bth_get_se(ohdr); |
| 157 | *pad = ib_bth_get_pad(ohdr); |
| 158 | *opcode = ib_bth_get_opcode(ohdr); |
| 159 | *tver = ib_bth_get_tver(ohdr); |
| 160 | *pkey = ib_bth_get_pkey(ohdr); |
| 161 | *psn = mask_psn(ib_bth_get_psn(ohdr)); |
| 162 | *qpn = ib_bth_get_qpn(ohdr); |
| 163 | } |
| 164 | |
| 165 | void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr, |
| 166 | u8 *ack, u8 *mig, u8 *opcode, |
| 167 | u8 *pad, u8 *se, u8 *tver, |
| 168 | u32 *psn, u32 *qpn) |
| 169 | { |
| 170 | *ack = ib_bth_get_ackreq(ohdr); |
| 171 | *mig = ib_bth_get_migreq(ohdr); |
| 172 | *opcode = ib_bth_get_opcode(ohdr); |
| 173 | *pad = ib_bth_get_pad(ohdr); |
| 174 | *se = ib_bth_get_se(ohdr); |
| 175 | *tver = ib_bth_get_tver(ohdr); |
| 176 | *psn = mask_psn(ib_bth_get_psn(ohdr)); |
| 177 | *qpn = ib_bth_get_qpn(ohdr); |
| 178 | } |
| 179 | |
| 180 | void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5, |
| 181 | u8 *lnh, u8 *lver, u8 *sl, u8 *sc, |
| 182 | u16 *len, u32 *dlid, u32 *slid) |
| 183 | { |
| 184 | *lnh = ib_get_lnh(hdr); |
| 185 | *lver = ib_get_lver(hdr); |
| 186 | *sl = ib_get_sl(hdr); |
| 187 | *sc = ib_get_sc(hdr) | (sc5 << 4); |
| 188 | *len = ib_get_len(hdr); |
| 189 | *dlid = ib_get_dlid(hdr); |
| 190 | *slid = ib_get_slid(hdr); |
| 191 | } |
| 192 | |
| 193 | void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr, |
| 194 | u8 *age, bool *becn, bool *fecn, |
| 195 | u8 *l4, u8 *rc, u8 *sc, |
| 196 | u16 *entropy, u16 *len, u16 *pkey, |
| 197 | u32 *dlid, u32 *slid) |
| 198 | { |
| 199 | *age = hfi1_16B_get_age(hdr); |
| 200 | *becn = hfi1_16B_get_becn(hdr); |
| 201 | *fecn = hfi1_16B_get_fecn(hdr); |
| 202 | *l4 = hfi1_16B_get_l4(hdr); |
| 203 | *rc = hfi1_16B_get_rc(hdr); |
| 204 | *sc = hfi1_16B_get_sc(hdr); |
| 205 | *entropy = hfi1_16B_get_entropy(hdr); |
| 206 | *len = hfi1_16B_get_len(hdr); |
| 207 | *pkey = hfi1_16B_get_pkey(hdr); |
| 208 | *dlid = hfi1_16B_get_dlid(hdr); |
| 209 | *slid = hfi1_16B_get_slid(hdr); |
| 210 | } |
| 211 | |
| 212 | #define LRH_PRN "len:%d sc:%d dlid:0x%.4x slid:0x%.4x " |
| 213 | #define LRH_9B_PRN "lnh:%d,%s lver:%d sl:%d" |
| 214 | #define LRH_16B_PRN "age:%d becn:%d fecn:%d l4:%d " \ |
| 215 | "rc:%d sc:%d pkey:0x%.4x entropy:0x%.4x" |
| 216 | const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass, |
| 217 | u8 age, bool becn, bool fecn, u8 l4, |
| 218 | u8 lnh, const char *lnh_name, u8 lver, |
| 219 | u8 rc, u8 sc, u8 sl, u16 entropy, |
| 220 | u16 len, u16 pkey, u32 dlid, u32 slid) |
| 221 | { |
| 222 | const char *ret = trace_seq_buffer_ptr(p); |
| 223 | |
| 224 | trace_seq_printf(p, LRH_PRN, len, sc, dlid, slid); |
| 225 | |
| 226 | if (bypass) |
| 227 | trace_seq_printf(p, LRH_16B_PRN, |
| 228 | age, becn, fecn, l4, rc, sc, pkey, entropy); |
| 229 | |
| 230 | else |
| 231 | trace_seq_printf(p, LRH_9B_PRN, |
| 232 | lnh, lnh_name, lver, sl); |
| 233 | trace_seq_putc(p, 0); |
| 234 | |
| 235 | return ret; |
| 236 | } |
| 237 | |
| 238 | #define BTH_9B_PRN \ |
| 239 | "op:0x%.2x,%s se:%d m:%d pad:%d tver:%d pkey:0x%.4x " \ |
| 240 | "f:%d b:%d qpn:0x%.6x a:%d psn:0x%.8x" |
| 241 | #define BTH_16B_PRN \ |
| 242 | "op:0x%.2x,%s se:%d m:%d pad:%d tver:%d " \ |
| 243 | "qpn:0x%.6x a:%d psn:0x%.8x" |
| 244 | #define L4_FM_16B_PRN \ |
| 245 | "op:0x%.2x,%s dest_qpn:0x%.6x src_qpn:0x%.6x" |
| 246 | const char *hfi1_trace_fmt_rest(struct trace_seq *p, bool bypass, u8 l4, |
| 247 | u8 ack, bool becn, bool fecn, u8 mig, |
| 248 | u8 se, u8 pad, u8 opcode, const char *opname, |
| 249 | u8 tver, u16 pkey, u32 psn, u32 qpn, |
| 250 | u32 dest_qpn, u32 src_qpn) |
| 251 | { |
| 252 | const char *ret = trace_seq_buffer_ptr(p); |
| 253 | |
| 254 | if (bypass) |
| 255 | if (l4 == OPA_16B_L4_FM) |
| 256 | trace_seq_printf(p, L4_FM_16B_PRN, |
| 257 | opcode, opname, dest_qpn, src_qpn); |
| 258 | else |
| 259 | trace_seq_printf(p, BTH_16B_PRN, |
| 260 | opcode, opname, |
| 261 | se, mig, pad, tver, qpn, ack, psn); |
| 262 | |
| 263 | else |
| 264 | trace_seq_printf(p, BTH_9B_PRN, |
| 265 | opcode, opname, |
| 266 | se, mig, pad, tver, pkey, fecn, becn, |
| 267 | qpn, ack, psn); |
| 268 | trace_seq_putc(p, 0); |
| 269 | |
| 270 | return ret; |
| 271 | } |
| 272 | |
| 273 | const char *parse_everbs_hdrs( |
| 274 | struct trace_seq *p, |
| 275 | u8 opcode, u8 l4, u32 dest_qpn, u32 src_qpn, |
| 276 | void *ehdrs) |
| 277 | { |
| 278 | union ib_ehdrs *eh = ehdrs; |
| 279 | const char *ret = trace_seq_buffer_ptr(p); |
| 280 | |
| 281 | if (l4 == OPA_16B_L4_FM) { |
| 282 | trace_seq_printf(p, "mgmt pkt"); |
| 283 | goto out; |
| 284 | } |
| 285 | |
| 286 | switch (opcode) { |
| 287 | /* imm */ |
| 288 | case OP(RC, SEND_LAST_WITH_IMMEDIATE): |
| 289 | case OP(UC, SEND_LAST_WITH_IMMEDIATE): |
| 290 | case OP(RC, SEND_ONLY_WITH_IMMEDIATE): |
| 291 | case OP(UC, SEND_ONLY_WITH_IMMEDIATE): |
| 292 | case OP(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE): |
| 293 | case OP(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE): |
| 294 | trace_seq_printf(p, IMM_PRN, |
| 295 | be32_to_cpu(eh->imm_data)); |
| 296 | break; |
| 297 | /* reth + imm */ |
| 298 | case OP(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE): |
| 299 | case OP(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE): |
| 300 | trace_seq_printf(p, RETH_PRN " " IMM_PRN, |
| 301 | get_ib_reth_vaddr(&eh->rc.reth), |
| 302 | be32_to_cpu(eh->rc.reth.rkey), |
| 303 | be32_to_cpu(eh->rc.reth.length), |
| 304 | be32_to_cpu(eh->rc.imm_data)); |
| 305 | break; |
| 306 | /* reth */ |
| 307 | case OP(RC, RDMA_READ_REQUEST): |
| 308 | case OP(RC, RDMA_WRITE_FIRST): |
| 309 | case OP(UC, RDMA_WRITE_FIRST): |
| 310 | case OP(RC, RDMA_WRITE_ONLY): |
| 311 | case OP(UC, RDMA_WRITE_ONLY): |
| 312 | trace_seq_printf(p, RETH_PRN, |
| 313 | get_ib_reth_vaddr(&eh->rc.reth), |
| 314 | be32_to_cpu(eh->rc.reth.rkey), |
| 315 | be32_to_cpu(eh->rc.reth.length)); |
| 316 | break; |
| 317 | case OP(RC, RDMA_READ_RESPONSE_FIRST): |
| 318 | case OP(RC, RDMA_READ_RESPONSE_LAST): |
| 319 | case OP(RC, RDMA_READ_RESPONSE_ONLY): |
| 320 | case OP(RC, ACKNOWLEDGE): |
| 321 | trace_seq_printf(p, AETH_PRN, be32_to_cpu(eh->aeth) >> 24, |
| 322 | parse_syndrome(be32_to_cpu(eh->aeth) >> 24), |
| 323 | be32_to_cpu(eh->aeth) & IB_MSN_MASK); |
| 324 | break; |
| 325 | /* aeth + atomicacketh */ |
| 326 | case OP(RC, ATOMIC_ACKNOWLEDGE): |
| 327 | trace_seq_printf(p, AETH_PRN " " ATOMICACKETH_PRN, |
| 328 | be32_to_cpu(eh->at.aeth) >> 24, |
| 329 | parse_syndrome(be32_to_cpu(eh->at.aeth) >> 24), |
| 330 | be32_to_cpu(eh->at.aeth) & IB_MSN_MASK, |
| 331 | ib_u64_get(&eh->at.atomic_ack_eth)); |
| 332 | break; |
| 333 | /* atomiceth */ |
| 334 | case OP(RC, COMPARE_SWAP): |
| 335 | case OP(RC, FETCH_ADD): |
| 336 | trace_seq_printf(p, ATOMICETH_PRN, |
| 337 | get_ib_ateth_vaddr(&eh->atomic_eth), |
| 338 | eh->atomic_eth.rkey, |
| 339 | get_ib_ateth_swap(&eh->atomic_eth), |
| 340 | get_ib_ateth_compare(&eh->atomic_eth)); |
| 341 | break; |
| 342 | /* deth */ |
| 343 | case OP(UD, SEND_ONLY): |
| 344 | case OP(UD, SEND_ONLY_WITH_IMMEDIATE): |
| 345 | trace_seq_printf(p, DETH_PRN, |
| 346 | be32_to_cpu(eh->ud.deth[0]), |
| 347 | be32_to_cpu(eh->ud.deth[1]) & RVT_QPN_MASK); |
| 348 | break; |
| 349 | /* ieth */ |
| 350 | case OP(RC, SEND_LAST_WITH_INVALIDATE): |
| 351 | case OP(RC, SEND_ONLY_WITH_INVALIDATE): |
| 352 | trace_seq_printf(p, IETH_PRN, |
| 353 | be32_to_cpu(eh->ieth)); |
| 354 | break; |
| 355 | } |
| 356 | out: |
| 357 | trace_seq_putc(p, 0); |
| 358 | return ret; |
| 359 | } |
| 360 | |
| 361 | const char *parse_sdma_flags( |
| 362 | struct trace_seq *p, |
| 363 | u64 desc0, u64 desc1) |
| 364 | { |
| 365 | const char *ret = trace_seq_buffer_ptr(p); |
| 366 | char flags[5] = { 'x', 'x', 'x', 'x', 0 }; |
| 367 | |
| 368 | flags[0] = (desc1 & SDMA_DESC1_INT_REQ_FLAG) ? 'I' : '-'; |
| 369 | flags[1] = (desc1 & SDMA_DESC1_HEAD_TO_HOST_FLAG) ? 'H' : '-'; |
| 370 | flags[2] = (desc0 & SDMA_DESC0_FIRST_DESC_FLAG) ? 'F' : '-'; |
| 371 | flags[3] = (desc0 & SDMA_DESC0_LAST_DESC_FLAG) ? 'L' : '-'; |
| 372 | trace_seq_printf(p, "%s", flags); |
| 373 | if (desc0 & SDMA_DESC0_FIRST_DESC_FLAG) |
| 374 | trace_seq_printf(p, " amode:%u aidx:%u alen:%u", |
| 375 | (u8)((desc1 >> SDMA_DESC1_HEADER_MODE_SHIFT) & |
| 376 | SDMA_DESC1_HEADER_MODE_MASK), |
| 377 | (u8)((desc1 >> SDMA_DESC1_HEADER_INDEX_SHIFT) & |
| 378 | SDMA_DESC1_HEADER_INDEX_MASK), |
| 379 | (u8)((desc1 >> SDMA_DESC1_HEADER_DWS_SHIFT) & |
| 380 | SDMA_DESC1_HEADER_DWS_MASK)); |
| 381 | return ret; |
| 382 | } |
| 383 | |
| 384 | const char *print_u32_array( |
| 385 | struct trace_seq *p, |
| 386 | u32 *arr, int len) |
| 387 | { |
| 388 | int i; |
| 389 | const char *ret = trace_seq_buffer_ptr(p); |
| 390 | |
| 391 | for (i = 0; i < len ; i++) |
| 392 | trace_seq_printf(p, "%s%#x", i == 0 ? "" : " ", arr[i]); |
| 393 | trace_seq_putc(p, 0); |
| 394 | return ret; |
| 395 | } |
| 396 | |
| 397 | __hfi1_trace_fn(AFFINITY); |
| 398 | __hfi1_trace_fn(PKT); |
| 399 | __hfi1_trace_fn(PROC); |
| 400 | __hfi1_trace_fn(SDMA); |
| 401 | __hfi1_trace_fn(LINKVERB); |
| 402 | __hfi1_trace_fn(DEBUG); |
| 403 | __hfi1_trace_fn(SNOOP); |
| 404 | __hfi1_trace_fn(CNTR); |
| 405 | __hfi1_trace_fn(PIO); |
| 406 | __hfi1_trace_fn(DC8051); |
| 407 | __hfi1_trace_fn(FIRMWARE); |
| 408 | __hfi1_trace_fn(RCVCTRL); |
| 409 | __hfi1_trace_fn(TID); |
| 410 | __hfi1_trace_fn(MMU); |
| 411 | __hfi1_trace_fn(IOCTL); |