#ifndef _UVERBS_IOCTL_
#define _UVERBS_IOCTL_
#include <rdma/uverbs_types.h>
#include <linux/uaccess.h>
#include <rdma/rdma_user_ioctl.h>
#include <rdma/ib_user_ioctl_verbs.h>
#include <rdma/ib_user_ioctl_cmds.h>
enum uverbs_attr_type { … };
enum uverbs_obj_access { … };
struct uverbs_attr_spec { … };
enum uapi_radix_data { … };
static inline __attribute_const__ u32 uapi_key_obj(u32 id)
{ … }
static inline __attribute_const__ bool uapi_key_is_object(u32 key)
{ … }
static inline __attribute_const__ u32 uapi_key_ioctl_method(u32 id)
{ … }
static inline __attribute_const__ u32 uapi_key_write_method(u32 id)
{ … }
static inline __attribute_const__ u32 uapi_key_write_ex_method(u32 id)
{ … }
static inline __attribute_const__ u32
uapi_key_attr_to_ioctl_method(u32 attr_key)
{ … }
static inline __attribute_const__ bool uapi_key_is_ioctl_method(u32 key)
{ … }
static inline __attribute_const__ bool uapi_key_is_write_method(u32 key)
{ … }
static inline __attribute_const__ bool uapi_key_is_write_ex_method(u32 key)
{ … }
static inline __attribute_const__ u32 uapi_key_attrs_start(u32 ioctl_method_key)
{ … }
static inline __attribute_const__ u32 uapi_key_attr(u32 id)
{ … }
static inline __attribute_const__ bool uapi_key_is_attr(u32 key)
{ … }
static inline __attribute_const__ u32 uapi_bkey_attr(u32 attr_key)
{ … }
static inline __attribute_const__ u32 uapi_bkey_to_key_attr(u32 attr_bkey)
{ … }
struct uverbs_attr_def { … };
struct uverbs_method_def { … };
struct uverbs_object_def { … };
enum uapi_definition_kind { … };
enum uapi_definition_scope { … };
struct uapi_definition { … };
#define DECLARE_UVERBS_OBJECT(_object_id, ...) …
#define DECLARE_UVERBS_WRITE(_command_num, _func, _cmd_desc, ...) …
#define DECLARE_UVERBS_WRITE_EX(_command_num, _func, _cmd_desc, ...) …
#define UAPI_DEF_OBJ_NEEDS_FN(ibdev_fn) …
#define UAPI_DEF_METHOD_NEEDS_FN(ibdev_fn) …
#define UAPI_DEF_IS_OBJ_SUPPORTED(_func) …
#define UAPI_DEF_CHAIN(_def_var) …
#define UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, _object_ptr, ...) …
#define UAPI_DEF_CHAIN_OBJ_TREE_NAMED(_object_enum, ...) …
#define UVERBS_ATTR_SIZE(_min_len, _len) …
#define UVERBS_ATTR_NO_DATA() …
#define UVERBS_ATTR_TYPE(_type) …
#define UVERBS_ATTR_STRUCT(_type, _last) …
#define UVERBS_ATTR_MIN_SIZE(_min_len) …
#define UA_ALLOC_AND_COPY …
#define UA_MANDATORY …
#define UA_OPTIONAL …
#define UVERBS_ATTR_IDRS_ARR(_attr_id, _idr_type, _access, _min_len, _max_len, \
...) …
#define UVERBS_IDR_ANY_OBJECT …
#define UVERBS_ATTR_IDR(_attr_id, _idr_type, _access, ...) …
#define UVERBS_ATTR_FD(_attr_id, _fd_type, _access, ...) …
#define UVERBS_ATTR_RAW_FD(_attr_id, ...) …
#define UVERBS_ATTR_PTR_IN(_attr_id, _type, ...) …
#define UVERBS_ATTR_PTR_OUT(_attr_id, _type, ...) …
#define UVERBS_ATTR_ENUM_IN(_attr_id, _enum_arr, ...) …
#define UVERBS_ATTR_CONST_IN(_attr_id, _enum_type, ...) …
#define UVERBS_ATTR_FLAGS_IN(_attr_id, _enum_type, ...) …
#define UVERBS_ATTR_UHW() …
struct uverbs_ptr_attr { … };
struct uverbs_obj_attr { … };
struct uverbs_objs_arr_attr { … };
struct uverbs_attr { … };
struct uverbs_attr_bundle { … };
static inline bool uverbs_attr_is_valid(const struct uverbs_attr_bundle *attrs_bundle,
unsigned int idx)
{ … }
static inline struct uverbs_attr_bundle *
rdma_udata_to_uverbs_attr_bundle(struct ib_udata *udata)
{ … }
#define rdma_udata_to_drv_context(udata, drv_dev_struct, member) …
#define IS_UVERBS_COPY_ERR(_ret) …
static inline const struct uverbs_attr *uverbs_attr_get(const struct uverbs_attr_bundle *attrs_bundle,
u16 idx)
{ … }
static inline int uverbs_attr_get_enum_id(const struct uverbs_attr_bundle *attrs_bundle,
u16 idx)
{ … }
static inline void *uverbs_attr_get_obj(const struct uverbs_attr_bundle *attrs_bundle,
u16 idx)
{ … }
static inline struct ib_uobject *uverbs_attr_get_uobject(const struct uverbs_attr_bundle *attrs_bundle,
u16 idx)
{ … }
static inline int
uverbs_attr_get_len(const struct uverbs_attr_bundle *attrs_bundle, u16 idx)
{ … }
void uverbs_finalize_uobj_create(const struct uverbs_attr_bundle *attrs_bundle,
u16 idx);
static inline int
uverbs_attr_ptr_get_array_size(struct uverbs_attr_bundle *attrs, u16 idx,
size_t elem_size)
{ … }
static inline int uverbs_attr_get_uobjs_arr(
const struct uverbs_attr_bundle *attrs_bundle, u16 attr_idx,
struct ib_uobject ***arr)
{ … }
static inline bool uverbs_attr_ptr_is_inline(const struct uverbs_attr *attr)
{ … }
static inline void *uverbs_attr_get_alloced_ptr(
const struct uverbs_attr_bundle *attrs_bundle, u16 idx)
{ … }
static inline int _uverbs_copy_from(void *to,
const struct uverbs_attr_bundle *attrs_bundle,
size_t idx,
size_t size)
{ … }
static inline int _uverbs_copy_from_or_zero(void *to,
const struct uverbs_attr_bundle *attrs_bundle,
size_t idx,
size_t size)
{ … }
#define uverbs_copy_from(to, attrs_bundle, idx) …
#define uverbs_copy_from_or_zero(to, attrs_bundle, idx) …
static inline struct ib_ucontext *
ib_uverbs_get_ucontext(const struct uverbs_attr_bundle *attrs)
{ … }
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
int uverbs_get_flags64(u64 *to, const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, u64 allowed_bits);
int uverbs_get_flags32(u32 *to, const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, u64 allowed_bits);
int uverbs_copy_to(const struct uverbs_attr_bundle *attrs_bundle, size_t idx,
const void *from, size_t size);
__malloc void *_uverbs_alloc(struct uverbs_attr_bundle *bundle, size_t size,
gfp_t flags);
static inline __malloc void *uverbs_alloc(struct uverbs_attr_bundle *bundle,
size_t size)
{ … }
static inline __malloc void *uverbs_zalloc(struct uverbs_attr_bundle *bundle,
size_t size)
{ … }
static inline __malloc void *uverbs_kcalloc(struct uverbs_attr_bundle *bundle,
size_t n, size_t size)
{ … }
int _uverbs_get_const_signed(s64 *to,
const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, s64 lower_bound, u64 upper_bound,
s64 *def_val);
int _uverbs_get_const_unsigned(u64 *to,
const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, u64 upper_bound, u64 *def_val);
int uverbs_copy_to_struct_or_zero(const struct uverbs_attr_bundle *bundle,
size_t idx, const void *from, size_t size);
#else
static inline int
uverbs_get_flags64(u64 *to, const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, u64 allowed_bits)
{
return -EINVAL;
}
static inline int
uverbs_get_flags32(u32 *to, const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, u64 allowed_bits)
{
return -EINVAL;
}
static inline int uverbs_copy_to(const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, const void *from, size_t size)
{
return -EINVAL;
}
static inline __malloc void *uverbs_alloc(struct uverbs_attr_bundle *bundle,
size_t size)
{
return ERR_PTR(-EINVAL);
}
static inline __malloc void *uverbs_zalloc(struct uverbs_attr_bundle *bundle,
size_t size)
{
return ERR_PTR(-EINVAL);
}
static inline int
_uverbs_get_const(s64 *to, const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, s64 lower_bound, u64 upper_bound,
s64 *def_val)
{
return -EINVAL;
}
static inline int
uverbs_copy_to_struct_or_zero(const struct uverbs_attr_bundle *bundle,
size_t idx, const void *from, size_t size)
{
return -EINVAL;
}
static inline int
_uverbs_get_const_signed(s64 *to,
const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, s64 lower_bound, u64 upper_bound,
s64 *def_val)
{
return -EINVAL;
}
static inline int
_uverbs_get_const_unsigned(u64 *to,
const struct uverbs_attr_bundle *attrs_bundle,
size_t idx, u64 upper_bound, u64 *def_val)
{
return -EINVAL;
}
#endif
#define uverbs_get_const_signed(_to, _attrs_bundle, _idx) …
#define uverbs_get_const_unsigned(_to, _attrs_bundle, _idx) …
#define uverbs_get_const_default_signed(_to, _attrs_bundle, _idx, _default) …
#define uverbs_get_const_default_unsigned(_to, _attrs_bundle, _idx, _default) …
#define uverbs_get_const(_to, _attrs_bundle, _idx) … \
#define uverbs_get_const_default(_to, _attrs_bundle, _idx, _default) …
static inline int
uverbs_get_raw_fd(int *to, const struct uverbs_attr_bundle *attrs_bundle,
size_t idx)
{ … }
#endif