virtio: config changed notify interface

Some virtio PCI devices can change the device configuration state, as
reflected in the device-specific configuration region of the device. In
this case:
 * If MSI-X capability is disabled:
    1. Set the second lower bit of the ISR Status field for the device
    2. Send the appropriate PCI interrupt for the device.
 * If MSI-X capability is enabled:
    1. If config_msix_vector is not NO_VECTOR, request the appropriate
       MSI-X interrupt message for the device, config_msix_vector sets
       the MSI-X Table entry number.

A single interrupt MAY indicate both that one or more virtqueue has been
used and that the configuration space has changed.

Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Hao Li <hao.l.li@intel.com>
This commit is contained in:
Shuo Liu 2018-02-11 17:01:05 +08:00 committed by Anthony Xu
parent d642fe8e54
commit 383bc5100a

View File

@ -294,7 +294,7 @@ struct vring_used {
*/
#define VIRTIO_CR_ISR_QUEUES 0x01
/* re-scan queues */
#define VIRTIO_CR_ISR_CONF_CHANGED 0x80
#define VIRTIO_CR_ISR_CONF_CHANGED 0x02
/* configuration changed */
#define VIRTIO_MSI_NO_VECTOR 0xFFFF
@ -524,6 +524,30 @@ vq_interrupt(struct virtio_base *vb, struct virtio_vq_info *vq)
}
}
/**
* @brief Deliver an config changed interrupt to guest.
*
* MSI-X or a generic MSI interrupt with config changed event.
*
* @param vb Pointer to struct virtio_base.
*
* @return NULL.
*/
static inline void
virtio_config_changed(struct virtio_base *vb)
{
if (pci_msix_enabled(vb->dev))
pci_generate_msix(vb->dev, vb->msix_cfg_idx);
else {
VIRTIO_BASE_LOCK(vb);
vb->isr |= VIRTIO_CR_ISR_CONF_CHANGED;
pci_generate_msi(vb->dev, 0);
pci_lintr_assert(vb->dev);
VIRTIO_BASE_UNLOCK(vb);
}
}
struct iovec;
/**