]> Pileus Git - ~andy/linux/commitdiff
virtio: support reserved vqs
authorMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Sep 2012 18:47:45 +0000 (21:47 +0300)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 28 Sep 2012 05:35:15 +0000 (15:05 +0930)
virtio network device multiqueue support reserves
vq 3 for future use (useful both for future extensions and to make it
pretty - this way receive vqs have even and transmit - odd numbers).
Make it possible to skip initialization for
specific vq numbers by specifying NULL for name.
Document this usage as well as (existing) NULL callback.

Drivers using this not coded up yet, so I simply tested
with virtio-pci and verified that this patch does
not break existing drivers.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/lguest/lguest_device.c
drivers/remoteproc/remoteproc_virtio.c
drivers/s390/kvm/kvm_virtio.c
drivers/virtio/virtio_mmio.c
drivers/virtio/virtio_pci.c
include/linux/virtio_config.h

index ccb7dfb028fa4937dc87f6954d3ca17b379811fb..fc92ccbd71dc22472c9c6fcea4fb54e5079fa19e 100644 (file)
@@ -263,6 +263,9 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
        struct virtqueue *vq;
        int err;
 
+       if (!name)
+               return NULL;
+
        /* We must have this many virtqueues. */
        if (index >= ldev->desc->num_vq)
                return ERR_PTR(-ENOENT);
index 343c1941c12327f527be058f619b3aaad835a288..e7a4780e93db4fb8ab9c3134debc960930cd6906 100644 (file)
@@ -84,6 +84,9 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev,
        if (id >= ARRAY_SIZE(rvdev->vring))
                return ERR_PTR(-EINVAL);
 
+       if (!name)
+               return NULL;
+
        ret = rproc_alloc_vring(rvdev, id);
        if (ret)
                return ERR_PTR(ret);
index 5565af20592fd3bb16c9d449391130fc2f9e1900..7dabef624da394e6b90a2e04c787f74a4ffaa98d 100644 (file)
@@ -190,6 +190,9 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
        if (index >= kdev->desc->num_vq)
                return ERR_PTR(-ENOENT);
 
+       if (!name)
+               return NULL;
+
        config = kvm_vq_config(kdev->desc)+index;
 
        err = vmem_add_mapping(config->address,
index 008bf58bdaae538e5598327f3f27c40327d7e6f0..5d7fee385b70f1b004218a5458f49ac6485e1fd0 100644 (file)
@@ -306,6 +306,9 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index,
        unsigned long flags, size;
        int err;
 
+       if (!name)
+               return NULL;
+
        /* Select the queue we're interested in */
        writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
 
index f5dfe6bdb9598c7ac4b5ef4553cee62190d83732..42b20769d122f047d3cdb1d932893244713c1a0d 100644 (file)
@@ -555,7 +555,10 @@ static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs,
        vp_dev->per_vq_vectors = per_vq_vectors;
        allocated_vectors = vp_dev->msix_used_vectors;
        for (i = 0; i < nvqs; ++i) {
-               if (!callbacks[i] || !vp_dev->msix_enabled)
+               if (!names[i]) {
+                       vqs[i] = NULL;
+                       continue;
+               } else if (!callbacks[i] || !vp_dev->msix_enabled)
                        msix_vec = VIRTIO_MSI_NO_VECTOR;
                else if (vp_dev->per_vq_vectors)
                        msix_vec = allocated_vectors++;
index 2c4a9895379d7b046f039c5d1d9400af622318db..e2850a7ea2762ef01351c05b38bc31c6db721ab4 100644 (file)
@@ -84,7 +84,9 @@
  *     nvqs: the number of virtqueues to find
  *     vqs: on success, includes new virtqueues
  *     callbacks: array of callbacks, for each virtqueue
+ *             include a NULL entry for vqs that do not need a callback
  *     names: array of virtqueue names (mainly for debugging)
+ *             include a NULL entry for vqs unused by driver
  *     Returns 0 on success or error status
  * @del_vqs: free virtqueues found by find_vqs().
  * @get_features: get the array of feature bits for this device.