From 219bec5146871d55cf12e91929808ff2a05a561f Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Fri, 29 May 2020 10:56:00 +0800 Subject: [PATCH] acrn-config: generate msix emulation information generate msix emulation information from known exist PCI devices for board config. Tracked-On: #4831 Signed-off-by: Wei Liu Reviewed-by: Binbin Wu Acked-by: Victor Sun --- misc/acrn-config/board_config/board_c.py | 38 +++++++++++++++++++++ misc/acrn-config/board_config/misc_cfg_h.py | 9 +++++ misc/acrn-config/library/board_cfg_lib.py | 7 ++++ 3 files changed, 54 insertions(+) diff --git a/misc/acrn-config/board_config/board_c.py b/misc/acrn-config/board_config/board_c.py index 00f2439b7..5542836a2 100644 --- a/misc/acrn-config/board_config/board_c.py +++ b/misc/acrn-config/board_config/board_c.py @@ -260,6 +260,41 @@ def gen_pci_hide(config): print("const union pci_bdf plat_hidden_pdevs[MAX_HIDDEN_PDEVS_NUM];", file=config) +def gen_known_caps_pci_devs(config): + """Generate information for known capabilities of pci devices""" + + vpid_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "", "") + for dev,known_dev in board_cfg_lib.KNOWN_CAPS_PCI_DEVS_DB.items(): + if dev not in board_cfg_lib.KNOWN_CAPS_PCI_DEVS: + board_cfg_lib.KNOWN_CAPS_PCI_DEVS[dev] = [] + for k_dev in known_dev: + for vpid_line in vpid_lines: + if k_dev in vpid_line: + bdf = vpid_line.split()[0] + board_cfg_lib.KNOWN_CAPS_PCI_DEVS[dev].append(bdf) + break + + for dev,bdf_list in board_cfg_lib.KNOWN_CAPS_PCI_DEVS.items(): + if dev == "TSN": + print("", file=config) + bdf_list_len = len(bdf_list) + if bdf_list_len == 0: + print("const struct vmsix_on_msi_info vmsix_on_msi_devs[MAX_VMSIX_ON_MSI_PDEVS_NUM];", file=config) + break + for i in range(bdf_list_len): + b = bdf_list[i].split(":")[0] + d = bdf_list[i].split(":")[1].split(".")[0] + f = bdf_list[i].split(".")[1] + print("#define VMSIX_ON_MSI_DEV{}\t.bdf.bits = {{.b = 0x{}U, .d = 0x{}U, .f =0x{}U}},".format(i, b, d, f), file=config) + + for i in range(bdf_list_len): + if i == 0: + print("const struct vmsix_on_msi_info vmsix_on_msi_devs[MAX_VMSIX_ON_MSI_PDEVS_NUM] = {", file=config) + print("\t{{VMSIX_ON_MSI_DEV{}}},".format(i), file=config) + if i == (bdf_list_len - 1): + print("};", file=config) + + def generate_file(config): """ Start to generate board.c @@ -286,4 +321,7 @@ def generate_file(config): # gen hide pci info for platform gen_pci_hide(config) + # gen known caps of pci dev info for platform + gen_known_caps_pci_devs(config) + return err_dic diff --git a/misc/acrn-config/board_config/misc_cfg_h.py b/misc/acrn-config/board_config/misc_cfg_h.py index 81fda9f3a..0d9777e56 100644 --- a/misc/acrn-config/board_config/misc_cfg_h.py +++ b/misc/acrn-config/board_config/misc_cfg_h.py @@ -181,6 +181,14 @@ def find_hi_mmio_window(config): print("#define HI_MMIO_START\t\t~0UL", file=config) print("#define HI_MMIO_END\t\t0UL", file=config) +def gen_known_caps_pci_head(config): + + for dev,bdf_list in board_cfg_lib.KNOWN_CAPS_PCI_DEVS.items(): + if dev == "TSN": + bdf_list_len = len(bdf_list) + print("#define MAX_VMSIX_ON_MSI_PDEVS_NUM\t{}U".format(bdf_list_len), file=config) + + def generate_file(config): """ Start to generate board.c @@ -237,6 +245,7 @@ def generate_file(config): common_clos_max = 0 print("#define MAX_PLATFORM_CLOS_NUM\t{}U".format(common_clos_max), file=config) + gen_known_caps_pci_head(config) # define rootfs with macro diff --git a/misc/acrn-config/library/board_cfg_lib.py b/misc/acrn-config/library/board_cfg_lib.py index 405f90044..491d51331 100644 --- a/misc/acrn-config/library/board_cfg_lib.py +++ b/misc/acrn-config/library/board_cfg_lib.py @@ -30,6 +30,13 @@ KNOWN_HIDDEN_PDEVS_BOARD_DB = { 'apl-up2':['00:0d:0'], } +TSN_DEVS = ["8086:4b30", "8086:4b31", "8086:4b32", "8086:4ba0", "8086:4ba1", "8086:4ba2", + "8086:4bb0", "8086:4bb1", "8086:4bb2", "8086:a0ac", "8086:43ac", "8086:43a2"] +KNOWN_CAPS_PCI_DEVS_DB = { + "TSN":TSN_DEVS, +} +KNOWN_CAPS_PCI_DEVS = {} + def get_info(board_info, msg_s, msg_e): """ Get information which specify by argument