[1/2] pci: rename catch-all ID

Message ID 20210331223423.2089467-2-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series pci: add rte prefix |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon March 31, 2021, 10:34 p.m. UTC
  The name of the constant PCI_ANY_ID was missing RTE_ prefix.
It is renamed, and the old name becomes a deprecated alias.

While renaming, the duplicate definitions in rte_bus_pci.h
are removed to keep only those in rte_pci.h.
Note: rte_pci.h is included in rte_bus_pci.h

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/bus/pci/pci_common.c  |  8 ++++----
 drivers/bus/pci/rte_bus_pci.h | 12 ++++--------
 lib/librte_pci/rte_pci.h      | 12 +++++++-----
 3 files changed, 15 insertions(+), 17 deletions(-)
  

Comments

David Marchand April 1, 2021, 7:58 a.m. UTC | #1
On Thu, Apr 1, 2021 at 12:34 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> @@ -95,7 +95,9 @@ struct rte_pci_addr {
>  };
>
>  /** Any PCI device identifier (vendor, device, ...) */
> -#define PCI_ANY_ID (0xffff)
> +#define RTE_PCI_ANY_ID (0xffff)
> +/** @deprecated Replaced with RTE_PCI_ANY_ID */
> +#define PCI_ANY_ID RTE_PCI_ANY_ID

We may also tag it for applications to notice the deprecation:

#define PCI_ANY_ID RTE_DEPRECATED(PCI_ANY_ID) RTE_PCI_ANY_ID


>  #define RTE_CLASS_ANY_ID (0xffffff)
>
>  /**
  
Thomas Monjalon April 1, 2021, 8:15 a.m. UTC | #2
01/04/2021 09:58, David Marchand:
> On Thu, Apr 1, 2021 at 12:34 AM Thomas Monjalon <thomas@monjalon.net> wrote:
> > @@ -95,7 +95,9 @@ struct rte_pci_addr {
> >  };
> >
> >  /** Any PCI device identifier (vendor, device, ...) */
> > -#define PCI_ANY_ID (0xffff)
> > +#define RTE_PCI_ANY_ID (0xffff)
> > +/** @deprecated Replaced with RTE_PCI_ANY_ID */
> > +#define PCI_ANY_ID RTE_PCI_ANY_ID
> 
> We may also tag it for applications to notice the deprecation:
> 
> #define PCI_ANY_ID RTE_DEPRECATED(PCI_ANY_ID) RTE_PCI_ANY_ID

Yes, I forgot this macro, thanks.
  
Parav Pandit April 5, 2021, 10:42 a.m. UTC | #3
> From: dev <dev-bounces@dpdk.org> On Behalf Of Thomas Monjalon
> Sent: Thursday, April 1, 2021 4:04 AM
> 
> The name of the constant PCI_ANY_ID was missing RTE_ prefix.
> It is renamed, and the old name becomes a deprecated alias.
> 
> While renaming, the duplicate definitions in rte_bus_pci.h are removed to
> keep only those in rte_pci.h.
> Note: rte_pci.h is included in rte_bus_pci.h
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  drivers/bus/pci/pci_common.c  |  8 ++++----  drivers/bus/pci/rte_bus_pci.h |
> 12 ++++--------
>  lib/librte_pci/rte_pci.h      | 12 +++++++-----
>  3 files changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
> index 9b8d769287..ee7f966358 100644
> --- a/drivers/bus/pci/pci_common.c
> +++ b/drivers/bus/pci/pci_common.c
> @@ -133,18 +133,18 @@ rte_pci_match(const struct rte_pci_driver
> *pci_drv,
>  	     id_table++) {
>  		/* check if device's identifiers match the driver's ones */
>  		if (id_table->vendor_id != pci_dev->id.vendor_id &&
> -				id_table->vendor_id != PCI_ANY_ID)
> +				id_table->vendor_id != RTE_PCI_ANY_ID)
>  			continue;
>  		if (id_table->device_id != pci_dev->id.device_id &&
> -				id_table->device_id != PCI_ANY_ID)
> +				id_table->device_id != RTE_PCI_ANY_ID)
>  			continue;
>  		if (id_table->subsystem_vendor_id !=
>  		    pci_dev->id.subsystem_vendor_id &&
> -		    id_table->subsystem_vendor_id != PCI_ANY_ID)
> +		    id_table->subsystem_vendor_id != RTE_PCI_ANY_ID)
>  			continue;
>  		if (id_table->subsystem_device_id !=
>  		    pci_dev->id.subsystem_device_id &&
> -		    id_table->subsystem_device_id != PCI_ANY_ID)
> +		    id_table->subsystem_device_id != RTE_PCI_ANY_ID)
>  			continue;
>  		if (id_table->class_id != pci_dev->id.class_id &&
>  				id_table->class_id != RTE_CLASS_ANY_ID) diff
> --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index
> 876abddefb..3a092bc6d5 100644
> --- a/drivers/bus/pci/rte_bus_pci.h
> +++ b/drivers/bus/pci/rte_bus_pci.h
> @@ -91,26 +91,22 @@ struct rte_pci_device {
> 
>  #define RTE_ETH_DEV_TO_PCI(eth_dev)	RTE_DEV_TO_PCI((eth_dev)-
> >device)
> 
> -/** Any PCI device identifier (vendor, device, ...) */ -#define PCI_ANY_ID
> (0xffff) -#define RTE_CLASS_ANY_ID (0xffffff)
> -
>  #ifdef __cplusplus
>  /** C++ macro used to help building up tables of device IDs */  #define
> RTE_PCI_DEVICE(vend, dev) \
>  	RTE_CLASS_ANY_ID,         \
>  	(vend),                   \
>  	(dev),                    \
> -	PCI_ANY_ID,               \
> -	PCI_ANY_ID
> +	RTE_PCI_ANY_ID,           \
> +	RTE_PCI_ANY_ID
>  #else
>  /** Macro used to help building up tables of device IDs */
>  #define RTE_PCI_DEVICE(vend, dev)          \
>  	.class_id = RTE_CLASS_ANY_ID,      \
>  	.vendor_id = (vend),               \
>  	.device_id = (dev),                \
> -	.subsystem_vendor_id = PCI_ANY_ID, \
> -	.subsystem_device_id = PCI_ANY_ID
> +	.subsystem_vendor_id = RTE_PCI_ANY_ID, \
> +	.subsystem_device_id = RTE_PCI_ANY_ID
>  #endif
> 
>  /**
> diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h index
> f89c7dbbea..ed3196a368 100644
> --- a/lib/librte_pci/rte_pci.h
> +++ b/lib/librte_pci/rte_pci.h
> @@ -78,10 +78,10 @@ extern "C" {
>   */
>  struct rte_pci_id {
>  	uint32_t class_id;            /**< Class ID or RTE_CLASS_ANY_ID. */
> -	uint16_t vendor_id;           /**< Vendor ID or PCI_ANY_ID. */
> -	uint16_t device_id;           /**< Device ID or PCI_ANY_ID. */
> -	uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or
> PCI_ANY_ID. */
> -	uint16_t subsystem_device_id; /**< Subsystem device ID or
> PCI_ANY_ID. */
> +	uint16_t vendor_id;           /**< Vendor ID or RTE_PCI_ANY_ID. */
> +	uint16_t device_id;           /**< Device ID or RTE_PCI_ANY_ID. */
> +	uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or
> RTE_PCI_ANY_ID. */
> +	uint16_t subsystem_device_id; /**< Subsystem device ID or
> +RTE_PCI_ANY_ID. */
>  };
> 
>  /**
> @@ -95,7 +95,9 @@ struct rte_pci_addr {
>  };
> 
>  /** Any PCI device identifier (vendor, device, ...) */ -#define PCI_ANY_ID
> (0xffff)
> +#define RTE_PCI_ANY_ID (0xffff)
> +/** @deprecated Replaced with RTE_PCI_ANY_ID */ #define PCI_ANY_ID
> +RTE_PCI_ANY_ID
>  #define RTE_CLASS_ANY_ID (0xffffff)
> 
>  /**
> --
> 2.30.1

Reviewed-by: Parav Pandit <parav@nvidia.com>
  

Patch

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 9b8d769287..ee7f966358 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -133,18 +133,18 @@  rte_pci_match(const struct rte_pci_driver *pci_drv,
 	     id_table++) {
 		/* check if device's identifiers match the driver's ones */
 		if (id_table->vendor_id != pci_dev->id.vendor_id &&
-				id_table->vendor_id != PCI_ANY_ID)
+				id_table->vendor_id != RTE_PCI_ANY_ID)
 			continue;
 		if (id_table->device_id != pci_dev->id.device_id &&
-				id_table->device_id != PCI_ANY_ID)
+				id_table->device_id != RTE_PCI_ANY_ID)
 			continue;
 		if (id_table->subsystem_vendor_id !=
 		    pci_dev->id.subsystem_vendor_id &&
-		    id_table->subsystem_vendor_id != PCI_ANY_ID)
+		    id_table->subsystem_vendor_id != RTE_PCI_ANY_ID)
 			continue;
 		if (id_table->subsystem_device_id !=
 		    pci_dev->id.subsystem_device_id &&
-		    id_table->subsystem_device_id != PCI_ANY_ID)
+		    id_table->subsystem_device_id != RTE_PCI_ANY_ID)
 			continue;
 		if (id_table->class_id != pci_dev->id.class_id &&
 				id_table->class_id != RTE_CLASS_ANY_ID)
diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index 876abddefb..3a092bc6d5 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -91,26 +91,22 @@  struct rte_pci_device {
 
 #define RTE_ETH_DEV_TO_PCI(eth_dev)	RTE_DEV_TO_PCI((eth_dev)->device)
 
-/** Any PCI device identifier (vendor, device, ...) */
-#define PCI_ANY_ID (0xffff)
-#define RTE_CLASS_ANY_ID (0xffffff)
-
 #ifdef __cplusplus
 /** C++ macro used to help building up tables of device IDs */
 #define RTE_PCI_DEVICE(vend, dev) \
 	RTE_CLASS_ANY_ID,         \
 	(vend),                   \
 	(dev),                    \
-	PCI_ANY_ID,               \
-	PCI_ANY_ID
+	RTE_PCI_ANY_ID,           \
+	RTE_PCI_ANY_ID
 #else
 /** Macro used to help building up tables of device IDs */
 #define RTE_PCI_DEVICE(vend, dev)          \
 	.class_id = RTE_CLASS_ANY_ID,      \
 	.vendor_id = (vend),               \
 	.device_id = (dev),                \
-	.subsystem_vendor_id = PCI_ANY_ID, \
-	.subsystem_device_id = PCI_ANY_ID
+	.subsystem_vendor_id = RTE_PCI_ANY_ID, \
+	.subsystem_device_id = RTE_PCI_ANY_ID
 #endif
 
 /**
diff --git a/lib/librte_pci/rte_pci.h b/lib/librte_pci/rte_pci.h
index f89c7dbbea..ed3196a368 100644
--- a/lib/librte_pci/rte_pci.h
+++ b/lib/librte_pci/rte_pci.h
@@ -78,10 +78,10 @@  extern "C" {
  */
 struct rte_pci_id {
 	uint32_t class_id;            /**< Class ID or RTE_CLASS_ANY_ID. */
-	uint16_t vendor_id;           /**< Vendor ID or PCI_ANY_ID. */
-	uint16_t device_id;           /**< Device ID or PCI_ANY_ID. */
-	uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */
-	uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */
+	uint16_t vendor_id;           /**< Vendor ID or RTE_PCI_ANY_ID. */
+	uint16_t device_id;           /**< Device ID or RTE_PCI_ANY_ID. */
+	uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or RTE_PCI_ANY_ID. */
+	uint16_t subsystem_device_id; /**< Subsystem device ID or RTE_PCI_ANY_ID. */
 };
 
 /**
@@ -95,7 +95,9 @@  struct rte_pci_addr {
 };
 
 /** Any PCI device identifier (vendor, device, ...) */
-#define PCI_ANY_ID (0xffff)
+#define RTE_PCI_ANY_ID (0xffff)
+/** @deprecated Replaced with RTE_PCI_ANY_ID */
+#define PCI_ANY_ID RTE_PCI_ANY_ID
 #define RTE_CLASS_ANY_ID (0xffffff)
 
 /**