From patchwork Sat Dec 21 01:32:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 11306571 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 3C13A17EF 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 1A20D2082E 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="NrVT3saZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726648AbfLUBdD (ORCPT ); Fri, 20 Dec 2019 20:33:03 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:1856 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbfLUBdD (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:51 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 20 Dec 2019 17:33:01 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 20 Dec 2019 17:33:01 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 21 Dec 2019 01:33:01 +0000 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL109.nvidia.com (172.20.187.15) 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 HQMAIL111.nvidia.com (172.20.187.18) 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 0/1] pyverbs: fix speed_to_str(), to handle disabled links Date: Fri, 20 Dec 2019 17:32:55 -0800 Message-ID: <20191221013256.100409-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1576891971; bh=7+j5Ua7VdVzF3bOTWeQmd5drlDWx7kbLh3NnwkZYYc4=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=NrVT3saZX67xdMBtrONF1pm6OBVV4NAHG328fPN4RqnqYPKzDp9n/eTOcZOQ9C1Ua V0lENL/h1ryroTY2f0hTbC46NIGoHz/Tm/EDxSaCYq6bY4zDIeC4/KHv/VmlaXPKtQ 7/kvy+UBbrmySi2YxQipr0yklfvZmw906GOzTXsip2vMvAH3rooLU6Dj3IKTEX8b24 7mk9xL2YSRy9azrJqpTriFUI1U5zfA3esw/SYd9LIfu21O+kR2PSDGfvKtZQJCTAwo HpL0ylyWnQlESYYS7owsCk2lyWHhtVCxD5wbMuOkXvzr/72JZtRtdLHKgkwRq98trj MDSFaE6ZASdRA== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Hi, This came up when I was running rdma-core tests on a two-machine setup, where each card had two ports, but there was only one cable. So only one port on each end was connected. The main thing I expect to be up for debate is, what string to return for speed, when a port is disabled or down? I initially thought about returning '(Disabled/down)', but it seems more accurate to just report '0.0 Gbps', so that's what I settled on. Background: here's what I wrote when discussing this over on linux-mm with Leon [1]: It looks like this test suite assumes that every link is connected! (Probably in most test systems, they are.) But in my setup, the ConnectX cards each have two slots, and I only have (and only need) one cable. So one link is up, and the other is disabled. This leads to the other problem, which is that if a link is disabled, the test suite finds a "0" token for attr.active_speed. That token is not in the approved list, and so d.speed_to_str() asserts. With some diagnostics added, I can see it checking each link: one passes, and the other asserts: assert attr.max_msg_sz > 0x1000 ...and the test run from that is: # ./build/bin/run_tests.py --verbose tests.test_device.DeviceTest test_dev_list (tests.test_device.DeviceTest) ... ok test_open_dev (tests.test_device.DeviceTest) ... ok test_query_device (tests.test_device.DeviceTest) ... ok test_query_device_ex (tests.test_device.DeviceTest) ... ok test_query_gid (tests.test_device.DeviceTest) ... ok test_query_port (tests.test_device.DeviceTest) ... Diagnostics =========================================== phys_state: Link up (5) active_width): 4X (2) active_speed: 25.0 Gbps (32) END of Diagnostics ==================================== Diagnostics =========================================== phys_state: Disabled (3) active_width): 4X (2) active_speed: Invalid speed END of Diagnostics ==================================== FAIL test_query_port_bad_flow (tests.test_device.DeviceTest) ... ok ====================================================================== FAIL: test_query_port (tests.test_device.DeviceTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/kernel_work/rdma-core/tests/test_device.py", line 135, in test_query_port self.verify_port_attr(port_attr) File "/kernel_work/rdma-core/tests/test_device.py", line 119, in verify_port_attr assert 'Invalid' not in d.speed_to_str(attr.active_speed) AssertionError ---------------------------------------------------------------------- Ran 7 tests in 0.055s FAILED (failures=1) [1] https://lore.kernel.org/r/b70ac328-2dc0-efe3-05c2-3e040b662256@nvidia.com John Hubbard (1): pyverbs: fix speed_to_str(), to handle disabled links pyverbs/device.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_device.py b/tests/test_device.py index 524e0e89..7b33d7db 100644 --- a/tests/test_device.py +++ b/tests/test_device.py @@ -110,6 +110,12 @@ class DeviceTest(unittest.TestCase): assert 'Invalid' not in d.translate_mtu(attr.max_mtu) assert 'Invalid' not in d.translate_mtu(attr.active_mtu) assert 'Invalid' not in d.width_to_str(attr.active_width) + print("") + print('Diagnostics ===========================================') + print('phys_state: ', d.phys_state_to_str(attr.phys_state)) + print('active_width): ', d.width_to_str(attr.active_width)) + print('active_speed: ', d.speed_to_str(attr.active_speed)) + print('END of Diagnostics ====================================') assert 'Invalid' not in d.speed_to_str(attr.active_speed) assert 'Invalid' not in d.translate_link_layer(attr.link_layer) assert attr.max_msg_sz > 0x1000