From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGHgj-0006hA-IR for qemu-devel@nongnu.org; Mon, 24 Sep 2012 19:03:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGHgi-0005bD-EG for qemu-devel@nongnu.org; Mon, 24 Sep 2012 19:03:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGHgi-0005b8-55 for qemu-devel@nongnu.org; Mon, 24 Sep 2012 19:03:40 -0400 Date: Tue, 25 Sep 2012 01:04:56 +0200 From: "Michael S. Tsirkin" Message-ID: <8fd64fbf244534376966c376e42dc6ecdc936dbc.1348527749.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH 09/14] virtio-net: simplify rx code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Jason Wang , Anthony Liguori , stefanha@linux.vnet.ibm.com, aurelien@aurel32.net Remove code duplication using guest header length that we track. Drop specific layout requirement for rx buffers: things work using generic iovec functions in any case. Signed-off-by: Michael S. Tsirkin --- hw/virtio-net.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 23feb21..2381ee5 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -719,12 +719,7 @@ static int32_t virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq) struct iovec *out_sg = &elem.out_sg[0]; struct iovec sg[VIRTQUEUE_MAX_SIZE]; - /* hdr_len refers to the header received from the guest */ - hdr_len = n->mergeable_rx_bufs ? - sizeof(struct virtio_net_hdr_mrg_rxbuf) : - sizeof(struct virtio_net_hdr); - - if (out_num < 1 || out_sg->iov_len != hdr_len) { + if (out_num < 1) { error_report("virtio-net header not in first element"); exit(1); } @@ -746,7 +741,7 @@ static int32_t virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq) out_sg = sg; } - len = hdr_len; + len = n->guest_hdr_len; ret = qemu_sendv_packet_async(&n->nic->nc, out_sg, out_num, virtio_net_tx_complete); -- MST