qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org,
	blauwirbel@gmail.com, shajnocz@redhat.com
Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com,
	Jason Wang <jasowang@redhat.com>,
	rusty@rustcorp.com.au, jwhan@filewood.snu.ac.kr,
	gaowanlong@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH V4 RESEND 01/22] net: tap: using bool instead of bitfield
Date: Fri,  1 Feb 2013 15:39:35 +0800	[thread overview]
Message-ID: <1359704396-55327-2-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1359704396-55327-1-git-send-email-jasowang@redhat.com>

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio-net.c   |    2 +-
 include/net/tap.h |    4 ++--
 net/tap-win32.c   |    6 +++---
 net/tap.c         |   38 ++++++++++++++++++--------------------
 4 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index dfb9687..b5579b4 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -1102,7 +1102,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
     n->nic = qemu_new_nic(&net_virtio_info, conf, object_get_typename(OBJECT(dev)), dev->id, n);
     peer_test_vnet_hdr(n);
     if (peer_has_vnet_hdr(n)) {
-        tap_using_vnet_hdr(n->nic->nc.peer, 1);
+        tap_using_vnet_hdr(n->nic->nc.peer, true);
         n->host_hdr_len = sizeof(struct virtio_net_hdr);
     } else {
         n->host_hdr_len = 0;
diff --git a/include/net/tap.h b/include/net/tap.h
index bb7efb5..883cebf 100644
--- a/include/net/tap.h
+++ b/include/net/tap.h
@@ -29,10 +29,10 @@
 #include "qemu-common.h"
 #include "qapi-types.h"
 
-int tap_has_ufo(NetClientState *nc);
+bool tap_has_ufo(NetClientState *nc);
 int tap_has_vnet_hdr(NetClientState *nc);
 int tap_has_vnet_hdr_len(NetClientState *nc, int len);
-void tap_using_vnet_hdr(NetClientState *nc, int using_vnet_hdr);
+void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr);
 void tap_set_offload(NetClientState *nc, int csum, int tso4, int tso6, int ecn, int ufo);
 void tap_set_vnet_hdr_len(NetClientState *nc, int len);
 
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 265369c..3052bba 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -722,9 +722,9 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
     return 0;
 }
 
-int tap_has_ufo(NetClientState *nc)
+bool tap_has_ufo(NetClientState *nc)
 {
-    return 0;
+    return false;
 }
 
 int tap_has_vnet_hdr(NetClientState *nc)
@@ -741,7 +741,7 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
 {
 }
 
-void tap_using_vnet_hdr(NetClientState *nc, int using_vnet_hdr)
+void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
 {
 }
 
diff --git a/net/tap.c b/net/tap.c
index eb40c42..5542c98 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -55,10 +55,10 @@ typedef struct TAPState {
     char down_script[1024];
     char down_script_arg[128];
     uint8_t buf[TAP_BUFSIZE];
-    unsigned int read_poll : 1;
-    unsigned int write_poll : 1;
-    unsigned int using_vnet_hdr : 1;
-    unsigned int has_ufo: 1;
+    bool read_poll;
+    bool write_poll;
+    bool using_vnet_hdr;
+    bool has_ufo;
     VHostNetState *vhost_net;
     unsigned host_vnet_hdr_len;
 } TAPState;
@@ -78,15 +78,15 @@ static void tap_update_fd_handler(TAPState *s)
                          s);
 }
 
-static void tap_read_poll(TAPState *s, int enable)
+static void tap_read_poll(TAPState *s, bool enable)
 {
-    s->read_poll = !!enable;
+    s->read_poll = enable;
     tap_update_fd_handler(s);
 }
 
-static void tap_write_poll(TAPState *s, int enable)
+static void tap_write_poll(TAPState *s, bool enable)
 {
-    s->write_poll = !!enable;
+    s->write_poll = enable;
     tap_update_fd_handler(s);
 }
 
@@ -94,7 +94,7 @@ static void tap_writable(void *opaque)
 {
     TAPState *s = opaque;
 
-    tap_write_poll(s, 0);
+    tap_write_poll(s, false);
 
     qemu_flush_queued_packets(&s->nc);
 }
@@ -108,7 +108,7 @@ static ssize_t tap_write_packet(TAPState *s, const struct iovec *iov, int iovcnt
     } while (len == -1 && errno == EINTR);
 
     if (len == -1 && errno == EAGAIN) {
-        tap_write_poll(s, 1);
+        tap_write_poll(s, true);
         return 0;
     }
 
@@ -186,7 +186,7 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen)
 static void tap_send_completed(NetClientState *nc, ssize_t len)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
-    tap_read_poll(s, 1);
+    tap_read_poll(s, true);
 }
 
 static void tap_send(void *opaque)
@@ -209,12 +209,12 @@ 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);
+            tap_read_poll(s, false);
         }
     } while (size > 0 && qemu_can_send_packet(&s->nc));
 }
 
-int tap_has_ufo(NetClientState *nc)
+bool tap_has_ufo(NetClientState *nc)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
 
@@ -253,12 +253,10 @@ void tap_set_vnet_hdr_len(NetClientState *nc, int len)
     s->host_vnet_hdr_len = len;
 }
 
-void tap_using_vnet_hdr(NetClientState *nc, int using_vnet_hdr)
+void tap_using_vnet_hdr(NetClientState *nc, bool using_vnet_hdr)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
 
-    using_vnet_hdr = using_vnet_hdr != 0;
-
     assert(nc->info->type == NET_CLIENT_OPTIONS_KIND_TAP);
     assert(!!s->host_vnet_hdr_len == using_vnet_hdr);
 
@@ -290,8 +288,8 @@ static void tap_cleanup(NetClientState *nc)
     if (s->down_script[0])
         launch_script(s->down_script, s->down_script_arg, s->fd);
 
-    tap_read_poll(s, 0);
-    tap_write_poll(s, 0);
+    tap_read_poll(s, false);
+    tap_write_poll(s, false);
     close(s->fd);
     s->fd = -1;
 }
@@ -337,7 +335,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
 
     s->fd = fd;
     s->host_vnet_hdr_len = vnet_hdr ? sizeof(struct virtio_net_hdr) : 0;
-    s->using_vnet_hdr = 0;
+    s->using_vnet_hdr = false;
     s->has_ufo = tap_probe_has_ufo(s->fd);
     tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
     /*
@@ -347,7 +345,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer,
     if (tap_probe_vnet_hdr_len(s->fd, s->host_vnet_hdr_len)) {
         tap_fd_set_vnet_hdr_len(s->fd, s->host_vnet_hdr_len);
     }
-    tap_read_poll(s, 1);
+    tap_read_poll(s, true);
     s->vhost_net = NULL;
     return s;
 }
-- 
1.7.1

  reply	other threads:[~2013-02-01  7:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01  7:39 [Qemu-devel] [PATCH V4 RESEND 00/22] Multiqueue virtio-net Jason Wang
2013-02-01  7:39 ` Jason Wang [this message]
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 02/22] net: tap: use abort() instead of assert(0) Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 03/22] net: introduce qemu_get_queue() Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 04/22] net: introduce qemu_get_nic() Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 05/22] net: intorduce qemu_del_nic() Jason Wang
2013-02-01 18:00   ` Eric Blake
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 06/22] net: introduce qemu_find_net_clients_except() Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 07/22] net: introduce qemu_net_client_setup() Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 08/22] net: introduce NetClientState destructor Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 09/22] net: multiqueue support Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 10/22] tap: import linux multiqueue constants Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 11/22] tap: factor out common tap initialization Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 12/22] tap: add Linux multiqueue support Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 13/22] tap: support enabling or disabling a queue Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 14/22] tap: introduce a helper to get the name of an interface Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 15/22] tap: multiqueue support Jason Wang
2013-02-01 22:43   ` Eric Blake
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 17/22] virtio: introduce virtio_del_queue() Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 18/22] virtio: add a queue_index to VirtQueue Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 19/22] virtio-net: separate virtqueue from VirtIONet Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 20/22] virtio-net: multiqueue support Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 21/22] virtio-net: migration support for multiqueue Jason Wang
2013-02-01  7:39 ` [Qemu-devel] [PATCH V4 RESEND 22/22] virtio-net: compat multiqueue support Jason Wang
2013-02-01  8:22 ` [Qemu-devel] [PATCH V4 RESEND 00/22] Multiqueue virtio-net Jason Wang

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=1359704396-55327-2-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=jwhan@filewood.snu.ac.kr \
    --cc=krkumar2@in.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mprivozn@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rusty@rustcorp.com.au \
    --cc=shajnocz@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).