acrn-config: Generate target xml and board.c file with MBA RDT resource

This patch adds support for,
1. Storing MBA resource and its max supported clos value
in the target xml file under clos subsection.
2. Generating board.c file with MBA RDT resource.

Tracked-On: #3725
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Vijay Dhanraj 2020-02-28 14:11:58 -08:00 committed by wenlingz
parent 2aaa050cab
commit 9a79443204
2 changed files with 49 additions and 15 deletions

View File

@ -11,6 +11,7 @@ import board_cfg_lib
class RDT(enum.Enum): class RDT(enum.Enum):
L2 = 0 L2 = 0
L3 = 1 L3 = 1
MBA = 2
INCLUDE_HEADER = """ INCLUDE_HEADER = """
#include <board.h> #include <board.h>
@ -83,8 +84,9 @@ def gen_dmar_structure(config):
def populate_clos_mask_msr(rdt_res, common_clos_max, mask, config): def populate_clos_mask_msr(rdt_res, common_clos_max, mask, config):
""" """
Populate the clos bitmask and msr index for a given RDT resource Populate the clos bitmask and msr index for a given RDT resource
:param rdt_res_str: it is a string representing the RDT resource :param rdt_res: it is a string representing the RDT resource
:param common_clos: Least common clos supported by all RDT resource :param common_clos_max: Least common clos supported by all RDT resource
:param mask: Max CLOS mask supported by the RDT resource
:param config: it is a file pointer of board information for writing to :param config: it is a file pointer of board information for writing to
""" """
for idx in range(common_clos_max): for idx in range(common_clos_max):
@ -94,15 +96,29 @@ def populate_clos_mask_msr(rdt_res, common_clos_max, mask, config):
rdt_res, idx), file=config) rdt_res, idx), file=config)
print("\t},", file=config) print("\t},", file=config)
def populate_mba_delay_mask(rdt_res, common_clos_max, config):
"""
Populate the mba delay mask and msr index for memory resource
:param rdt_res: it is a string representing the RDT resource
:param common_clos_max: Least common clos supported by all RDT resource
:param config: it is a file pointer of board information for writing to
"""
for idx in range(common_clos_max):
print("\t{", file=config)
print("\t\t.mba_delay = 0U,", file=config)
print("\t\t.msr_index = MSR_IA32_{0}_MASK_BASE + {1},".format(
rdt_res, idx), file=config)
print("\t},", file=config)
def gen_rdt_res(config): def gen_rdt_res(config):
""" """
Get RDT resource (L2, L3) information Get RDT resource (L2, L3, MBA) information
:param config: it is a file pointer of board information for writing to :param config: it is a file pointer of board information for writing to
""" """
err_dic = {} err_dic = {}
rdt_res_str ="" rdt_res_str =""
res_present = [0, 0] res_present = [0, 0, 0]
(rdt_resources, rdt_res_clos_max, rdt_res_mask_max) = board_cfg_lib.clos_info_parser(board_cfg_lib.BOARD_INFO_FILE) (rdt_resources, rdt_res_clos_max, rdt_res_mask_max) = board_cfg_lib.clos_info_parser(board_cfg_lib.BOARD_INFO_FILE)
if len(rdt_res_clos_max) != 0: if len(rdt_res_clos_max) != 0:
common_clos_max = min(rdt_res_clos_max) common_clos_max = min(rdt_res_clos_max)
@ -118,6 +134,7 @@ def gen_rdt_res(config):
if len(rdt_resources) == 0 or common_clos_max == 0: if len(rdt_resources) == 0 or common_clos_max == 0:
print("struct platform_clos_info platform_{0}_clos_array[MAX_PLATFORM_CLOS_NUM];".format("l2"), file=config) print("struct platform_clos_info platform_{0}_clos_array[MAX_PLATFORM_CLOS_NUM];".format("l2"), file=config)
print("struct platform_clos_info platform_{0}_clos_array[MAX_PLATFORM_CLOS_NUM];".format("l3"), file=config) print("struct platform_clos_info platform_{0}_clos_array[MAX_PLATFORM_CLOS_NUM];".format("l3"), file=config)
print("struct platform_clos_info platform_{0}_clos_array[MAX_PLATFORM_CLOS_NUM];".format("mba"), file=config)
else: else:
for idx, rdt_res in enumerate(rdt_resources): for idx, rdt_res in enumerate(rdt_resources):
if rdt_res == "L2": if rdt_res == "L2":
@ -134,14 +151,24 @@ def gen_rdt_res(config):
populate_clos_mask_msr(rdt_res, common_clos_max, int(rdt_res_mask_max[idx].strip('\''), 16), config) populate_clos_mask_msr(rdt_res, common_clos_max, int(rdt_res_mask_max[idx].strip('\''), 16), config)
print("};\n", file=config) print("};\n", file=config)
res_present[RDT.L3.value] = 1 res_present[RDT.L3.value] = 1
elif rdt_res == "MBA":
rdt_res_str = "mba"
print("struct platform_clos_info platform_{0}_clos_array[{1}] = {{".format(rdt_res_str,
"MAX_PLATFORM_CLOS_NUM"), file=config)
populate_mba_delay_mask(rdt_res, common_clos_max, config)
print("};\n", file=config)
res_present[RDT.MBA.value] = 1
else: else:
err_dic['board config: generate board.c failed'] = "The input of {} was corrupted!".format(board_cfg_lib.BOARD_INFO_FILE) err_dic['board config: generate board.c failed'] = "The input of {} was corrupted!".format(board_cfg_lib.BOARD_INFO_FILE)
return err_dic return err_dic
if res_present[RDT.L2.value] == 0: if res_present[RDT.L2.value] == 0:
print("struct platform_clos_info platform_{0}_clos_array[{1}];".format("l2", "MAX_PLATFORM_CLOS_NUM"), file=config) print("struct platform_clos_info platform_{0}_clos_array[{1}];".format("l2", "MAX_PLATFORM_CLOS_NUM"), file=config)
elif res_present[RDT.L3.value] == 0: if res_present[RDT.L3.value] == 0:
print("struct platform_clos_info platform_{0}_clos_array[{1}];".format("l3", "MAX_PLATFORM_CLOS_NUM"), file=config) print("struct platform_clos_info platform_{0}_clos_array[{1}];".format("l3", "MAX_PLATFORM_CLOS_NUM"), file=config)
if res_present[RDT.MBA.value] == 0:
print("struct platform_clos_info platform_{0}_clos_array[{1}];".format("mba", "MAX_PLATFORM_CLOS_NUM"), file=config)
print("#endif", file=config) print("#endif", file=config)
print("", file=config) print("", file=config)

View File

@ -7,7 +7,8 @@ import parser_lib
RDT_TYPE = { RDT_TYPE = {
"L2":4, "L2":4,
"L3":2 "L3":2,
"MBA":8
} }
@ -36,17 +37,17 @@ def dump_cpuid_reg(cmd, reg):
reg_value = line.split()[idx].split('=')[1] reg_value = line.split()[idx].split('=')[1]
if reg == "eax": if reg == "eax":
eax_reg_val = int(reg_value, 16) + 1 res_info = int(reg_value, 16) + 1
res_info = hex((1 << eax_reg_val) - 1)
break break
elif reg == "ebx": elif reg == "ebx":
res_info = [] res_info = []
if int(reg_value, 16) & RDT_TYPE['L2'] != 0: if int(reg_value, 16) & RDT_TYPE['L2'] != 0:
res_info.append("L2") res_info.append("L2")
break
if int(reg_value, 16) & RDT_TYPE['L3'] != 0: if int(reg_value, 16) & RDT_TYPE['L3'] != 0:
res_info.append("L3") res_info.append("L3")
break if int(reg_value, 16) & RDT_TYPE['MBA'] != 0:
res_info.append("MBA")
break
elif reg == "edx": elif reg == "edx":
res_info = int(reg_value, 16) + 1 res_info = int(reg_value, 16) + 1
break break
@ -59,7 +60,7 @@ def get_clos_info():
rdt_res = [] rdt_res = []
rdt_clos_max = [] rdt_clos_max = []
rdt_mask_max = [] rdt_mask_max = []
cmd = "cpuid -r -l 0x10" cmd = "cpuid -1 -r -l 0x10"
rdt_res = dump_cpuid_reg(cmd, "ebx") rdt_res = dump_cpuid_reg(cmd, "ebx")
if len(rdt_res) == 0: if len(rdt_res) == 0:
@ -67,13 +68,19 @@ def get_clos_info():
else: else:
for i in range(len(rdt_res)): for i in range(len(rdt_res)):
if rdt_res[i] == "L2": if rdt_res[i] == "L2":
cmd = "cpuid -r -l 0x10 --subleaf 2" cmd = "cpuid -1 -r -l 0x10 --subleaf 2"
rdt_clos_max.append(dump_cpuid_reg(cmd, "edx")) rdt_clos_max.append(dump_cpuid_reg(cmd, "edx"))
rdt_mask_max.append(dump_cpuid_reg(cmd, "eax")) l2_info = dump_cpuid_reg(cmd, "eax")
rdt_mask_max.append(hex((1 << l2_info) - 1))
if rdt_res[i] == "L3": if rdt_res[i] == "L3":
cmd = "cpuid -r -l 0x10 --subleaf 1" cmd = "cpuid -1 -r -l 0x10 --subleaf 1"
rdt_clos_max.append(dump_cpuid_reg(cmd, "edx")) rdt_clos_max.append(dump_cpuid_reg(cmd, "edx"))
rdt_mask_max.append(dump_cpuid_reg(cmd, "eax")) l3_info = dump_cpuid_reg(cmd, "eax")
rdt_mask_max.append(hex((1 << l3_info) - 1))
if rdt_res[i] == "MBA":
cmd = "cpuid -1 -r -l 0x10 --subleaf 3"
rdt_clos_max.append(dump_cpuid_reg(cmd, "edx"))
rdt_mask_max.append(hex(dump_cpuid_reg(cmd, "eax")))
return (rdt_res, rdt_clos_max, rdt_mask_max) return (rdt_res, rdt_clos_max, rdt_mask_max)