Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Trace point definitions for core RDMA functions.
0004  *
0005  * Author: Chuck Lever <chuck.lever@oracle.com>
0006  *
0007  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
0008  */
0009 
0010 #undef TRACE_SYSTEM
0011 #define TRACE_SYSTEM rdma_core
0012 
0013 #if !defined(_TRACE_RDMA_CORE_H) || defined(TRACE_HEADER_MULTI_READ)
0014 #define _TRACE_RDMA_CORE_H
0015 
0016 #include <linux/tracepoint.h>
0017 #include <rdma/ib_verbs.h>
0018 
0019 /*
0020  * enum ib_poll_context, from include/rdma/ib_verbs.h
0021  */
0022 #define IB_POLL_CTX_LIST            \
0023     ib_poll_ctx(DIRECT)         \
0024     ib_poll_ctx(SOFTIRQ)            \
0025     ib_poll_ctx(WORKQUEUE)          \
0026     ib_poll_ctx_end(UNBOUND_WORKQUEUE)
0027 
0028 #undef ib_poll_ctx
0029 #undef ib_poll_ctx_end
0030 
0031 #define ib_poll_ctx(x)      TRACE_DEFINE_ENUM(IB_POLL_##x);
0032 #define ib_poll_ctx_end(x)  TRACE_DEFINE_ENUM(IB_POLL_##x);
0033 
0034 IB_POLL_CTX_LIST
0035 
0036 #undef ib_poll_ctx
0037 #undef ib_poll_ctx_end
0038 
0039 #define ib_poll_ctx(x)      { IB_POLL_##x, #x },
0040 #define ib_poll_ctx_end(x)  { IB_POLL_##x, #x }
0041 
0042 #define rdma_show_ib_poll_ctx(x) \
0043         __print_symbolic(x, IB_POLL_CTX_LIST)
0044 
0045 /**
0046  ** Completion Queue events
0047  **/
0048 
0049 TRACE_EVENT(cq_schedule,
0050     TP_PROTO(
0051         struct ib_cq *cq
0052     ),
0053 
0054     TP_ARGS(cq),
0055 
0056     TP_STRUCT__entry(
0057         __field(u32, cq_id)
0058     ),
0059 
0060     TP_fast_assign(
0061         cq->timestamp = ktime_get();
0062         cq->interrupt = true;
0063 
0064         __entry->cq_id = cq->res.id;
0065     ),
0066 
0067     TP_printk("cq.id=%u", __entry->cq_id)
0068 );
0069 
0070 TRACE_EVENT(cq_reschedule,
0071     TP_PROTO(
0072         struct ib_cq *cq
0073     ),
0074 
0075     TP_ARGS(cq),
0076 
0077     TP_STRUCT__entry(
0078         __field(u32, cq_id)
0079     ),
0080 
0081     TP_fast_assign(
0082         cq->timestamp = ktime_get();
0083         cq->interrupt = false;
0084 
0085         __entry->cq_id = cq->res.id;
0086     ),
0087 
0088     TP_printk("cq.id=%u", __entry->cq_id)
0089 );
0090 
0091 TRACE_EVENT(cq_process,
0092     TP_PROTO(
0093         const struct ib_cq *cq
0094     ),
0095 
0096     TP_ARGS(cq),
0097 
0098     TP_STRUCT__entry(
0099         __field(u32, cq_id)
0100         __field(bool, interrupt)
0101         __field(s64, latency)
0102     ),
0103 
0104     TP_fast_assign(
0105         ktime_t latency = ktime_sub(ktime_get(), cq->timestamp);
0106 
0107         __entry->cq_id = cq->res.id;
0108         __entry->latency = ktime_to_us(latency);
0109         __entry->interrupt = cq->interrupt;
0110     ),
0111 
0112     TP_printk("cq.id=%u wake-up took %lld [us] from %s",
0113         __entry->cq_id, __entry->latency,
0114         __entry->interrupt ? "interrupt" : "reschedule"
0115     )
0116 );
0117 
0118 TRACE_EVENT(cq_poll,
0119     TP_PROTO(
0120         const struct ib_cq *cq,
0121         int requested,
0122         int rc
0123     ),
0124 
0125     TP_ARGS(cq, requested, rc),
0126 
0127     TP_STRUCT__entry(
0128         __field(u32, cq_id)
0129         __field(int, requested)
0130         __field(int, rc)
0131     ),
0132 
0133     TP_fast_assign(
0134         __entry->cq_id = cq->res.id;
0135         __entry->requested = requested;
0136         __entry->rc = rc;
0137     ),
0138 
0139     TP_printk("cq.id=%u requested %d, returned %d",
0140         __entry->cq_id, __entry->requested, __entry->rc
0141     )
0142 );
0143 
0144 TRACE_EVENT(cq_drain_complete,
0145     TP_PROTO(
0146         const struct ib_cq *cq
0147     ),
0148 
0149     TP_ARGS(cq),
0150 
0151     TP_STRUCT__entry(
0152         __field(u32, cq_id)
0153     ),
0154 
0155     TP_fast_assign(
0156         __entry->cq_id = cq->res.id;
0157     ),
0158 
0159     TP_printk("cq.id=%u",
0160         __entry->cq_id
0161     )
0162 );
0163 
0164 
0165 TRACE_EVENT(cq_modify,
0166     TP_PROTO(
0167         const struct ib_cq *cq,
0168         u16 comps,
0169         u16 usec
0170     ),
0171 
0172     TP_ARGS(cq, comps, usec),
0173 
0174     TP_STRUCT__entry(
0175         __field(u32, cq_id)
0176         __field(unsigned int, comps)
0177         __field(unsigned int, usec)
0178     ),
0179 
0180     TP_fast_assign(
0181         __entry->cq_id = cq->res.id;
0182         __entry->comps = comps;
0183         __entry->usec = usec;
0184     ),
0185 
0186     TP_printk("cq.id=%u comps=%u usec=%u",
0187         __entry->cq_id, __entry->comps, __entry->usec
0188     )
0189 );
0190 
0191 TRACE_EVENT(cq_alloc,
0192     TP_PROTO(
0193         const struct ib_cq *cq,
0194         int nr_cqe,
0195         int comp_vector,
0196         enum ib_poll_context poll_ctx
0197     ),
0198 
0199     TP_ARGS(cq, nr_cqe, comp_vector, poll_ctx),
0200 
0201     TP_STRUCT__entry(
0202         __field(u32, cq_id)
0203         __field(int, nr_cqe)
0204         __field(int, comp_vector)
0205         __field(unsigned long, poll_ctx)
0206     ),
0207 
0208     TP_fast_assign(
0209         __entry->cq_id = cq->res.id;
0210         __entry->nr_cqe = nr_cqe;
0211         __entry->comp_vector = comp_vector;
0212         __entry->poll_ctx = poll_ctx;
0213     ),
0214 
0215     TP_printk("cq.id=%u nr_cqe=%d comp_vector=%d poll_ctx=%s",
0216         __entry->cq_id, __entry->nr_cqe, __entry->comp_vector,
0217         rdma_show_ib_poll_ctx(__entry->poll_ctx)
0218     )
0219 );
0220 
0221 TRACE_EVENT(cq_alloc_error,
0222     TP_PROTO(
0223         int nr_cqe,
0224         int comp_vector,
0225         enum ib_poll_context poll_ctx,
0226         int rc
0227     ),
0228 
0229     TP_ARGS(nr_cqe, comp_vector, poll_ctx, rc),
0230 
0231     TP_STRUCT__entry(
0232         __field(int, rc)
0233         __field(int, nr_cqe)
0234         __field(int, comp_vector)
0235         __field(unsigned long, poll_ctx)
0236     ),
0237 
0238     TP_fast_assign(
0239         __entry->rc = rc;
0240         __entry->nr_cqe = nr_cqe;
0241         __entry->comp_vector = comp_vector;
0242         __entry->poll_ctx = poll_ctx;
0243     ),
0244 
0245     TP_printk("nr_cqe=%d comp_vector=%d poll_ctx=%s rc=%d",
0246         __entry->nr_cqe, __entry->comp_vector,
0247         rdma_show_ib_poll_ctx(__entry->poll_ctx), __entry->rc
0248     )
0249 );
0250 
0251 TRACE_EVENT(cq_free,
0252     TP_PROTO(
0253         const struct ib_cq *cq
0254     ),
0255 
0256     TP_ARGS(cq),
0257 
0258     TP_STRUCT__entry(
0259         __field(u32, cq_id)
0260     ),
0261 
0262     TP_fast_assign(
0263         __entry->cq_id = cq->res.id;
0264     ),
0265 
0266     TP_printk("cq.id=%u", __entry->cq_id)
0267 );
0268 
0269 /**
0270  ** Memory Region events
0271  **/
0272 
0273 /*
0274  * enum ib_mr_type, from include/rdma/ib_verbs.h
0275  */
0276 #define IB_MR_TYPE_LIST             \
0277     ib_mr_type_item(MEM_REG)        \
0278     ib_mr_type_item(SG_GAPS)        \
0279     ib_mr_type_item(DM)         \
0280     ib_mr_type_item(USER)           \
0281     ib_mr_type_item(DMA)            \
0282     ib_mr_type_end(INTEGRITY)
0283 
0284 #undef ib_mr_type_item
0285 #undef ib_mr_type_end
0286 
0287 #define ib_mr_type_item(x)  TRACE_DEFINE_ENUM(IB_MR_TYPE_##x);
0288 #define ib_mr_type_end(x)   TRACE_DEFINE_ENUM(IB_MR_TYPE_##x);
0289 
0290 IB_MR_TYPE_LIST
0291 
0292 #undef ib_mr_type_item
0293 #undef ib_mr_type_end
0294 
0295 #define ib_mr_type_item(x)  { IB_MR_TYPE_##x, #x },
0296 #define ib_mr_type_end(x)   { IB_MR_TYPE_##x, #x }
0297 
0298 #define rdma_show_ib_mr_type(x) \
0299         __print_symbolic(x, IB_MR_TYPE_LIST)
0300 
0301 TRACE_EVENT(mr_alloc,
0302     TP_PROTO(
0303         const struct ib_pd *pd,
0304         enum ib_mr_type mr_type,
0305         u32 max_num_sg,
0306         const struct ib_mr *mr
0307     ),
0308 
0309     TP_ARGS(pd, mr_type, max_num_sg, mr),
0310 
0311     TP_STRUCT__entry(
0312         __field(u32, pd_id)
0313         __field(u32, mr_id)
0314         __field(u32, max_num_sg)
0315         __field(int, rc)
0316         __field(unsigned long, mr_type)
0317     ),
0318 
0319     TP_fast_assign(
0320         __entry->pd_id = pd->res.id;
0321         if (IS_ERR(mr)) {
0322             __entry->mr_id = 0;
0323             __entry->rc = PTR_ERR(mr);
0324         } else {
0325             __entry->mr_id = mr->res.id;
0326             __entry->rc = 0;
0327         }
0328         __entry->max_num_sg = max_num_sg;
0329         __entry->mr_type = mr_type;
0330     ),
0331 
0332     TP_printk("pd.id=%u mr.id=%u type=%s max_num_sg=%u rc=%d",
0333         __entry->pd_id, __entry->mr_id,
0334         rdma_show_ib_mr_type(__entry->mr_type),
0335         __entry->max_num_sg, __entry->rc)
0336 );
0337 
0338 TRACE_EVENT(mr_integ_alloc,
0339     TP_PROTO(
0340         const struct ib_pd *pd,
0341         u32 max_num_data_sg,
0342         u32 max_num_meta_sg,
0343         const struct ib_mr *mr
0344     ),
0345 
0346     TP_ARGS(pd, max_num_data_sg, max_num_meta_sg, mr),
0347 
0348     TP_STRUCT__entry(
0349         __field(u32, pd_id)
0350         __field(u32, mr_id)
0351         __field(u32, max_num_data_sg)
0352         __field(u32, max_num_meta_sg)
0353         __field(int, rc)
0354     ),
0355 
0356     TP_fast_assign(
0357         __entry->pd_id = pd->res.id;
0358         if (IS_ERR(mr)) {
0359             __entry->mr_id = 0;
0360             __entry->rc = PTR_ERR(mr);
0361         } else {
0362             __entry->mr_id = mr->res.id;
0363             __entry->rc = 0;
0364         }
0365         __entry->max_num_data_sg = max_num_data_sg;
0366         __entry->max_num_meta_sg = max_num_meta_sg;
0367     ),
0368 
0369     TP_printk("pd.id=%u mr.id=%u max_num_data_sg=%u max_num_meta_sg=%u rc=%d",
0370         __entry->pd_id, __entry->mr_id, __entry->max_num_data_sg,
0371         __entry->max_num_meta_sg, __entry->rc)
0372 );
0373 
0374 TRACE_EVENT(mr_dereg,
0375     TP_PROTO(
0376         const struct ib_mr *mr
0377     ),
0378 
0379     TP_ARGS(mr),
0380 
0381     TP_STRUCT__entry(
0382         __field(u32, id)
0383     ),
0384 
0385     TP_fast_assign(
0386         __entry->id = mr->res.id;
0387     ),
0388 
0389     TP_printk("mr.id=%u", __entry->id)
0390 );
0391 
0392 #endif /* _TRACE_RDMA_CORE_H */
0393 
0394 #include <trace/define_trace.h>