dm: vPCI: add assign/deassign PCI device IC APIs
Add assign/deassign PCI device ioctl APIs assign a PCI device from SOS to post-launched VM or deassign a PCI device from post-launched VM to SOS. This patch is prepared for spliting passthrough PCI device from DM to HV. The old assign/deassign ptdev APIs will be discarded. Tracked-On: #4371 Signed-off-by: Li Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
fe3182ea05
commit
aa38ed5b69
|
@ -479,6 +479,18 @@ vm_unassign_ptdev(struct vmctx *ctx, int bus, int slot, int func)
|
|||
return ioctl(ctx->fd, IC_DEASSIGN_PTDEV, &bdf);
|
||||
}
|
||||
|
||||
int
|
||||
vm_assign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev)
|
||||
{
|
||||
return ioctl(ctx->fd, IC_ASSIGN_PCIDEV, pcidev);
|
||||
}
|
||||
|
||||
int
|
||||
vm_deassign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev)
|
||||
{
|
||||
return ioctl(ctx->fd, IC_DEASSIGN_PCIDEV, pcidev);
|
||||
}
|
||||
|
||||
int
|
||||
vm_map_ptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
|
||||
vm_paddr_t gpa, size_t len, vm_paddr_t hpa)
|
||||
|
|
|
@ -105,6 +105,8 @@
|
|||
#define IC_VM_PCI_MSIX_REMAP _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x02)
|
||||
#define IC_SET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x03)
|
||||
#define IC_RESET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x04)
|
||||
#define IC_ASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x05)
|
||||
#define IC_DEASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x06)
|
||||
|
||||
/* Power management */
|
||||
#define IC_ID_PM_BASE 0x60UL
|
||||
|
@ -147,6 +149,38 @@ struct vm_memmap {
|
|||
uint32_t prot; /* RWX */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Info to assign or deassign PCI for a VM
|
||||
*
|
||||
*/
|
||||
struct acrn_assign_pcidev {
|
||||
/** reversed for externed compatibility */
|
||||
uint32_t rsvd1;
|
||||
|
||||
/** virtual BDF# of the pass-through PCI device */
|
||||
uint16_t virt_bdf;
|
||||
|
||||
/** physical BDF# of the pass-through PCI device */
|
||||
uint16_t phys_bdf;
|
||||
|
||||
/** the PCI Interrupt Line, initialized by ACRN-DM, which is RO and
|
||||
* ideally not used for pass-through MSI/MSI-x devices.
|
||||
*/
|
||||
uint8_t intr_line;
|
||||
|
||||
/** the PCI Interrupt Pin, initialized by ACRN-DM, which is RO and
|
||||
* ideally not used for pass-through MSI/MSI-x devices.
|
||||
*/
|
||||
uint8_t intr_pin;
|
||||
|
||||
/** the base address of the PCI BAR, initialized by ACRN-DM. */
|
||||
uint32_t bar[6];
|
||||
|
||||
/** reserved for extension */
|
||||
uint32_t rsvd2[6];
|
||||
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
/**
|
||||
* @brief pass thru device irq data structure
|
||||
*/
|
||||
|
|
|
@ -125,6 +125,8 @@ int vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg);
|
|||
int vm_set_gsi_irq(struct vmctx *ctx, int gsi, uint32_t operation);
|
||||
int vm_assign_ptdev(struct vmctx *ctx, int bus, int slot, int func);
|
||||
int vm_unassign_ptdev(struct vmctx *ctx, int bus, int slot, int func);
|
||||
int vm_assign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev);
|
||||
int vm_deassign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev);
|
||||
int vm_map_ptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
|
||||
vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
|
||||
int vm_unmap_ptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
|
||||
|
|
Loading…
Reference in New Issue