]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / examples / vhost_scsi / vhost_scsi.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
3 */
4
5 #ifndef _VHOST_SCSI_H_
6 #define _VHOST_SCSI_H_
7
8 #include <sys/uio.h>
9 #include <stdint.h>
10 #include <linux/virtio_scsi.h>
11 #include <linux/virtio_ring.h>
12
13 #include <rte_vhost.h>
14
15 struct vhost_scsi_queue {
16 struct rte_vhost_vring vq;
17 uint16_t last_avail_idx;
18 uint16_t last_used_idx;
19 };
20
21 #define NUM_OF_SCSI_QUEUES 3
22
23 struct vhost_block_dev {
24 /** ID for vhost library. */
25 int vid;
26 /** Queues for the block device */
27 struct vhost_scsi_queue queues[NUM_OF_SCSI_QUEUES];
28 /** Unique name for this block device. */
29 char name[64];
30
31 /** Unique product name for this kind of block device. */
32 char product_name[256];
33
34 /** Size in bytes of a logical block for the backend */
35 uint32_t blocklen;
36
37 /** Number of blocks */
38 uint64_t blockcnt;
39
40 /** write cache enabled, not used at the moment */
41 int write_cache;
42
43 /** use memory as disk storage space */
44 uint8_t *data;
45 };
46
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;
53
54 #define VHOST_SCSI_MAX_IOVS 128
55
56 enum scsi_data_dir {
57 SCSI_DIR_NONE = 0,
58 SCSI_DIR_TO_DEV = 1,
59 SCSI_DIR_FROM_DEV = 2,
60 };
61
62 struct vhost_scsi_task {
63 int req_idx;
64 uint32_t dxfer_dir;
65 uint32_t data_len;
66 struct virtio_scsi_cmd_req *req;
67 struct virtio_scsi_cmd_resp *resp;
68 struct iovec iovs[VHOST_SCSI_MAX_IOVS];
69 uint32_t iovs_cnt;
70 struct vring_desc *desc;
71 struct rte_vhost_vring *vq;
72 struct vhost_block_dev *bdev;
73 struct vhost_scsi_ctrlr *ctrlr;
74 };
75
76 int vhost_bdev_process_scsi_commands(struct vhost_block_dev *bdev,
77 struct vhost_scsi_task *task);
78
79 #endif /* _VHOST_SCSI_H_ */