| 1 | /* |
| 2 | * Vhost-user generic virtio device |
| 3 | * |
| 4 | * Copyright (c) 2023 Linaro Ltd |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #ifndef QEMU_VHOST_USER_BASE_H |
| 10 | #define QEMU_VHOST_USER_BASE_H |
| 11 | |
| 12 | #include "hw/virtio/vhost.h" |
| 13 | #include "hw/virtio/vhost-user.h" |
| 14 | |
| 15 | #define TYPE_VHOST_USER_BASE "vhost-user-base" |
| 16 | |
| 17 | OBJECT_DECLARE_TYPE(VHostUserBase, VHostUserBaseClass, VHOST_USER_BASE) |
| 18 | |
| 19 | struct VHostUserBase { |
| 20 | VirtIODevice parent_obj; |
| 21 | |
| 22 | /* Properties */ |
| 23 | CharFrontend chardev; |
| 24 | uint16_t virtio_id; |
| 25 | uint32_t num_vqs; |
| 26 | uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */ |
| 27 | uint32_t config_size; |
| 28 | /* State tracking */ |
| 29 | VhostUserState vhost_user; |
| 30 | struct vhost_virtqueue *vhost_vq; |
| 31 | struct vhost_dev vhost_dev; |
| 32 | GPtrArray *vqs; |
| 33 | bool connected; |
| 34 | }; |
| 35 | |
| 36 | /* |
| 37 | * Needed so we can use the base realize after specialisation |
| 38 | * tweaks |
| 39 | */ |
| 40 | struct VHostUserBaseClass { |
| 41 | VirtioDeviceClass parent_class; |
| 42 | |
| 43 | DeviceRealize parent_realize; |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | #define TYPE_VHOST_USER_TEST_DEVICE "vhost-user-test-device" |
| 48 | |
| 49 | #endif /* QEMU_VHOST_USER_BASE_H */ |