From patchwork Sun Sep 6 06:35:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haggai Eran X-Patchwork-Id: 7130861 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 783E59F380 for ; Sun, 6 Sep 2015 06:35:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 893DC205EF for ; Sun, 6 Sep 2015 06:35:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D5AB205BD for ; Sun, 6 Sep 2015 06:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515AbbIFGfz (ORCPT ); Sun, 6 Sep 2015 02:35:55 -0400 Received: from [193.47.165.129] ([193.47.165.129]:40079 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750867AbbIFGfy (ORCPT ); Sun, 6 Sep 2015 02:35:54 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from haggaie@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 Sep 2015 09:35:31 +0300 Received: from arch003.mtl.labs.mlnx (arch003.mtl.labs.mlnx [10.137.35.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t866ZOj8025231; Sun, 6 Sep 2015 09:35:24 +0300 From: Haggai Eran To: Eli Cohen Cc: linux-rdma@vger.kernel.org, Haggai Eran Subject: [PATCH] libmlx5: Implement query device extended verb Date: Sun, 6 Sep 2015 09:35:31 +0300 Message-Id: <1441521331-18202-1-git-send-email-haggaie@mellanox.com> X-Mailer: git-send-email 1.7.11.2 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.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 Simply pass the extended query device verb to back to libiverbs, in order to support it. Also share some code with the legacy query device verb. Signed-off-by: Haggai Eran --- src/mlx5.c | 1 + src/mlx5.h | 3 +++ src/verbs.c | 41 +++++++++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/mlx5.c b/src/mlx5.c index d02328881992..f058ac498819 100644 --- a/src/mlx5.c +++ b/src/mlx5.c @@ -583,6 +583,7 @@ static int mlx5_init_context(struct verbs_device *vdev, verbs_set_ctx_op(v_ctx, close_xrcd, mlx5_close_xrcd); verbs_set_ctx_op(v_ctx, create_srq_ex, mlx5_create_srq_ex); verbs_set_ctx_op(v_ctx, get_srq_num, mlx5_get_srq_num); + verbs_set_ctx_op(v_ctx, query_device_ex, mlx5_query_device_ex); return 0; diff --git a/src/mlx5.h b/src/mlx5.h index 6ad79fe324d3..364afe12de68 100644 --- a/src/mlx5.h +++ b/src/mlx5.h @@ -537,6 +537,9 @@ void mlx5_free_db(struct mlx5_context *context, uint32_t *db); int mlx5_query_device(struct ibv_context *context, struct ibv_device_attr *attr); +int mlx5_query_device_ex(struct ibv_context *context, + const struct ibv_query_device_ex_input *input, + struct ibv_device_attr_ex *attr, size_t attr_size); struct ibv_qp *mlx5_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *attr); int mlx5_query_port(struct ibv_context *context, uint8_t port, diff --git a/src/verbs.c b/src/verbs.c index 8ddf4e631c9f..f269c37ea266 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -53,23 +53,52 @@ int mlx5_single_threaded = 0; +static int raw_fw_ver_to_string(uint64_t raw_fw_ver, char *buf, size_t len) +{ + unsigned major, minor, sub_minor; + + major = (raw_fw_ver >> 32) & 0xffff; + minor = (raw_fw_ver >> 16) & 0xffff; + sub_minor = raw_fw_ver & 0xffff; + + return snprintf(buf, len, "%d.%d.%04d", major, minor, sub_minor); +} + int mlx5_query_device(struct ibv_context *context, struct ibv_device_attr *attr) { struct ibv_query_device cmd; uint64_t raw_fw_ver; - unsigned major, minor, sub_minor; int ret; ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd); if (ret) return ret; - major = (raw_fw_ver >> 32) & 0xffff; - minor = (raw_fw_ver >> 16) & 0xffff; - sub_minor = raw_fw_ver & 0xffff; + raw_fw_ver_to_string(raw_fw_ver, attr->fw_ver, sizeof attr->fw_ver); + + return 0; +} + +int mlx5_query_device_ex(struct ibv_context *context, + const struct ibv_query_device_ex_input *input, + struct ibv_device_attr_ex *attr, size_t attr_size) +{ + struct ibv_query_device_ex cmd; + struct ibv_query_device_resp_ex resp; + uint64_t raw_fw_ver; + int ret; + + cmd.comp_mask = 0; + ret = ibv_cmd_query_device_ex(context, input, attr, attr_size, + &raw_fw_ver, &cmd, + sizeof(struct ibv_query_device_ex), + sizeof(cmd), &resp, + sizeof(struct ibv_query_device_resp_ex), + sizeof(resp)); + if (ret) + return ret; - snprintf(attr->fw_ver, sizeof attr->fw_ver, - "%d.%d.%04d", major, minor, sub_minor); + raw_fw_ver_to_string(raw_fw_ver, attr->orig_attr.fw_ver, sizeof attr->orig_attr.fw_ver); return 0; }