1 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
2 /*
3  * Copyright(c) 2016 Intel Corporation.
4  */
5 #if !defined(__RVT_TRACE_MR_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define __RVT_TRACE_MR_H
7 
8 #include <linux/tracepoint.h>
9 #include <linux/trace_seq.h>
10 
11 #include <rdma/ib_verbs.h>
12 #include <rdma/rdma_vt.h>
13 #include <rdma/rdmavt_mr.h>
14 
15 #include "mr.h"
16 
17 #undef TRACE_SYSTEM
18 #define TRACE_SYSTEM rvt_mr
19 DECLARE_EVENT_CLASS(
20 	rvt_mr_template,
21 	TP_PROTO(struct rvt_mregion *mr, u16 m, u16 n, void *v, size_t len),
22 	TP_ARGS(mr, m, n, v, len),
23 	TP_STRUCT__entry(
24 		RDI_DEV_ENTRY(ib_to_rvt(mr->pd->device))
25 		__field(void *, vaddr)
26 		__field(struct page *, page)
27 		__field(u64, iova)
28 		__field(u64, user_base)
29 		__field(size_t, len)
30 		__field(size_t, length)
31 		__field(u32, lkey)
32 		__field(u32, offset)
33 		__field(u16, m)
34 		__field(u16, n)
35 	),
36 	TP_fast_assign(
37 		RDI_DEV_ASSIGN(ib_to_rvt(mr->pd->device));
38 		__entry->vaddr = v;
39 		__entry->page = virt_to_page(v);
40 		__entry->iova = mr->iova;
41 		__entry->user_base = mr->user_base;
42 		__entry->lkey = mr->lkey;
43 		__entry->m = m;
44 		__entry->n = n;
45 		__entry->len = len;
46 		__entry->length = mr->length;
47 		__entry->offset = mr->offset;
48 	),
49 	TP_printk(
50 		"[%s] lkey %x iova %llx user_base %llx mr_len %lu vaddr %llx page %p m %u n %u len %lu off %u",
51 		__get_str(dev),
52 		__entry->lkey,
53 		__entry->iova,
54 		__entry->user_base,
55 		__entry->length,
56 		(unsigned long long)__entry->vaddr,
57 		__entry->page,
58 		__entry->m,
59 		__entry->n,
60 		__entry->len,
61 		__entry->offset
62 	)
63 );
64 
65 DEFINE_EVENT(
66 	rvt_mr_template, rvt_mr_page_seg,
67 	TP_PROTO(struct rvt_mregion *mr, u16 m, u16 n, void *v, size_t len),
68 	TP_ARGS(mr, m, n, v, len));
69 
70 DEFINE_EVENT(
71 	rvt_mr_template, rvt_mr_fmr_seg,
72 	TP_PROTO(struct rvt_mregion *mr, u16 m, u16 n, void *v, size_t len),
73 	TP_ARGS(mr, m, n, v, len));
74 
75 DEFINE_EVENT(
76 	rvt_mr_template, rvt_mr_user_seg,
77 	TP_PROTO(struct rvt_mregion *mr, u16 m, u16 n, void *v, size_t len),
78 	TP_ARGS(mr, m, n, v, len));
79 
80 DECLARE_EVENT_CLASS(
81 	rvt_sge_template,
82 	TP_PROTO(struct rvt_sge *sge, struct ib_sge *isge),
83 	TP_ARGS(sge, isge),
84 	TP_STRUCT__entry(
85 		RDI_DEV_ENTRY(ib_to_rvt(sge->mr->pd->device))
86 		__field(struct rvt_mregion *, mr)
87 		__field(struct rvt_sge *, sge)
88 		__field(struct ib_sge *, isge)
89 		__field(void *, vaddr)
90 		__field(u64, ivaddr)
91 		__field(u32, lkey)
92 		__field(u32, sge_length)
93 		__field(u32, length)
94 		__field(u32, ilength)
95 		__field(int, user)
96 		__field(u16, m)
97 		__field(u16, n)
98 	),
99 	TP_fast_assign(
100 		RDI_DEV_ASSIGN(ib_to_rvt(sge->mr->pd->device));
101 		__entry->mr = sge->mr;
102 		__entry->sge = sge;
103 		__entry->isge = isge;
104 		__entry->vaddr = sge->vaddr;
105 		__entry->ivaddr = isge->addr;
106 		__entry->lkey = sge->mr->lkey;
107 		__entry->sge_length = sge->sge_length;
108 		__entry->length = sge->length;
109 		__entry->ilength = isge->length;
110 		__entry->m = sge->m;
111 		__entry->n = sge->m;
112 		__entry->user = ibpd_to_rvtpd(sge->mr->pd)->user;
113 	),
114 	TP_printk(
115 		"[%s] mr %p sge %p isge %p vaddr %p ivaddr %llx lkey %x sge_length %u length %u ilength %u m %u n %u user %u",
116 		__get_str(dev),
117 		__entry->mr,
118 		__entry->sge,
119 		__entry->isge,
120 		__entry->vaddr,
121 		__entry->ivaddr,
122 		__entry->lkey,
123 		__entry->sge_length,
124 		__entry->length,
125 		__entry->ilength,
126 		__entry->m,
127 		__entry->n,
128 		__entry->user
129 	)
130 );
131 
132 DEFINE_EVENT(
133 	rvt_sge_template, rvt_sge_adjacent,
134 	TP_PROTO(struct rvt_sge *sge, struct ib_sge *isge),
135 	TP_ARGS(sge, isge));
136 
137 DEFINE_EVENT(
138 	rvt_sge_template, rvt_sge_new,
139 	TP_PROTO(struct rvt_sge *sge, struct ib_sge *isge),
140 	TP_ARGS(sge, isge));
141 
142 TRACE_EVENT(
143 	rvt_map_mr_sg,
144 	TP_PROTO(struct ib_mr *ibmr, int sg_nents, unsigned int *sg_offset),
145 	TP_ARGS(ibmr, sg_nents, sg_offset),
146 	TP_STRUCT__entry(
147 		RDI_DEV_ENTRY(ib_to_rvt(to_imr(ibmr)->mr.pd->device))
148 		__field(u64, iova)
149 		__field(u64, ibmr_iova)
150 		__field(u64, user_base)
151 		__field(u64, ibmr_length)
152 		__field(int, sg_nents)
153 		__field(uint, sg_offset)
154 	),
155 	TP_fast_assign(
156 		RDI_DEV_ASSIGN(ib_to_rvt(to_imr(ibmr)->mr.pd->device));
157 		__entry->ibmr_iova = ibmr->iova;
158 		__entry->iova = to_imr(ibmr)->mr.iova;
159 		__entry->user_base = to_imr(ibmr)->mr.user_base;
160 		__entry->ibmr_length = to_imr(ibmr)->mr.length;
161 		__entry->sg_nents = sg_nents;
162 		__entry->sg_offset = sg_offset ? *sg_offset : 0;
163 	),
164 	TP_printk(
165 		"[%s] ibmr_iova %llx iova %llx user_base %llx length %llx sg_nents %d sg_offset %u",
166 		__get_str(dev),
167 		__entry->ibmr_iova,
168 		__entry->iova,
169 		__entry->user_base,
170 		__entry->ibmr_length,
171 		__entry->sg_nents,
172 		__entry->sg_offset
173 	)
174 );
175 
176 #endif /* __RVT_TRACE_MR_H */
177 
178 #undef TRACE_INCLUDE_PATH
179 #undef TRACE_INCLUDE_FILE
180 #define TRACE_INCLUDE_PATH .
181 #define TRACE_INCLUDE_FILE trace_mr
182 #include <trace/define_trace.h>
183