]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
virtio-net: simplify rx code
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 24 Sep 2012 12:54:44 +0000 (14:54 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 29 Oct 2012 16:25:23 +0000 (18:25 +0200)
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 <mst@redhat.com>
hw/virtio-net.c

index 520664827108b0f74e11e43874698cd8444a685d..dc4a26cbd62f28f42109ad114449b7b02c4d89c4 100644 (file)
@@ -720,12 +720,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);
         }
@@ -747,7 +742,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);