Commit 8313c10f authored by Jason Gunthorpe's avatar Jason Gunthorpe
Browse files

RDMA/uverbs: Replace ib_uverbs_file with uverbs_attr_bundle for write



Now that we can add meta-data to the description of write() methods we
need to pass the uverbs_attr_bundle into all write based handlers so
future patches can use it as a container for any new data transferred out
of the core.

This is the first step to bringing the write() and ioctl() methods to a
common interface signature.

This is a simple search/replace, and we push the attr down into the uobj
and other APIs to keep changes minimal.

Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent 1b09577b
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -224,12 +224,14 @@ out_unlock:
 * uverbs_put_destroy.
 */
struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
				      u32 id, struct ib_uverbs_file *ufile)
				      u32 id,
				      const struct uverbs_attr_bundle *attrs)
{
	struct ib_uobject *uobj;
	int ret;

	uobj = rdma_lookup_get_uobject(obj, ufile, id, UVERBS_LOOKUP_DESTROY);
	uobj = rdma_lookup_get_uobject(obj, attrs->ufile, id,
				       UVERBS_LOOKUP_DESTROY);
	if (IS_ERR(uobj))
		return uobj;

@@ -248,11 +250,12 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
 * the uobj.
 */
int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
			   struct ib_uverbs_file *ufile, int success_res)
			   const struct uverbs_attr_bundle *attrs,
			   int success_res)
{
	struct ib_uobject *uobj;

	uobj = __uobj_get_destroy(obj, id, ufile);
	uobj = __uobj_get_destroy(obj, id, attrs);
	if (IS_ERR(uobj))
		return PTR_ERR(uobj);

@@ -267,7 +270,7 @@ static struct ib_uobject *alloc_uobj(struct ib_uverbs_file *ufile,
	struct ib_uobject *uobj;
	struct ib_ucontext *ucontext;

	ucontext = ib_uverbs_get_ucontext(ufile);
	ucontext = ib_uverbs_get_ucontext_file(ufile);
	if (IS_ERR(ucontext))
		return ERR_CAST(ucontext);

+4 −4
Original line number Diff line number Diff line
@@ -137,10 +137,10 @@ struct uverbs_api_ioctl_method {
};

struct uverbs_api_write_method {
	ssize_t (*handler)(struct ib_uverbs_file *file, const char __user *buf,
			   int in_len, int out_len);
	int (*handler_ex)(struct ib_uverbs_file *file, struct ib_udata *ucore,
			  struct ib_udata *uhw);
	ssize_t (*handler)(struct uverbs_attr_bundle *attrs,
			   const char __user *buf, int in_len, int out_len);
	int (*handler_ex)(struct uverbs_attr_bundle *attrs,
			  struct ib_udata *ucore, struct ib_udata *uhw);
	u8 disabled:1;
	u8 is_ex:1;
};
+152 −149

File changed.

Preview size limit exceeded, changes collapsed.

+7 −5
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ static void ib_uverbs_remove_one(struct ib_device *device, void *client_data);
 * Must be called with the ufile->device->disassociate_srcu held, and the lock
 * must be held until use of the ucontext is finished.
 */
struct ib_ucontext *ib_uverbs_get_ucontext(struct ib_uverbs_file *ufile)
struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile)
{
	/*
	 * We do not hold the hw_destroy_rwsem lock for this flow, instead
@@ -99,7 +99,7 @@ struct ib_ucontext *ib_uverbs_get_ucontext(struct ib_uverbs_file *ufile)

	return ucontext;
}
EXPORT_SYMBOL(ib_uverbs_get_ucontext);
EXPORT_SYMBOL(ib_uverbs_get_ucontext_file);

int uverbs_dealloc_mw(struct ib_mw *mw)
{
@@ -632,6 +632,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
	struct uverbs_api *uapi = file->device->uapi;
	struct ib_uverbs_ex_cmd_hdr ex_hdr;
	struct ib_uverbs_cmd_hdr hdr;
	struct uverbs_attr_bundle bundle;
	int srcu_key;
	ssize_t ret;

@@ -666,8 +667,9 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,

	buf += sizeof(hdr);

	bundle.ufile = file;
	if (!method_elm->is_ex) {
		ret = method_elm->handler(file, buf, hdr.in_words * 4,
		ret = method_elm->handler(&bundle, buf, hdr.in_words * 4,
					  hdr.out_words * 4);
	} else {
		struct ib_udata ucore;
@@ -685,7 +687,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
					ex_hdr.provider_in_words * 8,
					ex_hdr.provider_out_words * 8);

		ret = method_elm->handler_ex(file, &ucore, &uhw);
		ret = method_elm->handler_ex(&bundle, &ucore, &uhw);
		ret = (ret) ? : count;
	}

@@ -701,7 +703,7 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
	int srcu_key;

	srcu_key = srcu_read_lock(&file->device->disassociate_srcu);
	ucontext = ib_uverbs_get_ucontext(file);
	ucontext = ib_uverbs_get_ucontext_file(file);
	if (IS_ERR(ucontext)) {
		ret = PTR_ERR(ucontext);
		goto out;
+2 −2
Original line number Diff line number Diff line
@@ -8,14 +8,14 @@
#include "rdma_core.h"
#include "uverbs.h"

static ssize_t ib_uverbs_notsupp(struct ib_uverbs_file *file,
static ssize_t ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs,
				 const char __user *buf, int in_len,
				 int out_len)
{
	return -EOPNOTSUPP;
}

static int ib_uverbs_ex_notsupp(struct ib_uverbs_file *file,
static int ib_uverbs_ex_notsupp(struct uverbs_attr_bundle *attrs,
				struct ib_udata *ucore, struct ib_udata *uhw)
{
	return -EOPNOTSUPP;
Loading