rdma_core.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Trace point definitions for core RDMA functions.
  4. *
  5. * Author: Chuck Lever <chuck.lever@oracle.com>
  6. *
  7. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
  8. */
  9. #undef TRACE_SYSTEM
  10. #define TRACE_SYSTEM rdma_core
  11. #if !defined(_TRACE_RDMA_CORE_H) || defined(TRACE_HEADER_MULTI_READ)
  12. #define _TRACE_RDMA_CORE_H
  13. #include <linux/tracepoint.h>
  14. #include <rdma/ib_verbs.h>
  15. /*
  16. * enum ib_poll_context, from include/rdma/ib_verbs.h
  17. */
  18. #define IB_POLL_CTX_LIST \
  19. ib_poll_ctx(DIRECT) \
  20. ib_poll_ctx(SOFTIRQ) \
  21. ib_poll_ctx(WORKQUEUE) \
  22. ib_poll_ctx_end(UNBOUND_WORKQUEUE)
  23. #undef ib_poll_ctx
  24. #undef ib_poll_ctx_end
  25. #define ib_poll_ctx(x) TRACE_DEFINE_ENUM(IB_POLL_##x);
  26. #define ib_poll_ctx_end(x) TRACE_DEFINE_ENUM(IB_POLL_##x);
  27. IB_POLL_CTX_LIST
  28. #undef ib_poll_ctx
  29. #undef ib_poll_ctx_end
  30. #define ib_poll_ctx(x) { IB_POLL_##x, #x },
  31. #define ib_poll_ctx_end(x) { IB_POLL_##x, #x }
  32. #define rdma_show_ib_poll_ctx(x) \
  33. __print_symbolic(x, IB_POLL_CTX_LIST)
  34. /**
  35. ** Completion Queue events
  36. **/
  37. TRACE_EVENT(cq_schedule,
  38. TP_PROTO(
  39. struct ib_cq *cq
  40. ),
  41. TP_ARGS(cq),
  42. TP_STRUCT__entry(
  43. __field(u32, cq_id)
  44. ),
  45. TP_fast_assign(
  46. cq->timestamp = ktime_get();
  47. cq->interrupt = true;
  48. __entry->cq_id = cq->res.id;
  49. ),
  50. TP_printk("cq.id=%u", __entry->cq_id)
  51. );
  52. TRACE_EVENT(cq_reschedule,
  53. TP_PROTO(
  54. struct ib_cq *cq
  55. ),
  56. TP_ARGS(cq),
  57. TP_STRUCT__entry(
  58. __field(u32, cq_id)
  59. ),
  60. TP_fast_assign(
  61. cq->timestamp = ktime_get();
  62. cq->interrupt = false;
  63. __entry->cq_id = cq->res.id;
  64. ),
  65. TP_printk("cq.id=%u", __entry->cq_id)
  66. );
  67. TRACE_EVENT(cq_process,
  68. TP_PROTO(
  69. const struct ib_cq *cq
  70. ),
  71. TP_ARGS(cq),
  72. TP_STRUCT__entry(
  73. __field(u32, cq_id)
  74. __field(bool, interrupt)
  75. __field(s64, latency)
  76. ),
  77. TP_fast_assign(
  78. ktime_t latency = ktime_sub(ktime_get(), cq->timestamp);
  79. __entry->cq_id = cq->res.id;
  80. __entry->latency = ktime_to_us(latency);
  81. __entry->interrupt = cq->interrupt;
  82. ),
  83. TP_printk("cq.id=%u wake-up took %lld [us] from %s",
  84. __entry->cq_id, __entry->latency,
  85. __entry->interrupt ? "interrupt" : "reschedule"
  86. )
  87. );
  88. TRACE_EVENT(cq_poll,
  89. TP_PROTO(
  90. const struct ib_cq *cq,
  91. int requested,
  92. int rc
  93. ),
  94. TP_ARGS(cq, requested, rc),
  95. TP_STRUCT__entry(
  96. __field(u32, cq_id)
  97. __field(int, requested)
  98. __field(int, rc)
  99. ),
  100. TP_fast_assign(
  101. __entry->cq_id = cq->res.id;
  102. __entry->requested = requested;
  103. __entry->rc = rc;
  104. ),
  105. TP_printk("cq.id=%u requested %d, returned %d",
  106. __entry->cq_id, __entry->requested, __entry->rc
  107. )
  108. );
  109. TRACE_EVENT(cq_drain_complete,
  110. TP_PROTO(
  111. const struct ib_cq *cq
  112. ),
  113. TP_ARGS(cq),
  114. TP_STRUCT__entry(
  115. __field(u32, cq_id)
  116. ),
  117. TP_fast_assign(
  118. __entry->cq_id = cq->res.id;
  119. ),
  120. TP_printk("cq.id=%u",
  121. __entry->cq_id
  122. )
  123. );
  124. TRACE_EVENT(cq_modify,
  125. TP_PROTO(
  126. const struct ib_cq *cq,
  127. u16 comps,
  128. u16 usec
  129. ),
  130. TP_ARGS(cq, comps, usec),
  131. TP_STRUCT__entry(
  132. __field(u32, cq_id)
  133. __field(unsigned int, comps)
  134. __field(unsigned int, usec)
  135. ),
  136. TP_fast_assign(
  137. __entry->cq_id = cq->res.id;
  138. __entry->comps = comps;
  139. __entry->usec = usec;
  140. ),
  141. TP_printk("cq.id=%u comps=%u usec=%u",
  142. __entry->cq_id, __entry->comps, __entry->usec
  143. )
  144. );
  145. TRACE_EVENT(cq_alloc,
  146. TP_PROTO(
  147. const struct ib_cq *cq,
  148. int nr_cqe,
  149. int comp_vector,
  150. enum ib_poll_context poll_ctx
  151. ),
  152. TP_ARGS(cq, nr_cqe, comp_vector, poll_ctx),
  153. TP_STRUCT__entry(
  154. __field(u32, cq_id)
  155. __field(int, nr_cqe)
  156. __field(int, comp_vector)
  157. __field(unsigned long, poll_ctx)
  158. ),
  159. TP_fast_assign(
  160. __entry->cq_id = cq->res.id;
  161. __entry->nr_cqe = nr_cqe;
  162. __entry->comp_vector = comp_vector;
  163. __entry->poll_ctx = poll_ctx;
  164. ),
  165. TP_printk("cq.id=%u nr_cqe=%d comp_vector=%d poll_ctx=%s",
  166. __entry->cq_id, __entry->nr_cqe, __entry->comp_vector,
  167. rdma_show_ib_poll_ctx(__entry->poll_ctx)
  168. )
  169. );
  170. TRACE_EVENT(cq_alloc_error,
  171. TP_PROTO(
  172. int nr_cqe,
  173. int comp_vector,
  174. enum ib_poll_context poll_ctx,
  175. int rc
  176. ),
  177. TP_ARGS(nr_cqe, comp_vector, poll_ctx, rc),
  178. TP_STRUCT__entry(
  179. __field(int, rc)
  180. __field(int, nr_cqe)
  181. __field(int, comp_vector)
  182. __field(unsigned long, poll_ctx)
  183. ),
  184. TP_fast_assign(
  185. __entry->rc = rc;
  186. __entry->nr_cqe = nr_cqe;
  187. __entry->comp_vector = comp_vector;
  188. __entry->poll_ctx = poll_ctx;
  189. ),
  190. TP_printk("nr_cqe=%d comp_vector=%d poll_ctx=%s rc=%d",
  191. __entry->nr_cqe, __entry->comp_vector,
  192. rdma_show_ib_poll_ctx(__entry->poll_ctx), __entry->rc
  193. )
  194. );
  195. TRACE_EVENT(cq_free,
  196. TP_PROTO(
  197. const struct ib_cq *cq
  198. ),
  199. TP_ARGS(cq),
  200. TP_STRUCT__entry(
  201. __field(u32, cq_id)
  202. ),
  203. TP_fast_assign(
  204. __entry->cq_id = cq->res.id;
  205. ),
  206. TP_printk("cq.id=%u", __entry->cq_id)
  207. );
  208. /**
  209. ** Memory Region events
  210. **/
  211. /*
  212. * enum ib_mr_type, from include/rdma/ib_verbs.h
  213. */
  214. #define IB_MR_TYPE_LIST \
  215. ib_mr_type_item(MEM_REG) \
  216. ib_mr_type_item(SG_GAPS) \
  217. ib_mr_type_item(DM) \
  218. ib_mr_type_item(USER) \
  219. ib_mr_type_item(DMA) \
  220. ib_mr_type_end(INTEGRITY)
  221. #undef ib_mr_type_item
  222. #undef ib_mr_type_end
  223. #define ib_mr_type_item(x) TRACE_DEFINE_ENUM(IB_MR_TYPE_##x);
  224. #define ib_mr_type_end(x) TRACE_DEFINE_ENUM(IB_MR_TYPE_##x);
  225. IB_MR_TYPE_LIST
  226. #undef ib_mr_type_item
  227. #undef ib_mr_type_end
  228. #define ib_mr_type_item(x) { IB_MR_TYPE_##x, #x },
  229. #define ib_mr_type_end(x) { IB_MR_TYPE_##x, #x }
  230. #define rdma_show_ib_mr_type(x) \
  231. __print_symbolic(x, IB_MR_TYPE_LIST)
  232. TRACE_EVENT(mr_alloc,
  233. TP_PROTO(
  234. const struct ib_pd *pd,
  235. enum ib_mr_type mr_type,
  236. u32 max_num_sg,
  237. const struct ib_mr *mr
  238. ),
  239. TP_ARGS(pd, mr_type, max_num_sg, mr),
  240. TP_STRUCT__entry(
  241. __field(u32, pd_id)
  242. __field(u32, mr_id)
  243. __field(u32, max_num_sg)
  244. __field(int, rc)
  245. __field(unsigned long, mr_type)
  246. ),
  247. TP_fast_assign(
  248. __entry->pd_id = pd->res.id;
  249. if (IS_ERR(mr)) {
  250. __entry->mr_id = 0;
  251. __entry->rc = PTR_ERR(mr);
  252. } else {
  253. __entry->mr_id = mr->res.id;
  254. __entry->rc = 0;
  255. }
  256. __entry->max_num_sg = max_num_sg;
  257. __entry->mr_type = mr_type;
  258. ),
  259. TP_printk("pd.id=%u mr.id=%u type=%s max_num_sg=%u rc=%d",
  260. __entry->pd_id, __entry->mr_id,
  261. rdma_show_ib_mr_type(__entry->mr_type),
  262. __entry->max_num_sg, __entry->rc)
  263. );
  264. TRACE_EVENT(mr_integ_alloc,
  265. TP_PROTO(
  266. const struct ib_pd *pd,
  267. u32 max_num_data_sg,
  268. u32 max_num_meta_sg,
  269. const struct ib_mr *mr
  270. ),
  271. TP_ARGS(pd, max_num_data_sg, max_num_meta_sg, mr),
  272. TP_STRUCT__entry(
  273. __field(u32, pd_id)
  274. __field(u32, mr_id)
  275. __field(u32, max_num_data_sg)
  276. __field(u32, max_num_meta_sg)
  277. __field(int, rc)
  278. ),
  279. TP_fast_assign(
  280. __entry->pd_id = pd->res.id;
  281. if (IS_ERR(mr)) {
  282. __entry->mr_id = 0;
  283. __entry->rc = PTR_ERR(mr);
  284. } else {
  285. __entry->mr_id = mr->res.id;
  286. __entry->rc = 0;
  287. }
  288. __entry->max_num_data_sg = max_num_data_sg;
  289. __entry->max_num_meta_sg = max_num_meta_sg;
  290. ),
  291. TP_printk("pd.id=%u mr.id=%u max_num_data_sg=%u max_num_meta_sg=%u rc=%d",
  292. __entry->pd_id, __entry->mr_id, __entry->max_num_data_sg,
  293. __entry->max_num_meta_sg, __entry->rc)
  294. );
  295. TRACE_EVENT(mr_dereg,
  296. TP_PROTO(
  297. const struct ib_mr *mr
  298. ),
  299. TP_ARGS(mr),
  300. TP_STRUCT__entry(
  301. __field(u32, id)
  302. ),
  303. TP_fast_assign(
  304. __entry->id = mr->res.id;
  305. ),
  306. TP_printk("mr.id=%u", __entry->id)
  307. );
  308. #endif /* _TRACE_RDMA_CORE_H */
  309. #include <trace/define_trace.h>