diff mbox series

[RFC,v1,2/5] xen/public: arch-arm: reserve resources for virtio-pci

Message ID 20231127072754.4045254-3-Sergiy_Kibrik@epam.com (mailing list archive)
State New, archived
Headers show
Series ARM virtio-pci initial support | expand

Commit Message

Sergiy Kibrik Nov. 27, 2023, 7:27 a.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

In order to enable more use-cases such as having multiple
device-models (Qemu) running in different backend domains which provide
virtio-pci devices for the same guest, we allocate and expose one
PCI host bridge for every virtio backend domain for that guest.

For that purpose we reserve separate virtio-pci resources (memory and SPI range
for Legacy PCI interrupts) for up to 8 possible PCI host bridges
(to be aligned with MAX_NR_IOREQ_SERVERS) and allocate one host bridge per
backend domain. We'll need at most 32 interrupts (INTA..INTD legacy PCI
interrupts per each of 8 host bridges), and at most 32MB of memory
(since as it was observed virtio-pci devices use up to 16KB each, this can
be different for physical PCI devices ofc).

The details of PCI host bridge (including its host_id)
are to be written to dedicated Xenstore node for the device-model to retrieve.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
---
 xen/include/public/arch-arm.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index a25e87dbda..caa4e92b55 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -466,6 +466,28 @@  typedef uint64_t xen_callback_t;
 #define GUEST_VPCI_MEM_ADDR                 xen_mk_ullong(0x23000000)
 #define GUEST_VPCI_MEM_SIZE                 xen_mk_ullong(0x10000000)
 
+/*
+ * 8 MB is reserved for virtio-pci configuration space based on calculation
+ * 8 bridges x 32 devices x 8 functions x 4 KB = 8 MB
+ */
+#define GUEST_VIRTIO_PCI_ECAM_BASE          xen_mk_ullong(0x33000000)
+#define GUEST_VIRTIO_PCI_TOTAL_ECAM_SIZE    xen_mk_ullong(0x00800000)
+#define GUEST_VIRTIO_PCI_HOST_ECAM_SIZE     xen_mk_ullong(0x00100000)
+
+/* 32 MB is reserved for virtio-pci memory based on calculation
+ * 8 bridges x 32 devices x 8 functions x 16 KB per virtio-pci device = 32 MB
+ */
+#define GUEST_VIRTIO_PCI_ADDR_TYPE_MEM    xen_mk_ullong(0x02000000)
+#define GUEST_VIRTIO_PCI_MEM_ADDR         xen_mk_ullong(0x33800000)
+#define GUEST_VIRTIO_PCI_MEM_SIZE         xen_mk_ullong(0x02000000)
+
+/* 32 MB is reserved for virtio-pci Prefetch memory based on calculation
+ * 8 bridges x 32 devices x 8 functions x 16 KB per virtio-pci device = 32 MB
+ */
+#define GUEST_VIRTIO_PCI_ADDR_TYPE_PREFETCH_MEM    xen_mk_ullong(0x42000000)
+#define GUEST_VIRTIO_PCI_PREFETCH_MEM_ADDR         xen_mk_ullong(0x35800000)
+#define GUEST_VIRTIO_PCI_PREFETCH_MEM_SIZE         xen_mk_ullong(0x02000000)
+
 /*
  * 16MB == 4096 pages reserved for guest to use as a region to map its
  * grant table in.
@@ -515,6 +537,10 @@  typedef uint64_t xen_callback_t;
 #define GUEST_VIRTIO_MMIO_SPI_FIRST   33
 #define GUEST_VIRTIO_MMIO_SPI_LAST    43
 
+/* 8 bridges x 4 #INTA..#INTD interrupts = 32 SPIs to reserve for virtio-pci */
+#define GUEST_VIRTIO_PCI_SPI_FIRST   44
+#define GUEST_VIRTIO_PCI_SPI_LAST    76
+
 /* PSCI functions */
 #define PSCI_cpu_suspend 0
 #define PSCI_cpu_off     1