From: Cyrill Gorcunov <gorcunov@gmail.com>
To: penberg@kernel.org, mingo@elte.hu
Cc: asias.hejun@gmail.com, prasadjoshi124@gmail.com,
kvm@vger.kernel.org, levinsasha928@gmail.com,
Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [patch 1/2] kvm tools: Gather Virtio-PCI constants into one place
Date: Thu, 05 May 2011 23:06:40 +0400 [thread overview]
Message-ID: <20110505190733.367888565@gmail.com> (raw)
In-Reply-To: 20110505190639.741709609@gmail.com
[-- Attachment #1: kvm-tools-virtio-pci --]
[-- Type: text/plain, Size: 8016 bytes --]
It's better than have them sprinkled in.c files. Note
that pin for ring device is changed so it no longer shared
with block device (it is done in a sake of simplicity).
Also comment style if a bit tuned up in virtio-pci.h
just to be consistent.
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
tools/kvm/include/kvm/virtio-pci-dev.h | 40 +++++++++++++++++++++++++++++++++
tools/kvm/include/kvm/virtio-pci.h | 31 ++++++++++++++++++-------
tools/kvm/virtio-blk.c | 11 ---------
tools/kvm/virtio-console.c | 10 --------
tools/kvm/virtio-net.c | 10 --------
tools/kvm/virtio-rng.c | 10 --------
6 files changed, 67 insertions(+), 45 deletions(-)
Index: linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h
=====================================================================
--- /dev/null
+++ linux-2.6.git/tools/kvm/include/kvm/virtio-pci-dev.h
@@ -0,0 +1,40 @@
+#ifndef VIRTIO_PCI_DEV_H_
+#define VIRTIO_PCI_DEV_H_
+
+/*
+ * Virtio PCI device constants and resources
+ * they do use (such as irqs and pins).
+ */
+
+#define PCI_DEVICE_ID_VIRTIO_NET 0x1000
+#define PCI_DEVICE_ID_VIRTIO_BLK 0x1001
+#define PCI_DEVICE_ID_VIRTIO_CONSOLE 0x1003
+#define PCI_DEVICE_ID_VIRTIO_RNG 0x1004
+
+#define PCI_SUBSYSTEM_ID_VIRTIO_NET 0x0001
+#define PCI_SUBSYSTEM_ID_VIRTIO_BLK 0x0002
+#define PCI_SUBSYSTEM_ID_VIRTIO_CONSOLE 0x0003
+#define PCI_SUBSYSTEM_ID_VIRTIO_RNG 0x0004
+
+enum {
+ PCI_VIRTIO_BLK_DEVNUM = 1,
+ PCI_VIRTIO_CONSOLE_DEVNUM = 2,
+ PCI_VIRTIO_NET_DEVNUM = 3,
+ PCI_VIRTIO_RNG_DEVNUM = 4,
+};
+
+enum {
+ VIRTIO_BLK_PIN = 1,
+ VIRTIO_CONSOLE_PIN = 2,
+ VIRTIO_NET_PIN = 3,
+ VIRTIO_RNG_PIN = 4,
+};
+
+enum {
+ VIRTIO_RNG_IRQ = 11,
+ VIRTIO_CONSOLE_IRQ = 13,
+ VIRTIO_NET_IRQ = 14,
+ VIRTIO_BLK_IRQ = 15,
+};
+
+#endif /* VIRTIO_PCI_DEV_H_ */
Index: linux-2.6.git/tools/kvm/include/kvm/virtio-pci.h
=====================================================================
--- linux-2.6.git.orig/tools/kvm/include/kvm/virtio-pci.h
+++ linux-2.6.git/tools/kvm/include/kvm/virtio-pci.h
@@ -34,26 +34,41 @@
/* A 16-bit r/w queue notifier */
#define VIRTIO_PCI_QUEUE_NOTIFY 16
-/* An 8-bit device status register. */
+/* An 8-bit device status register */
#define VIRTIO_PCI_STATUS 18
-/* An 8-bit r/o interrupt status register. Reading the value will return the
- * current contents of the ISR and will also clear it. This is effectively
- * a read-and-acknowledge. */
+/*
+ * An 8-bit r/o interrupt status register.
+ *
+ * Reading the value will return the current contents of
+ * the ISR and will also clear it. This is effectively
+ * a read-and-acknowledge.
+ */
#define VIRTIO_PCI_ISR 19
-/* MSI-X registers: only enabled if MSI-X is enabled. */
-/* A 16-bit vector for configuration changes. */
+/*
+ * MSI-X registers: only enabled if MSI-X is enabled.
+ */
+
+/* A 16-bit vector for configuration changes */
#define VIRTIO_MSI_CONFIG_VECTOR 20
-/* A 16-bit vector for selected queue notifications. */
+/* A 16-bit vector for selected queue notifications */
#define VIRTIO_MSI_QUEUE_VECTOR 22
/* Vector value used to disable MSI for queue */
#define VIRTIO_MSI_NO_VECTOR 0xffff
-/* Config space size */
+/*
+ * Config space size.
+ */
#define VIRTIO_PCI_CONFIG_NOMSI 20
#define VIRTIO_PCI_CONFIG_MSI 24
+/*
+ * Virtio config space constants.
+ */
+#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
+#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET 0x1af4
+
#endif /* _LINUX_VIRTIO_PCI_H */
Index: linux-2.6.git/tools/kvm/virtio-blk.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio-blk.c
+++ linux-2.6.git/tools/kvm/virtio-blk.c
@@ -1,6 +1,7 @@
#include "kvm/virtio-blk.h"
#include "kvm/virtio-pci.h"
+#include "kvm/virtio-pci-dev.h"
#include "kvm/disk-image.h"
#include "kvm/virtio.h"
@@ -17,9 +18,6 @@
#include <inttypes.h>
#include <pthread.h>
-#define VIRTIO_BLK_IRQ 15
-#define VIRTIO_BLK_PIN 1
-
#define NUM_VIRT_QUEUES 1
#define VIRTIO_BLK_QUEUE_SIZE 128
@@ -223,11 +221,6 @@ static struct ioport_operations virtio_b
.io_out = virtio_blk_pci_io_out,
};
-#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_DEVICE_ID_VIRTIO_BLK 0x1001
-#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_SUBSYSTEM_ID_VIRTIO_BLK 0x0002
-
static struct pci_device_header virtio_blk_pci_device = {
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
.device_id = PCI_DEVICE_ID_VIRTIO_BLK,
@@ -241,8 +234,6 @@ static struct pci_device_header virtio_b
.irq_line = VIRTIO_BLK_IRQ,
};
-#define PCI_VIRTIO_BLK_DEVNUM 1
-
void virtio_blk__init(struct kvm *self)
{
if (!self->disk_image)
Index: linux-2.6.git/tools/kvm/virtio-console.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio-console.c
+++ linux-2.6.git/tools/kvm/virtio-console.c
@@ -1,5 +1,6 @@
#include "kvm/virtio-console.h"
#include "kvm/virtio-pci.h"
+#include "kvm/virtio-pci-dev.h"
#include "kvm/disk-image.h"
#include "kvm/virtio.h"
#include "kvm/ioport.h"
@@ -23,14 +24,10 @@
#include <unistd.h>
#include <fcntl.h>
-#define VIRTIO_CONSOLE_IRQ 13
-#define VIRTIO_CONSOLE_PIN 2
-
#define VIRTIO_CONSOLE_QUEUE_SIZE 128
#define VIRTIO_CONSOLE_NUM_QUEUES 2
#define VIRTIO_CONSOLE_RX_QUEUE 0
#define VIRTIO_CONSOLE_TX_QUEUE 1
-#define PCI_VIRTIO_CONSOLE_DEVNUM 2
struct console_device {
pthread_mutex_t mutex;
@@ -227,11 +224,6 @@ static struct ioport_operations virtio_c
.io_out = virtio_console_pci_io_out,
};
-#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_DEVICE_ID_VIRTIO_CONSOLE 0x1003
-#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_SUBSYSTEM_ID_VIRTIO_CONSOLE 0x0003
-
static struct pci_device_header virtio_console_pci_device = {
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
.device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE,
Index: linux-2.6.git/tools/kvm/virtio-net.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio-net.c
+++ linux-2.6.git/tools/kvm/virtio-net.c
@@ -1,5 +1,6 @@
#include "kvm/virtio-net.h"
#include "kvm/virtio-pci.h"
+#include "kvm/virtio-pci-dev.h"
#include "kvm/virtio.h"
#include "kvm/ioport.h"
#include "kvm/types.h"
@@ -20,14 +21,10 @@
#include <unistd.h>
#include <sys/wait.h>
-#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
struct net_device {
pthread_mutex_t mutex;
@@ -263,11 +260,6 @@ static struct ioport_operations virtio_n
.io_out = virtio_net_pci_io_out,
};
-#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_DEVICE_ID_VIRTIO_NET 0x1000
-#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_SUBSYSTEM_ID_VIRTIO_NET 0x0001
-
static struct pci_device_header virtio_net_pci_device = {
.vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
.device_id = PCI_DEVICE_ID_VIRTIO_NET,
Index: linux-2.6.git/tools/kvm/virtio-rng.c
=====================================================================
--- linux-2.6.git.orig/tools/kvm/virtio-rng.c
+++ linux-2.6.git/tools/kvm/virtio-rng.c
@@ -1,6 +1,7 @@
#include "kvm/virtio-rng.h"
#include "kvm/virtio-pci.h"
+#include "kvm/virtio-pci-dev.h"
#include "kvm/disk-image.h"
#include "kvm/virtio.h"
@@ -20,15 +21,6 @@
#include <inttypes.h>
#include <pthread.h>
-#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_DEVICE_ID_VIRTIO_RNG 0x1004
-#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET 0x1af4
-#define PCI_SUBSYSTEM_ID_VIRTIO_RNG 0x0004
-#define PCI_VIRTIO_RNG_DEVNUM 4
-
-#define VIRTIO_RNG_IRQ 11
-#define VIRTIO_RNG_PIN 1
-
#define NUM_VIRT_QUEUES 1
#define VIRTIO_RNG_QUEUE_SIZE 128
next prev parent reply other threads:[~2011-05-05 19:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 19:06 [patch 0/2] kvm-tools -- cleanup Cyrill Gorcunov
2011-05-05 19:06 ` Cyrill Gorcunov [this message]
2011-05-05 19:11 ` [patch 1/2] kvm tools: Gather Virtio-PCI constants into one place Cyrill Gorcunov
2011-05-05 20:09 ` Cyrill Gorcunov
2011-05-05 19:06 ` [patch 2/2] kvm tools - Cleanup IRQs definitions for virtio pci devices Cyrill Gorcunov
2011-05-05 20:14 ` Pekka Enberg
2011-05-05 20:15 ` Cyrill Gorcunov
2011-05-05 20:16 ` Pekka Enberg
2011-05-05 20:19 ` Cyrill Gorcunov
2011-05-05 20:24 ` 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=20110505190733.367888565@gmail.com \
--to=gorcunov@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--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