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 | 21 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 87 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 38 | ||||
-rw-r--r-- | include/scsi/scsi_dh.h | 80 | ||||
-rw-r--r-- | include/scsi/scsi_eh.h | 2 | ||||
-rw-r--r-- | include/scsi/scsi_host.h | 88 | ||||
-rw-r--r-- | include/scsi/scsi_transport_fc.h | 4 | ||||
-rw-r--r-- | include/scsi/scsi_transport_iscsi.h | 93 | ||||
-rw-r--r-- | include/scsi/sd.h | 57 | ||||
-rw-r--r-- | include/scsi/sg.h | 1 |
13 files changed, 467 insertions, 207 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..5c40cc537d4c 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 |
@@ -105,6 +106,7 @@ | |||
105 | #define VARIABLE_LENGTH_CMD 0x7f | 106 | #define VARIABLE_LENGTH_CMD 0x7f |
106 | #define REPORT_LUNS 0xa0 | 107 | #define REPORT_LUNS 0xa0 |
107 | #define MAINTENANCE_IN 0xa3 | 108 | #define MAINTENANCE_IN 0xa3 |
109 | #define MAINTENANCE_OUT 0xa4 | ||
108 | #define MOVE_MEDIUM 0xa5 | 110 | #define MOVE_MEDIUM 0xa5 |
109 | #define EXCHANGE_MEDIUM 0xa6 | 111 | #define EXCHANGE_MEDIUM 0xa6 |
110 | #define READ_12 0xa8 | 112 | #define READ_12 0xa8 |
@@ -124,6 +126,8 @@ | |||
124 | #define SAI_READ_CAPACITY_16 0x10 | 126 | #define SAI_READ_CAPACITY_16 0x10 |
125 | /* values for maintenance in */ | 127 | /* values for maintenance in */ |
126 | #define MI_REPORT_TARGET_PGS 0x0a | 128 | #define MI_REPORT_TARGET_PGS 0x0a |
129 | /* values for maintenance out */ | ||
130 | #define MO_SET_TARGET_PGS 0x0a | ||
127 | 131 | ||
128 | /* Values for T10/04-262r7 */ | 132 | /* Values for T10/04-262r7 */ |
129 | #define ATA_16 0x85 /* 16-byte pass-thru */ | 133 | #define ATA_16 0x85 /* 16-byte pass-thru */ |
@@ -400,6 +404,7 @@ struct scsi_lun { | |||
400 | #define SOFT_ERROR 0x2005 | 404 | #define SOFT_ERROR 0x2005 |
401 | #define ADD_TO_MLQUEUE 0x2006 | 405 | #define ADD_TO_MLQUEUE 0x2006 |
402 | #define TIMEOUT_ERROR 0x2007 | 406 | #define TIMEOUT_ERROR 0x2007 |
407 | #define SCSI_RETURN_NOT_HANDLED 0x2008 | ||
403 | 408 | ||
404 | /* | 409 | /* |
405 | * Midlevel queue return values. | 410 | * Midlevel queue return values. |
@@ -424,6 +429,22 @@ struct scsi_lun { | |||
424 | #define driver_byte(result) (((result) >> 24) & 0xff) | 429 | #define driver_byte(result) (((result) >> 24) & 0xff) |
425 | #define suggestion(result) (driver_byte(result) & SUGGEST_MASK) | 430 | #define suggestion(result) (driver_byte(result) & SUGGEST_MASK) |
426 | 431 | ||
432 | static inline void set_msg_byte(struct scsi_cmnd *cmd, char status) | ||
433 | { | ||
434 | cmd->result |= status << 8; | ||
435 | } | ||
436 | |||
437 | static inline void set_host_byte(struct scsi_cmnd *cmd, char status) | ||
438 | { | ||
439 | cmd->result |= status << 16; | ||
440 | } | ||
441 | |||
442 | static inline void set_driver_byte(struct scsi_cmnd *cmd, char status) | ||
443 | { | ||
444 | cmd->result |= status << 24; | ||
445 | } | ||
446 | |||
447 | |||
427 | #define sense_class(sense) (((sense) >> 4) & 0x7) | 448 | #define sense_class(sense) (((sense) >> 4) & 0x7) |
428 | #define sense_error(sense) ((sense) & 0xf) | 449 | #define sense_error(sense) ((sense) & 0xf) |
429 | #define sense_valid(sense) ((sense) & 0x80); | 450 | #define sense_valid(sense) ((sense) & 0x80); |
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 3e46dfae8194..f9f6e793575c 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; |
@@ -78,6 +77,9 @@ struct scsi_cmnd { | |||
78 | int allowed; | 77 | int allowed; |
79 | int timeout_per_command; | 78 | int timeout_per_command; |
80 | 79 | ||
80 | unsigned char prot_op; | ||
81 | unsigned char prot_type; | ||
82 | |||
81 | unsigned short cmd_len; | 83 | unsigned short cmd_len; |
82 | enum dma_data_direction sc_data_direction; | 84 | enum dma_data_direction sc_data_direction; |
83 | 85 | ||
@@ -88,6 +90,8 @@ struct scsi_cmnd { | |||
88 | 90 | ||
89 | /* These elements define the operation we ultimately want to perform */ | 91 | /* These elements define the operation we ultimately want to perform */ |
90 | struct scsi_data_buffer sdb; | 92 | struct scsi_data_buffer sdb; |
93 | struct scsi_data_buffer *prot_sdb; | ||
94 | |||
91 | unsigned underflow; /* Return error if less than | 95 | unsigned underflow; /* Return error if less than |
92 | this amount is transferred */ | 96 | this amount is transferred */ |
93 | 97 | ||
@@ -209,4 +213,85 @@ static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd, | |||
209 | buf, buflen); | 213 | buf, buflen); |
210 | } | 214 | } |
211 | 215 | ||
216 | /* | ||
217 | * The operations below are hints that tell the controller driver how | ||
218 | * to handle I/Os with DIF or similar types of protection information. | ||
219 | */ | ||
220 | enum scsi_prot_operations { | ||
221 | /* Normal I/O */ | ||
222 | SCSI_PROT_NORMAL = 0, | ||
223 | |||
224 | /* OS-HBA: Protected, HBA-Target: Unprotected */ | ||
225 | SCSI_PROT_READ_INSERT, | ||
226 | SCSI_PROT_WRITE_STRIP, | ||
227 | |||
228 | /* OS-HBA: Unprotected, HBA-Target: Protected */ | ||
229 | SCSI_PROT_READ_STRIP, | ||
230 | SCSI_PROT_WRITE_INSERT, | ||
231 | |||
232 | /* OS-HBA: Protected, HBA-Target: Protected */ | ||
233 | SCSI_PROT_READ_PASS, | ||
234 | SCSI_PROT_WRITE_PASS, | ||
235 | |||
236 | /* OS-HBA: Protected, HBA-Target: Protected, checksum conversion */ | ||
237 | SCSI_PROT_READ_CONVERT, | ||
238 | SCSI_PROT_WRITE_CONVERT, | ||
239 | }; | ||
240 | |||
241 | static inline void scsi_set_prot_op(struct scsi_cmnd *scmd, unsigned char op) | ||
242 | { | ||
243 | scmd->prot_op = op; | ||
244 | } | ||
245 | |||
246 | static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd) | ||
247 | { | ||
248 | return scmd->prot_op; | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * The controller usually does not know anything about the target it | ||
253 | * is communicating with. However, when DIX is enabled the controller | ||
254 | * must be know target type so it can verify the protection | ||
255 | * information passed along with the I/O. | ||
256 | */ | ||
257 | enum scsi_prot_target_type { | ||
258 | SCSI_PROT_DIF_TYPE0 = 0, | ||
259 | SCSI_PROT_DIF_TYPE1, | ||
260 | SCSI_PROT_DIF_TYPE2, | ||
261 | SCSI_PROT_DIF_TYPE3, | ||
262 | }; | ||
263 | |||
264 | static inline void scsi_set_prot_type(struct scsi_cmnd *scmd, unsigned char type) | ||
265 | { | ||
266 | scmd->prot_type = type; | ||
267 | } | ||
268 | |||
269 | static inline unsigned char scsi_get_prot_type(struct scsi_cmnd *scmd) | ||
270 | { | ||
271 | return scmd->prot_type; | ||
272 | } | ||
273 | |||
274 | static inline sector_t scsi_get_lba(struct scsi_cmnd *scmd) | ||
275 | { | ||
276 | return scmd->request->sector; | ||
277 | } | ||
278 | |||
279 | static inline unsigned scsi_prot_sg_count(struct scsi_cmnd *cmd) | ||
280 | { | ||
281 | return cmd->prot_sdb ? cmd->prot_sdb->table.nents : 0; | ||
282 | } | ||
283 | |||
284 | static inline struct scatterlist *scsi_prot_sglist(struct scsi_cmnd *cmd) | ||
285 | { | ||
286 | return cmd->prot_sdb ? cmd->prot_sdb->table.sgl : NULL; | ||
287 | } | ||
288 | |||
289 | static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd) | ||
290 | { | ||
291 | return cmd->prot_sdb; | ||
292 | } | ||
293 | |||
294 | #define scsi_for_each_prot_sg(cmd, sg, nseg, __i) \ | ||
295 | for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i) | ||
296 | |||
212 | #endif /* _SCSI_SCSI_CMND_H */ | 297 | #endif /* _SCSI_SCSI_CMND_H */ |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index f6a9fe0ef09c..291d56a19167 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -134,12 +134,14 @@ 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 */ |
140 | unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ | 141 | unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ |
141 | unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ | 142 | unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ |
142 | unsigned last_sector_bug:1; /* Always read last sector in a 1 sector read */ | 143 | unsigned last_sector_bug:1; /* do not use multisector accesses on |
144 | SD_LAST_BUGGY_SECTORS */ | ||
143 | 145 | ||
144 | DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ | 146 | DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ |
145 | struct list_head event_list; /* asserted events */ | 147 | struct list_head event_list; /* asserted events */ |
@@ -161,9 +163,36 @@ struct scsi_device { | |||
161 | 163 | ||
162 | struct execute_work ew; /* used to get process context on put */ | 164 | struct execute_work ew; /* used to get process context on put */ |
163 | 165 | ||
166 | struct scsi_dh_data *scsi_dh_data; | ||
164 | enum scsi_device_state sdev_state; | 167 | enum scsi_device_state sdev_state; |
165 | unsigned long sdev_data[0]; | 168 | unsigned long sdev_data[0]; |
166 | } __attribute__((aligned(sizeof(unsigned long)))); | 169 | } __attribute__((aligned(sizeof(unsigned long)))); |
170 | |||
171 | struct scsi_dh_devlist { | ||
172 | char *vendor; | ||
173 | char *model; | ||
174 | }; | ||
175 | |||
176 | struct scsi_device_handler { | ||
177 | /* Used by the infrastructure */ | ||
178 | struct list_head list; /* list of scsi_device_handlers */ | ||
179 | |||
180 | /* Filled by the hardware handler */ | ||
181 | struct module *module; | ||
182 | const char *name; | ||
183 | const struct scsi_dh_devlist *devlist; | ||
184 | int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); | ||
185 | int (*attach)(struct scsi_device *); | ||
186 | void (*detach)(struct scsi_device *); | ||
187 | int (*activate)(struct scsi_device *); | ||
188 | int (*prep_fn)(struct scsi_device *, struct request *); | ||
189 | }; | ||
190 | |||
191 | struct scsi_dh_data { | ||
192 | struct scsi_device_handler *scsi_dh; | ||
193 | char buf[0]; | ||
194 | }; | ||
195 | |||
167 | #define to_scsi_device(d) \ | 196 | #define to_scsi_device(d) \ |
168 | container_of(d, struct scsi_device, sdev_gendev) | 197 | container_of(d, struct scsi_device, sdev_gendev) |
169 | #define class_to_sdev(d) \ | 198 | #define class_to_sdev(d) \ |
@@ -230,7 +259,9 @@ extern struct scsi_device *__scsi_add_device(struct Scsi_Host *, | |||
230 | uint, uint, uint, void *hostdata); | 259 | uint, uint, uint, void *hostdata); |
231 | extern int scsi_add_device(struct Scsi_Host *host, uint channel, | 260 | extern int scsi_add_device(struct Scsi_Host *host, uint channel, |
232 | uint target, uint lun); | 261 | uint target, uint lun); |
262 | extern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh); | ||
233 | extern void scsi_remove_device(struct scsi_device *); | 263 | extern void scsi_remove_device(struct scsi_device *); |
264 | extern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh); | ||
234 | 265 | ||
235 | extern int scsi_device_get(struct scsi_device *); | 266 | extern int scsi_device_get(struct scsi_device *); |
236 | extern void scsi_device_put(struct scsi_device *); | 267 | extern void scsi_device_put(struct scsi_device *); |
@@ -393,6 +424,11 @@ static inline int scsi_device_enclosure(struct scsi_device *sdev) | |||
393 | return sdev->inquiry[6] & (1<<6); | 424 | return sdev->inquiry[6] & (1<<6); |
394 | } | 425 | } |
395 | 426 | ||
427 | static inline int scsi_device_protection(struct scsi_device *sdev) | ||
428 | { | ||
429 | return sdev->inquiry[5] & (1<<0); | ||
430 | } | ||
431 | |||
396 | #define MODULE_ALIAS_SCSI_DEVICE(type) \ | 432 | #define MODULE_ALIAS_SCSI_DEVICE(type) \ |
397 | MODULE_ALIAS("scsi:t-" __stringify(type) "*") | 433 | MODULE_ALIAS("scsi:t-" __stringify(type) "*") |
398 | #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" | 434 | #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" |
diff --git a/include/scsi/scsi_dh.h b/include/scsi/scsi_dh.h new file mode 100644 index 000000000000..33efce20c26c --- /dev/null +++ b/include/scsi/scsi_dh.h | |||
@@ -0,0 +1,80 @@ | |||
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_DEV_UNSUPP, /* device handler not supported */ | ||
36 | SCSI_DH_DEVICE_MAX, /* max device blkerr definition */ | ||
37 | |||
38 | /* | ||
39 | * transport errors | ||
40 | */ | ||
41 | SCSI_DH_NOTCONN = SCSI_DH_DEVICE_MAX + 1, | ||
42 | SCSI_DH_CONN_FAILURE, | ||
43 | SCSI_DH_TRANSPORT_MAX, /* max transport blkerr definition */ | ||
44 | |||
45 | /* | ||
46 | * driver and generic errors | ||
47 | */ | ||
48 | SCSI_DH_IO = SCSI_DH_TRANSPORT_MAX + 1, /* generic error */ | ||
49 | SCSI_DH_INVALID_IO, | ||
50 | SCSI_DH_RETRY, /* retry the req, but not immediately */ | ||
51 | SCSI_DH_IMM_RETRY, /* immediately retry the req */ | ||
52 | SCSI_DH_TIMED_OUT, | ||
53 | SCSI_DH_RES_TEMP_UNAVAIL, | ||
54 | SCSI_DH_DEV_OFFLINED, | ||
55 | SCSI_DH_NOSYS, | ||
56 | SCSI_DH_DRIVER_MAX, | ||
57 | }; | ||
58 | #if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE) | ||
59 | extern int scsi_dh_activate(struct request_queue *); | ||
60 | extern int scsi_dh_handler_exist(const char *); | ||
61 | extern int scsi_dh_attach(struct request_queue *, const char *); | ||
62 | extern void scsi_dh_detach(struct request_queue *); | ||
63 | #else | ||
64 | static inline int scsi_dh_activate(struct request_queue *req) | ||
65 | { | ||
66 | return 0; | ||
67 | } | ||
68 | static inline int scsi_dh_handler_exist(const char *name) | ||
69 | { | ||
70 | return 0; | ||
71 | } | ||
72 | static inline int scsi_dh_attach(struct request_queue *req, const char *name) | ||
73 | { | ||
74 | return SCSI_DH_NOSYS; | ||
75 | } | ||
76 | static inline void scsi_dh_detach(struct request_queue *q) | ||
77 | { | ||
78 | return; | ||
79 | } | ||
80 | #endif | ||
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 2a9add21267d..06a8790893ef 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h | |||
@@ -74,7 +74,9 @@ struct scsi_eh_save { | |||
74 | /* saved state */ | 74 | /* saved state */ |
75 | int result; | 75 | int result; |
76 | enum dma_data_direction data_direction; | 76 | enum dma_data_direction data_direction; |
77 | unsigned underflow; | ||
77 | unsigned char cmd_len; | 78 | unsigned char cmd_len; |
79 | unsigned char prot_op; | ||
78 | unsigned char *cmnd; | 80 | unsigned char *cmnd; |
79 | struct scsi_data_buffer sdb; | 81 | struct scsi_data_buffer sdb; |
80 | struct request *next_rq; | 82 | struct request *next_rq; |
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 1834fdfe82a7..44a55d1bf530 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
@@ -547,7 +547,7 @@ struct Scsi_Host { | |||
547 | unsigned int host_failed; /* commands that failed. */ | 547 | unsigned int host_failed; /* commands that failed. */ |
548 | unsigned int host_eh_scheduled; /* EH scheduled without command */ | 548 | unsigned int host_eh_scheduled; /* EH scheduled without command */ |
549 | 549 | ||
550 | unsigned short host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */ | 550 | unsigned int host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */ |
551 | int resetting; /* if set, it means that last_reset is a valid value */ | 551 | int resetting; /* if set, it means that last_reset is a valid value */ |
552 | unsigned long last_reset; | 552 | unsigned long last_reset; |
553 | 553 | ||
@@ -623,7 +623,7 @@ struct Scsi_Host { | |||
623 | /* | 623 | /* |
624 | * Optional work queue to be utilized by the transport | 624 | * Optional work queue to be utilized by the transport |
625 | */ | 625 | */ |
626 | char work_q_name[KOBJ_NAME_LEN]; | 626 | char work_q_name[20]; |
627 | struct workqueue_struct *work_q; | 627 | struct workqueue_struct *work_q; |
628 | 628 | ||
629 | /* | 629 | /* |
@@ -636,6 +636,10 @@ struct Scsi_Host { | |||
636 | */ | 636 | */ |
637 | unsigned int max_host_blocked; | 637 | unsigned int max_host_blocked; |
638 | 638 | ||
639 | /* Protection Information */ | ||
640 | unsigned int prot_capabilities; | ||
641 | unsigned char prot_guard_type; | ||
642 | |||
639 | /* | 643 | /* |
640 | * q used for scsi_tgt msgs, async events or any other requests that | 644 | * q used for scsi_tgt msgs, async events or any other requests that |
641 | * need to be processed in userspace | 645 | * need to be processed in userspace |
@@ -756,6 +760,86 @@ extern struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, | |||
756 | extern void scsi_free_host_dev(struct scsi_device *); | 760 | extern void scsi_free_host_dev(struct scsi_device *); |
757 | extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *); | 761 | extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *); |
758 | 762 | ||
763 | /* | ||
764 | * DIF defines the exchange of protection information between | ||
765 | * initiator and SBC block device. | ||
766 | * | ||
767 | * DIX defines the exchange of protection information between OS and | ||
768 | * initiator. | ||
769 | */ | ||
770 | enum scsi_host_prot_capabilities { | ||
771 | SHOST_DIF_TYPE1_PROTECTION = 1 << 0, /* T10 DIF Type 1 */ | ||
772 | SHOST_DIF_TYPE2_PROTECTION = 1 << 1, /* T10 DIF Type 2 */ | ||
773 | SHOST_DIF_TYPE3_PROTECTION = 1 << 2, /* T10 DIF Type 3 */ | ||
774 | |||
775 | SHOST_DIX_TYPE0_PROTECTION = 1 << 3, /* DIX between OS and HBA only */ | ||
776 | SHOST_DIX_TYPE1_PROTECTION = 1 << 4, /* DIX with DIF Type 1 */ | ||
777 | SHOST_DIX_TYPE2_PROTECTION = 1 << 5, /* DIX with DIF Type 2 */ | ||
778 | SHOST_DIX_TYPE3_PROTECTION = 1 << 6, /* DIX with DIF Type 3 */ | ||
779 | }; | ||
780 | |||
781 | /* | ||
782 | * SCSI hosts which support the Data Integrity Extensions must | ||
783 | * indicate their capabilities by setting the prot_capabilities using | ||
784 | * this call. | ||
785 | */ | ||
786 | static inline void scsi_host_set_prot(struct Scsi_Host *shost, unsigned int mask) | ||
787 | { | ||
788 | shost->prot_capabilities = mask; | ||
789 | } | ||
790 | |||
791 | static inline unsigned int scsi_host_get_prot(struct Scsi_Host *shost) | ||
792 | { | ||
793 | return shost->prot_capabilities; | ||
794 | } | ||
795 | |||
796 | static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type) | ||
797 | { | ||
798 | switch (target_type) { | ||
799 | case 1: return shost->prot_capabilities & SHOST_DIF_TYPE1_PROTECTION; | ||
800 | case 2: return shost->prot_capabilities & SHOST_DIF_TYPE2_PROTECTION; | ||
801 | case 3: return shost->prot_capabilities & SHOST_DIF_TYPE3_PROTECTION; | ||
802 | } | ||
803 | |||
804 | return 0; | ||
805 | } | ||
806 | |||
807 | static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsigned int target_type) | ||
808 | { | ||
809 | switch (target_type) { | ||
810 | case 0: return shost->prot_capabilities & SHOST_DIX_TYPE0_PROTECTION; | ||
811 | case 1: return shost->prot_capabilities & SHOST_DIX_TYPE1_PROTECTION; | ||
812 | case 2: return shost->prot_capabilities & SHOST_DIX_TYPE2_PROTECTION; | ||
813 | case 3: return shost->prot_capabilities & SHOST_DIX_TYPE3_PROTECTION; | ||
814 | } | ||
815 | |||
816 | return 0; | ||
817 | } | ||
818 | |||
819 | /* | ||
820 | * All DIX-capable initiators must support the T10-mandated CRC | ||
821 | * checksum. Controllers can optionally implement the IP checksum | ||
822 | * scheme which has much lower impact on system performance. Note | ||
823 | * that the main rationale for the checksum is to match integrity | ||
824 | * metadata with data. Detecting bit errors are a job for ECC memory | ||
825 | * and buses. | ||
826 | */ | ||
827 | |||
828 | enum scsi_host_guard_type { | ||
829 | SHOST_DIX_GUARD_CRC = 1 << 0, | ||
830 | SHOST_DIX_GUARD_IP = 1 << 1, | ||
831 | }; | ||
832 | |||
833 | static inline void scsi_host_set_guard(struct Scsi_Host *shost, unsigned char type) | ||
834 | { | ||
835 | shost->prot_guard_type = type; | ||
836 | } | ||
837 | |||
838 | static inline unsigned char scsi_host_get_guard(struct Scsi_Host *shost) | ||
839 | { | ||
840 | return shost->prot_guard_type; | ||
841 | } | ||
842 | |||
759 | /* legacy interfaces */ | 843 | /* legacy interfaces */ |
760 | extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int); | 844 | extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int); |
761 | extern void scsi_unregister(struct Scsi_Host *); | 845 | extern void scsi_unregister(struct Scsi_Host *); |
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 06f72bab9df0..878373c32ef7 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h | |||
@@ -489,9 +489,9 @@ struct fc_host_attrs { | |||
489 | u16 npiv_vports_inuse; | 489 | u16 npiv_vports_inuse; |
490 | 490 | ||
491 | /* work queues for rport state manipulation */ | 491 | /* work queues for rport state manipulation */ |
492 | char work_q_name[KOBJ_NAME_LEN]; | 492 | char work_q_name[20]; |
493 | struct workqueue_struct *work_q; | 493 | struct workqueue_struct *work_q; |
494 | char devloss_work_q_name[KOBJ_NAME_LEN]; | 494 | char devloss_work_q_name[20]; |
495 | struct workqueue_struct *devloss_work_q; | 495 | struct workqueue_struct *devloss_work_q; |
496 | }; | 496 | }; |
497 | 497 | ||
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index aab1eae2ec4c..8b6c91df4c7a 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,12 +194,20 @@ 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[20]; |
202 | }; | ||
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; | ||
212 | }; | 211 | }; |
213 | 212 | ||
214 | /* | 213 | /* |
@@ -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() */ |