diff --git a/misc/acrn-config/target/clos.py b/misc/acrn-config/target/clos.py index 3ab34e6c0..df01e970d 100644 --- a/misc/acrn-config/target/clos.py +++ b/misc/acrn-config/target/clos.py @@ -5,7 +5,7 @@ import parser_lib -CACHE_TYPE = { +RDT_TYPE = { "L2":4, "L3":2 } @@ -16,12 +16,11 @@ def dump_cpuid_reg(cmd, reg): :param cmd: command what can be executed in shell :param reg: register name """ - cache_t = '' - res = parser_lib.cmd_execute(cmd) + if reg == "eax": + idx = 2 if reg == "ebx": idx = 3 - if reg == "edx": idx = 5 @@ -36,52 +35,59 @@ def dump_cpuid_reg(cmd, reg): reg_value = line.split()[idx].split('=')[1] - if reg == "ebx": - if int(reg_value, 16) & CACHE_TYPE['L2'] != 0: - cache_t = "L2" + if reg == "eax": + eax_reg_val = int(reg_value, 16) + 1 + res_info = hex((1 << eax_reg_val) - 1) + break + elif reg == "ebx": + res_info = [] + if int(reg_value, 16) & RDT_TYPE['L2'] != 0: + res_info.append("L2") break - elif int(reg_value, 16) & CACHE_TYPE['L3'] != 0: - cache_t = "L3" - break - else: - cache_t = False + if int(reg_value, 16) & RDT_TYPE['L3'] != 0: + res_info.append("L3") break elif reg == "edx": - cache_t = int(reg_value, 16) + 1 + res_info = int(reg_value, 16) + 1 break - return cache_t + return res_info def get_clos_info(): - """Get clos max and clos cache type""" - clos_max = 0 - clos_cache = False + """Get max clos, mask supported and clos cache type""" + rdt_res = [] + rdt_clos_max = [] + rdt_mask_max = [] cmd = "cpuid -r -l 0x10" - clos_cache = dump_cpuid_reg(cmd, "ebx") + rdt_res = dump_cpuid_reg(cmd, "ebx") - if clos_cache == "L2": - cmd = "cpuid -r -l 0x10 --subleaf 2" - elif clos_cache == "L3": - cmd = "cpuid -r -l 0x10 --subleaf 1" + if len(rdt_res) == 0: + parser_lib.print_yel("Resource Allocation is not supported!") else: - clos_max = 0 - parser_lib.print_yel("CLOS is not supported!") - return (clos_cache, clos_max) + for i in range(len(rdt_res)): + if rdt_res[i] == "L2": + cmd = "cpuid -r -l 0x10 --subleaf 2" + rdt_clos_max.append(dump_cpuid_reg(cmd, "edx")) + rdt_mask_max.append(dump_cpuid_reg(cmd, "eax")) + if rdt_res[i] == "L3": + cmd = "cpuid -r -l 0x10 --subleaf 1" + rdt_clos_max.append(dump_cpuid_reg(cmd, "edx")) + rdt_mask_max.append(dump_cpuid_reg(cmd, "eax")) - clos_max = dump_cpuid_reg(cmd, "edx") - - return (clos_cache, clos_max) + return (rdt_res, rdt_clos_max, rdt_mask_max) def generate_info(board_info): """Generate clos information :param board_info: this is the file which stores the hardware board information """ - (clos_cache, clos_max) = get_clos_info() + (rdt_res, rdt_res_clos_max, rdt_res_mask_max) = get_clos_info() with open(board_info, 'a+') as config: print("\t", file=config) - print("\tclos supported by cache:{}".format(clos_cache), file=config) - print("\tclos max:{}".format(clos_max), file=config) + if ((len(rdt_res) != 0) and (len(rdt_res_clos_max) != 0)): + print("\trdt resources supported:", ', '.join(rdt_res), file=config) + print("\trdt resource clos max:",str(rdt_res_clos_max).strip('[]'), file=config) + print("\trdt resource mask max:",str(rdt_res_mask_max).strip('[]'), file=config) print("\t\n", file=config)