From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C70F2A0542; Thu, 10 Nov 2022 16:57:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 734C040150; Thu, 10 Nov 2022 16:57:54 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2072.outbound.protection.outlook.com [40.107.220.72]) by mails.dpdk.org (Postfix) with ESMTP id B386B400EF; Thu, 10 Nov 2022 16:57:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DnmlkkKWEiL9lj5gNLTrWwIct8aHp1s0ii2eLqbIWECtvlP9ELsCt2VYwtTBJRWKP+tLQt2OGLZnBkKiEjtoKBngIGww1Kdc85F8Shwp8cS+VAOUoP5S4yEGgYUuXHFAdyNoz7I2vnXSCDIGf4n5D9UoN1rp5qb0bFC2eF5uhP3uFQD72GFoh6y5zEpbHfrbO0wazQgOrNlG3kS0YeAqPvIvVaEf09oxKMklqi6jhPdlH0bquKiiZf/EFBD8lN9sKLOnUYSlbDvyMR4x1Nxi1BAOGE3CtnvLTqq8hULaGjv2ih7n4j52pufJVcgBJIv8FDOD5mecio0HDpji6MV3cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tg9WaqiUgrOmCj3g1+SmHZB05Sf09LQ0eWvPkgiKRzE=; b=RJmnU+wGqk6R9dExKzQ9e0hW84rw99fIUXVgKid5Dx81OQiCNV2K2sRWlgyLrlp7vz62w4zO9hO3CuBUVMvAGtxrTJYmBgWaFFw+vQcjV94higXBkPDdld7QROksUjuaLwKjoZiaLGNRWNio2sUbLJBsVFoQS4FYdg4YgLzdh63aA3qGDCIEBqNDk7tFpU4iDCxMya5N5xpuRdTIbMFji9ItyqG65n9SQH4Cg5wlgcamB2bJ61oStpjTtlZlXU6o4uoSYH2nDEqHEIZ+BMabV/KDoaT99uy3dRfxl1ESIgLSmns+CmgWJcOQ+Q0+jGVoNaMaf4clPTEQ0tksWUSrEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tg9WaqiUgrOmCj3g1+SmHZB05Sf09LQ0eWvPkgiKRzE=; b=fNnRT8xdVCxqJwlNymbkA04OXIPun0YwVRjsnQeUwGa6waq6X+H87xUxPUJy7EVPwHyCUD/2UTPLr5D7hZOKNAESpCERxc/OGpq89v6MT1IQiJUANWFHhx90uHRuTJROTSSPn08w7bvuBVsmlBfz7ftkjffLjnh+LHw3IIb61mCth1o6/YTZ2ZHkY3H4zpcD5H5Lni+7+rLEr9j3AmxVOt4AN5fNaH0Q4ddOEAzSAug4J0kzRx1wfDSTUfT+APzRKao7MIj4DPiHRe0trofzI4QxpSJNEBKpUuZhPToRp7cp2izqdifo7cEOUFdsmvwLRnE3r4ReYnGR+72EOKkJlg== Received: from BN9PR03CA0373.namprd03.prod.outlook.com (2603:10b6:408:f7::18) by DS0PR12MB7535.namprd12.prod.outlook.com (2603:10b6:8:13a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.25; Thu, 10 Nov 2022 15:57:50 +0000 Received: from BN8NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f7:cafe::76) by BN9PR03CA0373.outlook.office365.com (2603:10b6:408:f7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13 via Frontend Transport; Thu, 10 Nov 2022 15:57:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT004.mail.protection.outlook.com (10.13.176.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Thu, 10 Nov 2022 15:57:50 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 10 Nov 2022 07:57:42 -0800 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Thu, 10 Nov 2022 07:57:41 -0800 From: Bing Zhao To: , CC: , , Subject: [PATCH] common/mlx5: fix the sysfs port name translation Date: Thu, 10 Nov 2022 17:57:26 +0200 Message-ID: <20221110155726.649190-1-bingz@nvidia.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT004:EE_|DS0PR12MB7535:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c1a190e-0712-4d49-1e6f-08dac33451c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sNEaKTixGDZ1+s00KLRQGxYgRgepeSqwsScW9W+mA+jvKxx263dI6heCWh6/59xWuQExMgC8BZQHCcg8ZZL2khLuHg0p0kIsPxEyPU5Cpefm1yIiE77vVvjIeR5j5jSji27ryEEoP6eCU++UnWWT+PkHWuNisN+EUbI4ZXzaL2uRxyNJiuVMK8dZxC67Zl0hBgIaOFW//o0hfFo7O2Vr4K+3xpPZf6C98ibluId18IBAWTdShZaYZCrXzXie8nO7LAkaicgm9kV1uzbtTYAWNIuimy6yS5177i/rThxLizb6CS0zlgmS+2YKGxAq+GKgEFgI+qA9NWHQMKrqi40IFjm5uBkpLuHihEATF84Z3VpUtmYQm7GGxhWY5Kgfv95dt4APddBA0Pci3iTFh4mLqMqwDJQQWH55a8DZzr/8EQki2IrGzuQqmXsBtVSmTQ9rN75bmxviQW9G1QBToPqU3DKUfl1zfAgbgqNfvuVQqP3x2SJr/9bJBMbDLtOPjiC0RXFBpa60VEeggH3UemgZf00/JQ/b6vHMS96HenSNBPxbO2kXu4zPEnAOQigRlpFYymh9zPWzp5na9g0LW2GCmYrRw5K+Ii4klwxBfUNePUV96F5/pIvru0Obw84mCVyxi337Ann3GGojOIUDL+rp3jcCNswnc645JQGQIkE9FrehIJcagLkQRECifsabp5GlV7E17byqYhan4SZy7yTP76ERWasufhB994v2vjoELxKA/ucFL35yxCmKJivlXV+slIgY5dGPiqjXvLlqIM5NMA== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199015)(36840700001)(46966006)(40470700004)(356005)(82740400003)(40480700001)(83380400001)(40460700003)(7636003)(36756003)(86362001)(6666004)(110136005)(54906003)(6636002)(55016003)(316002)(8676002)(70586007)(8936002)(450100002)(478600001)(41300700001)(2906002)(4326008)(26005)(36860700001)(70206006)(82310400005)(5660300002)(6286002)(16526019)(186003)(2616005)(7696005)(47076005)(336012)(426003)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 15:57:50.2100 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c1a190e-0712-4d49-1e6f-08dac33451c8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7535 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org With some OFED or upstream kernel of mlx5, the port name fetched from "/sys/class/net/[DEV]/phys_port_name" may have a tailing "\n" as the EOL. The sscanf() will return the scanned items number with this EOL. In such case, the "equal to" condition is considered as false and the function mlx5_translate_port_name() will recognize the port type wrongly with UNKNOWN result. By changing the condition from "equal to" to "more than or equal to", the port type can be recognized successfully. Fixes: 654810b56828 ("common/mlx5: share Netlink commands") Fixes: 420bbdae89f2 ("net/mlx5: fix host physical function representor naming") Signed-off-by: Bing Zhao Acked-by: Viacheslav Ovsiienko --- drivers/common/mlx5/linux/mlx5_common_os.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index aafff60eeb..655347a7c8 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -108,7 +108,7 @@ mlx5_translate_port_name(const char *port_name_in, sc_items = sscanf(port_name_in, "%c%c%d%c%c%d%c", &pf_c1, &pf_c2, &port_info_out->pf_num, &vf_c1, &vf_c2, &port_info_out->port_name, &eol); - if (sc_items == 6 && pf_c1 == 'p' && pf_c2 == 'f') { + if (sc_items >= 6 && pf_c1 == 'p' && pf_c2 == 'f') { if (vf_c1 == 'v' && vf_c2 == 'f') { /* Kernel ver >= 5.0 or OFED ver >= 4.6 */ port_info_out->name_type = @@ -128,7 +128,7 @@ mlx5_translate_port_name(const char *port_name_in, */ sc_items = sscanf(port_name_in, "%c%d%c", &pf_c1, &port_info_out->port_name, &eol); - if (sc_items == 2 && pf_c1 == 'p') { + if (sc_items >= 2 && pf_c1 == 'p') { port_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_UPLINK; return; } @@ -138,7 +138,7 @@ mlx5_translate_port_name(const char *port_name_in, */ sc_items = sscanf(port_name_in, "%c%c%d%c", &pf_c1, &pf_c2, &port_info_out->pf_num, &eol); - if (sc_items == 3 && pf_c1 == 'p' && pf_c2 == 'f') { + if (sc_items >= 3 && pf_c1 == 'p' && pf_c2 == 'f') { port_info_out->port_name = -1; port_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_PFHPF; return; -- 2.21.0