From patchwork Fri Mar 9 23:08:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Wang X-Patchwork-Id: 35863 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 8E7155F4F; Fri, 9 Mar 2018 15:34:12 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 271DB5F2C for ; Fri, 9 Mar 2018 15:34:11 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2018 06:34:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,445,1515484800"; d="scan'208";a="35964317" Received: from dpdk-xiao-1.sh.intel.com ([10.67.110.153]) by fmsmga004.fm.intel.com with ESMTP; 09 Mar 2018 06:34:09 -0800 From: Xiao Wang To: dev@dpdk.org Cc: zhihong.wang@intel.com, maxime.coquelin@redhat.com, yliu@fridaylinux.org, cunming.liang@intel.com, rosen.xu@intel.com, junjie.j.chen@intel.com, dan.daly@intel.com, Xiao Wang Date: Sat, 10 Mar 2018 07:08:08 +0800 Message-Id: <20180309230809.63361-3-xiao.w.wang@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180309230809.63361-1-xiao.w.wang@intel.com> References: <20180309230809.63361-1-xiao.w.wang@intel.com> Subject: [dpdk-dev] [PATCH 2/3] bus/pci: expose sysfs parsing API 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" Some existing sysfs parsing functions are helpful for the later vDPA driver, this patch make them global and expose them to shared lib. Signed-off-by: Xiao Wang --- drivers/bus/pci/linux/pci.c | 9 ++++----- drivers/bus/pci/linux/pci_init.h | 8 ++++++++ drivers/bus/pci/rte_bus_pci_version.map | 8 ++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index abde64119..81e5e5650 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -32,7 +32,7 @@ extern struct rte_pci_bus rte_pci_bus; -static int +int pci_get_kernel_driver_by_path(const char *filename, char *dri_name) { int count; @@ -168,9 +168,8 @@ pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr, return 0; } -/* parse the "resource" sysfs file */ -static int -pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev) +int +rte_pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev) { FILE *f; char buf[BUFSIZ]; @@ -302,7 +301,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) /* parse resources */ snprintf(filename, sizeof(filename), "%s/resource", dirname); - if (pci_parse_sysfs_resource(filename, dev) < 0) { + if (rte_pci_parse_sysfs_resource(filename, dev) < 0) { RTE_LOG(ERR, EAL, "%s(): cannot parse resource\n", __func__); free(dev); return -1; diff --git a/drivers/bus/pci/linux/pci_init.h b/drivers/bus/pci/linux/pci_init.h index c2e603a37..e871c3942 100644 --- a/drivers/bus/pci/linux/pci_init.h +++ b/drivers/bus/pci/linux/pci_init.h @@ -83,6 +83,14 @@ int pci_vfio_unmap_resource(struct rte_pci_device *dev); int pci_vfio_is_enabled(void); +/* parse sysfs file path */ +int +pci_get_kernel_driver_by_path(const char *filename, char *dri_name); + +/* parse the "resource" sysfs file */ +int +rte_pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev); + #endif #endif /* EAL_PCI_INIT_H_ */ diff --git a/drivers/bus/pci/rte_bus_pci_version.map b/drivers/bus/pci/rte_bus_pci_version.map index 27e9c4f10..dff2b52e8 100644 --- a/drivers/bus/pci/rte_bus_pci_version.map +++ b/drivers/bus/pci/rte_bus_pci_version.map @@ -16,3 +16,11 @@ DPDK_17.11 { local: *; }; + +DPDK_18.05 { + global: + + pci_get_kernel_driver_by_path; + rte_pci_parse_sysfs_resource; + +} DPDK_17.11;