From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 58CD11BA6A for ; Thu, 26 Oct 2017 00:39:27 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id m72so4572592wmc.1 for ; Wed, 25 Oct 2017 15:39:27 -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=M/7kV+/DkBJ+j5us39Jc33EgWQknpjitUb1UWUednHE=; b=kg4GycCSVb6xGRIwNrJPMITDF+apcxddpntKJtlUiRWMZWT6Qj4+8q2cPOIjw+fV8D BezrseZVc//LIZTWFLIwpNCN/BO4iBrLfqCCMsMcXM2K+8UkLzJKyuRs99b21QXOHXwX KDkLFJzN9lbwhBoTTmjngASezyPsYEj3G4axMpI76UteWHDYl8EQxi6PwCDdz58L2a+r UZeMepwdJmHuOcpP7vdfU3S7YQNIgYXClnzs/sxrlQkleUfWf7zIB+ONZQfOhx6mtufs Rw4vqe+Q6cEXh9PUIZ2sUqSIc9YKcDkG+qTvoK1ID7h+D7W95TpE+6jEpa1oi+/fHkAW qMgg== 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=M/7kV+/DkBJ+j5us39Jc33EgWQknpjitUb1UWUednHE=; b=U6+7dNkM8dQhnbgHmKqPgjYMM4sEvYZEmhR2oymgJK3lUk0asyi1jmXws/RGnJsP+R AEEE7QPs4q6wTzKFOiJNXninS36mrXLHX4E0AgdXz6V79G2POCLnkVQTlzH0RgSnh+lG AJ5EqUacLCxS1AQKZZvculy8Xka2Xbwmb58vz3XDlzn5m4rsT8ZnQXnK7HOq9ZSH7pi8 5pjqLfAWosMZ7tCePDEYbozs+5doApcsAjyBL8h+sTTs7hs5ff3n1M5kP5QeYNMHo07Z CwX63Usiwz8qoU8CWEpMSAheqfqqKJjM8oQbDnKtv3GeQ+KvW6w2RxYRsiLIAbPhw34Z N4hg== X-Gm-Message-State: AMCzsaUn2dx2msYaaLFCThNOQtBNTsOVly+fWgGnYaiWsXW77S2FO75D 7/LjIoMvwpVhi2jeyXmIXS0DtVoy X-Google-Smtp-Source: ABhQp+QICGWGvj+084keOSTIb9uQiY650ODRIfUVDRA73+SoIzP6X5d4HgGkBE1YDIweejm+z1vtDA== X-Received: by 10.28.199.139 with SMTP id x133mr2897123wmf.145.1508971166452; Wed, 25 Oct 2017 15:39:26 -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 r63sm4466124wmg.13.2017.10.25.15.39.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Oct 2017 15:39:25 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 26 Oct 2017 00:38:36 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v7 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: , X-List-Received-Date: Wed, 25 Oct 2017 22:39:27 -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_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 a3c32fb..fdcf005 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; -- 2.1.4