2014-09-01 12:07:54 +02:00
|
|
|
/*
|
|
|
|
* libqos virtio PCI definitions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014 Marc Marí
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBQOS_VIRTIO_PCI_H
|
|
|
|
#define LIBQOS_VIRTIO_PCI_H
|
|
|
|
|
2020-08-04 20:00:40 +02:00
|
|
|
#include "virtio.h"
|
|
|
|
#include "pci.h"
|
|
|
|
#include "qgraph.h"
|
2014-09-01 12:07:59 +02:00
|
|
|
|
2019-10-23 12:04:21 +02:00
|
|
|
typedef struct QVirtioPCIMSIXOps QVirtioPCIMSIXOps;
|
|
|
|
|
2014-09-01 12:07:54 +02:00
|
|
|
typedef struct QVirtioPCIDevice {
|
2018-07-18 16:02:41 +02:00
|
|
|
QOSGraphObject obj;
|
2014-09-01 12:07:54 +02:00
|
|
|
QVirtioDevice vdev;
|
|
|
|
QPCIDevice *pdev;
|
2016-10-24 06:52:06 +02:00
|
|
|
QPCIBar bar;
|
2019-10-23 12:04:21 +02:00
|
|
|
const QVirtioPCIMSIXOps *msix_ops;
|
2014-09-01 12:07:59 +02:00
|
|
|
uint16_t config_msix_entry;
|
|
|
|
uint64_t config_msix_addr;
|
|
|
|
uint32_t config_msix_data;
|
2019-10-23 12:04:23 +02:00
|
|
|
|
|
|
|
int bar_idx;
|
2019-10-23 12:04:25 +02:00
|
|
|
|
|
|
|
/* VIRTIO 1.0 */
|
|
|
|
uint32_t common_cfg_offset;
|
|
|
|
uint32_t notify_cfg_offset;
|
|
|
|
uint32_t notify_off_multiplier;
|
|
|
|
uint32_t isr_cfg_offset;
|
|
|
|
uint32_t device_cfg_offset;
|
2014-09-01 12:07:54 +02:00
|
|
|
} QVirtioPCIDevice;
|
|
|
|
|
2019-10-23 12:04:21 +02:00
|
|
|
struct QVirtioPCIMSIXOps {
|
|
|
|
/* Set the Configuration Vector for MSI-X */
|
|
|
|
void (*set_config_vector)(QVirtioPCIDevice *d, uint16_t entry);
|
|
|
|
|
|
|
|
/* Set the Queue Vector for MSI-X */
|
|
|
|
void (*set_queue_vector)(QVirtioPCIDevice *d, uint16_t vq_idx,
|
|
|
|
uint16_t entry);
|
|
|
|
};
|
|
|
|
|
2014-09-01 12:07:59 +02:00
|
|
|
typedef struct QVirtQueuePCI {
|
|
|
|
QVirtQueue vq;
|
|
|
|
uint16_t msix_entry;
|
|
|
|
uint64_t msix_addr;
|
|
|
|
uint32_t msix_data;
|
2019-10-23 12:04:25 +02:00
|
|
|
|
|
|
|
/* VIRTIO 1.0 */
|
|
|
|
uint64_t notify_offset;
|
2014-09-01 12:07:59 +02:00
|
|
|
} QVirtQueuePCI;
|
|
|
|
|
2018-07-18 16:02:41 +02:00
|
|
|
void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr);
|
|
|
|
QVirtioPCIDevice *virtio_pci_new(QPCIBus *bus, QPCIAddress * addr);
|
2017-02-03 13:06:12 +01:00
|
|
|
|
2018-07-18 16:02:41 +02:00
|
|
|
/* virtio-pci object functions available for subclasses that
|
|
|
|
* override the original start_hw and destroy
|
|
|
|
* function. All virtio-xxx-pci subclass that override must
|
|
|
|
* take care of calling these two functions in the respective
|
|
|
|
* places
|
|
|
|
*/
|
|
|
|
void qvirtio_pci_destructor(QOSGraphObject *obj);
|
|
|
|
void qvirtio_pci_start_hw(QOSGraphObject *obj);
|
|
|
|
|
|
|
|
|
2014-09-01 12:07:55 +02:00
|
|
|
void qvirtio_pci_device_enable(QVirtioPCIDevice *d);
|
|
|
|
void qvirtio_pci_device_disable(QVirtioPCIDevice *d);
|
2014-09-01 12:07:59 +02:00
|
|
|
|
|
|
|
void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice *d,
|
|
|
|
QGuestAllocator *alloc, uint16_t entry);
|
|
|
|
void qvirtqueue_pci_msix_setup(QVirtioPCIDevice *d, QVirtQueuePCI *vqpci,
|
|
|
|
QGuestAllocator *alloc, uint16_t entry);
|
2019-10-23 12:04:22 +02:00
|
|
|
|
|
|
|
/* Used by Legacy and Modern virtio-pci code */
|
|
|
|
QVirtQueue *qvirtio_pci_virtqueue_setup_common(QVirtioDevice *d,
|
|
|
|
QGuestAllocator *alloc,
|
|
|
|
uint16_t index);
|
|
|
|
void qvirtio_pci_virtqueue_cleanup_common(QVirtQueue *vq,
|
|
|
|
QGuestAllocator *alloc);
|
|
|
|
|
2014-09-01 12:07:54 +02:00
|
|
|
#endif
|