DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] pci: pad vendor and device ID to 4 digits
@ 2017-06-23 17:29 Daniel Verkamp
  2017-06-23 17:44 ` Stephen Hemminger
  2017-06-23 18:20 ` [dpdk-dev] [PATCH v2] " Daniel Verkamp
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Verkamp @ 2017-06-23 17:29 UTC (permalink / raw)
  To: dev; +Cc: Daniel Verkamp

Some PCI vendor and device IDs have leading zeros.

Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
---
 lib/librte_eal/common/eal_common_pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 78b097e..c23421f 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -203,7 +203,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 		return 1;
 	}
 
-	RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
+	RTE_LOG(INFO, EAL, "  probe driver: %04x:%04x %s\n", dev->id.vendor_id,
 		dev->id.device_id, dr->driver.name);
 
 	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
@@ -253,7 +253,7 @@ rte_pci_detach_dev(struct rte_pci_device *dev)
 			loc->domain, loc->bus, loc->devid,
 			loc->function, dev->device.numa_node);
 
-	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
+	RTE_LOG(DEBUG, EAL, "  remove driver: %04x:%04x %s\n", dev->id.vendor_id,
 			dev->id.device_id, dr->driver.name);
 
 	if (dr->remove && (dr->remove(dev) < 0))
@@ -427,7 +427,7 @@ pci_dump_one_device(FILE *f, struct rte_pci_device *dev)
 
 	fprintf(f, PCI_PRI_FMT, dev->addr.domain, dev->addr.bus,
 	       dev->addr.devid, dev->addr.function);
-	fprintf(f, " - vendor:%x device:%x\n", dev->id.vendor_id,
+	fprintf(f, " - vendor:%04x device:%04x\n", dev->id.vendor_id,
 	       dev->id.device_id);
 
 	for (i = 0; i != sizeof(dev->mem_resource) /
-- 
2.9.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] pci: pad vendor and device ID to 4 digits
  2017-06-23 17:29 [dpdk-dev] [PATCH] pci: pad vendor and device ID to 4 digits Daniel Verkamp
@ 2017-06-23 17:44 ` Stephen Hemminger
  2017-06-23 18:20 ` [dpdk-dev] [PATCH v2] " Daniel Verkamp
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2017-06-23 17:44 UTC (permalink / raw)
  To: Daniel Verkamp; +Cc: dev

On Fri, 23 Jun 2017 10:29:41 -0700
Daniel Verkamp <daniel.verkamp@intel.com> wrote:

> Some PCI vendor and device IDs have leading zeros.
> 
> Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
> ---
>  lib/librte_eal/common/eal_common_pci.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
> index 78b097e..c23421f 100644
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -203,7 +203,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
>  		return 1;
>  	}
>  
> -	RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
> +	RTE_LOG(INFO, EAL, "  probe driver: %04x:%04x %s\n", dev->id.vendor_id,
>  		dev->id.device_id, dr->driver.name);
>  
>  	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
> @@ -253,7 +253,7 @@ rte_pci_detach_dev(struct rte_pci_device *dev)
>  			loc->domain, loc->bus, loc->devid,
>  			loc->function, dev->device.numa_node);
>  
> -	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
> +	RTE_LOG(DEBUG, EAL, "  remove driver: %04x:%04x %s\n", dev->id.vendor_id,
>  			dev->id.device_id, dr->driver.name);
>  
>  	if (dr->remove && (dr->remove(dev) < 0))
> @@ -427,7 +427,7 @@ pci_dump_one_device(FILE *f, struct rte_pci_device *dev)
>  
>  	fprintf(f, PCI_PRI_FMT, dev->addr.domain, dev->addr.bus,
>  	       dev->addr.devid, dev->addr.function);
> -	fprintf(f, " - vendor:%x device:%x\n", dev->id.vendor_id,
> +	fprintf(f, " - vendor:%04x device:%04x\n", dev->id.vendor_id,
>  	       dev->id.device_id);
>  
>  	for (i = 0; i != sizeof(dev->mem_resource) /

It would be better to use a format consistent with PCI_PRI_FMT, as in:
	RTE_LOG(DEBUG, EAL, "  remove driver: %.4" PRIx16 ":%.4" PRIx16 " %s\n",

Maybe introduce PCI_VENDOR_FMT
#define PCI_VENDOR_FMT   "%.4" PRIx16 ":%.4" PRIx16

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] pci: pad vendor and device ID to 4 digits
  2017-06-23 17:29 [dpdk-dev] [PATCH] pci: pad vendor and device ID to 4 digits Daniel Verkamp
  2017-06-23 17:44 ` Stephen Hemminger
@ 2017-06-23 18:20 ` Daniel Verkamp
  2017-07-05 13:16   ` Thomas Monjalon
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Verkamp @ 2017-06-23 18:20 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Daniel Verkamp

Some PCI vendor and device IDs have leading zeros.

Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
---

v2: added #define for format string, use %.4 style and PRIx16

 lib/librte_eal/common/eal_common_pci.c  | 8 ++++----
 lib/librte_eal/common/include/rte_pci.h | 3 +++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 78b097e..7924509 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -203,8 +203,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 		return 1;
 	}
 
-	RTE_LOG(INFO, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
-		dev->id.device_id, dr->driver.name);
+	RTE_LOG(INFO, EAL, "  probe driver: " PCI_ID_PRI_FMT " %s\n",
+		dev->id.vendor_id, dev->id.device_id, dr->driver.name);
 
 	if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
 		/* map resources for devices that use igb_uio */
@@ -253,8 +253,8 @@ rte_pci_detach_dev(struct rte_pci_device *dev)
 			loc->domain, loc->bus, loc->devid,
 			loc->function, dev->device.numa_node);
 
-	RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
-			dev->id.device_id, dr->driver.name);
+	RTE_LOG(DEBUG, EAL, "  remove driver: " PCI_ID_PRI_FMT " %s\n",
+			dev->id.vendor_id, dev->id.device_id, dr->driver.name);
 
 	if (dr->remove && (dr->remove(dev) < 0))
 		return -1;	/* negative value is an error */
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 0284a62..66edccb 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -68,6 +68,9 @@ const char *pci_get_sysfs_path(void);
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
 
+/** Formatting string for PCI vendor and device ID: Ex: 1234:5678 */
+#define PCI_ID_PRI_FMT "%.4" PRIx16 ":%.4" PRIx16
+
 /** Nb. of values in PCI device identifier format string. */
 #define PCI_FMT_NVAL 4
 
-- 
2.9.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] pci: pad vendor and device ID to 4 digits
  2017-06-23 18:20 ` [dpdk-dev] [PATCH v2] " Daniel Verkamp
@ 2017-07-05 13:16   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-07-05 13:16 UTC (permalink / raw)
  To: Daniel Verkamp; +Cc: dev, Stephen Hemminger

23/06/2017 20:20, Daniel Verkamp:
> Some PCI vendor and device IDs have leading zeros.
> 
> Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
> ---
> --- a/lib/librte_eal/common/include/rte_pci.h
> +++ b/lib/librte_eal/common/include/rte_pci.h
> @@ -68,6 +68,9 @@ const char *pci_get_sysfs_path(void);
>  /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
>  #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
>  
> +/** Formatting string for PCI vendor and device ID: Ex: 1234:5678 */
> +#define PCI_ID_PRI_FMT "%.4" PRIx16 ":%.4" PRIx16

Why not printing the whole PCI infos with domain and function?

Note: public macros should be prefixed with RTE_

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-05 13:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-23 17:29 [dpdk-dev] [PATCH] pci: pad vendor and device ID to 4 digits Daniel Verkamp
2017-06-23 17:44 ` Stephen Hemminger
2017-06-23 18:20 ` [dpdk-dev] [PATCH v2] " Daniel Verkamp
2017-07-05 13:16   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).