From: Mark McLoughlin <markmc@redhat.com>
To: qemu-devel@nongnu.org
Cc: Sven Rudolph <Sven_Rudolph@drewag.de>,
Scott Tsai <scottt.tw@gmail.com>,
Mark McLoughlin <markmc@redhat.com>
Subject: [Qemu-devel] [PATCH 4/5] virtio-net: split the has_buffers() logic from can_receive()
Date: Tue, 27 Oct 2009 18:16:38 +0000 [thread overview]
Message-ID: <1256667399-3149-5-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1256667399-3149-1-git-send-email-markmc@redhat.com>
We should only return zero from receive() for a condition which we'll
get notification of when it changes. Currently, we're returning zero
if the guest driver is not ready, but we won't ever flush our queue
when that status changes.
Also, don't check buffer space in can_receive(), but instead just allow
receive() to return zero when this condition occurs and have the caller
handle queueing the packet.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/virtio-net.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 7ee393b..a30aff4 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -367,12 +367,19 @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
qemu_notify_event();
}
-static int do_virtio_net_can_receive(VirtIONet *n, int bufsize)
+static int virtio_net_can_receive(VLANClientState *vc)
{
+ VirtIONet *n = vc->opaque;
+
if (!virtio_queue_ready(n->rx_vq) ||
!(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK))
return 0;
+ return 1;
+}
+
+static int virtio_net_has_buffers(VirtIONet *n, int bufsize)
+{
if (virtio_queue_empty(n->rx_vq) ||
(n->mergeable_rx_bufs &&
!virtqueue_avail_bytes(n->rx_vq, bufsize, 0))) {
@@ -384,13 +391,6 @@ static int do_virtio_net_can_receive(VirtIONet *n, int bufsize)
return 1;
}
-static int virtio_net_can_receive(VLANClientState *vc)
-{
- VirtIONet *n = vc->opaque;
-
- return do_virtio_net_can_receive(n, VIRTIO_NET_MAX_BUFSIZE);
-}
-
/* dhclient uses AF_PACKET but doesn't pass auxdata to the kernel so
* it never finds out that the packets don't have valid checksums. This
* causes dhclient to get upset. Fedora's carried a patch for ages to
@@ -517,7 +517,10 @@ static ssize_t virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_
struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
size_t hdr_len, offset, i;
- if (!do_virtio_net_can_receive(n, size))
+ if (!virtio_net_can_receive(n->vc))
+ return -1;
+
+ if (!virtio_net_has_buffers(n, size))
return 0;
if (!receive_filter(n, buf, size))
--
1.6.2.5
next prev parent reply other threads:[~2009-10-27 18:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 18:16 [Qemu-devel] [PATCH 0/5] Fix packet queueing to allow full tap queue drain Mark McLoughlin
2009-10-27 18:16 ` [Qemu-devel] [PATCH 1/5] tap: disable draining queue in one go Mark McLoughlin
2009-10-27 18:16 ` [Qemu-devel] [PATCH 2/5] net: disable receiving if client returns zero Mark McLoughlin
2009-10-27 18:16 ` [Qemu-devel] [PATCH 3/5] net/queue: queue packets even if sender doesn't supply a callback Mark McLoughlin
2009-10-27 18:16 ` Mark McLoughlin [this message]
2009-10-27 18:16 ` [Qemu-devel] [PATCH 5/5] tap: drain queue in tap_send() Mark McLoughlin
2009-10-30 16:21 ` Anthony Liguori
2009-10-30 16:34 ` Mark McLoughlin
2009-10-30 17:46 ` Anthony Liguori
2009-10-28 3:36 ` [Qemu-devel] Re: [PATCH 0/5] Fix packet queueing to allow full tap queue drain Scott Tsai
2009-10-28 8:49 ` Mark McLoughlin
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=1256667399-3149-5-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=Sven_Rudolph@drewag.de \
--cc=qemu-devel@nongnu.org \
--cc=scottt.tw@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.