mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 09:17:58 +00:00
hv: dm: Use new virtual device management ioctls
IC_ADD_HV_VDEV -> ACRN_IOCTL_CREATE_VDEV IC_REMOVE_HV_VDEV -> ACRN_IOCTL_DESTROY_VDEV struct acrn_emul_dev -> struct acrn_vdev Also, move struct acrn_vdev to acrn_common.h as this structure is used by both DM and HV. Tracked-On: #6282 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
#define DBG_LEVEL_HYCALL 6U
|
||||
|
||||
typedef int32_t (*emul_dev_create) (struct acrn_vm *vm, struct acrn_emul_dev *dev);
|
||||
typedef int32_t (*emul_dev_create) (struct acrn_vm *vm, struct acrn_vdev *dev);
|
||||
typedef int32_t (*emul_dev_destroy) (struct pci_vdev *vdev);
|
||||
struct emul_dev_ops {
|
||||
/*
|
||||
@@ -1241,13 +1241,13 @@ int32_t hcall_set_callback_vector(__unused struct acrn_vcpu *vcpu, __unused stru
|
||||
/*
|
||||
* @pre dev != NULL
|
||||
*/
|
||||
static struct emul_dev_ops *find_emul_dev_ops(struct acrn_emul_dev *dev)
|
||||
static struct emul_dev_ops *find_emul_dev_ops(struct acrn_vdev *dev)
|
||||
{
|
||||
struct emul_dev_ops *op = NULL;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0U; i < ARRAY_SIZE(emul_dev_ops_tbl); i++) {
|
||||
if (emul_dev_ops_tbl[i].dev_id == dev->dev_id.value) {
|
||||
if (emul_dev_ops_tbl[i].dev_id == dev->id.value) {
|
||||
op = &emul_dev_ops_tbl[i];
|
||||
break;
|
||||
}
|
||||
@@ -1261,7 +1261,7 @@ static struct emul_dev_ops *find_emul_dev_ops(struct acrn_emul_dev *dev)
|
||||
* @param vcpu Pointer to vCPU that initiates the hypercall
|
||||
* @param target_vm Pointer to target VM data structure
|
||||
* @param param guest physical address. This gpa points to data structure of
|
||||
* acrn_emul_dev including information about PCI or legacy devices
|
||||
* acrn_vdev including information about PCI or legacy devices
|
||||
*
|
||||
* @pre is_sos_vm(vcpu->vm)
|
||||
* @return 0 on success, non-zero on error.
|
||||
@@ -1270,7 +1270,7 @@ int32_t hcall_add_vdev(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, __unus
|
||||
{
|
||||
struct acrn_vm *vm = vcpu->vm;
|
||||
int32_t ret = -EINVAL;
|
||||
struct acrn_emul_dev dev;
|
||||
struct acrn_vdev dev;
|
||||
struct emul_dev_ops *op;
|
||||
|
||||
/* We should only create a device to a post-launched VM at creating time for safety, not runtime or other cases*/
|
||||
@@ -1293,7 +1293,7 @@ int32_t hcall_add_vdev(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, __unus
|
||||
* @param vcpu Pointer to vCPU that initiates the hypercall
|
||||
* @param target_vm Pointer to target VM data structure
|
||||
* @param param guest physical address. This gpa points to data structure of
|
||||
* acrn_emul_dev including information about PCI or legacy devices
|
||||
* acrn_vdev including information about PCI or legacy devices
|
||||
*
|
||||
* @pre is_sos_vm(vcpu->vm)
|
||||
* @return 0 on success, non-zero on error.
|
||||
@@ -1302,7 +1302,7 @@ int32_t hcall_remove_vdev(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, __u
|
||||
{
|
||||
struct acrn_vm *vm = vcpu->vm;
|
||||
int32_t ret = -EINVAL;
|
||||
struct acrn_emul_dev dev;
|
||||
struct acrn_vdev dev;
|
||||
struct pci_vdev *vdev;
|
||||
struct emul_dev_ops *op;
|
||||
union pci_bdf bdf;
|
||||
|
@@ -361,7 +361,7 @@ static void deinit_ivshmem_vdev(struct pci_vdev *vdev)
|
||||
* @pre vm != NULL
|
||||
* @pre dev != NULL
|
||||
*/
|
||||
int32_t create_ivshmem_vdev(struct acrn_vm *vm, struct acrn_emul_dev *dev)
|
||||
int32_t create_ivshmem_vdev(struct acrn_vm *vm, struct acrn_vdev *dev)
|
||||
{
|
||||
uint32_t i;
|
||||
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
|
@@ -163,7 +163,7 @@ const struct pci_vdev_ops vmcs9900_ops = {
|
||||
.read_vdev_cfg = read_vmcs9900_cfg,
|
||||
};
|
||||
|
||||
int32_t create_vmcs9900_vdev(struct acrn_vm *vm, struct acrn_emul_dev *dev)
|
||||
int32_t create_vmcs9900_vdev(struct acrn_vm *vm, struct acrn_vdev *dev)
|
||||
{
|
||||
uint32_t i;
|
||||
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
|
@@ -114,7 +114,7 @@ static void init_ptm(struct pci_vdev *vdev, struct vrp_config *vrp_config)
|
||||
pci_vdev_write_vcfg(vdev, PCIR_SUBBUS_1, 1U, vrp_config->subordinate_bus);
|
||||
}
|
||||
|
||||
int32_t create_vrp(struct acrn_vm *vm, struct acrn_emul_dev *dev)
|
||||
int32_t create_vrp(struct acrn_vm *vm, struct acrn_vdev *dev)
|
||||
{
|
||||
struct acrn_vm_config *vm_config = get_vm_config(vm->vm_id);
|
||||
struct acrn_vm_pci_dev_config *dev_config = NULL;
|
||||
@@ -128,7 +128,7 @@ int32_t create_vrp(struct acrn_vm *vm, struct acrn_emul_dev *dev)
|
||||
pr_acrnlog("%s: virtual root port phy_bdf=0x%x, vbdf=0x%x, vendor_id=0x%x, dev_id=0x%x,\
|
||||
primary_bus=0x%x, secondary_bus=0x%x, sub_bus=0x%x.\n",
|
||||
__func__, vrp_config->phy_bdf, dev->slot,
|
||||
dev->dev_id.fields.vendor_id, dev->dev_id.fields.device_id,
|
||||
dev->id.fields.vendor, dev->id.fields.device,
|
||||
vrp_config->primary_bus, vrp_config->secondary_bus, vrp_config->subordinate_bus);
|
||||
|
||||
for (i = 0U; i < vm_config->pci_dev_num; i++) {
|
||||
|
@@ -340,7 +340,7 @@ int32_t hcall_deassign_mmiodev(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm
|
||||
* @param target_vm Pointer to target VM data structure
|
||||
* @param param1 not used
|
||||
* @param param2 guest physical address. This gpa points to data structure of
|
||||
* acrn_emul_dev including information about PCI or legacy devices
|
||||
* acrn_vdev including information about PCI or legacy devices
|
||||
*
|
||||
* @pre is_sos_vm(vcpu->vm)
|
||||
* @return 0 on success, non-zero on error.
|
||||
@@ -354,7 +354,7 @@ int32_t hcall_add_vdev(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, uint64
|
||||
* @param target_vm Pointer to target VM data structure
|
||||
* @param param1 not used
|
||||
* @param param2 guest physical address. This gpa points to data structure of
|
||||
* acrn_emul_dev including information about PCI or legacy devices
|
||||
* acrn_vdev including information about PCI or legacy devices
|
||||
*
|
||||
* @pre is_sos_vm(vcpu->vm)
|
||||
* @return 0 on success, non-zero on error.
|
||||
|
@@ -37,7 +37,7 @@ extern const struct pci_vdev_ops vpci_ivshmem_ops;
|
||||
*/
|
||||
void init_ivshmem_shared_memory(void);
|
||||
|
||||
int32_t create_ivshmem_vdev(struct acrn_vm *vm, struct acrn_emul_dev *dev);
|
||||
int32_t create_ivshmem_vdev(struct acrn_vm *vm, struct acrn_vdev *dev);
|
||||
int32_t destroy_ivshmem_vdev(struct pci_vdev *vdev);
|
||||
#endif /* CONFIG_IVSHMEM_ENABLED */
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
extern const struct pci_vdev_ops vmcs9900_ops;
|
||||
void trigger_vmcs9900_msix(struct pci_vdev *vdev);
|
||||
int32_t create_vmcs9900_vdev(struct acrn_vm *vm, struct acrn_emul_dev *dev);
|
||||
int32_t create_vmcs9900_vdev(struct acrn_vm *vm, struct acrn_vdev *dev);
|
||||
int32_t destroy_vmcs9900_vdev(struct pci_vdev *vdev);
|
||||
|
||||
#endif
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
extern const struct pci_vdev_ops vrp_ops;
|
||||
|
||||
int32_t create_vrp(struct acrn_vm *vm, struct acrn_emul_dev *dev);
|
||||
int32_t create_vrp(struct acrn_vm *vm, struct acrn_vdev *dev);
|
||||
int32_t destroy_vrp(struct pci_vdev *vdev);
|
||||
|
||||
#endif
|
||||
|
@@ -750,6 +750,42 @@ struct acrn_mmiodev {
|
||||
uint64_t size;
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
/**
|
||||
* @brief Info to create or destroy a virtual PCI or legacy device for a VM
|
||||
*
|
||||
* the parameter for HC_CREATE_VDEV or HC_DESTROY_VDEV hypercall
|
||||
*/
|
||||
struct acrn_vdev {
|
||||
/*
|
||||
* the identifier of the device, the low 32 bits represent the vendor
|
||||
* id and device id of PCI device and the high 32 bits represent the
|
||||
* device number of the legacy device
|
||||
*/
|
||||
union {
|
||||
uint64_t value;
|
||||
struct {
|
||||
uint16_t vendor;
|
||||
uint16_t device;
|
||||
uint32_t legacy_id;
|
||||
} fields;
|
||||
} id;
|
||||
|
||||
/*
|
||||
* the slot of the device, if the device is a PCI device, the slot
|
||||
* represents BDF, otherwise it represents legacy device slot number
|
||||
*/
|
||||
uint64_t slot;
|
||||
|
||||
/** the IO resource address of the device, initialized by ACRN-DM. */
|
||||
uint32_t io_addr[ACRN_PCI_NUM_BARS];
|
||||
|
||||
/** the IO resource size of the device, initialized by ACRN-DM. */
|
||||
uint32_t io_size[ACRN_PCI_NUM_BARS];
|
||||
|
||||
/** the options for the virtual device, initialized by ACRN-DM. */
|
||||
uint8_t args[128];
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@@ -271,49 +271,6 @@ struct hc_ptdev_irq {
|
||||
|
||||
} __aligned(8);
|
||||
|
||||
/**
|
||||
* @brief Info to create or destroy a virtual PCI or legacy device for a VM
|
||||
*
|
||||
* the parameter for HC_ADD_VDEV or HC_REMOVE_VDEV hypercall
|
||||
*/
|
||||
struct acrn_emul_dev {
|
||||
/*
|
||||
* the identifier of the device, the low 32 bits represent the vendor
|
||||
* id and device id of PCI device and the high 32 bits represent the
|
||||
* device number of the legacy device
|
||||
*/
|
||||
union dev_id_info {
|
||||
uint64_t value;
|
||||
struct fields_info {
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint32_t legacy_device_number;
|
||||
} fields;
|
||||
} dev_id;
|
||||
|
||||
/*
|
||||
* the slot of the device, if the device is a PCI device, the slot
|
||||
* represents BDF, otherwise it represents legacy device slot number
|
||||
*/
|
||||
uint32_t slot;
|
||||
|
||||
/** reserved for extension */
|
||||
uint32_t reserved0;
|
||||
|
||||
/** the IO resource address of the device, initialized by ACRN-DM. */
|
||||
uint32_t io_addr[6];
|
||||
|
||||
/** the IO resource size of the device, initialized by ACRN-DM. */
|
||||
uint32_t io_size[6];
|
||||
|
||||
/** the options for the virtual device, initialized by ACRN-DM. */
|
||||
uint8_t args[128];
|
||||
|
||||
/** reserved for extension */
|
||||
uint64_t reserved1[8];
|
||||
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
/**
|
||||
* Hypervisor api version info, return it for HC_GET_API_VERSION hypercall
|
||||
*/
|
||||
|
Reference in New Issue
Block a user