Commit 2cc1e3b8 authored by Jason Gunthorpe's avatar Jason Gunthorpe

IB/uverbs: Replace file->ucontext with file in uverbs_cmd.c

The ucontext isn't needed any more, just pass the uverbs_file directly.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent 6ef1c828
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
#include "core_priv.h" #include "core_priv.h"
static struct ib_uverbs_completion_event_file * static struct ib_uverbs_completion_event_file *
ib_uverbs_lookup_comp_file(int fd, struct ib_ucontext *context) ib_uverbs_lookup_comp_file(int fd, struct ib_uverbs_file *ufile)
{ {
struct ib_uobject *uobj = uobj_get_read(UVERBS_OBJECT_COMP_CHANNEL, struct ib_uobject *uobj = uobj_get_read(UVERBS_OBJECT_COMP_CHANNEL,
fd, context); fd, ufile);
struct ib_uobject_file *uobj_file; struct ib_uobject_file *uobj_file;
if (IS_ERR(uobj)) if (IS_ERR(uobj))
...@@ -322,7 +322,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, ...@@ -322,7 +322,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp)); out_len - sizeof(resp));
uobj = uobj_alloc(UVERBS_OBJECT_PD, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_PD, file);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -509,8 +509,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file, ...@@ -509,8 +509,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
} }
} }
obj = (struct ib_uxrcd_object *)uobj_alloc(UVERBS_OBJECT_XRCD, obj = (struct ib_uxrcd_object *)uobj_alloc(UVERBS_OBJECT_XRCD, file);
file->ucontext);
if (IS_ERR(obj)) { if (IS_ERR(obj)) {
ret = PTR_ERR(obj); ret = PTR_ERR(obj);
goto err_tree_mutex_unlock; goto err_tree_mutex_unlock;
...@@ -652,11 +651,11 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, ...@@ -652,11 +651,11 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
if (ret) if (ret)
return ret; return ret;
uobj = uobj_alloc(UVERBS_OBJECT_MR, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_MR, file);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
if (!pd) { if (!pd) {
ret = -EINVAL; ret = -EINVAL;
goto err_free; goto err_free;
...@@ -748,8 +747,7 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file, ...@@ -748,8 +747,7 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
(cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))) (cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)))
return -EINVAL; return -EINVAL;
uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, file);
file->ucontext);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -767,7 +765,8 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file, ...@@ -767,7 +765,8 @@ ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
} }
if (cmd.flags & IB_MR_REREG_PD) { if (cmd.flags & IB_MR_REREG_PD) {
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle,
file);
if (!pd) { if (!pd) {
ret = -EINVAL; ret = -EINVAL;
goto put_uobjs; goto put_uobjs;
...@@ -840,11 +839,11 @@ ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file, ...@@ -840,11 +839,11 @@ ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof(cmd))) if (copy_from_user(&cmd, buf, sizeof(cmd)))
return -EFAULT; return -EFAULT;
uobj = uobj_alloc(UVERBS_OBJECT_MW, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_MW, file);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
if (!pd) { if (!pd) {
ret = -EINVAL; ret = -EINVAL;
goto err_free; goto err_free;
...@@ -921,7 +920,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file, ...@@ -921,7 +920,7 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
uobj = uobj_alloc(UVERBS_OBJECT_COMP_CHANNEL, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_COMP_CHANNEL, file);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -966,14 +965,12 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file, ...@@ -966,14 +965,12 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
if (cmd->comp_vector >= file->device->num_comp_vectors) if (cmd->comp_vector >= file->device->num_comp_vectors)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ, obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ, file);
file->ucontext);
if (IS_ERR(obj)) if (IS_ERR(obj))
return obj; return obj;
if (cmd->comp_channel >= 0) { if (cmd->comp_channel >= 0) {
ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel, ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel, file);
file->ucontext);
if (IS_ERR(ev_file)) { if (IS_ERR(ev_file)) {
ret = PTR_ERR(ev_file); ret = PTR_ERR(ev_file);
goto err; goto err;
...@@ -1155,7 +1152,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file, ...@@ -1155,7 +1152,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp)); out_len - sizeof(resp));
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext); cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
if (!cq) if (!cq)
return -EINVAL; return -EINVAL;
...@@ -1220,7 +1217,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, ...@@ -1220,7 +1217,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext); cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
if (!cq) if (!cq)
return -EINVAL; return -EINVAL;
...@@ -1267,7 +1264,7 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file, ...@@ -1267,7 +1264,7 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext); cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
if (!cq) if (!cq)
return -EINVAL; return -EINVAL;
...@@ -1294,8 +1291,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, ...@@ -1294,8 +1291,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
uobj = uobj_get_write(UVERBS_OBJECT_CQ, cmd.cq_handle, uobj = uobj_get_write(UVERBS_OBJECT_CQ, cmd.cq_handle, file);
file->ucontext);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -1353,8 +1349,7 @@ static int create_qp(struct ib_uverbs_file *file, ...@@ -1353,8 +1349,7 @@ static int create_qp(struct ib_uverbs_file *file,
if (cmd->qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW)) if (cmd->qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW))
return -EPERM; return -EPERM;
obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file);
file->ucontext);
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
obj->uxrcd = NULL; obj->uxrcd = NULL;
...@@ -1364,9 +1359,9 @@ static int create_qp(struct ib_uverbs_file *file, ...@@ -1364,9 +1359,9 @@ static int create_qp(struct ib_uverbs_file *file,
if (cmd_sz >= offsetof(typeof(*cmd), rwq_ind_tbl_handle) + if (cmd_sz >= offsetof(typeof(*cmd), rwq_ind_tbl_handle) +
sizeof(cmd->rwq_ind_tbl_handle) && sizeof(cmd->rwq_ind_tbl_handle) &&
(cmd->comp_mask & IB_UVERBS_CREATE_QP_MASK_IND_TABLE)) { (cmd->comp_mask & IB_UVERBS_CREATE_QP_MASK_IND_TABLE)) {
ind_tbl = uobj_get_obj_read(rwq_ind_table, UVERBS_OBJECT_RWQ_IND_TBL, ind_tbl = uobj_get_obj_read(rwq_ind_table,
cmd->rwq_ind_tbl_handle, UVERBS_OBJECT_RWQ_IND_TBL,
file->ucontext); cmd->rwq_ind_tbl_handle, file);
if (!ind_tbl) { if (!ind_tbl) {
ret = -EINVAL; ret = -EINVAL;
goto err_put; goto err_put;
...@@ -1392,7 +1387,7 @@ static int create_qp(struct ib_uverbs_file *file, ...@@ -1392,7 +1387,7 @@ static int create_qp(struct ib_uverbs_file *file,
if (cmd->qp_type == IB_QPT_XRC_TGT) { if (cmd->qp_type == IB_QPT_XRC_TGT) {
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->pd_handle, xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->pd_handle,
file->ucontext); file);
if (IS_ERR(xrcd_uobj)) { if (IS_ERR(xrcd_uobj)) {
ret = -EINVAL; ret = -EINVAL;
...@@ -1411,8 +1406,8 @@ static int create_qp(struct ib_uverbs_file *file, ...@@ -1411,8 +1406,8 @@ static int create_qp(struct ib_uverbs_file *file,
cmd->max_recv_sge = 0; cmd->max_recv_sge = 0;
} else { } else {
if (cmd->is_srq) { if (cmd->is_srq) {
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd->srq_handle, srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ,
file->ucontext); cmd->srq_handle, file);
if (!srq || srq->srq_type == IB_SRQT_XRC) { if (!srq || srq->srq_type == IB_SRQT_XRC) {
ret = -EINVAL; ret = -EINVAL;
goto err_put; goto err_put;
...@@ -1421,8 +1416,9 @@ static int create_qp(struct ib_uverbs_file *file, ...@@ -1421,8 +1416,9 @@ static int create_qp(struct ib_uverbs_file *file,
if (!ind_tbl) { if (!ind_tbl) {
if (cmd->recv_cq_handle != cmd->send_cq_handle) { if (cmd->recv_cq_handle != cmd->send_cq_handle) {
rcq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd->recv_cq_handle, rcq = uobj_get_obj_read(
file->ucontext); cq, UVERBS_OBJECT_CQ,
cmd->recv_cq_handle, file);
if (!rcq) { if (!rcq) {
ret = -EINVAL; ret = -EINVAL;
goto err_put; goto err_put;
...@@ -1432,11 +1428,12 @@ static int create_qp(struct ib_uverbs_file *file, ...@@ -1432,11 +1428,12 @@ static int create_qp(struct ib_uverbs_file *file,
} }
if (has_sq) if (has_sq)
scq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd->send_cq_handle, scq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ,
file->ucontext); cmd->send_cq_handle, file);
if (!ind_tbl) if (!ind_tbl)
rcq = rcq ?: scq; rcq = rcq ?: scq;
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle,
file);
if (!pd || (!scq && has_sq)) { if (!pd || (!scq && has_sq)) {
ret = -EINVAL; ret = -EINVAL;
goto err_put; goto err_put;
...@@ -1733,13 +1730,11 @@ ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file, ...@@ -1733,13 +1730,11 @@ ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file,
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp)); out_len - sizeof(resp));
obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file);
file->ucontext);
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd.pd_handle, xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd.pd_handle, file);
file->ucontext);
if (IS_ERR(xrcd_uobj)) { if (IS_ERR(xrcd_uobj)) {
ret = -EINVAL; ret = -EINVAL;
goto err_put; goto err_put;
...@@ -1841,7 +1836,7 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file, ...@@ -1841,7 +1836,7 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
goto out; goto out;
} }
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
if (!qp) { if (!qp) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -1946,7 +1941,7 @@ static int modify_qp(struct ib_uverbs_file *file, ...@@ -1946,7 +1941,7 @@ static int modify_qp(struct ib_uverbs_file *file,
if (!attr) if (!attr)
return -ENOMEM; return -ENOMEM;
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle, file);
if (!qp) { if (!qp) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
...@@ -2101,8 +2096,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, ...@@ -2101,8 +2096,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
memset(&resp, 0, sizeof resp); memset(&resp, 0, sizeof resp);
uobj = uobj_get_write(UVERBS_OBJECT_QP, cmd.qp_handle, uobj = uobj_get_write(UVERBS_OBJECT_QP, cmd.qp_handle, file);
file->ucontext);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -2167,7 +2161,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, ...@@ -2167,7 +2161,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
if (!user_wr) if (!user_wr)
return -ENOMEM; return -ENOMEM;
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
if (!qp) if (!qp)
goto out; goto out;
...@@ -2203,8 +2197,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, ...@@ -2203,8 +2197,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
goto out_put; goto out_put;
} }
ud->ah = uobj_get_obj_read(ah, UVERBS_OBJECT_AH, user_wr->wr.ud.ah, ud->ah = uobj_get_obj_read(ah, UVERBS_OBJECT_AH,
file->ucontext); user_wr->wr.ud.ah, file);
if (!ud->ah) { if (!ud->ah) {
kfree(ud); kfree(ud);
ret = -EINVAL; ret = -EINVAL;
...@@ -2438,7 +2432,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, ...@@ -2438,7 +2432,7 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
if (IS_ERR(wr)) if (IS_ERR(wr))
return PTR_ERR(wr); return PTR_ERR(wr);
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
if (!qp) if (!qp)
goto out; goto out;
...@@ -2487,7 +2481,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, ...@@ -2487,7 +2481,7 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
if (IS_ERR(wr)) if (IS_ERR(wr))
return PTR_ERR(wr); return PTR_ERR(wr);
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file->ucontext); srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
if (!srq) if (!srq)
goto out; goto out;
...@@ -2544,11 +2538,11 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file, ...@@ -2544,11 +2538,11 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr), in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp)); out_len - sizeof(resp));
uobj = uobj_alloc(UVERBS_OBJECT_AH, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_AH, file);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
if (!pd) { if (!pd) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
...@@ -2632,7 +2626,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, ...@@ -2632,7 +2626,7 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
if (!qp) if (!qp)
return -EINVAL; return -EINVAL;
...@@ -2683,7 +2677,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file, ...@@ -2683,7 +2677,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
if (!qp) if (!qp)
return -EINVAL; return -EINVAL;
...@@ -2791,7 +2785,7 @@ static void flow_resources_add(struct ib_uflow_resources *uflow_res, ...@@ -2791,7 +2785,7 @@ static void flow_resources_add(struct ib_uflow_resources *uflow_res,
uflow_res->num++; uflow_res->num++;
} }
static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext, static int kern_spec_to_ib_spec_action(struct ib_uverbs_file *ufile,
struct ib_uverbs_flow_spec *kern_spec, struct ib_uverbs_flow_spec *kern_spec,
union ib_flow_spec *ib_spec, union ib_flow_spec *ib_spec,
struct ib_uflow_resources *uflow_res) struct ib_uflow_resources *uflow_res)
...@@ -2820,7 +2814,7 @@ static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext, ...@@ -2820,7 +2814,7 @@ static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext,
ib_spec->action.act = uobj_get_obj_read(flow_action, ib_spec->action.act = uobj_get_obj_read(flow_action,
UVERBS_OBJECT_FLOW_ACTION, UVERBS_OBJECT_FLOW_ACTION,
kern_spec->action.handle, kern_spec->action.handle,
ucontext); ufile);
if (!ib_spec->action.act) if (!ib_spec->action.act)
return -EINVAL; return -EINVAL;
ib_spec->action.size = ib_spec->action.size =
...@@ -2838,7 +2832,7 @@ static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext, ...@@ -2838,7 +2832,7 @@ static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext,
uobj_get_obj_read(counters, uobj_get_obj_read(counters,
UVERBS_OBJECT_COUNTERS, UVERBS_OBJECT_COUNTERS,
kern_spec->flow_count.handle, kern_spec->flow_count.handle,
ucontext); ufile);
if (!ib_spec->flow_count.counters) if (!ib_spec->flow_count.counters)
return -EINVAL; return -EINVAL;
ib_spec->flow_count.size = ib_spec->flow_count.size =
...@@ -3019,7 +3013,7 @@ static int kern_spec_to_ib_spec_filter(struct ib_uverbs_flow_spec *kern_spec, ...@@ -3019,7 +3013,7 @@ static int kern_spec_to_ib_spec_filter(struct ib_uverbs_flow_spec *kern_spec,
kern_filter_sz, ib_spec); kern_filter_sz, ib_spec);
} }
static int kern_spec_to_ib_spec(struct ib_ucontext *ucontext, static int kern_spec_to_ib_spec(struct ib_uverbs_file *ufile,
struct ib_uverbs_flow_spec *kern_spec, struct ib_uverbs_flow_spec *kern_spec,
union ib_flow_spec *ib_spec, union ib_flow_spec *ib_spec,
struct ib_uflow_resources *uflow_res) struct ib_uflow_resources *uflow_res)
...@@ -3028,7 +3022,7 @@ static int kern_spec_to_ib_spec(struct ib_ucontext *ucontext, ...@@ -3028,7 +3022,7 @@ static int kern_spec_to_ib_spec(struct ib_ucontext *ucontext,
return -EINVAL; return -EINVAL;
if (kern_spec->type >= IB_FLOW_SPEC_ACTION_TAG) if (kern_spec->type >= IB_FLOW_SPEC_ACTION_TAG)
return kern_spec_to_ib_spec_action(ucontext, kern_spec, ib_spec, return kern_spec_to_ib_spec_action(ufile, kern_spec, ib_spec,
uflow_res); uflow_res);
else else
return kern_spec_to_ib_spec_filter(kern_spec, ib_spec); return kern_spec_to_ib_spec_filter(kern_spec, ib_spec);
...@@ -3071,18 +3065,17 @@ int ib_uverbs_ex_create_wq(struct ib_uverbs_file *file, ...@@ -3071,18 +3065,17 @@ int ib_uverbs_ex_create_wq(struct ib_uverbs_file *file,
if (cmd.comp_mask) if (cmd.comp_mask)
return -EOPNOTSUPP; return -EOPNOTSUPP;
obj = (struct ib_uwq_object *)uobj_alloc(UVERBS_OBJECT_WQ, obj = (struct ib_uwq_object *)uobj_alloc(UVERBS_OBJECT_WQ, file);
file->ucontext);
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
if (!pd) { if (!pd) {
err = -EINVAL; err = -EINVAL;
goto err_uobj; goto err_uobj;
} }
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext); cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
if (!cq) { if (!cq) {
err = -EINVAL; err = -EINVAL;
goto err_put_pd; goto err_put_pd;
...@@ -3186,8 +3179,7 @@ int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file, ...@@ -3186,8 +3179,7 @@ int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file,
return -EOPNOTSUPP; return -EOPNOTSUPP;
resp.response_length = required_resp_len; resp.response_length = required_resp_len;
uobj = uobj_get_write(UVERBS_OBJECT_WQ, cmd.wq_handle, uobj = uobj_get_write(UVERBS_OBJECT_WQ, cmd.wq_handle, file);
file->ucontext);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -3237,7 +3229,7 @@ int ib_uverbs_ex_modify_wq(struct ib_uverbs_file *file, ...@@ -3237,7 +3229,7 @@ int ib_uverbs_ex_modify_wq(struct ib_uverbs_file *file,
if (cmd.attr_mask > (IB_WQ_STATE | IB_WQ_CUR_STATE | IB_WQ_FLAGS)) if (cmd.attr_mask > (IB_WQ_STATE | IB_WQ_CUR_STATE | IB_WQ_FLAGS))
return -EINVAL; return -EINVAL;
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, file->ucontext); wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, file);
if (!wq) if (!wq)
return -EINVAL; return -EINVAL;
...@@ -3331,8 +3323,8 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file, ...@@ -3331,8 +3323,8 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file,
for (num_read_wqs = 0; num_read_wqs < num_wq_handles; for (num_read_wqs = 0; num_read_wqs < num_wq_handles;
num_read_wqs++) { num_read_wqs++) {
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, wqs_handles[num_read_wqs], wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ,
file->ucontext); wqs_handles[num_read_wqs], file);
if (!wq) { if (!wq) {
err = -EINVAL; err = -EINVAL;
goto put_wqs; goto put_wqs;
...@@ -3341,7 +3333,7 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file, ...@@ -3341,7 +3333,7 @@ int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file,
wqs[num_read_wqs] = wq; wqs[num_read_wqs] = wq;
} }
uobj = uobj_alloc(UVERBS_OBJECT_RWQ_IND_TBL, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_RWQ_IND_TBL, file);
if (IS_ERR(uobj)) { if (IS_ERR(uobj)) {
err = PTR_ERR(uobj); err = PTR_ERR(uobj);
goto put_wqs; goto put_wqs;
...@@ -3504,13 +3496,13 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, ...@@ -3504,13 +3496,13 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
kern_flow_attr = &cmd.flow_attr; kern_flow_attr = &cmd.flow_attr;
} }
uobj = uobj_alloc(UVERBS_OBJECT_FLOW, file->ucontext); uobj = uobj_alloc(UVERBS_OBJECT_FLOW, file);
if (IS_ERR(uobj)) { if (IS_ERR(uobj)) {
err = PTR_ERR(uobj); err = PTR_ERR(uobj);
goto err_free_attr; goto err_free_attr;
} }
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file->ucontext); qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
if (!qp) { if (!qp) {
err = -EINVAL; err = -EINVAL;
goto err_uobj; goto err_uobj;
...@@ -3546,8 +3538,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, ...@@ -3546,8 +3538,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
cmd.flow_attr.size > offsetof(struct ib_uverbs_flow_spec, reserved) && cmd.flow_attr.size > offsetof(struct ib_uverbs_flow_spec, reserved) &&
cmd.flow_attr.size >= cmd.flow_attr.size >=
((struct ib_uverbs_flow_spec *)kern_spec)->size; i++) { ((struct ib_uverbs_flow_spec *)kern_spec)->size; i++) {
err = kern_spec_to_ib_spec(file->ucontext, kern_spec, ib_spec, err = kern_spec_to_ib_spec(file, kern_spec, ib_spec, uflow_res);
uflow_res);
if (err) if (err)
goto err_free; goto err_free;
...@@ -3644,8 +3635,7 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file, ...@@ -3644,8 +3635,7 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
struct ib_srq_init_attr attr; struct ib_srq_init_attr attr;
int ret; int ret;
obj = (struct ib_usrq_object *)uobj_alloc(UVERBS_OBJECT_SRQ, obj = (struct ib_usrq_object *)uobj_alloc(UVERBS_OBJECT_SRQ, file);
file->ucontext);
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
...@@ -3654,7 +3644,7 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file, ...@@ -3654,7 +3644,7 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
if (cmd->srq_type == IB_SRQT_XRC) { if (cmd->srq_type == IB_SRQT_XRC) {
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->xrcd_handle, xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->xrcd_handle,
file->ucontext); file);
if (IS_ERR(xrcd_uobj)) { if (IS_ERR(xrcd_uobj)) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
...@@ -3671,15 +3661,15 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file, ...@@ -3671,15 +3661,15 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
} }
if (ib_srq_has_cq(cmd->srq_type)) { if (ib_srq_has_cq(cmd->srq_type)) {
attr.ext.cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd->cq_handle, attr.ext.cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ,
file->ucontext); cmd->cq_handle, file);
if (!attr.ext.cq) { if (!attr.ext.cq) {
ret = -EINVAL; ret = -EINVAL;
goto err_put_xrcd; goto err_put_xrcd;
} }
} }
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file->ucontext); pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file);
if (!pd) { if (!pd) {
ret = -EINVAL; ret = -EINVAL;
goto err_put_cq; goto err_put_cq;
...@@ -3851,7 +3841,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file, ...@@ -3851,7 +3841,7 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
ib_uverbs_init_udata(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd, ib_uverbs_init_udata(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
out_len); out_len);
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file->ucontext); srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
if (!srq) if (!srq)
return -EINVAL; return -EINVAL;
...@@ -3882,7 +3872,7 @@ ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file, ...@@ -3882,7 +3872,7 @@ ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file->ucontext); srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
if (!srq) if (!srq)
return -EINVAL; return -EINVAL;
...@@ -3919,8 +3909,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, ...@@ -3919,8 +3909,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
if (copy_from_user(&cmd, buf, sizeof cmd)) if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT; return -EFAULT;
uobj = uobj_get_write(UVERBS_OBJECT_SRQ, cmd.srq_handle, uobj = uobj_get_write(UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
file->ucontext);
if (IS_ERR(uobj)) if (IS_ERR(uobj))
return PTR_ERR(uobj); return PTR_ERR(uobj);
...@@ -4098,7 +4087,7 @@ int ib_uverbs_ex_modify_cq(struct ib_uverbs_file *file, ...@@ -4098,7 +4087,7 @@ int ib_uverbs_ex_modify_cq(struct ib_uverbs_file *file,
if (cmd.attr_mask > IB_CQ_MODERATE) if (cmd.attr_mask > IB_CQ_MODERATE)
return -EOPNOTSUPP; return -EOPNOTSUPP;
cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file->ucontext); cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
if (!cq) if (!cq)
return -EINVAL; return -EINVAL;
......
...@@ -56,20 +56,24 @@ static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type, ...@@ -56,20 +56,24 @@ static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type,
#define uobj_get_type(_object) UVERBS_OBJECT(_object).type_attrs #define uobj_get_type(_object) UVERBS_OBJECT(_object).type_attrs
#define uobj_get_read(_type, _id, _ucontext) \ #define uobj_get_read(_type, _id, _ufile) \
__uobj_get(uobj_get_type(_type), false, (_ucontext)->ufile, _id) __uobj_get(uobj_get_type(_type), false, _ufile, _id)
#define uobj_get_obj_read(_object, _type, _id, _ucontext) \ static inline void *_uobj_get_obj_read(const struct uverbs_obj_type *type,
({ \ int id, struct ib_uverbs_file *ufile)
struct ib_uobject *__uobj = \ {
__uobj_get(uobj_get_type(_type), \ struct ib_uobject *uobj = __uobj_get(type, false, ufile, id);
false, (_ucontext)->ufile, _id); \
\ if (IS_ERR(uobj))
(struct ib_##_object *)(IS_ERR(__uobj) ? NULL : __uobj->object);\ return NULL;
}) return uobj->object;
}
#define uobj_get_obj_read(_object, _type, _id, _ufile) \
((struct ib_##_object *)_uobj_get_obj_read(uobj_get_type(_type), _id, \
_ufile))
#define uobj_get_write(_type, _id, _ucontext) \ #define uobj_get_write(_type, _id, _ufile) \
__uobj_get(uobj_get_type(_type), true, (_ucontext)->ufile, _id) __uobj_get(uobj_get_type(_type), true, _ufile, _id)
int __uobj_perform_destroy(const struct uverbs_obj_type *type, int id, int __uobj_perform_destroy(const struct uverbs_obj_type *type, int id,
struct ib_uverbs_file *ufile, int success_res); struct ib_uverbs_file *ufile, int success_res);
...@@ -105,13 +109,12 @@ static inline void uobj_alloc_abort(struct ib_uobject *uobj) ...@@ -105,13 +109,12 @@ static inline void uobj_alloc_abort(struct ib_uobject *uobj)
} }
static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type, static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type,
struct ib_ucontext *ucontext) struct ib_uverbs_file *ufile)
{ {
return rdma_alloc_begin_uobject(type, ucontext->ufile); return rdma_alloc_begin_uobject(type, ufile);
} }
#define uobj_alloc(_type, ucontext) \ #define uobj_alloc(_type, _ufile) __uobj_alloc(uobj_get_type(_type), _ufile)
__uobj_alloc(uobj_get_type(_type), ucontext)
#endif #endif
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