[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200901301538.06975.rusty@rustcorp.com.au>
Date: Fri, 30 Jan 2009 15:38:06 +1030
From: Rusty Russell <rusty@...tcorp.com.au>
To: Alex Williamson <alex.williamson@...com>
Cc: markmc@...hat.com, netdev@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH v2 1/4] virtio_net: Add a virtqueue for outbound control commands
On Friday 30 January 2009 09:35:07 Alex Williamson wrote:
> +static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
> + void *data, unsigned int len)
> +{
> + struct scatterlist sg[3];
> + struct virtio_net_ctrl_hdr ctrl;
> + virtio_net_ctrl_ack status;
> + unsigned int tmp;
> + int i = 0;
> +
> + if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
> + return false;
> +
> + sg_init_table(sg, len ? 3 : 2);
I'd test data rather than len here.
> + sg_set_buf(&sg[i++], &ctrl, sizeof(ctrl));
> + if (len)
> + sg_set_buf(&sg[i++], data, len);
> + sg_set_buf(&sg[i], &status, sizeof(status));
> +
> + ctrl.class = class;
> + ctrl.cmd = cmd;
> +
> + status = ~0;
> +
> + if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, i, 1, vi) != 0)
> + BUG();
Hmm, I prefer initialize buffer, then set sg to refer to it. Seems to make
more sense to me.
> + while (!vi->cvq->vq_ops->get_buf(vi->cvq, &tmp))
> + cpu_relax();
This probably deserves a comment about why it's OK to spin here.
> + return status == VIRTIO_NET_OK ? true : false;
Or "return status == VIRTIO_NET_OK;" ?
See what I mean about nit-picking?
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists