diff mbox

[V3,4/29] tools/libacpi: Add DMA remapping reporting (DMAR) ACPI table structures

Message ID 1506049330-11196-5-git-send-email-tianyu.lan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

lan,Tianyu Sept. 22, 2017, 3:01 a.m. UTC
From: Chao Gao <chao.gao@intel.com>

Add dmar table structure according Chapter 8 "BIOS Considerations" of
VTd spec Rev. 2.4.

VTd spec:http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf

Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 tools/libacpi/acpi2_0.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

Comments

Roger Pau Monné Oct. 18, 2017, 2:36 p.m. UTC | #1
On Thu, Sep 21, 2017 at 11:01:45PM -0400, Lan Tianyu wrote:
> From: Chao Gao <chao.gao@intel.com>
> 
> Add dmar table structure according Chapter 8 "BIOS Considerations" of
> VTd spec Rev. 2.4.
> 
> VTd spec:http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf
> 
> Signed-off-by: Chao Gao <chao.gao@intel.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
>  tools/libacpi/acpi2_0.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
> 
> diff --git a/tools/libacpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
> index 2619ba3..758a823 100644
> --- a/tools/libacpi/acpi2_0.h
> +++ b/tools/libacpi/acpi2_0.h
> @@ -422,6 +422,65 @@ struct acpi_20_slit {
>  };
>  
>  /*
> + * DMA Remapping Table header definition (DMAR)
> + */
> +
> +/*
> + * DMAR Flags.
> + */
> +#define ACPI_DMAR_INTR_REMAP        (1 << 0)
> +#define ACPI_DMAR_X2APIC_OPT_OUT    (1 << 1)
> +
> +struct acpi_dmar {
> +    struct acpi_header header;
> +    uint8_t host_address_width;
> +    uint8_t flags;
> +    uint8_t reserved[10];
> +};
> +
> +/*
> + * Device Scope Types
> + */
> +#define ACPI_DMAR_DEVICE_SCOPE_PCI_ENDPOINT             0x01
> +#define ACPI_DMAR_DEVICE_SCOPE_PCI_SUB_HIERARACHY       0x01
                                                           ^0x02
> +#define ACPI_DMAR_DEVICE_SCOPE_IOAPIC                   0x03
> +#define ACPI_DMAR_DEVICE_SCOPE_HPET                     0x04
> +#define ACPI_DMAR_DEVICE_SCOPE_ACPI_NAMESPACE_DEVICE    0x05

Maybe you could try to reduce the length of the defines?

> +
> +struct dmar_device_scope {
> +    uint8_t type;
> +    uint8_t length;
> +    uint8_t reserved[2];
> +    uint8_t enumeration_id;
> +    uint8_t bus;
> +    uint16_t path[0];
> +};
> +
> +/*
> + * DMA Remapping Hardware Unit Types
> + */
> +#define ACPI_DMAR_TYPE_HARDWARE_UNIT        0x00
> +#define ACPI_DMAR_TYPE_RESERVED_MEMORY      0x01
> +#define ACPI_DMAR_TYPE_ATSR                 0x02
> +#define ACPI_DMAR_TYPE_HARDWARE_AFFINITY    0x03
> +#define ACPI_DMAR_TYPE_ANDD                 0x04

I think you either use acronyms for all of them (like ATSR and ANDD)
or not. But mixing acronyms with full names is confusing.

Thanks, Roger.
lan,Tianyu Oct. 19, 2017, 6:46 a.m. UTC | #2
On 2017年10月18日 22:36, Roger Pau Monné wrote:
> On Thu, Sep 21, 2017 at 11:01:45PM -0400, Lan Tianyu wrote:
>> From: Chao Gao <chao.gao@intel.com>
>>
>> Add dmar table structure according Chapter 8 "BIOS Considerations" of
>> VTd spec Rev. 2.4.
>>
>> VTd spec:http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf
>>
>> Signed-off-by: Chao Gao <chao.gao@intel.com>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>>  tools/libacpi/acpi2_0.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 61 insertions(+)
>>
>> diff --git a/tools/libacpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
>> index 2619ba3..758a823 100644
>> --- a/tools/libacpi/acpi2_0.h
>> +++ b/tools/libacpi/acpi2_0.h
>> @@ -422,6 +422,65 @@ struct acpi_20_slit {
>>  };
>>  
>>  /*
>> + * DMA Remapping Table header definition (DMAR)
>> + */
>> +
>> +/*
>> + * DMAR Flags.
>> + */
>> +#define ACPI_DMAR_INTR_REMAP        (1 << 0)
>> +#define ACPI_DMAR_X2APIC_OPT_OUT    (1 << 1)
>> +
>> +struct acpi_dmar {
>> +    struct acpi_header header;
>> +    uint8_t host_address_width;
>> +    uint8_t flags;
>> +    uint8_t reserved[10];
>> +};
>> +
>> +/*
>> + * Device Scope Types
>> + */
>> +#define ACPI_DMAR_DEVICE_SCOPE_PCI_ENDPOINT             0x01
>> +#define ACPI_DMAR_DEVICE_SCOPE_PCI_SUB_HIERARACHY       0x01
>                                                            ^0x02
>> +#define ACPI_DMAR_DEVICE_SCOPE_IOAPIC                   0x03
>> +#define ACPI_DMAR_DEVICE_SCOPE_HPET                     0x04
>> +#define ACPI_DMAR_DEVICE_SCOPE_ACPI_NAMESPACE_DEVICE    0x05
> 
> Maybe you could try to reduce the length of the defines?

Sure. Will update.

> 
>> +
>> +struct dmar_device_scope {
>> +    uint8_t type;
>> +    uint8_t length;
>> +    uint8_t reserved[2];
>> +    uint8_t enumeration_id;
>> +    uint8_t bus;
>> +    uint16_t path[0];
>> +};
>> +
>> +/*
>> + * DMA Remapping Hardware Unit Types
>> + */
>> +#define ACPI_DMAR_TYPE_HARDWARE_UNIT        0x00
>> +#define ACPI_DMAR_TYPE_RESERVED_MEMORY      0x01
>> +#define ACPI_DMAR_TYPE_ATSR                 0x02
>> +#define ACPI_DMAR_TYPE_HARDWARE_AFFINITY    0x03
>> +#define ACPI_DMAR_TYPE_ANDD                 0x04
> 
> I think you either use acronyms for all of them (like ATSR and ANDD)
> or not. But mixing acronyms with full names is confusing.

OK. Will update.
diff mbox

Patch

diff --git a/tools/libacpi/acpi2_0.h b/tools/libacpi/acpi2_0.h
index 2619ba3..758a823 100644
--- a/tools/libacpi/acpi2_0.h
+++ b/tools/libacpi/acpi2_0.h
@@ -422,6 +422,65 @@  struct acpi_20_slit {
 };
 
 /*
+ * DMA Remapping Table header definition (DMAR)
+ */
+
+/*
+ * DMAR Flags.
+ */
+#define ACPI_DMAR_INTR_REMAP        (1 << 0)
+#define ACPI_DMAR_X2APIC_OPT_OUT    (1 << 1)
+
+struct acpi_dmar {
+    struct acpi_header header;
+    uint8_t host_address_width;
+    uint8_t flags;
+    uint8_t reserved[10];
+};
+
+/*
+ * Device Scope Types
+ */
+#define ACPI_DMAR_DEVICE_SCOPE_PCI_ENDPOINT             0x01
+#define ACPI_DMAR_DEVICE_SCOPE_PCI_SUB_HIERARACHY       0x01
+#define ACPI_DMAR_DEVICE_SCOPE_IOAPIC                   0x03
+#define ACPI_DMAR_DEVICE_SCOPE_HPET                     0x04
+#define ACPI_DMAR_DEVICE_SCOPE_ACPI_NAMESPACE_DEVICE    0x05
+
+struct dmar_device_scope {
+    uint8_t type;
+    uint8_t length;
+    uint8_t reserved[2];
+    uint8_t enumeration_id;
+    uint8_t bus;
+    uint16_t path[0];
+};
+
+/*
+ * DMA Remapping Hardware Unit Types
+ */
+#define ACPI_DMAR_TYPE_HARDWARE_UNIT        0x00
+#define ACPI_DMAR_TYPE_RESERVED_MEMORY      0x01
+#define ACPI_DMAR_TYPE_ATSR                 0x02
+#define ACPI_DMAR_TYPE_HARDWARE_AFFINITY    0x03
+#define ACPI_DMAR_TYPE_ANDD                 0x04
+
+/*
+ * DMA Remapping Hardware Unit Flags. All other bits are reserved and must be 0.
+ */
+#define ACPI_DMAR_INCLUDE_PCI_ALL   (1 << 0)
+
+struct acpi_dmar_hardware_unit {
+    uint16_t type;
+    uint16_t length;
+    uint8_t flags;
+    uint8_t reserved;
+    uint16_t pci_segment;
+    uint64_t base_address;
+    struct dmar_device_scope scope[0];
+};
+
+/*
  * Table Signatures.
  */
 #define ACPI_2_0_RSDP_SIGNATURE ASCII64('R','S','D',' ','P','T','R',' ')
@@ -435,6 +494,7 @@  struct acpi_20_slit {
 #define ACPI_2_0_WAET_SIGNATURE ASCII32('W','A','E','T')
 #define ACPI_2_0_SRAT_SIGNATURE ASCII32('S','R','A','T')
 #define ACPI_2_0_SLIT_SIGNATURE ASCII32('S','L','I','T')
+#define ACPI_2_0_DMAR_SIGNATURE ASCII32('D','M','A','R')
 
 /*
  * Table revision numbers.
@@ -449,6 +509,7 @@  struct acpi_20_slit {
 #define ACPI_1_0_FADT_REVISION 0x01
 #define ACPI_2_0_SRAT_REVISION 0x01
 #define ACPI_2_0_SLIT_REVISION 0x01
+#define ACPI_2_0_DMAR_REVISION 0x01
 
 #pragma pack ()