1*bd0bbb9aSHalil Pasic /*
2*bd0bbb9aSHalil Pasic * virtio ccw vhost-user-fs implementation
3*bd0bbb9aSHalil Pasic *
4*bd0bbb9aSHalil Pasic * Copyright 2020 IBM Corp.
5*bd0bbb9aSHalil Pasic *
6*bd0bbb9aSHalil Pasic * This work is licensed under the terms of the GNU GPL, version 2 or (at
7*bd0bbb9aSHalil Pasic * your option) any later version. See the COPYING file in the top-level
8*bd0bbb9aSHalil Pasic * directory.
9*bd0bbb9aSHalil Pasic */
10*bd0bbb9aSHalil Pasic #include "qemu/osdep.h"
11*bd0bbb9aSHalil Pasic #include "hw/qdev-properties.h"
12*bd0bbb9aSHalil Pasic #include "qapi/error.h"
13*bd0bbb9aSHalil Pasic #include "hw/virtio/vhost-user-fs.h"
14*bd0bbb9aSHalil Pasic #include "virtio-ccw.h"
15*bd0bbb9aSHalil Pasic
16*bd0bbb9aSHalil Pasic typedef struct VHostUserFSCcw {
17*bd0bbb9aSHalil Pasic VirtioCcwDevice parent_obj;
18*bd0bbb9aSHalil Pasic VHostUserFS vdev;
19*bd0bbb9aSHalil Pasic } VHostUserFSCcw;
20*bd0bbb9aSHalil Pasic
21*bd0bbb9aSHalil Pasic #define TYPE_VHOST_USER_FS_CCW "vhost-user-fs-ccw"
22*bd0bbb9aSHalil Pasic #define VHOST_USER_FS_CCW(obj) \
23*bd0bbb9aSHalil Pasic OBJECT_CHECK(VHostUserFSCcw, (obj), TYPE_VHOST_USER_FS_CCW)
24*bd0bbb9aSHalil Pasic
25*bd0bbb9aSHalil Pasic
26*bd0bbb9aSHalil Pasic static Property vhost_user_fs_ccw_properties[] = {
27*bd0bbb9aSHalil Pasic DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
28*bd0bbb9aSHalil Pasic VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
29*bd0bbb9aSHalil Pasic DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
30*bd0bbb9aSHalil Pasic VIRTIO_CCW_MAX_REV),
31*bd0bbb9aSHalil Pasic DEFINE_PROP_END_OF_LIST(),
32*bd0bbb9aSHalil Pasic };
33*bd0bbb9aSHalil Pasic
vhost_user_fs_ccw_realize(VirtioCcwDevice * ccw_dev,Error ** errp)34*bd0bbb9aSHalil Pasic static void vhost_user_fs_ccw_realize(VirtioCcwDevice *ccw_dev, Error **errp)
35*bd0bbb9aSHalil Pasic {
36*bd0bbb9aSHalil Pasic VHostUserFSCcw *dev = VHOST_USER_FS_CCW(ccw_dev);
37*bd0bbb9aSHalil Pasic DeviceState *vdev = DEVICE(&dev->vdev);
38*bd0bbb9aSHalil Pasic
39*bd0bbb9aSHalil Pasic qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
40*bd0bbb9aSHalil Pasic }
41*bd0bbb9aSHalil Pasic
vhost_user_fs_ccw_instance_init(Object * obj)42*bd0bbb9aSHalil Pasic static void vhost_user_fs_ccw_instance_init(Object *obj)
43*bd0bbb9aSHalil Pasic {
44*bd0bbb9aSHalil Pasic VHostUserFSCcw *dev = VHOST_USER_FS_CCW(obj);
45*bd0bbb9aSHalil Pasic VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
46*bd0bbb9aSHalil Pasic
47*bd0bbb9aSHalil Pasic ccw_dev->force_revision_1 = true;
48*bd0bbb9aSHalil Pasic virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
49*bd0bbb9aSHalil Pasic TYPE_VHOST_USER_FS);
50*bd0bbb9aSHalil Pasic }
51*bd0bbb9aSHalil Pasic
vhost_user_fs_ccw_class_init(ObjectClass * klass,void * data)52*bd0bbb9aSHalil Pasic static void vhost_user_fs_ccw_class_init(ObjectClass *klass, void *data)
53*bd0bbb9aSHalil Pasic {
54*bd0bbb9aSHalil Pasic DeviceClass *dc = DEVICE_CLASS(klass);
55*bd0bbb9aSHalil Pasic VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
56*bd0bbb9aSHalil Pasic
57*bd0bbb9aSHalil Pasic k->realize = vhost_user_fs_ccw_realize;
58*bd0bbb9aSHalil Pasic device_class_set_props(dc, vhost_user_fs_ccw_properties);
59*bd0bbb9aSHalil Pasic set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
60*bd0bbb9aSHalil Pasic }
61*bd0bbb9aSHalil Pasic
62*bd0bbb9aSHalil Pasic static const TypeInfo vhost_user_fs_ccw = {
63*bd0bbb9aSHalil Pasic .name = TYPE_VHOST_USER_FS_CCW,
64*bd0bbb9aSHalil Pasic .parent = TYPE_VIRTIO_CCW_DEVICE,
65*bd0bbb9aSHalil Pasic .instance_size = sizeof(VHostUserFSCcw),
66*bd0bbb9aSHalil Pasic .instance_init = vhost_user_fs_ccw_instance_init,
67*bd0bbb9aSHalil Pasic .class_init = vhost_user_fs_ccw_class_init,
68*bd0bbb9aSHalil Pasic };
69*bd0bbb9aSHalil Pasic
vhost_user_fs_ccw_register(void)70*bd0bbb9aSHalil Pasic static void vhost_user_fs_ccw_register(void)
71*bd0bbb9aSHalil Pasic {
72*bd0bbb9aSHalil Pasic type_register_static(&vhost_user_fs_ccw);
73*bd0bbb9aSHalil Pasic }
74*bd0bbb9aSHalil Pasic
75*bd0bbb9aSHalil Pasic type_init(vhost_user_fs_ccw_register)
76