mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-17 00:41:30 +00:00
misc: refine vuart connection
We have redesign the vuart and the UI for user, so the config tool should change the schema and xform for the new xml, then change the static_allocators to alloc irq and io_port for new connection. This patch add a new vuart connection type and change the xforms to adapter the new type. Tracked-On: #6690 Reviewed-by: Junjie Mao <junjie.mao@intel.com> Signed-off-by: Chenli Wei <chenli.wei@linux.intel.com>
This commit is contained in:
parent
c4c7835c12
commit
9450fcf3e1
@ -177,6 +177,38 @@ must exactly match the module tag in the GRUB multiboot cmdline.</xs:documentati
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="VuartType">
|
||||
<xs:annotation>
|
||||
<xs:documentation>vCOM type</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="legacy" />
|
||||
<xs:enumeration value="pci" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:complexType name="VuartEndpointType">
|
||||
<xs:sequence>
|
||||
<xs:element name="vm_name" type="xs:string"/>
|
||||
<xs:element name="io_port" type="HexFormat" default="0x3F" />
|
||||
<xs:element name="vbdf" type="VBDFType" minOccurs="0" maxOccurs="1" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="VuartConnectionType">
|
||||
<xs:sequence>
|
||||
<xs:element name="name" type="xs:string" />
|
||||
<xs:element name="type" type="VuartType" default="legacy" />
|
||||
<xs:element name="endpoint" type="VuartEndpointType" minOccurs="2" maxOccurs="2" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="VuartConnectionsType">
|
||||
<xs:sequence>
|
||||
<xs:element name="vuart_connection" type="VuartConnectionType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:simpleType name="LegacyVuartType">
|
||||
<xs:annotation acrn:configurable="n">
|
||||
<xs:documentation>vCOM type</xs:documentation>
|
||||
|
@ -292,6 +292,12 @@ If this value is empty, then the default value will be calculated from informati
|
||||
<xs:element name="MEMORY" type="MemoryOptionsType" />
|
||||
<xs:element name="CAPACITIES" type="CapacitiesOptionsType" />
|
||||
<xs:element name="MISC_CFG" type="MiscCfgOptionsType" />
|
||||
<xs:element name="vuart_connections" type="VuartConnectionsType" minOccurs="0" maxOccurs="8">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specify the vUART connection setting.
|
||||
Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
@ -395,7 +401,7 @@ Refer SDM 17.19.2 for details, and use with caution.</xs:documentation>
|
||||
argument and memory.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="legacy_vuart" type="LegacyVuartConfiguration" minOccurs="2" maxOccurs="8">
|
||||
<xs:element name="legacy_vuart" type="LegacyVuartConfiguration" minOccurs="1" maxOccurs="8">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specify the vUART (aka COM) with the vUART ID by its ``id`` attribute.
|
||||
Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
|
||||
@ -407,12 +413,6 @@ Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
|
||||
its ``id`` attribute.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="communication_vuart" type="CommunicationVuartConfiguration" maxOccurs="unbounded">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Specify the communication vUART (aka PCI based vUART) with the vUART ID by
|
||||
its ``id`` attribute. When it is enabled, specify which target VM's vUART the current VM connects to.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="mmio_resources" type="MMIOResourcesConfiguration" minOccurs="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>MMIO resources to passthrough.</xs:documentation>
|
||||
|
@ -37,20 +37,6 @@ def main(args):
|
||||
user_vm_id = legacy_vuart.find('target_vm_id').text
|
||||
legacy_vuartid = int(legacy_vuart.attrib["id"])
|
||||
vuart_target_vmid[legacy_vuartid] = user_vm_id
|
||||
|
||||
vm_list = allocation_etree.xpath("//vm[load_order = 'SERVICE_VM']")
|
||||
for vm in vm_list:
|
||||
vuart_list = find_non_standard_uart(vm)
|
||||
if len(vuart_list) != 0:
|
||||
with open(args.out, "w+") as config_f:
|
||||
for uart_start_num, vuart in enumerate(vuart_list, start=START_VUART_DEV_NAME_NO):
|
||||
base = " port " + vuart.find('base').text
|
||||
vuart_id = int(vuart.attrib["id"])
|
||||
vm_id_note = "# User_VM_id: " + str(vuart_target_vmid[vuart_id]) + '\n'
|
||||
config_f.write(vm_id_note)
|
||||
conf = "/dev/ttyS" + str(uart_start_num) + base + UART_IRQ_BAUD + '\n'
|
||||
config_f.write(conf)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--allocation", help="the XML file summarizing resource allocated by config tool")
|
||||
|
@ -27,15 +27,10 @@ def find_unused_bdf(used_bdf):
|
||||
|
||||
def insert_vuart_to_dev_dict(scenario_etree, devdict, used):
|
||||
console_vuart = scenario_etree.xpath(f"./console_vuart[base != 'INVALID_PCI_BASE']/@id")
|
||||
communication_vuarts = scenario_etree.xpath(f".//communication_vuart[base != 'INVALID_PCI_BASE']/@id")
|
||||
for vuart_id in console_vuart:
|
||||
free_bdf = find_unused_bdf(used)
|
||||
devdict[f"{VUART}_{vuart_id}"] = free_bdf
|
||||
used.append(free_bdf)
|
||||
for vuart_id in communication_vuarts:
|
||||
free_bdf = find_unused_bdf(used)
|
||||
devdict[f"{VUART}_{vuart_id}"] = free_bdf
|
||||
used.append(free_bdf)
|
||||
|
||||
def insert_ivsheme_to_dev_dict(scenario_etree, devdict, vm_id, used):
|
||||
shmem_regions = lib.lib.get_ivshmem_regions_by_tree(scenario_etree)
|
||||
|
@ -95,6 +95,26 @@ def alloc_legacy_vuart_irqs(board_etree, scenario_etree, allocation_etree):
|
||||
|
||||
create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, legacy_vuart_id, legacy_vuart_irq)
|
||||
|
||||
def alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree):
|
||||
native_ttys = lib.lib.get_native_ttys()
|
||||
hv_debug_console = lib.lib.parse_hv_console(scenario_etree)
|
||||
|
||||
vm_node_list = scenario_etree.xpath("//vm")
|
||||
for vm_node in vm_node_list:
|
||||
load_order = common.get_node("./load_order/text()", vm_node)
|
||||
irq_list = get_native_valid_irq() if load_order == "SERVICE_VM" else [f"{d}" for d in list(range(1,15))]
|
||||
vuart_id = '1'
|
||||
vmname = common.get_node("./name/text()", vm_node)
|
||||
vuart_connections = scenario_etree.xpath("//vuart_connection")
|
||||
for connection in vuart_connections:
|
||||
endpoint_list = connection.xpath(".//endpoint")
|
||||
for endpoint in endpoint_list:
|
||||
vm_name = common.get_node("./vm_name/text()",endpoint)
|
||||
if vm_name == vmname:
|
||||
legacy_vuart_irq = alloc_irq(irq_list)
|
||||
create_vuart_irq_node(allocation_etree, common.get_node("./@id", vm_node), load_order, vuart_id, legacy_vuart_irq)
|
||||
vuart_id = str(int(vuart_id) + 1)
|
||||
|
||||
def get_irqs_of_device(device_node):
|
||||
irqs = set()
|
||||
|
||||
@ -231,4 +251,5 @@ def alloc_device_irqs(board_etree, scenario_etree, allocation_etree):
|
||||
|
||||
def fn(board_etree, scenario_etree, allocation_etree):
|
||||
alloc_legacy_vuart_irqs(board_etree, scenario_etree, allocation_etree)
|
||||
alloc_vuart_connection_irqs(board_etree, scenario_etree, allocation_etree)
|
||||
alloc_device_irqs(board_etree, scenario_etree, allocation_etree)
|
||||
|
@ -103,6 +103,7 @@
|
||||
<xsl:apply-templates select="os_config" />
|
||||
<xsl:call-template name="acpi_config" />
|
||||
<xsl:call-template name="legacy_vuart" />
|
||||
<xsl:call-template name="vuart_connection" />
|
||||
<xsl:call-template name="pci_dev_num" />
|
||||
<xsl:call-template name="pci_devs" />
|
||||
<xsl:if test="acrn:is-pre-launched-vm(load_order)">
|
||||
@ -264,6 +265,55 @@
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="vuart_connection">
|
||||
<xsl:variable name="vm_id" select="@id" />
|
||||
<xsl:variable name="vmname" select="name/text()" />
|
||||
<xsl:for-each select="//vuart_connection[endpoint/vm_name = $vmname]">
|
||||
<xsl:variable name="connection_name" select="name/text()" />
|
||||
<xsl:variable name="type" select="type/text()" />
|
||||
<xsl:variable name="vuart_id" select="position()"/>
|
||||
<xsl:value-of select="acrn:initializer(concat('vuart[', $vuart_id, ']'), '{', true())" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$type = 'legacy'">
|
||||
<xsl:value-of select="acrn:initializer('type', 'VUART_LEGACY_PIO')" />
|
||||
</xsl:when>
|
||||
<xsl:when test="$type = 'pci'">
|
||||
<xsl:value-of select="acrn:initializer('type', 'VUART_PCI')" />
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="acrn:initializer('irq', concat(//allocation-data/acrn-config/vm[@id=$vm_id]/legacy_vuart[@id=$vuart_id]/irq, 'U'))" />
|
||||
<xsl:for-each select="endpoint">
|
||||
<xsl:choose>
|
||||
<xsl:when test="vm_name = $vmname">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$type = 'legacy'">
|
||||
<xsl:value-of select="acrn:initializer('addr.port_base', concat(io_port, 'U'))" />
|
||||
</xsl:when>
|
||||
<xsl:when test="$type = 'pci'">
|
||||
<xsl:variable name="b" select="substring-before(vbdf/text(), ':')" />
|
||||
<xsl:variable name="d" select="substring-before(substring-after(vbdf/text(), ':'), '.')" />
|
||||
<xsl:variable name="f" select="substring-after(vbdf/text(), '.')" />
|
||||
<xsl:value-of select="acrn:initializer('addr.bdf', concat('{', $b, ', ', $d, ', ', $f, '}'))" />
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="target_name" select="vm_name" />
|
||||
<xsl:value-of select="acrn:initializer('t_vuart.vm_id', concat(//vm[name = $target_name]/@id, 'U'))" />
|
||||
<xsl:for-each select="//vuart_connection[endpoint/vm_name = $target_name]">
|
||||
<xsl:variable name="uart_num" select="position()"/>
|
||||
<xsl:if test="name = $connection_name">
|
||||
<xsl:value-of select="acrn:initializer('t_vuart.vuart_id', concat($uart_num, 'U'))" />
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
<xsl:text>},</xsl:text>
|
||||
<xsl:value-of select="$newline" />
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="pci_dev_num">
|
||||
<xsl:choose>
|
||||
<xsl:when test="acrn:is-service-vm(load_order)">
|
||||
|
Loading…
Reference in New Issue
Block a user