18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright(c) 2016 - 2018 Intel Corporation.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
58c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
108c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as
118c2ecf20Sopenharmony_ci * published by the Free Software Foundation.
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
148c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
158c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
168c2ecf20Sopenharmony_ci * General Public License for more details.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * BSD LICENSE
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
218c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
228c2ecf20Sopenharmony_ci * are met:
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci *  - Redistributions of source code must retain the above copyright
258c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
268c2ecf20Sopenharmony_ci *  - Redistributions in binary form must reproduce the above copyright
278c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
288c2ecf20Sopenharmony_ci *    the documentation and/or other materials provided with the
298c2ecf20Sopenharmony_ci *    distribution.
308c2ecf20Sopenharmony_ci *  - Neither the name of Intel Corporation nor the names of its
318c2ecf20Sopenharmony_ci *    contributors may be used to endorse or promote products derived
328c2ecf20Sopenharmony_ci *    from this software without specific prior written permission.
338c2ecf20Sopenharmony_ci *
348c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
358c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
368c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
378c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
388c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
398c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
408c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
418c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
428c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
438c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
448c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
458c2ecf20Sopenharmony_ci *
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_ci#if !defined(__RVT_TRACE_CQ_H) || defined(TRACE_HEADER_MULTI_READ)
488c2ecf20Sopenharmony_ci#define __RVT_TRACE_CQ_H
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
518c2ecf20Sopenharmony_ci#include <linux/trace_seq.h>
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h>
548c2ecf20Sopenharmony_ci#include <rdma/rdmavt_cq.h>
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM
578c2ecf20Sopenharmony_ci#define TRACE_SYSTEM rvt_cq
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define wc_opcode_name(opcode) { IB_WC_##opcode, #opcode  }
608c2ecf20Sopenharmony_ci#define show_wc_opcode(opcode)                                \
618c2ecf20Sopenharmony_ci__print_symbolic(opcode,                                      \
628c2ecf20Sopenharmony_ci	wc_opcode_name(SEND),                                 \
638c2ecf20Sopenharmony_ci	wc_opcode_name(RDMA_WRITE),                           \
648c2ecf20Sopenharmony_ci	wc_opcode_name(RDMA_READ),                            \
658c2ecf20Sopenharmony_ci	wc_opcode_name(COMP_SWAP),                            \
668c2ecf20Sopenharmony_ci	wc_opcode_name(FETCH_ADD),                            \
678c2ecf20Sopenharmony_ci	wc_opcode_name(LSO),                                  \
688c2ecf20Sopenharmony_ci	wc_opcode_name(LOCAL_INV),                            \
698c2ecf20Sopenharmony_ci	wc_opcode_name(REG_MR),                               \
708c2ecf20Sopenharmony_ci	wc_opcode_name(MASKED_COMP_SWAP),                     \
718c2ecf20Sopenharmony_ci	wc_opcode_name(RECV),                                 \
728c2ecf20Sopenharmony_ci	wc_opcode_name(RECV_RDMA_WITH_IMM))
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define CQ_ATTR_PRINT \
758c2ecf20Sopenharmony_ci"[%s] user cq %s cqe %u comp_vector %d comp_vector_cpu %d flags %x"
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(rvt_cq_template,
788c2ecf20Sopenharmony_ci		    TP_PROTO(struct rvt_cq *cq,
798c2ecf20Sopenharmony_ci			     const struct ib_cq_init_attr *attr),
808c2ecf20Sopenharmony_ci		    TP_ARGS(cq, attr),
818c2ecf20Sopenharmony_ci		    TP_STRUCT__entry(RDI_DEV_ENTRY(cq->rdi)
828c2ecf20Sopenharmony_ci				     __field(struct rvt_mmap_info *, ip)
838c2ecf20Sopenharmony_ci				     __field(unsigned int, cqe)
848c2ecf20Sopenharmony_ci				     __field(int, comp_vector)
858c2ecf20Sopenharmony_ci				     __field(int, comp_vector_cpu)
868c2ecf20Sopenharmony_ci				     __field(u32, flags)
878c2ecf20Sopenharmony_ci				     ),
888c2ecf20Sopenharmony_ci		    TP_fast_assign(RDI_DEV_ASSIGN(cq->rdi)
898c2ecf20Sopenharmony_ci				   __entry->ip = cq->ip;
908c2ecf20Sopenharmony_ci				   __entry->cqe = attr->cqe;
918c2ecf20Sopenharmony_ci				   __entry->comp_vector = attr->comp_vector;
928c2ecf20Sopenharmony_ci				   __entry->comp_vector_cpu =
938c2ecf20Sopenharmony_ci							cq->comp_vector_cpu;
948c2ecf20Sopenharmony_ci				   __entry->flags = attr->flags;
958c2ecf20Sopenharmony_ci				   ),
968c2ecf20Sopenharmony_ci		    TP_printk(CQ_ATTR_PRINT, __get_str(dev),
978c2ecf20Sopenharmony_ci			      __entry->ip ? "true" : "false", __entry->cqe,
988c2ecf20Sopenharmony_ci			      __entry->comp_vector, __entry->comp_vector_cpu,
998c2ecf20Sopenharmony_ci			      __entry->flags
1008c2ecf20Sopenharmony_ci			      )
1018c2ecf20Sopenharmony_ci);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ciDEFINE_EVENT(rvt_cq_template, rvt_create_cq,
1048c2ecf20Sopenharmony_ci	     TP_PROTO(struct rvt_cq *cq, const struct ib_cq_init_attr *attr),
1058c2ecf20Sopenharmony_ci	     TP_ARGS(cq, attr));
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define CQ_PRN \
1088c2ecf20Sopenharmony_ci"[%s] idx %u wr_id %llx status %u opcode %u,%s length %u qpn %x flags %x imm %x"
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ciDECLARE_EVENT_CLASS(
1118c2ecf20Sopenharmony_ci	rvt_cq_entry_template,
1128c2ecf20Sopenharmony_ci	TP_PROTO(struct rvt_cq *cq, struct ib_wc *wc, u32 idx),
1138c2ecf20Sopenharmony_ci	TP_ARGS(cq, wc, idx),
1148c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
1158c2ecf20Sopenharmony_ci		RDI_DEV_ENTRY(cq->rdi)
1168c2ecf20Sopenharmony_ci		__field(u64, wr_id)
1178c2ecf20Sopenharmony_ci		__field(u32, status)
1188c2ecf20Sopenharmony_ci		__field(u32, opcode)
1198c2ecf20Sopenharmony_ci		__field(u32, qpn)
1208c2ecf20Sopenharmony_ci		__field(u32, length)
1218c2ecf20Sopenharmony_ci		__field(u32, idx)
1228c2ecf20Sopenharmony_ci		__field(u32, flags)
1238c2ecf20Sopenharmony_ci		__field(u32, imm)
1248c2ecf20Sopenharmony_ci	),
1258c2ecf20Sopenharmony_ci	TP_fast_assign(
1268c2ecf20Sopenharmony_ci		RDI_DEV_ASSIGN(cq->rdi)
1278c2ecf20Sopenharmony_ci		__entry->wr_id = wc->wr_id;
1288c2ecf20Sopenharmony_ci		__entry->status = wc->status;
1298c2ecf20Sopenharmony_ci		__entry->opcode = wc->opcode;
1308c2ecf20Sopenharmony_ci		__entry->length = wc->byte_len;
1318c2ecf20Sopenharmony_ci		__entry->qpn = wc->qp->qp_num;
1328c2ecf20Sopenharmony_ci		__entry->idx = idx;
1338c2ecf20Sopenharmony_ci		__entry->flags = wc->wc_flags;
1348c2ecf20Sopenharmony_ci		__entry->imm = be32_to_cpu(wc->ex.imm_data);
1358c2ecf20Sopenharmony_ci	),
1368c2ecf20Sopenharmony_ci	TP_printk(
1378c2ecf20Sopenharmony_ci		CQ_PRN,
1388c2ecf20Sopenharmony_ci		__get_str(dev),
1398c2ecf20Sopenharmony_ci		__entry->idx,
1408c2ecf20Sopenharmony_ci		__entry->wr_id,
1418c2ecf20Sopenharmony_ci		__entry->status,
1428c2ecf20Sopenharmony_ci		__entry->opcode, show_wc_opcode(__entry->opcode),
1438c2ecf20Sopenharmony_ci		__entry->length,
1448c2ecf20Sopenharmony_ci		__entry->qpn,
1458c2ecf20Sopenharmony_ci		__entry->flags,
1468c2ecf20Sopenharmony_ci		__entry->imm
1478c2ecf20Sopenharmony_ci	)
1488c2ecf20Sopenharmony_ci);
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ciDEFINE_EVENT(
1518c2ecf20Sopenharmony_ci	rvt_cq_entry_template, rvt_cq_enter,
1528c2ecf20Sopenharmony_ci	TP_PROTO(struct rvt_cq *cq, struct ib_wc *wc, u32 idx),
1538c2ecf20Sopenharmony_ci	TP_ARGS(cq, wc, idx));
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ciDEFINE_EVENT(
1568c2ecf20Sopenharmony_ci	rvt_cq_entry_template, rvt_cq_poll,
1578c2ecf20Sopenharmony_ci	TP_PROTO(struct rvt_cq *cq, struct ib_wc *wc, u32 idx),
1588c2ecf20Sopenharmony_ci	TP_ARGS(cq, wc, idx));
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#endif /* __RVT_TRACE_CQ_H */
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_PATH
1638c2ecf20Sopenharmony_ci#undef TRACE_INCLUDE_FILE
1648c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_PATH .
1658c2ecf20Sopenharmony_ci#define TRACE_INCLUDE_FILE trace_cq
1668c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
167