diff --git a/misc/acrn-config/config_app/static/main.js b/misc/acrn-config/config_app/static/main.js index 86539d98d..25becaa0b 100644 --- a/misc/acrn-config/config_app/static/main.js +++ b/misc/acrn-config/config_app/static/main.js @@ -405,12 +405,14 @@ $().ready(function(){ var id = $(this).attr('id'); var value = $(this).val(); update_vcpu_clos_option(id, value); + update_rdt_clos_mask(id, value); }); $("select[ID$='FEATURES,RDT,CDP_ENABLED']").each(function(index, item) { var id = $(this).attr('id'); var value = $(item).val(); update_vcpu_clos_option(id, value); + update_rdt_clos_mask(id, value); }); $(document).on('click', "button:contains('+')", function() { @@ -565,6 +567,69 @@ function update_vcpu_clos_option(id, value) { } } +function update_rdt_clos_mask(id, value) { + $.ajax({ + type : "POST", + contentType: "application/json;charset=UTF-8", + url : "../get_num_of_rdt_res_entries", + data : JSON.stringify({'cdp_enabled': value}), + success : function(result) { + console.log(result); + num_clos_mask = result.num_clos_mask; + num_mba_delay = result.num_mba_delay; + clos_mask_entries = [null]; + index = 0; + $("input[ID$='hv,FEATURES,RDT,CLOS_MASK']").each(function(){ + index += 1; + if(index<=num_clos_mask) { + clos_mask_entries[0] = $(this).parent().parent(); + } + if(index>num_clos_mask) { + clos_mask_entries.push($(this).parent().parent()); + } + }); + if(index<=num_clos_mask) { + last_clos_mask_entry = clos_mask_entries[0]; + for(i=0; i0; i--) { + clos_mask_entries[i].remove(); + } + } + mba_delay_entries = [null]; + index = 0; + $("input[ID$='hv,FEATURES,RDT,MBA_DELAY']").each(function(){ + index += 1; + if(index<=num_mba_delay) { + mba_delay_entries[0] = $(this).parent().parent(); + } + if(index>num_mba_delay) { + mba_delay_entries.push($(this).parent().parent()); + } + }); + if(index<=num_mba_delay) { + last_mba_delay_entry = mba_delay_entries[0]; + for(i=0; i0; i--) { + mba_delay_entries[i].remove(); + } + } + }, + error : function(e){ + console.log(e.status); + console.log(e.responseText); + alert(e.responseText); + } + }); +} + function create_setting(type, default_name, name, mode){ var board_info = $("text#board_type").text(); if (board_info==null || board_info=='') { @@ -663,7 +728,7 @@ function save_scenario(generator=null){ $("input").each(function(){ var id = $(this).attr('id'); var value = $(this).val(); - if(id.indexOf('CLOS_MASK')>=0 ) { + if(id.indexOf('CLOS_MASK')>=0 || id.indexOf('MBA_DELAY')>=0) { if(id in scenario_config) { scenario_config[id].push(value); } else { diff --git a/misc/acrn-config/config_app/templates/scenario.html b/misc/acrn-config/config_app/templates/scenario.html index 15f5416c3..a8ae3a94a 100644 --- a/misc/acrn-config/config_app/templates/scenario.html +++ b/misc/acrn-config/config_app/templates/scenario.html @@ -233,7 +233,7 @@ the source files will be generated into default path and overwirte the previous

- {% elif sub_elem_2.tag != 'CLOS_MASK' %} + {% elif sub_elem_2.tag not in ['CLOS_MASK', 'MBA_DELAY'] %}
+ id="{{vm_type+','+elem.tag+','+sub_elem.tag+','+sub_elem_2.tag}}" value={{'' if sub_elem_2.text == None else sub_elem_2.text}}>

diff --git a/misc/acrn-config/config_app/views.py b/misc/acrn-config/config_app/views.py index b0191c4fd..3e756e9bd 100644 --- a/misc/acrn-config/config_app/views.py +++ b/misc/acrn-config/config_app/views.py @@ -473,13 +473,16 @@ def create_setting(): if mode == 'create': # update RDT->CLOS_MASK according to board xml scenario_config.set_curr(create_name) - rdt_clos_max = get_board_rdt_clos_max(board_info) elem_clos_max = scenario_config.get_curr_elem('hv', 'FEATURES', 'RDT', 'CLOS_MASK') - if rdt_clos_max > 0: - for i in range(rdt_clos_max - 1): - scenario_config.clone_curr_elem(elem_clos_max, 'hv', 'FEATURES', 'RDT') - else: - scenario_config.delete_curr_elem('hv', 'FEATURES', 'RDT', 'CLOS_MASK') + elem_mba_delay = scenario_config.get_curr_elem('hv', 'FEATURES', 'RDT', 'MBA_DELAY') + scenario_config.delete_curr_elem('hv', 'FEATURES', 'RDT', 'CLOS_MASK') + scenario_config.delete_curr_elem('hv', 'FEATURES', 'RDT', 'MBA_DELAY') + cdp_enabled = scenario_config.get_curr_value('hv', 'FEATURES', 'RDT', 'CDP_ENABLED') + (num_clos_mask, num_mba_delay) = get_num_of_rdt_res(board_info, cdp_enabled) + for i in range(num_clos_mask): + scenario_config.clone_curr_elem(elem_clos_max, 'hv', 'FEATURES', 'RDT') + for i in range(num_mba_delay): + scenario_config.clone_curr_elem(elem_mba_delay, 'hv', 'FEATURES', 'RDT') scenario_config.save(create_name) return {'status': 'success', 'setting': create_name, 'error_list': {}} @@ -623,20 +626,24 @@ def upload_board_info(): copyfile(generic_file, new_file) xml_config = XmlConfig(os.path.join(current_app.config.get('CONFIG_PATH'), board_type)) - xml_config.set_curr(generic_name[:-4]) + xml_config.set_curr(generic_name.rsplit('.', 1)[0]) xml_config.set_curr_attr('board', board_type) # update RDT->CLOS_MASK according to board xml xml_config_root = xml_config.get_curr_root() if 'board' in xml_config_root.attrib and 'scenario' in xml_config_root.attrib \ and 'uos_launcher' not in xml_config_root.attrib: - rdt_clos_max = get_board_rdt_clos_max(filename.rsplit('.', 1)[0]) + cdp_enabled = xml_config.get_curr_value('hv', 'FEATURES', 'RDT', 'CDP_ENABLED') + (num_clos_mask, num_mba_delay) = \ + get_num_of_rdt_res(filename.rsplit('.', 1)[0], cdp_enabled) elem_clos_max = xml_config.get_curr_elem('hv', 'FEATURES', 'RDT', 'CLOS_MASK') - if rdt_clos_max > 0: - for i in range(rdt_clos_max-1): - xml_config.clone_curr_elem(elem_clos_max, 'hv', 'FEATURES', 'RDT') - else: - xml_config.delete_curr_elem('hv', 'FEATURES', 'RDT', 'CLOS_MASK') - xml_config.save(generic_name[:-4], user_defined=False) + elem_mba_delay = xml_config.get_curr_elem('hv', 'FEATURES', 'RDT', 'MBA_DELAY') + xml_config.delete_curr_elem('hv', 'FEATURES', 'RDT', 'CLOS_MASK') + xml_config.delete_curr_elem('hv', 'FEATURES', 'RDT', 'MBA_DELAY') + for i in range(num_clos_mask): + xml_config.clone_curr_elem(elem_clos_max, 'hv', 'FEATURES', 'RDT') + for i in range(num_mba_delay): + xml_config.clone_curr_elem(elem_mba_delay, 'hv', 'FEATURES', 'RDT') + xml_config.save(generic_name.rsplit('.', 1)[0], user_defined=False) board_info = os.path.splitext(file.filename)[0] current_app.config.update(BOARD_INFO=board_info) @@ -829,6 +836,19 @@ def get_post_launch_vms(): return {'vm_list': vm_list} +@CONFIG_APP.route('/get_num_of_rdt_res_entries', methods=['POST']) +def get_num_of_rdt_res_entries(): + """ + get the number of rdt res entries + :return: the number of CLOS_MASK and MBA_DELAY entries + """ + data = request.json if request.method == "POST" else request.args + cdp_enabled = data['cdp_enabled'] + board_info = current_app.config.get('BOARD_INFO') + (num_clos_mask, num_mba_delay) = get_num_of_rdt_res(board_info, cdp_enabled) + return {'num_clos_mask': num_clos_mask, 'num_mba_delay': num_mba_delay} + + def get_post_launch_vm_list(scenario_name): """ get post launch VM list @@ -971,14 +991,53 @@ def get_board_info(board_info): return (bios_info, base_board_info) -def get_board_rdt_clos_max(board_info): +def get_num_of_rdt_res(board_file_name, cdp_enalbed): """ - get board info type - :param board_info: the board info file - :return: the rdt clos max + get the number of rdt res entries + :param board_file_name: the file name of the board + :param cdp_enalbed: cdp enalbed or not + :return: the number of rdt res entries """ - board_config = get_board_config(board_info) - rdt_clos_max = 0 + dict_rdt_res_clos_max = get_board_rdt_res_clos_max(board_file_name) + + num_clos_max = 0 + num_mba_delay = 0 + + if 'MBA' not in dict_rdt_res_clos_max.keys(): + num_mba_delay = 0 + if 'L2' not in dict_rdt_res_clos_max.keys() and 'L3' not in dict_rdt_res_clos_max.keys(): + num_clos_max = 0 + else: + num_clos_max = min(dict_rdt_res_clos_max.values()) + else: + if 'L2' not in dict_rdt_res_clos_max.keys() and 'L3' not in dict_rdt_res_clos_max.keys(): + num_clos_max = 0 + num_mba_delay = dict_rdt_res_clos_max['MBA'] + else: + if cdp_enalbed is not None and cdp_enalbed.strip().lower() == 'y': + for key in dict_rdt_res_clos_max.keys(): + if key not in ['MBA']: + dict_rdt_res_clos_max[key] = int(dict_rdt_res_clos_max[key] / 2) + common_clos_max = min(dict_rdt_res_clos_max.values()) + num_clos_max = common_clos_max * 2 + num_mba_delay = common_clos_max + else: + common_clos_max = min(dict_rdt_res_clos_max.values()) + num_clos_max = common_clos_max + num_mba_delay = common_clos_max + + return (num_clos_max, num_mba_delay) + + +def get_board_rdt_res_clos_max(board_file_name): + """ + get rdt res clos max of the board + :param board_file_name: the file name of the board + :return: the rdt res clos max + """ + board_config = get_board_config(board_file_name) + rdt_res_supported = [] + rdt_res_clos_max = [] if board_config is not None: board_info_root = board_config.get_curr_root() @@ -987,14 +1046,29 @@ def get_board_rdt_clos_max(board_info): if item.tag == 'CLOS_INFO': for line in item.text.split('\n'): line = line.strip() + if line.startswith('rdt resources supported'): + try: + rdt_res_supported = line.split(':')[1].split(',') + except: + pass if line.startswith('rdt resource clos max:'): try: - rdt_clos_max = int(line.split(':')[1].strip()) + rdt_res_clos_max = line.split(':')[1].split(',') break except: pass - - return rdt_clos_max + if len(rdt_res_clos_max) < len(rdt_res_supported): + for i in range(len(rdt_res_supported) - len(rdt_res_clos_max)): + rdt_res_clos_max.append(0) + dict_rdt_res_clos_max = {} + for i in range(len(rdt_res_supported)): + try: + clos_max = int(rdt_res_clos_max[i].strip()) + except: + clos_max = 0 + if clos_max > 0: + dict_rdt_res_clos_max[rdt_res_supported[i].strip()] = clos_max + return dict_rdt_res_clos_max def assign_vm_id(scenario_config): diff --git a/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml b/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml index 7509e7465..bafc5b7d2 100644 --- a/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml +++ b/misc/acrn-config/xmls/config-xmls/generic/hybrid.xml @@ -18,6 +18,7 @@ n n + 0 y n diff --git a/misc/acrn-config/xmls/config-xmls/generic/industry.xml b/misc/acrn-config/xmls/config-xmls/generic/industry.xml index af45d0fa0..cb87c6a92 100644 --- a/misc/acrn-config/xmls/config-xmls/generic/industry.xml +++ b/misc/acrn-config/xmls/config-xmls/generic/industry.xml @@ -18,6 +18,7 @@ n n + 0 y n diff --git a/misc/acrn-config/xmls/config-xmls/generic/logical_partition.xml b/misc/acrn-config/xmls/config-xmls/generic/logical_partition.xml index 0d693e2e4..730c3766b 100644 --- a/misc/acrn-config/xmls/config-xmls/generic/logical_partition.xml +++ b/misc/acrn-config/xmls/config-xmls/generic/logical_partition.xml @@ -18,6 +18,7 @@ n n + 0 y n diff --git a/misc/acrn-config/xmls/config-xmls/generic/sdc.xml b/misc/acrn-config/xmls/config-xmls/generic/sdc.xml index 6948e137f..104560cd9 100644 --- a/misc/acrn-config/xmls/config-xmls/generic/sdc.xml +++ b/misc/acrn-config/xmls/config-xmls/generic/sdc.xml @@ -18,6 +18,7 @@ n n + 0 y n diff --git a/misc/acrn-config/xmls/config-xmls/template/HV.xml b/misc/acrn-config/xmls/config-xmls/template/HV.xml index 93c4337ab..c4fd4fb2b 100644 --- a/misc/acrn-config/xmls/config-xmls/template/HV.xml +++ b/misc/acrn-config/xmls/config-xmls/template/HV.xml @@ -18,6 +18,7 @@ n n + 0 y n