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_create, 107 TP_PROTO( 108 const struct rdma_id_private *id_priv 109 ), 110 111 TP_ARGS(id_priv), 112 113 TP_STRUCT__entry( 114 __field(u32, cm_id) 115 ), 116 117 TP_fast_assign( 118 __entry->cm_id = id_priv->res.id; 119 ), 120 121 TP_printk("cm.id=%u", 122 __entry->cm_id 123 ) 124 ); 125 126 DECLARE_EVENT_CLASS(cma_qp_class, 127 TP_PROTO( 128 const struct rdma_id_private *id_priv 129 ), 130 131 TP_ARGS(id_priv), 132 133 TP_STRUCT__entry( 134 __field(u32, cm_id) 135 __field(u32, tos) 136 __field(u32, qp_num) 137 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 138 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 139 ), 140 141 TP_fast_assign( 142 __entry->cm_id = id_priv->res.id; 143 __entry->tos = id_priv->tos; 144 __entry->qp_num = id_priv->qp_num; 145 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 146 sizeof(struct sockaddr_in6)); 147 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 148 sizeof(struct sockaddr_in6)); 149 ), 150 151 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u qp_num=%u", 152 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 153 __entry->qp_num 154 ) 155 ); 156 157 #define DEFINE_CMA_QP_EVENT(name) \ 158 DEFINE_EVENT(cma_qp_class, cm_##name, \ 159 TP_PROTO( \ 160 const struct rdma_id_private *id_priv \ 161 ), \ 162 TP_ARGS(id_priv)) 163 164 DEFINE_CMA_QP_EVENT(send_req); 165 DEFINE_CMA_QP_EVENT(send_rep); 166 DEFINE_CMA_QP_EVENT(qp_destroy); 167 168 /* 169 * enum ib_wp_type, from include/rdma/ib_verbs.h 170 */ 171 #define IB_QP_TYPE_LIST \ 172 ib_qp_type(SMI) \ 173 ib_qp_type(GSI) \ 174 ib_qp_type(RC) \ 175 ib_qp_type(UC) \ 176 ib_qp_type(UD) \ 177 ib_qp_type(RAW_IPV6) \ 178 ib_qp_type(RAW_ETHERTYPE) \ 179 ib_qp_type(RAW_PACKET) \ 180 ib_qp_type(XRC_INI) \ 181 ib_qp_type_end(XRC_TGT) 182 183 #undef ib_qp_type 184 #undef ib_qp_type_end 185 186 #define ib_qp_type(x) TRACE_DEFINE_ENUM(IB_QPT_##x); 187 #define ib_qp_type_end(x) TRACE_DEFINE_ENUM(IB_QPT_##x); 188 189 IB_QP_TYPE_LIST 190 191 #undef ib_qp_type 192 #undef ib_qp_type_end 193 194 #define ib_qp_type(x) { IB_QPT_##x, #x }, 195 #define ib_qp_type_end(x) { IB_QPT_##x, #x } 196 197 #define rdma_show_qp_type(x) \ 198 __print_symbolic(x, IB_QP_TYPE_LIST) 199 200 201 TRACE_EVENT(cm_qp_create, 202 TP_PROTO( 203 const struct rdma_id_private *id_priv, 204 const struct ib_pd *pd, 205 const struct ib_qp_init_attr *qp_init_attr, 206 int rc 207 ), 208 209 TP_ARGS(id_priv, pd, qp_init_attr, rc), 210 211 TP_STRUCT__entry( 212 __field(u32, cm_id) 213 __field(u32, pd_id) 214 __field(u32, tos) 215 __field(u32, qp_num) 216 __field(u32, send_wr) 217 __field(u32, recv_wr) 218 __field(int, rc) 219 __field(unsigned long, qp_type) 220 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 221 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 222 ), 223 224 TP_fast_assign( 225 __entry->cm_id = id_priv->res.id; 226 __entry->pd_id = pd->res.id; 227 __entry->tos = id_priv->tos; 228 __entry->send_wr = qp_init_attr->cap.max_send_wr; 229 __entry->recv_wr = qp_init_attr->cap.max_recv_wr; 230 __entry->rc = rc; 231 if (!rc) { 232 __entry->qp_num = id_priv->qp_num; 233 __entry->qp_type = id_priv->id.qp_type; 234 } else { 235 __entry->qp_num = 0; 236 __entry->qp_type = 0; 237 } 238 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 239 sizeof(struct sockaddr_in6)); 240 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 241 sizeof(struct sockaddr_in6)); 242 ), 243 244 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u pd.id=%u qp_type=%s" 245 " send_wr=%u recv_wr=%u qp_num=%u rc=%d", 246 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, 247 __entry->tos, __entry->pd_id, 248 rdma_show_qp_type(__entry->qp_type), __entry->send_wr, 249 __entry->recv_wr, __entry->qp_num, __entry->rc 250 ) 251 ); 252 253 TRACE_EVENT(cm_req_handler, 254 TP_PROTO( 255 const struct rdma_id_private *id_priv, 256 int event 257 ), 258 259 TP_ARGS(id_priv, event), 260 261 TP_STRUCT__entry( 262 __field(u32, cm_id) 263 __field(u32, tos) 264 __field(unsigned long, event) 265 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 266 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 267 ), 268 269 TP_fast_assign( 270 __entry->cm_id = id_priv->res.id; 271 __entry->tos = id_priv->tos; 272 __entry->event = event; 273 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 274 sizeof(struct sockaddr_in6)); 275 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 276 sizeof(struct sockaddr_in6)); 277 ), 278 279 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s (%lu)", 280 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 281 rdma_show_ib_cm_event(__entry->event), __entry->event 282 ) 283 ); 284 285 TRACE_EVENT(cm_event_handler, 286 TP_PROTO( 287 const struct rdma_id_private *id_priv, 288 const struct rdma_cm_event *event 289 ), 290 291 TP_ARGS(id_priv, event), 292 293 TP_STRUCT__entry( 294 __field(u32, cm_id) 295 __field(u32, tos) 296 __field(unsigned long, event) 297 __field(int, status) 298 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 299 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 300 ), 301 302 TP_fast_assign( 303 __entry->cm_id = id_priv->res.id; 304 __entry->tos = id_priv->tos; 305 __entry->event = event->event; 306 __entry->status = event->status; 307 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 308 sizeof(struct sockaddr_in6)); 309 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 310 sizeof(struct sockaddr_in6)); 311 ), 312 313 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s (%lu/%d)", 314 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 315 rdma_show_cm_event(__entry->event), __entry->event, 316 __entry->status 317 ) 318 ); 319 320 TRACE_EVENT(cm_event_done, 321 TP_PROTO( 322 const struct rdma_id_private *id_priv, 323 const struct rdma_cm_event *event, 324 int result 325 ), 326 327 TP_ARGS(id_priv, event, result), 328 329 TP_STRUCT__entry( 330 __field(u32, cm_id) 331 __field(u32, tos) 332 __field(unsigned long, event) 333 __field(int, result) 334 __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) 335 __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) 336 ), 337 338 TP_fast_assign( 339 __entry->cm_id = id_priv->res.id; 340 __entry->tos = id_priv->tos; 341 __entry->event = event->event; 342 __entry->result = result; 343 memcpy(__entry->srcaddr, &id_priv->id.route.addr.src_addr, 344 sizeof(struct sockaddr_in6)); 345 memcpy(__entry->dstaddr, &id_priv->id.route.addr.dst_addr, 346 sizeof(struct sockaddr_in6)); 347 ), 348 349 TP_printk("cm.id=%u src=%pISpc dst=%pISpc tos=%u %s consumer returns %d", 350 __entry->cm_id, __entry->srcaddr, __entry->dstaddr, __entry->tos, 351 rdma_show_cm_event(__entry->event), __entry->result 352 ) 353 ); 354 355 DECLARE_EVENT_CLASS(cma_client_class, 356 TP_PROTO( 357 const struct ib_device *device 358 ), 359 360 TP_ARGS(device), 361 362 TP_STRUCT__entry( 363 __string(name, device->name) 364 ), 365 366 TP_fast_assign( 367 __assign_str(name, device->name); 368 ), 369 370 TP_printk("device name=%s", 371 __get_str(name) 372 ) 373 ); 374 375 #define DEFINE_CMA_CLIENT_EVENT(name) \ 376 DEFINE_EVENT(cma_client_class, cm_##name, \ 377 TP_PROTO( \ 378 const struct ib_device *device \ 379 ), \ 380 TP_ARGS(device)) 381 382 DEFINE_CMA_CLIENT_EVENT(add_one); 383 DEFINE_CMA_CLIENT_EVENT(remove_one); 384 385 #endif /* _TRACE_RDMA_CMA_H */ 386 387 #undef TRACE_INCLUDE_PATH 388 #define TRACE_INCLUDE_PATH . 389 #define TRACE_INCLUDE_FILE cma_trace 390 391 #include <trace/define_trace.h> 392