xref: /qemu/include/hw/virtio/vhost-user-blk.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
100343e4bSChangpeng Liu /*
200343e4bSChangpeng Liu  * vhost-user-blk host device
300343e4bSChangpeng Liu  * Copyright(C) 2017 Intel Corporation.
400343e4bSChangpeng Liu  *
500343e4bSChangpeng Liu  * Authors:
600343e4bSChangpeng Liu  *  Changpeng Liu <changpeng.liu@intel.com>
700343e4bSChangpeng Liu  *
800343e4bSChangpeng Liu  * Based on vhost-scsi.h, Copyright IBM, Corp. 2011
900343e4bSChangpeng Liu  *
1000343e4bSChangpeng Liu  * This work is licensed under the terms of the GNU LGPL, version 2 or later.
1100343e4bSChangpeng Liu  * See the COPYING.LIB file in the top-level directory.
1200343e4bSChangpeng Liu  *
1300343e4bSChangpeng Liu  */
1400343e4bSChangpeng Liu 
1500343e4bSChangpeng Liu #ifndef VHOST_USER_BLK_H
1600343e4bSChangpeng Liu #define VHOST_USER_BLK_H
1700343e4bSChangpeng Liu 
1800343e4bSChangpeng Liu #include "standard-headers/linux/virtio_blk.h"
1900343e4bSChangpeng Liu #include "hw/block/block.h"
2000343e4bSChangpeng Liu #include "chardev/char-fe.h"
2100343e4bSChangpeng Liu #include "hw/virtio/vhost.h"
224d0cf552STiwei Bie #include "hw/virtio/vhost-user.h"
23*db1015e9SEduardo Habkost #include "qom/object.h"
2400343e4bSChangpeng Liu 
2500343e4bSChangpeng Liu #define TYPE_VHOST_USER_BLK "vhost-user-blk"
26*db1015e9SEduardo Habkost typedef struct VHostUserBlk VHostUserBlk;
2700343e4bSChangpeng Liu #define VHOST_USER_BLK(obj) \
2800343e4bSChangpeng Liu         OBJECT_CHECK(VHostUserBlk, (obj), TYPE_VHOST_USER_BLK)
2900343e4bSChangpeng Liu 
30a4eef071SStefan Hajnoczi #define VHOST_USER_BLK_AUTO_NUM_QUEUES UINT16_MAX
31a4eef071SStefan Hajnoczi 
32*db1015e9SEduardo Habkost struct VHostUserBlk {
3300343e4bSChangpeng Liu     VirtIODevice parent_obj;
3400343e4bSChangpeng Liu     CharBackend chardev;
3500343e4bSChangpeng Liu     int32_t bootindex;
3600343e4bSChangpeng Liu     struct virtio_blk_config blkcfg;
3700343e4bSChangpeng Liu     uint16_t num_queues;
3800343e4bSChangpeng Liu     uint32_t queue_size;
3900343e4bSChangpeng Liu     uint32_t config_wce;
4000343e4bSChangpeng Liu     struct vhost_dev dev;
41a1fe0b8fSXie Yongji     struct vhost_inflight *inflight;
420b99f224SMarc-André Lureau     VhostUserState vhost_user;
4338e245a4SPan Nengyuan     struct vhost_virtqueue *vhost_vqs;
4438e245a4SPan Nengyuan     VirtQueue **virtqs;
4577542d43SXie Yongji     bool connected;
46*db1015e9SEduardo Habkost };
4700343e4bSChangpeng Liu 
4800343e4bSChangpeng Liu #endif
49