1 /** 2 * Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED. 3 * 4 * See file LICENSE for terms. 5 */ 6 7 #ifndef UCT_IB_LOG_H 8 #define UCT_IB_LOG_H 9 10 #include "ib_verbs.h" 11 #include "ib_iface.h" 12 13 #include <uct/base/uct_log.h> 14 #include <ucs/debug/log.h> 15 #include <ucs/sys/math.h> 16 17 18 enum { 19 UCT_IB_OPCODE_FLAG_HAS_RADDR = UCS_BIT(0), 20 UCT_IB_OPCODE_FLAG_HAS_ATOMIC = UCS_BIT(1), 21 UCT_IB_OPCODE_FLAG_HAS_EXT_ATOMIC = UCS_BIT(2) 22 }; 23 24 25 typedef struct uct_ib_opcode { 26 const char *name; 27 uint32_t flags; 28 } uct_ib_opcode_t; 29 30 31 const char *uct_ib_qp_type_str(int qp_type); 32 33 void uct_ib_log_dump_opcode(uct_ib_opcode_t *op, int signal, int fence, int se, 34 char *buf, size_t max); 35 36 void uct_ib_log_dump_sg_list(uct_ib_iface_t *iface, uct_am_trace_type_t type, 37 struct ibv_sge *sg_list, int num_sge, 38 uint64_t inline_bitmap, 39 uct_log_data_dump_func_t data_dump, 40 char *buf, size_t max); 41 42 void uct_ib_log_dump_remote_addr(uint64_t remote_addr, uint32_t rkey, 43 char *buf, size_t max); 44 45 void uct_ib_log_dump_atomic_fadd(uint64_t add, char *buf, size_t max); 46 47 void uct_ib_log_dump_atomic_cswap(uint64_t compare, uint64_t swap, char *buf, size_t max); 48 49 void uct_ib_log_dump_atomic_masked_fadd(int argsize, uint64_t add, uint64_t boundary, 50 char *buf, size_t max); 51 52 void uct_ib_log_dump_atomic_masked_cswap(int argsize, uint64_t compare, uint64_t compare_mask, 53 uint64_t swap, uint64_t swap_mask, 54 char *buf, size_t max); 55 56 void uct_ib_log_dump_recv_completion(uct_ib_iface_t *iface, uint32_t local_qp, 57 uint32_t sender_qp, uint16_t sender_lid, 58 void *data, size_t length, 59 uct_log_data_dump_func_t data_dump, 60 char *buf, size_t max); 61 62 void __uct_ib_log_post_send(const char *file, int line, const char *function, 63 uct_ib_iface_t *iface, struct ibv_qp *qp, 64 struct ibv_send_wr *wr, int max_sge, 65 uct_log_data_dump_func_t packet_dump_cb); 66 67 void __uct_ib_log_recv_completion(const char *file, int line, const char *function, 68 uct_ib_iface_t *iface, uint32_t l_qp, 69 uint32_t r_qp, uint16_t slid, void *data, 70 size_t length, 71 uct_log_data_dump_func_t packet_dump_cb); 72 73 #if HAVE_DECL_IBV_EXP_POST_SEND 74 void __uct_ib_log_exp_post_send(const char *file, int line, const char *function, 75 uct_ib_iface_t *iface, struct ibv_qp *qp, 76 struct ibv_exp_send_wr *wr, int max_sge, 77 uct_log_data_dump_func_t packet_dump_cb); 78 #endif 79 80 81 #define uct_ib_log_post_send(_iface, _qp, _wr, _max_sge, _dump_cb) \ 82 if (ucs_log_is_enabled(UCS_LOG_LEVEL_TRACE_DATA)) { \ 83 __uct_ib_log_post_send(__FILE__, __LINE__, __FUNCTION__, \ 84 _iface, _qp, _wr, _max_sge, _dump_cb); \ 85 } 86 87 /* Suitable for both: regular and exp wcs */ 88 #define uct_ib_log_recv_completion(_iface, _wc, _data, _length, _dump_cb, ...) \ 89 if (ucs_log_is_enabled(UCS_LOG_LEVEL_TRACE_DATA)) { \ 90 __uct_ib_log_recv_completion(__FILE__, __LINE__, __FUNCTION__, \ 91 _iface, (_wc)->qp_num, (_wc)->src_qp, (_wc)->slid, \ 92 _data, _length, _dump_cb, ## __VA_ARGS__); \ 93 } 94 95 #define uct_ib_log_exp_post_send(_iface, _qp, _wr, _max_sge,_dump_cb) \ 96 if (ucs_log_is_enabled(UCS_LOG_LEVEL_TRACE_DATA)) { \ 97 __uct_ib_log_exp_post_send(__FILE__, __LINE__, __FUNCTION__, \ 98 _iface, _qp, _wr, _max_sge, _dump_cb); \ 99 } 100 101 #endif 102