[dpdk-dev] [PATCH 2/3] bus/pci: expose sysfs parsing API

Xiao Wang xiao.w.wang at intel.com
Sat Mar 10 00:08:08 CET 2018


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 <xiao.w.wang at intel.com>
---
 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;
-- 
2.15.1



More information about the dev mailing list