• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * RDMA Network Block Driver
4  *
5  * Copyright (c) 2022 1&1 IONOS SE. All rights reserved.
6  */
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM rnbd_srv
9 
10 #if !defined(_TRACE_RNBD_SRV_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _TRACE_RNBD_SRV_H
12 
13 #include <linux/tracepoint.h>
14 
15 struct rnbd_srv_session;
16 struct rtrs_srv_op;
17 
18 DECLARE_EVENT_CLASS(rnbd_srv_link_class,
19 	TP_PROTO(struct rnbd_srv_session *srv),
20 
21 	TP_ARGS(srv),
22 
23 	TP_STRUCT__entry(
24 		__field(int, qdepth)
25 		__string(sessname, srv->sessname)
26 	),
27 
28 	TP_fast_assign(
29 		__entry->qdepth = srv->queue_depth;
30 		__assign_str(sessname, srv->sessname);
31 	),
32 
33 	TP_printk("sessname: %s qdepth: %d",
34 		   __get_str(sessname),
35 		   __entry->qdepth
36 	)
37 );
38 
39 #define DEFINE_LINK_EVENT(name) \
40 DEFINE_EVENT(rnbd_srv_link_class, name, \
41 	TP_PROTO(struct rnbd_srv_session *srv), \
42 	TP_ARGS(srv))
43 
44 DEFINE_LINK_EVENT(create_sess);
45 DEFINE_LINK_EVENT(destroy_sess);
46 
47 TRACE_DEFINE_ENUM(RNBD_OP_READ);
48 TRACE_DEFINE_ENUM(RNBD_OP_WRITE);
49 TRACE_DEFINE_ENUM(RNBD_OP_FLUSH);
50 TRACE_DEFINE_ENUM(RNBD_OP_DISCARD);
51 TRACE_DEFINE_ENUM(RNBD_OP_SECURE_ERASE);
52 TRACE_DEFINE_ENUM(RNBD_F_SYNC);
53 TRACE_DEFINE_ENUM(RNBD_F_FUA);
54 
55 #define show_rnbd_rw_flags(x) \
56 	__print_flags(x, "|", \
57 		{ RNBD_OP_READ,		"READ" }, \
58 		{ RNBD_OP_WRITE,	"WRITE" }, \
59 		{ RNBD_OP_FLUSH,	"FLUSH" }, \
60 		{ RNBD_OP_DISCARD,	"DISCARD" }, \
61 		{ RNBD_OP_SECURE_ERASE,	"SECURE_ERASE" }, \
62 		{ RNBD_F_SYNC,		"SYNC" }, \
63 		{ RNBD_F_FUA,		"FUA" })
64 
65 TRACE_EVENT(process_rdma,
66 	TP_PROTO(struct rnbd_srv_session *srv,
67 		 const struct rnbd_msg_io *msg,
68 		 struct rtrs_srv_op *id,
69 		 u32 datalen,
70 		 size_t usrlen),
71 
72 	TP_ARGS(srv, msg, id, datalen, usrlen),
73 
74 	TP_STRUCT__entry(
75 		__string(sessname, srv->sessname)
76 		__field(u8, dir)
77 		__field(u8, ver)
78 		__field(u32, device_id)
79 		__field(u64, sector)
80 		__field(u32, flags)
81 		__field(u32, bi_size)
82 		__field(u16, ioprio)
83 		__field(u32, datalen)
84 		__field(size_t, usrlen)
85 	),
86 
87 	TP_fast_assign(
88 		__assign_str(sessname, srv->sessname);
89 		__entry->dir = id->dir;
90 		__entry->ver = srv->ver;
91 		__entry->device_id = le32_to_cpu(msg->device_id);
92 		__entry->sector = le64_to_cpu(msg->sector);
93 		__entry->bi_size = le32_to_cpu(msg->bi_size);
94 		__entry->flags = le32_to_cpu(msg->rw);
95 		__entry->ioprio = le16_to_cpu(msg->prio);
96 		__entry->datalen = datalen;
97 		__entry->usrlen = usrlen;
98 	),
99 
100 	TP_printk("I/O req: sess: %s, type: %s, ver: %d, devid: %u, sector: %llu, bsize: %u, flags: %s, ioprio: %d, datalen: %u, usrlen: %zu",
101 		   __get_str(sessname),
102 		   __print_symbolic(__entry->dir,
103 			 { READ,  "READ" },
104 			 { WRITE, "WRITE" }),
105 		   __entry->ver,
106 		   __entry->device_id,
107 		   __entry->sector,
108 		   __entry->bi_size,
109 		   show_rnbd_rw_flags(__entry->flags),
110 		   __entry->ioprio,
111 		   __entry->datalen,
112 		   __entry->usrlen
113 	)
114 );
115 
116 TRACE_EVENT(process_msg_sess_info,
117 	TP_PROTO(struct rnbd_srv_session *srv,
118 		 const struct rnbd_msg_sess_info *msg),
119 
120 	TP_ARGS(srv, msg),
121 
122 	TP_STRUCT__entry(
123 		__field(u8, proto_ver)
124 		__field(u8, clt_ver)
125 		__field(u8, srv_ver)
126 		__string(sessname, srv->sessname)
127 	),
128 
129 	TP_fast_assign(
130 		__entry->proto_ver = srv->ver;
131 		__entry->clt_ver = msg->ver;
132 		__entry->srv_ver = RNBD_PROTO_VER_MAJOR;
133 		__assign_str(sessname, srv->sessname);
134 	),
135 
136 	TP_printk("Session %s using proto-ver %d (clt-ver: %d, srv-ver: %d)",
137 		   __get_str(sessname),
138 		   __entry->proto_ver,
139 		   __entry->clt_ver,
140 		   __entry->srv_ver
141 	)
142 );
143 
144 TRACE_DEFINE_ENUM(RNBD_ACCESS_RO);
145 TRACE_DEFINE_ENUM(RNBD_ACCESS_RW);
146 TRACE_DEFINE_ENUM(RNBD_ACCESS_MIGRATION);
147 
148 #define show_rnbd_access_mode(x) \
149 	__print_symbolic(x, \
150 		{ RNBD_ACCESS_RO,		"RO" }, \
151 		{ RNBD_ACCESS_RW,		"RW" }, \
152 		{ RNBD_ACCESS_MIGRATION,	"MIGRATION" })
153 
154 TRACE_EVENT(process_msg_open,
155 	TP_PROTO(struct rnbd_srv_session *srv,
156 		 const struct rnbd_msg_open *msg),
157 
158 	TP_ARGS(srv, msg),
159 
160 	TP_STRUCT__entry(
161 		__field(u8, access_mode)
162 		__string(sessname, srv->sessname)
163 		__string(dev_name, msg->dev_name)
164 	),
165 
166 	TP_fast_assign(
167 		__entry->access_mode = msg->access_mode;
168 		__assign_str(sessname, srv->sessname);
169 		__assign_str(dev_name, msg->dev_name);
170 	),
171 
172 	TP_printk("Open message received: session='%s' path='%s' access_mode=%s",
173 		   __get_str(sessname),
174 		   __get_str(dev_name),
175 		   show_rnbd_access_mode(__entry->access_mode)
176 	)
177 );
178 
179 TRACE_EVENT(process_msg_close,
180 	TP_PROTO(struct rnbd_srv_session *srv,
181 		 const struct rnbd_msg_close *msg),
182 
183 	TP_ARGS(srv, msg),
184 
185 	TP_STRUCT__entry(
186 		__field(u32, device_id)
187 		__string(sessname, srv->sessname)
188 	),
189 
190 	TP_fast_assign(
191 		__entry->device_id = le32_to_cpu(msg->device_id);
192 		__assign_str(sessname, srv->sessname);
193 	),
194 
195 	TP_printk("Close message received: session='%s' device id='%d'",
196 		   __get_str(sessname),
197 		   __entry->device_id
198 	)
199 );
200 
201 #endif /* _TRACE_RNBD_SRV_H */
202 
203 #undef TRACE_INCLUDE_PATH
204 #define TRACE_INCLUDE_PATH .
205 #define TRACE_INCLUDE_FILE rnbd-srv-trace
206 #include <trace/define_trace.h>
207 
208