[dpdk-dev] bus/pci: fix namespace of sysfs path function

Message ID 20171106020847.10462-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Thomas Monjalon Nov. 6, 2017, 2:08 a.m. UTC
  The function pci_get_sysfs_path was moved from EAL to the PCI driver.

The namespace is now fixed by adding "rte_" prefix.
The map files are fixed by removing the symbol from EAL and adding
it to the PCI driver.

It is an API break but it is probably not used by applications.
Anyway this API is already broken by the move in a new header file.

Fixes: c752998b5e2e ("pci: introduce library and driver")

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/pci/linux/pci.c             |  6 +++---
 drivers/bus/pci/linux/pci_uio.c         | 10 +++++-----
 drivers/bus/pci/linux/pci_vfio.c        |  6 +++---
 drivers/bus/pci/pci_common.c            |  2 +-
 drivers/bus/pci/rte_bus_pci.h           |  2 +-
 drivers/bus/pci/rte_bus_pci_version.map |  1 +
 drivers/net/szedata2/rte_eth_szedata2.c |  2 +-
 lib/librte_eal/rte_eal_version.map      |  1 -
 8 files changed, 15 insertions(+), 15 deletions(-)
  

Comments

Gaëtan Rivet Nov. 6, 2017, 8:43 a.m. UTC | #1
There are others namespace inconsistencies with my pci move, I will send
additional fixes later.

On Mon, Nov 06, 2017 at 03:08:47AM +0100, Thomas Monjalon wrote:
> The function pci_get_sysfs_path was moved from EAL to the PCI driver.
> 
> The namespace is now fixed by adding "rte_" prefix.
> The map files are fixed by removing the symbol from EAL and adding
> it to the PCI driver.
> 
> It is an API break but it is probably not used by applications.
> Anyway this API is already broken by the move in a new header file.
> 
> Fixes: c752998b5e2e ("pci: introduce library and driver")
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  drivers/bus/pci/linux/pci.c             |  6 +++---
>  drivers/bus/pci/linux/pci_uio.c         | 10 +++++-----
>  drivers/bus/pci/linux/pci_vfio.c        |  6 +++---
>  drivers/bus/pci/pci_common.c            |  2 +-
>  drivers/bus/pci/rte_bus_pci.h           |  2 +-
>  drivers/bus/pci/rte_bus_pci_version.map |  1 +
>  drivers/net/szedata2/rte_eth_szedata2.c |  2 +-
>  lib/librte_eal/rte_eal_version.map      |  1 -
>  8 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
> index cdf810693..e5cbc55b4 100644
> --- a/drivers/bus/pci/linux/pci.c
> +++ b/drivers/bus/pci/linux/pci.c
> @@ -395,7 +395,7 @@ pci_update_device(const struct rte_pci_addr *addr)
>  	char filename[PATH_MAX];
>  
>  	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
> -		 pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
> +		 rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
>  		 addr->function);
>  
>  	return pci_scan_one(filename, addr);
> @@ -468,7 +468,7 @@ rte_pci_scan(void)
>  		RTE_LOG(DEBUG, EAL, "VFIO PCI modules not loaded\n");
>  #endif
>  
> -	dir = opendir(pci_get_sysfs_path());
> +	dir = opendir(rte_pci_get_sysfs_path());
>  	if (dir == NULL) {
>  		RTE_LOG(ERR, EAL, "%s(): opendir failed: %s\n",
>  			__func__, strerror(errno));
> @@ -483,7 +483,7 @@ rte_pci_scan(void)
>  			continue;
>  
>  		snprintf(dirname, sizeof(dirname), "%s/%s",
> -				pci_get_sysfs_path(), e->d_name);
> +				rte_pci_get_sysfs_path(), e->d_name);
>  
>  		if (pci_scan_one(dirname, &addr) < 0)
>  			goto error;
> diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
> index 8cf6218fb..92b7f0275 100644
> --- a/drivers/bus/pci/linux/pci_uio.c
> +++ b/drivers/bus/pci/linux/pci_uio.c
> @@ -164,14 +164,14 @@ pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf,
>  	 * or uio:uioX */
>  
>  	snprintf(dirname, sizeof(dirname),
> -			"%s/" PCI_PRI_FMT "/uio", pci_get_sysfs_path(),
> +			"%s/" PCI_PRI_FMT "/uio", rte_pci_get_sysfs_path(),
>  			loc->domain, loc->bus, loc->devid, loc->function);
>  
>  	dir = opendir(dirname);
>  	if (dir == NULL) {
>  		/* retry with the parent directory */
>  		snprintf(dirname, sizeof(dirname),
> -				"%s/" PCI_PRI_FMT, pci_get_sysfs_path(),
> +				"%s/" PCI_PRI_FMT, rte_pci_get_sysfs_path(),
>  				loc->domain, loc->bus, loc->devid, loc->function);
>  		dir = opendir(dirname);
>  
> @@ -323,7 +323,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
>  	/* update devname for mmap  */
>  	snprintf(devname, sizeof(devname),
>  			"%s/" PCI_PRI_FMT "/resource%d",
> -			pci_get_sysfs_path(),
> +			rte_pci_get_sysfs_path(),
>  			loc->domain, loc->bus, loc->devid,
>  			loc->function, res_idx);
>  
> @@ -432,7 +432,7 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
>  
>  	/* open and read addresses of the corresponding resource in sysfs */
>  	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource",
> -		pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
> +		rte_pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
>  		dev->addr.devid, dev->addr.function);
>  	f = fopen(filename, "r");
>  	if (f == NULL) {
> @@ -454,7 +454,7 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
>  		goto error;
>  	}
>  	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource%d",
> -		pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
> +		rte_pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
>  		dev->addr.devid, dev->addr.function, bar);
>  
>  	/* mmap the pci resource */
> diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
> index 3ca35b6db..4b015b1ae 100644
> --- a/drivers/bus/pci/linux/pci_vfio.c
> +++ b/drivers/bus/pci/linux/pci_vfio.c
> @@ -465,7 +465,7 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
>  	snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
>  			loc->domain, loc->bus, loc->devid, loc->function);
>  
> -	ret = vfio_setup_device(pci_get_sysfs_path(), pci_addr,
> +	ret = vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
>  					&vfio_dev_fd, &device_info);
>  	if (ret)
>  		return ret;
> @@ -582,7 +582,7 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
>  	snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
>  			loc->domain, loc->bus, loc->devid, loc->function);
>  
> -	ret = vfio_setup_device(pci_get_sysfs_path(), pci_addr,
> +	ret = vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
>  					&vfio_dev_fd, &device_info);
>  	if (ret)
>  		return ret;
> @@ -662,7 +662,7 @@ pci_vfio_unmap_resource(struct rte_pci_device *dev)
>  		return -1;
>  	}
>  
> -	ret = vfio_release_device(pci_get_sysfs_path(), pci_addr,
> +	ret = vfio_release_device(rte_pci_get_sysfs_path(), pci_addr,
>  				  dev->intr_handle.vfio_dev_fd);
>  	if (ret < 0) {
>  		RTE_LOG(ERR, EAL,
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index 012420a9c..8b6a8bd88 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -59,7 +59,7 @@ extern struct rte_pci_bus rte_pci_bus;
>  
>  #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
>  
> -const char *pci_get_sysfs_path(void)
> +const char *rte_pci_get_sysfs_path(void)
>  {
>  	const char *path = NULL;
>  
> diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
> index c0b619f29..d4a299641 100644
> --- a/drivers/bus/pci/rte_bus_pci.h
> +++ b/drivers/bus/pci/rte_bus_pci.h
> @@ -60,7 +60,7 @@ extern "C" {
>  #include <rte_pci.h>
>  
>  /** Pathname of PCI devices directory. */
> -const char *pci_get_sysfs_path(void);
> +const char *rte_pci_get_sysfs_path(void);
>  
>  /* Forward declarations */
>  struct rte_pci_device;
> diff --git a/drivers/bus/pci/rte_bus_pci_version.map b/drivers/bus/pci/rte_bus_pci_version.map
> index ee67033b0..27e9c4f10 100644
> --- a/drivers/bus/pci/rte_bus_pci_version.map
> +++ b/drivers/bus/pci/rte_bus_pci_version.map
> @@ -2,6 +2,7 @@ DPDK_17.11 {
>  	global:
>  
>  	rte_pci_dump;
> +	rte_pci_get_sysfs_path;
>  	rte_pci_ioport_map;
>  	rte_pci_ioport_read;
>  	rte_pci_ioport_unmap;
> diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
> index c5486b72d..403cfdbb3 100644
> --- a/drivers/net/szedata2/rte_eth_szedata2.c
> +++ b/drivers/net/szedata2/rte_eth_szedata2.c
> @@ -1540,7 +1540,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
>  		return -EINVAL;
>  	}
>  	snprintf(rsc_filename, PATH_MAX,
> -		"%s/" PCI_PRI_FMT "/resource%u", pci_get_sysfs_path(),
> +		"%s/" PCI_PRI_FMT "/resource%u", rte_pci_get_sysfs_path(),
>  		pci_addr->domain, pci_addr->bus,
>  		pci_addr->devid, pci_addr->function, PCI_RESOURCE_NUMBER);
>  	fd = open(rsc_filename, O_RDWR);
> diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
> index b4d7cd93c..885892188 100644
> --- a/lib/librte_eal/rte_eal_version.map
> +++ b/lib/librte_eal/rte_eal_version.map
> @@ -124,7 +124,6 @@ DPDK_16.04 {
>  DPDK_16.07 {
>  	global:
>  
> -	pci_get_sysfs_path;
>  	rte_keepalive_mark_sleep;
>  	rte_keepalive_register_relay_callback;
>  	rte_rtm_supported;
> -- 
> 2.14.2
>
  
Thomas Monjalon Nov. 6, 2017, 11:44 p.m. UTC | #2
06/11/2017 09:43, Gaëtan Rivet:
> There are others namespace inconsistencies with my pci move, I will send
> additional fixes later.
> 
> On Mon, Nov 06, 2017 at 03:08:47AM +0100, Thomas Monjalon wrote:
> > The function pci_get_sysfs_path was moved from EAL to the PCI driver.
> > 
> > The namespace is now fixed by adding "rte_" prefix.
> > The map files are fixed by removing the symbol from EAL and adding
> > it to the PCI driver.
> > 
> > It is an API break but it is probably not used by applications.
> > Anyway this API is already broken by the move in a new header file.
> > 
> > Fixes: c752998b5e2e ("pci: introduce library and driver")
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>

Applied
  

Patch

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index cdf810693..e5cbc55b4 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -395,7 +395,7 @@  pci_update_device(const struct rte_pci_addr *addr)
 	char filename[PATH_MAX];
 
 	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
-		 pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
+		 rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
 		 addr->function);
 
 	return pci_scan_one(filename, addr);
@@ -468,7 +468,7 @@  rte_pci_scan(void)
 		RTE_LOG(DEBUG, EAL, "VFIO PCI modules not loaded\n");
 #endif
 
-	dir = opendir(pci_get_sysfs_path());
+	dir = opendir(rte_pci_get_sysfs_path());
 	if (dir == NULL) {
 		RTE_LOG(ERR, EAL, "%s(): opendir failed: %s\n",
 			__func__, strerror(errno));
@@ -483,7 +483,7 @@  rte_pci_scan(void)
 			continue;
 
 		snprintf(dirname, sizeof(dirname), "%s/%s",
-				pci_get_sysfs_path(), e->d_name);
+				rte_pci_get_sysfs_path(), e->d_name);
 
 		if (pci_scan_one(dirname, &addr) < 0)
 			goto error;
diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 8cf6218fb..92b7f0275 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -164,14 +164,14 @@  pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf,
 	 * or uio:uioX */
 
 	snprintf(dirname, sizeof(dirname),
-			"%s/" PCI_PRI_FMT "/uio", pci_get_sysfs_path(),
+			"%s/" PCI_PRI_FMT "/uio", rte_pci_get_sysfs_path(),
 			loc->domain, loc->bus, loc->devid, loc->function);
 
 	dir = opendir(dirname);
 	if (dir == NULL) {
 		/* retry with the parent directory */
 		snprintf(dirname, sizeof(dirname),
-				"%s/" PCI_PRI_FMT, pci_get_sysfs_path(),
+				"%s/" PCI_PRI_FMT, rte_pci_get_sysfs_path(),
 				loc->domain, loc->bus, loc->devid, loc->function);
 		dir = opendir(dirname);
 
@@ -323,7 +323,7 @@  pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
 	/* update devname for mmap  */
 	snprintf(devname, sizeof(devname),
 			"%s/" PCI_PRI_FMT "/resource%d",
-			pci_get_sysfs_path(),
+			rte_pci_get_sysfs_path(),
 			loc->domain, loc->bus, loc->devid,
 			loc->function, res_idx);
 
@@ -432,7 +432,7 @@  pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
 
 	/* open and read addresses of the corresponding resource in sysfs */
 	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource",
-		pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
+		rte_pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
 		dev->addr.devid, dev->addr.function);
 	f = fopen(filename, "r");
 	if (f == NULL) {
@@ -454,7 +454,7 @@  pci_uio_ioport_map(struct rte_pci_device *dev, int bar,
 		goto error;
 	}
 	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource%d",
-		pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
+		rte_pci_get_sysfs_path(), dev->addr.domain, dev->addr.bus,
 		dev->addr.devid, dev->addr.function, bar);
 
 	/* mmap the pci resource */
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 3ca35b6db..4b015b1ae 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -465,7 +465,7 @@  pci_vfio_map_resource_primary(struct rte_pci_device *dev)
 	snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
 			loc->domain, loc->bus, loc->devid, loc->function);
 
-	ret = vfio_setup_device(pci_get_sysfs_path(), pci_addr,
+	ret = vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
 					&vfio_dev_fd, &device_info);
 	if (ret)
 		return ret;
@@ -582,7 +582,7 @@  pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
 	snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
 			loc->domain, loc->bus, loc->devid, loc->function);
 
-	ret = vfio_setup_device(pci_get_sysfs_path(), pci_addr,
+	ret = vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
 					&vfio_dev_fd, &device_info);
 	if (ret)
 		return ret;
@@ -662,7 +662,7 @@  pci_vfio_unmap_resource(struct rte_pci_device *dev)
 		return -1;
 	}
 
-	ret = vfio_release_device(pci_get_sysfs_path(), pci_addr,
+	ret = vfio_release_device(rte_pci_get_sysfs_path(), pci_addr,
 				  dev->intr_handle.vfio_dev_fd);
 	if (ret < 0) {
 		RTE_LOG(ERR, EAL,
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 012420a9c..8b6a8bd88 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -59,7 +59,7 @@  extern struct rte_pci_bus rte_pci_bus;
 
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
-const char *pci_get_sysfs_path(void)
+const char *rte_pci_get_sysfs_path(void)
 {
 	const char *path = NULL;
 
diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index c0b619f29..d4a299641 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -60,7 +60,7 @@  extern "C" {
 #include <rte_pci.h>
 
 /** Pathname of PCI devices directory. */
-const char *pci_get_sysfs_path(void);
+const char *rte_pci_get_sysfs_path(void);
 
 /* Forward declarations */
 struct rte_pci_device;
diff --git a/drivers/bus/pci/rte_bus_pci_version.map b/drivers/bus/pci/rte_bus_pci_version.map
index ee67033b0..27e9c4f10 100644
--- a/drivers/bus/pci/rte_bus_pci_version.map
+++ b/drivers/bus/pci/rte_bus_pci_version.map
@@ -2,6 +2,7 @@  DPDK_17.11 {
 	global:
 
 	rte_pci_dump;
+	rte_pci_get_sysfs_path;
 	rte_pci_ioport_map;
 	rte_pci_ioport_read;
 	rte_pci_ioport_unmap;
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index c5486b72d..403cfdbb3 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1540,7 +1540,7 @@  rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 	snprintf(rsc_filename, PATH_MAX,
-		"%s/" PCI_PRI_FMT "/resource%u", pci_get_sysfs_path(),
+		"%s/" PCI_PRI_FMT "/resource%u", rte_pci_get_sysfs_path(),
 		pci_addr->domain, pci_addr->bus,
 		pci_addr->devid, pci_addr->function, PCI_RESOURCE_NUMBER);
 	fd = open(rsc_filename, O_RDWR);
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index b4d7cd93c..885892188 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -124,7 +124,6 @@  DPDK_16.04 {
 DPDK_16.07 {
 	global:
 
-	pci_get_sysfs_path;
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_rtm_supported;