blob: d119bcae45d48e6eb14afe7d26e61f18265fa206 [file] [log] [blame]
Marc-André Lureau267f6642019-05-24 15:09:46 +02001/*
2 * vhost-user GPU PCI device
3 *
4 * Copyright Red Hat, Inc. 2018
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 *
9 */
10
11#include "qemu/osdep.h"
12#include "qapi/error.h"
13#include "hw/virtio/virtio-gpu-pci.h"
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040014#include "qom/object.h"
Marc-André Lureau267f6642019-05-24 15:09:46 +020015
16#define TYPE_VHOST_USER_GPU_PCI "vhost-user-gpu-pci"
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040017typedef struct VhostUserGPUPCI VhostUserGPUPCI;
Eduardo Habkost8110fa12020-08-31 17:07:33 -040018DECLARE_INSTANCE_CHECKER(VhostUserGPUPCI, VHOST_USER_GPU_PCI,
19 TYPE_VHOST_USER_GPU_PCI)
Marc-André Lureau267f6642019-05-24 15:09:46 +020020
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040021struct VhostUserGPUPCI {
Marc-André Lureau267f6642019-05-24 15:09:46 +020022 VirtIOGPUPCIBase parent_obj;
23
24 VhostUserGPU vdev;
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040025};
Marc-André Lureau267f6642019-05-24 15:09:46 +020026
27static void vhost_user_gpu_pci_initfn(Object *obj)
28{
29 VhostUserGPUPCI *dev = VHOST_USER_GPU_PCI(obj);
30
31 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
32 TYPE_VHOST_USER_GPU);
33
34 VIRTIO_GPU_PCI_BASE(obj)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
35
36 object_property_add_alias(obj, "chardev",
Markus Armbrusterd2623122020-05-05 17:29:22 +020037 OBJECT(&dev->vdev), "chardev");
Marc-André Lureau267f6642019-05-24 15:09:46 +020038}
39
40static const VirtioPCIDeviceTypeInfo vhost_user_gpu_pci_info = {
41 .generic_name = TYPE_VHOST_USER_GPU_PCI,
42 .parent = TYPE_VIRTIO_GPU_PCI_BASE,
43 .instance_size = sizeof(VhostUserGPUPCI),
44 .instance_init = vhost_user_gpu_pci_initfn,
45};
Gerd Hoffmann561d0f42021-06-24 12:38:08 +020046module_obj(TYPE_VHOST_USER_GPU_PCI);
Jose R. Ziviani24ce7aa2022-05-28 00:20:23 +020047module_kconfig(VHOST_USER_GPU);
Marc-André Lureau267f6642019-05-24 15:09:46 +020048
49static void vhost_user_gpu_pci_register_types(void)
50{
51 virtio_pci_types_register(&vhost_user_gpu_pci_info);
52}
53
54type_init(vhost_user_gpu_pci_register_types)