From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A17EEC3F68F for ; Sat, 21 Dec 2019 01:33:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 781762070C for ; Sat, 21 Dec 2019 01:33:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="O55iA6Gb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726462AbfLUBdD (ORCPT ); Fri, 20 Dec 2019 20:33:03 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:1863 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbfLUBdD (ORCPT ); Fri, 20 Dec 2019 20:33:03 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 20 Dec 2019 17:32:52 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 20 Dec 2019 17:33:02 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 20 Dec 2019 17:33:02 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 21 Dec 2019 01:32:57 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sat, 21 Dec 2019 01:32:57 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 20 Dec 2019 17:32:57 -0800 From: John Hubbard To: Leon Romanovsky CC: Jason Gunthorpe , Noa Osherovich , , John Hubbard Subject: [PATCH 1/1] pyverbs: fix speed_to_str(), to handle disabled links Date: Fri, 20 Dec 2019 17:32:56 -0800 Message-ID: <20191221013256.100409-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191221013256.100409-1-jhubbard@nvidia.com> References: <20191221013256.100409-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1576891972; bh=15uHeEx+BUrKTkjhLcSO/RSQ9/iF69A3ke7v6PTPl/0=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=O55iA6GbVAA+8QqdCczSozP6QKGtlN5eMJNskelsCsjvwVIhdr3/mjllIp+keQnDd zuTFYDHm15f5NBTfNV1d0LMLkYlCyARvEulpd2FsDE1BkhOSlWiVP3lNl3dq3WwT0j UcbyZZHRcagmt4/MI+xs53T6VbkLUIg5HoxwIiFiSbU8c0Nocm6+26VdSJdrNVboI1 hnk/82TzgoQ1E+UiuT29kmVHBOndOtHMi0jp2eMy5yKfuzoNBur/6ajySFm4FSW446 Vlip5P1miINTbFhrgX6p05pMfA8GDNv/gBN+zSmKmoLQ4DcRFs874KuGTfZ0yLSWq6 6kYaN+FGEBGfw== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org For disabled links, the raw speed token is 0. However, speed_to_str() doesn't have that in the list. This leads to an assertion when running tests (test_query_port) when one link is down and other link(s) are up. Fix this by returning '0.0 Gbps' for the zero speed case. Cc: Noa Osherovich Signed-off-by: John Hubbard --- pyverbs/device.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyverbs/device.pyx b/pyverbs/device.pyx index 33d133fd..cf7b75de 100755 --- a/pyverbs/device.pyx +++ b/pyverbs/device.pyx @@ -923,8 +923,8 @@ def width_to_str(width): =20 =20 def speed_to_str(speed): - l =3D {1: '2.5 Gbps', 2: '5.0 Gbps', 4: '5.0 Gbps', 8: '10.0 Gbps', - 16: '14.0 Gbps', 32: '25.0 Gbps', 64: '50.0 Gbps'} + l =3D {0: '0.0 Gbps', 1: '2.5 Gbps', 2: '5.0 Gbps', 4: '5.0 Gbps', + 8: '10.0 Gbps', 16: '14.0 Gbps', 32: '25.0 Gbps', 64: '50.0 Gbps'= } try: return '{s} ({n})'.format(s=3Dl[speed], n=3Dspeed) except KeyError: --=20 2.24.1