blob: 1d2ae7a60e1170d8ce7597b4a5fa6cc796f686eb [file] [log] [blame]
Nicholas Bellinger057cbf42012-07-18 14:31:32 -07001#define TCM_VHOST_VERSION "v0.1"
2#define TCM_VHOST_NAMELEN 256
3#define TCM_VHOST_MAX_CDB_SIZE 32
4
5struct tcm_vhost_cmd {
6 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */
7 int tvc_vq_desc;
Nicholas Bellinger9f0abc12012-10-01 18:40:55 -07008 /* virtio-scsi initiator task attribute */
9 int tvc_task_attr;
10 /* virtio-scsi initiator data direction */
11 enum dma_data_direction tvc_data_direction;
12 /* Expected data transfer length from virtio-scsi header */
13 u32 tvc_exp_data_len;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070014 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */
15 u64 tvc_tag;
16 /* The number of scatterlists associated with this cmd */
17 u32 tvc_sgl_count;
18 /* Saved unpacked SCSI LUN for tcm_vhost_submission_work() */
19 u32 tvc_lun;
20 /* Pointer to the SGL formatted memory from virtio-scsi */
21 struct scatterlist *tvc_sgl;
22 /* Pointer to response */
23 struct virtio_scsi_cmd_resp __user *tvc_resp;
24 /* Pointer to vhost_scsi for our device */
25 struct vhost_scsi *tvc_vhost;
Asias He1b7f3902013-02-06 13:20:59 +080026 /* Pointer to vhost_virtqueue for the cmd */
27 struct vhost_virtqueue *tvc_vq;
Nicholas Bellinger9f0abc12012-10-01 18:40:55 -070028 /* Pointer to vhost nexus memory */
29 struct tcm_vhost_nexus *tvc_nexus;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070030 /* The TCM I/O descriptor that is accessed via container_of() */
31 struct se_cmd tvc_se_cmd;
32 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */
33 struct work_struct work;
34 /* Copy of the incoming SCSI command descriptor block (CDB) */
35 unsigned char tvc_cdb[TCM_VHOST_MAX_CDB_SIZE];
36 /* Sense buffer that will be mapped into outgoing status */
37 unsigned char tvc_sense_buf[TRANSPORT_SENSE_BUFFER];
38 /* Completed commands list, serviced from vhost worker thread */
Asias He9d6064a2013-01-06 14:36:13 +080039 struct llist_node tvc_completion_list;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070040};
41
42struct tcm_vhost_nexus {
43 /* Pointer to TCM session for I_T Nexus */
44 struct se_session *tvn_se_sess;
45};
46
47struct tcm_vhost_nacl {
48 /* Binary World Wide unique Port Name for Vhost Initiator port */
49 u64 iport_wwpn;
50 /* ASCII formatted WWPN for Sas Initiator port */
51 char iport_name[TCM_VHOST_NAMELEN];
52 /* Returned by tcm_vhost_make_nodeacl() */
53 struct se_node_acl se_node_acl;
54};
55
56struct tcm_vhost_tpg {
57 /* Vhost port target portal group tag for TCM */
58 u16 tport_tpgt;
59 /* Used to track number of TPG Port/Lun Links wrt to explict I_T Nexus shutdown */
Nicholas Bellinger101998f2012-07-30 13:30:00 -070060 int tv_tpg_port_count;
61 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
62 int tv_tpg_vhost_count;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070063 /* list for tcm_vhost_list */
64 struct list_head tv_tpg_list;
65 /* Used to protect access for tpg_nexus */
66 struct mutex tv_tpg_mutex;
67 /* Pointer to the TCM VHost I_T Nexus for this TPG endpoint */
68 struct tcm_vhost_nexus *tpg_nexus;
69 /* Pointer back to tcm_vhost_tport */
70 struct tcm_vhost_tport *tport;
71 /* Returned by tcm_vhost_make_tpg() */
72 struct se_portal_group se_tpg;
73};
74
75struct tcm_vhost_tport {
76 /* SCSI protocol the tport is providing */
77 u8 tport_proto_id;
78 /* Binary World Wide unique Port Name for Vhost Target port */
79 u64 tport_wwpn;
80 /* ASCII formatted WWPN for Vhost Target port */
81 char tport_name[TCM_VHOST_NAMELEN];
82 /* Returned by tcm_vhost_make_tport() */
83 struct se_wwn tport_wwn;
84};
85
86/*
87 * As per request from MST, keep TCM_VHOST related ioctl defines out of
88 * linux/vhost.h (user-space) for now..
89 */
90
91#include <linux/vhost.h>
92
93/*
94 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
95 *
96 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
97 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
Asias He67e18cf2013-02-05 12:31:57 +080098 * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
99 * All the targets under vhost_wwpn can be seen and used by guset.
Nicholas Bellinger057cbf42012-07-18 14:31:32 -0700100 */
101
Asias He67e18cf2013-02-05 12:31:57 +0800102#define VHOST_SCSI_ABI_VERSION 1
Nicholas Bellinger057cbf42012-07-18 14:31:32 -0700103
104struct vhost_scsi_target {
105 int abi_version;
Nicholas Bellinger5b7517f2012-08-16 18:56:34 -0700106 char vhost_wwpn[TRANSPORT_IQN_LEN];
Nicholas Bellinger057cbf42012-07-18 14:31:32 -0700107 unsigned short vhost_tpgt;
Michael S. Tsirkin6de71452012-08-18 15:44:09 -0700108 unsigned short reserved;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -0700109};
110
111/* VHOST_SCSI specific defines */
112#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
113#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
Nicholas Bellinger101998f2012-07-30 13:30:00 -0700114/* Changing this breaks userspace. */
115#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)