linux/drivers/infiniband/hw/hfi1/trace_ibhdrs.h
<<
>>
Prefs
   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
  50#include <linux/tracepoint.h>
  51#include <linux/trace_seq.h>
  52
  53#include "hfi.h"
  54
  55#undef TRACE_SYSTEM
  56#define TRACE_SYSTEM hfi1_ibhdrs
  57
  58#define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode  }
  59#define show_ib_opcode(opcode)                             \
  60__print_symbolic(opcode,                                   \
  61        ib_opcode_name(RC_SEND_FIRST),                     \
  62        ib_opcode_name(RC_SEND_MIDDLE),                    \
  63        ib_opcode_name(RC_SEND_LAST),                      \
  64        ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE),       \
  65        ib_opcode_name(RC_SEND_ONLY),                      \
  66        ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE),       \
  67        ib_opcode_name(RC_RDMA_WRITE_FIRST),               \
  68        ib_opcode_name(RC_RDMA_WRITE_MIDDLE),              \
  69        ib_opcode_name(RC_RDMA_WRITE_LAST),                \
  70        ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  71        ib_opcode_name(RC_RDMA_WRITE_ONLY),                \
  72        ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  73        ib_opcode_name(RC_RDMA_READ_REQUEST),              \
  74        ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST),       \
  75        ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE),      \
  76        ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST),        \
  77        ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY),        \
  78        ib_opcode_name(RC_ACKNOWLEDGE),                    \
  79        ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE),             \
  80        ib_opcode_name(RC_COMPARE_SWAP),                   \
  81        ib_opcode_name(RC_FETCH_ADD),                      \
  82        ib_opcode_name(RC_SEND_LAST_WITH_INVALIDATE),      \
  83        ib_opcode_name(RC_SEND_ONLY_WITH_INVALIDATE),      \
  84        ib_opcode_name(TID_RDMA_WRITE_REQ),                \
  85        ib_opcode_name(TID_RDMA_WRITE_RESP),               \
  86        ib_opcode_name(TID_RDMA_WRITE_DATA),               \
  87        ib_opcode_name(TID_RDMA_WRITE_DATA_LAST),          \
  88        ib_opcode_name(TID_RDMA_READ_REQ),                 \
  89        ib_opcode_name(TID_RDMA_READ_RESP),                \
  90        ib_opcode_name(TID_RDMA_RESYNC),                   \
  91        ib_opcode_name(TID_RDMA_ACK),                      \
  92        ib_opcode_name(UC_SEND_FIRST),                     \
  93        ib_opcode_name(UC_SEND_MIDDLE),                    \
  94        ib_opcode_name(UC_SEND_LAST),                      \
  95        ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE),       \
  96        ib_opcode_name(UC_SEND_ONLY),                      \
  97        ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE),       \
  98        ib_opcode_name(UC_RDMA_WRITE_FIRST),               \
  99        ib_opcode_name(UC_RDMA_WRITE_MIDDLE),              \
 100        ib_opcode_name(UC_RDMA_WRITE_LAST),                \
 101        ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
 102        ib_opcode_name(UC_RDMA_WRITE_ONLY),                \
 103        ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
 104        ib_opcode_name(UD_SEND_ONLY),                      \
 105        ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),       \
 106        ib_opcode_name(CNP))
 107
 108u8 ibhdr_exhdr_len(struct ib_header *hdr);
 109const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode,
 110                              u8 l4, u32 dest_qpn, u32 src_qpn,
 111                              void *ehdrs);
 112u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opah);
 113u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet);
 114const char *hfi1_trace_get_packet_l4_str(u8 l4);
 115void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr,
 116                             u8 *ack, bool *becn, bool *fecn, u8 *mig,
 117                             u8 *se, u8 *pad, u8 *opcode, u8 *tver,
 118                             u16 *pkey, u32 *psn, u32 *qpn);
 119void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5,
 120                             u8 *lnh, u8 *lver, u8 *sl, u8 *sc,
 121                             u16 *len, u32 *dlid, u32 *slid);
 122void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr,
 123                              u8 *ack, u8 *mig, u8 *opcode,
 124                              u8 *pad, u8 *se, u8 *tver,
 125                              u32 *psn, u32 *qpn);
 126void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr,
 127                              u8 *age, bool *becn, bool *fecn,
 128                              u8 *l4, u8 *rc, u8 *sc,
 129                              u16 *entropy, u16 *len, u16 *pkey,
 130                              u32 *dlid, u32 *slid);
 131
 132const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass,
 133                               u8 age, bool becn, bool fecn, u8 l4,
 134                               u8 lnh, const char *lnh_name, u8 lver,
 135                               u8 rc, u8 sc, u8 sl, u16 entropy,
 136                               u16 len, u16 pkey, u32 dlid, u32 slid);
 137
 138const char *hfi1_trace_fmt_rest(struct trace_seq *p, bool bypass, u8 l4,
 139                                u8 ack, bool becn, bool fecn, u8 mig,
 140                                u8 se, u8 pad, u8 opcode, const char *opname,
 141                                u8 tver, u16 pkey, u32 psn, u32 qpn,
 142                                u32 dest_qpn, u32 src_qpn);
 143
 144const char *hfi1_trace_get_packet_l2_str(u8 l2);
 145
 146#define __parse_ib_ehdrs(op, l4, dest_qpn, src_qpn, ehdrs) \
 147                         parse_everbs_hdrs(p, op, l4, dest_qpn, src_qpn, ehdrs)
 148
 149#define lrh_name(lrh) { HFI1_##lrh, #lrh }
 150#define show_lnh(lrh)                    \
 151__print_symbolic(lrh,                    \
 152        lrh_name(LRH_BTH),               \
 153        lrh_name(LRH_GRH))
 154
 155DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template,
 156                    TP_PROTO(struct hfi1_devdata *dd,
 157                             struct hfi1_packet *packet,
 158                             bool sc5),
 159                    TP_ARGS(dd, packet, sc5),
 160                    TP_STRUCT__entry(
 161                        DD_DEV_ENTRY(dd)
 162                        __field(u8, etype)
 163                        __field(u8, ack)
 164                        __field(u8, age)
 165                        __field(bool, becn)
 166                        __field(bool, fecn)
 167                        __field(u8, l2)
 168                        __field(u8, l4)
 169                        __field(u8, lnh)
 170                        __field(u8, lver)
 171                        __field(u8, mig)
 172                        __field(u8, opcode)
 173                        __field(u8, pad)
 174                        __field(u8, rc)
 175                        __field(u8, sc)
 176                        __field(u8, se)
 177                        __field(u8, sl)
 178                        __field(u8, tver)
 179                        __field(u16, entropy)
 180                        __field(u16, len)
 181                        __field(u16, pkey)
 182                        __field(u32, dlid)
 183                        __field(u32, psn)
 184                        __field(u32, qpn)
 185                        __field(u32, slid)
 186                        __field(u32, dest_qpn)
 187                        __field(u32, src_qpn)
 188                        /* extended headers */
 189                        __dynamic_array(u8, ehdrs,
 190                                        hfi1_trace_packet_hdr_len(packet))
 191                        ),
 192                    TP_fast_assign(
 193                        DD_DEV_ASSIGN(dd);
 194
 195                        __entry->etype = packet->etype;
 196                        __entry->l2 = hfi1_16B_get_l2(packet->hdr);
 197                        __entry->dest_qpn = 0;
 198                        __entry->src_qpn = 0;
 199                        if (__entry->etype == RHF_RCV_TYPE_BYPASS) {
 200                                hfi1_trace_parse_16b_hdr(packet->hdr,
 201                                                         &__entry->age,
 202                                                         &__entry->becn,
 203                                                         &__entry->fecn,
 204                                                         &__entry->l4,
 205                                                         &__entry->rc,
 206                                                         &__entry->sc,
 207                                                         &__entry->entropy,
 208                                                         &__entry->len,
 209                                                         &__entry->pkey,
 210                                                         &__entry->dlid,
 211                                                         &__entry->slid);
 212
 213                                if (__entry->l4 == OPA_16B_L4_FM) {
 214                                        __entry->opcode = IB_OPCODE_UD_SEND_ONLY;
 215                                        __entry->dest_qpn = hfi1_16B_get_dest_qpn(packet->mgmt);
 216                                        __entry->src_qpn = hfi1_16B_get_src_qpn(packet->mgmt);
 217                                }  else {
 218                                        hfi1_trace_parse_16b_bth(packet->ohdr,
 219                                                                 &__entry->ack,
 220                                                                 &__entry->mig,
 221                                                                 &__entry->opcode,
 222                                                                 &__entry->pad,
 223                                                                 &__entry->se,
 224                                                                 &__entry->tver,
 225                                                                 &__entry->psn,
 226                                                                 &__entry->qpn);
 227                                }
 228                        } else {
 229                                __entry->l4 = OPA_16B_L4_9B;
 230                                hfi1_trace_parse_9b_hdr(packet->hdr, sc5,
 231                                                        &__entry->lnh,
 232                                                        &__entry->lver,
 233                                                        &__entry->sl,
 234                                                        &__entry->sc,
 235                                                        &__entry->len,
 236                                                        &__entry->dlid,
 237                                                        &__entry->slid);
 238
 239                                  hfi1_trace_parse_9b_bth(packet->ohdr,
 240                                                          &__entry->ack,
 241                                                          &__entry->becn,
 242                                                          &__entry->fecn,
 243                                                          &__entry->mig,
 244                                                          &__entry->se,
 245                                                          &__entry->pad,
 246                                                          &__entry->opcode,
 247                                                          &__entry->tver,
 248                                                          &__entry->pkey,
 249                                                          &__entry->psn,
 250                                                          &__entry->qpn);
 251                        }
 252                        /* extended headers */
 253                        if (__entry->l4 != OPA_16B_L4_FM)
 254                                memcpy(__get_dynamic_array(ehdrs),
 255                                       &packet->ohdr->u,
 256                                       __get_dynamic_array_len(ehdrs));
 257                         ),
 258                    TP_printk("[%s] (%s) %s %s hlen:%d %s",
 259                              __get_str(dev),
 260                              __entry->etype != RHF_RCV_TYPE_BYPASS ?
 261                                        show_packettype(__entry->etype) :
 262                                        hfi1_trace_get_packet_l2_str(
 263                                                __entry->l2),
 264                              hfi1_trace_fmt_lrh(p,
 265                                                 __entry->etype ==
 266                                                        RHF_RCV_TYPE_BYPASS,
 267                                                 __entry->age,
 268                                                 __entry->becn,
 269                                                 __entry->fecn,
 270                                                 __entry->l4,
 271                                                 __entry->lnh,
 272                                                 show_lnh(__entry->lnh),
 273                                                 __entry->lver,
 274                                                 __entry->rc,
 275                                                 __entry->sc,
 276                                                 __entry->sl,
 277                                                 __entry->entropy,
 278                                                 __entry->len,
 279                                                 __entry->pkey,
 280                                                 __entry->dlid,
 281                                                 __entry->slid),
 282                              hfi1_trace_fmt_rest(p,
 283                                                  __entry->etype ==
 284                                                        RHF_RCV_TYPE_BYPASS,
 285                                                  __entry->l4,
 286                                                  __entry->ack,
 287                                                  __entry->becn,
 288                                                  __entry->fecn,
 289                                                  __entry->mig,
 290                                                  __entry->se,
 291                                                  __entry->pad,
 292                                                  __entry->opcode,
 293                                                  show_ib_opcode(__entry->opcode),
 294                                                  __entry->tver,
 295                                                  __entry->pkey,
 296                                                  __entry->psn,
 297                                                  __entry->qpn,
 298                                                  __entry->dest_qpn,
 299                                                  __entry->src_qpn),
 300                              /* extended headers */
 301                              __get_dynamic_array_len(ehdrs),
 302                              __parse_ib_ehdrs(
 303                                        __entry->opcode,
 304                                        __entry->l4,
 305                                        __entry->dest_qpn,
 306                                        __entry->src_qpn,
 307                                        (void *)__get_dynamic_array(ehdrs))
 308                             )
 309);
 310
 311DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
 312             TP_PROTO(struct hfi1_devdata *dd,
 313                      struct hfi1_packet *packet, bool sc5),
 314             TP_ARGS(dd, packet, sc5));
 315
 316DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
 317                    TP_PROTO(struct hfi1_devdata *dd,
 318                             struct hfi1_opa_header *opah, bool sc5),
 319                    TP_ARGS(dd, opah, sc5),
 320                    TP_STRUCT__entry(
 321                        DD_DEV_ENTRY(dd)
 322                        __field(u8, hdr_type)
 323                        __field(u8, ack)
 324                        __field(u8, age)
 325                        __field(bool, becn)
 326                        __field(bool, fecn)
 327                        __field(u8, l4)
 328                        __field(u8, lnh)
 329                        __field(u8, lver)
 330                        __field(u8, mig)
 331                        __field(u8, opcode)
 332                        __field(u8, pad)
 333                        __field(u8, rc)
 334                        __field(u8, sc)
 335                        __field(u8, se)
 336                        __field(u8, sl)
 337                        __field(u8, tver)
 338                        __field(u16, entropy)
 339                        __field(u16, len)
 340                        __field(u16, pkey)
 341                        __field(u32, dlid)
 342                        __field(u32, psn)
 343                        __field(u32, qpn)
 344                        __field(u32, slid)
 345                        __field(u32, dest_qpn)
 346                        __field(u32, src_qpn)
 347                        /* extended headers */
 348                        __dynamic_array(u8, ehdrs,
 349                                        hfi1_trace_opa_hdr_len(opah))
 350                        ),
 351                    TP_fast_assign(
 352                        struct ib_other_headers *ohdr;
 353
 354                        DD_DEV_ASSIGN(dd);
 355
 356                        __entry->hdr_type = opah->hdr_type;
 357                        __entry->dest_qpn = 0;
 358                        __entry->src_qpn = 0;
 359                        if (__entry->hdr_type)  {
 360                                hfi1_trace_parse_16b_hdr(&opah->opah,
 361                                                         &__entry->age,
 362                                                         &__entry->becn,
 363                                                         &__entry->fecn,
 364                                                         &__entry->l4,
 365                                                         &__entry->rc,
 366                                                         &__entry->sc,
 367                                                         &__entry->entropy,
 368                                                         &__entry->len,
 369                                                         &__entry->pkey,
 370                                                         &__entry->dlid,
 371                                                         &__entry->slid);
 372
 373                                if (__entry->l4 == OPA_16B_L4_FM) {
 374                                        ohdr = NULL;
 375                                        __entry->opcode = IB_OPCODE_UD_SEND_ONLY;
 376                                        __entry->dest_qpn = hfi1_16B_get_dest_qpn(&opah->opah.u.mgmt);
 377                                        __entry->src_qpn = hfi1_16B_get_src_qpn(&opah->opah.u.mgmt);
 378                                } else {
 379                                        if (__entry->l4 == OPA_16B_L4_IB_LOCAL)
 380                                                ohdr = &opah->opah.u.oth;
 381                                        else
 382                                                ohdr = &opah->opah.u.l.oth;
 383                                        hfi1_trace_parse_16b_bth(ohdr,
 384                                                                 &__entry->ack,
 385                                                                 &__entry->mig,
 386                                                                 &__entry->opcode,
 387                                                                 &__entry->pad,
 388                                                                 &__entry->se,
 389                                                                 &__entry->tver,
 390                                                                 &__entry->psn,
 391                                                                 &__entry->qpn);
 392                                }
 393                        } else {
 394                                __entry->l4 = OPA_16B_L4_9B;
 395                                hfi1_trace_parse_9b_hdr(&opah->ibh, sc5,
 396                                                        &__entry->lnh,
 397                                                        &__entry->lver,
 398                                                        &__entry->sl,
 399                                                        &__entry->sc,
 400                                                        &__entry->len,
 401                                                        &__entry->dlid,
 402                                                        &__entry->slid);
 403                                if (__entry->lnh == HFI1_LRH_BTH)
 404                                        ohdr = &opah->ibh.u.oth;
 405                                else
 406                                        ohdr = &opah->ibh.u.l.oth;
 407                                hfi1_trace_parse_9b_bth(ohdr,
 408                                                        &__entry->ack,
 409                                                        &__entry->becn,
 410                                                        &__entry->fecn,
 411                                                        &__entry->mig,
 412                                                        &__entry->se,
 413                                                        &__entry->pad,
 414                                                        &__entry->opcode,
 415                                                        &__entry->tver,
 416                                                        &__entry->pkey,
 417                                                        &__entry->psn,
 418                                                        &__entry->qpn);
 419                        }
 420
 421                        /* extended headers */
 422                        if (__entry->l4 != OPA_16B_L4_FM)
 423                                memcpy(__get_dynamic_array(ehdrs),
 424                                       &ohdr->u, __get_dynamic_array_len(ehdrs));
 425                    ),
 426                    TP_printk("[%s] (%s) %s %s hlen:%d %s",
 427                              __get_str(dev),
 428                              hfi1_trace_get_packet_l4_str(__entry->l4),
 429                              hfi1_trace_fmt_lrh(p,
 430                                                 !!__entry->hdr_type,
 431                                                 __entry->age,
 432                                                 __entry->becn,
 433                                                 __entry->fecn,
 434                                                 __entry->l4,
 435                                                 __entry->lnh,
 436                                                 show_lnh(__entry->lnh),
 437                                                 __entry->lver,
 438                                                 __entry->rc,
 439                                                 __entry->sc,
 440                                                 __entry->sl,
 441                                                 __entry->entropy,
 442                                                 __entry->len,
 443                                                 __entry->pkey,
 444                                                 __entry->dlid,
 445                                                 __entry->slid),
 446                              hfi1_trace_fmt_rest(p,
 447                                                  !!__entry->hdr_type,
 448                                                  __entry->l4,
 449                                                  __entry->ack,
 450                                                  __entry->becn,
 451                                                  __entry->fecn,
 452                                                  __entry->mig,
 453                                                  __entry->se,
 454                                                  __entry->pad,
 455                                                  __entry->opcode,
 456                                                  show_ib_opcode(__entry->opcode),
 457                                                  __entry->tver,
 458                                                  __entry->pkey,
 459                                                  __entry->psn,
 460                                                  __entry->qpn,
 461                                                  __entry->dest_qpn,
 462                                                  __entry->src_qpn),
 463                              /* extended headers */
 464                              __get_dynamic_array_len(ehdrs),
 465                              __parse_ib_ehdrs(
 466                                        __entry->opcode,
 467                                        __entry->l4,
 468                                        __entry->dest_qpn,
 469                                        __entry->src_qpn,
 470                                        (void *)__get_dynamic_array(ehdrs))
 471                             )
 472);
 473
 474DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
 475             TP_PROTO(struct hfi1_devdata *dd,
 476                      struct hfi1_opa_header *opah, bool sc5),
 477             TP_ARGS(dd, opah, sc5));
 478
 479DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
 480             TP_PROTO(struct hfi1_devdata *dd,
 481                      struct hfi1_opa_header *opah, bool sc5),
 482             TP_ARGS(dd, opah, sc5));
 483
 484DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
 485             TP_PROTO(struct hfi1_devdata *dd,
 486                      struct hfi1_opa_header *opah, bool sc5),
 487             TP_ARGS(dd, opah, sc5));
 488
 489
 490#endif /* __HFI1_TRACE_IBHDRS_H */
 491
 492#undef TRACE_INCLUDE_PATH
 493#undef TRACE_INCLUDE_FILE
 494#define TRACE_INCLUDE_PATH .
 495#define TRACE_INCLUDE_FILE trace_ibhdrs
 496#include <trace/define_trace.h>
 497