Commit 4ec1dcfc authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/core: Make ib_ucq_object use ib_uevent_object

Any uobject that sends events into the async_event_file should be using
ib_uevent_object so it can use the standard uevent based helper
functions. CQ pushes events into both the async_event and the comp_channel
in an open coded way. Move the async events related stuff to
ib_uevent_object.

Link: https://lore.kernel.org/r/1578504126-9400-6-git-send-email-yishaih@mellanox.comSigned-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 849e1490
...@@ -183,6 +183,7 @@ struct ib_uverbs_mcast_entry { ...@@ -183,6 +183,7 @@ struct ib_uverbs_mcast_entry {
struct ib_uevent_object { struct ib_uevent_object {
struct ib_uobject uobject; struct ib_uobject uobject;
/* List member for ib_uverbs_async_event_file list */
struct list_head event_list; struct list_head event_list;
u32 events_reported; u32 events_reported;
}; };
...@@ -210,11 +211,9 @@ struct ib_uwq_object { ...@@ -210,11 +211,9 @@ struct ib_uwq_object {
}; };
struct ib_ucq_object { struct ib_ucq_object {
struct ib_uobject uobject; struct ib_uevent_object uevent;
struct list_head comp_list; struct list_head comp_list;
struct list_head async_list;
u32 comp_events_reported; u32 comp_events_reported;
u32 async_events_reported;
}; };
extern const struct file_operations uverbs_event_fops; extern const struct file_operations uverbs_event_fops;
......
...@@ -1015,11 +1015,9 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1015,11 +1015,9 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
} }
} }
obj->uobject.user_handle = cmd->user_handle; obj->uevent.uobject.user_handle = cmd->user_handle;
obj->comp_events_reported = 0;
obj->async_events_reported = 0;
INIT_LIST_HEAD(&obj->comp_list); INIT_LIST_HEAD(&obj->comp_list);
INIT_LIST_HEAD(&obj->async_list); INIT_LIST_HEAD(&obj->uevent.event_list);
attr.cqe = cmd->cqe; attr.cqe = cmd->cqe;
attr.comp_vector = cmd->comp_vector; attr.comp_vector = cmd->comp_vector;
...@@ -1031,7 +1029,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1031,7 +1029,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
goto err_file; goto err_file;
} }
cq->device = ib_dev; cq->device = ib_dev;
cq->uobject = &obj->uobject; cq->uobject = &obj->uevent.uobject;
cq->comp_handler = ib_uverbs_comp_handler; cq->comp_handler = ib_uverbs_comp_handler;
cq->event_handler = ib_uverbs_cq_event_handler; cq->event_handler = ib_uverbs_cq_event_handler;
cq->cq_context = ev_file ? &ev_file->ev_queue : NULL; cq->cq_context = ev_file ? &ev_file->ev_queue : NULL;
...@@ -1041,9 +1039,9 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1041,9 +1039,9 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
if (ret) if (ret)
goto err_free; goto err_free;
obj->uobject.object = cq; obj->uevent.uobject.object = cq;
memset(&resp, 0, sizeof resp); memset(&resp, 0, sizeof resp);
resp.base.cq_handle = obj->uobject.id; resp.base.cq_handle = obj->uevent.uobject.id;
resp.base.cqe = cq->cqe; resp.base.cqe = cq->cqe;
resp.response_length = uverbs_response_length(attrs, sizeof(resp)); resp.response_length = uverbs_response_length(attrs, sizeof(resp));
...@@ -1054,7 +1052,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1054,7 +1052,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
if (ret) if (ret)
goto err_cb; goto err_cb;
rdma_alloc_commit_uobject(&obj->uobject, attrs); rdma_alloc_commit_uobject(&obj->uevent.uobject, attrs);
return obj; return obj;
err_cb: err_cb:
...@@ -1067,7 +1065,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, ...@@ -1067,7 +1065,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
ib_uverbs_release_ucq(attrs->ufile, ev_file, obj); ib_uverbs_release_ucq(attrs->ufile, ev_file, obj);
err: err:
uobj_alloc_abort(&obj->uobject, attrs); uobj_alloc_abort(&obj->uevent.uobject, attrs);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -1261,10 +1259,10 @@ static int ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs) ...@@ -1261,10 +1259,10 @@ static int ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs)
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
obj = container_of(uobj, struct ib_ucq_object, uobject); obj = container_of(uobj, struct ib_ucq_object, uevent.uobject);
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
resp.comp_events_reported = obj->comp_events_reported; resp.comp_events_reported = obj->comp_events_reported;
resp.async_events_reported = obj->async_events_reported; resp.async_events_reported = obj->uevent.events_reported;
uobj_put_destroy(uobj); uobj_put_destroy(uobj);
......
...@@ -150,12 +150,7 @@ void ib_uverbs_release_ucq(struct ib_uverbs_file *file, ...@@ -150,12 +150,7 @@ void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
uverbs_uobject_put(&ev_file->uobj); uverbs_uobject_put(&ev_file->uobj);
} }
spin_lock_irq(&file->async_file->ev_queue.lock); ib_uverbs_release_uevent(file, &uobj->uevent);
list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
list_del(&evt->list);
kfree(evt);
}
spin_unlock_irq(&file->async_file->ev_queue.lock);
} }
void ib_uverbs_release_uevent(struct ib_uverbs_file *file, void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
...@@ -413,7 +408,7 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) ...@@ -413,7 +408,7 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
return; return;
} }
uobj = container_of(cq->uobject, struct ib_ucq_object, uobject); uobj = container_of(cq->uobject, struct ib_ucq_object, uevent.uobject);
entry->desc.comp.cq_handle = cq->uobject->user_handle; entry->desc.comp.cq_handle = cq->uobject->user_handle;
entry->counter = &uobj->comp_events_reported; entry->counter = &uobj->comp_events_reported;
...@@ -462,12 +457,12 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file, ...@@ -462,12 +457,12 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
{ {
struct ib_ucq_object *uobj = container_of(event->element.cq->uobject, struct ib_uevent_object *uobj = container_of(
struct ib_ucq_object, uobject); event->element.cq->uobject, struct ib_uevent_object, uobject);
ib_uverbs_async_handler(uobj->uobject.ufile, uobj->uobject.user_handle, ib_uverbs_async_handler(uobj->uobject.ufile, uobj->uobject.user_handle,
event->event, &uobj->async_list, event->event, &uobj->event_list,
&uobj->async_events_reported); &uobj->events_reported);
} }
void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr) void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
......
...@@ -41,7 +41,7 @@ static int uverbs_free_cq(struct ib_uobject *uobject, ...@@ -41,7 +41,7 @@ static int uverbs_free_cq(struct ib_uobject *uobject,
struct ib_cq *cq = uobject->object; struct ib_cq *cq = uobject->object;
struct ib_uverbs_event_queue *ev_queue = cq->cq_context; struct ib_uverbs_event_queue *ev_queue = cq->cq_context;
struct ib_ucq_object *ucq = struct ib_ucq_object *ucq =
container_of(uobject, struct ib_ucq_object, uobject); container_of(uobject, struct ib_ucq_object, uevent.uobject);
int ret; int ret;
ret = ib_destroy_cq_user(cq, &attrs->driver_udata); ret = ib_destroy_cq_user(cq, &attrs->driver_udata);
...@@ -63,7 +63,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( ...@@ -63,7 +63,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
{ {
struct ib_ucq_object *obj = container_of( struct ib_ucq_object *obj = container_of(
uverbs_attr_get_uobject(attrs, UVERBS_ATTR_CREATE_CQ_HANDLE), uverbs_attr_get_uobject(attrs, UVERBS_ATTR_CREATE_CQ_HANDLE),
typeof(*obj), uobject); typeof(*obj), uevent.uobject);
struct ib_device *ib_dev = attrs->context->device; struct ib_device *ib_dev = attrs->context->device;
int ret; int ret;
u64 user_handle; u64 user_handle;
...@@ -106,10 +106,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( ...@@ -106,10 +106,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
goto err_event_file; goto err_event_file;
} }
obj->comp_events_reported = 0;
obj->async_events_reported = 0;
INIT_LIST_HEAD(&obj->comp_list); INIT_LIST_HEAD(&obj->comp_list);
INIT_LIST_HEAD(&obj->async_list); INIT_LIST_HEAD(&obj->uevent.event_list);
cq = rdma_zalloc_drv_obj(ib_dev, ib_cq); cq = rdma_zalloc_drv_obj(ib_dev, ib_cq);
if (!cq) { if (!cq) {
...@@ -118,7 +116,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( ...@@ -118,7 +116,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
} }
cq->device = ib_dev; cq->device = ib_dev;
cq->uobject = &obj->uobject; cq->uobject = &obj->uevent.uobject;
cq->comp_handler = ib_uverbs_comp_handler; cq->comp_handler = ib_uverbs_comp_handler;
cq->event_handler = ib_uverbs_cq_event_handler; cq->event_handler = ib_uverbs_cq_event_handler;
cq->cq_context = ev_file ? &ev_file->ev_queue : NULL; cq->cq_context = ev_file ? &ev_file->ev_queue : NULL;
...@@ -129,8 +127,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( ...@@ -129,8 +127,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
if (ret) if (ret)
goto err_free; goto err_free;
obj->uobject.object = cq; obj->uevent.uobject.object = cq;
obj->uobject.user_handle = user_handle; obj->uevent.uobject.user_handle = user_handle;
rdma_restrack_uadd(&cq->res); rdma_restrack_uadd(&cq->res);
ret = uverbs_copy_to(attrs, UVERBS_ATTR_CREATE_CQ_RESP_CQE, &cq->cqe, ret = uverbs_copy_to(attrs, UVERBS_ATTR_CREATE_CQ_RESP_CQE, &cq->cqe,
...@@ -182,10 +180,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_DESTROY)( ...@@ -182,10 +180,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_DESTROY)(
struct ib_uobject *uobj = struct ib_uobject *uobj =
uverbs_attr_get_uobject(attrs, UVERBS_ATTR_DESTROY_CQ_HANDLE); uverbs_attr_get_uobject(attrs, UVERBS_ATTR_DESTROY_CQ_HANDLE);
struct ib_ucq_object *obj = struct ib_ucq_object *obj =
container_of(uobj, struct ib_ucq_object, uobject); container_of(uobj, struct ib_ucq_object, uevent.uobject);
struct ib_uverbs_destroy_cq_resp resp = { struct ib_uverbs_destroy_cq_resp resp = {
.comp_events_reported = obj->comp_events_reported, .comp_events_reported = obj->comp_events_reported,
.async_events_reported = obj->async_events_reported .async_events_reported = obj->uevent.events_reported
}; };
return uverbs_copy_to(attrs, UVERBS_ATTR_DESTROY_CQ_RESP, &resp, return uverbs_copy_to(attrs, UVERBS_ATTR_DESTROY_CQ_RESP, &resp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment