acrn-config: Generate info in pci_dev file for Pre-Launched VMs

Pre-Launched VMs need the vbar_base values pre-populated
for pass-thru PCI devices.

This patch moves the pci parser logic from board_cfg_gen to library
so that scenario_cfg_gen scripts can use pci parser routines while
generating pci_dev file logical partition scenario.

Tracked-On: #4666
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
This commit is contained in:
Sainath Grandhi
2020-04-19 14:56:10 -07:00
committed by wenlingz
parent e5561a5c71
commit c548ba10b9
3 changed files with 166 additions and 135 deletions

View File

@@ -5,16 +5,43 @@
import common
import scenario_cfg_lib
import board_cfg_lib
PCI_DEV_TYPE = ['PCI_DEV_TYPE_HVEMUL', 'PCI_DEV_TYPE_PTDEV']
def add_instance_to_name(i_cnt, bdf, bar_attr):
if i_cnt == 0 and bar_attr.name.upper() == "HOST BRIDGE":
tmp_sub_name = "_".join(bar_attr.name.split()).upper()
else:
if '-' in bar_attr.name:
tmp_sub_name = common.undline_name(bar_attr.name) + "_" + str(i_cnt)
else:
tmp_sub_name = "_".join(bar_attr.name.split()).upper() + "_" + str(i_cnt)
board_cfg_lib.PCI_DEV_BAR_DESC.pci_dev_dic[bdf].name_w_i_cnt = tmp_sub_name
def generate_file(vm_info, config):
"""
Generate pci_dev.c while logical_partition scenario
Generate pci_dev.c for Pre-Launched VMs in a scenario.
:param config: it is pointer for for file write to
:return: None
"""
sub_name_count = board_cfg_lib.parser_pci()
compared_bdf = []
for cnt_sub_name in sub_name_count.keys():
i_cnt = 0
for bdf, bar_attr in board_cfg_lib.PCI_DEV_BAR_DESC.pci_dev_dic.items():
if cnt_sub_name == bar_attr.name and bdf not in compared_bdf:
compared_bdf.append(bdf)
else:
continue
add_instance_to_name(i_cnt, bdf, bar_attr)
i_cnt += 1
print("{}".format(scenario_cfg_lib.HEADER_LICENSE), file=config)
print("", file=config)
print("#include <vm_config.h>", file=config)
@@ -52,7 +79,11 @@ def generate_file(vm_info, config):
print("\t{", file=config)
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
print("\t\t.vbdf.bits = {{.b = 0x00U, .d = 0x0{}U, .f = 0x00U}},".format(pci_cnt), file=config)
print("\t\t.pbdf.bits = {{.b = 0x{:02X}U, .d = 0x{:02X}U, .f = 0x{:02X}U}},".format(bus, dev, fun), file=config)
for bdf, bar_attr in board_cfg_lib.PCI_DEV_BAR_DESC.pci_dev_dic.items():
if bdf == pci_bdf_dev:
print("\t\t{},".format(board_cfg_lib.PCI_DEV_BAR_DESC.pci_dev_dic[bdf].name_w_i_cnt), file=config)
else:
continue
print("\t},", file=config)
pci_cnt += 1