From 564c9dcb79b7a17ff7c6ec8022d001f39c3eaede Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Tue, 2 Apr 2019 09:44:39 +0800 Subject: [PATCH] HV: refine pt_dev.c for partition mode Use MACROs in pt_dev.c to replace straight-forward BDF numbers. The pt devices for each VM will be chosen from Board specific PCI devices list which defined in pci_devices.h; Tracked-On: #2291 Signed-off-by: Victor Sun Acked-by: Eddie Dong --- .../x86/configs/apl-mrb/partition_config.h | 2 +- .../arch/x86/configs/apl-mrb/pci_devices.h | 20 +++++++++++++++++++ hypervisor/arch/x86/configs/apl-mrb/pt_dev.c | 17 ++++++++++------ .../arch/x86/configs/dnv-cb2/pci_devices.h | 20 +++++++++++++++++++ hypervisor/arch/x86/configs/dnv-cb2/pt_dev.c | 15 +++++++------- 5 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 hypervisor/arch/x86/configs/apl-mrb/pci_devices.h create mode 100644 hypervisor/arch/x86/configs/dnv-cb2/pci_devices.h diff --git a/hypervisor/arch/x86/configs/apl-mrb/partition_config.h b/hypervisor/arch/x86/configs/apl-mrb/partition_config.h index ac1ef2ed3..87f1749f2 100644 --- a/hypervisor/arch/x86/configs/apl-mrb/partition_config.h +++ b/hypervisor/arch/x86/configs/apl-mrb/partition_config.h @@ -35,7 +35,7 @@ console=ttyS2 no_timer_check ignore_loglevel log_buf_len=16M \ consoleblank=0 tsc=reliable xapic_phys" -#define VM0_CONFIG_PCI_PTDEV_NUM 2U +#define VM0_CONFIG_PCI_PTDEV_NUM 3U #define VM1_CONFIG_PCI_PTDEV_NUM 3U extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; diff --git a/hypervisor/arch/x86/configs/apl-mrb/pci_devices.h b/hypervisor/arch/x86/configs/apl-mrb/pci_devices.h new file mode 100644 index 000000000..238d15c11 --- /dev/null +++ b/hypervisor/arch/x86/configs/apl-mrb/pci_devices.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PCI_DEVICES_H_ +#define PCI_DEVICES_H_ + +#define HOST_BRIDGE .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U} +#define SATA_CONTROLLER .pbdf.bits = {.b = 0x00U, .d = 0x12U, .f = 0x00U} +#define USB_CONTROLLER .pbdf.bits = {.b = 0x00U, .d = 0x15U, .f = 0x00U} + +#define STORAGE_CONTROLLER_0 SATA_CONTROLLER +#define STORAGE_CONTROLLER_1 USB_CONTROLLER + +#define ETHERNET_CONTROLLER_0 .pbdf.bits = {.b = 0x02U, .d = 0x00U, .f = 0x00U} +#define ETHERNET_CONTROLLER_1 + +#endif /* PCI_DEVICES_H_ */ diff --git a/hypervisor/arch/x86/configs/apl-mrb/pt_dev.c b/hypervisor/arch/x86/configs/apl-mrb/pt_dev.c index 94af133e7..f106c3a09 100644 --- a/hypervisor/arch/x86/configs/apl-mrb/pt_dev.c +++ b/hypervisor/arch/x86/configs/apl-mrb/pt_dev.c @@ -4,31 +4,36 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include +#include #include +#include struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, + HOST_BRIDGE }, { .vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x12U, .f = 0x00U}, + STORAGE_CONTROLLER_0 + }, + { + .vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U}, + ETHERNET_CONTROLLER_0 }, }; struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, + HOST_BRIDGE }, { .vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x15U, .f = 0x00U}, + STORAGE_CONTROLLER_1 }, { .vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U}, - .pbdf.bits = {.b = 0x02U, .d = 0x00U, .f = 0x00U}, + ETHERNET_CONTROLLER_1 }, }; diff --git a/hypervisor/arch/x86/configs/dnv-cb2/pci_devices.h b/hypervisor/arch/x86/configs/dnv-cb2/pci_devices.h new file mode 100644 index 000000000..b808d77c2 --- /dev/null +++ b/hypervisor/arch/x86/configs/dnv-cb2/pci_devices.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PCI_DEVICES_H_ +#define PCI_DEVICES_H_ + +#define HOST_BRIDGE .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U} +#define SATA_CONTROLLER .pbdf.bits = {.b = 0x00U, .d = 0x14U, .f = 0x00U} +#define USB_CONTROLLER .pbdf.bits = {.b = 0x00U, .d = 0x15U, .f = 0x00U} + +#define STORAGE_CONTROLLER_0 SATA_CONTROLLER +#define STORAGE_CONTROLLER_1 USB_CONTROLLER + +#define ETHERNET_CONTROLLER_0 .pbdf.bits = {.b = 0x03U, .d = 0x00U, .f = 0x00U} +#define ETHERNET_CONTROLLER_1 .pbdf.bits = {.b = 0x03U, .d = 0x00U, .f = 0x01U} + +#endif /* PCI_DEVICES_H_ */ diff --git a/hypervisor/arch/x86/configs/dnv-cb2/pt_dev.c b/hypervisor/arch/x86/configs/dnv-cb2/pt_dev.c index 5c4935cea..f106c3a09 100644 --- a/hypervisor/arch/x86/configs/dnv-cb2/pt_dev.c +++ b/hypervisor/arch/x86/configs/dnv-cb2/pt_dev.c @@ -4,35 +4,36 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include +#include #include +#include struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, + HOST_BRIDGE }, { .vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U}, - .pbdf.bits = {.b = 0x03U, .d = 0x00U, .f = 0x01U}, + STORAGE_CONTROLLER_0 }, { .vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x15U, .f = 0x00U}, + ETHERNET_CONTROLLER_0 }, }; struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, + HOST_BRIDGE }, { .vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U}, - .pbdf.bits = {.b = 0x00U, .d = 0x14U, .f = 0x00U}, + STORAGE_CONTROLLER_1 }, { .vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U}, - .pbdf.bits = {.b = 0x03U, .d = 0x00U, .f = 0x00U}, + ETHERNET_CONTROLLER_1 }, };