aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma/uverbs_types.h
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2017-04-04 13:31:43 +0300
committerDoug Ledford <dledford@redhat.com>2017-04-05 13:28:04 -0400
commit6be60aed126ccd4dfb4a60d1dc2ecec0bca21b2e (patch)
tree31764e2f00ed54dc264a7e71d1dd16830152b987 /include/rdma/uverbs_types.h
parentIB/core: Add support for idr types (diff)
downloadlinux-dev-6be60aed126ccd4dfb4a60d1dc2ecec0bca21b2e.tar.xz
linux-dev-6be60aed126ccd4dfb4a60d1dc2ecec0bca21b2e.zip
IB/core: Add idr based standard types
This patch adds the standard idr based types. These types are used in downstream patches in order to initialize, destroy and lookup IB standard objects which are based on idr objects. An idr object requires filling out several parameters. Its op pointer should point to uverbs_idr_ops and its size should be at least the size of ib_uobject. We add a macro to make the type declaration easier. Signed-off-by: Matan Barak <matanb@mellanox.com> Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Reviewed-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to '')
-rw-r--r--include/rdma/uverbs_types.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/rdma/uverbs_types.h b/include/rdma/uverbs_types.h
index 0777e405f22a..66368b5a3006 100644
--- a/include/rdma/uverbs_types.h
+++ b/include/rdma/uverbs_types.h
@@ -129,4 +129,18 @@ void rdma_alloc_abort_uobject(struct ib_uobject *uobj);
int __must_check rdma_remove_commit_uobject(struct ib_uobject *uobj);
int rdma_alloc_commit_uobject(struct ib_uobject *uobj);
+extern const struct uverbs_obj_type_class uverbs_idr_class;
+
+#define UVERBS_BUILD_BUG_ON(cond) (sizeof(char[1 - 2 * !!(cond)]) - \
+ sizeof(char))
+#define UVERBS_TYPE_ALLOC_IDR_SZ(_size, _order) \
+ { \
+ .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)
#endif