From patchwork Thu May 19 11:51:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9127311 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F240BF29F for ; Thu, 19 May 2016 11:53:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DC6420211 for ; Thu, 19 May 2016 11:53:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09CD62021B for ; Thu, 19 May 2016 11:53:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753942AbcESLxw (ORCPT ); Thu, 19 May 2016 07:53:52 -0400 Received: from [193.47.165.129] ([193.47.165.129]:46138 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754581AbcESLxw (ORCPT ); Thu, 19 May 2016 07:53:52 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 May 2016 14:52:50 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u4JBqo43014655; Thu, 19 May 2016 14:52:50 +0300 Received: from vnc17.mtl.labs.mlnx (localhost.localdomain [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id u4JBqoen010429; Thu, 19 May 2016 14:52:50 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id u4JBqorq010427; Thu, 19 May 2016 14:52:50 +0300 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, matanb@mellanox.com, majd@mellanox.com, talal@mellanox.com, jgunthorpe@obsidianresearch.com Subject: [PATCH V2 libibverbs 6/7] Add a verb that queries real time values from the HCA Date: Thu, 19 May 2016 14:51:41 +0300 Message-Id: <1463658702-9975-7-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1463658702-9975-1-git-send-email-yishaih@mellanox.com> References: <1463658702-9975-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matan Barak Add ibv_query_rt_values_ex, an extension verb to query certain real time values of a device. Currently, only IBV_VALUES_MASK_RAW_CLOCK is supported, but this verb could support other flags like IBV_VALUES_MASK_TEMP_SENSOR, IBV_VALUES_MASK_CORE_FREQ, etc. This extension verb only calls the provider. The provider has to query this value somehow and mark the queried values in comp_mask. Signed-off-by: Matan Barak Reviewed-by: Yishai Hadas --- Makefile.am | 3 ++- include/infiniband/verbs.h | 33 +++++++++++++++++++++++++++++ man/ibv_query_rt_values_ex.3 | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 man/ibv_query_rt_values_ex.3 diff --git a/Makefile.am b/Makefile.am index a1c2122..16f838d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,7 +65,8 @@ man_MANS = man/ibv_asyncwatch.1 man/ibv_devices.1 man/ibv_devinfo.1 \ man/ibv_create_qp_ex.3 man/ibv_create_srq_ex.3 man/ibv_open_xrcd.3 \ man/ibv_get_srq_num.3 man/ibv_open_qp.3 man/ibv_query_device_ex.3 \ man/ibv_alloc_mw.3 man/ibv_bind_mw.3 man/ibv_inc_rkey.3 \ - man/ibv_rereg_mr.3 man/ibv_create_cq_ex.3 + man/ibv_rereg_mr.3 man/ibv_create_cq_ex.3 \ + man/ibv_query_rt_values_ex.3 DEBIAN = debian/changelog debian/compat debian/control debian/copyright \ debian/ibverbs-utils.install debian/libibverbs1.install \ diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index c96eb26..337dbda 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -1232,6 +1232,16 @@ struct ibv_cq_init_attr_ex { uint32_t flags; }; +enum ibv_values_mask { + IBV_VALUES_MASK_RAW_CLOCK = 1 << 0, + IBV_VALUES_MASK_RESERVED = 1 << 1 +}; + +struct ibv_values_ex { + uint32_t comp_mask; + struct timespec raw_clock; +}; + enum verbs_context_mask { VERBS_CONTEXT_XRCD = 1 << 0, VERBS_CONTEXT_SRQ = 1 << 1, @@ -1243,6 +1253,8 @@ enum verbs_context_mask { struct verbs_context { /* "grows up" - new fields go here */ + int (*query_rt_values)(struct ibv_context *context, + struct ibv_values_ex *values); struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context, struct ibv_cq_init_attr_ex *init_attr); struct verbs_ex_private *priv; @@ -1762,6 +1774,27 @@ ibv_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_ini } /** + * ibv_query_rt_values_ex - Get current real time @values of a device. + * @values - in/out - defines the attributes we need to query/queried. + * (Or's bits of enum ibv_values_mask on values->comp_mask field) + */ +static inline int +ibv_query_rt_values_ex(struct ibv_context *context, + struct ibv_values_ex *values) +{ + struct verbs_context *vctx; + + vctx = verbs_get_ctx_op(context, query_rt_values); + if (!vctx) + return ENOSYS; + + if (values->comp_mask & ~(IBV_VALUES_MASK_RESERVED - 1)) + return EINVAL; + + return vctx->query_rt_values(context, values); +} + +/** * ibv_query_device_ex - Get extended device properties */ static inline int diff --git a/man/ibv_query_rt_values_ex.3 b/man/ibv_query_rt_values_ex.3 new file mode 100644 index 0000000..fcc460c --- /dev/null +++ b/man/ibv_query_rt_values_ex.3 @@ -0,0 +1,50 @@ +.\" -*- nroff -*- +.\" +.TH IBV_QUERY_RT_VALUES_EX 3 2016-2-20 libibverbs "Libibverbs Programmer's Manual" +.SH "NAME" +ibv_query_rt_values_ex \- query an RDMA device for some real time values +.SH "SYNOPSIS" +.nf +.B #include +.sp +.BI "int ibv_query_rt_values_ex(struct ibv_context " "*context", +.BI " struct ibv_values_ex " "*values" ); +.fi +.SH "DESCRIPTION" +.B ibv_query_rt_values_ex() +returns certain real time values of a device +.I context\fR. +The argument +.I attr +is a pointer to an ibv_device_attr_ex struct, as defined in . +.PP +.nf +struct ibv_values_ex { +.in +8 +uint32_t comp_mask; /* Compatibility mask that defines the query/queried fields [in/out] */ +struct timespec raw_clock; /* HW raw clock */ +.in -8 +}; + +enum ibv_values_mask { + IBV_VALUES_MASK_RAW_CLOCK = 1 << 0, /* HW raw clock */ +}; + +.fi +.SH "RETURN VALUE" +.B ibv_query_rt_values_ex() +returns 0 on success, or the value of errno on failure (which indicates the failure reason). +.SH "NOTES" +This extension verb only calls the provider, the provider has to query this value somehow and mark +the queried values in the comp_mask field. +.SH "SEE ALSO" +.BR ibv_query_device (3), +.BR ibv_open_device (3), +.BR ibv_query_port (3), +.BR ibv_query_pkey (3), +.BR ibv_query_gid (3) +.SH "AUTHORS" +.TP +Matan Barak +.TP +Yishai Hadas