Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/mana_ib: Use struct mana_ib_queue for CQs

Use struct mana_ib_queue and its helpers for CQs

Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Link: https://lore.kernel.org/r/1711483688-24358-3-git-send-email-kotaranov@linux.microsoft.com
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Konstantin Taranov and committed by
Leon Romanovsky
60a7ac0b 46f5be7c

+24 -58
+10 -42
drivers/infiniband/hw/mana/cq.c
··· 39 39 } 40 40 41 41 cq->cqe = attr->cqe; 42 - cq->umem = ib_umem_get(ibdev, ucmd.buf_addr, cq->cqe * COMP_ENTRY_SIZE, 43 - IB_ACCESS_LOCAL_WRITE); 44 - if (IS_ERR(cq->umem)) { 45 - err = PTR_ERR(cq->umem); 46 - ibdev_dbg(ibdev, "Failed to get umem for create cq, err %d\n", 47 - err); 42 + err = mana_ib_create_queue(mdev, ucmd.buf_addr, cq->cqe * COMP_ENTRY_SIZE, &cq->queue); 43 + if (err) { 44 + ibdev_dbg(ibdev, "Failed to create queue for create cq, %d\n", err); 48 45 return err; 49 46 } 50 47 51 - err = mana_ib_create_zero_offset_dma_region(mdev, cq->umem, &cq->gdma_region); 52 - if (err) { 53 - ibdev_dbg(ibdev, 54 - "Failed to create dma region for create cq, %d\n", 55 - err); 56 - goto err_release_umem; 57 - } 58 - 59 - ibdev_dbg(ibdev, 60 - "create_dma_region ret %d gdma_region 0x%llx\n", 61 - err, cq->gdma_region); 62 - 63 - /* 64 - * The CQ ID is not known at this time. The ID is generated at create_qp 65 - */ 66 - cq->id = INVALID_QUEUE_ID; 67 - 68 48 return 0; 69 - 70 - err_release_umem: 71 - ib_umem_release(cq->umem); 72 - return err; 73 49 } 74 50 75 51 int mana_ib_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) ··· 54 78 struct ib_device *ibdev = ibcq->device; 55 79 struct mana_ib_dev *mdev; 56 80 struct gdma_context *gc; 57 - int err; 58 81 59 82 mdev = container_of(ibdev, struct mana_ib_dev, ib_dev); 60 83 gc = mdev_to_gc(mdev); 61 84 62 - err = mana_ib_gd_destroy_dma_region(mdev, cq->gdma_region); 63 - if (err) { 64 - ibdev_dbg(ibdev, 65 - "Failed to destroy dma region, %d\n", err); 66 - return err; 85 + if (cq->queue.id != INVALID_QUEUE_ID) { 86 + kfree(gc->cq_table[cq->queue.id]); 87 + gc->cq_table[cq->queue.id] = NULL; 67 88 } 68 89 69 - if (cq->id != INVALID_QUEUE_ID) { 70 - kfree(gc->cq_table[cq->id]); 71 - gc->cq_table[cq->id] = NULL; 72 - } 73 - 74 - ib_umem_release(cq->umem); 90 + mana_ib_destroy_queue(mdev, &cq->queue); 75 91 76 92 return 0; 77 93 } ··· 82 114 struct gdma_queue *gdma_cq; 83 115 84 116 /* Create CQ table entry */ 85 - WARN_ON(gc->cq_table[cq->id]); 117 + WARN_ON(gc->cq_table[cq->queue.id]); 86 118 gdma_cq = kzalloc(sizeof(*gdma_cq), GFP_KERNEL); 87 119 if (!gdma_cq) 88 120 return -ENOMEM; ··· 90 122 gdma_cq->cq.context = cq; 91 123 gdma_cq->type = GDMA_CQ; 92 124 gdma_cq->cq.callback = mana_ib_cq_handler; 93 - gdma_cq->id = cq->id; 94 - gc->cq_table[cq->id] = gdma_cq; 125 + gdma_cq->id = cq->queue.id; 126 + gc->cq_table[cq->queue.id] = gdma_cq; 95 127 return 0; 96 128 }
+1 -3
drivers/infiniband/hw/mana/mana_ib.h
··· 88 88 89 89 struct mana_ib_cq { 90 90 struct ib_cq ibcq; 91 - struct ib_umem *umem; 91 + struct mana_ib_queue queue; 92 92 int cqe; 93 - u64 gdma_region; 94 - u64 id; 95 93 u32 comp_vector; 96 94 }; 97 95
+13 -13
drivers/infiniband/hw/mana/qp.c
··· 197 197 wq_spec.gdma_region = wq->gdma_region; 198 198 wq_spec.queue_size = wq->wq_buf_size; 199 199 200 - cq_spec.gdma_region = cq->gdma_region; 200 + cq_spec.gdma_region = cq->queue.gdma_region; 201 201 cq_spec.queue_size = cq->cqe * COMP_ENTRY_SIZE; 202 202 cq_spec.modr_ctx_id = 0; 203 203 eq = &mpc->ac->eqs[cq->comp_vector % gc->max_num_queues]; ··· 213 213 214 214 /* The GDMA regions are now owned by the WQ object */ 215 215 wq->gdma_region = GDMA_INVALID_DMA_REGION; 216 - cq->gdma_region = GDMA_INVALID_DMA_REGION; 216 + cq->queue.gdma_region = GDMA_INVALID_DMA_REGION; 217 217 218 218 wq->id = wq_spec.queue_index; 219 - cq->id = cq_spec.queue_index; 219 + cq->queue.id = cq_spec.queue_index; 220 220 221 221 ibdev_dbg(&mdev->ib_dev, 222 222 "ret %d rx_object 0x%llx wq id %llu cq id %llu\n", 223 - ret, wq->rx_object, wq->id, cq->id); 223 + ret, wq->rx_object, wq->id, cq->queue.id); 224 224 225 - resp.entries[i].cqid = cq->id; 225 + resp.entries[i].cqid = cq->queue.id; 226 226 resp.entries[i].wqid = wq->id; 227 227 228 228 mana_ind_table[i] = wq->rx_object; ··· 232 232 if (ret) 233 233 goto fail; 234 234 235 - gdma_cq_allocated[i] = gc->cq_table[cq->id]; 235 + gdma_cq_allocated[i] = gc->cq_table[cq->queue.id]; 236 236 } 237 237 resp.num_entries = i; 238 238 ··· 264 264 wq = container_of(ibwq, struct mana_ib_wq, ibwq); 265 265 cq = container_of(ibcq, struct mana_ib_cq, ibcq); 266 266 267 - gc->cq_table[cq->id] = NULL; 267 + gc->cq_table[cq->queue.id] = NULL; 268 268 kfree(gdma_cq_allocated[i]); 269 269 270 270 mana_destroy_wq_obj(mpc, GDMA_RQ, wq->rx_object); ··· 374 374 wq_spec.gdma_region = qp->sq_gdma_region; 375 375 wq_spec.queue_size = ucmd.sq_buf_size; 376 376 377 - cq_spec.gdma_region = send_cq->gdma_region; 377 + cq_spec.gdma_region = send_cq->queue.gdma_region; 378 378 cq_spec.queue_size = send_cq->cqe * COMP_ENTRY_SIZE; 379 379 cq_spec.modr_ctx_id = 0; 380 380 eq_vec = send_cq->comp_vector % gc->max_num_queues; ··· 392 392 393 393 /* The GDMA regions are now owned by the WQ object */ 394 394 qp->sq_gdma_region = GDMA_INVALID_DMA_REGION; 395 - send_cq->gdma_region = GDMA_INVALID_DMA_REGION; 395 + send_cq->queue.gdma_region = GDMA_INVALID_DMA_REGION; 396 396 397 397 qp->sq_id = wq_spec.queue_index; 398 - send_cq->id = cq_spec.queue_index; 398 + send_cq->queue.id = cq_spec.queue_index; 399 399 400 400 /* Create CQ table entry */ 401 401 err = mana_ib_install_cq_cb(mdev, send_cq); ··· 404 404 405 405 ibdev_dbg(&mdev->ib_dev, 406 406 "ret %d qp->tx_object 0x%llx sq id %llu cq id %llu\n", err, 407 - qp->tx_object, qp->sq_id, send_cq->id); 407 + qp->tx_object, qp->sq_id, send_cq->queue.id); 408 408 409 409 resp.sqid = qp->sq_id; 410 - resp.cqid = send_cq->id; 410 + resp.cqid = send_cq->queue.id; 411 411 resp.tx_vp_offset = pd->tx_vp_offset; 412 412 413 413 err = ib_copy_to_udata(udata, &resp, sizeof(resp)); ··· 422 422 423 423 err_release_gdma_cq: 424 424 kfree(gdma_cq); 425 - gc->cq_table[send_cq->id] = NULL; 425 + gc->cq_table[send_cq->queue.id] = NULL; 426 426 427 427 err_destroy_wq_obj: 428 428 mana_destroy_wq_obj(mpc, GDMA_SQ, qp->tx_object);