hv: add ivshmem device
Ivshmem device is used for shared memory based communication between pre-launched/post-launched VMs. this patch implements ivshmem device configuration space initialization and ivshmem device operation methods. v2: introduce init_one_pcibar interface to simplify BAR initialization operation of HV emulated PCI device. v3: 1) due to init_one_pcibar API is only used for pre-launched VM vdevs it can't be applied to all vdevs, so remove it. 2) move ivshmem BARs initialization to subsequent patch, this patch only introduce ivshmem configuration space initialization. Tracked-On: #4853 Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
d6f563c4eb
commit
92f9f5a4f3
|
@ -12,6 +12,12 @@
|
|||
#include <ivshmem.h>
|
||||
#include "vpci_priv.h"
|
||||
|
||||
/* config space of ivshmem device */
|
||||
#define IVSHMEM_VENDOR_ID 0x1af4U
|
||||
#define IVSHMEM_DEVICE_ID 0x1110U
|
||||
#define IVSHMEM_CLASS 0x05U
|
||||
#define IVSHMEM_REV 0x01U
|
||||
|
||||
/* IVSHMEM_SHM_SIZE is provided by offline tool */
|
||||
static uint8_t ivshmem_base[IVSHMEM_SHM_SIZE] __aligned(PDE_SIZE);
|
||||
|
||||
|
@ -26,4 +32,46 @@ void init_ivshmem_shared_memory()
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t read_ivshmem_vdev_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
/* Implementation in next patch */
|
||||
(void) vdev;
|
||||
(void) offset;
|
||||
(void) bytes;
|
||||
(void) val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t write_ivshmem_vdev_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val)
|
||||
{
|
||||
/* Implementation in next patch */
|
||||
(void) vdev;
|
||||
(void) offset;
|
||||
(void) bytes;
|
||||
(void) val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_ivshmem_vdev(struct pci_vdev *vdev)
|
||||
{
|
||||
/* initialize ivshmem config */
|
||||
pci_vdev_write_vcfg(vdev, PCIR_VENDOR, 2U, IVSHMEM_VENDOR_ID);
|
||||
pci_vdev_write_vcfg(vdev, PCIR_DEVICE, 2U, IVSHMEM_DEVICE_ID);
|
||||
pci_vdev_write_vcfg(vdev, PCIR_REVID, 1U, IVSHMEM_REV);
|
||||
pci_vdev_write_vcfg(vdev, PCIR_CLASS, 1U, IVSHMEM_CLASS);
|
||||
|
||||
vdev->user = vdev;
|
||||
}
|
||||
|
||||
static void deinit_ivshmem_vdev(struct pci_vdev *vdev)
|
||||
{
|
||||
vdev->user = NULL;
|
||||
}
|
||||
|
||||
const struct pci_vdev_ops vpci_ivshmem_ops = {
|
||||
.init_vdev = init_ivshmem_vdev,
|
||||
.deinit_vdev = deinit_ivshmem_vdev,
|
||||
.write_vdev_cfg = write_ivshmem_vdev_cfg,
|
||||
.read_vdev_cfg = read_ivshmem_vdev_cfg,
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@ struct ivshmem_shm_region {
|
|||
uint64_t size;
|
||||
};
|
||||
|
||||
extern const struct pci_vdev_ops vpci_ivshmem_ops;
|
||||
|
||||
/**
|
||||
* @brief Initialize ivshmem shared memory regions
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue