diff --git a/src/uct/ib/base/ib_device.c b/src/uct/ib/base/ib_device.c index a13c00a5ed1..38242223b6c 100644 --- a/src/uct/ib/base/ib_device.c +++ b/src/uct/ib/base/ib_device.c @@ -683,6 +683,14 @@ ucs_status_t uct_ib_device_port_check(uct_ib_device_t *dev, uint8_t port_num, return UCS_ERR_UNREACHABLE; } + if (flags & UCT_IB_DEVICE_FLAG_SRQ) { + if (IBV_DEV_ATTR(dev, max_srq) == 0) { + ucs_trace("%s:%d does not support SRQ", uct_ib_device_name(dev), + port_num); + return UCS_ERR_UNSUPPORTED; + } + } + if (!uct_ib_device_is_port_ib(dev, port_num) && (flags & UCT_IB_DEVICE_FLAG_LINK_IB)) { ucs_debug("%s:%d is not IB link layer", uct_ib_device_name(dev), port_num); diff --git a/src/uct/ib/base/ib_device.h b/src/uct/ib/base/ib_device.h index 1a556adce95..a5acd340f41 100644 --- a/src/uct/ib/base/ib_device.h +++ b/src/uct/ib/base/ib_device.h @@ -92,6 +92,7 @@ enum { UCT_IB_DEVICE_FLAG_MLX4_PRM = UCS_BIT(1), /* Device supports mlx4 PRM */ UCT_IB_DEVICE_FLAG_MLX5_PRM = UCS_BIT(2), /* Device supports mlx5 PRM */ UCT_IB_DEVICE_FLAG_MELLANOX = UCS_BIT(3), /* Mellanox device */ + UCT_IB_DEVICE_FLAG_SRQ = UCS_BIT(4), /* Supports SRQ */ UCT_IB_DEVICE_FLAG_LINK_IB = UCS_BIT(5), /* Require only IB */ UCT_IB_DEVICE_FLAG_DC_V1 = UCS_BIT(6), /* Device supports DC ver 1 */ UCT_IB_DEVICE_FLAG_DC_V2 = UCS_BIT(7), /* Device supports DC ver 2 */ diff --git a/src/uct/ib/base/ib_iface.c b/src/uct/ib/base/ib_iface.c index 5ce603a895a..e1b41e38450 100644 --- a/src/uct/ib/base/ib_iface.c +++ b/src/uct/ib/base/ib_iface.c @@ -1108,11 +1108,10 @@ ucs_status_t uct_ib_iface_create_qp(uct_ib_iface_t *iface, #endif if (qp == NULL) { uct_ib_check_memlock_limit_msg( - UCS_LOG_LEVEL_ERROR, - "%s: iface %p failed to create %s QP " + dev->ibv_context, UCS_LOG_LEVEL_ERROR, + "iface %p failed to create %s QP " "TX wr:%d sge:%d inl:%d resp:%d RX wr:%d sge:%d resp:%d", - uct_ib_device_name(dev), iface, - uct_ib_qp_type_str(attr->qp_type), attr->cap.max_send_wr, + iface, uct_ib_qp_type_str(attr->qp_type), attr->cap.max_send_wr, attr->cap.max_send_sge, attr->cap.max_inline_data, attr->max_inl_cqe[UCT_IB_DIR_TX], attr->cap.max_recv_wr, attr->cap.max_recv_sge, attr->max_inl_cqe[UCT_IB_DIR_RX]); @@ -1138,25 +1137,25 @@ ucs_status_t uct_ib_verbs_create_cq(uct_ib_iface_t *iface, uct_ib_dir_t dir, const uct_ib_iface_init_attr_t *init_attr, int preferred_cpu, size_t inl) { - uct_ib_device_t *dev = uct_ib_iface_device(iface); - unsigned cq_size = uct_ib_cq_size(iface, init_attr, dir); + struct ibv_context *ibv_context = uct_ib_iface_device(iface)->ibv_context; + unsigned cq_size = uct_ib_cq_size(iface, init_attr, dir); struct ibv_cq *cq; #if HAVE_DECL_IBV_CREATE_CQ_EX struct ibv_cq_init_attr_ex cq_attr = {}; uct_ib_fill_cq_attr(&cq_attr, init_attr, iface, preferred_cpu, cq_size); - cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(dev->ibv_context, &cq_attr)); + cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(ibv_context, &cq_attr)); if (!cq && ((errno == EOPNOTSUPP) || (errno == ENOSYS))) #endif { iface->config.max_inl_cqe[dir] = 0; - cq = ibv_create_cq(dev->ibv_context, cq_size, NULL, iface->comp_channel, + cq = ibv_create_cq(ibv_context, cq_size, NULL, iface->comp_channel, preferred_cpu); } if (cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, + uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_ERROR, "ibv_create_cq(cqe=%d)", cq_size); return UCS_ERR_IO_ERROR; } diff --git a/src/uct/ib/base/ib_log.h b/src/uct/ib/base/ib_log.h index 456f818d8c2..8f510ed4a30 100644 --- a/src/uct/ib/base/ib_log.h +++ b/src/uct/ib/base/ib_log.h @@ -76,14 +76,15 @@ void __uct_ib_log_recv_completion(const char *file, int line, const char *functi size_t length, uct_log_data_dump_func_t packet_dump_cb); -#define uct_ib_check_memlock_limit_msg(level, _fmt, ...) \ +#define uct_ib_check_memlock_limit_msg(_ibv_context, _level, _fmt, ...) \ ({ \ UCS_STRING_BUFFER_ONSTACK(_msg, 256); \ int _tmp_errno = errno; \ - ucs_string_buffer_appendf(&_msg, _fmt, ## __VA_ARGS__); \ + ucs_string_buffer_appendf(&_msg, _fmt, ##__VA_ARGS__); \ ucs_string_buffer_appendf(&_msg, " failed: %s", strerror(_tmp_errno)); \ uct_ib_memlock_limit_msg(&_msg, _tmp_errno); \ - ucs_log(level, "%s", ucs_string_buffer_cstr(&_msg)); \ + ucs_log(_level, "%s: %s", ibv_get_device_name((_ibv_context)->device), \ + ucs_string_buffer_cstr(&_msg)); \ }) #define uct_ib_log_post_send(_iface, _qp, _wr, _max_sge, _dump_cb) \ diff --git a/src/uct/ib/base/ib_md.c b/src/uct/ib/base/ib_md.c index 74e03f80b7b..a22024ac63c 100644 --- a/src/uct/ib/base/ib_md.c +++ b/src/uct/ib/base/ib_md.c @@ -1358,18 +1358,17 @@ void uct_ib_md_free(uct_ib_md_t *md) void uct_ib_md_ece_check(uct_ib_md_t *md) { #if HAVE_DECL_IBV_SET_ECE - uct_ib_device_t *dev = &md->dev; - struct ibv_pd *pd = md->pd; - struct ibv_ece ece = {}; + struct ibv_context *ibv_context = md->dev.ibv_context; + struct ibv_pd *pd = md->pd; + struct ibv_ece ece = {}; struct ibv_qp *dummy_qp; struct ibv_cq *cq; struct ibv_qp_init_attr qp_init_attr; - cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0); + cq = ibv_create_cq(ibv_context, 1, NULL, NULL, 0); if (cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, - "%s: ibv_create_cq()", - uct_ib_device_name(dev)); + uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_DEBUG, + "ibv_create_cq()"); return; } @@ -1384,9 +1383,8 @@ void uct_ib_md_ece_check(uct_ib_md_t *md) dummy_qp = ibv_create_qp(pd, &qp_init_attr); if (dummy_qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, - "%s: ibv_create_qp()", - uct_ib_device_name(dev)); + uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_DEBUG, + "ibv_create_qp(RC)"); goto free_cq; } diff --git a/src/uct/ib/dc/dc_mlx5.c b/src/uct/ib/dc/dc_mlx5.c index 13916efe11e..e585b6f72c6 100644 --- a/src/uct/ib/dc/dc_mlx5.c +++ b/src/uct/ib/dc/dc_mlx5.c @@ -419,9 +419,9 @@ static ucs_status_t uct_dc_mlx5_iface_create_dci(uct_dc_mlx5_iface_t *iface, qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, dev->ibv_context, &attr.super.ibv, &dv_attr); if (qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, - "%s: mlx5dv_create_qp("UCT_IB_IFACE_FMT", DCI)", - uct_ib_device_name(dev), + uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR, + "mlx5dv_create_qp(" UCT_IB_IFACE_FMT + ", DCI)", UCT_IB_IFACE_ARG(ib_iface)); status = UCS_ERR_IO_ERROR; goto err_put_res_domain; @@ -593,9 +593,8 @@ uct_dc_mlx5_iface_create_dct(uct_dc_mlx5_iface_t *iface, iface->rx.dct.verbs.qp = mlx5dv_create_qp(dev->ibv_context, &init_attr, &dv_init_attr); if (iface->rx.dct.verbs.qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, - "%s: mlx5dv_create_qp(DCT)", - uct_ib_device_name(dev)); + uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR, + "mlx5dv_create_qp(DCT)"); return UCS_ERR_INVALID_PARAM; } @@ -1352,7 +1351,7 @@ static uct_iface_ops_t uct_dc_mlx5_iface_tl_ops = { static ucs_status_t uct_dc_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md) { - uct_ib_device_t *dev = &md->super.dev; + struct ibv_context *ibv_context = md->super.dev.ibv_context; uct_ib_qp_init_attr_t qp_init_attr = {}; struct mlx5dv_qp_init_attr dv_attr = {}; struct ibv_qp *dci_qp; @@ -1363,7 +1362,7 @@ static ucs_status_t uct_dc_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md) return UCS_OK; } - status = uct_ib_mlx5dv_qp_tmp_objs_create(dev, md->super.pd, &qp_tmp_objs, 0); + status = uct_ib_mlx5dv_qp_tmp_objs_create(md->super.pd, &qp_tmp_objs, 0); if (status != UCS_OK) { goto out; } @@ -1372,12 +1371,11 @@ static ucs_status_t uct_dc_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md) IBV_QPT_DRIVER, 0); uct_ib_mlx5dv_dci_qp_init_attr(&qp_init_attr, &dv_attr); - dci_qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, dev->ibv_context, + dci_qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, ibv_context, &qp_init_attr, &dv_attr); if (dci_qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, - "%s: mlx5dv_create_qp(DCI)", - uct_ib_device_name(dev)); + uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_ERROR, + "mlx5dv_create_qp(DCI)"); status = UCS_ERR_IO_ERROR; goto out_qp_tmp_objs_close; } @@ -1690,7 +1688,8 @@ uct_dc_mlx5_query_tl_devices(uct_md_h md, uct_tl_device_resource_t **tl_devices_ return UCS_ERR_NO_DEVICE; } - flags = UCT_IB_DEVICE_FLAG_MLX5_PRM | UCT_IB_DEVICE_FLAG_DC | + flags = UCT_IB_DEVICE_FLAG_SRQ | UCT_IB_DEVICE_FLAG_MLX5_PRM | + UCT_IB_DEVICE_FLAG_DC | (ib_md->config.eth_pause ? 0 : UCT_IB_DEVICE_FLAG_LINK_IB); return uct_ib_device_query_ports(&ib_md->dev, flags, tl_devices_p, num_tl_devices_p); diff --git a/src/uct/ib/mlx5/dv/ib_mlx5_dv.c b/src/uct/ib/mlx5/dv/ib_mlx5_dv.c index 103262528ab..e8850cd7c41 100644 --- a/src/uct/ib/mlx5/dv/ib_mlx5_dv.c +++ b/src/uct/ib/mlx5/dv/ib_mlx5_dv.c @@ -50,7 +50,7 @@ void uct_ib_mlx5dv_dct_qp_init_attr(uct_ib_qp_init_attr_t *qp_attr, } ucs_status_t -uct_ib_mlx5dv_qp_tmp_objs_create(uct_ib_device_t *dev, struct ibv_pd *pd, +uct_ib_mlx5dv_qp_tmp_objs_create(struct ibv_pd *pd, uct_ib_mlx5dv_qp_tmp_objs_t *qp_tmp_objs, int silent) { @@ -58,10 +58,9 @@ uct_ib_mlx5dv_qp_tmp_objs_create(uct_ib_device_t *dev, struct ibv_pd *pd, ucs_log_level_t level = silent ? UCS_LOG_LEVEL_DEBUG : UCS_LOG_LEVEL_ERROR; - qp_tmp_objs->cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0); + qp_tmp_objs->cq = ibv_create_cq(pd->context, 1, NULL, NULL, 0); if (qp_tmp_objs->cq == NULL) { - uct_ib_check_memlock_limit_msg(level, "%s: ibv_create_cq()", - uct_ib_device_name(dev)); + uct_ib_check_memlock_limit_msg(pd->context, level, "ibv_create_cq()"); goto out; } @@ -69,8 +68,7 @@ uct_ib_mlx5dv_qp_tmp_objs_create(uct_ib_device_t *dev, struct ibv_pd *pd, srq_attr.attr.max_wr = 1; qp_tmp_objs->srq = ibv_create_srq(pd, &srq_attr); if (qp_tmp_objs->srq == NULL) { - uct_ib_check_memlock_limit_msg(level, "%s: ibv_create_srq()", - uct_ib_device_name(dev)); + uct_ib_check_memlock_limit_msg(pd->context, level, "ibv_create_srq()"); goto out_destroy_cq; } diff --git a/src/uct/ib/mlx5/dv/ib_mlx5_dv.h b/src/uct/ib/mlx5/dv/ib_mlx5_dv.h index 158db3d1d66..e8f33be8c01 100644 --- a/src/uct/ib/mlx5/dv/ib_mlx5_dv.h +++ b/src/uct/ib/mlx5/dv/ib_mlx5_dv.h @@ -57,7 +57,7 @@ void uct_ib_mlx5dv_dct_qp_init_attr(uct_ib_qp_init_attr_t *qp_attr, * Creates CQ and SRQ which are needed for creating QP. */ ucs_status_t -uct_ib_mlx5dv_qp_tmp_objs_create(uct_ib_device_t *dev, struct ibv_pd *pd, +uct_ib_mlx5dv_qp_tmp_objs_create(struct ibv_pd *pd, uct_ib_mlx5dv_qp_tmp_objs_t *qp_tmp_objs, int silent); diff --git a/src/uct/ib/mlx5/dv/ib_mlx5dv_md.c b/src/uct/ib/mlx5/dv/ib_mlx5dv_md.c index 0a1af5048a6..3953d0083d2 100644 --- a/src/uct/ib/mlx5/dv/ib_mlx5dv_md.c +++ b/src/uct/ib/mlx5/dv/ib_mlx5dv_md.c @@ -1168,9 +1168,8 @@ uct_ib_mlx5_devx_open_device(struct ibv_device *ibv_device) cq = ibv_create_cq(ctx, 1, NULL, NULL, 0); if (cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, - "%s: ibv_create_cq()", - ibv_get_device_name(ibv_device)); + uct_ib_check_memlock_limit_msg(ctx, UCS_LOG_LEVEL_DEBUG, + "ibv_create_cq()"); goto close_ctx; } @@ -1900,6 +1899,7 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) char out[UCT_IB_MLX5DV_ST_SZ_BYTES(query_qp_out)] = {}; struct ibv_qp_init_attr qp_init_attr = {}; struct ibv_qp_attr qp_attr = {}; + uct_ib_device_t *dev = &md->super.dev; uint8_t *counter_set_id; struct ibv_qp *dummy_qp; struct ibv_cq *dummy_cq; @@ -1911,11 +1911,10 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) return *counter_set_id; } - dummy_cq = ibv_create_cq(md->super.dev.ibv_context, 1, NULL, NULL, 0); + dummy_cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0); if (dummy_cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, - "%s: ibv_create_cq()", - uct_ib_device_name(&md->super.dev)); + uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_DEBUG, + "ibv_create_cq()"); goto err; } @@ -1929,9 +1928,8 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) dummy_qp = ibv_create_qp(md->super.pd, &qp_init_attr); if (dummy_qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, - "%s: ibv_create_qp()", - uct_ib_device_name(&md->super.dev)); + uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_DEBUG, + "ibv_create_qp(RC)"); goto err_free_cq; } @@ -1943,8 +1941,7 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) IBV_QP_ACCESS_FLAGS); if (ret) { ucs_diag("failed to modify dummy QP 0x%x to INIT on %s:%d: %m", - dummy_qp->qp_num, uct_ib_device_name(&md->super.dev), - port_num); + dummy_qp->qp_num, uct_ib_device_name(dev), port_num); goto err_destroy_qp; } @@ -1955,7 +1952,7 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) if (ret) { ucs_diag("mlx5dv_devx_qp_query(%s:%d, DUMMY_QP, QPN=0x%x) failed, " "syndrome 0x%x: %m", - uct_ib_device_name(&md->super.dev), port_num, dummy_qp->qp_num, + uct_ib_device_name(dev), port_num, dummy_qp->qp_num, UCT_IB_MLX5DV_GET(query_qp_out, out, syndrome)); goto err_destroy_qp; } @@ -1965,8 +1962,8 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) ibv_destroy_qp(dummy_qp); ibv_destroy_cq(dummy_cq); - ucs_debug("counter_set_id on %s:%d is 0x%x", - uct_ib_device_name(&md->super.dev), port_num, *counter_set_id); + ucs_debug("counter_set_id on %s:%d is 0x%x", uct_ib_device_name(dev), + port_num, *counter_set_id); return *counter_set_id; err_destroy_qp: @@ -1975,8 +1972,8 @@ uct_ib_mlx5_devx_md_get_counter_set_id(uct_ib_mlx5_md_t *md, uint8_t port_num) ibv_destroy_cq(dummy_cq); err: *counter_set_id = 0; - ucs_debug("using zero counter_set_id on %s:%d", - uct_ib_device_name(&md->super.dev), port_num); + ucs_debug("using zero counter_set_id on %s:%d", uct_ib_device_name(dev), + port_num); return 0; } @@ -2383,7 +2380,7 @@ static void uct_ib_mlx5dv_check_dc(uct_ib_device_t *dev) goto out; } - status = uct_ib_mlx5dv_qp_tmp_objs_create(dev, pd, &qp_tmp_objs, 1); + status = uct_ib_mlx5dv_qp_tmp_objs_create(pd, &qp_tmp_objs, 1); if (status != UCS_OK) { goto out_dealloc_pd; } diff --git a/src/uct/ib/mlx5/ib_mlx5.c b/src/uct/ib/mlx5/ib_mlx5.c index b946c758f6e..f77c928fc62 100644 --- a/src/uct/ib/mlx5/ib_mlx5.c +++ b/src/uct/ib/mlx5/ib_mlx5.c @@ -123,9 +123,8 @@ uct_ib_mlx5_create_cq(uct_ib_iface_t *iface, uct_ib_dir_t dir, cq = ibv_cq_ex_to_cq(mlx5dv_create_cq(dev->ibv_context, &cq_attr, &dv_attr)); if (cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, - "%s: mlx5dv_create_cq(cqe=%d)", - uct_ib_device_name(dev), cq_attr.cqe); + uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR, + "mlx5dv_create_cq(cqe=%d)", cq_attr.cqe); return UCS_ERR_IO_ERROR; } diff --git a/src/uct/ib/mlx5/ib_mlx5.h b/src/uct/ib/mlx5/ib_mlx5.h index bd5b758af7c..9c509c42d00 100644 --- a/src/uct/ib/mlx5/ib_mlx5.h +++ b/src/uct/ib/mlx5/ib_mlx5.h @@ -883,7 +883,9 @@ uct_ib_mlx5_md_buf_alloc(uct_ib_mlx5_md_t *md, size_t size, int silent, void **buf_p, uct_ib_mlx5_devx_umem_t *mem, int access_mode, char *name) { - ucs_log_level_t level = silent ? UCS_LOG_LEVEL_DEBUG : UCS_LOG_LEVEL_ERROR; + struct ibv_context *ibv_context = md->super.dev.ibv_context; + const ucs_log_level_t level = silent ? UCS_LOG_LEVEL_DEBUG : + UCS_LOG_LEVEL_ERROR; ucs_status_t status; void *buf; int ret; @@ -904,10 +906,12 @@ uct_ib_mlx5_md_buf_alloc(uct_ib_mlx5_md_t *md, size_t size, int silent, } mem->size = size; - mem->mem = mlx5dv_devx_umem_reg(md->super.dev.ibv_context, buf, size, - access_mode); + mem->mem = mlx5dv_devx_umem_reg(ibv_context, buf, size, access_mode); if (mem->mem == NULL) { - uct_ib_check_memlock_limit_msg(level, "mlx5dv_devx_umem_reg()"); + uct_ib_check_memlock_limit_msg( + ibv_context, level, + "mlx5dv_devx_umem_reg(size=%zu access=0x%x)", size, + access_mode); status = UCS_ERR_NO_MEMORY; goto err_dofork; } diff --git a/src/uct/ib/rc/accel/gga_mlx5.c b/src/uct/ib/rc/accel/gga_mlx5.c index af7845d6c9f..014ae933db7 100644 --- a/src/uct/ib/rc/accel/gga_mlx5.c +++ b/src/uct/ib/rc/accel/gga_mlx5.c @@ -222,8 +222,9 @@ uct_gga_mlx5_query_tl_devices(uct_md_h md, } status = uct_ib_device_query_ports(&mlx5_md->super.dev, - UCT_IB_DEVICE_FLAG_MLX5_PRM, &tl_devices, - &num_tl_devices); + UCT_IB_DEVICE_FLAG_SRQ | + UCT_IB_DEVICE_FLAG_MLX5_PRM, + &tl_devices, &num_tl_devices); if (status != UCS_OK) { return status; } diff --git a/src/uct/ib/rc/accel/rc_mlx5_iface.c b/src/uct/ib/rc/accel/rc_mlx5_iface.c index af8313148d9..e87fcd47d81 100644 --- a/src/uct/ib/rc/accel/rc_mlx5_iface.c +++ b/src/uct/ib/rc/accel/rc_mlx5_iface.c @@ -323,7 +323,7 @@ ucs_status_t uct_rc_mlx5_iface_create_qp(uct_rc_mlx5_iface_common_t *iface, uct_ib_mlx5_md_t *md = uct_ib_mlx5_iface_md(ib_iface); ucs_status_t status; #if HAVE_DEVX - uct_ib_device_t *dev = &md->super.dev; + struct ibv_context *ibv_context = md->super.dev.ibv_context; struct mlx5dv_qp_init_attr dv_attr = {}; uint64_t cookie; @@ -365,12 +365,11 @@ ucs_status_t uct_rc_mlx5_iface_create_qp(uct_rc_mlx5_iface_common_t *iface, uct_rc_mlx5_common_fill_dv_qp_attr(iface, &attr->super.ibv, &dv_attr, UCS_BIT(UCT_IB_DIR_TX) | UCS_BIT(UCT_IB_DIR_RX)); - qp->verbs.qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, dev->ibv_context, + qp->verbs.qp = UCS_PROFILE_CALL_ALWAYS(mlx5dv_create_qp, ibv_context, &attr->super.ibv, &dv_attr); if (qp->verbs.qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, - "%s: mlx5dv_create_qp("UCT_IB_IFACE_FMT")", - uct_ib_device_name(dev), + uct_ib_check_memlock_limit_msg(ibv_context, UCS_LOG_LEVEL_ERROR, + "mlx5dv_create_qp(" UCT_IB_IFACE_FMT ")", UCT_IB_IFACE_ARG(ib_iface)); status = UCS_ERR_IO_ERROR; goto err; @@ -1089,7 +1088,7 @@ uct_rc_mlx5_query_tl_devices(uct_md_h md, uct_tl_device_resource_t **tl_devices_ return UCS_ERR_NO_DEVICE; } - flags = UCT_IB_DEVICE_FLAG_MLX5_PRM | + flags = UCT_IB_DEVICE_FLAG_SRQ | UCT_IB_DEVICE_FLAG_MLX5_PRM | (ib_md->config.eth_pause ? 0 : UCT_IB_DEVICE_FLAG_LINK_IB); return uct_ib_device_query_ports(&ib_md->dev, flags, tl_devices_p, num_tl_devices_p); diff --git a/src/uct/ib/rc/base/rc_iface.c b/src/uct/ib/rc/base/rc_iface.c index 0a2ac875433..5b51aa28242 100644 --- a/src/uct/ib/rc/base/rc_iface.c +++ b/src/uct/ib/rc/base/rc_iface.c @@ -510,7 +510,8 @@ ucs_status_t uct_rc_iface_init_rx(uct_rc_iface_t *iface, srq_init_attr.srq_context = iface; srq = ibv_create_srq(pd, &srq_init_attr); if (srq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, "ibv_create_srq()"); + uct_ib_check_memlock_limit_msg(pd->context, UCS_LOG_LEVEL_ERROR, + "ibv_create_srq()"); return UCS_ERR_IO_ERROR; } iface->rx.srq.quota = srq_init_attr.attr.max_wr; diff --git a/src/uct/ib/rc/verbs/rc_verbs_iface.c b/src/uct/ib/rc/verbs/rc_verbs_iface.c index db412e531a4..e045cd07faf 100644 --- a/src/uct/ib/rc/verbs/rc_verbs_iface.c +++ b/src/uct/ib/rc/verbs/rc_verbs_iface.c @@ -528,8 +528,7 @@ static uct_rc_iface_ops_t uct_rc_verbs_iface_ops = { .ep_vfs_populate = uct_rc_verbs_ep_vfs_populate }; -static ucs_status_t -uct_rc_verbs_can_create_qp(struct ibv_context *ctx, struct ibv_pd *pd) +static ucs_status_t uct_rc_verbs_can_create_qp(struct ibv_pd *pd) { struct ibv_qp_init_attr qp_init_attr = { .qp_type = IBV_QPT_RC, @@ -544,9 +543,10 @@ uct_rc_verbs_can_create_qp(struct ibv_context *ctx, struct ibv_pd *pd) struct ibv_qp *qp; ucs_status_t status; - cq = ibv_create_cq(ctx, 1, NULL, NULL, 0); + cq = ibv_create_cq(pd->context, 1, NULL, NULL, 0); if (cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, "ibv_create_cq()"); + uct_ib_check_memlock_limit_msg(pd->context, UCS_LOG_LEVEL_DEBUG, + "ibv_create_cq()"); status = UCS_ERR_IO_ERROR; goto err; } @@ -556,7 +556,8 @@ uct_rc_verbs_can_create_qp(struct ibv_context *ctx, struct ibv_pd *pd) qp = ibv_create_qp(pd, &qp_init_attr); if (qp == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_DEBUG, "ibv_create_qp()"); + uct_ib_check_memlock_limit_msg(pd->context, UCS_LOG_LEVEL_DEBUG, + "ibv_create_qp(RC)"); status = UCS_ERR_UNSUPPORTED; goto err_destroy_cq; } @@ -579,13 +580,13 @@ uct_rc_verbs_query_tl_devices(uct_md_h md, ucs_status_t status; /* device does not support RC if we cannot create an RC QP */ - status = uct_rc_verbs_can_create_qp(ib_md->dev.ibv_context, ib_md->pd); + status = uct_rc_verbs_can_create_qp(ib_md->pd); if (status != UCS_OK) { return status; } - return uct_ib_device_query_ports(&ib_md->dev, 0, tl_devices_p, - num_tl_devices_p); + return uct_ib_device_query_ports(&ib_md->dev, UCT_IB_DEVICE_FLAG_SRQ, + tl_devices_p, num_tl_devices_p); } UCT_TL_DEFINE_ENTRY(&uct_ib_component, rc_verbs, uct_rc_verbs_query_tl_devices, diff --git a/src/uct/ib/rdmacm/rdmacm_cm.c b/src/uct/ib/rdmacm/rdmacm_cm.c index bef4c0f349a..49a10084944 100644 --- a/src/uct/ib/rdmacm/rdmacm_cm.c +++ b/src/uct/ib/rdmacm/rdmacm_cm.c @@ -187,8 +187,8 @@ uct_rdmacm_cm_device_context_init(uct_rdmacm_cm_device_context_t *ctx, /* Create a dummy completion queue */ ctx->cq = ibv_create_cq(verbs, 1, NULL, NULL, 0); if (ctx->cq == NULL) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, - "%s: ibv_create_cq()", dev_name); + uct_ib_check_memlock_limit_msg(verbs, UCS_LOG_LEVEL_ERROR, + "ibv_create_cq()"); return UCS_ERR_IO_ERROR; } diff --git a/src/uct/ib/ud/accel/ud_mlx5.c b/src/uct/ib/ud/accel/ud_mlx5.c index eefb99af4b2..f8b188f2f50 100644 --- a/src/uct/ib/ud/accel/ud_mlx5.c +++ b/src/uct/ib/ud/accel/ud_mlx5.c @@ -803,7 +803,9 @@ static ucs_status_t uct_ud_mlx5_iface_create_qp(uct_ib_iface_t *ib_iface, status = uct_ib_mlx5_iface_create_qp(ib_iface, qp, &attr); if (status != UCS_OK) { - uct_ib_check_memlock_limit_msg(UCS_LOG_LEVEL_ERROR, "ibv_create_qp()"); + uct_ib_check_memlock_limit_msg(ib_md->super.dev.ibv_context, + UCS_LOG_LEVEL_ERROR, + "ibv_create_qp(UD)"); return status; } @@ -910,22 +912,31 @@ static ucs_status_t uct_ud_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md) uct_ib_device_t *dev = &md->super.dev; ucs_status_t status; struct ibv_qp *qp; - uct_ib_mlx5dv_qp_tmp_objs_t qp_tmp_objs; + struct ibv_cq *cq; if (md->dv_tx_wqe_ratio.ud != 0) { return UCS_OK; } - status = uct_ib_mlx5dv_qp_tmp_objs_create(dev, md->super.pd, &qp_tmp_objs, 0); - if (status != UCS_OK) { + cq = ibv_create_cq(dev->ibv_context, 1, NULL, NULL, 0); + if (cq == NULL) { + uct_ib_check_memlock_limit_msg(dev->ibv_context, UCS_LOG_LEVEL_ERROR, + "ibv_create_cq()"); + status = UCS_ERR_IO_ERROR; goto out; } - uct_ib_mlx5dv_qp_init_attr(&qp_init_attr, md->super.pd, &qp_tmp_objs, - IBV_QPT_UD, 128); + qp_init_attr.send_cq = cq; + qp_init_attr.recv_cq = cq; + qp_init_attr.qp_type = IBV_QPT_UD; + qp_init_attr.sq_sig_all = 0; + qp_init_attr.cap.max_send_wr = 128; + qp_init_attr.cap.max_recv_wr = 128; uct_ud_mlx5_qp_update_caps(&qp_init_attr.cap); #if HAVE_DECL_IBV_CREATE_QP_EX + qp_init_attr.comp_mask = IBV_QP_INIT_ATTR_PD; + qp_init_attr.pd = md->super.pd; qp = UCS_PROFILE_CALL_ALWAYS(ibv_create_qp_ex, dev->ibv_context, &qp_init_attr); #else @@ -940,7 +951,7 @@ static ucs_status_t uct_ud_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md) qp_init_attr.cap.max_inline_data, qp_init_attr.cap.max_recv_wr, qp_init_attr.cap.max_recv_sge); status = UCS_ERR_IO_ERROR; - goto out_qp_tmp_objs_close; + goto out_destroy_cq; } status = uct_ib_mlx5dv_calc_tx_wqe_ratio(qp, qp_init_attr.cap.max_send_wr, @@ -948,8 +959,8 @@ static ucs_status_t uct_ud_mlx5dv_calc_tx_wqe_ratio(uct_ib_mlx5_md_t *md) uct_ib_destroy_qp(qp); -out_qp_tmp_objs_close: - uct_ib_mlx5dv_qp_tmp_objs_destroy(&qp_tmp_objs); +out_destroy_cq: + ibv_destroy_cq(cq); out: return status; }