1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Trace point definitions for the RDMA Connect Manager. 4 * 5 * Author: Chuck Lever <chuck.lever@oracle.com> 6 * 7 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 8 */ 9 10 #undef TRACE_SYSTEM 11 #define TRACE_SYSTEM rdma_cma 12 13 #if !defined(_TRACE_RDMA_CMA_H) || defined(TRACE_HEADER_MULTI_READ) 14 15 #define _TRACE_RDMA_CMA_H 16 17 #include <linux/tracepoint.h> 18 #include <trace/events/rdma.h> 19 20 /* 21 * enum ib_cm_event_type, from include/rdma/ib_cm.h 22 */ 23 #define IB_CM_EVENT_LIST \ 24 ib_cm_event(REQ_ERROR) \ 25 ib_cm_event(REQ_RECEIVED) \ 26 ib_cm_event(REP_ERROR) \ 27 ib_cm_event(REP_RECEIVED) \ 28 ib_cm_event(RTU_RECEIVED) \ 29 ib_cm_event(USER_ESTABLISHED) \ 30 ib_cm_event(DREQ_ERROR) \ 31 ib_cm_event(DREQ_RECEIVED) \ 32 ib_cm_event(DREP_RECEIVED) \ 33 ib_cm_event(TIMEWAIT_EXIT) \ 34 ib_cm_event(MRA_RECEIVED) \ 35 ib_cm_event(REJ_RECEIVED) \ 36 ib_cm_event(LAP_ERROR) \ 37 ib_cm_event(LAP_RECEIVED) \ 38 ib_cm_event(APR_RECEIVED) \ 39 ib_cm_event(SIDR_REQ_ERROR) \ 40 ib_cm_event(SIDR_REQ_RECEIVED) \ 41 ib_cm_event_end(SIDR_REP_RECEIVED) 42 43 #undef ib_cm_event 44 #undef ib_cm_event_end 45 46 #define ib_cm_event(x) TRACE_DEFINE_ENUM(IB_CM_##x); 47 #define ib_cm_event_end(x) TRACE_DEFINE_ENUM(IB_CM_##x); 48 49 IB_CM_EVENT_LIST 50 51 #undef ib_cm_event 52 #undef ib_cm_event_end 53 54 #define ib_cm_event(x) { IB_CM_##x, #x }, 55 #define ib_cm_event_end(x) { IB_CM_##x, #x } 56 57 #define rdma_show_ib_cm_event(x) \ 58 __print_symbolic(x, IB_CM_EVENT_LIST) 59 60 61 DECLARE_EVENT_CLASS(cma_fsm_class, 62 TP_PROTO( 63 const struct rdma_id_private *id_priv 64 ), 65 66 TP_ARGS(id_priv), 67 68 TP_STRUCT__entry( 69 __field(u32, cm_id) 70 __field(u32, tos) 71 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 72 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 73 ), 74 75 TP_fast_assign( 76 __entry->cm_id = id_priv->res.id; 77 __entry->tos = id_priv->tos; 78 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 79 sizeof(struct sockaddr_in6)); 80 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 81 sizeof(struct sockaddr_in6)); 82 ), 83 84 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u", 85 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos 86 ) 87 ); 88 89 #define DEFINE_CMA_FSM_EVENT(name) \ 90 DEFINE_EVENT(cma_fsm_class, cm_##name, \ 91 TP_PROTO( \ 92 const struct rdma_id_private *id_priv \ 93 ), \ 94 TP_ARGS(id_priv)) 95 96 DEFINE_CMA_FSM_EVENT(send_rtu); 97 DEFINE_CMA_FSM_EVENT(send_rej); 98 DEFINE_CMA_FSM_EVENT(send_mra); 99 DEFINE_CMA_FSM_EVENT(send_sidr_req); 100 DEFINE_CMA_FSM_EVENT(send_sidr_rep); 101 DEFINE_CMA_FSM_EVENT(disconnect); 102 DEFINE_CMA_FSM_EVENT(sent_drep); 103 DEFINE_CMA_FSM_EVENT(sent_dreq); 104 DEFINE_CMA_FSM_EVENT(id_destroy); 105 106 TRACE_EVENT(cm_id_attach, 107 TP_PROTO( 108 const struct rdma_id_private *id_priv, 109 const struct ib_device *device 110 ), 111 112 TP_ARGS(id_priv, device), 113 114 TP_STRUCT__entry( 115 __field(u32, cm_id) 116 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 117 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 118 __string(devname, device->name) 119 ), 120 121 TP_fast_assign( 122 __entry->cm_id = id_priv->res.id; 123 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 124 sizeof(struct sockaddr_in6)); 125 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 126 sizeof(struct sockaddr_in6)); 127 __assign_str(devname, device->name); 128 ), 129 130 TP_printk("cm.id=%u src=%pISpc dst=%pISpc device=%s", 131 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, 132 __get_str(devname) 133 ) 134 ); 135 136 DECLARE_EVENT_CLASS(cma_qp_class, 137 TP_PROTO( 138 const struct rdma_id_private *id_priv 139 ), 140 141 TP_ARGS(id_priv), 142 143 TP_STRUCT__entry( 144 __field(u32, cm_id) 145 __field(u32, tos) 146 __field(u32, qp_num) 147 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 148 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 149 ), 150 151 TP_fast_assign( 152 __entry->cm_id = id_priv->res.id; 153 __entry->tos = id_priv->tos; 154 __entry->qp_num = id_priv->qp_num; 155 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 156 sizeof(struct sockaddr_in6)); 157 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 158 sizeof(struct sockaddr_in6)); 159 ), 160 161 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u qp_num=%u", 162 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 163 __entry->qp_num 164 ) 165 ); 166 167 #define DEFINE_CMA_QP_EVENT(name) \ 168 DEFINE_EVENT(cma_qp_class, cm_##name, \ 169 TP_PROTO( \ 170 const struct rdma_id_private *id_priv \ 171 ), \ 172 TP_ARGS(id_priv)) 173 174 DEFINE_CMA_QP_EVENT(send_req); 175 DEFINE_CMA_QP_EVENT(send_rep); 176 DEFINE_CMA_QP_EVENT(qp_destroy); 177 178 /* 179 * enum ib_wp_type, from include/rdma/ib_verbs.h 180 */ 181 #define IB_QP_TYPE_LIST \ 182 ib_qp_type(SMI) \ 183 ib_qp_type(GSI) \ 184 ib_qp_type(RC) \ 185 ib_qp_type(UC) \ 186 ib_qp_type(UD) \ 187 ib_qp_type(RAW_IPV6) \ 188 ib_qp_type(RAW_ETHERTYPE) \ 189 ib_qp_type(RAW_PACKET) \ 190 ib_qp_type(XRC_INI) \ 191 ib_qp_type_end(XRC_TGT) 192 193 #undef ib_qp_type 194 #undef ib_qp_type_end 195 196 #define ib_qp_type(x) TRACE_DEFINE_ENUM(IB_QPT_##x); 197 #define ib_qp_type_end(x) TRACE_DEFINE_ENUM(IB_QPT_##x); 198 199 IB_QP_TYPE_LIST 200 201 #undef ib_qp_type 202 #undef ib_qp_type_end 203 204 #define ib_qp_type(x) { IB_QPT_##x, #x }, 205 #define ib_qp_type_end(x) { IB_QPT_##x, #x } 206 207 #define rdma_show_qp_type(x) \ 208 __print_symbolic(x, IB_QP_TYPE_LIST) 209 210 211 TRACE_EVENT(cm_qp_create, 212 TP_PROTO( 213 const struct rdma_id_private *id_priv, 214 const struct ib_pd *pd, 215 const struct ib_qp_init_attr *qp_init_attr, 216 int rc 217 ), 218 219 TP_ARGS(id_priv, pd, qp_init_attr, rc), 220 221 TP_STRUCT__entry( 222 __field(u32, cm_id) 223 __field(u32, pd_id) 224 __field(u32, tos) 225 __field(u32, qp_num) 226 __field(u32, send_wr) 227 __field(u32, recv_wr) 228 __field(int, rc) 229 __field(unsigned long, qp_type) 230 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 231 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 232 ), 233 234 TP_fast_assign( 235 __entry->cm_id = id_priv->res.id; 236 __entry->pd_id = pd->res.id; 237 __entry->tos = id_priv->tos; 238 __entry->send_wr = qp_init_attr->cap.max_send_wr; 239 __entry->recv_wr = qp_init_attr->cap.max_recv_wr; 240 __entry->rc = rc; 241 if (!rc) { 242 __entry->qp_num = id_priv->qp_num; 243 __entry->qp_type = id_priv->id.qp_type; 244 } else { 245 __entry->qp_num = 0; 246 __entry->qp_type = 0; 247 } 248 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 249 sizeof(struct sockaddr_in6)); 250 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 251 sizeof(struct sockaddr_in6)); 252 ), 253 254 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u pd.id=%u qp_type=%s" 255 " send_wr=%u recv_wr=%u qp_num=%u rc=%d", 256 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, 257 __entry->tos, __entry->pd_id, 258 rdma_show_qp_type(__entry->qp_type), __entry->send_wr, 259 __entry->recv_wr, __entry->qp_num, __entry->rc 260 ) 261 ); 262 263 TRACE_EVENT(cm_req_handler, 264 TP_PROTO( 265 const struct rdma_id_private *id_priv, 266 int event 267 ), 268 269 TP_ARGS(id_priv, event), 270 271 TP_STRUCT__entry( 272 __field(u32, cm_id) 273 __field(u32, tos) 274 __field(unsigned long, event) 275 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 276 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 277 ), 278 279 TP_fast_assign( 280 __entry->cm_id = id_priv->res.id; 281 __entry->tos = id_priv->tos; 282 __entry->event = event; 283 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 284 sizeof(struct sockaddr_in6)); 285 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 286 sizeof(struct sockaddr_in6)); 287 ), 288 289 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s (%lu)", 290 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 291 rdma_show_ib_cm_event(__entry->event), __entry->event 292 ) 293 ); 294 295 TRACE_EVENT(cm_event_handler, 296 TP_PROTO( 297 const struct rdma_id_private *id_priv, 298 const struct rdma_cm_event *event 299 ), 300 301 TP_ARGS(id_priv, event), 302 303 TP_STRUCT__entry( 304 __field(u32, cm_id) 305 __field(u32, tos) 306 __field(unsigned long, event) 307 __field(int, status) 308 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 309 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 310 ), 311 312 TP_fast_assign( 313 __entry->cm_id = id_priv->res.id; 314 __entry->tos = id_priv->tos; 315 __entry->event = event->event; 316 __entry->status = event->status; 317 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 318 sizeof(struct sockaddr_in6)); 319 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 320 sizeof(struct sockaddr_in6)); 321 ), 322 323 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s (%lu/%d)", 324 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 325 rdma_show_cm_event(__entry->event), __entry->event, 326 __entry->status 327 ) 328 ); 329 330 TRACE_EVENT(cm_event_done, 331 TP_PROTO( 332 const struct rdma_id_private *id_priv, 333 const struct rdma_cm_event *event, 334 int result 335 ), 336 337 TP_ARGS(id_priv, event, result), 338 339 TP_STRUCT__entry( 340 __field(u32, cm_id) 341 __field(u32, tos) 342 __field(unsigned long, event) 343 __field(int, result) 344 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 345 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 346 ), 347 348 TP_fast_assign( 349 __entry->cm_id = id_priv->res.id; 350 __entry->tos = id_priv->tos; 351 __entry->event = event->event; 352 __entry->result = result; 353 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 354 sizeof(struct sockaddr_in6)); 355 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 356 sizeof(struct sockaddr_in6)); 357 ), 358 359 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s consumer returns %d", 360 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 361 rdma_show_cm_event(__entry->event), __entry->result 362 ) 363 ); 364 365 DECLARE_EVENT_CLASS(cma_client_class, 366 TP_PROTO( 367 const struct ib_device *device 368 ), 369 370 TP_ARGS(device), 371 372 TP_STRUCT__entry( 373 __string(name, device->name) 374 ), 375 376 TP_fast_assign( 377 __assign_str(name, device->name); 378 ), 379 380 TP_printk("device name=%s", 381 __get_str(name) 382 ) 383 ); 384 385 #define DEFINE_CMA_CLIENT_EVENT(name) \ 386 DEFINE_EVENT(cma_client_class, cm_##name, \ 387 TP_PROTO( \ 388 const struct ib_device *device \ 389 ), \ 390 TP_ARGS(device)) 391 392 DEFINE_CMA_CLIENT_EVENT(add_one); 393 DEFINE_CMA_CLIENT_EVENT(remove_one); 394 395 #endif /* _TRACE_RDMA_CMA_H */ 396 397 #undef TRACE_INCLUDE_PATH 398 #define TRACE_INCLUDE_PATH . 399 #define TRACE_INCLUDE_FILE cma_trace 400 401 #include <trace/define_trace.h> 402