From patchwork Wed Feb 24 09:41:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 8403361 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CD9CA9F2F0 for ; Wed, 24 Feb 2016 09:43:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF9AF202EC for ; Wed, 24 Feb 2016 09:43:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7B91202EB for ; Wed, 24 Feb 2016 09:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751069AbcBXJnY (ORCPT ); Wed, 24 Feb 2016 04:43:24 -0500 Received: from [193.47.165.129] ([193.47.165.129]:33168 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750871AbcBXJnX (ORCPT ); Wed, 24 Feb 2016 04:43:23 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 24 Feb 2016 11:42:46 +0200 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 u1O9gjXW026429; Wed, 24 Feb 2016 11:42:45 +0200 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 u1O9gjJp031495; Wed, 24 Feb 2016 11:42:45 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id u1O9gjpM031494; Wed, 24 Feb 2016 11:42:45 +0200 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, ogerlitz@mellanox.com Subject: [PATCH V1 libibverbs 2/8] Add timestamp_mask and hca_core_clock to ibv_query_device_ex Date: Wed, 24 Feb 2016 11:41:58 +0200 Message-Id: <1456306924-31298-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1456306924-31298-1-git-send-email-yishaih@mellanox.com> References: <1456306924-31298-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=-6.9 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 The fields timestamp_mask and hca_core_clock were added to the extended version of ibv_query_device verb. timestamp_mask represents the supported mask of the timestamp. Users could infer the accuracy of the reported possible timestamp. hca_core_clock represents the frequency of the HCA (in kHZ). Since timestamp is given in hardware cycles, knowing the frequency is mandatory in order to convert this number into seconds. Signed-off-by: Matan Barak Reviewed-by: Yishai Hadas --- examples/devinfo.c | 10 ++++++++++ include/infiniband/kern-abi.h | 2 ++ include/infiniband/verbs.h | 2 ++ src/cmd.c | 21 +++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/examples/devinfo.c b/examples/devinfo.c index a8de982..0af8c3b 100644 --- a/examples/devinfo.c +++ b/examples/devinfo.c @@ -339,6 +339,16 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) printf("\tlocal_ca_ack_delay:\t\t%d\n", device_attr.orig_attr.local_ca_ack_delay); print_odp_caps(&device_attr.odp_caps); + if (device_attr.completion_timestamp_mask) + printf("\tcompletion timestamp_mask:\t\t\t0x%016lx\n", + device_attr.completion_timestamp_mask); + else + printf("\tcompletion_timestamp_mask not supported\n"); + + if (device_attr.hca_core_clock) + printf("\thca_core_clock:\t\t\t%lukHZ\n", device_attr.hca_core_clock); + else + printf("\tcore clock not supported\n"); } for (port = 1; port <= device_attr.orig_attr.phys_port_cnt; ++port) { diff --git a/include/infiniband/kern-abi.h b/include/infiniband/kern-abi.h index 31da4be..b196a04 100644 --- a/include/infiniband/kern-abi.h +++ b/include/infiniband/kern-abi.h @@ -269,6 +269,8 @@ struct ibv_query_device_resp_ex { __u32 comp_mask; __u32 response_length; struct ibv_odp_caps_resp odp_caps; + __u64 timestamp_mask; + __u64 hca_core_clock; }; struct ibv_query_port { diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 99d6265..3ddf07c 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -207,6 +207,8 @@ struct ibv_device_attr_ex { struct ibv_device_attr orig_attr; uint32_t comp_mask; struct ibv_odp_caps odp_caps; + uint64_t completion_timestamp_mask; + uint64_t hca_core_clock; }; enum ibv_mtu { diff --git a/src/cmd.c b/src/cmd.c index b8c51ce..e22a24b 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -189,6 +189,27 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, } } + if (attr_size >= offsetof(struct ibv_device_attr_ex, + completion_timestamp_mask) + + sizeof(attr->completion_timestamp_mask)) { + if (resp->response_length >= + offsetof(struct ibv_query_device_resp_ex, timestamp_mask) + + sizeof(resp->timestamp_mask)) + attr->completion_timestamp_mask = resp->timestamp_mask; + else + attr->completion_timestamp_mask = 0; + } + + if (attr_size >= offsetof(struct ibv_device_attr_ex, hca_core_clock) + + sizeof(attr->hca_core_clock)) { + if (resp->response_length >= + offsetof(struct ibv_query_device_resp_ex, hca_core_clock) + + sizeof(resp->hca_core_clock)) + attr->hca_core_clock = resp->hca_core_clock; + else + attr->hca_core_clock = 0; + } + return 0; }