@@ -256,3 +256,22 @@ static int uverbs_hot_unplug_completion_event_file(struct ib_uobject_file *uobj_
/* 2 is used in order to free the PD after MRs */
&UVERBS_TYPE_ALLOC_IDR(2, uverbs_free_pd));
+DECLARE_UVERBS_TYPE(uverbs_type_device, NULL);
+
+DECLARE_UVERBS_TYPES(uverbs_common_types,
+ ADD_UVERBS_TYPE(UVERBS_TYPE_DEVICE, uverbs_type_device),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_PD, uverbs_type_pd),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_MR, uverbs_type_mr),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_COMP_CHANNEL, uverbs_type_comp_channel),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_CQ, uverbs_type_cq),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_QP, uverbs_type_qp),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_AH, uverbs_type_ah),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_MW, uverbs_type_mw),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_SRQ, uverbs_type_srq),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_FLOW, uverbs_type_flow),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_WQ, uverbs_type_wq),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_RWQ_IND_TBL,
+ uverbs_type_rwq_ind_table),
+ ADD_UVERBS_TYPE(UVERBS_TYPE_XRCD, uverbs_type_xrcd),
+);
+EXPORT_SYMBOL(uverbs_common_types);
@@ -135,6 +135,17 @@ struct uverbs_spec_root {
const struct uverbs_type name = { \
.type_attrs = _type_attrs, \
}
+#define _UVERBS_TYPE_SZ(...) \
+ (sizeof((const struct uverbs_type *[]){__VA_ARGS__}) / \
+ sizeof(const struct uverbs_type *))
+#define ADD_UVERBS_TYPE(type_idx, type_ptr) \
+ [type_idx] = ((const struct uverbs_type * const)&(type_ptr))
+#define UVERBS_TYPES(...) ((const struct uverbs_type_group) \
+ {.num_types = _UVERBS_TYPE_SZ(__VA_ARGS__), \
+ .types = (const struct uverbs_type *[]){__VA_ARGS__} })
+#define DECLARE_UVERBS_TYPES(name, ...) \
+ const struct uverbs_type_group name = UVERBS_TYPES(__VA_ARGS__)
+
/* =================================================
* Parsing infrastructure
* =================================================
@@ -35,6 +35,23 @@
#include <rdma/uverbs_types.h>
+enum uverbs_common_types {
+ UVERBS_TYPE_DEVICE, /* No instances of DEVICE are allowed */
+ UVERBS_TYPE_PD,
+ UVERBS_TYPE_COMP_CHANNEL,
+ UVERBS_TYPE_CQ,
+ UVERBS_TYPE_QP,
+ UVERBS_TYPE_SRQ,
+ UVERBS_TYPE_AH,
+ UVERBS_TYPE_MR,
+ UVERBS_TYPE_MW,
+ UVERBS_TYPE_FLOW,
+ UVERBS_TYPE_XRCD,
+ UVERBS_TYPE_RWQ_IND_TBL,
+ UVERBS_TYPE_WQ,
+ UVERBS_TYPE_LAST,
+};
+
extern const struct uverbs_type uverbs_type_comp_channel;
extern const struct uverbs_type uverbs_type_cq;
extern const struct uverbs_type uverbs_type_qp;
@@ -47,6 +64,8 @@
extern const struct uverbs_type uverbs_type_mw;
extern const struct uverbs_type uverbs_type_pd;
extern const struct uverbs_type uverbs_type_xrcd;
+extern const struct uverbs_type uverbs_type_device;
+extern const struct uverbs_type_group uverbs_common_types;
static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type,
bool write,