From 9450fcf3e1672968845ec840628cf3db04837afe Mon Sep 17 00:00:00 2001 From: Chenli Wei Date: Mon, 28 Feb 2022 16:41:14 +0800 Subject: [PATCH] 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 Signed-off-by: Chenli Wei --- misc/config_tools/schema/VMtypes.xsd | 32 ++++++++++++ misc/config_tools/schema/config.xsd | 14 +++--- .../service_vm_config/serial_config.py | 14 ------ misc/config_tools/static_allocators/bdf.py | 5 -- misc/config_tools/static_allocators/intx.py | 21 ++++++++ .../xforms/vm_configurations.c.xsl | 50 +++++++++++++++++++ 6 files changed, 110 insertions(+), 26 deletions(-) diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd index 2d76c43e0..dddb0a5dd 100644 --- a/misc/config_tools/schema/VMtypes.xsd +++ b/misc/config_tools/schema/VMtypes.xsd @@ -177,6 +177,38 @@ must exactly match the module tag in the GRUB multiboot cmdline. + + + vCOM type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vCOM type diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd index 0556711e6..4bf20ad6c 100644 --- a/misc/config_tools/schema/config.xsd +++ b/misc/config_tools/schema/config.xsd @@ -292,6 +292,12 @@ If this value is empty, then the default value will be calculated from informati + + + Specify the vUART connection setting. +Refer to :ref:`vuart_config` for detailed vUART settings. + + @@ -395,7 +401,7 @@ Refer SDM 17.19.2 for details, and use with caution. argument and memory. - + Specify the vUART (aka COM) with the vUART ID by its ``id`` attribute. Refer to :ref:`vuart_config` for detailed vUART settings. @@ -407,12 +413,6 @@ Refer to :ref:`vuart_config` for detailed vUART settings. its ``id`` attribute. - - - 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. - - MMIO resources to passthrough. diff --git a/misc/config_tools/service_vm_config/serial_config.py b/misc/config_tools/service_vm_config/serial_config.py index 455c63d43..d7eaf2b55 100644 --- a/misc/config_tools/service_vm_config/serial_config.py +++ b/misc/config_tools/service_vm_config/serial_config.py @@ -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") diff --git a/misc/config_tools/static_allocators/bdf.py b/misc/config_tools/static_allocators/bdf.py index 7952af473..005c9000f 100644 --- a/misc/config_tools/static_allocators/bdf.py +++ b/misc/config_tools/static_allocators/bdf.py @@ -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) diff --git a/misc/config_tools/static_allocators/intx.py b/misc/config_tools/static_allocators/intx.py index 9ca099200..b8316cfed 100644 --- a/misc/config_tools/static_allocators/intx.py +++ b/misc/config_tools/static_allocators/intx.py @@ -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) diff --git a/misc/config_tools/xforms/vm_configurations.c.xsl b/misc/config_tools/xforms/vm_configurations.c.xsl index 9d27617c1..001b0e592 100644 --- a/misc/config_tools/xforms/vm_configurations.c.xsl +++ b/misc/config_tools/xforms/vm_configurations.c.xsl @@ -103,6 +103,7 @@ + @@ -264,6 +265,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + }, + + + +