mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
IB/core: Declare an object instead of declaring only type attributes
Switch all uverbs_type_attrs_xxxx with DECLARE_UVERBS_OBJECT macros. This will be later used in order to embed the object specific methods in the objects as well. Signed-off-by: Matan Barak <[email protected]> Reviewed-by: Yishai Hadas <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
This commit is contained in:
parent
fac9658cab
commit
5009010fbf
4 changed files with 107 additions and 99 deletions
|
|
@ -127,6 +127,22 @@ struct uverbs_root_spec {
|
|||
struct uverbs_object_spec_hash *object_buckets[0];
|
||||
};
|
||||
|
||||
/*
|
||||
* =======================================
|
||||
* Verbs definitions
|
||||
* =======================================
|
||||
*/
|
||||
|
||||
struct uverbs_object_def {
|
||||
const struct uverbs_obj_type *type_attrs;
|
||||
};
|
||||
|
||||
#define _UVERBS_OBJECT(_id, _type_attrs, ...) \
|
||||
((const struct uverbs_object_def) { \
|
||||
.type_attrs = _type_attrs})
|
||||
#define DECLARE_UVERBS_OBJECT(_name, _id, _type_attrs, ...) \
|
||||
const struct uverbs_object_def _name = \
|
||||
_UVERBS_OBJECT(_id, _type_attrs, ##__VA_ARGS__)
|
||||
/* =================================================
|
||||
* Parsing infrastructure
|
||||
* =================================================
|
||||
|
|
|
|||
|
|
@ -35,18 +35,18 @@
|
|||
|
||||
#include <rdma/uverbs_types.h>
|
||||
|
||||
extern const struct uverbs_obj_fd_type uverbs_type_attrs_comp_channel;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_cq;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_qp;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_rwq_ind_table;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_wq;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_srq;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_ah;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_flow;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_mr;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_mw;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_pd;
|
||||
extern const struct uverbs_obj_idr_type uverbs_type_attrs_xrcd;
|
||||
extern const struct uverbs_object_def uverbs_object_comp_channel;
|
||||
extern const struct uverbs_object_def uverbs_object_cq;
|
||||
extern const struct uverbs_object_def uverbs_object_qp;
|
||||
extern const struct uverbs_object_def uverbs_object_rwq_ind_table;
|
||||
extern const struct uverbs_object_def uverbs_object_wq;
|
||||
extern const struct uverbs_object_def uverbs_object_srq;
|
||||
extern const struct uverbs_object_def uverbs_object_ah;
|
||||
extern const struct uverbs_object_def uverbs_object_flow;
|
||||
extern const struct uverbs_object_def uverbs_object_mr;
|
||||
extern const struct uverbs_object_def uverbs_object_mw;
|
||||
extern const struct uverbs_object_def uverbs_object_pd;
|
||||
extern const struct uverbs_object_def uverbs_object_xrcd;
|
||||
|
||||
static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type,
|
||||
bool write,
|
||||
|
|
@ -56,22 +56,22 @@ static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type,
|
|||
return rdma_lookup_get_uobject(type, ucontext, id, write);
|
||||
}
|
||||
|
||||
#define uobj_get_type(_type) uverbs_type_attrs_##_type.type
|
||||
#define uobj_get_type(_object) uverbs_object_##_object.type_attrs
|
||||
|
||||
#define uobj_get_read(_type, _id, _ucontext) \
|
||||
__uobj_get(&(_type), false, _ucontext, _id)
|
||||
__uobj_get(_type, false, _ucontext, _id)
|
||||
|
||||
#define uobj_get_obj_read(_type, _id, _ucontext) \
|
||||
#define uobj_get_obj_read(_object, _id, _ucontext) \
|
||||
({ \
|
||||
struct ib_uobject *uobj = \
|
||||
__uobj_get(&uobj_get_type(_type), \
|
||||
struct ib_uobject *__uobj = \
|
||||
__uobj_get(uverbs_object_##_object.type_attrs, \
|
||||
false, _ucontext, _id); \
|
||||
\
|
||||
(struct ib_##_type *)(IS_ERR(uobj) ? NULL : uobj->object); \
|
||||
(struct ib_##_object *)(IS_ERR(__uobj) ? NULL : __uobj->object);\
|
||||
})
|
||||
|
||||
#define uobj_get_write(_type, _id, _ucontext) \
|
||||
__uobj_get(&(_type), true, _ucontext, _id)
|
||||
__uobj_get(_type, true, _ucontext, _id)
|
||||
|
||||
static inline void uobj_put_read(struct ib_uobject *uobj)
|
||||
{
|
||||
|
|
@ -108,7 +108,7 @@ static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type
|
|||
}
|
||||
|
||||
#define uobj_alloc(_type, ucontext) \
|
||||
__uobj_alloc(&(_type), ucontext)
|
||||
__uobj_alloc(_type, ucontext)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -151,22 +151,30 @@ extern const struct uverbs_obj_type_class uverbs_fd_class;
|
|||
|
||||
#define UVERBS_BUILD_BUG_ON(cond) (sizeof(char[1 - 2 * !!(cond)]) - \
|
||||
sizeof(char))
|
||||
#define UVERBS_TYPE_ALLOC_FD(_size, _order) \
|
||||
{ \
|
||||
.destroy_order = _order, \
|
||||
.type_class = &uverbs_fd_class, \
|
||||
.obj_size = (_size) + \
|
||||
UVERBS_BUILD_BUG_ON((_size) < \
|
||||
sizeof(struct ib_uobject_file)),\
|
||||
}
|
||||
#define UVERBS_TYPE_ALLOC_IDR_SZ(_size, _order) \
|
||||
{ \
|
||||
#define UVERBS_TYPE_ALLOC_FD(_order, _obj_size, _context_closed, _fops, _name, _flags)\
|
||||
((&((const struct uverbs_obj_fd_type) \
|
||||
{.type = { \
|
||||
.destroy_order = _order, \
|
||||
.type_class = &uverbs_fd_class, \
|
||||
.obj_size = (_obj_size) + \
|
||||
UVERBS_BUILD_BUG_ON((_obj_size) < sizeof(struct ib_uobject_file)), \
|
||||
}, \
|
||||
.context_closed = _context_closed, \
|
||||
.fops = _fops, \
|
||||
.name = _name, \
|
||||
.flags = _flags}))->type)
|
||||
#define UVERBS_TYPE_ALLOC_IDR_SZ(_size, _order, _destroy_object) \
|
||||
((&((const struct uverbs_obj_idr_type) \
|
||||
{.type = { \
|
||||
.destroy_order = _order, \
|
||||
.type_class = &uverbs_idr_class, \
|
||||
.obj_size = (_size) + \
|
||||
UVERBS_BUILD_BUG_ON((_size) < \
|
||||
sizeof(struct ib_uobject)), \
|
||||
}
|
||||
#define UVERBS_TYPE_ALLOC_IDR(_order) \
|
||||
UVERBS_TYPE_ALLOC_IDR_SZ(sizeof(struct ib_uobject), _order)
|
||||
UVERBS_BUILD_BUG_ON((_size) < \
|
||||
sizeof(struct ib_uobject)) \
|
||||
}, \
|
||||
.destroy_object = _destroy_object,}))->type)
|
||||
#define UVERBS_TYPE_ALLOC_IDR(_order, _destroy_object) \
|
||||
UVERBS_TYPE_ALLOC_IDR_SZ(sizeof(struct ib_uobject), _order, \
|
||||
_destroy_object)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue