]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/uverbs: Use uverbs_attr_bundle to pass udata for ioctl()
authorJason Gunthorpe <jgg@mellanox.com>
Sun, 25 Nov 2018 18:51:20 +0000 (20:51 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 26 Nov 2018 23:48:07 +0000 (16:48 -0700)
Have the core code initialize the driver_udata if the method has a udata
description. This is done using the same create_udata the handler was
supposed to call.

This makes ioctl consistent with the write and write_ex paths.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
drivers/infiniband/core/rdma_core.h
drivers/infiniband/core/uverbs_ioctl.c
drivers/infiniband/core/uverbs_std_types_cq.c
drivers/infiniband/core/uverbs_uapi.c
include/rdma/uverbs_ioctl.h

index b11396536d8e63f8d9526fc522648c601c158d9d..b1bf1579fc26270dd991c3c5a0bbde0c14c63948 100644 (file)
@@ -131,6 +131,7 @@ struct uverbs_api_ioctl_method {
        u8 use_stack:1;
        u8 driver_method:1;
        u8 disabled:1;
+       u8 has_udata:1;
        u8 key_bitmap_len;
        u8 destroy_bkey;
 };
index 5c04149ce77549ac2941d8b9b744957ea61c2af8..e643a43dce8d61715dd653da4395a4e425e5e5a2 100644 (file)
@@ -435,6 +435,9 @@ static int ib_uverbs_run_method(struct bundle_priv *pbundle,
                                    pbundle->method_elm->key_bitmap_len)))
                return -EINVAL;
 
+       if (pbundle->method_elm->has_udata)
+               create_udata(&pbundle->bundle, &pbundle->bundle.driver_udata);
+
        if (destroy_bkey != UVERBS_API_ATTR_BKEY_LEN) {
                struct uverbs_obj_attr *destroy_attr =
                        &pbundle->bundle.attrs[destroy_bkey].obj_attr;
index 859d1e862034a59db36a5581e0bf1f29139f7af5..859518eab5830e7ad9d11068853ad12257b458f1 100644 (file)
@@ -64,7 +64,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
                uverbs_attr_get_uobject(attrs, UVERBS_ATTR_CREATE_CQ_HANDLE),
                typeof(*obj), uobject);
        struct ib_device *ib_dev = obj->uobject.context->device;
-       struct ib_udata uhw;
        int ret;
        u64 user_handle;
        struct ib_cq_init_attr attr = {};
@@ -111,10 +110,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
        INIT_LIST_HEAD(&obj->comp_list);
        INIT_LIST_HEAD(&obj->async_list);
 
-       /* Temporary, only until drivers get the new uverbs_attr_bundle */
-       create_udata(attrs, &uhw);
-
-       cq = ib_dev->create_cq(ib_dev, &attr, obj->uobject.context, &uhw);
+       cq = ib_dev->create_cq(ib_dev, &attr, obj->uobject.context,
+                              &attrs->driver_udata);
        if (IS_ERR(cq)) {
                ret = PTR_ERR(cq);
                goto err_event_file;
index e16137cc5b28994e252abc761cd4370af5bbb4a6..b3d5f36b0462537dc013c6584403acc4189e7c89 100644 (file)
@@ -381,6 +381,9 @@ uapi_finalize_ioctl_method(struct uverbs_api *uapi,
                if (elm->spec.mandatory)
                        __set_bit(attr_bkey, method_elm->attr_mandatory);
 
+               if (elm->spec.is_udata)
+                       method_elm->has_udata = true;
+
                if (type == UVERBS_ATTR_TYPE_IDR ||
                    type == UVERBS_ATTR_TYPE_FD) {
                        u8 access = elm->spec.u.obj.access;
index 5fa8d63aa83875773d0f31c2b3ec00e3c44af9d5..8fc87079c2b8862250dc5142ca86955f1084eb73 100644 (file)
@@ -79,6 +79,8 @@ struct uverbs_attr_spec {
         */
        u8 alloc_and_copy:1;
        u8 mandatory:1;
+       /* True if this is from UVERBS_ATTR_UHW */
+       u8 is_udata:1;
 
        union {
                struct {
@@ -598,10 +600,12 @@ struct uapi_definition {
 #define UVERBS_ATTR_UHW()                                                      \
        UVERBS_ATTR_PTR_IN(UVERBS_ATTR_UHW_IN,                                 \
                           UVERBS_ATTR_MIN_SIZE(0),                            \
-                          UA_OPTIONAL),                                       \
+                          UA_OPTIONAL,                                        \
+                          .is_udata = 1),                                     \
        UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_UHW_OUT,                               \
                            UVERBS_ATTR_MIN_SIZE(0),                           \
-                           UA_OPTIONAL)
+                           UA_OPTIONAL,                                       \
+                           .is_udata = 1)
 
 /* =================================================
  *              Parsing infrastructure