1 /* 2 * Copyright(c) 2015 - 2020 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 #include "exp_rcv.h" 50 #include "ipoib.h" 51 52 static u8 __get_ib_hdr_len(struct ib_header *hdr) 53 { 54 struct ib_other_headers *ohdr; 55 u8 opcode; 56 57 if (ib_get_lnh(hdr) == HFI1_LRH_BTH) 58 ohdr = &hdr->u.oth; 59 else 60 ohdr = &hdr->u.l.oth; 61 opcode = ib_bth_get_opcode(ohdr); 62 return hdr_len_by_opcode[opcode] == 0 ? 63 0 : hdr_len_by_opcode[opcode] - (12 + 8); 64 } 65 66 static u8 __get_16b_hdr_len(struct hfi1_16b_header *hdr) 67 { 68 struct ib_other_headers *ohdr = NULL; 69 u8 opcode; 70 u8 l4 = hfi1_16B_get_l4(hdr); 71 72 if (l4 == OPA_16B_L4_FM) { 73 opcode = IB_OPCODE_UD_SEND_ONLY; 74 return (8 + 8); /* No BTH */ 75 } 76 77 if (l4 == OPA_16B_L4_IB_LOCAL) 78 ohdr = &hdr->u.oth; 79 else 80 ohdr = &hdr->u.l.oth; 81 82 opcode = ib_bth_get_opcode(ohdr); 83 return hdr_len_by_opcode[opcode] == 0 ? 84 0 : hdr_len_by_opcode[opcode] - (12 + 8 + 8); 85 } 86 87 u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet) 88 { 89 if (packet->etype != RHF_RCV_TYPE_BYPASS) 90 return __get_ib_hdr_len(packet->hdr); 91 else 92 return __get_16b_hdr_len(packet->hdr); 93 } 94 95 u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opa_hdr) 96 { 97 if (!opa_hdr->hdr_type) 98 return __get_ib_hdr_len(&opa_hdr->ibh); 99 else 100 return __get_16b_hdr_len(&opa_hdr->opah); 101 } 102 103 const char *hfi1_trace_get_packet_l4_str(u8 l4) 104 { 105 if (l4) 106 return "16B"; 107 else 108 return "9B"; 109 } 110 111 const char *hfi1_trace_get_packet_l2_str(u8 l2) 112 { 113 switch (l2) { 114 case 0: 115 return "0"; 116 case 1: 117 return "1"; 118 case 2: 119 return "16B"; 120 case 3: 121 return "9B"; 122 } 123 return ""; 124 } 125 126 #define IMM_PRN "imm:%d" 127 #define RETH_PRN "reth vaddr:0x%.16llx rkey:0x%.8x dlen:0x%.8x" 128 #define AETH_PRN "aeth syn:0x%.2x %s msn:0x%.8x" 129 #define DETH_PRN "deth qkey:0x%.8x sqpn:0x%.6x" 130 #define DETH_ENTROPY_PRN "deth qkey:0x%.8x sqpn:0x%.6x entropy:0x%.2x" 131 #define IETH_PRN "ieth rkey:0x%.8x" 132 #define ATOMICACKETH_PRN "origdata:%llx" 133 #define ATOMICETH_PRN "vaddr:0x%llx rkey:0x%.8x sdata:%llx cdata:%llx" 134 #define TID_RDMA_KDETH "kdeth0 0x%x kdeth1 0x%x" 135 #define TID_RDMA_KDETH_DATA "kdeth0 0x%x: kver %u sh %u intr %u tidctrl %u tid %x offset %x kdeth1 0x%x: jkey %x" 136 #define TID_READ_REQ_PRN "tid_flow_psn 0x%x tid_flow_qp 0x%x verbs_qp 0x%x" 137 #define TID_READ_RSP_PRN "verbs_qp 0x%x" 138 #define TID_WRITE_REQ_PRN "original_qp 0x%x" 139 #define TID_WRITE_RSP_PRN "tid_flow_psn 0x%x tid_flow_qp 0x%x verbs_qp 0x%x" 140 #define TID_WRITE_DATA_PRN "verbs_qp 0x%x" 141 #define TID_ACK_PRN "tid_flow_psn 0x%x verbs_psn 0x%x tid_flow_qp 0x%x verbs_qp 0x%x" 142 #define TID_RESYNC_PRN "verbs_qp 0x%x" 143 144 #define OP(transport, op) IB_OPCODE_## transport ## _ ## op 145 146 static const char *parse_syndrome(u8 syndrome) 147 { 148 switch (syndrome >> 5) { 149 case 0: 150 return "ACK"; 151 case 1: 152 return "RNRNAK"; 153 case 3: 154 return "NAK"; 155 } 156 return ""; 157 } 158 159 void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr, 160 u8 *ack, bool *becn, bool *fecn, u8 *mig, 161 u8 *se, u8 *pad, u8 *opcode, u8 *tver, 162 u16 *pkey, u32 *psn, u32 *qpn) 163 { 164 *ack = ib_bth_get_ackreq(ohdr); 165 *becn = ib_bth_get_becn(ohdr); 166 *fecn = ib_bth_get_fecn(ohdr); 167 *mig = ib_bth_get_migreq(ohdr); 168 *se = ib_bth_get_se(ohdr); 169 *pad = ib_bth_get_pad(ohdr); 170 *opcode = ib_bth_get_opcode(ohdr); 171 *tver = ib_bth_get_tver(ohdr); 172 *pkey = ib_bth_get_pkey(ohdr); 173 *psn = mask_psn(ib_bth_get_psn(ohdr)); 174 *qpn = ib_bth_get_qpn(ohdr); 175 } 176 177 void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr, 178 u8 *ack, u8 *mig, u8 *opcode, 179 u8 *pad, u8 *se, u8 *tver, 180 u32 *psn, u32 *qpn) 181 { 182 *ack = ib_bth_get_ackreq(ohdr); 183 *mig = ib_bth_get_migreq(ohdr); 184 *opcode = ib_bth_get_opcode(ohdr); 185 *pad = ib_bth_get_pad(ohdr); 186 *se = ib_bth_get_se(ohdr); 187 *tver = ib_bth_get_tver(ohdr); 188 *psn = mask_psn(ib_bth_get_psn(ohdr)); 189 *qpn = ib_bth_get_qpn(ohdr); 190 } 191 192 static u16 ib_get_len(const struct ib_header *hdr) 193 { 194 return be16_to_cpu(hdr->lrh[2]); 195 } 196 197 void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5, 198 u8 *lnh, u8 *lver, u8 *sl, u8 *sc, 199 u16 *len, u32 *dlid, u32 *slid) 200 { 201 *lnh = ib_get_lnh(hdr); 202 *lver = ib_get_lver(hdr); 203 *sl = ib_get_sl(hdr); 204 *sc = ib_get_sc(hdr) | (sc5 << 4); 205 *len = ib_get_len(hdr); 206 *dlid = ib_get_dlid(hdr); 207 *slid = ib_get_slid(hdr); 208 } 209 210 void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr, 211 u8 *age, bool *becn, bool *fecn, 212 u8 *l4, u8 *rc, u8 *sc, 213 u16 *entropy, u16 *len, u16 *pkey, 214 u32 *dlid, u32 *slid) 215 { 216 *age = hfi1_16B_get_age(hdr); 217 *becn = hfi1_16B_get_becn(hdr); 218 *fecn = hfi1_16B_get_fecn(hdr); 219 *l4 = hfi1_16B_get_l4(hdr); 220 *rc = hfi1_16B_get_rc(hdr); 221 *sc = hfi1_16B_get_sc(hdr); 222 *entropy = hfi1_16B_get_entropy(hdr); 223 *len = hfi1_16B_get_len(hdr); 224 *pkey = hfi1_16B_get_pkey(hdr); 225 *dlid = hfi1_16B_get_dlid(hdr); 226 *slid = hfi1_16B_get_slid(hdr); 227 } 228 229 #define LRH_PRN "len:%d sc:%d dlid:0x%.4x slid:0x%.4x " 230 #define LRH_9B_PRN "lnh:%d,%s lver:%d sl:%d" 231 #define LRH_16B_PRN "age:%d becn:%d fecn:%d l4:%d " \ 232 "rc:%d sc:%d pkey:0x%.4x entropy:0x%.4x" 233 const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass, 234 u8 age, bool becn, bool fecn, u8 l4, 235 u8 lnh, const char *lnh_name, u8 lver, 236 u8 rc, u8 sc, u8 sl, u16 entropy, 237 u16 len, u16 pkey, u32 dlid, u32 slid) 238 { 239 const char *ret = trace_seq_buffer_ptr(p); 240 241 trace_seq_printf(p, LRH_PRN, len, sc, dlid, slid); 242 243 if (bypass) 244 trace_seq_printf(p, LRH_16B_PRN, 245 age, becn, fecn, l4, rc, sc, pkey, entropy); 246 247 else 248 trace_seq_printf(p, LRH_9B_PRN, 249 lnh, lnh_name, lver, sl); 250 trace_seq_putc(p, 0); 251 252 return ret; 253 } 254 255 #define BTH_9B_PRN \ 256 "op:0x%.2x,%s se:%d m:%d pad:%d tver:%d pkey:0x%.4x " \ 257 "f:%d b:%d qpn:0x%.6x a:%d psn:0x%.8x" 258 #define BTH_16B_PRN \ 259 "op:0x%.2x,%s se:%d m:%d pad:%d tver:%d " \ 260 "qpn:0x%.6x a:%d psn:0x%.8x" 261 #define L4_FM_16B_PRN \ 262 "op:0x%.2x,%s dest_qpn:0x%.6x src_qpn:0x%.6x" 263 const char *hfi1_trace_fmt_rest(struct trace_seq *p, bool bypass, u8 l4, 264 u8 ack, bool becn, bool fecn, u8 mig, 265 u8 se, u8 pad, u8 opcode, const char *opname, 266 u8 tver, u16 pkey, u32 psn, u32 qpn, 267 u32 dest_qpn, u32 src_qpn) 268 { 269 const char *ret = trace_seq_buffer_ptr(p); 270 271 if (bypass) 272 if (l4 == OPA_16B_L4_FM) 273 trace_seq_printf(p, L4_FM_16B_PRN, 274 opcode, opname, dest_qpn, src_qpn); 275 else 276 trace_seq_printf(p, BTH_16B_PRN, 277 opcode, opname, 278 se, mig, pad, tver, qpn, ack, psn); 279 280 else 281 trace_seq_printf(p, BTH_9B_PRN, 282 opcode, opname, 283 se, mig, pad, tver, pkey, fecn, becn, 284 qpn, ack, psn); 285 trace_seq_putc(p, 0); 286 287 return ret; 288 } 289 290 const char *parse_everbs_hdrs( 291 struct trace_seq *p, 292 u8 opcode, u8 l4, u32 dest_qpn, u32 src_qpn, 293 void *ehdrs) 294 { 295 union ib_ehdrs *eh = ehdrs; 296 const char *ret = trace_seq_buffer_ptr(p); 297 298 if (l4 == OPA_16B_L4_FM) { 299 trace_seq_printf(p, "mgmt pkt"); 300 goto out; 301 } 302 303 switch (opcode) { 304 /* imm */ 305 case OP(RC, SEND_LAST_WITH_IMMEDIATE): 306 case OP(UC, SEND_LAST_WITH_IMMEDIATE): 307 case OP(RC, SEND_ONLY_WITH_IMMEDIATE): 308 case OP(UC, SEND_ONLY_WITH_IMMEDIATE): 309 case OP(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE): 310 case OP(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE): 311 trace_seq_printf(p, IMM_PRN, 312 be32_to_cpu(eh->imm_data)); 313 break; 314 /* reth + imm */ 315 case OP(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE): 316 case OP(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE): 317 trace_seq_printf(p, RETH_PRN " " IMM_PRN, 318 get_ib_reth_vaddr(&eh->rc.reth), 319 be32_to_cpu(eh->rc.reth.rkey), 320 be32_to_cpu(eh->rc.reth.length), 321 be32_to_cpu(eh->rc.imm_data)); 322 break; 323 /* reth */ 324 case OP(RC, RDMA_READ_REQUEST): 325 case OP(RC, RDMA_WRITE_FIRST): 326 case OP(UC, RDMA_WRITE_FIRST): 327 case OP(RC, RDMA_WRITE_ONLY): 328 case OP(UC, RDMA_WRITE_ONLY): 329 trace_seq_printf(p, RETH_PRN, 330 get_ib_reth_vaddr(&eh->rc.reth), 331 be32_to_cpu(eh->rc.reth.rkey), 332 be32_to_cpu(eh->rc.reth.length)); 333 break; 334 case OP(RC, RDMA_READ_RESPONSE_FIRST): 335 case OP(RC, RDMA_READ_RESPONSE_LAST): 336 case OP(RC, RDMA_READ_RESPONSE_ONLY): 337 case OP(RC, ACKNOWLEDGE): 338 trace_seq_printf(p, AETH_PRN, be32_to_cpu(eh->aeth) >> 24, 339 parse_syndrome(be32_to_cpu(eh->aeth) >> 24), 340 be32_to_cpu(eh->aeth) & IB_MSN_MASK); 341 break; 342 case OP(TID_RDMA, WRITE_REQ): 343 trace_seq_printf(p, TID_RDMA_KDETH " " RETH_PRN " " 344 TID_WRITE_REQ_PRN, 345 le32_to_cpu(eh->tid_rdma.w_req.kdeth0), 346 le32_to_cpu(eh->tid_rdma.w_req.kdeth1), 347 ib_u64_get(&eh->tid_rdma.w_req.reth.vaddr), 348 be32_to_cpu(eh->tid_rdma.w_req.reth.rkey), 349 be32_to_cpu(eh->tid_rdma.w_req.reth.length), 350 be32_to_cpu(eh->tid_rdma.w_req.verbs_qp)); 351 break; 352 case OP(TID_RDMA, WRITE_RESP): 353 trace_seq_printf(p, TID_RDMA_KDETH " " AETH_PRN " " 354 TID_WRITE_RSP_PRN, 355 le32_to_cpu(eh->tid_rdma.w_rsp.kdeth0), 356 le32_to_cpu(eh->tid_rdma.w_rsp.kdeth1), 357 be32_to_cpu(eh->tid_rdma.w_rsp.aeth) >> 24, 358 parse_syndrome(/* aeth */ 359 be32_to_cpu(eh->tid_rdma.w_rsp.aeth) 360 >> 24), 361 (be32_to_cpu(eh->tid_rdma.w_rsp.aeth) & 362 IB_MSN_MASK), 363 be32_to_cpu(eh->tid_rdma.w_rsp.tid_flow_psn), 364 be32_to_cpu(eh->tid_rdma.w_rsp.tid_flow_qp), 365 be32_to_cpu(eh->tid_rdma.w_rsp.verbs_qp)); 366 break; 367 case OP(TID_RDMA, WRITE_DATA_LAST): 368 case OP(TID_RDMA, WRITE_DATA): 369 trace_seq_printf(p, TID_RDMA_KDETH_DATA " " TID_WRITE_DATA_PRN, 370 le32_to_cpu(eh->tid_rdma.w_data.kdeth0), 371 KDETH_GET(eh->tid_rdma.w_data.kdeth0, KVER), 372 KDETH_GET(eh->tid_rdma.w_data.kdeth0, SH), 373 KDETH_GET(eh->tid_rdma.w_data.kdeth0, INTR), 374 KDETH_GET(eh->tid_rdma.w_data.kdeth0, TIDCTRL), 375 KDETH_GET(eh->tid_rdma.w_data.kdeth0, TID), 376 KDETH_GET(eh->tid_rdma.w_data.kdeth0, OFFSET), 377 le32_to_cpu(eh->tid_rdma.w_data.kdeth1), 378 KDETH_GET(eh->tid_rdma.w_data.kdeth1, JKEY), 379 be32_to_cpu(eh->tid_rdma.w_data.verbs_qp)); 380 break; 381 case OP(TID_RDMA, READ_REQ): 382 trace_seq_printf(p, TID_RDMA_KDETH " " RETH_PRN " " 383 TID_READ_REQ_PRN, 384 le32_to_cpu(eh->tid_rdma.r_req.kdeth0), 385 le32_to_cpu(eh->tid_rdma.r_req.kdeth1), 386 ib_u64_get(&eh->tid_rdma.r_req.reth.vaddr), 387 be32_to_cpu(eh->tid_rdma.r_req.reth.rkey), 388 be32_to_cpu(eh->tid_rdma.r_req.reth.length), 389 be32_to_cpu(eh->tid_rdma.r_req.tid_flow_psn), 390 be32_to_cpu(eh->tid_rdma.r_req.tid_flow_qp), 391 be32_to_cpu(eh->tid_rdma.r_req.verbs_qp)); 392 break; 393 case OP(TID_RDMA, READ_RESP): 394 trace_seq_printf(p, TID_RDMA_KDETH_DATA " " AETH_PRN " " 395 TID_READ_RSP_PRN, 396 le32_to_cpu(eh->tid_rdma.r_rsp.kdeth0), 397 KDETH_GET(eh->tid_rdma.r_rsp.kdeth0, KVER), 398 KDETH_GET(eh->tid_rdma.r_rsp.kdeth0, SH), 399 KDETH_GET(eh->tid_rdma.r_rsp.kdeth0, INTR), 400 KDETH_GET(eh->tid_rdma.r_rsp.kdeth0, TIDCTRL), 401 KDETH_GET(eh->tid_rdma.r_rsp.kdeth0, TID), 402 KDETH_GET(eh->tid_rdma.r_rsp.kdeth0, OFFSET), 403 le32_to_cpu(eh->tid_rdma.r_rsp.kdeth1), 404 KDETH_GET(eh->tid_rdma.r_rsp.kdeth1, JKEY), 405 be32_to_cpu(eh->tid_rdma.r_rsp.aeth) >> 24, 406 parse_syndrome(/* aeth */ 407 be32_to_cpu(eh->tid_rdma.r_rsp.aeth) 408 >> 24), 409 (be32_to_cpu(eh->tid_rdma.r_rsp.aeth) & 410 IB_MSN_MASK), 411 be32_to_cpu(eh->tid_rdma.r_rsp.verbs_qp)); 412 break; 413 case OP(TID_RDMA, ACK): 414 trace_seq_printf(p, TID_RDMA_KDETH " " AETH_PRN " " 415 TID_ACK_PRN, 416 le32_to_cpu(eh->tid_rdma.ack.kdeth0), 417 le32_to_cpu(eh->tid_rdma.ack.kdeth1), 418 be32_to_cpu(eh->tid_rdma.ack.aeth) >> 24, 419 parse_syndrome(/* aeth */ 420 be32_to_cpu(eh->tid_rdma.ack.aeth) 421 >> 24), 422 (be32_to_cpu(eh->tid_rdma.ack.aeth) & 423 IB_MSN_MASK), 424 be32_to_cpu(eh->tid_rdma.ack.tid_flow_psn), 425 be32_to_cpu(eh->tid_rdma.ack.verbs_psn), 426 be32_to_cpu(eh->tid_rdma.ack.tid_flow_qp), 427 be32_to_cpu(eh->tid_rdma.ack.verbs_qp)); 428 break; 429 case OP(TID_RDMA, RESYNC): 430 trace_seq_printf(p, TID_RDMA_KDETH " " TID_RESYNC_PRN, 431 le32_to_cpu(eh->tid_rdma.resync.kdeth0), 432 le32_to_cpu(eh->tid_rdma.resync.kdeth1), 433 be32_to_cpu(eh->tid_rdma.resync.verbs_qp)); 434 break; 435 /* aeth + atomicacketh */ 436 case OP(RC, ATOMIC_ACKNOWLEDGE): 437 trace_seq_printf(p, AETH_PRN " " ATOMICACKETH_PRN, 438 be32_to_cpu(eh->at.aeth) >> 24, 439 parse_syndrome(be32_to_cpu(eh->at.aeth) >> 24), 440 be32_to_cpu(eh->at.aeth) & IB_MSN_MASK, 441 ib_u64_get(&eh->at.atomic_ack_eth)); 442 break; 443 /* atomiceth */ 444 case OP(RC, COMPARE_SWAP): 445 case OP(RC, FETCH_ADD): 446 trace_seq_printf(p, ATOMICETH_PRN, 447 get_ib_ateth_vaddr(&eh->atomic_eth), 448 eh->atomic_eth.rkey, 449 get_ib_ateth_swap(&eh->atomic_eth), 450 get_ib_ateth_compare(&eh->atomic_eth)); 451 break; 452 /* deth */ 453 case OP(UD, SEND_ONLY): 454 trace_seq_printf(p, DETH_ENTROPY_PRN, 455 be32_to_cpu(eh->ud.deth[0]), 456 be32_to_cpu(eh->ud.deth[1]) & RVT_QPN_MASK, 457 be32_to_cpu(eh->ud.deth[1]) >> 458 HFI1_IPOIB_ENTROPY_SHIFT); 459 break; 460 case OP(UD, SEND_ONLY_WITH_IMMEDIATE): 461 trace_seq_printf(p, DETH_PRN, 462 be32_to_cpu(eh->ud.deth[0]), 463 be32_to_cpu(eh->ud.deth[1]) & RVT_QPN_MASK); 464 break; 465 /* ieth */ 466 case OP(RC, SEND_LAST_WITH_INVALIDATE): 467 case OP(RC, SEND_ONLY_WITH_INVALIDATE): 468 trace_seq_printf(p, IETH_PRN, 469 be32_to_cpu(eh->ieth)); 470 break; 471 } 472 out: 473 trace_seq_putc(p, 0); 474 return ret; 475 } 476 477 const char *parse_sdma_flags( 478 struct trace_seq *p, 479 u64 desc0, u64 desc1) 480 { 481 const char *ret = trace_seq_buffer_ptr(p); 482 char flags[5] = { 'x', 'x', 'x', 'x', 0 }; 483 484 flags[0] = (desc1 & SDMA_DESC1_INT_REQ_FLAG) ? 'I' : '-'; 485 flags[1] = (desc1 & SDMA_DESC1_HEAD_TO_HOST_FLAG) ? 'H' : '-'; 486 flags[2] = (desc0 & SDMA_DESC0_FIRST_DESC_FLAG) ? 'F' : '-'; 487 flags[3] = (desc0 & SDMA_DESC0_LAST_DESC_FLAG) ? 'L' : '-'; 488 trace_seq_printf(p, "%s", flags); 489 if (desc0 & SDMA_DESC0_FIRST_DESC_FLAG) 490 trace_seq_printf(p, " amode:%u aidx:%u alen:%u", 491 (u8)((desc1 >> SDMA_DESC1_HEADER_MODE_SHIFT) & 492 SDMA_DESC1_HEADER_MODE_MASK), 493 (u8)((desc1 >> SDMA_DESC1_HEADER_INDEX_SHIFT) & 494 SDMA_DESC1_HEADER_INDEX_MASK), 495 (u8)((desc1 >> SDMA_DESC1_HEADER_DWS_SHIFT) & 496 SDMA_DESC1_HEADER_DWS_MASK)); 497 return ret; 498 } 499 500 const char *print_u32_array( 501 struct trace_seq *p, 502 u32 *arr, int len) 503 { 504 int i; 505 const char *ret = trace_seq_buffer_ptr(p); 506 507 for (i = 0; i < len ; i++) 508 trace_seq_printf(p, "%s%#x", i == 0 ? "" : " ", arr[i]); 509 trace_seq_putc(p, 0); 510 return ret; 511 } 512 513 u8 hfi1_trace_get_tid_ctrl(u32 ent) 514 { 515 return EXP_TID_GET(ent, CTRL); 516 } 517 518 u16 hfi1_trace_get_tid_len(u32 ent) 519 { 520 return EXP_TID_GET(ent, LEN); 521 } 522 523 u16 hfi1_trace_get_tid_idx(u32 ent) 524 { 525 return EXP_TID_GET(ent, IDX); 526 } 527 528 struct hfi1_ctxt_hist { 529 atomic_t count; 530 atomic_t data[255]; 531 }; 532 533 struct hfi1_ctxt_hist hist = { 534 .count = ATOMIC_INIT(0) 535 }; 536 537 const char *hfi1_trace_print_rsm_hist(struct trace_seq *p, unsigned int ctxt) 538 { 539 int i, len = ARRAY_SIZE(hist.data); 540 const char *ret = trace_seq_buffer_ptr(p); 541 unsigned long packet_count = atomic_fetch_inc(&hist.count); 542 543 trace_seq_printf(p, "packet[%lu]", packet_count); 544 for (i = 0; i < len; ++i) { 545 unsigned long val; 546 atomic_t *count = &hist.data[i]; 547 548 if (ctxt == i) 549 val = atomic_fetch_inc(count); 550 else 551 val = atomic_read(count); 552 553 if (val) 554 trace_seq_printf(p, "(%d:%lu)", i, val); 555 } 556 trace_seq_putc(p, 0); 557 return ret; 558 } 559 560 __hfi1_trace_fn(AFFINITY); 561 __hfi1_trace_fn(PKT); 562 __hfi1_trace_fn(PROC); 563 __hfi1_trace_fn(SDMA); 564 __hfi1_trace_fn(LINKVERB); 565 __hfi1_trace_fn(DEBUG); 566 __hfi1_trace_fn(SNOOP); 567 __hfi1_trace_fn(CNTR); 568 __hfi1_trace_fn(PIO); 569 __hfi1_trace_fn(DC8051); 570 __hfi1_trace_fn(FIRMWARE); 571 __hfi1_trace_fn(RCVCTRL); 572 __hfi1_trace_fn(TID); 573 __hfi1_trace_fn(MMU); 574 __hfi1_trace_fn(IOCTL); 575