Commit 9499f5e7 authored by Rusty Russell's avatar Rusty Russell
Browse files

virtio: add names to virtqueue struct, mapping from devices to queues.



Add a linked list of all virtqueues for a virtio device: this helps for
debugging and is also needed for upcoming interface change.

Also, add a "name" field for clearer debug messages.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent ef688e15
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -288,7 +288,7 @@ static int virtblk_probe(struct virtio_device *vdev)
	sg_init_table(vblk->sg, vblk->sg_elems);

	/* We expect one virtqueue, for output. */
	vblk->vq = vdev->config->find_vq(vdev, 0, blk_done);
	vblk->vq = vdev->config->find_vq(vdev, 0, blk_done, "requests");
	if (IS_ERR(vblk->vq)) {
		err = PTR_ERR(vblk->vq);
		goto out_free_vblk;
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ static int virtrng_probe(struct virtio_device *vdev)
	int err;

	/* We expect a single virtqueue. */
	vq = vdev->config->find_vq(vdev, 0, random_recv_done);
	vq = vdev->config->find_vq(vdev, 0, random_recv_done, "input");
	if (IS_ERR(vq))
		return PTR_ERR(vq);

+2 −2
Original line number Diff line number Diff line
@@ -202,13 +202,13 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
	/* Find the input queue. */
	/* FIXME: This is why we want to wean off hvc: we do nothing
	 * when input comes in. */
	in_vq = vdev->config->find_vq(vdev, 0, hvc_handle_input);
	in_vq = vdev->config->find_vq(vdev, 0, hvc_handle_input, "input");
	if (IS_ERR(in_vq)) {
		err = PTR_ERR(in_vq);
		goto free;
	}

	out_vq = vdev->config->find_vq(vdev, 1, NULL);
	out_vq = vdev->config->find_vq(vdev, 1, NULL, "output");
	if (IS_ERR(out_vq)) {
		err = PTR_ERR(out_vq);
		goto free_in_vq;
+3 −2
Original line number Diff line number Diff line
@@ -228,7 +228,8 @@ extern void lguest_setup_irq(unsigned int irq);
 * function. */
static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
				    unsigned index,
				    void (*callback)(struct virtqueue *vq))
				    void (*callback)(struct virtqueue *vq),
				    const char *name)
{
	struct lguest_device *ldev = to_lgdev(vdev);
	struct lguest_vq_info *lvq;
@@ -263,7 +264,7 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
	/* OK, tell virtio_ring.c to set up a virtqueue now we know its size
	 * and we've got a pointer to its pages. */
	vq = vring_new_virtqueue(lvq->config.num, LGUEST_VRING_ALIGN,
				 vdev, lvq->pages, lg_notify, callback);
				 vdev, lvq->pages, lg_notify, callback, name);
	if (!vq) {
		err = -ENOMEM;
		goto unmap;
+3 −3
Original line number Diff line number Diff line
@@ -906,20 +906,20 @@ static int virtnet_probe(struct virtio_device *vdev)
		vi->mergeable_rx_bufs = true;

	/* We expect two virtqueues, receive then send. */
	vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
	vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done, "input");
	if (IS_ERR(vi->rvq)) {
		err = PTR_ERR(vi->rvq);
		goto free;
	}

	vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done);
	vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done, "output");
	if (IS_ERR(vi->svq)) {
		err = PTR_ERR(vi->svq);
		goto free_recv;
	}

	if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
		vi->cvq = vdev->config->find_vq(vdev, 2, NULL);
		vi->cvq = vdev->config->find_vq(vdev, 2, NULL, "control");
		if (IS_ERR(vi->cvq)) {
			err = PTR_ERR(vi->svq);
			goto free_send;
Loading