qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send(


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send()
Date: Wed, 17 Mar 2010 12:52:06 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0

On 03/11/2010 10:55 AM, Juan Quintela wrote:
This way we can remove the poll test

Signed-off-by: Juan Quintela<address@hidden>

Won't this cause unnecessary wake ups?

Right now, we use the can_read() poll function to determine whether to add an fd to a fdset. With this patch, we always add the fd to the fdset and then we just fail the read.

To eliminate the poll function, we need to change the handlers from polling, to noticing when they no longer can be read, and remove the read callback entirely.

Regards,

Anthony Liguori

---
  net/tap.c |   27 +++++++++------------------
  1 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index 7a7320c..3ab65a3 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -61,17 +61,15 @@ typedef struct TAPState {

  static int launch_script(const char *setup_script, const char *ifname, int 
fd);

-static int tap_can_send(void *opaque);
  static void tap_send(void *opaque);
  static void tap_writable(void *opaque);

  static void tap_update_fd_handler(TAPState *s)
  {
-    qemu_set_fd_handler2(s->fd,
-                         s->read_poll  ? tap_can_send : NULL,
-                         s->read_poll  ? tap_send     : NULL,
-                         s->write_poll ? tap_writable : NULL,
-                         s);
+    qemu_set_fd_handler(s->fd,
+                        s->read_poll  ? tap_send     : NULL,
+                        s->write_poll ? tap_writable : NULL,
+                        s);
  }

  static void tap_read_poll(TAPState *s, int enable)
@@ -165,13 +163,6 @@ static ssize_t tap_receive(VLANClientState *nc, const 
uint8_t *buf, size_t size)
      return tap_write_packet(s, iov, 1);
  }

-static int tap_can_send(void *opaque)
-{
-    TAPState *s = opaque;
-
-    return qemu_can_send_packet(&s->nc);
-}
-
  #ifndef __sun__
  ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen)
  {
@@ -188,12 +179,10 @@ static void tap_send_completed(VLANClientState *nc, 
ssize_t len)
  static void tap_send(void *opaque)
  {
      TAPState *s = opaque;
-    int size;

-    do {
+    while (qemu_can_send_packet(&s->nc)>  0) {
          uint8_t *buf = s->buf;
-
-        size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
+        int size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
          if (size<= 0) {
              break;
          }
@@ -206,8 +195,10 @@ static void tap_send(void *opaque)
          size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed);
          if (size == 0) {
              tap_read_poll(s, 0);
+        } else if (size<  0) {
+            return;
          }
-    } while (size>  0&&  qemu_can_send_packet(&s->nc));
+    }
  }

  int tap_has_ufo(VLANClientState *nc)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]