summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h')
-rw-r--r--src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h b/src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h
new file mode 100644
index 00000000..7f98d8d1
--- /dev/null
+++ b/src/spdk/dpdk/examples/vhost_scsi/vhost_scsi.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _VHOST_SCSI_H_
+#define _VHOST_SCSI_H_
+
+#include <sys/uio.h>
+#include <stdint.h>
+#include <linux/virtio_scsi.h>
+#include <linux/virtio_ring.h>
+
+#include <rte_vhost.h>
+
+struct vhost_scsi_queue {
+ struct rte_vhost_vring vq;
+ uint16_t last_avail_idx;
+ uint16_t last_used_idx;
+};
+
+#define NUM_OF_SCSI_QUEUES 3
+
+struct vhost_block_dev {
+ /** ID for vhost library. */
+ int vid;
+ /** Queues for the block device */
+ struct vhost_scsi_queue queues[NUM_OF_SCSI_QUEUES];
+ /** Unique name for this block device. */
+ char name[64];
+
+ /** Unique product name for this kind of block device. */
+ char product_name[256];
+
+ /** Size in bytes of a logical block for the backend */
+ uint32_t blocklen;
+
+ /** Number of blocks */
+ uint64_t blockcnt;
+
+ /** write cache enabled, not used at the moment */
+ int write_cache;
+
+ /** use memory as disk storage space */
+ uint8_t *data;
+};
+
+struct vhost_scsi_ctrlr {
+ /** Only support 1 LUN for the example */
+ struct vhost_block_dev *bdev;
+ /** VM memory region */
+ struct rte_vhost_memory *mem;
+} __rte_cache_aligned;
+
+#define VHOST_SCSI_MAX_IOVS 128
+
+enum scsi_data_dir {
+ SCSI_DIR_NONE = 0,
+ SCSI_DIR_TO_DEV = 1,
+ SCSI_DIR_FROM_DEV = 2,
+};
+
+struct vhost_scsi_task {
+ int req_idx;
+ uint32_t dxfer_dir;
+ uint32_t data_len;
+ struct virtio_scsi_cmd_req *req;
+ struct virtio_scsi_cmd_resp *resp;
+ struct iovec iovs[VHOST_SCSI_MAX_IOVS];
+ uint32_t iovs_cnt;
+ struct vring_desc *desc;
+ struct rte_vhost_vring *vq;
+ struct vhost_block_dev *bdev;
+ struct vhost_scsi_ctrlr *ctrlr;
+};
+
+int vhost_bdev_process_scsi_commands(struct vhost_block_dev *bdev,
+ struct vhost_scsi_task *task);
+
+#endif /* _VHOST_SCSI_H_ */