From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id E69A61B1A7 for ; Thu, 12 Oct 2017 10:17:47 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id q132so10967880wmd.2 for ; Thu, 12 Oct 2017 01:17:47 -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=sIM39XDLtKzXeQ50oyiPOdeEBnjplHuVlbTr/5UxeXKIaWmwH8Hmjd/kS0HPIYHhRo AbU8JukLn0IF/Hi8LAUW5RGX0Le771Tu2rOpxeUfBY+OJAtIcIukT8WRkoIZO6eddF16 ZjaqF4gXZvPp7bCEiOibMES8ZIfXZX330fv2zMjyqAsEUicSuPG2RUwG+l4JG3VV8PsK kzZuBwCHxAjV2a12E+s9DjQQTbTzX6vq6M0uTSHEsmCyQThPp47KkMA0H4n0G1homyVK Oy/w3Ksm7/gJu9FyDn/stxOY6xXlo3id7BVpRo/06X/udm8J8HufHAZP/4OEACPCD3ec 1Eig== 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=X5xMjzupKrdKqQfqIfDTHBRk3T/fvdUI7h/WCHg45k+FQO2VpXbqDlqEoqtkaO/mtF zbqyzpadwJTVTWNscrQxvcTw/aDN4qu5xFHXGdwDZDco+DpP+NkHxbxw0vUnim+5fk9D BAnCnEemYuQrym94MSZz92z/lgrEEfTMFG0Pctc52JnWu4FJmmdoXx6ZTMwPeh8lQTzp K70qlxZPoiksGBNyTfVvX+F1MpB9IQV+ntOk+yQNIDQclqcq6SL+xgmActMVkDAdNrXd IbJVcIGGKA2hkKoWlwDNelwHnHyOVgOuKMlqDH3XmETcByj2R0BKl/IijK+XZQ7DwbU8 eeIg== X-Gm-Message-State: AMCzsaXgccEeVh8cA7mcdZrV1n1mBZblgTFI4wQ7PPm/2SnID6opIYab m7AeNdlfdFuHRKIaeWZBbjD9nf7I X-Google-Smtp-Source: AOwi7QCmfKj/4RvE/PbqRgHhzglbfGuw3eNuMD3f8xvqBBuVlI+s/iLjEVb0p1kpO5f972s6ZhUIeg== X-Received: by 10.28.60.68 with SMTP id j65mr1070678wma.16.1507796267110; Thu, 12 Oct 2017 01:17:47 -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 25sm16711227wrv.8.2017.10.12.01.17.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 01:17:46 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 12 Oct 2017 10:17:13 +0200 Message-Id: <2cad2323c4e162b7ba04424740c4346e13f5edbf.1507795823.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 13/16] 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: , X-List-Received-Date: Thu, 12 Oct 2017 08:17:48 -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 --- 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