From patchwork Fri Jun 23 18:20:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Verkamp X-Patchwork-Id: 25665 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EA429292D; Fri, 23 Jun 2017 20:20:42 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 999FB1C0B for ; Fri, 23 Jun 2017 20:20:41 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 23 Jun 2017 11:20:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,379,1493708400"; d="scan'208";a="118145084" Received: from dverkamp-desk2.ch.intel.com ([143.182.137.94]) by fmsmga005.fm.intel.com with ESMTP; 23 Jun 2017 11:20:40 -0700 From: Daniel Verkamp To: dev@dpdk.org Cc: Stephen Hemminger , Daniel Verkamp Date: Fri, 23 Jun 2017 11:20:32 -0700 Message-Id: <20170623182032.28734-1-daniel.verkamp@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170623172941.14423-1-daniel.verkamp@intel.com> References: <20170623172941.14423-1-daniel.verkamp@intel.com> Subject: [dpdk-dev] [PATCH v2] pci: pad vendor and device ID to 4 digits 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 PCI vendor and device IDs have leading zeros. Signed-off-by: Daniel Verkamp --- 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