From: Dor Laor <dor.laor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH 4/6] virtio network driver for QEMU (v2)
Date: Sun, 11 Nov 2007 19:31:23 +0200 [thread overview]
Message-ID: <47373C6B.7090102@qumranet.com> (raw)
In-Reply-To: <11947512454030-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Anthony Liguori wrote:
> This patch implements a very naive virtio network device backend in QEMU.
> Even with this simple implementation, it get's about 3x the throughput of
> rtl8139. Of course, there's a whole lot of room for optimization to eliminate
> the unnecessary copying and support more advanced features.
>
> To use a virtio network device, simply specific '-net nic,model=virtio'
>
> Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
>
[snip]
> +/* TX */
> +static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq)
> +{
> + VirtIONet *n = to_virtio_net(vdev);
> + VirtQueueElement elem;
> +
> + while (virtqueue_pop(vq, &elem)) {
> + int i;
> + size_t len = 0;
> +
> + /* ignore the header for now */
> + for (i = 1; i < elem.out_num; i++) {
> + qemu_send_packet(n->vc, elem.out_sg[i].iov_base,
> + elem.out_sg[i].iov_len);
> + len += elem.out_sg[i].iov_len;
> + }
> +
> + virtqueue_push(vq, &elem, sizeof(struct virtio_net_hdr) + len);
> + virtio_notify(&n->vdev, vq);
> + }
> +}
>
Get the notify out of the while please.
Regardless of above, at the moment you copy the receive packets into
virtio sg's.
I had a did an incomplete job of adding vectored read to qemu.
What's your opinion about it? Maybe using qemu's pending dma functions?
Regards & cheers,
Dor.
> +
> +VirtIODevice *virtio_net_init(PCIBus *bus, uint16_t vendor, uint16_t device,
> + NICInfo *nd, int devfn)
> +{
> + VirtIONet *n;
> +
> + n = (VirtIONet *)virtio_init_pci(bus, "virtio-net", vendor, device,
> + vendor, VIRTIO_ID_NET,
> + 6, sizeof(VirtIONet));
> +
> + n->vdev.update_config = virtio_net_update_config;
> + n->vdev.get_features = virtio_net_get_features;
> + n->rx_vq = virtio_add_queue(&n->vdev, virtio_net_handle_rx);
> + n->tx_vq = virtio_add_queue(&n->vdev, virtio_net_handle_tx);
> + n->can_receive = 0;
> + memcpy(n->mac, nd->macaddr, 6);
> + n->vc = qemu_new_vlan_client(nd->vlan, virtio_net_receive,
> + virtio_net_can_receive, n);
> +
> + return &n->vdev;
> +}
> diff --git a/qemu/vl.h b/qemu/vl.h
> index 7b5cc8d..4f26fbb 100644
> --- a/qemu/vl.h
> +++ b/qemu/vl.h
> @@ -1401,6 +1401,9 @@ VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,
>
> VirtIODevice *virtio_9p_init(PCIBus *bus, uint16_t vendor, uint16_t device);
>
> +VirtIODevice *virtio_net_init(PCIBus *bus, uint16_t vendor, uint16_t device,
> + NICInfo *nd, int devfn);
> +
> /* buf = NULL means polling */
> typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
> const uint8_t *buf, int len);
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-11-11 17:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-11 3:20 [PATCH 0/6] QEMU support for virtio (v2) Anthony Liguori
[not found] ` <11947512401155-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-11 3:20 ` [PATCH 1/6] Basic virtio infrastructure for QEMU (v2) Anthony Liguori
2007-11-11 3:20 ` [PATCH 2/6] virtio block driver " Anthony Liguori
[not found] ` <11947512432057-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-11 17:24 ` Dor Laor
[not found] ` <47373ADF.3000607-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-11 19:25 ` Anthony Liguori
[not found] ` <47375731.7020007-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-12 12:21 ` Dor Laor
[not found] ` <4738452F.8070502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-12 23:25 ` Anthony Liguori
[not found] ` <4738E102.2050200-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-13 0:28 ` Rusty Russell
[not found] ` <200711131128.44492.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2007-11-27 9:47 ` Avi Kivity
2007-11-12 15:02 ` Daniel P. Berrange
[not found] ` <20071112150211.GA14436-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2007-11-12 15:05 ` Avi Kivity
[not found] ` <47386BA9.8050000-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-12 23:26 ` Anthony Liguori
2007-11-11 3:20 ` [PATCH 3/6] 9p virtio transport " Anthony Liguori
2007-11-11 3:20 ` [PATCH 4/6] virtio network driver " Anthony Liguori
[not found] ` <11947512454030-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-11 17:31 ` Dor Laor [this message]
[not found] ` <47373C6B.7090102-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-11 19:29 ` Anthony Liguori
2007-11-11 3:20 ` [PATCH 5/6] Remove hypercall driver (v2) Anthony Liguori
[not found] ` <1194751246584-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-11 17:25 ` Dor Laor
2007-11-27 12:28 ` Avi Kivity
2007-11-11 3:20 ` [PATCH 6/6] Provide a mechanism to build virtio drivers as modules (v2) Anthony Liguori
[not found] ` <11947512473786-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-27 12:30 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47373C6B.7090102@qumranet.com \
--to=dor.laor-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox