Skip to content

Commit

Permalink
RDMA/mana_ib: Use struct mana_ib_queue for RAW QPs
Browse files Browse the repository at this point in the history
Use struct mana_ib_queue and its helpers for RAW QPs

Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Link: https://lore.kernel.org/r/1711483688-24358-5-git-send-email-kotaranov@linux.microsoft.com
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
  • Loading branch information
Konstantin Taranov authored and rleon committed Apr 2, 2024
1 parent 688bac2 commit f10242b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 46 deletions.
8 changes: 2 additions & 6 deletions drivers/infiniband/hw/mana/mana_ib.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,8 @@ struct mana_ib_cq {
struct mana_ib_qp {
struct ib_qp ibqp;

/* Work queue info */
struct ib_umem *sq_umem;
int sqe;
u64 sq_gdma_region;
u64 sq_id;
mana_handle_t tx_object;
mana_handle_t qp_handle;
struct mana_ib_queue raw_sq;

/* The port on the IB device, starting with 1 */
u32 port;
Expand Down
56 changes: 16 additions & 40 deletions drivers/infiniband/hw/mana/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
struct mana_obj_spec cq_spec = {};
struct mana_port_context *mpc;
struct net_device *ndev;
struct ib_umem *umem;
struct mana_eq *eq;
int eq_vec;
u32 port;
Expand Down Expand Up @@ -346,32 +345,15 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
ibdev_dbg(&mdev->ib_dev, "ucmd sq_buf_addr 0x%llx port %u\n",
ucmd.sq_buf_addr, ucmd.port);

umem = ib_umem_get(ibpd->device, ucmd.sq_buf_addr, ucmd.sq_buf_size,
IB_ACCESS_LOCAL_WRITE);
if (IS_ERR(umem)) {
err = PTR_ERR(umem);
ibdev_dbg(&mdev->ib_dev,
"Failed to get umem for create qp-raw, err %d\n",
err);
goto err_free_vport;
}
qp->sq_umem = umem;

err = mana_ib_create_zero_offset_dma_region(mdev, qp->sq_umem,
&qp->sq_gdma_region);
err = mana_ib_create_queue(mdev, ucmd.sq_buf_addr, ucmd.sq_buf_size, &qp->raw_sq);
if (err) {
ibdev_dbg(&mdev->ib_dev,
"Failed to create dma region for create qp-raw, %d\n",
err);
goto err_release_umem;
"Failed to create queue for create qp-raw, err %d\n", err);
goto err_free_vport;
}

ibdev_dbg(&mdev->ib_dev,
"create_dma_region ret %d gdma_region 0x%llx\n",
err, qp->sq_gdma_region);

/* Create a WQ on the same port handle used by the Ethernet */
wq_spec.gdma_region = qp->sq_gdma_region;
wq_spec.gdma_region = qp->raw_sq.gdma_region;
wq_spec.queue_size = ucmd.sq_buf_size;

cq_spec.gdma_region = send_cq->queue.gdma_region;
Expand All @@ -382,19 +364,19 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
cq_spec.attached_eq = eq->eq->id;

err = mana_create_wq_obj(mpc, mpc->port_handle, GDMA_SQ, &wq_spec,
&cq_spec, &qp->tx_object);
&cq_spec, &qp->qp_handle);
if (err) {
ibdev_dbg(&mdev->ib_dev,
"Failed to create wq for create raw-qp, err %d\n",
err);
goto err_destroy_dma_region;
goto err_destroy_queue;
}

/* The GDMA regions are now owned by the WQ object */
qp->sq_gdma_region = GDMA_INVALID_DMA_REGION;
qp->raw_sq.gdma_region = GDMA_INVALID_DMA_REGION;
send_cq->queue.gdma_region = GDMA_INVALID_DMA_REGION;

qp->sq_id = wq_spec.queue_index;
qp->raw_sq.id = wq_spec.queue_index;
send_cq->queue.id = cq_spec.queue_index;

/* Create CQ table entry */
Expand All @@ -403,10 +385,10 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
goto err_destroy_wq_obj;

ibdev_dbg(&mdev->ib_dev,
"ret %d qp->tx_object 0x%llx sq id %llu cq id %llu\n", err,
qp->tx_object, qp->sq_id, send_cq->queue.id);
"ret %d qp->qp_handle 0x%llx sq id %llu cq id %llu\n", err,
qp->qp_handle, qp->raw_sq.id, send_cq->queue.id);

resp.sqid = qp->sq_id;
resp.sqid = qp->raw_sq.id;
resp.cqid = send_cq->queue.id;
resp.tx_vp_offset = pd->tx_vp_offset;

Expand All @@ -425,13 +407,10 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
gc->cq_table[send_cq->queue.id] = NULL;

err_destroy_wq_obj:
mana_destroy_wq_obj(mpc, GDMA_SQ, qp->tx_object);
mana_destroy_wq_obj(mpc, GDMA_SQ, qp->qp_handle);

err_destroy_dma_region:
mana_ib_gd_destroy_dma_region(mdev, qp->sq_gdma_region);

err_release_umem:
ib_umem_release(umem);
err_destroy_queue:
mana_ib_destroy_queue(mdev, &qp->raw_sq);

err_free_vport:
mana_ib_uncfg_vport(mdev, pd, port);
Expand Down Expand Up @@ -505,12 +484,9 @@ static int mana_ib_destroy_qp_raw(struct mana_ib_qp *qp, struct ib_udata *udata)
mpc = netdev_priv(ndev);
pd = container_of(ibpd, struct mana_ib_pd, ibpd);

mana_destroy_wq_obj(mpc, GDMA_SQ, qp->tx_object);
mana_destroy_wq_obj(mpc, GDMA_SQ, qp->qp_handle);

if (qp->sq_umem) {
mana_ib_gd_destroy_dma_region(mdev, qp->sq_gdma_region);
ib_umem_release(qp->sq_umem);
}
mana_ib_destroy_queue(mdev, &qp->raw_sq);

mana_ib_uncfg_vport(mdev, pd, qp->port);

Expand Down

0 comments on commit f10242b

Please sign in to comment.