]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Use definitions from kernel headers
authorSasha Levin <levinsasha928@gmail.com>
Wed, 11 May 2011 15:17:25 +0000 (18:17 +0300)
committerPekka Enberg <penberg@kernel.org>
Wed, 11 May 2011 15:51:16 +0000 (18:51 +0300)
Instead of redefining virtio pci constants (or not using them at all), use
constants from kernel header.

Acked-and-tested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/virtio-pci-dev.h
tools/kvm/include/kvm/virtio-pci.h [deleted file]
tools/kvm/include/kvm/virtio.h
tools/kvm/virtio/blk.c
tools/kvm/virtio/console.c
tools/kvm/virtio/net.c
tools/kvm/virtio/rng.c

index d2274d024801e40904dd07657464b61763644d68..706ad207962df502b2789cf6b83f443c61e6f808 100644 (file)
@@ -16,4 +16,7 @@
 #define PCI_SUBSYSTEM_ID_VIRTIO_CONSOLE                0x0003
 #define PCI_SUBSYSTEM_ID_VIRTIO_RNG            0x0004
 
+#define PCI_VENDOR_ID_REDHAT_QUMRANET          0x1af4
+#define PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET        0x1af4
+
 #endif /* VIRTIO_PCI_DEV_H_ */
diff --git a/tools/kvm/include/kvm/virtio-pci.h b/tools/kvm/include/kvm/virtio-pci.h
deleted file mode 100644 (file)
index b507d1d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Virtio PCI driver
- *
- * This module allows virtio devices to be used over a virtual PCI device.
- * This can be used with QEMU based VMMs like KVM or Xen.
- *
- * Copyright IBM Corp. 2007
- *
- * Authors:
- *  Anthony Liguori  <aliguori@us.ibm.com>
- *
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- */
-
-#ifndef _LINUX_VIRTIO_PCI_H
-#define _LINUX_VIRTIO_PCI_H
-
-/* A 32-bit r/o bitmask of the features supported by the host */
-#define VIRTIO_PCI_HOST_FEATURES       0
-
-/* A 32-bit r/w bitmask of features activated by the guest */
-#define VIRTIO_PCI_GUEST_FEATURES      4
-
-/* A 32-bit r/w PFN for the currently selected queue */
-#define VIRTIO_PCI_QUEUE_PFN           8
-
-/* A 16-bit r/o queue size for the currently selected queue */
-#define VIRTIO_PCI_QUEUE_NUM           12
-
-/* A 16-bit r/w queue selector */
-#define VIRTIO_PCI_QUEUE_SEL           14
-
-/* A 16-bit r/w queue notifier */
-#define VIRTIO_PCI_QUEUE_NOTIFY                16
-
-/* 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.
- */
-#define VIRTIO_PCI_ISR                 19
-
-/*
- * 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 */
-#define VIRTIO_MSI_QUEUE_VECTOR         22
-
-/* Vector value used to disable MSI for queue */
-#define VIRTIO_MSI_NO_VECTOR            0xffff
-
-/*
- * 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 bea63df9035376a08254fc4357b42e8acc46f291..66e6fdb1acb5d7d12a273ea1491464969e6b907b 100644 (file)
@@ -2,6 +2,7 @@
 #define KVM__VIRTIO_H
 
 #include <linux/virtio_ring.h>
+#include <linux/virtio_pci.h>
 
 #include <linux/types.h>
 #include <sys/uio.h>
@@ -43,7 +44,7 @@ static inline bool virt_queue__available(struct virt_queue *vq)
  */
 static inline void *guest_pfn_to_host(struct kvm *kvm, u32 pfn)
 {
-       return guest_flat_to_host(kvm, (unsigned long)pfn << 12);
+       return guest_flat_to_host(kvm, (unsigned long)pfn << VIRTIO_PCI_QUEUE_ADDR_SHIFT);
 }
 
 struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len);
index 9f1aa1dfce22a3dd4ffee620c5b6f109064311c6..8d480bfb214584cea48a990da23bf7ad3173a853 100644 (file)
@@ -1,6 +1,5 @@
 #include "kvm/virtio-blk.h"
 
-#include "kvm/virtio-pci.h"
 #include "kvm/virtio-pci-dev.h"
 #include "kvm/irq.h"
 #include "kvm/disk-image.h"
@@ -58,7 +57,7 @@ static bool virtio_blk_dev_in(struct blk_dev *bdev, void *data, unsigned long of
        if (size != 1 || count != 1)
                return false;
 
-       ioport__write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]);
+       ioport__write8(data, config_space[offset - VIRTIO_MSI_CONFIG_VECTOR]);
 
        return true;
 }
@@ -199,7 +198,7 @@ static bool virtio_blk_pci_io_out(struct kvm *self, u16 port, void *data, int si
                queue->pfn              = ioport__read32(data);
                p                       = guest_pfn_to_host(self, queue->pfn);
 
-               vring_init(&queue->vring, VIRTIO_BLK_QUEUE_SIZE, p, 4096);
+               vring_init(&queue->vring, VIRTIO_BLK_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
 
                *job                    = (struct blk_dev_job) {
                        .vq                     = queue,
index 87b816af0960c66f75b842dca5c67590bf8e732f..38f52f96e61c6f992ec31faf2c42d5ec93d7dcee 100644 (file)
@@ -1,5 +1,4 @@
 #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"
@@ -104,10 +103,10 @@ static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long o
        if (size != 1 || count != 1)
                return false;
 
-       if ((offset - VIRTIO_PCI_CONFIG_NOMSI) > sizeof(struct virtio_console_config))
-               error("config offset is too big: %li", offset - VIRTIO_PCI_CONFIG_NOMSI);
+       if ((offset - VIRTIO_MSI_CONFIG_VECTOR) > sizeof(struct virtio_console_config))
+               error("config offset is too big: %li", offset - VIRTIO_MSI_CONFIG_VECTOR);
 
-       ioport__write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]);
+       ioport__write8(data, config_space[offset - VIRTIO_MSI_CONFIG_VECTOR]);
 
        return true;
 }
@@ -201,7 +200,7 @@ static bool virtio_console_pci_io_out(struct kvm *self, u16 port, void *data, in
                queue->pfn              = ioport__read32(data);
                p                       = guest_pfn_to_host(self, queue->pfn);
 
-               vring_init(&queue->vring, VIRTIO_CONSOLE_QUEUE_SIZE, p, 4096);
+               vring_init(&queue->vring, VIRTIO_CONSOLE_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
 
                if (cdev.queue_selector == VIRTIO_CONSOLE_TX_QUEUE)
                        cdev.jobs[cdev.queue_selector] = thread_pool__add_job(self, virtio_console_handle_callback, queue);
index 3f3ee22734f88b0644203febb4abe1b95003580d..2009d4ac3ea8902e5d2a3f5ca59754fef978e8e1 100644 (file)
@@ -1,5 +1,4 @@
 #include "kvm/virtio-net.h"
-#include "kvm/virtio-pci.h"
 #include "kvm/virtio-pci-dev.h"
 #include "kvm/virtio.h"
 #include "kvm/ioport.h"
@@ -154,10 +153,10 @@ static bool virtio_net_pci_io_device_specific_in(void *data, unsigned long offse
        if (size != 1 || count != 1)
                return false;
 
-       if ((offset - VIRTIO_PCI_CONFIG_NOMSI) > sizeof(struct virtio_net_config))
-               error("config offset is too big: %li", offset - VIRTIO_PCI_CONFIG_NOMSI);
+       if ((offset - VIRTIO_MSI_CONFIG_VECTOR) > sizeof(struct virtio_net_config))
+               error("config offset is too big: %li", offset - VIRTIO_MSI_CONFIG_VECTOR);
 
-       ioport__write8(data, config_space[offset - VIRTIO_PCI_CONFIG_NOMSI]);
+       ioport__write8(data, config_space[offset - VIRTIO_MSI_CONFIG_VECTOR]);
 
        return true;
 }
@@ -247,7 +246,7 @@ static bool virtio_net_pci_io_out(struct kvm *self, u16 port, void *data, int si
                queue->pfn                      = ioport__read32(data);
                p                               = guest_pfn_to_host(self, queue->pfn);
 
-               vring_init(&queue->vring, VIRTIO_NET_QUEUE_SIZE, p, 4096);
+               vring_init(&queue->vring, VIRTIO_NET_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
 
                break;
        }
index 1951d0d1c3702bb0532a626e6699744a7f92b75e..cf258fa4dae1d8c914a55222037ed33659062d5a 100644 (file)
@@ -1,6 +1,5 @@
 #include "kvm/virtio-rng.h"
 
-#include "kvm/virtio-pci.h"
 #include "kvm/virtio-pci-dev.h"
 
 #include "kvm/disk-image.h"
@@ -131,7 +130,7 @@ static bool virtio_rng_pci_io_out(struct kvm *kvm, u16 port, void *data, int siz
                queue->pfn              = ioport__read32(data);
                p                       = guest_pfn_to_host(kvm, queue->pfn);
 
-               vring_init(&queue->vring, VIRTIO_RNG_QUEUE_SIZE, p, 4096);
+               vring_init(&queue->vring, VIRTIO_RNG_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
 
                rdev.jobs[rdev.queue_selector] = thread_pool__add_job(kvm, virtio_rng_do_io, queue);