1 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
2 /*
3  * Copyright(c) 2016 Intel Corporation.
4  */
5 #if !defined(__RVT_TRACE_TX_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define __RVT_TRACE_TX_H
7 
8 #include <linux/tracepoint.h>
9 #include <linux/trace_seq.h>
10 
11 #include <rdma/ib_verbs.h>
12 #include <rdma/rdmavt_qp.h>
13 
14 #undef TRACE_SYSTEM
15 #define TRACE_SYSTEM rvt_tx
16 
17 #define wr_opcode_name(opcode) { IB_WR_##opcode, #opcode  }
18 #define show_wr_opcode(opcode)                             \
19 __print_symbolic(opcode,                                   \
20 	wr_opcode_name(RDMA_WRITE),                        \
21 	wr_opcode_name(RDMA_WRITE_WITH_IMM),               \
22 	wr_opcode_name(SEND),                              \
23 	wr_opcode_name(SEND_WITH_IMM),                     \
24 	wr_opcode_name(RDMA_READ),                         \
25 	wr_opcode_name(ATOMIC_CMP_AND_SWP),                \
26 	wr_opcode_name(ATOMIC_FETCH_AND_ADD),              \
27 	wr_opcode_name(LSO),                               \
28 	wr_opcode_name(SEND_WITH_INV),                     \
29 	wr_opcode_name(RDMA_READ_WITH_INV),                \
30 	wr_opcode_name(LOCAL_INV),                         \
31 	wr_opcode_name(MASKED_ATOMIC_CMP_AND_SWP),         \
32 	wr_opcode_name(MASKED_ATOMIC_FETCH_AND_ADD),       \
33 	wr_opcode_name(RESERVED1),                         \
34 	wr_opcode_name(RESERVED2),                         \
35 	wr_opcode_name(RESERVED3),                         \
36 	wr_opcode_name(RESERVED4),                         \
37 	wr_opcode_name(RESERVED5),                         \
38 	wr_opcode_name(RESERVED6),                         \
39 	wr_opcode_name(RESERVED7),                         \
40 	wr_opcode_name(RESERVED8),                         \
41 	wr_opcode_name(RESERVED9),                         \
42 	wr_opcode_name(RESERVED10))
43 
44 #define POS_PRN \
45 "[%s] wqe %p wr_id %llx send_flags %x qpn %x qpt %u psn %x lpsn %x ssn %x length %u opcode 0x%.2x,%s size %u avail %u head %u last %u pid %u num_sge %u wr_num_sge %u"
46 
47 TRACE_EVENT(
48 	rvt_post_one_wr,
49 	TP_PROTO(struct rvt_qp *qp, struct rvt_swqe *wqe, int wr_num_sge),
50 	TP_ARGS(qp, wqe, wr_num_sge),
51 	TP_STRUCT__entry(
52 		RDI_DEV_ENTRY(ib_to_rvt(qp->ibqp.device))
53 		__field(u64, wr_id)
54 		__field(struct rvt_swqe *, wqe)
55 		__field(u32, qpn)
56 		__field(u32, qpt)
57 		__field(u32, psn)
58 		__field(u32, lpsn)
59 		__field(u32, length)
60 		__field(u32, opcode)
61 		__field(u32, size)
62 		__field(u32, avail)
63 		__field(u32, head)
64 		__field(u32, last)
65 		__field(u32, ssn)
66 		__field(int, send_flags)
67 		__field(pid_t, pid)
68 		__field(int, num_sge)
69 		__field(int, wr_num_sge)
70 	),
71 	TP_fast_assign(
72 		RDI_DEV_ASSIGN(ib_to_rvt(qp->ibqp.device));
73 		__entry->wqe = wqe;
74 		__entry->wr_id = wqe->wr.wr_id;
75 		__entry->qpn = qp->ibqp.qp_num;
76 		__entry->qpt = qp->ibqp.qp_type;
77 		__entry->psn = wqe->psn;
78 		__entry->lpsn = wqe->lpsn;
79 		__entry->length = wqe->length;
80 		__entry->opcode = wqe->wr.opcode;
81 		__entry->size = qp->s_size;
82 		__entry->avail = qp->s_avail;
83 		__entry->head = qp->s_head;
84 		__entry->last = qp->s_last;
85 		__entry->pid = qp->pid;
86 		__entry->ssn = wqe->ssn;
87 		__entry->send_flags = wqe->wr.send_flags;
88 		__entry->num_sge = wqe->wr.num_sge;
89 		__entry->wr_num_sge = wr_num_sge;
90 	),
91 	TP_printk(
92 		POS_PRN,
93 		__get_str(dev),
94 		__entry->wqe,
95 		__entry->wr_id,
96 		__entry->send_flags,
97 		__entry->qpn,
98 		__entry->qpt,
99 		__entry->psn,
100 		__entry->lpsn,
101 		__entry->ssn,
102 		__entry->length,
103 		__entry->opcode, show_wr_opcode(__entry->opcode),
104 		__entry->size,
105 		__entry->avail,
106 		__entry->head,
107 		__entry->last,
108 		__entry->pid,
109 		__entry->num_sge,
110 		__entry->wr_num_sge
111 	)
112 );
113 
114 TRACE_EVENT(
115 	rvt_qp_send_completion,
116 	TP_PROTO(struct rvt_qp *qp, struct rvt_swqe *wqe, u32 idx),
117 	TP_ARGS(qp, wqe, idx),
118 	TP_STRUCT__entry(
119 		RDI_DEV_ENTRY(ib_to_rvt(qp->ibqp.device))
120 		__field(struct rvt_swqe *, wqe)
121 		__field(u64, wr_id)
122 		__field(u32, qpn)
123 		__field(u32, qpt)
124 		__field(u32, length)
125 		__field(u32, idx)
126 		__field(u32, ssn)
127 		__field(enum ib_wr_opcode, opcode)
128 		__field(int, send_flags)
129 	),
130 	TP_fast_assign(
131 		RDI_DEV_ASSIGN(ib_to_rvt(qp->ibqp.device));
132 		__entry->wqe = wqe;
133 		__entry->wr_id = wqe->wr.wr_id;
134 		__entry->qpn = qp->ibqp.qp_num;
135 		__entry->qpt = qp->ibqp.qp_type;
136 		__entry->length = wqe->length;
137 		__entry->idx = idx;
138 		__entry->ssn = wqe->ssn;
139 		__entry->opcode = wqe->wr.opcode;
140 		__entry->send_flags = wqe->wr.send_flags;
141 	),
142 	TP_printk(
143 		"[%s] qpn 0x%x qpt %u wqe %p idx %u wr_id %llx length %u ssn %u opcode %x send_flags %x",
144 		__get_str(dev),
145 		__entry->qpn,
146 		__entry->qpt,
147 		__entry->wqe,
148 		__entry->idx,
149 		__entry->wr_id,
150 		__entry->length,
151 		__entry->ssn,
152 		__entry->opcode,
153 		__entry->send_flags
154 	)
155 );
156 #endif /* __RVT_TRACE_TX_H */
157 
158 #undef TRACE_INCLUDE_PATH
159 #undef TRACE_INCLUDE_FILE
160 #define TRACE_INCLUDE_PATH .
161 #define TRACE_INCLUDE_FILE trace_tx
162 #include <trace/define_trace.h>
163 
164