qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
	prem.mallappa@broadcom.com, peter.maydell@linaro.org,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	shannon.zhao@linaro.org
Cc: christoffer.dall@linaro.org, drjones@redhat.com, tn@semihalf.com
Subject: [Qemu-devel] [PATCH 2/2] ARM: Virt: ACPI: Build an IORT table with RC and ITS nodes
Date: Thu, 13 Oct 2016 12:55:43 +0200	[thread overview]
Message-ID: <1476356143-10577-3-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1476356143-10577-1-git-send-email-eric.auger@redhat.com>

From: Prem Mallappa <prem.mallappa@broadcom.com>

This patch builds an IORT table that features a root complex node and
an ITS node. This complements the ITS description in the ACPI MADT
table and allows vhost-net on ACPI guest.

Signed-off-by: Prem Mallappa <prem.mallappa@broadcom.com>
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 hw/arm/virt-acpi-build.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index fa0655a..373630a 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -384,6 +384,73 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset)
 }
 
 static void
+build_iort(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
+{
+    int iort_start = table_data->len;
+    AcpiIortTable *iort;
+    AcpiIortNode *iort_node;
+    AcpiIortItsGroup *its;
+    AcpiIortRC *rc;
+    AcpiIortIdMapping *idmap;
+    size_t node_size;
+
+    /* at the moment if there is no its, no need to build the IORT */
+    if (!its_class_name() || guest_info->no_its) {
+        return;
+    }
+
+    iort = acpi_data_push(table_data, sizeof(*iort));
+
+    iort->length = sizeof(*iort);
+    iort->node_offset = table_data->len - iort_start;
+
+    /* ITS group node featuring a single ITS identifier */
+    iort->node_count++;
+    node_size =  sizeof(*its) + sizeof(uint32_t);
+    its = acpi_data_push(table_data, node_size);
+
+    iort_node = &its->iort_node;
+    iort_node->type = ACPI_IORT_NODE_ITS_GROUP;
+    iort_node->length = node_size;
+    iort->length += iort_node->length;
+
+    iort_node->mapping_count = 0;  /* ITS groups do not have IDs */
+    iort_node->mapping_offset = 0; /* no ID array */
+    its->its_count = 1;            /* single ITS identifier */
+    its->identifiers[0] = 0;       /* ID = 0 as described in the MADT */
+
+    /* Root Complex Node with a single ID mapping*/
+    iort->node_count++;
+    node_size = sizeof(*rc) + sizeof(*idmap);
+    rc = acpi_data_push(table_data, node_size);
+
+    iort_node = &rc->iort_node;
+    iort_node->type = ACPI_IORT_NODE_PCI_ROOT_COMPLEX;
+    iort_node->length = node_size;
+    iort->length += iort_node->length;
+
+    iort_node->mapping_count = 1;
+    iort_node->mapping_offset = sizeof(*rc);
+
+    rc->memory_properties.cache_coherency = ACPI_IORT_NODE_COHERENT;
+    rc->memory_properties.hints = 0;
+    rc->memory_properties.memory_flags = 0;
+    rc->ats_attribute = 0;      /* does not support ATS */
+    rc->pci_segment_number = 0; /* MCFG _SEG */
+
+    /* fill array of ID mappings */
+    idmap = &rc->id_mapping_array[0];
+    idmap->input_base = 0;
+    idmap->id_count = 0xFFFF;
+    idmap->output_base = 0;
+    idmap->output_reference = iort->node_offset;
+    idmap->flags = 0;
+
+    build_header(linker, table_data, (void *)(table_data->data + iort_start),
+                 "IORT", table_data->len - iort_start, 0, NULL, NULL);
+}
+
+static void
 build_spcr(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
 {
     AcpiSerialPortConsoleRedirection *spcr;
@@ -676,6 +743,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
      * MADT
      * MCFG
      * DSDT
+     * IORT = ACPI 6.0
      */
 
     /* DSDT is pointed to by FADT */
@@ -703,6 +771,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
         build_srat(tables_blob, tables->linker, guest_info);
     }
 
+    acpi_add_table(table_offsets, tables_blob);
+    build_iort(tables_blob, tables->linker, guest_info);
+
     /* RSDT is pointed to by RSDP */
     rsdt = tables_blob->len;
     build_rsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
-- 
2.5.5

  parent reply	other threads:[~2016-10-13 10:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-13 10:55 [Qemu-devel] [PATCH 0/2] ACPI IORT generation for ITS support Eric Auger
2016-10-13 10:55 ` [Qemu-devel] [PATCH 1/2] ACPI: Add IORT Structure definition Eric Auger
2016-10-13 15:00   ` Andrew Jones
2016-10-13 17:12     ` Auger Eric
2016-10-13 10:55 ` Eric Auger [this message]
2016-10-13 15:11   ` [Qemu-devel] [PATCH 2/2] ARM: Virt: ACPI: Build an IORT table with RC and ITS nodes Andrew Jones
2016-10-14  8:24     ` Auger Eric
2016-10-13 12:02 ` [Qemu-devel] [PATCH 0/2] ACPI IORT generation for ITS support no-reply
2016-10-13 12:17   ` Auger Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476356143-10577-3-git-send-email-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=christoffer.dall@linaro.org \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=prem.mallappa@broadcom.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhao@linaro.org \
    --cc=tn@semihalf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).