From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gaetan.rivet@6wind.com>
Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48])
 by dpdk.org (Postfix) with ESMTP id 4DB341B23C
 for <dev@dpdk.org>; Thu, 12 Oct 2017 12:46:20 +0200 (CEST)
Received: by mail-wm0-f48.google.com with SMTP id q132so12123214wmd.2
 for <dev@dpdk.org>; Thu, 12 Oct 2017 03:46:20 -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=xpmWQtTU9MoqV7USCqqACOGKeONBrM1laPLvgivcHVs=;
 b=Kzr8EctxovkxWrlQtBSxli2XiRyZcHj0hbwslxzQTl/vWmQLJo58hbIdzYP8kvFTWE
 mTwAadZKVJKewbDWDnHYo716Mv2fnhn009WtQtxxAvpfNeCGGJLFZPRg10fM86hX3eaF
 P/XlFbFB/mEB28XrCmJMqSn0U1RQfm2FJdF5pHUqsQ40Nns98bSPY92eBKhdZXZR83On
 j1eTlDCdiFycNnVUxn87Ry4r2YY4TbOZBiJSeh9Hs4tvEOo6jKlPN47UPyiIFgKhMZ1z
 KPXidh+BcPbEB9OIN6mOa5g2+UaaYuBu/2cj3fPdqV5Ig7Zv+VDVRZNvVK595JC6Yzw4
 1qfQ==
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=xpmWQtTU9MoqV7USCqqACOGKeONBrM1laPLvgivcHVs=;
 b=KWurHH8Dl4umfAkbAxJLuDfWNPFTSnuPO5GFNpGc+zQq+YQ9QVNCjznW3pAQ3HXVOn
 tUPGfog4oiNah42whXQc+1Eiau2b97EW4w2D89qJhNOsB8xuzeH51B5FM2fBFNwlaiyY
 e1hVdwtjpqtFwDD0gI6siI+yrsxIYc73HD+cf5aIWB5ss8wOfObUN5LqFDfaJ5iEe1Zc
 M7yhmDMdl/6h7Z1MoD8Ofu3G0Naie0DY+glQ8IjB6K+6H7JXo3Bjn+OFrQ2xNczgxfNR
 eeCvIoAINNoc9ag71sAJPZshTsz9IN+7tOks9t/rh3wQ7sD15HTW6af65QQgNNU4MGW2
 V8qA==
X-Gm-Message-State: AMCzsaWo3jd2/EELNPxu3RcmzTz377CJqGwZxjogI1rxio+XMa8Ctben
 b/uvXQkt7lPCZPlqOqk/GTqLgBIc
X-Google-Smtp-Source: AOwi7QArW5vZ61nip+Dh7GqoL82SsmwMW0v7TV+qIVRdCwlGSNyeCqPRUQHnzX7klyTNo7q0X0XiGg==
X-Received: by 10.223.199.205 with SMTP id y13mr1885270wrg.71.1507805179380;
 Thu, 12 Oct 2017 03:46:19 -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 z192sm16481146wmz.28.2017.10.12.03.46.18
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
 Thu, 12 Oct 2017 03:46:18 -0700 (PDT)
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Date: Thu, 12 Oct 2017 12:45:40 +0200
Message-Id: <d9c4814a505dc2c65d991beb534fedc2f9e97525.1507804944.git.gaetan.rivet@6wind.com>
X-Mailer: git-send-email 2.1.4
In-Reply-To: <cover.1507804944.git.gaetan.rivet@6wind.com>
References: <cover.1507795823.git.gaetan.rivet@6wind.com>
 <cover.1507804944.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1507804944.git.gaetan.rivet@6wind.com>
References: <cover.1507804944.git.gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v5 13/20] 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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Oct 2017 10:46:21 -0000

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 <gaetan.rivet@6wind.com>
---
 lib/librte_pci/include/rte_pci.h   | 15 +++++++++++++++
 lib/librte_pci/rte_pci.c           | 10 ++++++++++
 lib/librte_pci/rte_pci_version.map |  1 +
 3 files changed, 26 insertions(+)

diff --git a/lib/librte_pci/include/rte_pci.h b/lib/librte_pci/include/rte_pci.h
index 38cbdb3..9e79557 100644
--- a/lib/librte_pci/include/rte_pci.h
+++ b/lib/librte_pci/include/rte_pci.h
@@ -256,6 +256,21 @@ int rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,
 int pci_addr_cmp(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 pci_addr_parse(const char *str, struct rte_pci_addr *addr);
+
 /**
  * Map a particular resource from a file.
  *
diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c
index fc2fc7f..7ba472c 100644
--- a/lib/librte_pci/rte_pci.c
+++ b/lib/librte_pci/rte_pci.c
@@ -171,6 +171,16 @@ pci_addr_cmp(const struct rte_pci_addr *addr,
 		return 0;
 }
 
+int
+pci_addr_parse(const char *str, struct rte_pci_addr *addr)
+{
+	if (pci_bdf_parse(str, addr) == 0 ||
+	    pci_dbdf_parse(str, addr) == 0)
+		return 0;
+	return -1;
+}
+
+
 /* map a particular resource from a file */
 void *
 pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
diff --git a/lib/librte_pci/rte_pci_version.map b/lib/librte_pci/rte_pci_version.map
index 8d180e3..5f50f98 100644
--- a/lib/librte_pci/rte_pci_version.map
+++ b/lib/librte_pci/rte_pci_version.map
@@ -4,6 +4,7 @@ DPDK_17.11 {
 	eal_parse_pci_BDF;
 	eal_parse_pci_DomBDF;
 	pci_addr_cmp;
+	pci_addr_parse;
 	pci_bdf_parse;
 	pci_dbdf_parse;
 	pci_device_name;
-- 
2.1.4