From patchwork Sat Dec 21 01:32:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 11306573 X-Patchwork-Delegate: leon@leon.nu Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 678EC138D for ; Sat, 21 Dec 2019 01:33:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 452772070C for ; Sat, 21 Dec 2019 01:33:22 +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 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): def speed_to_str(speed): - l = {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 = {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=l[speed], n=speed) except KeyError: