diff options
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/iscsi_if.h | 93 | ||||
-rw-r--r-- | include/scsi/iscsi_proto.h | 3 | ||||
-rw-r--r-- | include/scsi/libiscsi.h | 107 | ||||
-rw-r--r-- | include/scsi/scsi.h | 18 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 1 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 23 | ||||
-rw-r--r-- | include/scsi/scsi_dh.h | 69 | ||||
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 91 | ||||
-rw-r--r-- | include/scsi/sd.h | 57 | ||||
-rw-r--r-- | include/scsi/sg.h | 1 |
10 files changed, 262 insertions, 201 deletions
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h index e19e58423166..16be12f1cbe8 100644 --- a/include/scsi/iscsi_if.h +++ b/include/scsi/iscsi_if.h | |||
@@ -50,6 +50,7 @@ enum iscsi_uevent_e { | |||
50 | ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, | 50 | ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, |
51 | ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16, | 51 | ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16, |
52 | ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17, | 52 | ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17, |
53 | ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18, | ||
53 | 54 | ||
54 | /* up events */ | 55 | /* up events */ |
55 | ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, | 56 | ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, |
@@ -78,6 +79,12 @@ struct iscsi_uevent { | |||
78 | uint16_t cmds_max; | 79 | uint16_t cmds_max; |
79 | uint16_t queue_depth; | 80 | uint16_t queue_depth; |
80 | } c_session; | 81 | } c_session; |
82 | struct msg_create_bound_session { | ||
83 | uint64_t ep_handle; | ||
84 | uint32_t initial_cmdsn; | ||
85 | uint16_t cmds_max; | ||
86 | uint16_t queue_depth; | ||
87 | } c_bound_session; | ||
81 | struct msg_destroy_session { | 88 | struct msg_destroy_session { |
82 | uint32_t sid; | 89 | uint32_t sid; |
83 | } d_session; | 90 | } d_session; |
@@ -250,42 +257,49 @@ enum iscsi_param { | |||
250 | 257 | ||
251 | ISCSI_PARAM_PING_TMO, | 258 | ISCSI_PARAM_PING_TMO, |
252 | ISCSI_PARAM_RECV_TMO, | 259 | ISCSI_PARAM_RECV_TMO, |
260 | |||
261 | ISCSI_PARAM_IFACE_NAME, | ||
262 | ISCSI_PARAM_ISID, | ||
263 | ISCSI_PARAM_INITIATOR_NAME, | ||
253 | /* must always be last */ | 264 | /* must always be last */ |
254 | ISCSI_PARAM_MAX, | 265 | ISCSI_PARAM_MAX, |
255 | }; | 266 | }; |
256 | 267 | ||
257 | #define ISCSI_MAX_RECV_DLENGTH (1 << ISCSI_PARAM_MAX_RECV_DLENGTH) | 268 | #define ISCSI_MAX_RECV_DLENGTH (1ULL << ISCSI_PARAM_MAX_RECV_DLENGTH) |
258 | #define ISCSI_MAX_XMIT_DLENGTH (1 << ISCSI_PARAM_MAX_XMIT_DLENGTH) | 269 | #define ISCSI_MAX_XMIT_DLENGTH (1ULL << ISCSI_PARAM_MAX_XMIT_DLENGTH) |
259 | #define ISCSI_HDRDGST_EN (1 << ISCSI_PARAM_HDRDGST_EN) | 270 | #define ISCSI_HDRDGST_EN (1ULL << ISCSI_PARAM_HDRDGST_EN) |
260 | #define ISCSI_DATADGST_EN (1 << ISCSI_PARAM_DATADGST_EN) | 271 | #define ISCSI_DATADGST_EN (1ULL << ISCSI_PARAM_DATADGST_EN) |
261 | #define ISCSI_INITIAL_R2T_EN (1 << ISCSI_PARAM_INITIAL_R2T_EN) | 272 | #define ISCSI_INITIAL_R2T_EN (1ULL << ISCSI_PARAM_INITIAL_R2T_EN) |
262 | #define ISCSI_MAX_R2T (1 << ISCSI_PARAM_MAX_R2T) | 273 | #define ISCSI_MAX_R2T (1ULL << ISCSI_PARAM_MAX_R2T) |
263 | #define ISCSI_IMM_DATA_EN (1 << ISCSI_PARAM_IMM_DATA_EN) | 274 | #define ISCSI_IMM_DATA_EN (1ULL << ISCSI_PARAM_IMM_DATA_EN) |
264 | #define ISCSI_FIRST_BURST (1 << ISCSI_PARAM_FIRST_BURST) | 275 | #define ISCSI_FIRST_BURST (1ULL << ISCSI_PARAM_FIRST_BURST) |
265 | #define ISCSI_MAX_BURST (1 << ISCSI_PARAM_MAX_BURST) | 276 | #define ISCSI_MAX_BURST (1ULL << ISCSI_PARAM_MAX_BURST) |
266 | #define ISCSI_PDU_INORDER_EN (1 << ISCSI_PARAM_PDU_INORDER_EN) | 277 | #define ISCSI_PDU_INORDER_EN (1ULL << ISCSI_PARAM_PDU_INORDER_EN) |
267 | #define ISCSI_DATASEQ_INORDER_EN (1 << ISCSI_PARAM_DATASEQ_INORDER_EN) | 278 | #define ISCSI_DATASEQ_INORDER_EN (1ULL << ISCSI_PARAM_DATASEQ_INORDER_EN) |
268 | #define ISCSI_ERL (1 << ISCSI_PARAM_ERL) | 279 | #define ISCSI_ERL (1ULL << ISCSI_PARAM_ERL) |
269 | #define ISCSI_IFMARKER_EN (1 << ISCSI_PARAM_IFMARKER_EN) | 280 | #define ISCSI_IFMARKER_EN (1ULL << ISCSI_PARAM_IFMARKER_EN) |
270 | #define ISCSI_OFMARKER_EN (1 << ISCSI_PARAM_OFMARKER_EN) | 281 | #define ISCSI_OFMARKER_EN (1ULL << ISCSI_PARAM_OFMARKER_EN) |
271 | #define ISCSI_EXP_STATSN (1 << ISCSI_PARAM_EXP_STATSN) | 282 | #define ISCSI_EXP_STATSN (1ULL << ISCSI_PARAM_EXP_STATSN) |
272 | #define ISCSI_TARGET_NAME (1 << ISCSI_PARAM_TARGET_NAME) | 283 | #define ISCSI_TARGET_NAME (1ULL << ISCSI_PARAM_TARGET_NAME) |
273 | #define ISCSI_TPGT (1 << ISCSI_PARAM_TPGT) | 284 | #define ISCSI_TPGT (1ULL << ISCSI_PARAM_TPGT) |
274 | #define ISCSI_PERSISTENT_ADDRESS (1 << ISCSI_PARAM_PERSISTENT_ADDRESS) | 285 | #define ISCSI_PERSISTENT_ADDRESS (1ULL << ISCSI_PARAM_PERSISTENT_ADDRESS) |
275 | #define ISCSI_PERSISTENT_PORT (1 << ISCSI_PARAM_PERSISTENT_PORT) | 286 | #define ISCSI_PERSISTENT_PORT (1ULL << ISCSI_PARAM_PERSISTENT_PORT) |
276 | #define ISCSI_SESS_RECOVERY_TMO (1 << ISCSI_PARAM_SESS_RECOVERY_TMO) | 287 | #define ISCSI_SESS_RECOVERY_TMO (1ULL << ISCSI_PARAM_SESS_RECOVERY_TMO) |
277 | #define ISCSI_CONN_PORT (1 << ISCSI_PARAM_CONN_PORT) | 288 | #define ISCSI_CONN_PORT (1ULL << ISCSI_PARAM_CONN_PORT) |
278 | #define ISCSI_CONN_ADDRESS (1 << ISCSI_PARAM_CONN_ADDRESS) | 289 | #define ISCSI_CONN_ADDRESS (1ULL << ISCSI_PARAM_CONN_ADDRESS) |
279 | #define ISCSI_USERNAME (1 << ISCSI_PARAM_USERNAME) | 290 | #define ISCSI_USERNAME (1ULL << ISCSI_PARAM_USERNAME) |
280 | #define ISCSI_USERNAME_IN (1 << ISCSI_PARAM_USERNAME_IN) | 291 | #define ISCSI_USERNAME_IN (1ULL << ISCSI_PARAM_USERNAME_IN) |
281 | #define ISCSI_PASSWORD (1 << ISCSI_PARAM_PASSWORD) | 292 | #define ISCSI_PASSWORD (1ULL << ISCSI_PARAM_PASSWORD) |
282 | #define ISCSI_PASSWORD_IN (1 << ISCSI_PARAM_PASSWORD_IN) | 293 | #define ISCSI_PASSWORD_IN (1ULL << ISCSI_PARAM_PASSWORD_IN) |
283 | #define ISCSI_FAST_ABORT (1 << ISCSI_PARAM_FAST_ABORT) | 294 | #define ISCSI_FAST_ABORT (1ULL << ISCSI_PARAM_FAST_ABORT) |
284 | #define ISCSI_ABORT_TMO (1 << ISCSI_PARAM_ABORT_TMO) | 295 | #define ISCSI_ABORT_TMO (1ULL << ISCSI_PARAM_ABORT_TMO) |
285 | #define ISCSI_LU_RESET_TMO (1 << ISCSI_PARAM_LU_RESET_TMO) | 296 | #define ISCSI_LU_RESET_TMO (1ULL << ISCSI_PARAM_LU_RESET_TMO) |
286 | #define ISCSI_HOST_RESET_TMO (1 << ISCSI_PARAM_HOST_RESET_TMO) | 297 | #define ISCSI_HOST_RESET_TMO (1ULL << ISCSI_PARAM_HOST_RESET_TMO) |
287 | #define ISCSI_PING_TMO (1 << ISCSI_PARAM_PING_TMO) | 298 | #define ISCSI_PING_TMO (1ULL << ISCSI_PARAM_PING_TMO) |
288 | #define ISCSI_RECV_TMO (1 << ISCSI_PARAM_RECV_TMO) | 299 | #define ISCSI_RECV_TMO (1ULL << ISCSI_PARAM_RECV_TMO) |
300 | #define ISCSI_IFACE_NAME (1ULL << ISCSI_PARAM_IFACE_NAME) | ||
301 | #define ISCSI_ISID (1ULL << ISCSI_PARAM_ISID) | ||
302 | #define ISCSI_INITIATOR_NAME (1ULL << ISCSI_PARAM_INITIATOR_NAME) | ||
289 | 303 | ||
290 | /* iSCSI HBA params */ | 304 | /* iSCSI HBA params */ |
291 | enum iscsi_host_param { | 305 | enum iscsi_host_param { |
@@ -296,20 +310,13 @@ enum iscsi_host_param { | |||
296 | ISCSI_HOST_PARAM_MAX, | 310 | ISCSI_HOST_PARAM_MAX, |
297 | }; | 311 | }; |
298 | 312 | ||
299 | #define ISCSI_HOST_HWADDRESS (1 << ISCSI_HOST_PARAM_HWADDRESS) | 313 | #define ISCSI_HOST_HWADDRESS (1ULL << ISCSI_HOST_PARAM_HWADDRESS) |
300 | #define ISCSI_HOST_INITIATOR_NAME (1 << ISCSI_HOST_PARAM_INITIATOR_NAME) | 314 | #define ISCSI_HOST_INITIATOR_NAME (1ULL << ISCSI_HOST_PARAM_INITIATOR_NAME) |
301 | #define ISCSI_HOST_NETDEV_NAME (1 << ISCSI_HOST_PARAM_NETDEV_NAME) | 315 | #define ISCSI_HOST_NETDEV_NAME (1ULL << ISCSI_HOST_PARAM_NETDEV_NAME) |
302 | #define ISCSI_HOST_IPADDRESS (1 << ISCSI_HOST_PARAM_IPADDRESS) | 316 | #define ISCSI_HOST_IPADDRESS (1ULL << ISCSI_HOST_PARAM_IPADDRESS) |
303 | 317 | ||
304 | #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) | 318 | #define iscsi_ptr(_handle) ((void*)(unsigned long)_handle) |
305 | #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) | 319 | #define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr) |
306 | #define hostdata_session(_hostdata) (iscsi_ptr(*(unsigned long *)_hostdata)) | ||
307 | |||
308 | /** | ||
309 | * iscsi_hostdata - get LLD hostdata from scsi_host | ||
310 | * @_hostdata: pointer to scsi host's hostdata | ||
311 | **/ | ||
312 | #define iscsi_hostdata(_hostdata) ((void*)_hostdata + sizeof(unsigned long)) | ||
313 | 320 | ||
314 | /* | 321 | /* |
315 | * These flags presents iSCSI Data-Path capabilities. | 322 | * These flags presents iSCSI Data-Path capabilities. |
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h index e0593bfae622..f2a2c1169486 100644 --- a/include/scsi/iscsi_proto.h +++ b/include/scsi/iscsi_proto.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define ISCSI_PROTO_H | 22 | #define ISCSI_PROTO_H |
23 | 23 | ||
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <scsi/scsi.h> | ||
25 | 26 | ||
26 | #define ISCSI_DRAFT20_VERSION 0x00 | 27 | #define ISCSI_DRAFT20_VERSION 0x00 |
27 | 28 | ||
@@ -156,7 +157,7 @@ struct iscsi_ecdb_ahdr { | |||
156 | uint8_t ahstype; | 157 | uint8_t ahstype; |
157 | uint8_t reserved; | 158 | uint8_t reserved; |
158 | /* 4-byte aligned extended CDB spillover */ | 159 | /* 4-byte aligned extended CDB spillover */ |
159 | uint8_t ecdb[260 - ISCSI_CDB_SIZE]; | 160 | uint8_t ecdb[SCSI_MAX_VARLEN_CDB_SIZE - ISCSI_CDB_SIZE]; |
160 | }; | 161 | }; |
161 | 162 | ||
162 | /* SCSI Response Header */ | 163 | /* SCSI Response Header */ |
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index cd3ca63d4fb1..5e75bb7f311c 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #define LIBISCSI_H | 24 | #define LIBISCSI_H |
25 | 25 | ||
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #include <linux/wait.h> | ||
27 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
28 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
29 | #include <linux/workqueue.h> | 30 | #include <linux/workqueue.h> |
@@ -31,6 +32,7 @@ | |||
31 | #include <scsi/iscsi_if.h> | 32 | #include <scsi/iscsi_if.h> |
32 | 33 | ||
33 | struct scsi_transport_template; | 34 | struct scsi_transport_template; |
35 | struct scsi_host_template; | ||
34 | struct scsi_device; | 36 | struct scsi_device; |
35 | struct Scsi_Host; | 37 | struct Scsi_Host; |
36 | struct scsi_cmnd; | 38 | struct scsi_cmnd; |
@@ -40,6 +42,7 @@ struct iscsi_cls_session; | |||
40 | struct iscsi_cls_conn; | 42 | struct iscsi_cls_conn; |
41 | struct iscsi_session; | 43 | struct iscsi_session; |
42 | struct iscsi_nopin; | 44 | struct iscsi_nopin; |
45 | struct device; | ||
43 | 46 | ||
44 | /* #define DEBUG_SCSI */ | 47 | /* #define DEBUG_SCSI */ |
45 | #ifdef DEBUG_SCSI | 48 | #ifdef DEBUG_SCSI |
@@ -49,9 +52,7 @@ struct iscsi_nopin; | |||
49 | #endif | 52 | #endif |
50 | 53 | ||
51 | #define ISCSI_DEF_XMIT_CMDS_MAX 128 /* must be power of 2 */ | 54 | #define ISCSI_DEF_XMIT_CMDS_MAX 128 /* must be power of 2 */ |
52 | #define ISCSI_MGMT_CMDS_MAX 16 /* must be power of 2 */ | 55 | #define ISCSI_MGMT_CMDS_MAX 15 |
53 | |||
54 | #define ISCSI_MGMT_ITT_OFFSET 0xa00 | ||
55 | 56 | ||
56 | #define ISCSI_DEF_CMD_PER_LUN 32 | 57 | #define ISCSI_DEF_CMD_PER_LUN 32 |
57 | #define ISCSI_MAX_CMD_PER_LUN 128 | 58 | #define ISCSI_MAX_CMD_PER_LUN 128 |
@@ -69,7 +70,10 @@ enum { | |||
69 | /* Connection suspend "bit" */ | 70 | /* Connection suspend "bit" */ |
70 | #define ISCSI_SUSPEND_BIT 1 | 71 | #define ISCSI_SUSPEND_BIT 1 |
71 | 72 | ||
72 | #define ISCSI_ITT_MASK (0xfff) | 73 | #define ISCSI_ITT_MASK (0x1fff) |
74 | #define ISCSI_TOTAL_CMDS_MAX 4096 | ||
75 | /* this must be a power of two greater than ISCSI_MGMT_CMDS_MAX */ | ||
76 | #define ISCSI_TOTAL_CMDS_MIN 16 | ||
73 | #define ISCSI_AGE_SHIFT 28 | 77 | #define ISCSI_AGE_SHIFT 28 |
74 | #define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT) | 78 | #define ISCSI_AGE_MASK (0xf << ISCSI_AGE_SHIFT) |
75 | 79 | ||
@@ -82,18 +86,6 @@ enum { | |||
82 | ISCSI_DIGEST_SIZE = sizeof(__u32), | 86 | ISCSI_DIGEST_SIZE = sizeof(__u32), |
83 | }; | 87 | }; |
84 | 88 | ||
85 | struct iscsi_mgmt_task { | ||
86 | /* | ||
87 | * Becuae LLDs allocate their hdr differently, this is a pointer to | ||
88 | * that storage. It must be setup at session creation time. | ||
89 | */ | ||
90 | struct iscsi_hdr *hdr; | ||
91 | char *data; /* mgmt payload */ | ||
92 | unsigned data_count; /* counts data to be sent */ | ||
93 | uint32_t itt; /* this ITT */ | ||
94 | void *dd_data; /* driver/transport data */ | ||
95 | struct list_head running; | ||
96 | }; | ||
97 | 89 | ||
98 | enum { | 90 | enum { |
99 | ISCSI_TASK_COMPLETED, | 91 | ISCSI_TASK_COMPLETED, |
@@ -101,7 +93,7 @@ enum { | |||
101 | ISCSI_TASK_RUNNING, | 93 | ISCSI_TASK_RUNNING, |
102 | }; | 94 | }; |
103 | 95 | ||
104 | struct iscsi_cmd_task { | 96 | struct iscsi_task { |
105 | /* | 97 | /* |
106 | * Because LLDs allocate their hdr differently, this is a pointer | 98 | * Because LLDs allocate their hdr differently, this is a pointer |
107 | * and length to that storage. It must be setup at session | 99 | * and length to that storage. It must be setup at session |
@@ -118,6 +110,7 @@ struct iscsi_cmd_task { | |||
118 | /* offset in unsolicited stream (bytes); */ | 110 | /* offset in unsolicited stream (bytes); */ |
119 | unsigned unsol_offset; | 111 | unsigned unsol_offset; |
120 | unsigned data_count; /* remaining Data-Out */ | 112 | unsigned data_count; /* remaining Data-Out */ |
113 | char *data; /* mgmt payload */ | ||
121 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ | 114 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ |
122 | struct iscsi_conn *conn; /* used connection */ | 115 | struct iscsi_conn *conn; /* used connection */ |
123 | 116 | ||
@@ -128,9 +121,9 @@ struct iscsi_cmd_task { | |||
128 | void *dd_data; /* driver/transport data */ | 121 | void *dd_data; /* driver/transport data */ |
129 | }; | 122 | }; |
130 | 123 | ||
131 | static inline void* iscsi_next_hdr(struct iscsi_cmd_task *ctask) | 124 | static inline void* iscsi_next_hdr(struct iscsi_task *task) |
132 | { | 125 | { |
133 | return (void*)ctask->hdr + ctask->hdr_len; | 126 | return (void*)task->hdr + task->hdr_len; |
134 | } | 127 | } |
135 | 128 | ||
136 | /* Connection's states */ | 129 | /* Connection's states */ |
@@ -146,11 +139,6 @@ struct iscsi_conn { | |||
146 | void *dd_data; /* iscsi_transport data */ | 139 | void *dd_data; /* iscsi_transport data */ |
147 | struct iscsi_session *session; /* parent session */ | 140 | struct iscsi_session *session; /* parent session */ |
148 | /* | 141 | /* |
149 | * LLDs should set this lock. It protects the transport recv | ||
150 | * code | ||
151 | */ | ||
152 | rwlock_t *recv_lock; | ||
153 | /* | ||
154 | * conn_stop() flag: stop to recover, stop to terminate | 142 | * conn_stop() flag: stop to recover, stop to terminate |
155 | */ | 143 | */ |
156 | int stop_stage; | 144 | int stop_stage; |
@@ -159,7 +147,7 @@ struct iscsi_conn { | |||
159 | unsigned long last_ping; | 147 | unsigned long last_ping; |
160 | int ping_timeout; | 148 | int ping_timeout; |
161 | int recv_timeout; | 149 | int recv_timeout; |
162 | struct iscsi_mgmt_task *ping_mtask; | 150 | struct iscsi_task *ping_task; |
163 | 151 | ||
164 | /* iSCSI connection-wide sequencing */ | 152 | /* iSCSI connection-wide sequencing */ |
165 | uint32_t exp_statsn; | 153 | uint32_t exp_statsn; |
@@ -175,9 +163,8 @@ struct iscsi_conn { | |||
175 | * should always fit in this buffer | 163 | * should always fit in this buffer |
176 | */ | 164 | */ |
177 | char *data; | 165 | char *data; |
178 | struct iscsi_mgmt_task *login_mtask; /* mtask used for login/text */ | 166 | struct iscsi_task *login_task; /* mtask used for login/text */ |
179 | struct iscsi_mgmt_task *mtask; /* xmit mtask in progress */ | 167 | struct iscsi_task *task; /* xmit task in progress */ |
180 | struct iscsi_cmd_task *ctask; /* xmit ctask in progress */ | ||
181 | 168 | ||
182 | /* xmit */ | 169 | /* xmit */ |
183 | struct list_head mgmtqueue; /* mgmt (control) xmit queue */ | 170 | struct list_head mgmtqueue; /* mgmt (control) xmit queue */ |
@@ -208,9 +195,6 @@ struct iscsi_conn { | |||
208 | /* remote portal currently connected to */ | 195 | /* remote portal currently connected to */ |
209 | int portal_port; | 196 | int portal_port; |
210 | char portal_address[ISCSI_ADDRESS_BUF_LEN]; | 197 | char portal_address[ISCSI_ADDRESS_BUF_LEN]; |
211 | /* local address */ | ||
212 | int local_port; | ||
213 | char local_address[ISCSI_ADDRESS_BUF_LEN]; | ||
214 | 198 | ||
215 | /* MIB-statistics */ | 199 | /* MIB-statistics */ |
216 | uint64_t txdata_octets; | 200 | uint64_t txdata_octets; |
@@ -246,6 +230,7 @@ enum { | |||
246 | }; | 230 | }; |
247 | 231 | ||
248 | struct iscsi_session { | 232 | struct iscsi_session { |
233 | struct iscsi_cls_session *cls_session; | ||
249 | /* | 234 | /* |
250 | * Syncs up the scsi eh thread with the iscsi eh thread when sending | 235 | * Syncs up the scsi eh thread with the iscsi eh thread when sending |
251 | * task management functions. This must be taken before the session | 236 | * task management functions. This must be taken before the session |
@@ -281,10 +266,8 @@ struct iscsi_session { | |||
281 | char *password; | 266 | char *password; |
282 | char *password_in; | 267 | char *password_in; |
283 | char *targetname; | 268 | char *targetname; |
269 | char *ifacename; | ||
284 | char *initiatorname; | 270 | char *initiatorname; |
285 | /* hw address or netdev iscsi connection is bound to */ | ||
286 | char *hwaddress; | ||
287 | char *netdev; | ||
288 | /* control data */ | 271 | /* control data */ |
289 | struct iscsi_transport *tt; | 272 | struct iscsi_transport *tt; |
290 | struct Scsi_Host *host; | 273 | struct Scsi_Host *host; |
@@ -298,12 +281,20 @@ struct iscsi_session { | |||
298 | int state; /* session state */ | 281 | int state; /* session state */ |
299 | int age; /* counts session re-opens */ | 282 | int age; /* counts session re-opens */ |
300 | 283 | ||
284 | int scsi_cmds_max; /* max scsi commands */ | ||
301 | int cmds_max; /* size of cmds array */ | 285 | int cmds_max; /* size of cmds array */ |
302 | struct iscsi_cmd_task **cmds; /* Original Cmds arr */ | 286 | struct iscsi_task **cmds; /* Original Cmds arr */ |
303 | struct iscsi_pool cmdpool; /* PDU's pool */ | 287 | struct iscsi_pool cmdpool; /* PDU's pool */ |
304 | int mgmtpool_max; /* size of mgmt array */ | 288 | }; |
305 | struct iscsi_mgmt_task **mgmt_cmds; /* Original mgmt arr */ | 289 | |
306 | struct iscsi_pool mgmtpool; /* Mgmt PDU's pool */ | 290 | struct iscsi_host { |
291 | char *initiatorname; | ||
292 | /* hw address or netdev iscsi connection is bound to */ | ||
293 | char *hwaddress; | ||
294 | char *netdev; | ||
295 | /* local address */ | ||
296 | int local_port; | ||
297 | char local_address[ISCSI_ADDRESS_BUF_LEN]; | ||
307 | }; | 298 | }; |
308 | 299 | ||
309 | /* | 300 | /* |
@@ -316,42 +307,44 @@ extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); | |||
316 | extern int iscsi_queuecommand(struct scsi_cmnd *sc, | 307 | extern int iscsi_queuecommand(struct scsi_cmnd *sc, |
317 | void (*done)(struct scsi_cmnd *)); | 308 | void (*done)(struct scsi_cmnd *)); |
318 | 309 | ||
319 | |||
320 | /* | 310 | /* |
321 | * iSCSI host helpers. | 311 | * iSCSI host helpers. |
322 | */ | 312 | */ |
313 | #define iscsi_host_priv(_shost) \ | ||
314 | (shost_priv(_shost) + sizeof(struct iscsi_host)) | ||
315 | |||
323 | extern int iscsi_host_set_param(struct Scsi_Host *shost, | 316 | extern int iscsi_host_set_param(struct Scsi_Host *shost, |
324 | enum iscsi_host_param param, char *buf, | 317 | enum iscsi_host_param param, char *buf, |
325 | int buflen); | 318 | int buflen); |
326 | extern int iscsi_host_get_param(struct Scsi_Host *shost, | 319 | extern int iscsi_host_get_param(struct Scsi_Host *shost, |
327 | enum iscsi_host_param param, char *buf); | 320 | enum iscsi_host_param param, char *buf); |
321 | extern int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev); | ||
322 | extern struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht, | ||
323 | int dd_data_size, uint16_t qdepth); | ||
324 | extern void iscsi_host_remove(struct Scsi_Host *shost); | ||
325 | extern void iscsi_host_free(struct Scsi_Host *shost); | ||
328 | 326 | ||
329 | /* | 327 | /* |
330 | * session management | 328 | * session management |
331 | */ | 329 | */ |
332 | extern struct iscsi_cls_session * | 330 | extern struct iscsi_cls_session * |
333 | iscsi_session_setup(struct iscsi_transport *, struct scsi_transport_template *, | 331 | iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *shost, |
334 | uint16_t, uint16_t, int, int, uint32_t, uint32_t *); | 332 | uint16_t, int, uint32_t, unsigned int); |
335 | extern void iscsi_session_teardown(struct iscsi_cls_session *); | 333 | extern void iscsi_session_teardown(struct iscsi_cls_session *); |
336 | extern struct iscsi_session *class_to_transport_session(struct iscsi_cls_session *); | ||
337 | extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *); | 334 | extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *); |
338 | extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn, | 335 | extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn, |
339 | enum iscsi_param param, char *buf, int buflen); | 336 | enum iscsi_param param, char *buf, int buflen); |
340 | extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session, | 337 | extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session, |
341 | enum iscsi_param param, char *buf); | 338 | enum iscsi_param param, char *buf); |
342 | 339 | ||
343 | #define session_to_cls(_sess) \ | ||
344 | hostdata_session(_sess->host->hostdata) | ||
345 | |||
346 | #define iscsi_session_printk(prefix, _sess, fmt, a...) \ | 340 | #define iscsi_session_printk(prefix, _sess, fmt, a...) \ |
347 | iscsi_cls_session_printk(prefix, \ | 341 | iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a) |
348 | (struct iscsi_cls_session *)session_to_cls(_sess), fmt, ##a) | ||
349 | 342 | ||
350 | /* | 343 | /* |
351 | * connection management | 344 | * connection management |
352 | */ | 345 | */ |
353 | extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *, | 346 | extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *, |
354 | uint32_t); | 347 | int, uint32_t); |
355 | extern void iscsi_conn_teardown(struct iscsi_cls_conn *); | 348 | extern void iscsi_conn_teardown(struct iscsi_cls_conn *); |
356 | extern int iscsi_conn_start(struct iscsi_cls_conn *); | 349 | extern int iscsi_conn_start(struct iscsi_cls_conn *); |
357 | extern void iscsi_conn_stop(struct iscsi_cls_conn *, int); | 350 | extern void iscsi_conn_stop(struct iscsi_cls_conn *, int); |
@@ -360,25 +353,29 @@ extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *, | |||
360 | extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err); | 353 | extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err); |
361 | extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, | 354 | extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, |
362 | enum iscsi_param param, char *buf); | 355 | enum iscsi_param param, char *buf); |
356 | extern void iscsi_suspend_tx(struct iscsi_conn *conn); | ||
363 | 357 | ||
364 | #define iscsi_conn_printk(prefix, _c, fmt, a...) \ | 358 | #define iscsi_conn_printk(prefix, _c, fmt, a...) \ |
365 | iscsi_cls_conn_printk(prefix, _c->cls_conn, fmt, ##a) | 359 | iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \ |
360 | fmt, ##a) | ||
366 | 361 | ||
367 | /* | 362 | /* |
368 | * pdu and task processing | 363 | * pdu and task processing |
369 | */ | 364 | */ |
370 | extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *); | 365 | extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *); |
371 | extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *, | 366 | extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_task *, |
372 | struct iscsi_data *hdr); | 367 | struct iscsi_data *hdr); |
373 | extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, | 368 | extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, |
374 | char *, uint32_t); | 369 | char *, uint32_t); |
375 | extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *, | 370 | extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *, |
376 | char *, int); | 371 | char *, int); |
377 | extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *, | 372 | extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *, |
378 | uint32_t *); | 373 | char *, int); |
379 | extern void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask); | 374 | extern int iscsi_verify_itt(struct iscsi_conn *, itt_t); |
380 | extern void iscsi_free_mgmt_task(struct iscsi_conn *conn, | 375 | extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t); |
381 | struct iscsi_mgmt_task *mtask); | 376 | extern void iscsi_requeue_task(struct iscsi_task *task); |
377 | extern void iscsi_put_task(struct iscsi_task *task); | ||
378 | extern void __iscsi_get_task(struct iscsi_task *task); | ||
382 | 379 | ||
383 | /* | 380 | /* |
384 | * generic helpers | 381 | * generic helpers |
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 32742c4563de..00137a7769ee 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #define _SCSI_SCSI_H | 9 | #define _SCSI_SCSI_H |
10 | 10 | ||
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <scsi/scsi_cmnd.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * The maximum number of SG segments that we will put inside a | 15 | * The maximum number of SG segments that we will put inside a |
@@ -400,6 +401,7 @@ struct scsi_lun { | |||
400 | #define SOFT_ERROR 0x2005 | 401 | #define SOFT_ERROR 0x2005 |
401 | #define ADD_TO_MLQUEUE 0x2006 | 402 | #define ADD_TO_MLQUEUE 0x2006 |
402 | #define TIMEOUT_ERROR 0x2007 | 403 | #define TIMEOUT_ERROR 0x2007 |
404 | #define SCSI_RETURN_NOT_HANDLED 0x2008 | ||
403 | 405 | ||
404 | /* | 406 | /* |
405 | * Midlevel queue return values. | 407 | * Midlevel queue return values. |
@@ -424,6 +426,22 @@ struct scsi_lun { | |||
424 | #define driver_byte(result) (((result) >> 24) & 0xff) | 426 | #define driver_byte(result) (((result) >> 24) & 0xff) |
425 | #define suggestion(result) (driver_byte(result) & SUGGEST_MASK) | 427 | #define suggestion(result) (driver_byte(result) & SUGGEST_MASK) |
426 | 428 | ||
429 | static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) | ||
430 | { | ||
431 | cmd->result |= status << 8; | ||
432 | } | ||
433 | |||
434 | static inline void set_host_byte(struct scsi_cmnd *cmd, char status) | ||
435 | { | ||
436 | cmd->result |= status << 16; | ||
437 | } | ||
438 | |||
439 | static inline void set_driver_byte(struct scsi_cmnd *cmd, char status) | ||
440 | { | ||
441 | cmd->result |= status << 24; | ||
442 | } | ||
443 | |||
444 | |||
427 | #define sense_class(sense) (((sense) >> 4) & 0x7) | 445 | #define sense_class(sense) (((sense) >> 4) & 0x7) |
428 | #define sense_error(sense) ((sense) & 0xf) | 446 | #define sense_error(sense) ((sense) & 0xf) |
429 | #define sense_valid(sense) ((sense) & 0x80); | 447 | #define sense_valid(sense) ((sense) & 0x80); |
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 3e46dfae8194..66c944849d6b 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
8 | #include <linux/timer.h> | 8 | #include <linux/timer.h> |
9 | #include <linux/scatterlist.h> | 9 | #include <linux/scatterlist.h> |
10 | #include <linux/blkdev.h> | ||
11 | 10 | ||
12 | struct Scsi_Host; | 11 | struct Scsi_Host; |
13 | struct scsi_device; | 12 | struct scsi_device; |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index f6a9fe0ef09c..6467f78b191f 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -134,6 +134,7 @@ struct scsi_device { | |||
134 | unsigned no_start_on_add:1; /* do not issue start on add */ | 134 | unsigned no_start_on_add:1; /* do not issue start on add */ |
135 | unsigned allow_restart:1; /* issue START_UNIT in error handler */ | 135 | unsigned allow_restart:1; /* issue START_UNIT in error handler */ |
136 | unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ | 136 | unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ |
137 | unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */ | ||
137 | unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ | 138 | unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ |
138 | unsigned select_no_atn:1; | 139 | unsigned select_no_atn:1; |
139 | unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ | 140 | unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ |
@@ -161,9 +162,29 @@ struct scsi_device { | |||
161 | 162 | ||
162 | struct execute_work ew; /* used to get process context on put */ | 163 | struct execute_work ew; /* used to get process context on put */ |
163 | 164 | ||
165 | struct scsi_dh_data *scsi_dh_data; | ||
164 | enum scsi_device_state sdev_state; | 166 | enum scsi_device_state sdev_state; |
165 | unsigned long sdev_data[0]; | 167 | unsigned long sdev_data[0]; |
166 | } __attribute__((aligned(sizeof(unsigned long)))); | 168 | } __attribute__((aligned(sizeof(unsigned long)))); |
169 | |||
170 | struct scsi_device_handler { | ||
171 | /* Used by the infrastructure */ | ||
172 | struct list_head list; /* list of scsi_device_handlers */ | ||
173 | struct notifier_block nb; | ||
174 | |||
175 | /* Filled by the hardware handler */ | ||
176 | struct module *module; | ||
177 | const char *name; | ||
178 | int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); | ||
179 | int (*activate)(struct scsi_device *); | ||
180 | int (*prep_fn)(struct scsi_device *, struct request *); | ||
181 | }; | ||
182 | |||
183 | struct scsi_dh_data { | ||
184 | struct scsi_device_handler *scsi_dh; | ||
185 | char buf[0]; | ||
186 | }; | ||
187 | |||
167 | #define to_scsi_device(d) \ | 188 | #define to_scsi_device(d) \ |
168 | container_of(d, struct scsi_device, sdev_gendev) | 189 | container_of(d, struct scsi_device, sdev_gendev) |
169 | #define class_to_sdev(d) \ | 190 | #define class_to_sdev(d) \ |
@@ -230,7 +251,9 @@ extern struct scsi_device *__scsi_add_device(struct Scsi_Host *, | |||
230 | uint, uint, uint, void *hostdata); | 251 | uint, uint, uint, void *hostdata); |
231 | extern int scsi_add_device(struct Scsi_Host *host, uint channel, | 252 | extern int scsi_add_device(struct Scsi_Host *host, uint channel, |
232 | uint target, uint lun); | 253 | uint target, uint lun); |
254 | extern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh); | ||
233 | extern void scsi_remove_device(struct scsi_device *); | 255 | extern void scsi_remove_device(struct scsi_device *); |
256 | extern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh); | ||
234 | 257 | ||
235 | extern int scsi_device_get(struct scsi_device *); | 258 | extern int scsi_device_get(struct scsi_device *); |
236 | extern void scsi_device_put(struct scsi_device *); | 259 | extern void scsi_device_put(struct scsi_device *); |
diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h new file mode 100644 index 000000000000..3ad2303d1a16 --- /dev/null +++ b/include/scsi/scsi_dh.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Header file for SCSI device handler infrastruture. | ||
3 | * | ||
4 | * Modified version of patches posted by Mike Christie <michaelc@cs.wisc.edu> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | * | ||
20 | * Copyright IBM Corporation, 2007 | ||
21 | * Authors: | ||
22 | * Chandra Seetharaman <sekharan@us.ibm.com> | ||
23 | * Mike Anderson <andmike@linux.vnet.ibm.com> | ||
24 | */ | ||
25 | |||
26 | #include <scsi/scsi_device.h> | ||
27 | |||
28 | enum { | ||
29 | SCSI_DH_OK = 0, | ||
30 | /* | ||
31 | * device errors | ||
32 | */ | ||
33 | SCSI_DH_DEV_FAILED, /* generic device error */ | ||
34 | SCSI_DH_DEV_TEMP_BUSY, | ||
35 | SCSI_DH_DEVICE_MAX, /* max device blkerr definition */ | ||
36 | |||
37 | /* | ||
38 | * transport errors | ||
39 | */ | ||
40 | SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1, | ||
41 | SCSI_DH_CONN_FAILURE, | ||
42 | SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */ | ||
43 | |||
44 | /* | ||
45 | * driver and generic errors | ||
46 | */ | ||
47 | SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */ | ||
48 | SCSI_DH_INVALID_IO, | ||
49 | SCSI_DH_RETRY, /* retry the req, but not immediately */ | ||
50 | SCSI_DH_IMM_RETRY, /* immediately retry the req */ | ||
51 | SCSI_DH_TIMED_OUT, | ||
52 | SCSI_DH_RES_TEMP_UNAVAIL, | ||
53 | SCSI_DH_DEV_OFFLINED, | ||
54 | SCSI_DH_NOSYS, | ||
55 | SCSI_DH_DRIVER_MAX, | ||
56 | }; | ||
57 | #if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE) | ||
58 | extern int scsi_dh_activate(struct request_queue *); | ||
59 | extern int scsi_dh_handler_exist(const char *); | ||
60 | #else | ||
61 | static inline int scsi_dh_activate(struct request_queue *req) | ||
62 | { | ||
63 | return 0; | ||
64 | } | ||
65 | static inline int scsi_dh_handler_exist(const char *name) | ||
66 | { | ||
67 | return 0; | ||
68 | } | ||
69 | #endif | ||
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index aab1eae2ec4c..f5444e033cc9 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h | |||
@@ -30,11 +30,11 @@ | |||
30 | 30 | ||
31 | struct scsi_transport_template; | 31 | struct scsi_transport_template; |
32 | struct iscsi_transport; | 32 | struct iscsi_transport; |
33 | struct iscsi_endpoint; | ||
33 | struct Scsi_Host; | 34 | struct Scsi_Host; |
34 | struct iscsi_cls_conn; | 35 | struct iscsi_cls_conn; |
35 | struct iscsi_conn; | 36 | struct iscsi_conn; |
36 | struct iscsi_cmd_task; | 37 | struct iscsi_task; |
37 | struct iscsi_mgmt_task; | ||
38 | struct sockaddr; | 38 | struct sockaddr; |
39 | 39 | ||
40 | /** | 40 | /** |
@@ -58,19 +58,22 @@ struct sockaddr; | |||
58 | * @stop_conn: suspend/recover/terminate connection | 58 | * @stop_conn: suspend/recover/terminate connection |
59 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. | 59 | * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text. |
60 | * @session_recovery_timedout: notify LLD a block during recovery timed out | 60 | * @session_recovery_timedout: notify LLD a block during recovery timed out |
61 | * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs. | 61 | * @init_task: Initialize a iscsi_task and any internal structs. |
62 | * Called from queuecommand with session lock held. | 62 | * When offloading the data path, this is called from |
63 | * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs. | 63 | * queuecommand with the session lock, or from the |
64 | * Called from iscsi_conn_send_generic with xmitmutex. | 64 | * iscsi_conn_send_pdu context with the session lock. |
65 | * @xmit_cmd_task: Requests LLD to transfer cmd task. Returns 0 or the | 65 | * When not offloading the data path, this is called |
66 | * from the scsi work queue without the session lock. | ||
67 | * @xmit_task Requests LLD to transfer cmd task. Returns 0 or the | ||
66 | * the number of bytes transferred on success, and -Exyz | 68 | * the number of bytes transferred on success, and -Exyz |
67 | * value on error. | 69 | * value on error. When offloading the data path, this |
68 | * @xmit_mgmt_task: Requests LLD to transfer mgmt task. Returns 0 or the | 70 | * is called from queuecommand with the session lock, or |
69 | * the number of bytes transferred on success, and -Exyz | 71 | * from the iscsi_conn_send_pdu context with the session |
70 | * value on error. | 72 | * lock. When not offloading the data path, this is called |
71 | * @cleanup_cmd_task: requests LLD to fail cmd task. Called with xmitmutex | 73 | * from the scsi work queue without the session lock. |
72 | * and session->lock after the connection has been | 74 | * @cleanup_task: requests LLD to fail task. Called with session lock |
73 | * suspended and terminated during recovery. If called | 75 | * and after the connection has been suspended and |
76 | * terminated during recovery. If called | ||
74 | * from abort task then connection is not suspended | 77 | * from abort task then connection is not suspended |
75 | * or terminated but sk_callback_lock is held | 78 | * or terminated but sk_callback_lock is held |
76 | * | 79 | * |
@@ -83,17 +86,9 @@ struct iscsi_transport { | |||
83 | /* LLD sets this to indicate what values it can export to sysfs */ | 86 | /* LLD sets this to indicate what values it can export to sysfs */ |
84 | uint64_t param_mask; | 87 | uint64_t param_mask; |
85 | uint64_t host_param_mask; | 88 | uint64_t host_param_mask; |
86 | struct scsi_host_template *host_template; | 89 | struct iscsi_cls_session *(*create_session) (struct iscsi_endpoint *ep, |
87 | /* LLD connection data size */ | 90 | uint16_t cmds_max, uint16_t qdepth, |
88 | int conndata_size; | 91 | uint32_t sn, uint32_t *hn); |
89 | /* LLD session data size */ | ||
90 | int sessiondata_size; | ||
91 | int max_lun; | ||
92 | unsigned int max_conn; | ||
93 | unsigned int max_cmd_len; | ||
94 | struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it, | ||
95 | struct scsi_transport_template *t, uint16_t, uint16_t, | ||
96 | uint32_t sn, uint32_t *hn); | ||
97 | void (*destroy_session) (struct iscsi_cls_session *session); | 92 | void (*destroy_session) (struct iscsi_cls_session *session); |
98 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, | 93 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, |
99 | uint32_t cid); | 94 | uint32_t cid); |
@@ -118,20 +113,15 @@ struct iscsi_transport { | |||
118 | char *data, uint32_t data_size); | 113 | char *data, uint32_t data_size); |
119 | void (*get_stats) (struct iscsi_cls_conn *conn, | 114 | void (*get_stats) (struct iscsi_cls_conn *conn, |
120 | struct iscsi_stats *stats); | 115 | struct iscsi_stats *stats); |
121 | int (*init_cmd_task) (struct iscsi_cmd_task *ctask); | 116 | int (*init_task) (struct iscsi_task *task); |
122 | void (*init_mgmt_task) (struct iscsi_conn *conn, | 117 | int (*xmit_task) (struct iscsi_task *task); |
123 | struct iscsi_mgmt_task *mtask); | 118 | void (*cleanup_task) (struct iscsi_conn *conn, |
124 | int (*xmit_cmd_task) (struct iscsi_conn *conn, | 119 | struct iscsi_task *task); |
125 | struct iscsi_cmd_task *ctask); | ||
126 | void (*cleanup_cmd_task) (struct iscsi_conn *conn, | ||
127 | struct iscsi_cmd_task *ctask); | ||
128 | int (*xmit_mgmt_task) (struct iscsi_conn *conn, | ||
129 | struct iscsi_mgmt_task *mtask); | ||
130 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); | 120 | void (*session_recovery_timedout) (struct iscsi_cls_session *session); |
131 | int (*ep_connect) (struct sockaddr *dst_addr, int non_blocking, | 121 | struct iscsi_endpoint *(*ep_connect) (struct sockaddr *dst_addr, |
132 | uint64_t *ep_handle); | 122 | int non_blocking); |
133 | int (*ep_poll) (uint64_t ep_handle, int timeout_ms); | 123 | int (*ep_poll) (struct iscsi_endpoint *ep, int timeout_ms); |
134 | void (*ep_disconnect) (uint64_t ep_handle); | 124 | void (*ep_disconnect) (struct iscsi_endpoint *ep); |
135 | int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type, | 125 | int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type, |
136 | uint32_t enable, struct sockaddr *dst_addr); | 126 | uint32_t enable, struct sockaddr *dst_addr); |
137 | }; | 127 | }; |
@@ -172,9 +162,10 @@ enum { | |||
172 | ISCSI_SESSION_FREE, | 162 | ISCSI_SESSION_FREE, |
173 | }; | 163 | }; |
174 | 164 | ||
165 | #define ISCSI_MAX_TARGET -1 | ||
166 | |||
175 | struct iscsi_cls_session { | 167 | struct iscsi_cls_session { |
176 | struct list_head sess_list; /* item in session_list */ | 168 | struct list_head sess_list; /* item in session_list */ |
177 | struct list_head host_list; | ||
178 | struct iscsi_transport *transport; | 169 | struct iscsi_transport *transport; |
179 | spinlock_t lock; | 170 | spinlock_t lock; |
180 | struct work_struct block_work; | 171 | struct work_struct block_work; |
@@ -186,7 +177,7 @@ struct iscsi_cls_session { | |||
186 | int recovery_tmo; | 177 | int recovery_tmo; |
187 | struct delayed_work recovery_work; | 178 | struct delayed_work recovery_work; |
188 | 179 | ||
189 | int target_id; | 180 | unsigned int target_id; |
190 | 181 | ||
191 | int state; | 182 | int state; |
192 | int sid; /* session id */ | 183 | int sid; /* session id */ |
@@ -203,14 +194,22 @@ struct iscsi_cls_session { | |||
203 | #define starget_to_session(_stgt) \ | 194 | #define starget_to_session(_stgt) \ |
204 | iscsi_dev_to_session(_stgt->dev.parent) | 195 | iscsi_dev_to_session(_stgt->dev.parent) |
205 | 196 | ||
206 | struct iscsi_host { | 197 | struct iscsi_cls_host { |
207 | struct list_head sessions; | ||
208 | atomic_t nr_scans; | 198 | atomic_t nr_scans; |
209 | struct mutex mutex; | 199 | struct mutex mutex; |
210 | struct workqueue_struct *scan_workq; | 200 | struct workqueue_struct *scan_workq; |
211 | char scan_workq_name[KOBJ_NAME_LEN]; | 201 | char scan_workq_name[KOBJ_NAME_LEN]; |
212 | }; | 202 | }; |
213 | 203 | ||
204 | extern void iscsi_host_for_each_session(struct Scsi_Host *shost, | ||
205 | void (*fn)(struct iscsi_cls_session *)); | ||
206 | |||
207 | struct iscsi_endpoint { | ||
208 | void *dd_data; /* LLD private data */ | ||
209 | struct device dev; | ||
210 | unsigned int id; | ||
211 | }; | ||
212 | |||
214 | /* | 213 | /* |
215 | * session and connection functions that can be used by HW iSCSI LLDs | 214 | * session and connection functions that can be used by HW iSCSI LLDs |
216 | */ | 215 | */ |
@@ -222,22 +221,26 @@ struct iscsi_host { | |||
222 | 221 | ||
223 | extern int iscsi_session_chkready(struct iscsi_cls_session *session); | 222 | extern int iscsi_session_chkready(struct iscsi_cls_session *session); |
224 | extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, | 223 | extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost, |
225 | struct iscsi_transport *transport); | 224 | struct iscsi_transport *transport, int dd_size); |
226 | extern int iscsi_add_session(struct iscsi_cls_session *session, | 225 | extern int iscsi_add_session(struct iscsi_cls_session *session, |
227 | unsigned int target_id); | 226 | unsigned int target_id); |
228 | extern int iscsi_session_event(struct iscsi_cls_session *session, | 227 | extern int iscsi_session_event(struct iscsi_cls_session *session, |
229 | enum iscsi_uevent_e event); | 228 | enum iscsi_uevent_e event); |
230 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, | 229 | extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, |
231 | struct iscsi_transport *t, | 230 | struct iscsi_transport *t, |
231 | int dd_size, | ||
232 | unsigned int target_id); | 232 | unsigned int target_id); |
233 | extern void iscsi_remove_session(struct iscsi_cls_session *session); | 233 | extern void iscsi_remove_session(struct iscsi_cls_session *session); |
234 | extern void iscsi_free_session(struct iscsi_cls_session *session); | 234 | extern void iscsi_free_session(struct iscsi_cls_session *session); |
235 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); | 235 | extern int iscsi_destroy_session(struct iscsi_cls_session *session); |
236 | extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, | 236 | extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, |
237 | uint32_t cid); | 237 | int dd_size, uint32_t cid); |
238 | extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); | 238 | extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); |
239 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); | 239 | extern void iscsi_unblock_session(struct iscsi_cls_session *session); |
240 | extern void iscsi_block_session(struct iscsi_cls_session *session); | 240 | extern void iscsi_block_session(struct iscsi_cls_session *session); |
241 | extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time); | 241 | extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time); |
242 | extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size); | ||
243 | extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep); | ||
244 | extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle); | ||
242 | 245 | ||
243 | #endif | 246 | #endif |
diff --git a/include/scsi/sd.h b/include/scsi/sd.h deleted file mode 100644 index 4f032d48cb6e..000000000000 --- a/include/scsi/sd.h +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | #ifndef _SCSI_DISK_H | ||
2 | #define _SCSI_DISK_H | ||
3 | |||
4 | /* | ||
5 | * More than enough for everybody ;) The huge number of majors | ||
6 | * is a leftover from 16bit dev_t days, we don't really need that | ||
7 | * much numberspace. | ||
8 | */ | ||
9 | #define SD_MAJORS 16 | ||
10 | |||
11 | /* | ||
12 | * This is limited by the naming scheme enforced in sd_probe, | ||
13 | * add another character to it if you really need more disks. | ||
14 | */ | ||
15 | #define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26) | ||
16 | |||
17 | /* | ||
18 | * Time out in seconds for disks and Magneto-opticals (which are slower). | ||
19 | */ | ||
20 | #define SD_TIMEOUT (30 * HZ) | ||
21 | #define SD_MOD_TIMEOUT (75 * HZ) | ||
22 | |||
23 | /* | ||
24 | * Number of allowed retries | ||
25 | */ | ||
26 | #define SD_MAX_RETRIES 5 | ||
27 | #define SD_PASSTHROUGH_RETRIES 1 | ||
28 | |||
29 | /* | ||
30 | * Size of the initial data buffer for mode and read capacity data | ||
31 | */ | ||
32 | #define SD_BUF_SIZE 512 | ||
33 | |||
34 | struct scsi_disk { | ||
35 | struct scsi_driver *driver; /* always &sd_template */ | ||
36 | struct scsi_device *device; | ||
37 | struct device dev; | ||
38 | struct gendisk *disk; | ||
39 | unsigned int openers; /* protected by BKL for now, yuck */ | ||
40 | sector_t capacity; /* size in 512-byte sectors */ | ||
41 | u32 index; | ||
42 | u8 media_present; | ||
43 | u8 write_prot; | ||
44 | unsigned previous_state : 1; | ||
45 | unsigned WCE : 1; /* state of disk WCE bit */ | ||
46 | unsigned RCD : 1; /* state of disk RCD bit, unused */ | ||
47 | unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ | ||
48 | }; | ||
49 | #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) | ||
50 | |||
51 | #define sd_printk(prefix, sdsk, fmt, a...) \ | ||
52 | (sdsk)->disk ? \ | ||
53 | sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \ | ||
54 | (sdsk)->disk->disk_name, ##a) : \ | ||
55 | sdev_printk(prefix, (sdsk)->device, fmt, ##a) | ||
56 | |||
57 | #endif /* _SCSI_DISK_H */ | ||
diff --git a/include/scsi/sg.h b/include/scsi/sg.h index 519c49a0fc11..934ae389671d 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h | |||
@@ -206,6 +206,7 @@ typedef struct sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ | |||
206 | #define SG_SCSI_RESET_DEVICE 1 | 206 | #define SG_SCSI_RESET_DEVICE 1 |
207 | #define SG_SCSI_RESET_BUS 2 | 207 | #define SG_SCSI_RESET_BUS 2 |
208 | #define SG_SCSI_RESET_HOST 3 | 208 | #define SG_SCSI_RESET_HOST 3 |
209 | #define SG_SCSI_RESET_TARGET 4 | ||
209 | 210 | ||
210 | /* synchronous SCSI command ioctl, (only in version 3 interface) */ | 211 | /* synchronous SCSI command ioctl, (only in version 3 interface) */ |
211 | #define SG_IO 0x2285 /* similar effect as write() followed by read() */ | 212 | #define SG_IO 0x2285 /* similar effect as write() followed by read() */ |