From adbaaaf6cbc6dfa7b5e87d2891c35a6aacf726d2 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Fri, 2 Aug 2019 05:48:10 +0800 Subject: [PATCH] hv: vpci: rename ptdev_config to pci_dev_config pci_dev_config in VM configure stores all the PCI devices for a VM. Besides PT devices, there're other type devices, like virtual host bridge. So rename ptdev to pci_dev for these configure. Tracked-On: #3475 Signed-off-by: Li, Fei1 Acked-by: Eddie Dong --- doc/developer-guides/sw_design_guidelines.rst | 18 ++++++------ doc/tutorials/using_partition_mode_on_up2.rst | 6 ++-- hypervisor/dm/vpci/pci_pt.c | 4 +-- hypervisor/dm/vpci/vpci.c | 28 +++++++++---------- hypervisor/include/arch/x86/vm_config.h | 12 ++++---- hypervisor/include/dm/vpci.h | 4 +-- .../scenarios/logical_partition/pt_dev.c | 4 +-- .../logical_partition/vm_configurations.c | 12 ++++---- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/doc/developer-guides/sw_design_guidelines.rst b/doc/developer-guides/sw_design_guidelines.rst index 0316c2e95..2b22d9a71 100644 --- a/doc/developer-guides/sw_design_guidelines.rst +++ b/doc/developer-guides/sw_design_guidelines.rst @@ -290,7 +290,7 @@ The rules of error detection and error handling on a module level are shown in | | | array size and non-null | | | | | | pointer. | | | +--------------------+-----------+----------------------------+---------------------------+-------------------------+ - | Configuration data | Corrupted | No. | The bootloader initializes| 'vm_config->pci_ptdevs' | + | Configuration data | Corrupted | No. | The bootloader initializes| 'vm_config->pci_devs' | | of the VM | VM config | The related pre-conditions | hypervisor (including | is configured | | | | are required. | code, data, and bss) and | statically. | | | | Note: VM configuration data| verifies the integrity of | | @@ -328,19 +328,19 @@ a module level. struct acrn_vpci *vpci = (struct acrn_vpci *)&(vm->vpci); struct pci_vdev *vdev; struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id); - struct acrn_vm_pci_ptdev_config *ptdev_config; + struct acrn_vm_pci_dev_config *pci_dev_config; uint32_t i; - vpci->pci_vdev_cnt = vm_config->pci_ptdev_num; + vpci->pci_vdev_cnt = vm_config->pci_dev_num; for (i = 0U; i < vpci->pci_vdev_cnt; i++) { vdev = &vpci->pci_vdevs[i]; vdev->vpci = vpci; - ptdev_config = &vm_config->pci_ptdevs[i]; - vdev->vbdf.value = ptdev_config->vbdf.value; + pci_dev_config = &vm_config->pci_devs[i]; + vdev->vbdf.value = pci_dev_config->vbdf.value; if (vdev->vbdf.value != 0U) { - partition_mode_pdev_init(vdev, ptdev_config->pbdf); + partition_mode_pdev_init(vdev, pci_dev_config->pbdf); vdev->ops = &pci_ops_vdev_pt; } else { vdev->ops = &pci_ops_vdev_hostbridge; @@ -367,7 +367,7 @@ pre-conditions and ``get_vm_config`` itself shall guarantee the post-condition. /** * @pre vm_id < CONFIG_MAX_VM_NUM * @post retval != NULL - * @post retval->pci_ptdev_num <= MAX_PCI_DEV_NUM + * @post retval->pci_dev_num <= MAX_PCI_DEV_NUM */ struct acrn_vm_config *get_vm_config(uint16_t vm_id) { @@ -398,9 +398,9 @@ Given the two reasons above, 'vdev' is always not NULL. So, the error checking codes are not required for 'vdev'. -**Question_3: Is error checking required for 'ptdev_config'?** +**Question_3: Is error checking required for 'pci_dev_config'?** -No. 'ptdev_config' is getting data from the array 'pci_vdevs[]', which is the +No. 'pci_dev_config' is getting data from the array 'pci_vdevs[]', which is the physical PCI device information coming from Board Support Package and firmware. For physical PCI device information, the related application constraints shall be defined in the design document or safety manual. For debug purpose, diff --git a/doc/tutorials/using_partition_mode_on_up2.rst b/doc/tutorials/using_partition_mode_on_up2.rst index 4bf24139e..53a83e7b5 100644 --- a/doc/tutorials/using_partition_mode_on_up2.rst +++ b/doc/tutorials/using_partition_mode_on_up2.rst @@ -229,7 +229,7 @@ Enable partition mode in ACRN hypervisor PCI devices that are available to the privileged VMs are hardcoded in the source file ``hypervisor/arch/x86/configs/up2/pt_dev.c``. - You need to review and modify the ``vm0_pci_ptdevs`` and ``vm1_pci_ptdevs`` + You need to review and modify the ``vm0_pci_devs`` and ``vm1_pci_devs`` structures in the source code to match the PCI BDF addresses of the SATA controller and the USB controller noted in step 1: @@ -238,7 +238,7 @@ Enable partition mode in ACRN hypervisor :caption: hypervisor/arch/x86/configs/up2/pt_dev.c ... - struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[2] = { + struct acrn_vm_pci_dev_config vm0_pci_devs[2] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, @@ -250,7 +250,7 @@ Enable partition mode in ACRN hypervisor }; ... - struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[3] = { + struct acrn_vm_pci_dev_config vm1_pci_devs[3] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, .pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, diff --git a/hypervisor/dm/vpci/pci_pt.c b/hypervisor/dm/vpci/pci_pt.c index 1b14ea515..d47531a80 100644 --- a/hypervisor/dm/vpci/pci_pt.c +++ b/hypervisor/dm/vpci/pci_pt.c @@ -498,7 +498,7 @@ void init_vdev_pt(struct pci_vdev *vdev) vbar_base = get_pbar_base(vdev->pdev, idx); } else if (idx > 0U) { /* For pre-launched VMs: vbar base is predefined in vm_config */ - vbar_base = vdev->ptdev_config->vbar_base[idx - 1U]; + vbar_base = vdev->pci_dev_config->vbar_base[idx - 1U]; } else { vbar_base = 0UL; } @@ -522,7 +522,7 @@ void init_vdev_pt(struct pci_vdev *vdev) vbar_base = get_pbar_base(vdev->pdev, idx); } else { /* For pre-launched VMs: vbar base is predefined in vm_config */ - vbar_base = vdev->ptdev_config->vbar_base[idx]; + vbar_base = vdev->pci_dev_config->vbar_base[idx]; } vdev_pt_write_vbar(vdev, pci_bar_offset(idx), (uint32_t)vbar_base); break; diff --git a/hypervisor/dm/vpci/vpci.c b/hypervisor/dm/vpci/vpci.c index 22a10621a..0d845d162 100644 --- a/hypervisor/dm/vpci/vpci.c +++ b/hypervisor/dm/vpci/vpci.c @@ -420,25 +420,25 @@ static void write_cfg(const struct acrn_vpci *vpci, union pci_bdf bdf, /** * @pre vm_config != NULL - * @pre vm_config->pci_ptdev_num <= CONFIG_MAX_PCI_DEV_NUM + * @pre vm_config->pci_dev_num <= CONFIG_MAX_PCI_DEV_NUM */ -static struct acrn_vm_pci_ptdev_config *find_ptdev_config_by_pbdf(const struct acrn_vm_config *vm_config, +static struct acrn_vm_pci_dev_config *find_pci_dev_config(const struct acrn_vm_config *vm_config, union pci_bdf pbdf) { - struct acrn_vm_pci_ptdev_config *ptdev_config, *tmp; + struct acrn_vm_pci_dev_config *pci_dev_config, *tmp; uint16_t i; - ptdev_config = NULL; - for (i = 0U; i < vm_config->pci_ptdev_num; i++) { - tmp = &vm_config->pci_ptdevs[i]; + pci_dev_config = NULL; + for (i = 0U; i < vm_config->pci_dev_num; i++) { + tmp = &vm_config->pci_devs[i]; if (bdf_is_equal(&tmp->pbdf, &pbdf)) { - ptdev_config = tmp; + pci_dev_config = tmp; break; } } - return ptdev_config; + return pci_dev_config; } /** @@ -450,11 +450,11 @@ static void init_vdev_for_pdev(struct pci_pdev *pdev, const struct acrn_vm *vm) { const struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id); struct acrn_vpci *vpci = &(((struct acrn_vm *)vm)->vpci); - struct acrn_vm_pci_ptdev_config *ptdev_config; + struct acrn_vm_pci_dev_config *pci_dev_config; - ptdev_config = find_ptdev_config_by_pbdf(vm_config, pdev->bdf); + pci_dev_config = find_pci_dev_config(vm_config, pdev->bdf); - if (((is_prelaunched_vm(vm) && (ptdev_config != NULL)) || is_sos_vm(vm)) + if (((is_prelaunched_vm(vm) && (pci_dev_config != NULL)) || is_sos_vm(vm)) && (vpci->pci_vdev_cnt < CONFIG_MAX_PCI_DEV_NUM)) { struct pci_vdev *vdev; @@ -463,11 +463,11 @@ static void init_vdev_for_pdev(struct pci_pdev *pdev, const struct acrn_vm *vm) vdev->vpci = vpci; vdev->pdev = pdev; - vdev->ptdev_config = ptdev_config; + vdev->pci_dev_config = pci_dev_config; - if (ptdev_config != NULL) { + if (pci_dev_config != NULL) { /* vbdf is defined in vm_config */ - vdev->bdf.value = ptdev_config->vbdf.value; + vdev->bdf.value = pci_dev_config->vbdf.value; } else { /* vbdf is not defined in vm_config, set it to equal to pbdf */ vdev->bdf.value = pdev->bdf.value; diff --git a/hypervisor/include/arch/x86/vm_config.h b/hypervisor/include/arch/x86/vm_config.h index 285e7db72..2ba878d54 100644 --- a/hypervisor/include/arch/x86/vm_config.h +++ b/hypervisor/include/arch/x86/vm_config.h @@ -78,10 +78,10 @@ struct acrn_vm_os_config { uint64_t kernel_ramdisk_addr; } __aligned(8); -struct acrn_vm_pci_ptdev_config { - union pci_bdf vbdf; /* virtual BDF of PCI PT device */ - union pci_bdf pbdf; /* physical BDF of PCI PT device */ - uint64_t vbar_base[PCI_BAR_COUNT]; /* vbar base address of PCI PT device */ +struct acrn_vm_pci_dev_config { + union pci_bdf vbdf; /* virtual BDF of PCI device */ + union pci_bdf pbdf; /* physical BDF of PCI device */ + uint64_t vbar_base[PCI_BAR_COUNT]; /* vbar base address of PCI device */ } __aligned(8); struct acrn_vm_config { @@ -97,8 +97,8 @@ struct acrn_vm_config { */ struct acrn_vm_mem_config memory; /* memory configuration of VM */ struct epc_section epc; /* EPC memory configuration of VM */ - uint16_t pci_ptdev_num; /* indicate how many PCI PT devices in VM */ - struct acrn_vm_pci_ptdev_config *pci_ptdevs; /* point to PCI PT devices BDF list */ + uint16_t pci_dev_num; /* indicate how many PCI devices in VM */ + struct acrn_vm_pci_dev_config *pci_devs; /* point to PCI devices BDF list */ struct acrn_vm_os_config os_config; /* OS information the VM */ uint16_t clos; /* if guest_flags has GUEST_FLAG_CLOS_REQUIRED, then VM use this CLOS */ diff --git a/hypervisor/include/dm/vpci.h b/hypervisor/include/dm/vpci.h index 0f361f6cd..d3ef54cf5 100644 --- a/hypervisor/include/dm/vpci.h +++ b/hypervisor/include/dm/vpci.h @@ -91,8 +91,8 @@ struct pci_vdev { struct pci_msi msi; struct pci_msix msix; - /* Pointer to corresponding PCI PT device's vm_config */ - struct acrn_vm_pci_ptdev_config *ptdev_config; + /* Pointer to corresponding PCI device's vm_config */ + struct acrn_vm_pci_dev_config *pci_dev_config; /* Pointer to corressponding operations */ const struct pci_vdev_ops *vdev_ops; diff --git a/hypervisor/scenarios/logical_partition/pt_dev.c b/hypervisor/scenarios/logical_partition/pt_dev.c index 30ed83dc6..3a2603806 100644 --- a/hypervisor/scenarios/logical_partition/pt_dev.c +++ b/hypervisor/scenarios/logical_partition/pt_dev.c @@ -12,7 +12,7 @@ * The memory range of vBAR should exactly match with the e820 layout of VM. */ -struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = { +struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, HOST_BRIDGE @@ -27,7 +27,7 @@ struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = { }, }; -struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = { +struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_PTDEV_NUM] = { { .vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U}, HOST_BRIDGE diff --git a/hypervisor/scenarios/logical_partition/vm_configurations.c b/hypervisor/scenarios/logical_partition/vm_configurations.c index beb768c12..1dab5c991 100644 --- a/hypervisor/scenarios/logical_partition/vm_configurations.c +++ b/hypervisor/scenarios/logical_partition/vm_configurations.c @@ -7,8 +7,8 @@ #include #include -extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM]; -extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM]; +extern struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM]; +extern struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_PTDEV_NUM]; struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { { /* VM0 */ @@ -46,8 +46,8 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .t_vuart.vm_id = 1U, .t_vuart.vuart_id = 1U, }, - .pci_ptdev_num = VM0_CONFIG_PCI_PTDEV_NUM, - .pci_ptdevs = vm0_pci_ptdevs, + .pci_dev_num = VM0_CONFIG_PCI_PTDEV_NUM, + .pci_devs = vm0_pci_devs, }, { /* VM1 */ .load_order = PRE_LAUNCHED_VM, @@ -85,7 +85,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = { .t_vuart.vm_id = 0U, .t_vuart.vuart_id = 1U, }, - .pci_ptdev_num = VM1_CONFIG_PCI_PTDEV_NUM, - .pci_ptdevs = vm1_pci_ptdevs, + .pci_dev_num = VM1_CONFIG_PCI_PTDEV_NUM, + .pci_devs = vm1_pci_devs, }, };