Skip to content

Commit 44b607a

Browse files
Konstantin Taranovrleon
authored andcommitted
RDMA/mana_ib: implement uapi for creation of rnic cq
Enable users to create RNIC CQs using a corresponding flag. With the previous request size, an ethernet CQ is created. As a response, return ID of the created CQ. Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com> Link: https://lore.kernel.org/r/1714137160-5222-6-git-send-email-kotaranov@linux.microsoft.com Reviewed-by: Long Li <longli@microsoft.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent f79edef commit 44b607a

File tree

2 files changed

+63
-4
lines changed

2 files changed

+63
-4
lines changed

drivers/infiniband/hw/mana/cq.c

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
99
struct ib_udata *udata)
1010
{
1111
struct mana_ib_cq *cq = container_of(ibcq, struct mana_ib_cq, ibcq);
12+
struct mana_ib_create_cq_resp resp = {};
13+
struct mana_ib_ucontext *mana_ucontext;
1214
struct ib_device *ibdev = ibcq->device;
1315
struct mana_ib_create_cq ucmd = {};
1416
struct mana_ib_dev *mdev;
17+
bool is_rnic_cq;
18+
u32 doorbell;
1519
int err;
1620

1721
mdev = container_of(ibdev, struct mana_ib_dev, ib_dev);
1822

19-
if (udata->inlen < sizeof(ucmd))
20-
return -EINVAL;
21-
2223
cq->comp_vector = attr->comp_vector % ibdev->num_comp_vectors;
24+
cq->cq_handle = INVALID_MANA_HANDLE;
25+
26+
if (udata->inlen < offsetof(struct mana_ib_create_cq, flags))
27+
return -EINVAL;
2328

2429
err = ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen));
2530
if (err) {
@@ -28,7 +33,9 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
2833
return err;
2934
}
3035

31-
if (attr->cqe > mdev->adapter_caps.max_qp_wr) {
36+
is_rnic_cq = !!(ucmd.flags & MANA_IB_CREATE_RNIC_CQ);
37+
38+
if (!is_rnic_cq && attr->cqe > mdev->adapter_caps.max_qp_wr) {
3239
ibdev_dbg(ibdev, "CQE %d exceeding limit\n", attr->cqe);
3340
return -EINVAL;
3441
}
@@ -40,7 +47,41 @@ int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
4047
return err;
4148
}
4249

50+
mana_ucontext = rdma_udata_to_drv_context(udata, struct mana_ib_ucontext,
51+
ibucontext);
52+
doorbell = mana_ucontext->doorbell;
53+
54+
if (is_rnic_cq) {
55+
err = mana_ib_gd_create_cq(mdev, cq, doorbell);
56+
if (err) {
57+
ibdev_dbg(ibdev, "Failed to create RNIC cq, %d\n", err);
58+
goto err_destroy_queue;
59+
}
60+
61+
err = mana_ib_install_cq_cb(mdev, cq);
62+
if (err) {
63+
ibdev_dbg(ibdev, "Failed to install cq callback, %d\n", err);
64+
goto err_destroy_rnic_cq;
65+
}
66+
}
67+
68+
resp.cqid = cq->queue.id;
69+
err = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen));
70+
if (err) {
71+
ibdev_dbg(&mdev->ib_dev, "Failed to copy to udata, %d\n", err);
72+
goto err_remove_cq_cb;
73+
}
74+
4375
return 0;
76+
77+
err_remove_cq_cb:
78+
mana_ib_remove_cq_cb(mdev, cq);
79+
err_destroy_rnic_cq:
80+
mana_ib_gd_destroy_cq(mdev, cq);
81+
err_destroy_queue:
82+
mana_ib_destroy_queue(mdev, &cq->queue);
83+
84+
return err;
4485
}
4586

4687
int mana_ib_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
@@ -52,6 +93,12 @@ int mana_ib_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata)
5293
mdev = container_of(ibdev, struct mana_ib_dev, ib_dev);
5394

5495
mana_ib_remove_cq_cb(mdev, cq);
96+
97+
/* Ignore return code as there is not much we can do about it.
98+
* The error message is printed inside.
99+
*/
100+
mana_ib_gd_destroy_cq(mdev, cq);
101+
55102
mana_ib_destroy_queue(mdev, &cq->queue);
56103

57104
return 0;

include/uapi/rdma/mana-abi.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@
1616

1717
#define MANA_IB_UVERBS_ABI_VERSION 1
1818

19+
enum mana_ib_create_cq_flags {
20+
MANA_IB_CREATE_RNIC_CQ = 1 << 0,
21+
};
22+
1923
struct mana_ib_create_cq {
2024
__aligned_u64 buf_addr;
25+
__u16 flags;
26+
__u16 reserved0;
27+
__u32 reserved1;
28+
};
29+
30+
struct mana_ib_create_cq_resp {
31+
__u32 cqid;
32+
__u32 reserved;
2133
};
2234

2335
struct mana_ib_create_qp {

0 commit comments

Comments
 (0)