From patchwork Wed Jun 7 12:22:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Barak X-Patchwork-Id: 9771435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CCF2460393 for ; Wed, 7 Jun 2017 12:23:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A223727F10 for ; Wed, 7 Jun 2017 12:23:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9716A28472; Wed, 7 Jun 2017 12:23:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C155283AD for ; Wed, 7 Jun 2017 12:23:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751517AbdFGMX0 (ORCPT ); Wed, 7 Jun 2017 08:23:26 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:42867 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751507AbdFGMXJ (ORCPT ); Wed, 7 Jun 2017 08:23:09 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from matanb@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 Jun 2017 15:23:03 +0300 Received: from gen-l-vrt-078.mtl.labs.mlnx. (gen-l-vrt-078.mtl.labs.mlnx [10.137.78.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v57CMxxR016058; Wed, 7 Jun 2017 15:23:02 +0300 From: Matan Barak To: Doug Ledford Cc: linux-rdma@vger.kernel.org, Jason Gunthorpe , Sean Hefty , Liran Liss , Yishai Hadas , Leon Romanovsky , Tal Alon , Christoph Lameter , Ira Weiny , Majd Dibbiny , Matan Barak Subject: [PATCH for-next 05/13] IB/core: Add DEVICE type and root types structure Date: Wed, 7 Jun 2017 15:22:44 +0300 Message-Id: <1496838172-39671-6-git-send-email-matanb@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1496838172-39671-1-git-send-email-matanb@mellanox.com> References: <1496838172-39671-1-git-send-email-matanb@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds the DEVICE type. This type supports creating the context that all objects are created from. Moreover, it supports executing actions which are related to the device itself, such as QUERY_DEVICE. The only related object to this type is a singleton (per file instance) context. All standard types are put in the root structure. This root will later on be used in drivers as their parsing tree root. Later on, when new features are added, these drivers could define their own root. Signed-off-by: Matan Barak Reviewed-by: Yishai Hadas --- drivers/infiniband/core/uverbs_std_types.c | 19 +++++++++++++++++++ include/rdma/uverbs_ioctl.h | 11 +++++++++++ include/rdma/uverbs_std_types.h | 19 +++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/drivers/infiniband/core/uverbs_std_types.c b/drivers/infiniband/core/uverbs_std_types.c index a204975..4c97be8 100644 --- a/drivers/infiniband/core/uverbs_std_types.c +++ b/drivers/infiniband/core/uverbs_std_types.c @@ -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); diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h index ee89cce..ca636a2 100644 --- a/include/rdma/uverbs_ioctl.h +++ b/include/rdma/uverbs_ioctl.h @@ -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 * ================================================= diff --git a/include/rdma/uverbs_std_types.h b/include/rdma/uverbs_std_types.h index 0810faf..3f582ad 100644 --- a/include/rdma/uverbs_std_types.h +++ b/include/rdma/uverbs_std_types.h @@ -35,6 +35,23 @@ #include +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,