Commit 817d6576 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/core: Simplify type usage for ib_uverbs_async_handler()

This function works on an ib_uverbs_async_file. Accept that as a parameter
instead of the struct ib_uverbs_file.

Consoldiate all the callers working from an ib_uevent_object to a single
function and locate the async_file directly from the struct ib_uobject
instead of using context_ptr.

Link: https://lore.kernel.org/r/1578504126-9400-11-git-send-email-yishaih@mellanox.comSigned-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent e04dd131
...@@ -235,8 +235,6 @@ void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr); ...@@ -235,8 +235,6 @@ void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
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);
void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr); void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr); void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_event_handler(struct ib_event_handler *handler,
struct ib_event *event);
int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd, int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd,
enum rdma_remove_reason why, enum rdma_remove_reason why,
struct uverbs_attr_bundle *attrs); struct uverbs_attr_bundle *attrs);
......
...@@ -1378,7 +1378,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1378,7 +1378,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
} }
attr.event_handler = ib_uverbs_qp_event_handler; attr.event_handler = ib_uverbs_qp_event_handler;
attr.qp_context = attrs->ufile;
attr.send_cq = scq; attr.send_cq = scq;
attr.recv_cq = rcq; attr.recv_cq = rcq;
attr.srq = srq; attr.srq = srq;
...@@ -1394,7 +1393,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1394,7 +1393,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
attr.cap.max_recv_sge = cmd->max_recv_sge; attr.cap.max_recv_sge = cmd->max_recv_sge;
attr.cap.max_inline_data = cmd->max_inline_data; attr.cap.max_inline_data = cmd->max_inline_data;
obj->uevent.events_reported = 0;
INIT_LIST_HEAD(&obj->uevent.event_list); INIT_LIST_HEAD(&obj->uevent.event_list);
INIT_LIST_HEAD(&obj->mcast_list); INIT_LIST_HEAD(&obj->mcast_list);
...@@ -1442,7 +1440,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs, ...@@ -1442,7 +1440,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
qp->srq = attr.srq; qp->srq = attr.srq;
qp->rwq_ind_tbl = ind_tbl; qp->rwq_ind_tbl = ind_tbl;
qp->event_handler = attr.event_handler; qp->event_handler = attr.event_handler;
qp->qp_context = attr.qp_context;
qp->qp_type = attr.qp_type; qp->qp_type = attr.qp_type;
atomic_set(&qp->usecnt, 0); atomic_set(&qp->usecnt, 0);
atomic_inc(&pd->usecnt); atomic_inc(&pd->usecnt);
...@@ -1577,7 +1574,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs) ...@@ -1577,7 +1574,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs)
struct ib_xrcd *xrcd; struct ib_xrcd *xrcd;
struct ib_uobject *uninitialized_var(xrcd_uobj); struct ib_uobject *uninitialized_var(xrcd_uobj);
struct ib_qp *qp; struct ib_qp *qp;
struct ib_qp_open_attr attr; struct ib_qp_open_attr attr = {};
int ret; int ret;
struct ib_device *ib_dev; struct ib_device *ib_dev;
...@@ -1603,11 +1600,9 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs) ...@@ -1603,11 +1600,9 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs)
} }
attr.event_handler = ib_uverbs_qp_event_handler; attr.event_handler = ib_uverbs_qp_event_handler;
attr.qp_context = attrs->ufile;
attr.qp_num = cmd.qpn; attr.qp_num = cmd.qpn;
attr.qp_type = cmd.qp_type; attr.qp_type = cmd.qp_type;
obj->uevent.events_reported = 0;
INIT_LIST_HEAD(&obj->uevent.event_list); INIT_LIST_HEAD(&obj->uevent.event_list);
INIT_LIST_HEAD(&obj->mcast_list); INIT_LIST_HEAD(&obj->mcast_list);
...@@ -2962,7 +2957,6 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) ...@@ -2962,7 +2957,6 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs)
wq_init_attr.wq_type = cmd.wq_type; wq_init_attr.wq_type = cmd.wq_type;
wq_init_attr.event_handler = ib_uverbs_wq_event_handler; wq_init_attr.event_handler = ib_uverbs_wq_event_handler;
wq_init_attr.create_flags = cmd.create_flags; wq_init_attr.create_flags = cmd.create_flags;
obj->uevent.events_reported = 0;
INIT_LIST_HEAD(&obj->uevent.event_list); INIT_LIST_HEAD(&obj->uevent.event_list);
wq = pd->device->ops.create_wq(pd, &wq_init_attr, &attrs->driver_udata); wq = pd->device->ops.create_wq(pd, &wq_init_attr, &attrs->driver_udata);
...@@ -3452,7 +3446,6 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, ...@@ -3452,7 +3446,6 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
attr.attr.max_sge = cmd->max_sge; attr.attr.max_sge = cmd->max_sge;
attr.attr.srq_limit = cmd->srq_limit; attr.attr.srq_limit = cmd->srq_limit;
obj->uevent.events_reported = 0;
INIT_LIST_HEAD(&obj->uevent.event_list); INIT_LIST_HEAD(&obj->uevent.event_list);
srq = rdma_zalloc_drv_obj(ib_dev, ib_srq); srq = rdma_zalloc_drv_obj(ib_dev, ib_srq);
......
...@@ -421,23 +421,23 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) ...@@ -421,23 +421,23 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
kill_fasync(&ev_queue->async_queue, SIGIO, POLL_IN); kill_fasync(&ev_queue->async_queue, SIGIO, POLL_IN);
} }
static void ib_uverbs_async_handler(struct ib_uverbs_file *file, static void
__u64 element, __u64 event, ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
struct list_head *obj_list, __u64 element, __u64 event, struct list_head *obj_list,
u32 *counter) u32 *counter)
{ {
struct ib_uverbs_event *entry; struct ib_uverbs_event *entry;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&file->async_file->ev_queue.lock, flags); spin_lock_irqsave(&async_file->ev_queue.lock, flags);
if (file->async_file->ev_queue.is_closed) { if (async_file->ev_queue.is_closed) {
spin_unlock_irqrestore(&file->async_file->ev_queue.lock, flags); spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
return; return;
} }
entry = kmalloc(sizeof(*entry), GFP_ATOMIC); entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) { if (!entry) {
spin_unlock_irqrestore(&file->async_file->ev_queue.lock, flags); spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
return; return;
} }
...@@ -446,67 +446,54 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file, ...@@ -446,67 +446,54 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
entry->desc.async.reserved = 0; entry->desc.async.reserved = 0;
entry->counter = counter; entry->counter = counter;
list_add_tail(&entry->list, &file->async_file->ev_queue.event_list); list_add_tail(&entry->list, &async_file->ev_queue.event_list);
if (obj_list) if (obj_list)
list_add_tail(&entry->obj_list, obj_list); list_add_tail(&entry->obj_list, obj_list);
spin_unlock_irqrestore(&file->async_file->ev_queue.lock, flags); spin_unlock_irqrestore(&async_file->ev_queue.lock, flags);
wake_up_interruptible(&file->async_file->ev_queue.poll_wait); wake_up_interruptible(&async_file->ev_queue.poll_wait);
kill_fasync(&file->async_file->ev_queue.async_queue, SIGIO, POLL_IN); kill_fasync(&async_file->ev_queue.async_queue, SIGIO, POLL_IN);
} }
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) static void uverbs_uobj_event(struct ib_uevent_object *eobj,
struct ib_event *event)
{ {
struct ib_uevent_object *uobj = &event->element.cq->uobject->uevent; ib_uverbs_async_handler(eobj->uobject.ufile->async_file,
eobj->uobject.user_handle, event->event,
&eobj->event_list, &eobj->events_reported);
}
ib_uverbs_async_handler(uobj->uobject.ufile, uobj->uobject.user_handle, void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
event->event, &uobj->event_list, {
&uobj->events_reported); uverbs_uobj_event(&event->element.cq->uobject->uevent, event);
} }
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)
{ {
struct ib_uevent_object *uobj;
/* for XRC target qp's, check that qp is live */ /* for XRC target qp's, check that qp is live */
if (!event->element.qp->uobject) if (!event->element.qp->uobject)
return; return;
uobj = &event->element.qp->uobject->uevent; uverbs_uobj_event(&event->element.qp->uobject->uevent, event);
ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
event->event, &uobj->event_list,
&uobj->events_reported);
} }
void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr) void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr)
{ {
struct ib_uevent_object *uobj = &event->element.wq->uobject->uevent; uverbs_uobj_event(&event->element.wq->uobject->uevent, event);
ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
event->event, &uobj->event_list,
&uobj->events_reported);
} }
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr) void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr)
{ {
struct ib_uevent_object *uobj; uverbs_uobj_event(&event->element.srq->uobject->uevent, event);
uobj = &event->element.srq->uobject->uevent;
ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
event->event, &uobj->event_list,
&uobj->events_reported);
} }
void ib_uverbs_event_handler(struct ib_event_handler *handler, static void ib_uverbs_event_handler(struct ib_event_handler *handler,
struct ib_event *event) struct ib_event *event)
{ {
struct ib_uverbs_file *file = ib_uverbs_async_handler(
container_of(handler, struct ib_uverbs_file, event_handler); container_of(handler, struct ib_uverbs_file, event_handler)
->async_file,
ib_uverbs_async_handler(file, event->element.port_num, event->event, event->element.port_num, event->event, NULL, NULL);
NULL, NULL);
} }
void ib_uverbs_free_async_event_file(struct ib_uverbs_file *file) void ib_uverbs_free_async_event_file(struct ib_uverbs_file *file)
......
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