From patchwork Wed Jan 22 11:49:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 3522831 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6AB1EC02DC for ; Wed, 22 Jan 2014 12:16:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5911120155 for ; Wed, 22 Jan 2014 12:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23AF920154 for ; Wed, 22 Jan 2014 12:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755305AbaAVMQV (ORCPT ); Wed, 22 Jan 2014 07:16:21 -0500 Received: from cmexedge2.ext.emulex.com ([138.239.224.100]:33808 "EHLO CMEXEDGE2.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755304AbaAVMQU (ORCPT ); Wed, 22 Jan 2014 07:16:20 -0500 Received: from CMEXHTCAS2.ad.emulex.com (138.239.115.218) by CMEXEDGE2.ext.emulex.com (138.239.224.100) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 22 Jan 2014 04:16:56 -0800 Received: from neo01.lab.bg.emulex.com (10.192.204.8) by smtp.emulex.com (138.239.115.208) with Microsoft SMTP Server id 14.3.174.1; Wed, 22 Jan 2014 04:16:16 -0800 From: To: CC: , Devesh Sharma Subject: [PATCH] RDMA/libibverbs: Display proper speed for RoCE devices Date: Wed, 22 Jan 2014 17:19:03 +0530 X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 Message-ID: <4b5b3757-bfbe-49a6-aa12-3267a11187d0@CMEXHTCAS2.ad.emulex.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=-7.5 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: Devesh Sharma currently ibv_devinfo -v display active_width. However, on RoCE link_width is not defined. Therefore adding checks on link_layer while displaying active_link_speed and active_link_width. Also adding check on link_layer while displaying LID, SM_LID and LMC. Signed-off-by: Devesh Sharma --- examples/devinfo.c | 36 +++++++++++++++++++++++++++++------- 1 files changed, 29 insertions(+), 7 deletions(-) diff --git a/examples/devinfo.c b/examples/devinfo.c index ff078e4..85c8c0a 100644 --- a/examples/devinfo.c +++ b/examples/devinfo.c @@ -149,6 +149,17 @@ static const char *speed_str(uint8_t speed) } } +static const char *roce_speed_str (uint8_t speed) +{ + switch (speed) { + case 1: return "2.5 Gbps"; + case 2: return "5.0 Gbps"; + case 4: return "10.0 Gbps"; + case 8: return "40.0 Gbps"; + default: return "invalid speed"; + } +} + static const char *vl_str(uint8_t vl_num) { switch (vl_num) { @@ -305,9 +316,13 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) mtu_str(port_attr.max_mtu), port_attr.max_mtu); printf("\t\t\tactive_mtu:\t\t%s (%d)\n", mtu_str(port_attr.active_mtu), port_attr.active_mtu); - printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid); - printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid); - printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc); + + if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { + printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid); + printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid); + printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc); + } + printf("\t\t\tlink_layer:\t\t%s\n", link_layer_str(port_attr.link_layer)); @@ -323,10 +338,17 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) printf("\t\t\tgid_tbl_len:\t\t%d\n", port_attr.gid_tbl_len); printf("\t\t\tsubnet_timeout:\t\t%d\n", port_attr.subnet_timeout); printf("\t\t\tinit_type_reply:\t%d\n", port_attr.init_type_reply); - printf("\t\t\tactive_width:\t\t%sX (%d)\n", - width_str(port_attr.active_width), port_attr.active_width); - printf("\t\t\tactive_speed:\t\t%s (%d)\n", - speed_str(port_attr.active_speed), port_attr.active_speed); + + if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { + printf("\t\t\tactive_width:\t\t%sX (%d)\n", + width_str(port_attr.active_width), port_attr.active_width); + printf("\t\t\tactive_speed:\t\t%s (%d)\n", + speed_str(port_attr.active_speed), port_attr.active_speed); + } else { + printf("\t\t\tactive_speed:\t\t%s (%d)\n", + roce_speed_str(port_attr.active_speed * port_attr.active_width), + port_attr.active_speed * port_attr.active_width); + } if (ib_dev->transport_type == IBV_TRANSPORT_IB) printf("\t\t\tphys_state:\t\t%s (%d)\n", port_phy_state_str(port_attr.phys_state), port_attr.phys_state);