Skip to content

Commit

Permalink
providers/mana: Introduce a struct for raw QPs
Browse files Browse the repository at this point in the history
Define struct for fields related to raw QPs.

Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
  • Loading branch information
Konstantin Taranov committed Jul 1, 2024
1 parent a8e4f0f commit 7314f71
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
12 changes: 7 additions & 5 deletions providers/mana/mana.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions providers/mana/manadv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
24 changes: 12 additions & 12 deletions providers/mana/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,37 @@ 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;
}

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,
sizeof(qp_cmd), &qp_resp.ibv_resp,
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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7314f71

Please sign in to comment.