]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/rdma/uverbs_types.h
IB/core: Add idr based standard types
[karo-tx-linux.git] / include / rdma / uverbs_types.h
index 0777e405f22a08cfc9e628635ebf2bb4b1568e28..66368b5a30066515626d003c7a8e8f57fbd92f5e 100644 (file)
@@ -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