Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio: Add get_shm_region method

Virtio defines 'shared memory regions' that provide a continuously
shared region between the host and guest.

Provide a method to find a particular region on a device.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Cc: kvm@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>

authored by

Sebastien Boeuf and committed by
Miklos Szeredi
5bfe37ca 9123e3a7

+17
+17
include/linux/virtio_config.h
··· 11 11 12 12 struct irq_affinity; 13 13 14 + struct virtio_shm_region { 15 + u64 addr; 16 + u64 len; 17 + }; 18 + 14 19 /** 15 20 * virtio_config_ops - operations for configuring a virtio device 16 21 * Note: Do not assume that a transport implements all of the operations ··· 71 66 * the caller can then copy. 72 67 * @set_vq_affinity: set the affinity for a virtqueue (optional). 73 68 * @get_vq_affinity: get the affinity for a virtqueue (optional). 69 + * @get_shm_region: get a shared memory region based on the index. 74 70 */ 75 71 typedef void vq_callback_t(struct virtqueue *); 76 72 struct virtio_config_ops { ··· 95 89 const struct cpumask *cpu_mask); 96 90 const struct cpumask *(*get_vq_affinity)(struct virtio_device *vdev, 97 91 int index); 92 + bool (*get_shm_region)(struct virtio_device *vdev, 93 + struct virtio_shm_region *region, u8 id); 98 94 }; 99 95 100 96 /* If driver didn't advertise the feature, it will never appear. */ ··· 257 249 if (vdev->config->set_vq_affinity) 258 250 return vdev->config->set_vq_affinity(vq, cpu_mask); 259 251 return 0; 252 + } 253 + 254 + static inline 255 + bool virtio_get_shm_region(struct virtio_device *vdev, 256 + struct virtio_shm_region *region, u8 id) 257 + { 258 + if (!vdev->config->get_shm_region) 259 + return false; 260 + return vdev->config->get_shm_region(vdev, region, id); 260 261 } 261 262 262 263 static inline bool virtio_is_little_endian(struct virtio_device *vdev)