IB/uverbs: Add UVERBS_ATTR_FLAGS_IN to the specs language
This clearly indicates that the input is a bitwise combination of values in an enum, and identifies which enum contains the definition of the bits. Special accessors are provided that handle the mandatory validation of the allowed bits and enforce the correct type for bitwise flags. If we had introduced this at the start then the kabi would have uniformly used u64 data to pass flags, however today there is a mixture of u64 and u32 flags. All places are converted to accept both sizes and the accessor fixes it. This allows all existing flags to grow to u64 in future without any hassle. Finally all flags are, by definition, optional. If flags are not passed the accessor does not fail, but provides a value of zero. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:
@@ -858,16 +858,21 @@ static int devx_umem_get(struct mlx5_ib_dev *dev, struct ib_ucontext *ucontext,
|
||||
{
|
||||
u64 addr;
|
||||
size_t size;
|
||||
int access;
|
||||
u32 access;
|
||||
int npages;
|
||||
int err;
|
||||
u32 page_mask;
|
||||
|
||||
if (uverbs_copy_from(&addr, attrs, MLX5_IB_ATTR_DEVX_UMEM_REG_ADDR) ||
|
||||
uverbs_copy_from(&size, attrs, MLX5_IB_ATTR_DEVX_UMEM_REG_LEN) ||
|
||||
uverbs_copy_from(&access, attrs, MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS))
|
||||
uverbs_copy_from(&size, attrs, MLX5_IB_ATTR_DEVX_UMEM_REG_LEN))
|
||||
return -EFAULT;
|
||||
|
||||
err = uverbs_get_flags32(&access, attrs,
|
||||
MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS,
|
||||
IB_ACCESS_SUPPORTED);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = ib_check_mr_access(access);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -1012,9 +1017,8 @@ DECLARE_UVERBS_NAMED_METHOD(
|
||||
UVERBS_ATTR_PTR_IN(MLX5_IB_ATTR_DEVX_UMEM_REG_LEN,
|
||||
UVERBS_ATTR_TYPE(u64),
|
||||
UA_MANDATORY),
|
||||
UVERBS_ATTR_PTR_IN(MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS,
|
||||
UVERBS_ATTR_TYPE(u32),
|
||||
UA_MANDATORY),
|
||||
UVERBS_ATTR_FLAGS_IN(MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS,
|
||||
enum ib_access_flags),
|
||||
UVERBS_ATTR_PTR_OUT(MLX5_IB_ATTR_DEVX_UMEM_REG_OUT_ID,
|
||||
UVERBS_ATTR_TYPE(u32),
|
||||
UA_MANDATORY));
|
||||
|
@@ -3859,12 +3859,11 @@ mlx5_ib_create_flow_action_esp(struct ib_device *device,
|
||||
u64 flags;
|
||||
int err = 0;
|
||||
|
||||
if (IS_UVERBS_COPY_ERR(uverbs_copy_from(&action_flags, attrs,
|
||||
MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS)))
|
||||
return ERR_PTR(-EFAULT);
|
||||
|
||||
if (action_flags >= (MLX5_FLOW_ACTION_ESP_CREATE_LAST_SUPPORTED << 1))
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
err = uverbs_get_flags64(
|
||||
&action_flags, attrs, MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS,
|
||||
((MLX5_FLOW_ACTION_ESP_CREATE_LAST_SUPPORTED << 1) - 1));
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
flags = mlx5_ib_flow_action_flags_to_accel_xfrm_flags(action_flags);
|
||||
|
||||
@@ -5531,9 +5530,8 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE(
|
||||
mlx5_ib_flow_action,
|
||||
UVERBS_OBJECT_FLOW_ACTION,
|
||||
UVERBS_METHOD_FLOW_ACTION_ESP_CREATE,
|
||||
UVERBS_ATTR_PTR_IN(MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS,
|
||||
UVERBS_ATTR_TYPE(u64),
|
||||
UA_MANDATORY));
|
||||
UVERBS_ATTR_FLAGS_IN(MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS,
|
||||
enum mlx5_ib_uapi_flow_action_flags));
|
||||
|
||||
#define NUM_TREES 5
|
||||
static int populate_specs_root(struct mlx5_ib_dev *dev)
|
||||
|
Reference in New Issue
Block a user