IB/core: Add DEVICE object and root tree structure
authorMatan Barak <matanb@mellanox.com>
Thu, 3 Aug 2017 13:06:59 +0000 (16:06 +0300)
committerDoug Ledford <dledford@redhat.com>
Thu, 31 Aug 2017 12:35:10 +0000 (08:35 -0400)
This adds the DEVICE object. This object supports creating the context
that all objects are created from. Moreover, it supports executing
methods which are related to the device itself, such as QUERY_DEVICE.
This is a singleton object (per file instance).

All standard objects are put in the root structure. This root will later
on be used in drivers as the source for their whole parsing tree.
Later on, when new features are added, these drivers could mix this root
with other customized objects.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/uverbs_std_types.c
include/rdma/uverbs_ioctl.h
include/rdma/uverbs_std_types.h

index b75c7da0d0a43d43c357dcc7396478abd836fde6..5f90978bda8dfdb703c04a5ce0c9b8c113f4d43a 100644 (file)
@@ -257,3 +257,20 @@ DECLARE_UVERBS_OBJECT(uverbs_object_xrcd, UVERBS_OBJECT_XRCD,
 DECLARE_UVERBS_OBJECT(uverbs_object_pd, UVERBS_OBJECT_PD,
                      /* 2 is used in order to free the PD after MRs */
                      &UVERBS_TYPE_ALLOC_IDR(2, uverbs_free_pd));
+
+DECLARE_UVERBS_OBJECT(uverbs_object_device, UVERBS_OBJECT_DEVICE, NULL);
+
+DECLARE_UVERBS_OBJECT_TREE(uverbs_default_objects,
+                          &uverbs_object_device,
+                          &uverbs_object_pd,
+                          &uverbs_object_mr,
+                          &uverbs_object_comp_channel,
+                          &uverbs_object_cq,
+                          &uverbs_object_qp,
+                          &uverbs_object_ah,
+                          &uverbs_object_mw,
+                          &uverbs_object_srq,
+                          &uverbs_object_flow,
+                          &uverbs_object_wq,
+                          &uverbs_object_rwq_ind_table,
+                          &uverbs_object_xrcd);
index 99130083615ecf5c4854eb88f5531f21e49dd8aa..2e8925434d742c654006e637a82ff02c61405e80 100644 (file)
@@ -133,16 +133,51 @@ struct uverbs_root_spec {
  * =======================================
  */
 
+struct uverbs_attr_def {
+       u16                           id;
+       struct uverbs_attr_spec       attr;
+};
+
+struct uverbs_method_def {
+       u16                                  id;
+       /* Combination of bits from enum UVERBS_ACTION_FLAG_XXXX */
+       u32                                  flags;
+       size_t                               num_attrs;
+       const struct uverbs_attr_def * const (*attrs)[];
+       int (*handler)(struct ib_device *ib_dev, struct ib_uverbs_file *ufile,
+                      struct uverbs_attr_bundle *ctx);
+};
+
 struct uverbs_object_def {
+       u16                                      id;
        const struct uverbs_obj_type            *type_attrs;
+       size_t                                   num_methods;
+       const struct uverbs_method_def * const (*methods)[];
+};
+
+struct uverbs_object_tree_def {
+       size_t                                   num_objects;
+       const struct uverbs_object_def * const (*objects)[];
 };
 
 #define _UVERBS_OBJECT(_id, _type_attrs, ...)                          \
        ((const struct uverbs_object_def) {                             \
+        .id = _id,                                                     \
         .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__)
+#define _UVERBS_TREE_OBJECTS_SZ(...)                                   \
+       (sizeof((const struct uverbs_object_def * const []){__VA_ARGS__}) / \
+        sizeof(const struct uverbs_object_def *))
+#define _UVERBS_OBJECT_TREE(...)                                       \
+       ((const struct uverbs_object_tree_def) {                        \
+        .num_objects = _UVERBS_TREE_OBJECTS_SZ(__VA_ARGS__),           \
+        .objects = &(const struct uverbs_object_def * const []){__VA_ARGS__} })
+#define DECLARE_UVERBS_OBJECT_TREE(_name, ...)                         \
+       const struct uverbs_object_tree_def _name =                     \
+               _UVERBS_OBJECT_TREE(__VA_ARGS__)
+
 /* =================================================
  *              Parsing infrastructure
  * =================================================
index eda271b4aa6c4c93d8ac7a61c31c5a41bbcb3667..bef74099b7c591de65172a426698552938218d39 100644 (file)
 
 #include <rdma/uverbs_types.h>
 
+enum uverbs_default_objects {
+       UVERBS_OBJECT_DEVICE, /* No instances of DEVICE are allowed */
+       UVERBS_OBJECT_PD,
+       UVERBS_OBJECT_COMP_CHANNEL,
+       UVERBS_OBJECT_CQ,
+       UVERBS_OBJECT_QP,
+       UVERBS_OBJECT_SRQ,
+       UVERBS_OBJECT_AH,
+       UVERBS_OBJECT_MR,
+       UVERBS_OBJECT_MW,
+       UVERBS_OBJECT_FLOW,
+       UVERBS_OBJECT_XRCD,
+       UVERBS_OBJECT_RWQ_IND_TBL,
+       UVERBS_OBJECT_WQ,
+       UVERBS_OBJECT_LAST,
+};
+
 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;
@@ -47,6 +64,7 @@ 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;
+extern const struct uverbs_object_def uverbs_object_device;
 
 static inline struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type,
                                            bool write,