From 7314f715bf1c08c55706d4f50bc5aaabde7e449c Mon Sep 17 00:00:00 2001 From: Konstantin Taranov Date: Tue, 14 May 2024 11:21:07 +0200 Subject: [PATCH] providers/mana: Introduce a struct for raw QPs Define struct for fields related to raw QPs. Signed-off-by: Konstantin Taranov --- providers/mana/mana.h | 12 +++++++----- providers/mana/manadv.c | 10 +++++----- providers/mana/qp.c | 24 ++++++++++++------------ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/providers/mana/mana.h b/providers/mana/mana.h index 35b7b14d0..0d64d92ad 100644 --- a/providers/mana/mana.h +++ b/providers/mana/mana.h @@ -60,18 +60,20 @@ struct mana_gdma_queue { void *buffer; }; -struct mana_qp { - struct verbs_qp ibqp; - +struct mana_ib_raw_qp { void *send_buf; uint32_t send_buf_size; - int send_wqe_count; - uint32_t sqid; uint32_t tx_vp_offset; }; +struct mana_qp { + struct verbs_qp ibqp; + + struct mana_ib_raw_qp raw_qp; +}; + struct mana_wq { struct ibv_wq ibwq; diff --git a/providers/mana/manadv.c b/providers/mana/manadv.c index 3fcd52335..4b40d05bb 100644 --- a/providers/mana/manadv.c +++ b/providers/mana/manadv.c @@ -53,11 +53,11 @@ int manadv_init_obj(struct manadv_obj *obj, uint64_t obj_type) struct ibv_context *context = ibqp->context; struct mana_context *ctx = to_mctx(context); - obj->qp.out->sq_buf = qp->send_buf; - obj->qp.out->sq_count = qp->send_wqe_count; - obj->qp.out->sq_size = qp->send_buf_size; - obj->qp.out->sq_id = qp->sqid; - obj->qp.out->tx_vp_offset = qp->tx_vp_offset; + obj->qp.out->sq_buf = qp->raw_qp.send_buf; + obj->qp.out->sq_count = qp->raw_qp.send_wqe_count; + obj->qp.out->sq_size = qp->raw_qp.send_buf_size; + obj->qp.out->sq_id = qp->raw_qp.sqid; + obj->qp.out->tx_vp_offset = qp->raw_qp.tx_vp_offset; obj->qp.out->db_page = ctx->db_page; } diff --git a/providers/mana/qp.c b/providers/mana/qp.c index 328ce419d..0db1b6fe5 100644 --- a/providers/mana/qp.c +++ b/providers/mana/qp.c @@ -67,13 +67,13 @@ static struct ibv_qp *mana_create_qp_raw(struct ibv_pd *ibpd, if (!qp) return NULL; - qp->send_buf_size = + qp->raw_qp.send_buf_size = attr->cap.max_send_wr * get_wqe_size(attr->cap.max_send_sge); - qp->send_buf_size = align_hw_size(qp->send_buf_size); + qp->raw_qp.send_buf_size = align_hw_size(qp->raw_qp.send_buf_size); - qp->send_buf = ctx->extern_alloc.alloc(qp->send_buf_size, - ctx->extern_alloc.data); - if (!qp->send_buf) { + qp->raw_qp.send_buf = ctx->extern_alloc.alloc(qp->raw_qp.send_buf_size, + ctx->extern_alloc.data); + if (!qp->raw_qp.send_buf) { errno = ENOMEM; goto free_qp; } @@ -81,8 +81,8 @@ static struct ibv_qp *mana_create_qp_raw(struct ibv_pd *ibpd, qp_cmd_drv = &qp_cmd.drv_payload; qp_resp_drv = &qp_resp.drv_payload; - qp_cmd_drv->sq_buf_addr = (uintptr_t)qp->send_buf; - qp_cmd_drv->sq_buf_size = qp->send_buf_size; + qp_cmd_drv->sq_buf_addr = (uintptr_t)qp->raw_qp.send_buf; + qp_cmd_drv->sq_buf_size = qp->raw_qp.send_buf_size; qp_cmd_drv->port = port; ret = ibv_cmd_create_qp(ibpd, &qp->ibqp.qp, attr, &qp_cmd.ibv_cmd, @@ -90,14 +90,14 @@ static struct ibv_qp *mana_create_qp_raw(struct ibv_pd *ibpd, sizeof(qp_resp)); if (ret) { verbs_err(verbs_get_ctx(ibpd->context), "Create QP failed\n"); - ctx->extern_alloc.free(qp->send_buf, ctx->extern_alloc.data); + ctx->extern_alloc.free(qp->raw_qp.send_buf, ctx->extern_alloc.data); errno = ret; goto free_qp; } - qp->sqid = qp_resp_drv->sqid; - qp->tx_vp_offset = qp_resp_drv->tx_vp_offset; - qp->send_wqe_count = attr->cap.max_send_wr; + qp->raw_qp.sqid = qp_resp_drv->sqid; + qp->raw_qp.tx_vp_offset = qp_resp_drv->tx_vp_offset; + qp->raw_qp.send_wqe_count = attr->cap.max_send_wr; cq->cqid = qp_resp_drv->cqid; @@ -150,7 +150,7 @@ int mana_destroy_qp(struct ibv_qp *ibqp) return ret; } - ctx->extern_alloc.free(qp->send_buf, ctx->extern_alloc.data); + ctx->extern_alloc.free(qp->raw_qp.send_buf, ctx->extern_alloc.data); free(qp); return 0;