diff --git a/misc/acrn-config/hv_config/board_defconfig.py b/misc/acrn-config/hv_config/board_defconfig.py index 7856076cb..983b3ef61 100644 --- a/misc/acrn-config/hv_config/board_defconfig.py +++ b/misc/acrn-config/hv_config/board_defconfig.py @@ -194,7 +194,13 @@ def get_capacities(hv_info, config): print("CONFIG_MAX_PCI_DEV_NUM={}".format(hv_info.cap.max_pci_dev_num), file=config) print("CONFIG_MAX_IOAPIC_LINES={}".format(hv_info.cap.max_ioapic_lines), file=config) print("CONFIG_MAX_PT_IRQ_ENTRIES={}".format(hv_info.cap.max_pt_irq_entries), file=config) - print("CONFIG_MAX_MSIX_TABLE_NUM={}".format(hv_info.cap.max_msix_table_num), file=config) + max_msix_table_num = 0 + if not hv_info.cap.max_msix_table_num: + native_max_msix_line = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "", "") + max_msix_table_num = native_max_msix_line[0].strip() + else: + max_msix_table_num = hv_info.cap.max_msix_table_num + print("CONFIG_MAX_MSIX_TABLE_NUM={}".format(max_msix_table_num), file=config) print("CONFIG_MAX_EMULATED_MMIO_REGIONS={}".format(hv_info.cap.max_emu_mmio_regions), file=config) diff --git a/misc/acrn-config/hv_config/hv_item.py b/misc/acrn-config/hv_config/hv_item.py index aec321dcb..720337a8f 100644 --- a/misc/acrn-config/hv_config/hv_item.py +++ b/misc/acrn-config/hv_config/hv_item.py @@ -78,7 +78,7 @@ class CapHv: hv_cfg_lib.ir_entries_check(self.max_ir_entries, "CAPACITIES", "MAX_IR_ENTRIES") hv_cfg_lib.hv_size_check(self.iommu_bus_num, "CAPACITIES", "IOMMU_BUS_NUM") hv_cfg_lib.hv_range_check(self.max_pci_dev_num, "CAPACITIES", "MAX_PCI_DEV_NUM", hv_cfg_lib.RANGE_DB['PCI_DEV_NUM']) - hv_cfg_lib.hv_range_check(self.max_msix_table_num, "CAPACITIES", "MAX_MSIX_TABLE_NUM", hv_cfg_lib.RANGE_DB['MSIX_TABLE_NUM']) + hv_cfg_lib.max_msix_table_num_check(self.max_msix_table_num, "CAPACITIES", "MAX_MSIX_TABLE_NUM") class MisCfg: diff --git a/misc/acrn-config/library/hv_cfg_lib.py b/misc/acrn-config/library/hv_cfg_lib.py index 8be745851..0d7a7d2a2 100644 --- a/misc/acrn-config/library/hv_cfg_lib.py +++ b/misc/acrn-config/library/hv_cfg_lib.py @@ -71,10 +71,11 @@ def release_check(sel_str, dbg_opt, rel_str): ERR_LIST[key] = "{} should be in {}".format(rel_str, N_Y) -def hv_range_check(str_val, branch_tag, item, range_db): +def hv_range_check(str_val, branch_tag, item, range_db, empty_check_enable=True): - if empty_check(str_val, branch_tag, item): - return + if empty_check_enable: + if empty_check(str_val, branch_tag, item): + return if not is_numeric_check(str_val, branch_tag, item): return range_check(str_val, branch_tag, item, range_db) @@ -225,3 +226,16 @@ def mba_delay_check(mba_delay_list, feature, mba_str, max_mask_str): key = 'hv,{},{},{}'.format(feature, mba_str, max_mask_str) ERR_LIST[key] = "{} should be in range[0,{}]".format(max_mask_str, mba_delay_str) return + + +def max_msix_table_num_check(max_msix_table_num, cap_str, max_msi_num_str): + native_max_msix_line = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "", "") + if not native_max_msix_line and not max_msix_table_num: + empty_check(max_msix_table_num, cap_str, max_msi_num_str) + return + + if max_msix_table_num: + hv_range_check(max_msix_table_num, cap_str, max_msi_num_str, RANGE_DB['MSIX_TABLE_NUM'], False) + if native_max_msix_line: + native_max_msix_num = native_max_msix_line[0].strip() + range_check(native_max_msix_num, "In board xml", max_msi_num_str, RANGE_DB['MSIX_TABLE_NUM']) diff --git a/misc/acrn-config/target/misc.py b/misc/acrn-config/target/misc.py index 4b2194882..064d8059e 100644 --- a/misc/acrn-config/target/misc.py +++ b/misc/acrn-config/target/misc.py @@ -217,6 +217,27 @@ def dump_cpu_core_info(config): print("\t", file=config) print("", file=config) +def dump_max_msix_table_num(config): + + msix_table_num_list = [] + max_msix_table_num = 1 + cmd = 'lspci -vv | grep "MSI-X" | grep "Count="' + res_lines = parser_lib.get_output_lines(cmd) + for line in res_lines: + tmp_num = line.split('=')[1].split()[0] + msix_table_num_list.append(tmp_num) + + if msix_table_num_list: + max_msix_table_num = max(msix_table_num_list) + print("\t", file=config) + print("\t{}".format(max_msix_table_num), file=config) + print("\t", file=config) + + +def dump_dev_config_info(config): + + dump_max_msix_table_num(config) + print("", file=config) def generate_info(board_info): """Get System Ram information @@ -235,3 +256,5 @@ def generate_info(board_info): dump_total_mem(config) dump_cpu_core_info(config) + + dump_dev_config_info(config) diff --git a/misc/acrn-config/target/parser_lib.py b/misc/acrn-config/target/parser_lib.py index aa43bb980..44ea108de 100644 --- a/misc/acrn-config/target/parser_lib.py +++ b/misc/acrn-config/target/parser_lib.py @@ -154,3 +154,15 @@ def dump_execute(cmd, desc, config): print("\t{}".format(line.strip()), file=config) print("\t".format(desc), file=config) + + +def get_output_lines(cmd): + res_lines = [] + res = cmd_execute(cmd) + while True: + line = res.stdout.readline().decode('ascii') + if not line: + break + res_lines.append(line.strip()) + + return res_lines