]>
git.proxmox.com Git - ceph.git/blob - ceph/src/msg/async/rdma/ib_dbg.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
7 #define dout_subsys ceph_subsys_ms
9 #define dout_prefix *_dout << "ib_dbg "
12 if (g_ceph_context && g_ceph_context->_log) \
13 ldout(g_ceph_context,1) << f << ":" << l << " ib command: " << __func__
15 static inline struct ibv_srq
*_ibv_create_srq(const char *f
, int l
,
17 struct ibv_srq_init_attr
*srq_init_attr
)
19 auto ret
= ibv_create_srq(pd
, srq_init_attr
);
21 ibdbg_ldout
<< " pd: " << pd
<<
22 " | srq: " << ret
<< dendl
;
26 #define ibv_create_srq(...) _ibv_create_srq(__func__, __LINE__, __VA_ARGS__)
28 static inline void _ibv_ack_cq_events(const char *f
, int l
,
29 struct ibv_cq
*cq
, unsigned int nevents
)
31 ibdbg_ldout
<< " cq: " << cq
<< " nevents: " << nevents
<< dendl
;
33 ibv_ack_cq_events(cq
, nevents
);
35 #define ibv_ack_cq_events(...) _ibv_ack_cq_events(__func__, __LINE__, __VA_ARGS__)
37 static inline struct ibv_pd
*_ibv_alloc_pd(const char *f
, int l
,
38 struct ibv_context
*context
)
40 auto ret
= ibv_alloc_pd(context
);
43 ibdbg_ldout
<< " ctxt: " << context
<<
44 " | pd: " << ret
<< dendl
;
48 #define ibv_alloc_pd(...) _ibv_alloc_pd(__func__, __LINE__, __VA_ARGS__)
50 static inline int _ibv_close_device(const char *f
, int l
,
51 struct ibv_context
*context
)
53 auto ret
= ibv_close_device(context
);
55 ibdbg_ldout
<< " ctxt: " << context
<<
56 " | ret: " << ret
<< dendl
;
60 #define ibv_close_device(...) _ibv_close_device(__func__, __LINE__, __VA_ARGS__)
62 static inline struct ibv_comp_channel
*_ibv_create_comp_channel(const char *f
, int l
,
63 struct ibv_context
*context
)
65 auto ret
= ibv_create_comp_channel(context
);
67 ibdbg_ldout
<< " ctxt: " << context
<<
68 " | channel: " << ret
<< " fd: " << ( ret
? ret
->fd
: -1 ) << dendl
;
72 #define ibv_create_comp_channel(...) _ibv_create_comp_channel(__func__, __LINE__, __VA_ARGS__)
74 static inline struct ibv_cq
*_ibv_create_cq(const char *f
, int l
,
75 struct ibv_context
*context
, int cqe
,
77 struct ibv_comp_channel
*channel
,
80 auto ret
= ibv_create_cq(context
, cqe
, cq_context
, channel
, comp_vector
);
82 ibdbg_ldout
<< " context: " << context
<< " channel: " << channel
<<
83 " | cq: " << ret
<< dendl
;
87 #define ibv_create_cq(...) _ibv_create_cq(__func__, __LINE__, __VA_ARGS__)
89 static inline struct ibv_qp
*_ibv_create_qp(const char *f
, int l
,
91 struct ibv_qp_init_attr
*qp_init_attr
)
93 auto ret
= ibv_create_qp(pd
, qp_init_attr
);
95 ibdbg_ldout
<< " pd: " << pd
<<
96 " send_cq: " << qp_init_attr
->send_cq
<<
97 " recv_cq: " << qp_init_attr
->recv_cq
<<
98 " srq: " << qp_init_attr
->srq
<<
99 " | qp: " << ret
<< dendl
;
103 #define ibv_create_qp(...) _ibv_create_qp(__func__, __LINE__, __VA_ARGS__)
105 static inline int _ibv_dealloc_pd(const char *f
, int l
,
108 auto ret
= ibv_dealloc_pd(pd
);
110 ibdbg_ldout
<< " pd: " << pd
<<
111 " | ret: " << ret
<< dendl
;
115 #define ibv_dealloc_pd(...) _ibv_dealloc_pd(__func__, __LINE__, __VA_ARGS__)
117 static inline int _ibv_destroy_comp_channel(const char *f
, int l
,
118 struct ibv_comp_channel
*channel
)
120 auto ret
= ibv_destroy_comp_channel(channel
);
122 ibdbg_ldout
<< " channel: " << channel
<<
123 " | ret: " << ret
<< dendl
;
127 #define ibv_destroy_comp_channel(...) _ibv_destroy_comp_channel(__func__, __LINE__, __VA_ARGS__)
129 static inline int _ibv_destroy_cq(const char *f
, int l
,
132 auto ret
= ibv_destroy_cq(cq
);
135 ibdbg_ldout
<< " cq: " << cq
<<
136 " | ret: " << cpp_strerror(ret
) << dendl
;
138 ibdbg_ldout
<< " cq: " << cq
<<
139 " | ret: " << ret
<< dendl
;
144 #define ibv_destroy_cq(...) _ibv_destroy_cq(__func__, __LINE__, __VA_ARGS__)
146 static inline int _ibv_destroy_qp(const char *f
, int l
,
149 auto ret
= ibv_destroy_qp(qp
);
151 ibdbg_ldout
<< " qp: " << qp
<<
152 " | ret: " << ret
<< dendl
;
156 #define ibv_destroy_qp(...) _ibv_destroy_qp(__func__, __LINE__, __VA_ARGS__)
158 static inline int _ibv_destroy_srq(const char *f
, int l
,
161 auto ret
= ibv_destroy_srq(srq
);
163 ibdbg_ldout
<< " srq: " << srq
<<
164 " | ret: " << ret
<< dendl
;
168 #define ibv_destroy_srq(...) _ibv_destroy_srq(__func__, __LINE__, __VA_ARGS__)
170 //#define ibv_exp_query_gid_attr(...) _ibv_exp_query_gid_attr(__func__, __LINE__, __VA_ARGS__)
172 static inline int _ibv_fork_init(const char *f
, int l
)
174 auto ret
= ibv_fork_init();
177 " | ret: " << ret
<< dendl
;
181 #define ibv_fork_init() _ibv_fork_init(__func__, __LINE__)
183 static inline void _ibv_free_device_list(const char *f
, int l
,
184 struct ibv_device
**list
)
186 ibdbg_ldout
<< " list: " << list
<< dendl
;
188 ibv_free_device_list(list
);
190 #define ibv_free_device_list(...) _ibv_free_device_list(__func__, __LINE__, __VA_ARGS__)
192 static inline int _ibv_get_cq_event(const char *f
, int l
,
193 struct ibv_comp_channel
*channel
,
194 struct ibv_cq
**cq
, void **cq_context
)
196 auto ret
= ibv_get_cq_event(channel
, cq
, cq_context
);
198 ibdbg_ldout
<< " channel: " << channel
<< " cq: " << cq
<< " cq_context:" << cq_context
<<
199 " | ret: " << ret
<< dendl
;
203 #define ibv_get_cq_event(...) _ibv_get_cq_event(__func__, __LINE__, __VA_ARGS__)
205 static inline struct ibv_device
**_ibv_get_device_list(const char *f
, int l
,
208 auto ret
= ibv_get_device_list(num_devices
);
211 " | num: " << *num_devices
<< " list: " << ret
<< dendl
;
215 #define ibv_get_device_list(...) _ibv_get_device_list(__func__, __LINE__, __VA_ARGS__)
217 static inline const char *_ibv_get_device_name(const char *f
, int l
,
218 struct ibv_device
*device
)
220 auto ret
= ibv_get_device_name(device
);
222 ibdbg_ldout
<< " device: " << device
<<
223 " | name: " << ret
<< dendl
;
227 #define ibv_get_device_name(...) _ibv_get_device_name(__func__, __LINE__, __VA_ARGS__)
229 static inline int _ibv_modify_qp(const char *f
, int l
,
230 struct ibv_qp
*qp
, struct ibv_qp_attr
*attr
,
233 auto ret
= ibv_modify_qp(qp
, attr
, attr_mask
);
235 ibdbg_ldout
<< " qp: " << qp
<<
236 " | ret: " << ret
<< dendl
;
240 #define ibv_modify_qp(...) _ibv_modify_qp(__func__, __LINE__, __VA_ARGS__)
242 static inline struct ibv_context
*_ibv_open_device(const char *f
, int l
,
243 struct ibv_device
*device
)
245 auto ret
= ibv_open_device(device
);
247 ibdbg_ldout
<< " device: " << device
<<
248 " | ret: " << ret
<< dendl
;
252 #define ibv_open_device(...) _ibv_open_device(__func__, __LINE__, __VA_ARGS__)
254 static inline int _ibv_poll_cq(const char *f
, int l
,
255 struct ibv_cq
*cq
, int num_entries
, struct ibv_wc
*wc
)
257 auto ret
= ibv_poll_cq(cq
, num_entries
, wc
);
258 static utime_t last_print
= ceph_clock_now();
259 static int suppressed_counter
= 0;
261 if ((ceph_clock_now() - last_print
).to_msec() < 100) {
262 suppressed_counter
++;
266 if (suppressed_counter
> 0) {
267 ibdbg_ldout
<< " cq: " << cq
<< " num_entries: " << num_entries
<<
269 " {suppressed " << suppressed_counter
<< " prints}" << dendl
;
270 suppressed_counter
= 0;
272 ibdbg_ldout
<< " cq: " << cq
<< " num_entries: " << num_entries
<<
273 " | ret: " << ret
<< dendl
;
276 last_print
= ceph_clock_now();
280 #define ibv_poll_cq(...) _ibv_poll_cq(__func__, __LINE__, __VA_ARGS__)
282 static inline int _ibv_post_send(const char *f
, int l
,
283 struct ibv_qp
*qp
, struct ibv_send_wr
*wr
,
284 struct ibv_send_wr
**bad_wr
)
286 auto ret
= ibv_post_send(qp
, wr
, bad_wr
);
288 ibdbg_ldout
<< " qp: " << qp
<<
289 " | ret: " << ret
<< dendl
;
293 #define ibv_post_send(...) _ibv_post_send(__func__, __LINE__, __VA_ARGS__)
295 static inline int _ibv_post_srq_recv(const char *f
, int l
,
297 struct ibv_recv_wr
*recv_wr
,
298 struct ibv_recv_wr
**bad_recv_wr
)
300 auto ret
= ibv_post_srq_recv(srq
, recv_wr
, bad_recv_wr
);
302 static struct ibv_srq
*last_srq
= nullptr;
303 if (last_srq
!= srq
) {
304 ibdbg_ldout
<< " srq: " << srq
<<
305 " | ret: " << ret
<< dendl
;
311 #define ibv_post_srq_recv(...) _ibv_post_srq_recv(__func__, __LINE__, __VA_ARGS__)
313 static inline int _ibv_query_device(const char *f
, int l
,
314 struct ibv_context
*context
,
315 struct ibv_device_attr
*device_attr
)
317 auto ret
= ibv_query_device(context
, device_attr
);
319 ibdbg_ldout
<< " context: " << context
<<
320 " | ret: " << ret
<< dendl
;
324 #define ibv_query_device(...) _ibv_query_device(__func__, __LINE__, __VA_ARGS__)
326 static inline int _ibv_query_gid(const char *f
, int l
,
327 struct ibv_context
*context
, int port_num
,
328 int index
, union ibv_gid
*gid
)
330 auto ret
= ibv_query_gid(context
, port_num
, index
, gid
);
332 ibdbg_ldout
<< " context: " << context
<< " port_num: " << port_num
<< " index: " << index
<<
333 " | ret: " << ret
<< dendl
;
337 #define ibv_query_gid(...) _ibv_query_gid(__func__, __LINE__, __VA_ARGS__)
339 static inline int ____ibv_query_port(const char *f
, int l
,
340 struct ibv_context
*context
,
342 struct ibv_port_attr
*port_attr
)
344 auto ret
= ___ibv_query_port(context
, port_num
, port_attr
);
346 ibdbg_ldout
<< " context: " << context
<< " port_num: " << port_num
<<
347 " | ret: " << ret
<< dendl
;
351 #define ___ibv_query_port(...) ____ibv_query_port(__func__, __LINE__, __VA_ARGS__)
353 static inline int _ibv_req_notify_cq(const char *f
, int l
,
354 struct ibv_cq
*cq
, int solicited_only
)
356 auto ret
= ibv_req_notify_cq(cq
, solicited_only
);
358 ibdbg_ldout
<< " cq: " << cq
<< " solicited_only: " << solicited_only
<<
359 " | ret: " << ret
<< dendl
;
363 #define ibv_req_notify_cq(...) _ibv_req_notify_cq(__func__, __LINE__, __VA_ARGS__)
365 static inline int _ibv_get_async_event(const char *f
, int l
,
366 struct ibv_context
*context
,
367 struct ibv_async_event
*event
)
369 auto ret
= ibv_get_async_event(context
, event
);
371 ibdbg_ldout
<< " context: " << context
<<
372 " | event: " << event
<< " ret: " << ret
<< dendl
;
376 #define ibv_get_async_event(...) _ibv_get_async_event(__func__, __LINE__, __VA_ARGS__)
378 static inline void _ibv_ack_async_event(const char *f
, int l
,
379 struct ibv_async_event
*event
)
381 ibdbg_ldout
<< " event: " << event
<< dendl
;
383 ibv_ack_async_event(event
);
385 #define ibv_ack_async_event(...) _ibv_ack_async_event(__func__, __LINE__, __VA_ARGS__)
387 #endif // __IB_DBG_H__