public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com,
	prasadjoshi124@gmail.com, kvm@vger.kernel.org,
	Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 4/5] kvm tools: virtio-net code cleanup
Date: Thu,  5 May 2011 21:34:34 +0300	[thread overview]
Message-ID: <1304620475-10289-4-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1304620475-10289-1-git-send-email-levinsasha928@gmail.com>

Clean coding style and naming within virtio-net.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/virtio/net.c |   68 ++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index f0d24fa..61910f2 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -20,14 +20,14 @@
 #include <unistd.h>
 #include <sys/wait.h>
 
-#define VIRTIO_NET_IRQ		14
-#define VIRTIO_NET_PIN		3
+#define VIRTIO_NET_IRQ			14
+#define VIRTIO_NET_PIN			3
 
-#define VIRTIO_NET_QUEUE_SIZE	128
-#define VIRTIO_NET_NUM_QUEUES	2
-#define VIRTIO_NET_RX_QUEUE	0
-#define VIRTIO_NET_TX_QUEUE	1
-#define PCI_VIRTIO_NET_DEVNUM	3
+#define VIRTIO_NET_QUEUE_SIZE		128
+#define VIRTIO_NET_NUM_QUEUES		2
+#define VIRTIO_NET_RX_QUEUE		0
+#define VIRTIO_NET_TX_QUEUE		1
+#define PCI_VIRTIO_NET_DEVNUM		3
 
 struct net_device {
 	pthread_mutex_t			mutex;
@@ -53,20 +53,20 @@ struct net_device {
 };
 
 static struct net_device net_device = {
-	.mutex			= PTHREAD_MUTEX_INITIALIZER,
+	.mutex				= PTHREAD_MUTEX_INITIALIZER,
 
 	.net_config = {
-		.mac		= {0x00, 0x11, 0x22, 0x33, 0x44, 0x55},
-		.status		= VIRTIO_NET_S_LINK_UP,
+		.mac			= {0x00, 0x11, 0x22, 0x33, 0x44, 0x55},
+		.status			= VIRTIO_NET_S_LINK_UP,
 	},
-	.host_features		= 1UL << VIRTIO_NET_F_MAC |
-				  1UL << VIRTIO_NET_F_CSUM |
-				  1UL << VIRTIO_NET_F_HOST_UFO |
-				  1UL << VIRTIO_NET_F_HOST_TSO4 |
-				  1UL << VIRTIO_NET_F_HOST_TSO6 |
-				  1UL << VIRTIO_NET_F_GUEST_UFO |
-				  1UL << VIRTIO_NET_F_GUEST_TSO4 |
-				  1UL << VIRTIO_NET_F_GUEST_TSO6,
+	.host_features			= 1UL << VIRTIO_NET_F_MAC |
+					1UL << VIRTIO_NET_F_CSUM |
+					1UL << VIRTIO_NET_F_HOST_UFO |
+					1UL << VIRTIO_NET_F_HOST_TSO4 |
+					1UL << VIRTIO_NET_F_HOST_TSO6 |
+					1UL << VIRTIO_NET_F_GUEST_UFO |
+					1UL << VIRTIO_NET_F_GUEST_TSO4 |
+					1UL << VIRTIO_NET_F_GUEST_TSO6,
 };
 
 static void *virtio_net_rx_thread(void *p)
@@ -78,8 +78,8 @@ static void *virtio_net_rx_thread(void *p)
 	u16 head;
 	int len;
 
-	self = p;
-	vq = &net_device.vqs[VIRTIO_NET_RX_QUEUE];
+	self	= p;
+	vq	= &net_device.vqs[VIRTIO_NET_RX_QUEUE];
 
 	while (1) {
 		mutex_lock(&net_device.io_rx_mutex);
@@ -88,8 +88,8 @@ static void *virtio_net_rx_thread(void *p)
 		mutex_unlock(&net_device.io_rx_mutex);
 
 		while (virt_queue__available(vq)) {
-			head = virt_queue__get_iov(vq, iov, &out, &in, self);
-			len = readv(net_device.tap_fd, iov, in);
+			head	= virt_queue__get_iov(vq, iov, &out, &in, self);
+			len	= readv(net_device.tap_fd, iov, in);
 			virt_queue__set_used_elem(vq, head, len);
 			/* We should interrupt guest right now, otherwise latency is huge. */
 			kvm__irq_line(self, VIRTIO_NET_IRQ, 1);
@@ -111,8 +111,8 @@ static void *virtio_net_tx_thread(void *p)
 	u16 head;
 	int len;
 
-	self = p;
-	vq = &net_device.vqs[VIRTIO_NET_TX_QUEUE];
+	self	= p;
+	vq	= &net_device.vqs[VIRTIO_NET_TX_QUEUE];
 
 	while (1) {
 		mutex_lock(&net_device.io_tx_mutex);
@@ -121,8 +121,8 @@ static void *virtio_net_tx_thread(void *p)
 		mutex_unlock(&net_device.io_tx_mutex);
 
 		while (virt_queue__available(vq)) {
-			head = virt_queue__get_iov(vq, iov, &out, &in, self);
-			len = writev(net_device.tap_fd, iov, out);
+			head	= virt_queue__get_iov(vq, iov, &out, &in, self);
+			len	= writev(net_device.tap_fd, iov, out);
 			virt_queue__set_used_elem(vq, head, len);
 		}
 
@@ -150,8 +150,8 @@ static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offse
 
 static bool virtio_net_pci_io_in(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
-	unsigned long offset = port - IOPORT_VIRTIO_NET;
-	bool ret = true;
+	unsigned long	offset	= port - IOPORT_VIRTIO_NET;
+	bool		ret	= true;
 
 	mutex_lock(&net_device.mutex);
 
@@ -210,8 +210,8 @@ static void virtio_net_handle_callback(struct kvm *self, u16 queue_index)
 
 static bool virtio_net_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)
 {
-	unsigned long offset = port - IOPORT_VIRTIO_NET;
-	bool ret = true;
+	unsigned long	offset			= port - IOPORT_VIRTIO_NET;
+	bool		ret			= true;
 
 	mutex_lock(&net_device.mutex);
 
@@ -225,9 +225,9 @@ static bool virtio_net_pci_io_out(struct kvm *self, u16 port, void *data, int si
 
 		assert(net_device.queue_selector < VIRTIO_NET_NUM_QUEUES);
 
-		queue		= &net_device.vqs[net_device.queue_selector];
-		queue->pfn	= ioport__read32(data);
-		p		= guest_flat_to_host(self, queue->pfn << 12);
+		queue				= &net_device.vqs[net_device.queue_selector];
+		queue->pfn			= ioport__read32(data);
+		p				= guest_flat_to_host(self, queue->pfn << 12);
 
 		vring_init(&queue->vring, VIRTIO_NET_QUEUE_SIZE, p, 4096);
 
@@ -251,7 +251,7 @@ static bool virtio_net_pci_io_out(struct kvm *self, u16 port, void *data, int si
 	case VIRTIO_MSI_QUEUE_VECTOR:
 		break;
 	default:
-		ret = false;
+		ret				= false;
 	};
 
 	mutex_unlock(&net_device.mutex);
-- 
1.7.5.rc3


  parent reply	other threads:[~2011-05-05 18:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 18:34 [PATCH 1/5] kvm tools: Abolishment of uint*_t types Sasha Levin
2011-05-05 18:34 ` [PATCH 2/5] kvm tools: virtio-blk code cleanup Sasha Levin
2011-05-05 18:34 ` [PATCH 3/5] kvm tools: virtio-console " Sasha Levin
2011-05-05 18:34 ` Sasha Levin [this message]
2011-05-05 18:34 ` [PATCH 5/5] kvm tools: virtio-rng " Sasha Levin
2011-05-05 19:06   ` Ingo Molnar
2011-05-05 19:02 ` [PATCH 1/5] kvm tools: Abolishment of uint*_t types Pekka Enberg

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=1304620475-10289-4-git-send-email-levinsasha928@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox