1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
10 #include <linux/virtio_scsi.h>
11 #include <linux/virtio_ring.h>
13 #include <rte_vhost.h>
15 struct vhost_scsi_queue {
16 struct rte_vhost_vring vq;
17 uint16_t last_avail_idx;
18 uint16_t last_used_idx;
21 #define NUM_OF_SCSI_QUEUES 3
23 struct vhost_block_dev {
24 /** ID for vhost library. */
26 /** Queues for the block device */
27 struct vhost_scsi_queue queues[NUM_OF_SCSI_QUEUES];
28 /** Unique name for this block device. */
31 /** Unique product name for this kind of block device. */
32 char product_name[256];
34 /** Size in bytes of a logical block for the backend */
37 /** Number of blocks */
40 /** write cache enabled, not used at the moment */
43 /** use memory as disk storage space */
47 struct vhost_scsi_ctrlr {
48 /** Only support 1 LUN for the example */
49 struct vhost_block_dev *bdev;
50 /** VM memory region */
51 struct rte_vhost_memory *mem;
52 } __rte_cache_aligned;
54 #define VHOST_SCSI_MAX_IOVS 128
59 SCSI_DIR_FROM_DEV = 2,
62 struct vhost_scsi_task {
66 struct virtio_scsi_cmd_req *req;
67 struct virtio_scsi_cmd_resp *resp;
68 struct iovec iovs[VHOST_SCSI_MAX_IOVS];
70 struct vring_desc *desc;
71 struct rte_vhost_vring *vq;
72 struct vhost_block_dev *bdev;
73 struct vhost_scsi_ctrlr *ctrlr;
76 int vhost_bdev_process_scsi_commands(struct vhost_block_dev *bdev,
77 struct vhost_scsi_task *task);
79 #endif /* _VHOST_SCSI_H_ */