Commit ef87df2c authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/uverbs: Use uverbs_attr_bundle to pass udata for write_ex

The core code needs to compute the udata so we may as well pass it in the
uverbs_attr_bundle instead of on the stack. This converts the simple case
of write_ex() which already has a core calculation.

Also change the write() path to use the attrs for ib_uverbs_init_udata()
instead of on the stack. This lets the write to write_ex compatibility
path continue to follow the lead of the _ex path.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent da0f60df
...@@ -139,7 +139,7 @@ struct uverbs_api_write_method { ...@@ -139,7 +139,7 @@ struct uverbs_api_write_method {
int (*handler)(struct uverbs_attr_bundle *attrs, const char __user *buf, int (*handler)(struct uverbs_attr_bundle *attrs, const char __user *buf,
int in_len, int out_len); int in_len, int out_len);
int (*handler_ex)(struct uverbs_attr_bundle *attrs, int (*handler_ex)(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw); struct ib_udata *ucore);
u8 disabled:1; u8 disabled:1;
u8 is_ex:1; u8 is_ex:1;
u8 has_udata:1; u8 has_udata:1;
......
This diff is collapsed.
...@@ -697,7 +697,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, ...@@ -697,7 +697,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
hdr.out_words * 4); hdr.out_words * 4);
} else { } else {
struct ib_udata ucore; struct ib_udata ucore;
struct ib_udata uhw;
buf += sizeof(ex_hdr); buf += sizeof(ex_hdr);
...@@ -705,13 +704,13 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, ...@@ -705,13 +704,13 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
u64_to_user_ptr(ex_hdr.response), u64_to_user_ptr(ex_hdr.response),
hdr.in_words * 8, hdr.out_words * 8); hdr.in_words * 8, hdr.out_words * 8);
ib_uverbs_init_udata_buf_or_null(&uhw, ib_uverbs_init_udata_buf_or_null(&bundle.driver_udata,
buf + ucore.inlen, buf + ucore.inlen,
u64_to_user_ptr(ex_hdr.response) + ucore.outlen, u64_to_user_ptr(ex_hdr.response) + ucore.outlen,
ex_hdr.provider_in_words * 8, ex_hdr.provider_in_words * 8,
ex_hdr.provider_out_words * 8); ex_hdr.provider_out_words * 8);
ret = method_elm->handler_ex(&bundle, &ucore, &uhw); ret = method_elm->handler_ex(&bundle, &ucore);
} }
srcu_read_unlock(&file->device->disassociate_srcu, srcu_key); srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
......
...@@ -15,7 +15,7 @@ static int ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs, ...@@ -15,7 +15,7 @@ static int ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs,
} }
static int ib_uverbs_ex_notsupp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_ex_notsupp(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw) struct ib_udata *ucore)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -375,8 +375,7 @@ struct uapi_definition { ...@@ -375,8 +375,7 @@ struct uapi_definition {
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len); int out_len);
int (*func_write_ex)(struct uverbs_attr_bundle *attrs, int (*func_write_ex)(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *ucore);
struct ib_udata *uhw);
const struct uapi_definition *chain; const struct uapi_definition *chain;
const struct uverbs_object_def *chain_obj_tree; const struct uverbs_object_def *chain_obj_tree;
size_t needs_fn_offset; size_t needs_fn_offset;
...@@ -643,6 +642,7 @@ struct uverbs_attr { ...@@ -643,6 +642,7 @@ struct uverbs_attr {
}; };
struct uverbs_attr_bundle { struct uverbs_attr_bundle {
struct ib_udata driver_udata;
struct ib_uverbs_file *ufile; struct ib_uverbs_file *ufile;
DECLARE_BITMAP(attr_present, UVERBS_API_ATTR_BKEY_LEN); DECLARE_BITMAP(attr_present, UVERBS_API_ATTR_BKEY_LEN);
struct uverbs_attr attrs[]; struct uverbs_attr attrs[];
......
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