aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-05-01 20:50:34 -0400
committerMichael S. Tsirkin <mst@redhat.com>2013-05-02 06:40:15 -0400
commit5012a3a384ad917b5c72a918607bd0cc64452ff8 (patch)
treed014dbbbf78f061098a757b5a67c3212ed1259c1
parenteb62b74e90790dbc1aca7ea2a7161e23de7c9065 (diff)
tcm_vhost: header split up
move uapi parts to vhost.h move .c private parts to .c itself Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Asias He <asias@redhat.com> Acked-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/vhost/scsi.c112
-rw-r--r--drivers/vhost/tcm_vhost.h131
-rw-r--r--include/uapi/linux/vhost.h28
3 files changed, 132 insertions, 139 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 19ca021bf88c..eb1aa56dced8 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -51,7 +51,110 @@
51 51
52#include "vhost.c" 52#include "vhost.c"
53#include "vhost.h" 53#include "vhost.h"
54#include "tcm_vhost.h" 54
55#define TCM_VHOST_VERSION "v0.1"
56#define TCM_VHOST_NAMELEN 256
57#define TCM_VHOST_MAX_CDB_SIZE 32
58
59struct vhost_scsi_inflight {
60 /* Wait for the flush operation to finish */
61 struct completion comp;
62 /* Refcount for the inflight reqs */
63 struct kref kref;
64};
65
66struct tcm_vhost_cmd {
67 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */
68 int tvc_vq_desc;
69 /* virtio-scsi initiator task attribute */
70 int tvc_task_attr;
71 /* virtio-scsi initiator data direction */
72 enum dma_data_direction tvc_data_direction;
73 /* Expected data transfer length from virtio-scsi header */
74 u32 tvc_exp_data_len;
75 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */
76 u64 tvc_tag;
77 /* The number of scatterlists associated with this cmd */
78 u32 tvc_sgl_count;
79 /* Saved unpacked SCSI LUN for tcm_vhost_submission_work() */
80 u32 tvc_lun;
81 /* Pointer to the SGL formatted memory from virtio-scsi */
82 struct scatterlist *tvc_sgl;
83 /* Pointer to response */
84 struct virtio_scsi_cmd_resp __user *tvc_resp;
85 /* Pointer to vhost_scsi for our device */
86 struct vhost_scsi *tvc_vhost;
87 /* Pointer to vhost_virtqueue for the cmd */
88 struct vhost_virtqueue *tvc_vq;
89 /* Pointer to vhost nexus memory */
90 struct tcm_vhost_nexus *tvc_nexus;
91 /* The TCM I/O descriptor that is accessed via container_of() */
92 struct se_cmd tvc_se_cmd;
93 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */
94 struct work_struct work;
95 /* Copy of the incoming SCSI command descriptor block (CDB) */
96 unsigned char tvc_cdb[TCM_VHOST_MAX_CDB_SIZE];
97 /* Sense buffer that will be mapped into outgoing status */
98 unsigned char tvc_sense_buf[TRANSPORT_SENSE_BUFFER];
99 /* Completed commands list, serviced from vhost worker thread */
100 struct llist_node tvc_completion_list;
101 /* Used to track inflight cmd */
102 struct vhost_scsi_inflight *inflight;
103};
104
105struct tcm_vhost_nexus {
106 /* Pointer to TCM session for I_T Nexus */
107 struct se_session *tvn_se_sess;
108};
109
110struct tcm_vhost_nacl {
111 /* Binary World Wide unique Port Name for Vhost Initiator port */
112 u64 iport_wwpn;
113 /* ASCII formatted WWPN for Sas Initiator port */
114 char iport_name[TCM_VHOST_NAMELEN];
115 /* Returned by tcm_vhost_make_nodeacl() */
116 struct se_node_acl se_node_acl;
117};
118
119struct vhost_scsi;
120struct tcm_vhost_tpg {
121 /* Vhost port target portal group tag for TCM */
122 u16 tport_tpgt;
123 /* Used to track number of TPG Port/Lun Links wrt to explict I_T Nexus shutdown */
124 int tv_tpg_port_count;
125 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
126 int tv_tpg_vhost_count;
127 /* list for tcm_vhost_list */
128 struct list_head tv_tpg_list;
129 /* Used to protect access for tpg_nexus */
130 struct mutex tv_tpg_mutex;
131 /* Pointer to the TCM VHost I_T Nexus for this TPG endpoint */
132 struct tcm_vhost_nexus *tpg_nexus;
133 /* Pointer back to tcm_vhost_tport */
134 struct tcm_vhost_tport *tport;
135 /* Returned by tcm_vhost_make_tpg() */
136 struct se_portal_group se_tpg;
137 /* Pointer back to vhost_scsi, protected by tv_tpg_mutex */
138 struct vhost_scsi *vhost_scsi;
139};
140
141struct tcm_vhost_tport {
142 /* SCSI protocol the tport is providing */
143 u8 tport_proto_id;
144 /* Binary World Wide unique Port Name for Vhost Target port */
145 u64 tport_wwpn;
146 /* ASCII formatted WWPN for Vhost Target port */
147 char tport_name[TCM_VHOST_NAMELEN];
148 /* Returned by tcm_vhost_make_tport() */
149 struct se_wwn tport_wwn;
150};
151
152struct tcm_vhost_evt {
153 /* event to be sent to guest */
154 struct virtio_scsi_event event;
155 /* event list, serviced from vhost worker thread */
156 struct llist_node list;
157};
55 158
56enum { 159enum {
57 VHOST_SCSI_VQ_CTL = 0, 160 VHOST_SCSI_VQ_CTL = 0,
@@ -73,13 +176,6 @@ enum {
73#define VHOST_SCSI_MAX_VQ 128 176#define VHOST_SCSI_MAX_VQ 128
74#define VHOST_SCSI_MAX_EVENT 128 177#define VHOST_SCSI_MAX_EVENT 128
75 178
76struct vhost_scsi_inflight {
77 /* Wait for the flush operation to finish */
78 struct completion comp;
79 /* Refcount for the inflight reqs */
80 struct kref kref;
81};
82
83struct vhost_scsi_virtqueue { 179struct vhost_scsi_virtqueue {
84 struct vhost_virtqueue vq; 180 struct vhost_virtqueue vq;
85 /* 181 /*
diff --git a/drivers/vhost/tcm_vhost.h b/drivers/vhost/tcm_vhost.h
deleted file mode 100644
index 26a57c2fdf92..000000000000
--- a/drivers/vhost/tcm_vhost.h
+++ /dev/null
@@ -1,131 +0,0 @@
1#define TCM_VHOST_VERSION "v0.1"
2#define TCM_VHOST_NAMELEN 256
3#define TCM_VHOST_MAX_CDB_SIZE 32
4
5struct vhost_scsi_inflight;
6struct tcm_vhost_cmd {
7 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */
8 int tvc_vq_desc;
9 /* virtio-scsi initiator task attribute */
10 int tvc_task_attr;
11 /* virtio-scsi initiator data direction */
12 enum dma_data_direction tvc_data_direction;
13 /* Expected data transfer length from virtio-scsi header */
14 u32 tvc_exp_data_len;
15 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */
16 u64 tvc_tag;
17 /* The number of scatterlists associated with this cmd */
18 u32 tvc_sgl_count;
19 /* Saved unpacked SCSI LUN for tcm_vhost_submission_work() */
20 u32 tvc_lun;
21 /* Pointer to the SGL formatted memory from virtio-scsi */
22 struct scatterlist *tvc_sgl;
23 /* Pointer to response */
24 struct virtio_scsi_cmd_resp __user *tvc_resp;
25 /* Pointer to vhost_scsi for our device */
26 struct vhost_scsi *tvc_vhost;
27 /* Pointer to vhost_virtqueue for the cmd */
28 struct vhost_virtqueue *tvc_vq;
29 /* Pointer to vhost nexus memory */
30 struct tcm_vhost_nexus *tvc_nexus;
31 /* The TCM I/O descriptor that is accessed via container_of() */
32 struct se_cmd tvc_se_cmd;
33 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */
34 struct work_struct work;
35 /* Copy of the incoming SCSI command descriptor block (CDB) */
36 unsigned char tvc_cdb[TCM_VHOST_MAX_CDB_SIZE];
37 /* Sense buffer that will be mapped into outgoing status */
38 unsigned char tvc_sense_buf[TRANSPORT_SENSE_BUFFER];
39 /* Completed commands list, serviced from vhost worker thread */
40 struct llist_node tvc_completion_list;
41 /* Used to track inflight cmd */
42 struct vhost_scsi_inflight *inflight;
43};
44
45struct tcm_vhost_nexus {
46 /* Pointer to TCM session for I_T Nexus */
47 struct se_session *tvn_se_sess;
48};
49
50struct tcm_vhost_nacl {
51 /* Binary World Wide unique Port Name for Vhost Initiator port */
52 u64 iport_wwpn;
53 /* ASCII formatted WWPN for Sas Initiator port */
54 char iport_name[TCM_VHOST_NAMELEN];
55 /* Returned by tcm_vhost_make_nodeacl() */
56 struct se_node_acl se_node_acl;
57};
58
59struct vhost_scsi;
60struct tcm_vhost_tpg {
61 /* Vhost port target portal group tag for TCM */
62 u16 tport_tpgt;
63 /* Used to track number of TPG Port/Lun Links wrt to explict I_T Nexus shutdown */
64 int tv_tpg_port_count;
65 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
66 int tv_tpg_vhost_count;
67 /* list for tcm_vhost_list */
68 struct list_head tv_tpg_list;
69 /* Used to protect access for tpg_nexus */
70 struct mutex tv_tpg_mutex;
71 /* Pointer to the TCM VHost I_T Nexus for this TPG endpoint */
72 struct tcm_vhost_nexus *tpg_nexus;
73 /* Pointer back to tcm_vhost_tport */
74 struct tcm_vhost_tport *tport;
75 /* Returned by tcm_vhost_make_tpg() */
76 struct se_portal_group se_tpg;
77 /* Pointer back to vhost_scsi, protected by tv_tpg_mutex */
78 struct vhost_scsi *vhost_scsi;
79};
80
81struct tcm_vhost_tport {
82 /* SCSI protocol the tport is providing */
83 u8 tport_proto_id;
84 /* Binary World Wide unique Port Name for Vhost Target port */
85 u64 tport_wwpn;
86 /* ASCII formatted WWPN for Vhost Target port */
87 char tport_name[TCM_VHOST_NAMELEN];
88 /* Returned by tcm_vhost_make_tport() */
89 struct se_wwn tport_wwn;
90};
91
92struct tcm_vhost_evt {
93 /* event to be sent to guest */
94 struct virtio_scsi_event event;
95 /* event list, serviced from vhost worker thread */
96 struct llist_node list;
97};
98
99/*
100 * As per request from MST, keep TCM_VHOST related ioctl defines out of
101 * linux/vhost.h (user-space) for now..
102 */
103
104#include <linux/vhost.h>
105
106/*
107 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
108 *
109 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
110 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
111 * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
112 * All the targets under vhost_wwpn can be seen and used by guset.
113 */
114
115#define VHOST_SCSI_ABI_VERSION 1
116
117struct vhost_scsi_target {
118 int abi_version;
119 char vhost_wwpn[TRANSPORT_IQN_LEN];
120 unsigned short vhost_tpgt;
121 unsigned short reserved;
122};
123
124/* VHOST_SCSI specific defines */
125#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
126#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
127/* Changing this breaks userspace. */
128#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
129/* Set and get the events missed flag */
130#define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
131#define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index e847f1e30756..bb6a5b4cb3c5 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -127,4 +127,32 @@ struct vhost_memory {
127/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ 127/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
128#define VHOST_NET_F_VIRTIO_NET_HDR 27 128#define VHOST_NET_F_VIRTIO_NET_HDR 27
129 129
130/* VHOST_SCSI specific definitions */
131
132/*
133 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
134 *
135 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
136 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
137 * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
138 * All the targets under vhost_wwpn can be seen and used by guset.
139 */
140
141#define VHOST_SCSI_ABI_VERSION 1
142
143struct vhost_scsi_target {
144 int abi_version;
145 char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */
146 unsigned short vhost_tpgt;
147 unsigned short reserved;
148};
149
150#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
151#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
152/* Changing this breaks userspace. */
153#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
154/* Set and get the events missed flag */
155#define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
156#define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)
157
130#endif 158#endif