From patchwork Tue May 12 13:30:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Stojaczyk, Dariusz" X-Patchwork-Id: 70110 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 49CAEA04A2; Tue, 12 May 2020 15:31:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18D931BF9C; Tue, 12 May 2020 15:31:25 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id EB0CD1BF31 for ; Tue, 12 May 2020 15:31:22 +0200 (CEST) IronPort-SDR: 6Yl4JdGOxamoybVu/+WzSnlosDgMnk2qQHNhPfPlJAGYxwYUg2doKIel30OmrGlHOaTMtKaESx Zq8WnehyWKRA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2020 06:31:21 -0700 IronPort-SDR: uP5rKy1tkveUXND5dAO5HGwwClXlzFXqVQmNc8V+UUccpTguwlQLTmCMpoELogERKoh41/jjwr AlRbEeQkNxGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,383,1583222400"; d="scan'208";a="297305426" Received: from ultraviolet.igk.intel.com (HELO localhost.localdomain) ([10.102.17.137]) by fmsmga002.fm.intel.com with ESMTP; 12 May 2020 06:31:20 -0700 From: Darek Stojaczyk To: dev@dpdk.org Cc: Darek Stojaczyk Date: Tue, 12 May 2020 15:30:57 +0200 Message-Id: <20200512133057.106374-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] pci: properly parse 32-bit domain numbers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The parsing code was bailing on domains greater than UINT16_MAX, but domain numbers like that are still valid and present on some systems. One example is Intel VMD (Volume Management Device), which acts somewhat as a software-managed PCI switch and its upstream linux driver assigns all downstream devices a PCI domain of 0x10000. Parsing a BDF like 10000:01:00.0 was failing before. To fix it, increase the upper limit of domain number to UINT32_MAX. This matches the size of struct rte_pci_addr->domain (uint32). Signed-off-by: Darek Stojaczyk Acked-by: Gaetan Rivet Acked-by: Gaetan Rivet --- lib/librte_pci/rte_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index d1ab6b414d..ad2cdfebb2 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -72,9 +72,9 @@ pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr) errno = 0; val = strtoul(in, &end, 16); - if (errno != 0 || end[0] != ':' || val > UINT16_MAX) + if (errno != 0 || end[0] != ':' || val > UINT32_MAX) return -EINVAL; - dev_addr->domain = (uint16_t)val; + dev_addr->domain = (uint32_t)val; in = end + 1; in = get_u8_pciaddr_field(in, &dev_addr->bus, ':'); if (in == NULL)