mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 05:30:24 +00:00
acrn-config: support to parse pci_devs for pre launched vm
As it doesn't depends on the scenario, there are sos/pre launched VMS in config xmls, emulate vhostbridge for sos vm, specify the pass-thru PCI device for pre launched vm. Add support to parse pci_devs for pre launched vm. Tracked-On: #4641 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com> Acked-by: Terry Zou <terry.zou@intel.com>
This commit is contained in:
parent
8fbd859fbf
commit
eba8c23bff
@ -49,18 +49,18 @@ class AvailablePthru():
|
|||||||
return self.bdf_vpid_map
|
return self.bdf_vpid_map
|
||||||
|
|
||||||
def get_pci_dev(self):
|
def get_pci_dev(self):
|
||||||
self.avl["usb_xdci"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['usb_xdci'])
|
self.avl["usb_xdci"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['usb_xdci'])
|
||||||
self.avl["ipu"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu'])
|
self.avl["ipu"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu'])
|
||||||
self.avl["ipu_i2c"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu_i2c'])
|
self.avl["ipu_i2c"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu_i2c'])
|
||||||
self.avl["cse"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['cse'])
|
self.avl["cse"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['cse'])
|
||||||
self.avl["audio"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio'])
|
self.avl["audio"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio'])
|
||||||
self.avl["audio_codec"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio_codec'])
|
self.avl["audio_codec"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio_codec'])
|
||||||
self.avl["sd_card"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sd_card'])
|
self.avl["sd_card"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sd_card'])
|
||||||
self.avl["wifi"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['wifi'])
|
self.avl["wifi"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['wifi'])
|
||||||
self.avl["ethernet"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ethernet'])
|
self.avl["ethernet"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ethernet'])
|
||||||
self.avl["sata"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sata'])
|
self.avl["sata"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sata'])
|
||||||
self.avl["nvme"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['nvme'])
|
self.avl["nvme"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['nvme'])
|
||||||
self.avl["bluetooth"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['bluetooth'])
|
self.avl["bluetooth"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['bluetooth'])
|
||||||
|
|
||||||
def insert_nun(self):
|
def insert_nun(self):
|
||||||
self.avl["usb_xdci"].insert(0, '')
|
self.avl["usb_xdci"].insert(0, '')
|
||||||
|
@ -19,7 +19,7 @@ PY_CACHES = ["__pycache__", "../board_config/__pycache__", "../scenario_config/_
|
|||||||
GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTHROUGH",
|
GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTHROUGH",
|
||||||
"GUEST_FLAG_IO_COMPLETION_POLLING", "GUEST_FLAG_HIDE_MTRR", "GUEST_FLAG_RT"]
|
"GUEST_FLAG_IO_COMPLETION_POLLING", "GUEST_FLAG_HIDE_MTRR", "GUEST_FLAG_RT"]
|
||||||
|
|
||||||
MULTI_ITEM = ["guest_flag", "pcpu_id", "vcpu_clos", "input", "block", "network"]
|
MULTI_ITEM = ["guest_flag", "pcpu_id", "vcpu_clos", "input", "block", "network", "pci_dev"]
|
||||||
|
|
||||||
SIZE_K = 1024
|
SIZE_K = 1024
|
||||||
SIZE_M = SIZE_K * 1024
|
SIZE_M = SIZE_K * 1024
|
||||||
@ -43,6 +43,7 @@ class MultiItem():
|
|||||||
self.vir_block = []
|
self.vir_block = []
|
||||||
self.vir_console = []
|
self.vir_console = []
|
||||||
self.vir_network = []
|
self.vir_network = []
|
||||||
|
self.pci_dev = []
|
||||||
|
|
||||||
class TmpItem():
|
class TmpItem():
|
||||||
|
|
||||||
@ -255,7 +256,6 @@ def get_leaf_value(tmp, tag_str, leaf):
|
|||||||
# get guest flag for logical partition vm1
|
# get guest flag for logical partition vm1
|
||||||
if leaf.tag == "guest_flag" and tag_str == "guest_flag":
|
if leaf.tag == "guest_flag" and tag_str == "guest_flag":
|
||||||
t_flag = find_tmp_flag(leaf.text)
|
t_flag = find_tmp_flag(leaf.text)
|
||||||
#print("--debug: tag:{},{}".format(tag_str), t_flag)
|
|
||||||
tmp.multi.guest_flag.append(t_flag)
|
tmp.multi.guest_flag.append(t_flag)
|
||||||
|
|
||||||
# get cpu for vm
|
# get cpu for vm
|
||||||
@ -278,6 +278,10 @@ def get_leaf_value(tmp, tag_str, leaf):
|
|||||||
if leaf.tag == "network" and tag_str == "network":
|
if leaf.tag == "network" and tag_str == "network":
|
||||||
tmp.multi.vir_network.append(leaf.text)
|
tmp.multi.vir_network.append(leaf.text)
|
||||||
|
|
||||||
|
# get pci_dev for vm
|
||||||
|
if leaf.tag == "pci_dev" and tag_str == "pci_dev":
|
||||||
|
tmp.multi.pci_dev.append(leaf.text)
|
||||||
|
|
||||||
|
|
||||||
def get_sub_value(tmp, tag_str, vm_id):
|
def get_sub_value(tmp, tag_str, vm_id):
|
||||||
|
|
||||||
@ -305,6 +309,10 @@ def get_sub_value(tmp, tag_str, vm_id):
|
|||||||
if tmp.multi.vir_network and tag_str == "network":
|
if tmp.multi.vir_network and tag_str == "network":
|
||||||
tmp.tag[vm_id] = tmp.multi.vir_network
|
tmp.tag[vm_id] = tmp.multi.vir_network
|
||||||
|
|
||||||
|
# append pci_dev for vm
|
||||||
|
if tmp.multi.pci_dev and tag_str == "pci_dev":
|
||||||
|
tmp.tag[vm_id] = tmp.multi.pci_dev
|
||||||
|
|
||||||
|
|
||||||
def get_leaf_tag_map(config_file, branch_tag, tag_str=''):
|
def get_leaf_tag_map(config_file, branch_tag, tag_str=''):
|
||||||
"""
|
"""
|
||||||
@ -421,3 +429,15 @@ def num2int(str_value):
|
|||||||
def get_vm_types():
|
def get_vm_types():
|
||||||
global VM_TYPES
|
global VM_TYPES
|
||||||
VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "load_order")
|
VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "load_order")
|
||||||
|
|
||||||
|
|
||||||
|
def get_avl_dev_info(bdf_desc_map, pci_sub_class):
|
||||||
|
|
||||||
|
tmp_pci_desc = []
|
||||||
|
for sub_class in pci_sub_class:
|
||||||
|
for pci_desc_value in bdf_desc_map.values():
|
||||||
|
pci_desc_sub_class = ' '.join(pci_desc_value.strip().split(':')[1].split()[1:])
|
||||||
|
if sub_class == pci_desc_sub_class:
|
||||||
|
tmp_pci_desc.append(pci_desc_value.strip())
|
||||||
|
|
||||||
|
return tmp_pci_desc
|
||||||
|
@ -184,18 +184,6 @@ def get_post_vm_cnt():
|
|||||||
return (launch_vm_count, post_vm_count)
|
return (launch_vm_count, post_vm_count)
|
||||||
|
|
||||||
|
|
||||||
def get_avl_dev_info(bdf_desc_map, pci_sub_class):
|
|
||||||
|
|
||||||
tmp_pci_desc = []
|
|
||||||
for sub_class in pci_sub_class:
|
|
||||||
for pci_desc_value in bdf_desc_map.values():
|
|
||||||
pci_desc_sub_class = ' '.join(pci_desc_value.strip().split(':')[1].split()[1:])
|
|
||||||
if sub_class == pci_desc_sub_class:
|
|
||||||
tmp_pci_desc.append(pci_desc_value.strip())
|
|
||||||
|
|
||||||
return tmp_pci_desc
|
|
||||||
|
|
||||||
|
|
||||||
def is_config_file_match():
|
def is_config_file_match():
|
||||||
|
|
||||||
match = True
|
match = True
|
||||||
|
@ -25,8 +25,6 @@ AVALIBLE_COM2_BASE = ['INVALID_COM_BASE', 'COM2_BASE']
|
|||||||
VUART_IRQ = ['SOS_COM1_IRQ', 'SOS_COM2_IRQ', 'COM1_IRQ', 'COM2_IRQ', 'COM3_IRQ',
|
VUART_IRQ = ['SOS_COM1_IRQ', 'SOS_COM2_IRQ', 'COM1_IRQ', 'COM2_IRQ', 'COM3_IRQ',
|
||||||
'COM4_IRQ', 'CONFIG_COM_IRQ', '3', '4', '6', '7']
|
'COM4_IRQ', 'CONFIG_COM_IRQ', '3', '4', '6', '7']
|
||||||
|
|
||||||
PCI_DEV_NUM_LIST = ['SOS_EMULATED_PCI_DEV_NUM', 'VM0_CONFIG_PCI_DEV_NUM', 'VM1_CONFIG_PCI_DEV_NUM']
|
|
||||||
PCI_DEVS_LIST = ['sos_pci_devs', 'vm0_pci_devs', 'vm1_pci_devs']
|
|
||||||
# Support 512M, 1G, 2G
|
# Support 512M, 1G, 2G
|
||||||
# pre launch less then 2G, sos vm less than 24G
|
# pre launch less then 2G, sos vm less than 24G
|
||||||
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE']
|
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE']
|
||||||
@ -36,6 +34,43 @@ COMMUNICATE_VM_ID = []
|
|||||||
ERR_LIST = {}
|
ERR_LIST = {}
|
||||||
|
|
||||||
KATA_VM_COUNT = 0
|
KATA_VM_COUNT = 0
|
||||||
|
PT_SUB_PCI = {}
|
||||||
|
PT_SUB_PCI['ethernet'] = ['Ethernet controller', 'Network controller', '802.1a controller',
|
||||||
|
'802.1b controller', 'Wireless controller']
|
||||||
|
PT_SUB_PCI['sata'] = ['SATA controller']
|
||||||
|
PT_SUB_PCI['nvme'] = ['Non-Volatile memory controller']
|
||||||
|
|
||||||
|
|
||||||
|
def get_pci_devs(pci_items):
|
||||||
|
|
||||||
|
pci_devs = {}
|
||||||
|
for vm_i,pci_descs in pci_items.items():
|
||||||
|
bdf_list = []
|
||||||
|
for pci_des in pci_descs:
|
||||||
|
if not pci_des:
|
||||||
|
continue
|
||||||
|
bdf = pci_des.split()[0]
|
||||||
|
bdf_list.append(bdf)
|
||||||
|
|
||||||
|
pci_devs[vm_i] = bdf_list
|
||||||
|
|
||||||
|
return pci_devs
|
||||||
|
|
||||||
|
|
||||||
|
def get_pci_num(pci_devs):
|
||||||
|
|
||||||
|
pci_devs_num = {}
|
||||||
|
for vm_i,pci_devs_list in pci_devs.items():
|
||||||
|
# vhostbridge
|
||||||
|
cnt_dev = 1
|
||||||
|
for pci_dev in pci_devs_list:
|
||||||
|
if not pci_dev:
|
||||||
|
continue
|
||||||
|
cnt_dev += 1
|
||||||
|
|
||||||
|
pci_devs_num[vm_i] = cnt_dev
|
||||||
|
|
||||||
|
return pci_devs_num
|
||||||
|
|
||||||
|
|
||||||
def check_board_private_info():
|
def check_board_private_info():
|
||||||
@ -362,37 +397,18 @@ def os_kern_root_dev_check(id_kern_rootdev_dic, prime_item, item):
|
|||||||
ERR_LIST[key] = "VM os config kernel root device should not empty"
|
ERR_LIST[key] = "VM os config kernel root device should not empty"
|
||||||
|
|
||||||
|
|
||||||
def pci_dev_num_check(id_dev_num_dic, item):
|
def pci_devs_check(pci_bdf_devs, branch_tag, tag_str):
|
||||||
"""
|
|
||||||
Check vm pci device number
|
|
||||||
:param item: vm pci_dev_num item in xml
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
|
|
||||||
for vm_i,vm_type in common.VM_TYPES.items():
|
|
||||||
if vm_i not in id_dev_num_dic.keys():
|
|
||||||
continue
|
|
||||||
pci_dev_num = id_dev_num_dic[vm_i]
|
|
||||||
if vm_type != "POST_LAUNCHED_VM" and pci_dev_num:
|
|
||||||
if pci_dev_num not in PCI_DEV_NUM_LIST:
|
|
||||||
key = "vm:id={},{}".format(vm_i, item)
|
|
||||||
ERR_LIST[key] = "VM pci device number shoud be one of {}".format(PCI_DEV_NUM_LIST)
|
|
||||||
|
|
||||||
def pci_devs_check(id_devs_dic, item):
|
|
||||||
"""
|
"""
|
||||||
Check vm pci devices
|
Check vm pci devices
|
||||||
:param item: vm pci_devs item in xml
|
:param item: vm pci_devs item in xml
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
(bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(common.BOARD_INFO_FILE)
|
||||||
for vm_i,vm_type in common.VM_TYPES.items():
|
for id_key, pci_bdf_devs_list in pci_bdf_devs.items():
|
||||||
if vm_i not in id_devs_dic.keys():
|
for pci_bdf_dev in pci_bdf_devs_list:
|
||||||
continue
|
if pci_bdf_dev and pci_bdf_dev not in bdf_desc_map.keys():
|
||||||
pci_dev = id_devs_dic[vm_i]
|
key = "vm:id={},{},{}".format(id_key, branch_tag, tag_str)
|
||||||
if vm_type != "POST_LAUNCHED_VM" and pci_dev:
|
ERR_LIST[key] = "The {} is unkonw device of PCI".format(pci_bdf_dev)
|
||||||
if pci_dev not in PCI_DEVS_LIST:
|
|
||||||
key = "vm:id={},{}".format(vm_i, item)
|
|
||||||
ERR_LIST[key] = "VM pci device shoud be one of {}".format(PCI_DEVS_LIST)
|
|
||||||
|
|
||||||
|
|
||||||
def get_vuart1_vmid(vm_vuart1):
|
def get_vuart1_vmid(vm_vuart1):
|
||||||
@ -497,3 +513,48 @@ def get_first_post_vm():
|
|||||||
break
|
break
|
||||||
|
|
||||||
return (err_dic, i)
|
return (err_dic, i)
|
||||||
|
|
||||||
|
|
||||||
|
def avl_pci_devs():
|
||||||
|
|
||||||
|
pci_dev_list = []
|
||||||
|
(bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(common.BOARD_INFO_FILE)
|
||||||
|
pci_dev_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['ethernet'])
|
||||||
|
tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['sata'])
|
||||||
|
pci_dev_list.extend(tmp_pci_list)
|
||||||
|
tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['nvme'])
|
||||||
|
pci_dev_list.extend(tmp_pci_list)
|
||||||
|
|
||||||
|
return pci_dev_list
|
||||||
|
|
||||||
|
|
||||||
|
def check_vuart(v0_vuart, v1_vuart):
|
||||||
|
|
||||||
|
vm_target_id_dic = {}
|
||||||
|
for vm_i,vuart_dic in v1_vuart.items():
|
||||||
|
# check target vm id
|
||||||
|
if 'base' not in vuart_dic.keys():
|
||||||
|
key = "vm:id={},vuart:id=1,base".format(vm_i)
|
||||||
|
ERR_LIST[key] = "base should be in xml"
|
||||||
|
return
|
||||||
|
|
||||||
|
if not vuart_dic['base'] or vuart_dic['base'] not in VUART_BASE:
|
||||||
|
key = "vm:id={},vuart:id=1,base".format(vm_i)
|
||||||
|
ERR_LIST[key] = "base should be SOS/COM BASE"
|
||||||
|
|
||||||
|
if vuart_dic['base'] == "INVALID_COM_BASE":
|
||||||
|
continue
|
||||||
|
|
||||||
|
if 'target_vm_id' not in vuart_dic.keys():
|
||||||
|
key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
|
||||||
|
ERR_LIST[key] = "target_vm_id should be in xml"
|
||||||
|
|
||||||
|
if not vuart_dic['target_vm_id'] or not vuart_dic['target_vm_id'].isnumeric():
|
||||||
|
key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
|
||||||
|
ERR_LIST[key] = "target_vm_id should be numeric of vm id"
|
||||||
|
vm_target_id_dic[vm_i] = vuart_dic['target_vm_id']
|
||||||
|
|
||||||
|
for vm_i,t_vm_id in vm_target_id_dic.items():
|
||||||
|
if t_vm_id.isnumeric() and int(t_vm_id) not in common.VM_TYPES.keys():
|
||||||
|
key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
|
||||||
|
ERR_LIST[key] = "target_vm_id which specified does not exist"
|
||||||
|
@ -9,7 +9,7 @@ import scenario_cfg_lib
|
|||||||
PCI_DEV_TYPE = ['PCI_DEV_TYPE_HVEMUL', 'PCI_DEV_TYPE_PTDEV']
|
PCI_DEV_TYPE = ['PCI_DEV_TYPE_HVEMUL', 'PCI_DEV_TYPE_PTDEV']
|
||||||
|
|
||||||
|
|
||||||
def generate_file(config):
|
def generate_file(vm_info, config):
|
||||||
"""
|
"""
|
||||||
Generate pci_dev.c while logical_partition scenario
|
Generate pci_dev.c while logical_partition scenario
|
||||||
:param config: it is pointer for for file write to
|
:param config: it is pointer for for file write to
|
||||||
@ -29,27 +29,31 @@ def generate_file(config):
|
|||||||
print(" * The memory range of vBAR should exactly match with the e820 layout of VM.",
|
print(" * The memory range of vBAR should exactly match with the e820 layout of VM.",
|
||||||
file=config)
|
file=config)
|
||||||
print(" */", file=config)
|
print(" */", file=config)
|
||||||
for i in list(common.VM_TYPES.keys()):
|
for vm_i, pci_bdf_devs_list in vm_info.cfg_pci.pci_devs.items():
|
||||||
|
pci_cnt = 1
|
||||||
|
if not pci_bdf_devs_list:
|
||||||
|
continue
|
||||||
|
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
print("struct acrn_vm_pci_dev_config " +
|
print("struct acrn_vm_pci_dev_config " +
|
||||||
"vm{}_pci_devs[VM{}_CONFIG_PCI_DEV_NUM] = {{".format(i, i), file=config)
|
"vm{}_pci_devs[{}] = {{".format(vm_i, vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
|
||||||
print("\t{", file=config)
|
print("\t{", file=config)
|
||||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[0]), file=config)
|
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[0]), file=config)
|
||||||
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},", file=config)
|
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},", file=config)
|
||||||
print("\t\t.vdev_ops = &vhostbridge_ops,", file=config)
|
print("\t\t.vdev_ops = &vhostbridge_ops,", file=config)
|
||||||
print("\t},", file=config)
|
print("\t},", file=config)
|
||||||
print("\t{", file=config)
|
|
||||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
|
for pci_bdf_dev in pci_bdf_devs_list:
|
||||||
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U},", file=config)
|
if not pci_bdf_dev:
|
||||||
print("\t\tVM{}_STORAGE_CONTROLLER".format(i), file=config)
|
continue
|
||||||
print("\t},", file=config)
|
bus = int(pci_bdf_dev.split(':')[0], 16)
|
||||||
if i != 0:
|
dev = int(pci_bdf_dev.split(':')[1].split('.')[0], 16)
|
||||||
print("#if defined(VM{}_NETWORK_CONTROLLER)".format(i), file=config)
|
fun = int(pci_bdf_dev.split('.')[1], 16)
|
||||||
print("\t{", file=config)
|
print("\t{", file=config)
|
||||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
|
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
|
||||||
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U},", file=config)
|
print("\t\t.vbdf.bits = {{.b = 0x00U, .d = 0x0{}U, .f = 0x00U}},".format(pci_cnt), file=config)
|
||||||
print("\t\tVM{}_NETWORK_CONTROLLER".format(i), file=config)
|
print("\t\t.pbdf.bits = {{.b = 0x{:02X}U, .d = 0x{:02X}U, .f = 0x{:02X}U}},".format(bus, dev, fun), file=config)
|
||||||
print("\t},", file=config)
|
print("\t},", file=config)
|
||||||
if i != 0:
|
pci_cnt += 1
|
||||||
print("#endif", file=config)
|
|
||||||
print("};", file=config)
|
print("};", file=config)
|
||||||
|
@ -47,6 +47,7 @@ def get_scenario_item_values(board_info, scenario_info):
|
|||||||
scenario_item_values["vm,guest_flags"] = guest_flags
|
scenario_item_values["vm,guest_flags"] = guest_flags
|
||||||
scenario_item_values["vm,clos"] = hw_info.get_clos_val()
|
scenario_item_values["vm,clos"] = hw_info.get_clos_val()
|
||||||
scenario_item_values["vm,severity"] = scenario_cfg_lib.VM_SEVERITY
|
scenario_item_values["vm,severity"] = scenario_cfg_lib.VM_SEVERITY
|
||||||
|
scenario_item_values["vm,pci_devs,pci_dev"] = scenario_cfg_lib.avl_pci_devs()
|
||||||
scenario_item_values["vm,os_config,kern_type"] = scenario_cfg_lib.KERN_TYPE_LIST
|
scenario_item_values["vm,os_config,kern_type"] = scenario_cfg_lib.KERN_TYPE_LIST
|
||||||
scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
|
scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))
|
||||||
|
|
||||||
@ -185,9 +186,11 @@ def main(args):
|
|||||||
return err_dic
|
return err_dic
|
||||||
|
|
||||||
# generate pci_dev.c
|
# generate pci_dev.c
|
||||||
if scenario_items['vm'].load_order_cnt.pre_vm >= 2:
|
for vm_i,pci_dev_num in scenario_items['vm'].cfg_pci.pci_dev_num.items():
|
||||||
with open(pci_config_c, 'w') as config:
|
if pci_dev_num >= 2:
|
||||||
pci_dev_c.generate_file(config)
|
with open(pci_config_c, 'w') as config:
|
||||||
|
pci_dev_c.generate_file(scenario_items['vm'], config)
|
||||||
|
break
|
||||||
|
|
||||||
if not err_dic:
|
if not err_dic:
|
||||||
print("Scenario configurations for {} is generated successfully.".format(scenario))
|
print("Scenario configurations for {} is generated successfully.".format(scenario))
|
||||||
|
@ -142,8 +142,14 @@ class VuartInfo:
|
|||||||
"""
|
"""
|
||||||
self.v0_vuart = board_cfg_lib.get_vuart_info_id(self.scenario_info, 0)
|
self.v0_vuart = board_cfg_lib.get_vuart_info_id(self.scenario_info, 0)
|
||||||
self.v1_vuart = board_cfg_lib.get_vuart_info_id(self.scenario_info, 1)
|
self.v1_vuart = board_cfg_lib.get_vuart_info_id(self.scenario_info, 1)
|
||||||
scenario_cfg_lib.check_board_private_info()
|
|
||||||
|
|
||||||
|
def check_item(self):
|
||||||
|
"""
|
||||||
|
Check all items in this class
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
scenario_cfg_lib.check_board_private_info()
|
||||||
|
scenario_cfg_lib.check_vuart(self.v0_vuart, self.v1_vuart)
|
||||||
|
|
||||||
class MemInfo:
|
class MemInfo:
|
||||||
""" This is Abstract of class of memory setting information """
|
""" This is Abstract of class of memory setting information """
|
||||||
@ -193,14 +199,15 @@ class CfgPci:
|
|||||||
Get pci device number items
|
Get pci device number items
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.pci_dev_num = common.get_leaf_tag_map(self.scenario_info, "pci_dev_num")
|
self.pci_dev_num = scenario_cfg_lib.get_pci_num(self.pci_devs)
|
||||||
|
|
||||||
def get_pci_devs(self):
|
def get_pci_devs(self):
|
||||||
"""
|
"""
|
||||||
Get pci devices items
|
Get pci devices items
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.pci_devs = common.get_leaf_tag_map(self.scenario_info, "pci_devs")
|
pci_items = common.get_leaf_tag_map(self.scenario_info, "pci_devs", "pci_dev")
|
||||||
|
self.pci_devs = scenario_cfg_lib.get_pci_devs(pci_items)
|
||||||
|
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
@ -208,15 +215,14 @@ class CfgPci:
|
|||||||
Get all items which belong to this class
|
Get all items which belong to this class
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.get_pci_dev_num()
|
|
||||||
self.get_pci_devs()
|
self.get_pci_devs()
|
||||||
|
self.get_pci_dev_num()
|
||||||
|
|
||||||
def check_item(self):
|
def check_item(self):
|
||||||
""" Check all items in this class
|
""" Check all items in this class
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
scenario_cfg_lib.pci_dev_num_check(self.pci_dev_num, "pci_dev_num")
|
scenario_cfg_lib.pci_devs_check(self.pci_devs, "pci_devs", "pci_dev")
|
||||||
scenario_cfg_lib.pci_devs_check(self.pci_devs, "pci_devs")
|
|
||||||
|
|
||||||
|
|
||||||
class EpcSection:
|
class EpcSection:
|
||||||
@ -316,3 +322,4 @@ class VmInfo:
|
|||||||
self.mem_info.check_item()
|
self.mem_info.check_item()
|
||||||
self.os_cfg.check_item()
|
self.os_cfg.check_item()
|
||||||
self.cfg_pci.check_item()
|
self.cfg_pci.check_item()
|
||||||
|
self.vuart.check_item()
|
||||||
|
@ -139,13 +139,6 @@ def vuart_output(vm_type, i, vm_info, config):
|
|||||||
vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config)
|
vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config)
|
||||||
print("\t\t},", file=config)
|
print("\t\t},", file=config)
|
||||||
|
|
||||||
# pci_dev_num/pci_devs only for SOS_VM or logical_partition pre_launched_vm
|
|
||||||
if vm_type == "SOS_VM" or vm_type == "PRE_LAUNCHED_VM":
|
|
||||||
if vm_info.cfg_pci.pci_dev_num[i] and vm_info.cfg_pci.pci_dev_num[i] != None:
|
|
||||||
print("\t\t.pci_dev_num = {},".format(vm_info.cfg_pci.pci_dev_num[i]), file=config)
|
|
||||||
if vm_info.cfg_pci.pci_devs[i] and vm_info.cfg_pci.pci_devs[i] != None:
|
|
||||||
print("\t\t.pci_devs = {},".format(vm_info.cfg_pci.pci_devs[i]), file=config)
|
|
||||||
|
|
||||||
|
|
||||||
def is_need_epc(epc_section, i, config):
|
def is_need_epc(epc_section, i, config):
|
||||||
"""
|
"""
|
||||||
@ -337,6 +330,10 @@ def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
|
|||||||
if err_dic:
|
if err_dic:
|
||||||
return err_dic
|
return err_dic
|
||||||
|
|
||||||
|
if vm_info.cfg_pci.pci_devs[vm_i] and vm_info.cfg_pci.pci_devs[vm_i] != None:
|
||||||
|
print("\t\t.pci_dev_num = {}U,".format(vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
|
||||||
|
print("\t\t.pci_devs = vm{}_pci_devs,".format(vm_i), file=config)
|
||||||
|
|
||||||
print("\t},", file=config)
|
print("\t},", file=config)
|
||||||
|
|
||||||
|
|
||||||
@ -387,7 +384,7 @@ def pre_launch_definiation(vm_info, config):
|
|||||||
if vm_type != "PRE_LAUNCHED_VM":
|
if vm_type != "PRE_LAUNCHED_VM":
|
||||||
continue
|
continue
|
||||||
print("extern struct acrn_vm_pci_dev_config " +
|
print("extern struct acrn_vm_pci_dev_config " +
|
||||||
"vm{0}_pci_devs[VM{1}_CONFIG_PCI_DEV_NUM];".format(vm_i, vm_i), file=config)
|
"vm{}_pci_devs[{}];".format(vm_i, vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
|
||||||
print("", file=config)
|
print("", file=config)
|
||||||
|
|
||||||
def generate_file(vm_info, config):
|
def generate_file(vm_info, config):
|
||||||
@ -397,8 +394,10 @@ def generate_file(vm_info, config):
|
|||||||
"""
|
"""
|
||||||
err_dic = {}
|
err_dic = {}
|
||||||
gen_source_header(config)
|
gen_source_header(config)
|
||||||
if vm_info.load_order_cnt.pre_vm >= 2:
|
for vm_i,pci_dev_num in vm_info.cfg_pci.pci_dev_num.items():
|
||||||
pre_launch_definiation(vm_info, config)
|
if pci_dev_num >= 2:
|
||||||
|
pre_launch_definiation(vm_info, config)
|
||||||
|
break
|
||||||
|
|
||||||
print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
|
print("struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {", file=config)
|
||||||
for vm_i, vm_type in common.VM_TYPES.items():
|
for vm_i, vm_type in common.VM_TYPES.items():
|
||||||
|
@ -126,7 +126,7 @@ def gen_header_file(vm_info, config):
|
|||||||
|
|
||||||
def get_dm_owned_guest_flag_mask(vm_info, config):
|
def get_dm_owned_guest_flag_mask(vm_info, config):
|
||||||
|
|
||||||
if vm_info.load_order_cnt.pre_vm >= 2:
|
if "SOS_VM" not in common.VM_TYPES.values():
|
||||||
print("#define DM_OWNED_GUEST_FLAG_MASK\t0UL", file=config)
|
print("#define DM_OWNED_GUEST_FLAG_MASK\t0UL", file=config)
|
||||||
else:
|
else:
|
||||||
print("/* Bits mask of guest flags that can be programmed by device model." +
|
print("/* Bits mask of guest flags that can be programmed by device model." +
|
||||||
|
Loading…
Reference in New Issue
Block a user