xref: /linux/drivers/infiniband/sw/rdmavt/trace_cq.h (revision 6beeaf48db6c548fcfc2ad32739d33af2fef3a5b)
1 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
2 /*
3  * Copyright(c) 2016 - 2018 Intel Corporation.
4  */
5 #if !defined(__RVT_TRACE_CQ_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define __RVT_TRACE_CQ_H
7 
8 #include <linux/tracepoint.h>
9 #include <linux/trace_seq.h>
10 
11 #include <rdma/ib_verbs.h>
12 #include <rdma/rdmavt_cq.h>
13 
14 #undef TRACE_SYSTEM
15 #define TRACE_SYSTEM rvt_cq
16 
17 #define wc_opcode_name(opcode) { IB_WC_##opcode, #opcode  }
18 #define show_wc_opcode(opcode)                                \
19 __print_symbolic(opcode,                                      \
20 	wc_opcode_name(SEND),                                 \
21 	wc_opcode_name(RDMA_WRITE),                           \
22 	wc_opcode_name(RDMA_READ),                            \
23 	wc_opcode_name(COMP_SWAP),                            \
24 	wc_opcode_name(FETCH_ADD),                            \
25 	wc_opcode_name(LSO),                                  \
26 	wc_opcode_name(LOCAL_INV),                            \
27 	wc_opcode_name(REG_MR),                               \
28 	wc_opcode_name(MASKED_COMP_SWAP),                     \
29 	wc_opcode_name(RECV),                                 \
30 	wc_opcode_name(RECV_RDMA_WITH_IMM))
31 
32 #define CQ_ATTR_PRINT \
33 "[%s] user cq %s cqe %u comp_vector %d comp_vector_cpu %d flags %x"
34 
35 DECLARE_EVENT_CLASS(rvt_cq_template,
36 		    TP_PROTO(struct rvt_cq *cq,
37 			     const struct ib_cq_init_attr *attr),
38 		    TP_ARGS(cq, attr),
39 		    TP_STRUCT__entry(RDI_DEV_ENTRY(cq->rdi)
40 				     __field(struct rvt_mmap_info *, ip)
41 				     __field(unsigned int, cqe)
42 				     __field(int, comp_vector)
43 				     __field(int, comp_vector_cpu)
44 				     __field(u32, flags)
45 				     ),
46 		    TP_fast_assign(RDI_DEV_ASSIGN(cq->rdi);
47 				   __entry->ip = cq->ip;
48 				   __entry->cqe = attr->cqe;
49 				   __entry->comp_vector = attr->comp_vector;
50 				   __entry->comp_vector_cpu =
51 							cq->comp_vector_cpu;
52 				   __entry->flags = attr->flags;
53 				   ),
54 		    TP_printk(CQ_ATTR_PRINT, __get_str(dev),
55 			      __entry->ip ? "true" : "false", __entry->cqe,
56 			      __entry->comp_vector, __entry->comp_vector_cpu,
57 			      __entry->flags
58 			      )
59 );
60 
61 DEFINE_EVENT(rvt_cq_template, rvt_create_cq,
62 	     TP_PROTO(struct rvt_cq *cq, const struct ib_cq_init_attr *attr),
63 	     TP_ARGS(cq, attr));
64 
65 #define CQ_PRN \
66 "[%s] idx %u wr_id %llx status %u opcode %u,%s length %u qpn %x flags %x imm %x"
67 
68 DECLARE_EVENT_CLASS(
69 	rvt_cq_entry_template,
70 	TP_PROTO(struct rvt_cq *cq, struct ib_wc *wc, u32 idx),
71 	TP_ARGS(cq, wc, idx),
72 	TP_STRUCT__entry(
73 		RDI_DEV_ENTRY(cq->rdi)
74 		__field(u64, wr_id)
75 		__field(u32, status)
76 		__field(u32, opcode)
77 		__field(u32, qpn)
78 		__field(u32, length)
79 		__field(u32, idx)
80 		__field(u32, flags)
81 		__field(u32, imm)
82 	),
83 	TP_fast_assign(
84 		RDI_DEV_ASSIGN(cq->rdi);
85 		__entry->wr_id = wc->wr_id;
86 		__entry->status = wc->status;
87 		__entry->opcode = wc->opcode;
88 		__entry->length = wc->byte_len;
89 		__entry->qpn = wc->qp->qp_num;
90 		__entry->idx = idx;
91 		__entry->flags = wc->wc_flags;
92 		__entry->imm = be32_to_cpu(wc->ex.imm_data);
93 	),
94 	TP_printk(
95 		CQ_PRN,
96 		__get_str(dev),
97 		__entry->idx,
98 		__entry->wr_id,
99 		__entry->status,
100 		__entry->opcode, show_wc_opcode(__entry->opcode),
101 		__entry->length,
102 		__entry->qpn,
103 		__entry->flags,
104 		__entry->imm
105 	)
106 );
107 
108 DEFINE_EVENT(
109 	rvt_cq_entry_template, rvt_cq_enter,
110 	TP_PROTO(struct rvt_cq *cq, struct ib_wc *wc, u32 idx),
111 	TP_ARGS(cq, wc, idx));
112 
113 DEFINE_EVENT(
114 	rvt_cq_entry_template, rvt_cq_poll,
115 	TP_PROTO(struct rvt_cq *cq, struct ib_wc *wc, u32 idx),
116 	TP_ARGS(cq, wc, idx));
117 
118 #endif /* __RVT_TRACE_CQ_H */
119 
120 #undef TRACE_INCLUDE_PATH
121 #undef TRACE_INCLUDE_FILE
122 #define TRACE_INCLUDE_PATH .
123 #define TRACE_INCLUDE_FILE trace_cq
124 #include <trace/define_trace.h>
125