target/sh4: Remove MMU_MODE{0,1}_SUFFIX
[qemu/ar7.git] / hw / virtio / vhost-scsi-pci.c
blobe8dfbfc60f9a5f25b4d7214872d1e02baa7d71e1
1 /*
2 * Vhost scsi PCI bindings
4 * Copyright IBM, Corp. 2011
6 * Authors:
7 * Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
9 * Changes for QEMU mainline + tcm_vhost kernel upstream:
10 * Nicholas Bellinger <nab@risingtidesystems.com>
12 * This work is licensed under the terms of the GNU LGPL, version 2 or later.
13 * See the COPYING.LIB file in the top-level directory.
17 #include "qemu/osdep.h"
19 #include "standard-headers/linux/virtio_pci.h"
20 #include "hw/qdev-properties.h"
21 #include "hw/virtio/vhost-scsi.h"
22 #include "qapi/error.h"
23 #include "qemu/module.h"
24 #include "virtio-pci.h"
26 typedef struct VHostSCSIPCI VHostSCSIPCI;
29 * vhost-scsi-pci: This extends VirtioPCIProxy.
31 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci-base"
32 #define VHOST_SCSI_PCI(obj) \
33 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
35 struct VHostSCSIPCI {
36 VirtIOPCIProxy parent_obj;
37 VHostSCSI vdev;
40 static Property vhost_scsi_pci_properties[] = {
41 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
42 DEV_NVECTORS_UNSPECIFIED),
43 DEFINE_PROP_END_OF_LIST(),
46 static void vhost_scsi_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
48 VHostSCSIPCI *dev = VHOST_SCSI_PCI(vpci_dev);
49 DeviceState *vdev = DEVICE(&dev->vdev);
50 VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
52 if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
53 vpci_dev->nvectors = vs->conf.num_queues + 3;
56 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
57 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
60 static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data)
62 DeviceClass *dc = DEVICE_CLASS(klass);
63 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
64 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
65 k->realize = vhost_scsi_pci_realize;
66 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
67 dc->props = vhost_scsi_pci_properties;
68 pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
69 pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_SCSI;
70 pcidev_k->revision = 0x00;
71 pcidev_k->class_id = PCI_CLASS_STORAGE_SCSI;
74 static void vhost_scsi_pci_instance_init(Object *obj)
76 VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
78 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
79 TYPE_VHOST_SCSI);
80 object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
81 "bootindex", &error_abort);
84 static const VirtioPCIDeviceTypeInfo vhost_scsi_pci_info = {
85 .base_name = TYPE_VHOST_SCSI_PCI,
86 .generic_name = "vhost-scsi-pci",
87 .transitional_name = "vhost-scsi-pci-transitional",
88 .non_transitional_name = "vhost-scsi-pci-non-transitional",
89 .instance_size = sizeof(VHostSCSIPCI),
90 .instance_init = vhost_scsi_pci_instance_init,
91 .class_init = vhost_scsi_pci_class_init,
94 static void vhost_scsi_pci_register(void)
96 virtio_pci_types_register(&vhost_scsi_pci_info);
99 type_init(vhost_scsi_pci_register)