/* * Barriers in virtio are tricky. Non-SMP virtio guests can't assume * they're not on an SMP host system, so they need to assume real * barriers. Non-SMP virtio hosts could skip the barriers, but does * anyone care? * * For virtio_pci on SMP, we don't need to order with respect to MMIO * accesses through relaxed memory I/O windows, so virt_mb() et al are * sufficient. * * For using virtio to talk to real devices (eg. other heterogeneous * CPUs) we do need real barriers. In theory, we could be using both * kinds of virtio, so it's a runtime decision, and the branch is * actually quite cheap.
*/
staticinlinevoid virtio_mb(bool weak_barriers)
{ if (weak_barriers)
virt_mb(); else
mb();
}
staticinlinevoid virtio_rmb(bool weak_barriers)
{ if (weak_barriers)
virt_rmb(); else
dma_rmb();
}
staticinlinevoid virtio_wmb(bool weak_barriers)
{ if (weak_barriers)
virt_wmb(); else
dma_wmb();
}
#define virtio_store_mb(weak_barriers, p, v) \ do { \ if (weak_barriers) { \
virt_store_mb(*p, v); \
} else { \
WRITE_ONCE(*p, v); \
mb(); \
} \
} while (0) \
/* * Creates a virtqueue and allocates the descriptor ring. If * may_reduce_num is set, then this may allocate a smaller ring than * expected. The caller should query virtqueue_get_vring_size to learn * the actual size of the ring.
*/ struct virtqueue *vring_create_virtqueue(unsignedint index, unsignedint num, unsignedint vring_align, struct virtio_device *vdev, bool weak_barriers, bool may_reduce_num, bool ctx, bool (*notify)(struct virtqueue *vq), void (*callback)(struct virtqueue *vq), constchar *name);
/* * Creates a virtqueue and allocates the descriptor ring with per * virtqueue DMA device.
*/ struct virtqueue *vring_create_virtqueue_dma(unsignedint index, unsignedint num, unsignedint vring_align, struct virtio_device *vdev, bool weak_barriers, bool may_reduce_num, bool ctx, bool (*notify)(struct virtqueue *vq), void (*callback)(struct virtqueue *vq), constchar *name, struct device *dma_dev);
/* * Creates a virtqueue with a standard layout but a caller-allocated * ring.
*/ struct virtqueue *vring_new_virtqueue(unsignedint index, unsignedint num, unsignedint vring_align, struct virtio_device *vdev, bool weak_barriers, bool ctx, void *pages, bool (*notify)(struct virtqueue *vq), void (*callback)(struct virtqueue *vq), constchar *name);
/* * Destroys a virtqueue. If created with vring_create_virtqueue, this * also frees the ring.
*/ void vring_del_virtqueue(struct virtqueue *vq);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.