mirror of
https://github.com/torvalds/linux.git
synced 2026-05-13 00:28:54 +02:00
RDMA/core: Prepare create CQ path for API unification
Ensure that .create_cq_umem() and .create_cq() follow the same API contract, allowing drivers to be gradually migrated to the umem-aware CQ management flow. Link: https://patch.msgid.link/20260213-refactor-umem-v1-7-f3be85847922@nvidia.com Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
This commit is contained in:
parent
2ead7b09bc
commit
584ec74748
|
|
@ -2700,7 +2700,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
|||
SET_DEVICE_OP(dev_ops, create_ah);
|
||||
SET_DEVICE_OP(dev_ops, create_counters);
|
||||
SET_DEVICE_OP(dev_ops, create_cq);
|
||||
SET_DEVICE_OP(dev_ops, create_cq_umem);
|
||||
SET_DEVICE_OP(dev_ops, create_user_cq);
|
||||
SET_DEVICE_OP(dev_ops, create_flow);
|
||||
SET_DEVICE_OP(dev_ops, create_qp);
|
||||
SET_DEVICE_OP(dev_ops, create_rwq_ind_table);
|
||||
|
|
|
|||
|
|
@ -1068,7 +1068,10 @@ static int create_cq(struct uverbs_attr_bundle *attrs,
|
|||
rdma_restrack_new(&cq->res, RDMA_RESTRACK_CQ);
|
||||
rdma_restrack_set_name(&cq->res, NULL);
|
||||
|
||||
ret = ib_dev->ops.create_cq(cq, &attr, attrs);
|
||||
if (ib_dev->ops.create_user_cq)
|
||||
ret = ib_dev->ops.create_user_cq(cq, &attr, attrs);
|
||||
else
|
||||
ret = ib_dev->ops.create_cq(cq, &attr, attrs);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
rdma_restrack_add(&cq->res);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
|
|||
int buffer_fd;
|
||||
int ret;
|
||||
|
||||
if ((!ib_dev->ops.create_cq && !ib_dev->ops.create_cq_umem) || !ib_dev->ops.destroy_cq)
|
||||
if ((!ib_dev->ops.create_cq && !ib_dev->ops.create_user_cq) ||
|
||||
!ib_dev->ops.destroy_cq)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ret = uverbs_copy_from(&attr.comp_vector, attrs,
|
||||
|
|
@ -130,7 +131,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
|
|||
|
||||
if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_CQ_BUFFER_FD) ||
|
||||
uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_CQ_BUFFER_OFFSET) ||
|
||||
!ib_dev->ops.create_cq_umem) {
|
||||
!ib_dev->ops.create_user_cq) {
|
||||
ret = -EINVAL;
|
||||
goto err_event_file;
|
||||
}
|
||||
|
|
@ -155,7 +156,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
|
|||
goto err_event_file;
|
||||
|
||||
if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_CQ_BUFFER_VA) ||
|
||||
!ib_dev->ops.create_cq_umem) {
|
||||
!ib_dev->ops.create_user_cq) {
|
||||
ret = -EINVAL;
|
||||
goto err_event_file;
|
||||
}
|
||||
|
|
@ -196,11 +197,16 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
|
|||
rdma_restrack_new(&cq->res, RDMA_RESTRACK_CQ);
|
||||
rdma_restrack_set_name(&cq->res, NULL);
|
||||
|
||||
ret = umem ? ib_dev->ops.create_cq_umem(cq, &attr, umem, attrs) :
|
||||
ib_dev->ops.create_cq(cq, &attr, attrs);
|
||||
if (ib_dev->ops.create_user_cq)
|
||||
ret = ib_dev->ops.create_user_cq(cq, &attr, attrs);
|
||||
else
|
||||
ret = ib_dev->ops.create_cq(cq, &attr, attrs);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
/* Check that driver didn't overrun existing umem */
|
||||
WARN_ON(umem && cq->umem != umem);
|
||||
|
||||
obj->uevent.uobject.object = cq;
|
||||
obj->uevent.uobject.user_handle = user_handle;
|
||||
rdma_restrack_add(&cq->res);
|
||||
|
|
|
|||
|
|
@ -2204,7 +2204,6 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
|
|||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
cq->device = device;
|
||||
cq->uobject = NULL;
|
||||
cq->comp_handler = comp_handler;
|
||||
cq->event_handler = event_handler;
|
||||
cq->cq_context = cq_context;
|
||||
|
|
@ -2219,6 +2218,11 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
|
|||
kfree(cq);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
/*
|
||||
* We are in kernel verbs flow and drivers are not allowed
|
||||
* to set umem pointer, it needs to stay NULL.
|
||||
*/
|
||||
WARN_ON_ONCE(cq->umem);
|
||||
|
||||
rdma_restrack_add(&cq->res);
|
||||
return cq;
|
||||
|
|
|
|||
|
|
@ -161,10 +161,8 @@ int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
|
|||
int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
|
||||
int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
int efa_create_cq_umem(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct ib_umem *umem, struct uverbs_attr_bundle *attrs);
|
||||
int efa_create_user_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
|
|
|
|||
|
|
@ -371,8 +371,7 @@ static const struct ib_device_ops efa_dev_ops = {
|
|||
.alloc_hw_device_stats = efa_alloc_hw_device_stats,
|
||||
.alloc_pd = efa_alloc_pd,
|
||||
.alloc_ucontext = efa_alloc_ucontext,
|
||||
.create_cq = efa_create_cq,
|
||||
.create_cq_umem = efa_create_cq_umem,
|
||||
.create_user_cq = efa_create_user_cq,
|
||||
.create_qp = efa_create_qp,
|
||||
.create_user_ah = efa_create_ah,
|
||||
.dealloc_pd = efa_dealloc_pd,
|
||||
|
|
|
|||
|
|
@ -1130,8 +1130,8 @@ static int cq_mmap_entries_setup(struct efa_dev *dev, struct efa_cq *cq,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int efa_create_cq_umem(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct ib_umem *umem, struct uverbs_attr_bundle *attrs)
|
||||
int efa_create_user_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct ib_udata *udata = &attrs->driver_udata;
|
||||
struct efa_ucontext *ucontext = rdma_udata_to_drv_context(
|
||||
|
|
@ -1306,12 +1306,6 @@ int efa_create_cq_umem(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
|||
return err;
|
||||
}
|
||||
|
||||
int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
return efa_create_cq_umem(ibcq, attr, NULL, attrs);
|
||||
}
|
||||
|
||||
static int umem_to_page_list(struct efa_dev *dev,
|
||||
struct ib_umem *umem,
|
||||
u64 *page_list,
|
||||
|
|
|
|||
|
|
@ -2538,9 +2538,8 @@ struct ib_device_ops {
|
|||
int (*destroy_qp)(struct ib_qp *qp, struct ib_udata *udata);
|
||||
int (*create_cq)(struct ib_cq *cq, const struct ib_cq_init_attr *attr,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
int (*create_cq_umem)(struct ib_cq *cq,
|
||||
int (*create_user_cq)(struct ib_cq *cq,
|
||||
const struct ib_cq_init_attr *attr,
|
||||
struct ib_umem *umem,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
int (*modify_cq)(struct ib_cq *cq, u16 cq_count, u16 cq_period);
|
||||
int (*destroy_cq)(struct ib_cq *cq, struct ib_udata *udata);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user