[07/14] pci: define some BAR constants

Message ID 20230803075038.307012-8-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Cleanup PCI(e) drivers |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Aug. 3, 2023, 7:50 a.m. UTC
  Define some PCI BAR constants and use them in existing drivers.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/pci/linux/pci_vfio.c | 7 +++----
 lib/pci/rte_pci.h                | 4 ++++
 2 files changed, 7 insertions(+), 4 deletions(-)
  

Comments

Bruce Richardson Aug. 3, 2023, 9:58 a.m. UTC | #1
On Thu, Aug 03, 2023 at 09:50:30AM +0200, David Marchand wrote:
> Define some PCI BAR constants and use them in existing drivers.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  

Patch

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index f96b3ce7fb..c2e3d2f4b5 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -5,7 +5,6 @@ 
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
-#include <linux/pci_regs.h>
 #include <sys/eventfd.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
@@ -430,14 +429,14 @@  pci_vfio_is_ioport_bar(const struct rte_pci_device *dev, int vfio_dev_fd,
 	}
 
 	ret = pread64(vfio_dev_fd, &ioport_bar, sizeof(ioport_bar),
-			  offset + PCI_BASE_ADDRESS_0 + bar_index * 4);
+			  offset + RTE_PCI_BASE_ADDRESS_0 + bar_index * 4);
 	if (ret != sizeof(ioport_bar)) {
 		RTE_LOG(ERR, EAL, "Cannot read command (%x) from config space!\n",
-			PCI_BASE_ADDRESS_0 + bar_index*4);
+			RTE_PCI_BASE_ADDRESS_0 + bar_index*4);
 		return -1;
 	}
 
-	return (ioport_bar & PCI_BASE_ADDRESS_SPACE_IO) != 0;
+	return (ioport_bar & RTE_PCI_BASE_ADDRESS_SPACE_IO) != 0;
 }
 
 static int
diff --git a/lib/pci/rte_pci.h b/lib/pci/rte_pci.h
index bf2b2639f4..429904cff9 100644
--- a/lib/pci/rte_pci.h
+++ b/lib/pci/rte_pci.h
@@ -43,6 +43,10 @@  extern "C" {
 #define RTE_PCI_STATUS		0x06	/* 16 bits */
 #define RTE_PCI_STATUS_CAP_LIST	0x10	/* Support Capability List */
 
+/* Base addresses */
+#define RTE_PCI_BASE_ADDRESS_0		0x10	/* 32 bits */
+#define RTE_PCI_BASE_ADDRESS_SPACE_IO	0x01
+
 /* Capability registers */
 #define RTE_PCI_CAPABILITY_LIST	0x34	/* Offset of first capability list entry */
 #define RTE_PCI_CAP_ID_PM	0x01	/* Power Management */