xref: /qemu/include/hw/virtio/vhost-user-blk.h (revision a4eef0711b2cf7a7476c3e2c202a414b68a1baa0)
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"
2300343e4bSChangpeng Liu 
2400343e4bSChangpeng Liu #define TYPE_VHOST_USER_BLK "vhost-user-blk"
2500343e4bSChangpeng Liu #define VHOST_USER_BLK(obj) \
2600343e4bSChangpeng Liu         OBJECT_CHECK(VHostUserBlk, (obj), TYPE_VHOST_USER_BLK)
2700343e4bSChangpeng Liu 
28*a4eef071SStefan Hajnoczi #define VHOST_USER_BLK_AUTO_NUM_QUEUES UINT16_MAX
29*a4eef071SStefan Hajnoczi 
3000343e4bSChangpeng Liu typedef struct VHostUserBlk {
3100343e4bSChangpeng Liu     VirtIODevice parent_obj;
3200343e4bSChangpeng Liu     CharBackend chardev;
3300343e4bSChangpeng Liu     int32_t bootindex;
3400343e4bSChangpeng Liu     struct virtio_blk_config blkcfg;
3500343e4bSChangpeng Liu     uint16_t num_queues;
3600343e4bSChangpeng Liu     uint32_t queue_size;
3700343e4bSChangpeng Liu     uint32_t config_wce;
3800343e4bSChangpeng Liu     struct vhost_dev dev;
39a1fe0b8fSXie Yongji     struct vhost_inflight *inflight;
400b99f224SMarc-André Lureau     VhostUserState vhost_user;
4138e245a4SPan Nengyuan     struct vhost_virtqueue *vhost_vqs;
4238e245a4SPan Nengyuan     VirtQueue **virtqs;
4377542d43SXie Yongji     bool connected;
4400343e4bSChangpeng Liu } VHostUserBlk;
4500343e4bSChangpeng Liu 
4600343e4bSChangpeng Liu #endif
47