RDMA/uverbs: Add generic function to fill in flow action object
authorMark Bloch <markb@mellanox.com>
Tue, 28 Aug 2018 11:18:52 +0000 (14:18 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 5 Sep 2018 21:23:59 +0000 (15:23 -0600)
Refactor the initialization of a flow action object to a common function.

Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs_std_types_flow_action.c
drivers/infiniband/hw/mlx5/flow.c
include/rdma/uverbs_std_types.h

index d8cfafe23bd9cd9e1bff887d176bed47d1c6ae24..cb9486ad5c677609bbfc5311c0baba0730c08835 100644 (file)
@@ -326,11 +326,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_FLOW_ACTION_ESP_CREATE)(
        if (IS_ERR(action))
                return PTR_ERR(action);
 
-       atomic_set(&action->usecnt, 0);
-       action->device = ib_dev;
-       action->type = IB_FLOW_ACTION_ESP;
-       action->uobject = uobj;
-       uobj->object = action;
+       uverbs_flow_action_fill_action(action, uobj, ib_dev,
+                                      IB_FLOW_ACTION_ESP);
 
        return 0;
 }
index 02103a4b372c35559930ef9972f7d34194a2e24f..0c89d5431c7e0ca0ac762ad5ebcc0d4fc8d0c903 100644 (file)
@@ -7,6 +7,7 @@
 #include <rdma/ib_verbs.h>
 #include <rdma/uverbs_types.h>
 #include <rdma/uverbs_ioctl.h>
+#include <rdma/uverbs_std_types.h>
 #include <rdma/mlx5_user_ioctl_cmds.h>
 #include <rdma/mlx5_user_ioctl_verbs.h>
 #include <rdma/ib_umem.h>
@@ -279,11 +280,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(
        if (IS_ERR(action))
                return PTR_ERR(action);
 
-       atomic_set(&action->usecnt, 0);
-       action->device = uobj->context->device;
-       action->type = IB_FLOW_ACTION_UNSPECIFIED;
-       action->uobject = uobj;
-       uobj->object = action;
+       uverbs_flow_action_fill_action(action, uobj, uobj->context->device,
+                                      IB_FLOW_ACTION_UNSPECIFIED);
 
        return 0;
 }
index 3b00231cc084d7528e7052c4f8db78a1d0d1ca23..526d918fcd5a88bb10c2074b71fbad7fceec7a3c 100644 (file)
@@ -140,5 +140,17 @@ __uobj_alloc(const struct uverbs_api_object *obj, struct ib_uverbs_file *ufile,
 #define uobj_alloc(_type, _ufile, _ib_dev)                                     \
        __uobj_alloc(uobj_get_type(_ufile, _type), _ufile, _ib_dev)
 
+static inline void uverbs_flow_action_fill_action(struct ib_flow_action *action,
+                                                 struct ib_uobject *uobj,
+                                                 struct ib_device *ib_dev,
+                                                 enum ib_flow_action_type type)
+{
+       atomic_set(&action->usecnt, 0);
+       action->device = ib_dev;
+       action->type = type;
+       action->uobject = uobj;
+       uobj->object = action;
+}
+
 #endif