diff mbox series

[v2,1/8] acpi: Add VIOT structure definitions

Message ID 20210903143208.2434284-2-jean-philippe@linaro.org
State New
Headers show
Series virtio-iommu: Add ACPI support | expand

Commit Message

Jean-Philippe Brucker Sept. 3, 2021, 2:32 p.m. UTC
The ACPI Virtual I/O Translation table (VIOT) table describes I/O
topology for paravirtual devices. At the moment it describes the
relation between virtio-iommu devices and their endpoints. Add the
structure definitions for VIOT.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

---
Following the latest spec draft, and related acpica change
https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf
https://github.com/acpica/acpica/commit/fc4e33319c1ee08f20f5c44853dd8426643f6dfd
---
 include/hw/acpi/acpi-defs.h | 60 +++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

-- 
2.33.0

Comments

Eric Auger Sept. 6, 2021, 12:44 p.m. UTC | #1
Hi Jean,

On 9/3/21 4:32 PM, Jean-Philippe Brucker wrote:
> The ACPI Virtual I/O Translation table (VIOT) table describes I/O

> topology for paravirtual devices. At the moment it describes the

> relation between virtio-iommu devices and their endpoints. Add the

> structure definitions for VIOT.


I don't think those additions are needed anymore. Looking at Igor's
conversions inĀ  [PATCH v2 00/35] acpi: refactor error prone
build_header() and packed structures usage in ACPI tables you will see
he removes them and hardcode the sizes/offsets in
hw/arm/virt-acpu-build.c and removes the associated structs. Even the
enum values are not used anymore which is arguable but this seems to be
the default style now. Anyway there are some structs like AcpiViotMmio
which are not used in this series. Thanks Eric
>

> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

> ---

> Following the latest spec draft, and related acpica change

> https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf

> https://github.com/acpica/acpica/commit/fc4e33319c1ee08f20f5c44853dd8426643f6dfd

> ---

>  include/hw/acpi/acpi-defs.h | 60 +++++++++++++++++++++++++++++++++++++

>  1 file changed, 60 insertions(+)

>

> diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h

> index cf9f44299c..adbf7d7b77 100644

> --- a/include/hw/acpi/acpi-defs.h

> +++ b/include/hw/acpi/acpi-defs.h

> @@ -618,4 +618,64 @@ struct AcpiIortRC {

>  } QEMU_PACKED;

>  typedef struct AcpiIortRC AcpiIortRC;

>  

> +/*

> + * Virtual I/O Translation Table

> + */

> +struct AcpiViot {

> +    ACPI_TABLE_HEADER_DEF

> +    uint16_t node_count;

> +    uint16_t node_offset;

> +    uint8_t reserved[8];

> +} QEMU_PACKED;

> +typedef struct AcpiViot AcpiViot;

> +

> +#define ACPI_VIOT_NODE_HEADER_DEF   /* Fields common to all nodes */ \

> +    uint8_t type;          \

> +    uint8_t reserved;      \

> +    uint16_t length;

> +

> +/* Values for node Type above */

> +enum {

> +    ACPI_VIOT_NODE_PCI_RANGE = 0x01,

> +    ACPI_VIOT_NODE_MMIO = 0x02,

> +    ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI = 0x03,

> +    ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO = 0x04,

> +};

> +

> +struct AcpiViotPciRange {

> +    ACPI_VIOT_NODE_HEADER_DEF

> +    uint32_t endpoint_start;

> +    uint16_t segment_start;

> +    uint16_t segment_end;

> +    uint16_t bdf_start;

> +    uint16_t bdf_end;

> +    uint16_t output_node;

> +    uint8_t reserved1[6];

> +} QEMU_PACKED;

> +typedef struct AcpiViotPciRange AcpiViotPciRange;

> +

> +struct AcpiViotMmio {

> +    ACPI_VIOT_NODE_HEADER_DEF

> +    uint32_t endpoint;

> +    uint64_t base_address;

> +    uint16_t output_node;

> +    uint8_t reserved1[6];

> +} QEMU_PACKED;

> +typedef struct AcpiViotMmio AcpiViotMmio;

> +

> +struct AcpiViotVirtioIommuPci {

> +    ACPI_VIOT_NODE_HEADER_DEF

> +    uint16_t segment;

> +    uint16_t bdf;

> +    uint8_t reserved1[8];

> +} QEMU_PACKED;

> +typedef struct AcpiViotVirtioIommuPci AcpiViotVirtioIommuPci;

> +

> +struct AcpiViotVirtioIommuMmio {

> +    ACPI_VIOT_NODE_HEADER_DEF

> +    uint8_t reserved1[4];

> +    uint64_t base_address;

> +} QEMU_PACKED;

> +typedef struct AcpiViotVirtioIommuMmio AcpiViotVirtioIommuMmio;

> +

>  #endif
diff mbox series

Patch

diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index cf9f44299c..adbf7d7b77 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -618,4 +618,64 @@  struct AcpiIortRC {
 } QEMU_PACKED;
 typedef struct AcpiIortRC AcpiIortRC;
 
+/*
+ * Virtual I/O Translation Table
+ */
+struct AcpiViot {
+    ACPI_TABLE_HEADER_DEF
+    uint16_t node_count;
+    uint16_t node_offset;
+    uint8_t reserved[8];
+} QEMU_PACKED;
+typedef struct AcpiViot AcpiViot;
+
+#define ACPI_VIOT_NODE_HEADER_DEF   /* Fields common to all nodes */ \
+    uint8_t type;          \
+    uint8_t reserved;      \
+    uint16_t length;
+
+/* Values for node Type above */
+enum {
+    ACPI_VIOT_NODE_PCI_RANGE = 0x01,
+    ACPI_VIOT_NODE_MMIO = 0x02,
+    ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI = 0x03,
+    ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO = 0x04,
+};
+
+struct AcpiViotPciRange {
+    ACPI_VIOT_NODE_HEADER_DEF
+    uint32_t endpoint_start;
+    uint16_t segment_start;
+    uint16_t segment_end;
+    uint16_t bdf_start;
+    uint16_t bdf_end;
+    uint16_t output_node;
+    uint8_t reserved1[6];
+} QEMU_PACKED;
+typedef struct AcpiViotPciRange AcpiViotPciRange;
+
+struct AcpiViotMmio {
+    ACPI_VIOT_NODE_HEADER_DEF
+    uint32_t endpoint;
+    uint64_t base_address;
+    uint16_t output_node;
+    uint8_t reserved1[6];
+} QEMU_PACKED;
+typedef struct AcpiViotMmio AcpiViotMmio;
+
+struct AcpiViotVirtioIommuPci {
+    ACPI_VIOT_NODE_HEADER_DEF
+    uint16_t segment;
+    uint16_t bdf;
+    uint8_t reserved1[8];
+} QEMU_PACKED;
+typedef struct AcpiViotVirtioIommuPci AcpiViotVirtioIommuPci;
+
+struct AcpiViotVirtioIommuMmio {
+    ACPI_VIOT_NODE_HEADER_DEF
+    uint8_t reserved1[4];
+    uint64_t base_address;
+} QEMU_PACKED;
+typedef struct AcpiViotVirtioIommuMmio AcpiViotVirtioIommuMmio;
+
 #endif