[PATCH 3/5] pci-assign: Privatize type definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No need to carry the type definitions in device-assignment.h. Move them
over to allow dropping the header once we use an INTx routing notifier
instead of exporting assigned_dev_update_irqs.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 hw/device-assignment.c |   90 +++++++++++++++++++++++++++++++++++++++++++++
 hw/device-assignment.h |   96 ------------------------------------------------
 2 files changed, 90 insertions(+), 96 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index b9b955b..da50069 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/io.h>
+#include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "qemu-kvm.h"
@@ -40,6 +41,7 @@
 #include "monitor.h"
 #include "range.h"
 #include "sysemu.h"
+#include "pci.h"
 
 #define MSIX_PAGE_SIZE 0x1000
 
@@ -61,6 +63,94 @@
 #define DEBUG(fmt, ...) do { } while(0)
 #endif
 
+typedef struct PCIHostDevice {
+    int seg;
+    int bus;
+    int dev;
+    int func;
+} PCIHostDevice;
+
+typedef struct {
+    int type;           /* Memory or port I/O */
+    int valid;
+    uint32_t base_addr;
+    uint32_t size;    /* size of the region */
+    int resource_fd;
+} PCIRegion;
+
+typedef struct {
+    uint8_t bus, dev, func; /* Bus inside domain, device and function */
+    int irq;                /* IRQ number */
+    uint16_t region_number; /* number of active regions */
+
+    /* Port I/O or MMIO Regions */
+    PCIRegion regions[PCI_NUM_REGIONS - 1];
+    int config_fd;
+} PCIDevRegions;
+
+typedef struct {
+    MemoryRegion container;
+    MemoryRegion real_iomem;
+    union {
+        void *r_virtbase;    /* mmapped access address for memory regions */
+        uint32_t r_baseport; /* the base guest port for I/O regions */
+    } u;
+    int num;            /* our index within v_addrs[] */
+    pcibus_t e_size;    /* emulated size of region in bytes */
+    pcibus_t r_size;    /* real size of region in bytes */
+    PCIRegion *region;
+} AssignedDevRegion;
+
+#define ASSIGNED_DEVICE_PREFER_MSI_BIT  0
+#define ASSIGNED_DEVICE_SHARE_INTX_BIT  1
+
+#define ASSIGNED_DEVICE_PREFER_MSI_MASK (1 << ASSIGNED_DEVICE_PREFER_MSI_BIT)
+#define ASSIGNED_DEVICE_SHARE_INTX_MASK (1 << ASSIGNED_DEVICE_SHARE_INTX_BIT)
+
+typedef struct {
+    uint32_t addr_lo;
+    uint32_t addr_hi;
+    uint32_t data;
+    uint32_t ctrl;
+} MSIXTableEntry;
+
+typedef struct AssignedDevice {
+    PCIDevice dev;
+    PCIHostDevice host;
+    uint32_t features;
+    int intpin;
+    uint8_t debug_flags;
+    AssignedDevRegion v_addrs[PCI_NUM_REGIONS - 1];
+    PCIDevRegions real_device;
+    int run;
+    int girq;
+    uint16_t h_segnr;
+    uint8_t h_busnr;
+    uint8_t h_devfn;
+    int irq_requested_type;
+    int bound;
+    struct {
+#define ASSIGNED_DEVICE_CAP_MSI (1 << 0)
+#define ASSIGNED_DEVICE_CAP_MSIX (1 << 1)
+        uint32_t available;
+#define ASSIGNED_DEVICE_MSI_ENABLED (1 << 0)
+#define ASSIGNED_DEVICE_MSIX_ENABLED (1 << 1)
+#define ASSIGNED_DEVICE_MSIX_MASKED (1 << 2)
+        uint32_t state;
+    } cap;
+    uint8_t emulate_config_read[PCI_CONFIG_SPACE_SIZE];
+    uint8_t emulate_config_write[PCI_CONFIG_SPACE_SIZE];
+    int irq_entries_nr;
+    struct kvm_irq_routing_entry *entry;
+    MSIXTableEntry *msix_table;
+    target_phys_addr_t msix_table_addr;
+    uint16_t msix_max;
+    MemoryRegion mmio;
+    char *configfd_name;
+    int32_t bootindex;
+    QLIST_ENTRY(AssignedDevice) next;
+} AssignedDevice;
+
 static void assigned_dev_load_option_rom(AssignedDevice *dev);
 
 static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev);
diff --git a/hw/device-assignment.h b/hw/device-assignment.h
index 1ef2dbe..3fcb804 100644
--- a/hw/device-assignment.h
+++ b/hw/device-assignment.h
@@ -28,102 +28,6 @@
 #ifndef __DEVICE_ASSIGNMENT_H__
 #define __DEVICE_ASSIGNMENT_H__
 
-#include <sys/mman.h>
-#include "qemu-common.h"
-#include "qemu-queue.h"
-#include "pci.h"
-
-/* From include/linux/pci.h in the kernel sources */
-#define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))
-
-typedef struct PCIHostDevice {
-    int seg;
-    int bus;
-    int dev;
-    int func;
-} PCIHostDevice;
-
-typedef struct {
-    int type;           /* Memory or port I/O */
-    int valid;
-    uint32_t base_addr;
-    uint32_t size;    /* size of the region */
-    int resource_fd;
-} PCIRegion;
-
-typedef struct {
-    uint8_t bus, dev, func; /* Bus inside domain, device and function */
-    int irq;                /* IRQ number */
-    uint16_t region_number; /* number of active regions */
-
-    /* Port I/O or MMIO Regions */
-    PCIRegion regions[PCI_NUM_REGIONS - 1];
-    int config_fd;
-} PCIDevRegions;
-
-typedef struct {
-    MemoryRegion container;
-    MemoryRegion real_iomem;
-    union {
-        void *r_virtbase;    /* mmapped access address for memory regions */
-        uint32_t r_baseport; /* the base guest port for I/O regions */
-    } u;
-    int num;            /* our index within v_addrs[] */
-    pcibus_t e_size;    /* emulated size of region in bytes */
-    pcibus_t r_size;    /* real size of region in bytes */
-    PCIRegion *region;
-} AssignedDevRegion;
-
-#define ASSIGNED_DEVICE_PREFER_MSI_BIT  0
-#define ASSIGNED_DEVICE_SHARE_INTX_BIT  1
-
-#define ASSIGNED_DEVICE_PREFER_MSI_MASK (1 << ASSIGNED_DEVICE_PREFER_MSI_BIT)
-#define ASSIGNED_DEVICE_SHARE_INTX_MASK (1 << ASSIGNED_DEVICE_SHARE_INTX_BIT)
-
-typedef struct {
-    uint32_t addr_lo;
-    uint32_t addr_hi;
-    uint32_t data;
-    uint32_t ctrl;
-} MSIXTableEntry;
-
-typedef struct AssignedDevice {
-    PCIDevice dev;
-    PCIHostDevice host;
-    uint32_t features;
-    int intpin;
-    uint8_t debug_flags;
-    AssignedDevRegion v_addrs[PCI_NUM_REGIONS - 1];
-    PCIDevRegions real_device;
-    int run;
-    int girq;
-    uint16_t h_segnr;
-    uint8_t h_busnr;
-    uint8_t h_devfn;
-    int irq_requested_type;
-    int bound;
-    struct {
-#define ASSIGNED_DEVICE_CAP_MSI (1 << 0)
-#define ASSIGNED_DEVICE_CAP_MSIX (1 << 1)
-        uint32_t available;
-#define ASSIGNED_DEVICE_MSI_ENABLED (1 << 0)
-#define ASSIGNED_DEVICE_MSIX_ENABLED (1 << 1)
-#define ASSIGNED_DEVICE_MSIX_MASKED (1 << 2)
-        uint32_t state;
-    } cap;
-    uint8_t emulate_config_read[PCI_CONFIG_SPACE_SIZE];
-    uint8_t emulate_config_write[PCI_CONFIG_SPACE_SIZE];
-    int irq_entries_nr;
-    struct kvm_irq_routing_entry *entry;
-    MSIXTableEntry *msix_table;
-    target_phys_addr_t msix_table_addr;
-    uint16_t msix_max;
-    MemoryRegion mmio;
-    char *configfd_name;
-    int32_t bootindex;
-    QLIST_ENTRY(AssignedDevice) next;
-} AssignedDevice;
-
 void assigned_dev_update_irqs(void);
 
 #endif              /* __DEVICE_ASSIGNMENT_H__ */
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux