From patchwork Thu Oct 26 10:05:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 30953 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EE7681BAF4; Thu, 26 Oct 2017 12:06:59 +0200 (CEST) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 313501BA9B for ; Thu, 26 Oct 2017 12:06:45 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id m72so6877866wmc.1 for ; Thu, 26 Oct 2017 03:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=x2JGEUNy4Szl3sfVTAc1YxprDdwNNoyfm4b7woAo1Ts=; b=d8JAlJyGWmm8vmHyFo9cY2Wxo6vUkD/UrsHXZifwIxEptjTuW7CYflmIXSb5z+74NE xYRP9+8RvgW5GtcpKytbrUg5aJVXu8LKFEew3XVWKVhMKSz4t4zgXbTX2qiAcKiCxJ9A pnv0KZrfdqjEZEDgf9yc9TwsgjaNOIFcuH3hmg9y1AVIrBehI1T4RnvPffCmMvXgnlRH mrxtdoO9gofWWVeWVfXwrWeEiVJ9uGGWR6+mlMHTy8EXApf2Lh23zceYm9zF3E6+aTZw 9Bw9AlGFu0KTvygSnOHJbOIX2g2S2wPbiViDyZrAYpC5Z0oVh7cq1OzlhqXQUfr72x3Q Sa2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=x2JGEUNy4Szl3sfVTAc1YxprDdwNNoyfm4b7woAo1Ts=; b=Qn/xmaoZZ4N4wLK8imRSqASYyVBDGQkksrFct/Q6l1CSq80dGt/TMA80YkdDCjIvuH tQllRmsce4M/0VQsKAy3PJl4IqhJ3j0aMBPkyHtggfohk/wkYKW6yBsyREDF7tmfM3Xo mgQE3DItsZmZi50GxB1tiMr9cKC5NJq0L4aJpdl7ousXEwsPke0VhRo4c3fnJvS7bdXv AY222xQ4adQ23wA35MB8jiPbu46mhDx050SGHik8GgYgp0O7n9cKhfU/S1E7FN1nt45p 2afAHGe4gDqrpv0Vh94dpXEB/JpoYIGjonqgBh3Gqi+K01eEQVD/x8ibRaxYKI/1E8ZT J0Ww== X-Gm-Message-State: AMCzsaVyqNxMjatmOOTKWyFfd60kE4W04SuHz++plGN7DwOLh8RygLOv rouxNRZvfpWSnpRckFn+t6GzNZHp X-Google-Smtp-Source: ABhQp+TIDc2M3TajKTqQOA1pL+y/t5Zhb5ZndBLq+hrj51m6aiKS49wQG4jvmnG2WAeBSd2tAhJLSA== X-Received: by 10.80.135.176 with SMTP id a45mr27168820eda.112.1509012404345; Thu, 26 Oct 2017 03:06:44 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id u12sm3339619edk.45.2017.10.26.03.06.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Oct 2017 03:06:43 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 26 Oct 2017 12:05:59 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v8 14/25] pci: introduce PCI address parsing function 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" A new single function that is able to parse all currently supported format: * Domain-Bus-Device-Function * Bus-Device-Function Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_pci.c | 9 +++++++++ lib/librte_eal/common/include/rte_pci.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 3 files changed, 24 insertions(+) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 2230e09..d01b0f9 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -199,6 +199,15 @@ rte_eal_compare_pci_addr(const struct rte_pci_addr *addr, return rte_pci_addr_cmp(addr, addr2); } +int +rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr) +{ + if (rte_pci_bdf_parse(str, addr) == 0 || + rte_pci_dbdf_parse(str, addr) == 0) + return 0; + return -1; +} + void pci_name_set(struct rte_pci_device *dev) { diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 9ac19d5..11ba442 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -347,6 +347,20 @@ int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr, const struct rte_pci_addr *addr2); /** + * Utility function to parse a string into a PCI location. + * + * @param str + * The string to parse + * @param addr + * The reference to the structure where the location + * is stored. + * @return + * 0 on success + * <0 otherwise + */ +int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr); + +/** * Scan the content of the PCI bus, and the devices in the devices * list * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 5cad972..3568694 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -254,6 +254,7 @@ DPDK_17.11 { rte_lcore_has_role; rte_memcpy_ptr; rte_pci_addr_cmp; + rte_pci_addr_parse; rte_pci_bdf_parse; rte_pci_dbdf_parse; rte_pci_device_name;