acrn-config: Generate target xml file with multiple RDT resources

This patch adds support for storing multiple RDT resource
and its max supported clos value in the target xml file under
clos subsection.

Tracked-On: #3715
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Vijay Dhanraj 2019-09-20 14:29:41 -07:00 committed by wenlingz
parent a63f81097d
commit 4a007cc3a9

View File

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