From b00fad2ab7736fec186814a27756794ef3f4ca35 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 8 Aug 2011 18:36:28 -0300 Subject: [RHEL6 qemu-kvm PATCH 05/10] pci: introduce multifunction property. RH-Author: Gerd Hoffmann Message-id: <1312828592-1443-4-git-send-email-kraxel@redhat.com> Patchwork-id: 31119 O-Subject: [RHEL-6.2 kvm PATCH 3/7] pci: introduce multifunction property. Bugzilla: 729104 RH-Acked-by: Alex Williamson RH-Acked-by: Amos Kong RH-Acked-by: Michael S. Tsirkin From: Isaku Yamahata introduce multifunction property. Also introduce new convenient device creation function which will be used later. For bisectability this patch doesn't do anything, but sets the property resulting in no functional changes. Actual changes will be introduced by later patch. Signed-off-by: Isaku Yamahata Signed-off-by: Blue Swirl (cherry picked from commit 498238687fd3a2bf3efb32694732f88ceac72e99) --- hw/pci.c | 22 +++++++++++++++++++--- hw/pci.h | 9 +++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) Signed-off-by: Eduardo Habkost --- hw/pci.c | 22 +++++++++++++++++++--- hw/pci.h | 9 +++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 41e2139..993d42b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -72,6 +72,8 @@ static struct BusInfo pci_bus_info = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, + QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_END_OF_LIST() } }; @@ -1517,22 +1519,36 @@ void pci_qdev_register_many(PCIDeviceInfo *info) } } -PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name) +PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction, + const char *name) { DeviceState *dev; dev = qdev_create(&bus->qbus, name); qdev_prop_set_uint32(dev, "addr", devfn); + qdev_prop_set_bit(dev, "multifunction", multifunction); return DO_UPCAST(PCIDevice, qdev, dev); } -PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name) +PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, + bool multifunction, + const char *name) { - PCIDevice *dev = pci_create(bus, devfn, name); + PCIDevice *dev = pci_create_multifunction(bus, devfn, multifunction, name); qdev_init_nofail(&dev->qdev); return dev; } +PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name) +{ + return pci_create_multifunction(bus, devfn, false, name); +} + +PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name) +{ + return pci_create_simple_multifunction(bus, devfn, false, name); +} + static int pci_find_space(PCIDevice *pdev, uint8_t size) { int config_size = pci_config_size(pdev); diff --git a/hw/pci.h b/hw/pci.h index afebb64..d55bde5 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -129,6 +129,10 @@ typedef struct PCIIORegion { enum { QEMU_PCI_CAP_MSIX = 0x1, QEMU_PCI_CAP_EXPRESS = 0x2, + + /* multifunction capable device */ +#define QEMU_PCI_CAP_MULTIFUNCTION_BITNR 2 + QEMU_PCI_CAP_MULTIFUNCTION = (1 << QEMU_PCI_CAP_MULTIFUNCTION_BITNR), }; typedef int (*msix_mask_notifier_func)(PCIDevice *, unsigned vector, @@ -354,6 +358,11 @@ typedef struct { void pci_qdev_register(PCIDeviceInfo *info); void pci_qdev_register_many(PCIDeviceInfo *info); +PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction, + const char *name); +PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, + bool multifunction, + const char *name); PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name); PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); -- 1.7.3.2