From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 80D0EA04B0 for ; Fri, 4 Dec 2020 14:39:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 515F12F42; Fri, 4 Dec 2020 14:39:22 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 42EEC2F42 for ; Fri, 4 Dec 2020 14:39:20 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 4 Dec 2020 15:39:16 +0200 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0B4DdGCY001468; Fri, 4 Dec 2020 15:39:16 +0200 From: Viacheslav Ovsiienko To: stable@dpdk.org Cc: ktraynor@redhat.com Date: Fri, 4 Dec 2020 13:39:14 +0000 Message-Id: <1607089154-25892-1-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-stable] [PATCH] [18.11] net/mlx5: fix PCI address lookup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" mlx5 PMDs use the mlx5_dev_to_pci_addr() routine to convert Infiniband device name to the Bus-Device-Function location on the PCI bus. The routine returned success even in case of not found identification string. On caller side it likely caused the wrong match with the BDF of previous device resulting in wrong representor and master recognitions. Fixes: 771fa900b73a ("mlx5: introduce new driver for Mellanox ConnectX-4 adapters") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_ethdev.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index e35ff32..f1ec6f2 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -968,6 +968,7 @@ struct ethtool_link_settings { { FILE *file; char line[32]; + int rc = -ENOENT; MKSTR(path, "%s/device/uevent", device->ibdev_path); file = fopen(path, "rb"); @@ -977,16 +978,19 @@ struct ethtool_link_settings { } while (fgets(line, sizeof(line), file) == line) { size_t len = strlen(line); - int ret; /* Truncate long lines. */ - if (len == (sizeof(line) - 1)) + if (len == (sizeof(line) - 1)) { while (line[(len - 1)] != '\n') { - ret = fgetc(file); + int ret = fgetc(file); + if (ret == EOF) - break; + goto exit; line[(len - 1)] = ret; } + /* No match for long lines. */ + continue; + } /* Extract information. */ if (sscanf(line, "PCI_SLOT_NAME=" @@ -995,12 +999,15 @@ struct ethtool_link_settings { &pci_addr->bus, &pci_addr->devid, &pci_addr->function) == 4) { - ret = 0; + rc = 0; break; } } +exit: fclose(file); - return 0; + if (rc) + rte_errno = -rc; + return rc; } /** -- 1.8.3.1