From patchwork Thu May 5 18:34:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 757902 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p45IZXio029142 for ; Thu, 5 May 2011 18:35:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932095Ab1EESf0 (ORCPT ); Thu, 5 May 2011 14:35:26 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:39451 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932084Ab1EESfY (ORCPT ); Thu, 5 May 2011 14:35:24 -0400 Received: by wya21 with SMTP id 21so1836365wya.19 for ; Thu, 05 May 2011 11:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=dbeUl6O4Jh4xXZ/x2K1bXl3E7C08FJ4RCNnvulvPy4A=; b=A4yVDsnnZKqHWvMT/cznuR4KSHssWeE9rGlwxe/M7ELNmhUOH+9Ig2Eorl5mBggHXL AQc7rj2TP3m+r5p0Y+LTap05Olpp5eOLDqA69DRUvwIocbJOxvEv2KnbdcNR4flFWtSX ULl7XdGfM9yr/PlGeA7pEHXiuHkUsAFlAl+Yc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=x78VUh84zXhXR2FUiADEVK6FP02pxY4QU4KJh0g1bC4ePToQiwELrMzrDmFISc2sgR Qlsftfg4gbOmaYoMzqPknVWo13D3dnVAnxMYOFEUyiumhT4jL+7ddCczeYKxt/D2L8bM 5bsHJZKRA9yQ56vmK4qh9AabJybYeTINyfEaM= Received: by 10.227.196.82 with SMTP id ef18mr2858381wbb.114.1304620523294; Thu, 05 May 2011 11:35:23 -0700 (PDT) Received: from localhost.localdomain ([109.65.211.213]) by mx.google.com with ESMTPS id x13sm1037449wby.25.2011.05.05.11.35.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 May 2011 11:35:23 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 4/5] kvm tools: virtio-net code cleanup Date: Thu, 5 May 2011 21:34:34 +0300 Message-Id: <1304620475-10289-4-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1304620475-10289-1-git-send-email-levinsasha928@gmail.com> References: <1304620475-10289-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 05 May 2011 18:35:33 +0000 (UTC) Clean coding style and naming within virtio-net. Signed-off-by: Sasha Levin --- 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 #include -#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);