9ae3a8
From 35510628e459d51b1ef6048bb307462a75ecf2d2 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <35510628e459d51b1ef6048bb307462a75ecf2d2.1387298827.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
9ae3a8
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
9ae3a8
From: "Michael S. Tsirkin" <mst@redhat.com>
9ae3a8
Date: Tue, 17 Dec 2013 15:18:04 +0100
9ae3a8
Subject: [PATCH 29/56] pcie_host: expose address format
9ae3a8
9ae3a8
RH-Author: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Message-id: <1387293161-4085-30-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 56335
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 29/57] pcie_host: expose address format
9ae3a8
Bugzilla: 1034876
9ae3a8
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
Callers pass in the address so it's helpful for
9ae3a8
them to be able to decode it.
9ae3a8
9ae3a8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
Tested-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
(cherry picked from commit 6f6d282330a3c85ecbeb54dec5b57282bd177b44)
9ae3a8
---
9ae3a8
 include/hw/pci/pcie_host.h | 21 +++++++++++++++++++++
9ae3a8
 hw/pci/pcie_host.c         | 21 ---------------------
9ae3a8
 2 files changed, 21 insertions(+), 21 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 hw/pci/pcie_host.c         | 21 ---------------------
9ae3a8
 include/hw/pci/pcie_host.h | 21 +++++++++++++++++++++
9ae3a8
 2 files changed, 21 insertions(+), 21 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
9ae3a8
index 0a78a8f..a6db258 100644
9ae3a8
--- a/hw/pci/pcie_host.c
9ae3a8
+++ b/hw/pci/pcie_host.c
9ae3a8
@@ -24,27 +24,6 @@
9ae3a8
 #include "hw/pci/pcie_host.h"
9ae3a8
 #include "exec/address-spaces.h"
9ae3a8
 
9ae3a8
-/*
9ae3a8
- * PCI express mmcfig address
9ae3a8
- * bit 20 - 28: bus number
9ae3a8
- * bit 15 - 19: device number
9ae3a8
- * bit 12 - 14: function number
9ae3a8
- * bit  0 - 11: offset in configuration space of a given device
9ae3a8
- */
9ae3a8
-#define PCIE_MMCFG_SIZE_MAX             (1ULL << 28)
9ae3a8
-#define PCIE_MMCFG_SIZE_MIN             (1ULL << 20)
9ae3a8
-#define PCIE_MMCFG_BUS_BIT              20
9ae3a8
-#define PCIE_MMCFG_BUS_MASK             0x1ff
9ae3a8
-#define PCIE_MMCFG_DEVFN_BIT            12
9ae3a8
-#define PCIE_MMCFG_DEVFN_MASK           0xff
9ae3a8
-#define PCIE_MMCFG_CONFOFFSET_MASK      0xfff
9ae3a8
-#define PCIE_MMCFG_BUS(addr)            (((addr) >> PCIE_MMCFG_BUS_BIT) & \
9ae3a8
-                                         PCIE_MMCFG_BUS_MASK)
9ae3a8
-#define PCIE_MMCFG_DEVFN(addr)          (((addr) >> PCIE_MMCFG_DEVFN_BIT) & \
9ae3a8
-                                         PCIE_MMCFG_DEVFN_MASK)
9ae3a8
-#define PCIE_MMCFG_CONFOFFSET(addr)     ((addr) & PCIE_MMCFG_CONFOFFSET_MASK)
9ae3a8
-
9ae3a8
-
9ae3a8
 /* a helper function to get a PCIDevice for a given mmconfig address */
9ae3a8
 static inline PCIDevice *pcie_dev_find_by_mmcfg_addr(PCIBus *s,
9ae3a8
                                                      uint32_t mmcfg_addr)
9ae3a8
diff --git a/include/hw/pci/pcie_host.h b/include/hw/pci/pcie_host.h
9ae3a8
index bac3c67..da0f275 100644
9ae3a8
--- a/include/hw/pci/pcie_host.h
9ae3a8
+++ b/include/hw/pci/pcie_host.h
9ae3a8
@@ -54,4 +54,25 @@ void pcie_host_mmcfg_update(PCIExpressHost *e,
9ae3a8
                             hwaddr addr,
9ae3a8
                             uint32_t size);
9ae3a8
 
9ae3a8
+/*
9ae3a8
+ * PCI express ECAM (Enhanced Configuration Address Mapping) format.
9ae3a8
+ * AKA mmcfg address
9ae3a8
+ * bit 20 - 28: bus number
9ae3a8
+ * bit 15 - 19: device number
9ae3a8
+ * bit 12 - 14: function number
9ae3a8
+ * bit  0 - 11: offset in configuration space of a given device
9ae3a8
+ */
9ae3a8
+#define PCIE_MMCFG_SIZE_MAX             (1ULL << 28)
9ae3a8
+#define PCIE_MMCFG_SIZE_MIN             (1ULL << 20)
9ae3a8
+#define PCIE_MMCFG_BUS_BIT              20
9ae3a8
+#define PCIE_MMCFG_BUS_MASK             0x1ff
9ae3a8
+#define PCIE_MMCFG_DEVFN_BIT            12
9ae3a8
+#define PCIE_MMCFG_DEVFN_MASK           0xff
9ae3a8
+#define PCIE_MMCFG_CONFOFFSET_MASK      0xfff
9ae3a8
+#define PCIE_MMCFG_BUS(addr)            (((addr) >> PCIE_MMCFG_BUS_BIT) & \
9ae3a8
+                                         PCIE_MMCFG_BUS_MASK)
9ae3a8
+#define PCIE_MMCFG_DEVFN(addr)          (((addr) >> PCIE_MMCFG_DEVFN_BIT) & \
9ae3a8
+                                         PCIE_MMCFG_DEVFN_MASK)
9ae3a8
+#define PCIE_MMCFG_CONFOFFSET(addr)     ((addr) & PCIE_MMCFG_CONFOFFSET_MASK)
9ae3a8
+
9ae3a8
 #endif /* PCIE_HOST_H */
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8