#include "core_priv.h"
static struct ib_uverbs_completion_event_file *
-_ib_uverbs_lookup_comp_file(s32 fd, struct ib_uverbs_file *ufile)
+_ib_uverbs_lookup_comp_file(s32 fd, const struct uverbs_attr_bundle *attrs)
{
struct ib_uobject *uobj = ufd_get_read(UVERBS_OBJECT_COMP_CHANNEL,
- fd, ufile);
+ fd, attrs);
if (IS_ERR(uobj))
return (void *)uobj;
#define ib_uverbs_lookup_comp_file(_fd, _ufile) \
_ib_uverbs_lookup_comp_file((_fd)*typecheck(s32, _fd), _ufile)
-static ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_get_context(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
+ struct ib_uverbs_file *file = attrs->ufile;
struct ib_uverbs_get_context cmd;
struct ib_uverbs_get_context_resp resp;
struct ib_udata udata;
resp->phys_port_cnt = ib_dev->phys_port_cnt;
}
-static ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_query_device(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
struct ib_uverbs_query_device_resp resp;
struct ib_ucontext *ucontext;
- ucontext = ib_uverbs_get_ucontext(file);
+ ucontext = ib_uverbs_get_ucontext(attrs);
if (IS_ERR(ucontext))
return PTR_ERR(ucontext);
return res;
}
-static ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_query_port(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
struct ib_ucontext *ucontext;
struct ib_device *ib_dev;
- ucontext = ib_uverbs_get_ucontext(file);
+ ucontext = ib_uverbs_get_ucontext(attrs);
if (IS_ERR(ucontext))
return PTR_ERR(ucontext);
ib_dev = ucontext->device;
return in_len;
}
-static ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- uobj = uobj_alloc(UVERBS_OBJECT_PD, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_PD, attrs, &ib_dev);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
return ret;
}
-static ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_dealloc_pd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- return uobj_perform_destroy(UVERBS_OBJECT_PD, cmd.pd_handle, file,
+ return uobj_perform_destroy(UVERBS_OBJECT_PD, cmd.pd_handle, attrs,
in_len);
}
}
}
-static ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
+ struct ib_uverbs_device *ibudev = attrs->ufile->device;
struct ib_uverbs_open_xrcd cmd;
struct ib_uverbs_open_xrcd_resp resp;
struct ib_udata udata;
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- mutex_lock(&file->device->xrcd_tree_mutex);
+ mutex_lock(&ibudev->xrcd_tree_mutex);
if (cmd.fd != -1) {
/* search for file descriptor */
}
inode = file_inode(f.file);
- xrcd = find_xrcd(file->device, inode);
+ xrcd = find_xrcd(ibudev, inode);
if (!xrcd && !(cmd.oflags & O_CREAT)) {
/* no file descriptor. Need CREATE flag */
ret = -EAGAIN;
}
}
- obj = (struct ib_uxrcd_object *)uobj_alloc(UVERBS_OBJECT_XRCD, file,
+ obj = (struct ib_uxrcd_object *)uobj_alloc(UVERBS_OBJECT_XRCD, attrs,
&ib_dev);
if (IS_ERR(obj)) {
ret = PTR_ERR(obj);
if (inode) {
if (new_xrcd) {
/* create new inode/xrcd table entry */
- ret = xrcd_table_insert(file->device, inode, xrcd);
+ ret = xrcd_table_insert(ibudev, inode, xrcd);
if (ret)
goto err_dealloc_xrcd;
}
if (f.file)
fdput(f);
- mutex_unlock(&file->device->xrcd_tree_mutex);
+ mutex_unlock(&ibudev->xrcd_tree_mutex);
return uobj_alloc_commit(&obj->uobject, in_len);
err_copy:
if (inode) {
if (new_xrcd)
- xrcd_table_delete(file->device, inode);
+ xrcd_table_delete(ibudev, inode);
atomic_dec(&xrcd->usecnt);
}
if (f.file)
fdput(f);
- mutex_unlock(&file->device->xrcd_tree_mutex);
+ mutex_unlock(&ibudev->xrcd_tree_mutex);
return ret;
}
-static ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_close_xrcd(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- return uobj_perform_destroy(UVERBS_OBJECT_XRCD, cmd.xrcd_handle, file,
+ return uobj_perform_destroy(UVERBS_OBJECT_XRCD, cmd.xrcd_handle, attrs,
in_len);
}
return ret;
}
-static ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, int out_len)
{
struct ib_uverbs_reg_mr cmd;
if (ret)
return ret;
- uobj = uobj_alloc(UVERBS_OBJECT_MR, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_MR, attrs, &ib_dev);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
- pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
+ pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs);
if (!pd) {
ret = -EINVAL;
goto err_free;
return ret;
}
-static ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
(cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)))
return -EINVAL;
- uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, file);
+ uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, attrs);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
if (cmd.flags & IB_MR_REREG_PD) {
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle,
- file);
+ attrs);
if (!pd) {
ret = -EINVAL;
goto put_uobjs;
return ret;
}
-static ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_dereg_mr(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- return uobj_perform_destroy(UVERBS_OBJECT_MR, cmd.mr_handle, file,
+ return uobj_perform_destroy(UVERBS_OBJECT_MR, cmd.mr_handle, attrs,
in_len);
}
-static ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof(cmd)))
return -EFAULT;
- uobj = uobj_alloc(UVERBS_OBJECT_MW, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_MW, attrs, &ib_dev);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
- pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
+ pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs);
if (!pd) {
ret = -EINVAL;
goto err_free;
return ret;
}
-static ssize_t ib_uverbs_dealloc_mw(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_dealloc_mw(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof(cmd)))
return -EFAULT;
- return uobj_perform_destroy(UVERBS_OBJECT_MW, cmd.mw_handle, file,
+ return uobj_perform_destroy(UVERBS_OBJECT_MW, cmd.mw_handle, attrs,
in_len);
}
-static ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_create_comp_channel(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- uobj = uobj_alloc(UVERBS_OBJECT_COMP_CHANNEL, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_COMP_CHANNEL, attrs, &ib_dev);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
return uobj_alloc_commit(uobj, in_len);
}
-static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
+static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw,
struct ib_uverbs_ex_create_cq *cmd,
size_t cmd_sz,
- int (*cb)(struct ib_uverbs_file *file,
+ int (*cb)(struct uverbs_attr_bundle *attrs,
struct ib_ucq_object *obj,
struct ib_uverbs_ex_create_cq_resp *resp,
struct ib_udata *udata,
struct ib_cq_init_attr attr = {};
struct ib_device *ib_dev;
- if (cmd->comp_vector >= file->device->num_comp_vectors)
+ if (cmd->comp_vector >= attrs->ufile->device->num_comp_vectors)
return ERR_PTR(-EINVAL);
- obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ, file,
+ obj = (struct ib_ucq_object *)uobj_alloc(UVERBS_OBJECT_CQ, attrs,
&ib_dev);
if (IS_ERR(obj))
return obj;
if (cmd->comp_channel >= 0) {
- ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel, file);
+ ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel, attrs);
if (IS_ERR(ev_file)) {
ret = PTR_ERR(ev_file);
goto err;
cq->res.type = RDMA_RESTRACK_CQ;
rdma_restrack_add(&cq->res);
- ret = cb(file, obj, &resp, ucore, context);
+ ret = cb(attrs, obj, &resp, ucore, context);
if (ret)
goto err_cb;
err_file:
if (ev_file)
- ib_uverbs_release_ucq(file, ev_file, obj);
+ ib_uverbs_release_ucq(attrs->ufile, ev_file, obj);
err:
uobj_alloc_abort(&obj->uobject);
return ERR_PTR(ret);
}
-static int ib_uverbs_create_cq_cb(struct ib_uverbs_file *file,
+static int ib_uverbs_create_cq_cb(struct uverbs_attr_bundle *attrs,
struct ib_ucq_object *obj,
struct ib_uverbs_ex_create_cq_resp *resp,
struct ib_udata *ucore, void *context)
return 0;
}
-static ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_create_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
cmd_ex.comp_vector = cmd.comp_vector;
cmd_ex.comp_channel = cmd.comp_channel;
- obj = create_cq(file, &ucore, &uhw, &cmd_ex,
+ obj = create_cq(attrs, &ucore, &uhw, &cmd_ex,
offsetof(typeof(cmd_ex), comp_channel) +
sizeof(cmd.comp_channel), ib_uverbs_create_cq_cb,
NULL);
return in_len;
}
-static int ib_uverbs_ex_create_cq_cb(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_cq_cb(struct uverbs_attr_bundle *attrs,
struct ib_ucq_object *obj,
struct ib_uverbs_ex_create_cq_resp *resp,
struct ib_udata *ucore, void *context)
return 0;
}
-static int ib_uverbs_ex_create_cq(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_cq(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_create_cq_resp resp;
sizeof(resp.response_length)))
return -ENOSPC;
- obj = create_cq(file, ucore, uhw, &cmd,
+ obj = create_cq(attrs, ucore, uhw, &cmd,
min(ucore->inlen, sizeof(cmd)),
ib_uverbs_ex_create_cq_cb, NULL);
return PTR_ERR_OR_ZERO(obj);
}
-static ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_resize_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
+ cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs);
if (!cq)
return -EINVAL;
return 0;
}
-static ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_poll_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
+ cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs);
if (!cq)
return -EINVAL;
return ret;
}
-static ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_req_notify_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
+ cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs);
if (!cq)
return -EINVAL;
return in_len;
}
-static ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_destroy_cq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- uobj = uobj_get_destroy(UVERBS_OBJECT_CQ, cmd.cq_handle, file);
+ uobj = uobj_get_destroy(UVERBS_OBJECT_CQ, cmd.cq_handle, attrs);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
return in_len;
}
-static int create_qp(struct ib_uverbs_file *file,
+static int create_qp(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw,
struct ib_uverbs_ex_create_qp *cmd,
size_t cmd_sz,
- int (*cb)(struct ib_uverbs_file *file,
+ int (*cb)(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_ex_create_qp_resp *resp,
struct ib_udata *udata),
void *context)
if (cmd->qp_type == IB_QPT_RAW_PACKET && !capable(CAP_NET_RAW))
return -EPERM;
- obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file,
+ obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, attrs,
&ib_dev);
if (IS_ERR(obj))
return PTR_ERR(obj);
(cmd->comp_mask & IB_UVERBS_CREATE_QP_MASK_IND_TABLE)) {
ind_tbl = uobj_get_obj_read(rwq_ind_table,
UVERBS_OBJECT_RWQ_IND_TBL,
- cmd->rwq_ind_tbl_handle, file);
+ cmd->rwq_ind_tbl_handle, attrs);
if (!ind_tbl) {
ret = -EINVAL;
goto err_put;
if (cmd->qp_type == IB_QPT_XRC_TGT) {
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->pd_handle,
- file);
+ attrs);
if (IS_ERR(xrcd_uobj)) {
ret = -EINVAL;
} else {
if (cmd->is_srq) {
srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ,
- cmd->srq_handle, file);
+ cmd->srq_handle, attrs);
if (!srq || srq->srq_type == IB_SRQT_XRC) {
ret = -EINVAL;
goto err_put;
if (cmd->recv_cq_handle != cmd->send_cq_handle) {
rcq = uobj_get_obj_read(
cq, UVERBS_OBJECT_CQ,
- cmd->recv_cq_handle, file);
+ cmd->recv_cq_handle, attrs);
if (!rcq) {
ret = -EINVAL;
goto err_put;
if (has_sq)
scq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ,
- cmd->send_cq_handle, file);
+ cmd->send_cq_handle, attrs);
if (!ind_tbl)
rcq = rcq ?: scq;
pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle,
- file);
+ attrs);
if (!pd || (!scq && has_sq)) {
ret = -EINVAL;
goto err_put;
}
attr.event_handler = ib_uverbs_qp_event_handler;
- attr.qp_context = file;
+ attr.qp_context = attrs->ufile;
attr.send_cq = scq;
attr.recv_cq = rcq;
attr.srq = srq;
resp.response_length = offsetof(typeof(resp), response_length) +
sizeof(resp.response_length);
- ret = cb(file, &resp, ucore);
+ ret = cb(attrs, &resp, ucore);
if (ret)
goto err_cb;
return ret;
}
-static int ib_uverbs_create_qp_cb(struct ib_uverbs_file *file,
+static int ib_uverbs_create_qp_cb(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_ex_create_qp_resp *resp,
struct ib_udata *ucore)
{
return 0;
}
-static ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_create_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
cmd_ex.qp_type = cmd.qp_type;
cmd_ex.is_srq = cmd.is_srq;
- err = create_qp(file, &ucore, &uhw, &cmd_ex,
+ err = create_qp(attrs, &ucore, &uhw, &cmd_ex,
offsetof(typeof(cmd_ex), is_srq) +
sizeof(cmd.is_srq), ib_uverbs_create_qp_cb,
NULL);
return in_len;
}
-static int ib_uverbs_ex_create_qp_cb(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_qp_cb(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_ex_create_qp_resp *resp,
struct ib_udata *ucore)
{
return 0;
}
-static int ib_uverbs_ex_create_qp(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_qp(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_create_qp_resp resp;
sizeof(resp.response_length)))
return -ENOSPC;
- err = create_qp(file, ucore, uhw, &cmd,
+ err = create_qp(attrs, ucore, uhw, &cmd,
min(ucore->inlen, sizeof(cmd)),
ib_uverbs_ex_create_qp_cb, NULL);
return 0;
}
-static ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, file,
+ obj = (struct ib_uqp_object *)uobj_alloc(UVERBS_OBJECT_QP, attrs,
&ib_dev);
if (IS_ERR(obj))
return PTR_ERR(obj);
- xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd.pd_handle, file);
+ xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd.pd_handle, attrs);
if (IS_ERR(xrcd_uobj)) {
ret = -EINVAL;
goto err_put;
}
attr.event_handler = ib_uverbs_qp_event_handler;
- attr.qp_context = file;
+ attr.qp_context = attrs->ufile;
attr.qp_num = cmd.qpn;
attr.qp_type = cmd.qp_type;
uverb_attr->port_num = rdma_ah_get_port_num(rdma_attr);
}
-static ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_query_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
goto out;
}
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (!qp) {
ret = -EINVAL;
goto out;
rdma_ah_set_make_grd(rdma_attr, false);
}
-static int modify_qp(struct ib_uverbs_file *file,
+static int modify_qp(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_ex_modify_qp *cmd, struct ib_udata *udata)
{
struct ib_qp_attr *attr;
if (!attr)
return -ENOMEM;
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd->base.qp_handle,
+ attrs);
if (!qp) {
ret = -EINVAL;
goto out;
return ret;
}
-static ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_modify_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd.base) - sizeof(struct ib_uverbs_cmd_hdr),
out_len);
- ret = modify_qp(file, &cmd, &udata);
+ ret = modify_qp(attrs, &cmd, &udata);
if (ret)
return ret;
return in_len;
}
-static int ib_uverbs_ex_modify_qp(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_modify_qp(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_modify_qp cmd = {};
return -EOPNOTSUPP;
}
- ret = modify_qp(file, &cmd, uhw);
+ ret = modify_qp(attrs, &cmd, uhw);
return ret;
}
-static ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_destroy_qp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- uobj = uobj_get_destroy(UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ uobj = uobj_get_destroy(UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
num_sge * sizeof (struct ib_sge), GFP_KERNEL);
}
-static ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_post_send(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (!user_wr)
return -ENOMEM;
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (!qp)
goto out;
}
ud->ah = uobj_get_obj_read(ah, UVERBS_OBJECT_AH,
- user_wr->wr.ud.ah, file);
+ user_wr->wr.ud.ah, attrs);
if (!ud->ah) {
kfree(ud);
ret = -EINVAL;
return ERR_PTR(ret);
}
-static ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_post_recv(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (IS_ERR(wr))
return PTR_ERR(wr);
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (!qp)
goto out;
return ret ? ret : in_len;
}
-static ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_post_srq_recv(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (IS_ERR(wr))
return PTR_ERR(wr);
- srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
+ srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs);
if (!srq)
goto out;
return ret ? ret : in_len;
}
-static ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- uobj = uobj_alloc(UVERBS_OBJECT_AH, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_AH, attrs, &ib_dev);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
goto err;
}
- pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
+ pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs);
if (!pd) {
ret = -EINVAL;
goto err;
return ret;
}
-static ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_destroy_ah(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- return uobj_perform_destroy(UVERBS_OBJECT_AH, cmd.ah_handle, file,
+ return uobj_perform_destroy(UVERBS_OBJECT_AH, cmd.ah_handle, attrs,
in_len);
}
-static ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_attach_mcast(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (!qp)
return -EINVAL;
return ret ? ret : in_len;
}
-static ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_detach_mcast(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (!qp)
return -EINVAL;
}
EXPORT_SYMBOL(flow_resources_add);
-static int kern_spec_to_ib_spec_action(struct ib_uverbs_file *ufile,
+static int kern_spec_to_ib_spec_action(const struct uverbs_attr_bundle *attrs,
struct ib_uverbs_flow_spec *kern_spec,
union ib_flow_spec *ib_spec,
struct ib_uflow_resources *uflow_res)
ib_spec->action.act = uobj_get_obj_read(flow_action,
UVERBS_OBJECT_FLOW_ACTION,
kern_spec->action.handle,
- ufile);
+ attrs);
if (!ib_spec->action.act)
return -EINVAL;
ib_spec->action.size =
uobj_get_obj_read(counters,
UVERBS_OBJECT_COUNTERS,
kern_spec->flow_count.handle,
- ufile);
+ attrs);
if (!ib_spec->flow_count.counters)
return -EINVAL;
ib_spec->flow_count.size =
kern_filter_sz, ib_spec);
}
-static int kern_spec_to_ib_spec(struct ib_uverbs_file *ufile,
+static int kern_spec_to_ib_spec(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_flow_spec *kern_spec,
union ib_flow_spec *ib_spec,
struct ib_uflow_resources *uflow_res)
return -EINVAL;
if (kern_spec->type >= IB_FLOW_SPEC_ACTION_TAG)
- return kern_spec_to_ib_spec_action(ufile, kern_spec, ib_spec,
+ return kern_spec_to_ib_spec_action(attrs, kern_spec, ib_spec,
uflow_res);
else
return kern_spec_to_ib_spec_filter(kern_spec, ib_spec);
}
-static int ib_uverbs_ex_create_wq(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_create_wq cmd = {};
if (cmd.comp_mask)
return -EOPNOTSUPP;
- obj = (struct ib_uwq_object *)uobj_alloc(UVERBS_OBJECT_WQ, file,
+ obj = (struct ib_uwq_object *)uobj_alloc(UVERBS_OBJECT_WQ, attrs,
&ib_dev);
if (IS_ERR(obj))
return PTR_ERR(obj);
- pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, file);
+ pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd.pd_handle, attrs);
if (!pd) {
err = -EINVAL;
goto err_uobj;
}
- cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
+ cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs);
if (!cq) {
err = -EINVAL;
goto err_put_pd;
wq_init_attr.cq = cq;
wq_init_attr.max_sge = cmd.max_sge;
wq_init_attr.max_wr = cmd.max_wr;
- wq_init_attr.wq_context = file;
+ wq_init_attr.wq_context = attrs->ufile;
wq_init_attr.wq_type = cmd.wq_type;
wq_init_attr.event_handler = ib_uverbs_wq_event_handler;
if (ucore->inlen >= (offsetof(typeof(cmd), create_flags) +
return err;
}
-static int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_destroy_wq(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_destroy_wq cmd = {};
return -EOPNOTSUPP;
resp.response_length = required_resp_len;
- uobj = uobj_get_destroy(UVERBS_OBJECT_WQ, cmd.wq_handle, file);
+ uobj = uobj_get_destroy(UVERBS_OBJECT_WQ, cmd.wq_handle, attrs);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
return ib_copy_to_udata(ucore, &resp, resp.response_length);
}
-static int ib_uverbs_ex_modify_wq(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_modify_wq(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_modify_wq cmd = {};
if (cmd.attr_mask > (IB_WQ_STATE | IB_WQ_CUR_STATE | IB_WQ_FLAGS))
return -EINVAL;
- wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, file);
+ wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ, cmd.wq_handle, attrs);
if (!wq)
return -EINVAL;
return ret;
}
-static int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_rwq_ind_table(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw)
{
for (num_read_wqs = 0; num_read_wqs < num_wq_handles;
num_read_wqs++) {
wq = uobj_get_obj_read(wq, UVERBS_OBJECT_WQ,
- wqs_handles[num_read_wqs], file);
+ wqs_handles[num_read_wqs], attrs);
if (!wq) {
err = -EINVAL;
goto put_wqs;
wqs[num_read_wqs] = wq;
}
- uobj = uobj_alloc(UVERBS_OBJECT_RWQ_IND_TBL, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_RWQ_IND_TBL, attrs, &ib_dev);
if (IS_ERR(uobj)) {
err = PTR_ERR(uobj);
goto put_wqs;
return err;
}
-static int ib_uverbs_ex_destroy_rwq_ind_table(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_destroy_rwq_ind_table(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw)
{
return -EOPNOTSUPP;
return uobj_perform_destroy(UVERBS_OBJECT_RWQ_IND_TBL,
- cmd.ind_tbl_handle, file, 0);
+ cmd.ind_tbl_handle, attrs, 0);
}
-static int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw)
{
kern_flow_attr = &cmd.flow_attr;
}
- uobj = uobj_alloc(UVERBS_OBJECT_FLOW, file, &ib_dev);
+ uobj = uobj_alloc(UVERBS_OBJECT_FLOW, attrs, &ib_dev);
if (IS_ERR(uobj)) {
err = PTR_ERR(uobj);
goto err_free_attr;
}
- qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, file);
+ qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
if (!qp) {
err = -EINVAL;
goto err_uobj;
cmd.flow_attr.size >= kern_spec->size;
i++) {
err = kern_spec_to_ib_spec(
- file, (struct ib_uverbs_flow_spec *)kern_spec,
+ attrs, (struct ib_uverbs_flow_spec *)kern_spec,
ib_spec, uflow_res);
if (err)
goto err_free;
return err;
}
-static int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_destroy_flow(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw)
{
if (cmd.comp_mask)
return -EINVAL;
- return uobj_perform_destroy(UVERBS_OBJECT_FLOW, cmd.flow_handle, file,
+ return uobj_perform_destroy(UVERBS_OBJECT_FLOW, cmd.flow_handle, attrs,
0);
}
-static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
+static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
struct ib_uverbs_create_xsrq *cmd,
struct ib_udata *udata)
{
int ret;
struct ib_device *ib_dev;
- obj = (struct ib_usrq_object *)uobj_alloc(UVERBS_OBJECT_SRQ, file,
+ obj = (struct ib_usrq_object *)uobj_alloc(UVERBS_OBJECT_SRQ, attrs,
&ib_dev);
if (IS_ERR(obj))
return PTR_ERR(obj);
if (cmd->srq_type == IB_SRQT_XRC) {
xrcd_uobj = uobj_get_read(UVERBS_OBJECT_XRCD, cmd->xrcd_handle,
- file);
+ attrs);
if (IS_ERR(xrcd_uobj)) {
ret = -EINVAL;
goto err;
if (ib_srq_has_cq(cmd->srq_type)) {
attr.ext.cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ,
- cmd->cq_handle, file);
+ cmd->cq_handle, attrs);
if (!attr.ext.cq) {
ret = -EINVAL;
goto err_put_xrcd;
}
}
- pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, file);
+ pd = uobj_get_obj_read(pd, UVERBS_OBJECT_PD, cmd->pd_handle, attrs);
if (!pd) {
ret = -EINVAL;
goto err_put_cq;
}
attr.event_handler = ib_uverbs_srq_event_handler;
- attr.srq_context = file;
+ attr.srq_context = attrs->ufile;
attr.srq_type = cmd->srq_type;
attr.attr.max_wr = cmd->max_wr;
attr.attr.max_sge = cmd->max_sge;
return ret;
}
-static ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_create_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- ret = __uverbs_create_xsrq(file, &xcmd, &udata);
+ ret = __uverbs_create_xsrq(attrs, &xcmd, &udata);
if (ret)
return ret;
return in_len;
}
-static ssize_t ib_uverbs_create_xsrq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_create_xsrq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
out_len - sizeof(resp));
- ret = __uverbs_create_xsrq(file, &cmd, &udata);
+ ret = __uverbs_create_xsrq(attrs, &cmd, &udata);
if (ret)
return ret;
return in_len;
}
-static ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_modify_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
ib_uverbs_init_udata(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
out_len);
- srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
+ srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs);
if (!srq)
return -EINVAL;
return ret ? ret : in_len;
}
-static ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_query_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
+ srq = uobj_get_obj_read(srq, UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs);
if (!srq)
return -EINVAL;
return in_len;
}
-static ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
+static ssize_t ib_uverbs_destroy_srq(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len,
int out_len)
{
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- uobj = uobj_get_destroy(UVERBS_OBJECT_SRQ, cmd.srq_handle, file);
+ uobj = uobj_get_destroy(UVERBS_OBJECT_SRQ, cmd.srq_handle, attrs);
if (IS_ERR(uobj))
return PTR_ERR(uobj);
return in_len;
}
-static int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_query_device(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore,
struct ib_udata *uhw)
{
struct ib_device *ib_dev;
int err;
- ucontext = ib_uverbs_get_ucontext(file);
+ ucontext = ib_uverbs_get_ucontext(attrs);
if (IS_ERR(ucontext))
return PTR_ERR(ucontext);
ib_dev = ucontext->device;
return err;
}
-static int ib_uverbs_ex_modify_cq(struct ib_uverbs_file *file,
+static int ib_uverbs_ex_modify_cq(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw)
{
struct ib_uverbs_ex_modify_cq cmd = {};
if (cmd.attr_mask > IB_CQ_MODERATE)
return -EOPNOTSUPP;
- cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, file);
+ cq = uobj_get_obj_read(cq, UVERBS_OBJECT_CQ, cmd.cq_handle, attrs);
if (!cq)
return -EINVAL;