diff options
Diffstat (limited to 'include/scsi/libiscsi.h')
-rw-r--r-- | include/scsi/libiscsi.h | 82 |
1 files changed, 65 insertions, 17 deletions
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index b4b31132618b..889f51fabab9 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h | |||
@@ -57,11 +57,14 @@ struct iscsi_nopin; | |||
57 | #define ISCSI_MAX_CMD_PER_LUN 128 | 57 | #define ISCSI_MAX_CMD_PER_LUN 128 |
58 | 58 | ||
59 | /* Task Mgmt states */ | 59 | /* Task Mgmt states */ |
60 | #define TMABORT_INITIAL 0x0 | 60 | enum { |
61 | #define TMABORT_SUCCESS 0x1 | 61 | TMF_INITIAL, |
62 | #define TMABORT_FAILED 0x2 | 62 | TMF_QUEUED, |
63 | #define TMABORT_TIMEDOUT 0x3 | 63 | TMF_SUCCESS, |
64 | #define TMABORT_NOT_FOUND 0x4 | 64 | TMF_FAILED, |
65 | TMF_TIMEDOUT, | ||
66 | TMF_NOT_FOUND, | ||
67 | }; | ||
65 | 68 | ||
66 | /* Connection suspend "bit" */ | 69 | /* Connection suspend "bit" */ |
67 | #define ISCSI_SUSPEND_BIT 1 | 70 | #define ISCSI_SUSPEND_BIT 1 |
@@ -74,6 +77,13 @@ struct iscsi_nopin; | |||
74 | 77 | ||
75 | #define ISCSI_ADDRESS_BUF_LEN 64 | 78 | #define ISCSI_ADDRESS_BUF_LEN 64 |
76 | 79 | ||
80 | enum { | ||
81 | /* this is the maximum possible storage for AHSs */ | ||
82 | ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) + | ||
83 | sizeof(struct iscsi_rlength_ahdr), | ||
84 | ISCSI_DIGEST_SIZE = sizeof(__u32), | ||
85 | }; | ||
86 | |||
77 | struct iscsi_mgmt_task { | 87 | struct iscsi_mgmt_task { |
78 | /* | 88 | /* |
79 | * Becuae LLDs allocate their hdr differently, this is a pointer to | 89 | * Becuae LLDs allocate their hdr differently, this is a pointer to |
@@ -91,15 +101,17 @@ enum { | |||
91 | ISCSI_TASK_COMPLETED, | 101 | ISCSI_TASK_COMPLETED, |
92 | ISCSI_TASK_PENDING, | 102 | ISCSI_TASK_PENDING, |
93 | ISCSI_TASK_RUNNING, | 103 | ISCSI_TASK_RUNNING, |
94 | ISCSI_TASK_ABORTING, | ||
95 | }; | 104 | }; |
96 | 105 | ||
97 | struct iscsi_cmd_task { | 106 | struct iscsi_cmd_task { |
98 | /* | 107 | /* |
99 | * Becuae LLDs allocate their hdr differently, this is a pointer to | 108 | * Because LLDs allocate their hdr differently, this is a pointer |
100 | * that storage. It must be setup at session creation time. | 109 | * and length to that storage. It must be setup at session |
110 | * creation time. | ||
101 | */ | 111 | */ |
102 | struct iscsi_cmd *hdr; | 112 | struct iscsi_cmd *hdr; |
113 | unsigned short hdr_max; | ||
114 | unsigned short hdr_len; /* accumulated size of hdr used */ | ||
103 | int itt; /* this ITT */ | 115 | int itt; /* this ITT */ |
104 | 116 | ||
105 | uint32_t unsol_datasn; | 117 | uint32_t unsol_datasn; |
@@ -110,7 +122,6 @@ struct iscsi_cmd_task { | |||
110 | unsigned data_count; /* remaining Data-Out */ | 122 | unsigned data_count; /* remaining Data-Out */ |
111 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ | 123 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ |
112 | struct iscsi_conn *conn; /* used connection */ | 124 | struct iscsi_conn *conn; /* used connection */ |
113 | struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */ | ||
114 | 125 | ||
115 | /* state set/tested under session->lock */ | 126 | /* state set/tested under session->lock */ |
116 | int state; | 127 | int state; |
@@ -119,6 +130,11 @@ struct iscsi_cmd_task { | |||
119 | void *dd_data; /* driver/transport data */ | 130 | void *dd_data; /* driver/transport data */ |
120 | }; | 131 | }; |
121 | 132 | ||
133 | static inline void* iscsi_next_hdr(struct iscsi_cmd_task *ctask) | ||
134 | { | ||
135 | return (void*)ctask->hdr + ctask->hdr_len; | ||
136 | } | ||
137 | |||
122 | struct iscsi_conn { | 138 | struct iscsi_conn { |
123 | struct iscsi_cls_conn *cls_conn; /* ptr to class connection */ | 139 | struct iscsi_cls_conn *cls_conn; /* ptr to class connection */ |
124 | void *dd_data; /* iscsi_transport data */ | 140 | void *dd_data; /* iscsi_transport data */ |
@@ -132,6 +148,12 @@ struct iscsi_conn { | |||
132 | * conn_stop() flag: stop to recover, stop to terminate | 148 | * conn_stop() flag: stop to recover, stop to terminate |
133 | */ | 149 | */ |
134 | int stop_stage; | 150 | int stop_stage; |
151 | struct timer_list transport_timer; | ||
152 | unsigned long last_recv; | ||
153 | unsigned long last_ping; | ||
154 | int ping_timeout; | ||
155 | int recv_timeout; | ||
156 | struct iscsi_mgmt_task *ping_mtask; | ||
135 | 157 | ||
136 | /* iSCSI connection-wide sequencing */ | 158 | /* iSCSI connection-wide sequencing */ |
137 | uint32_t exp_statsn; | 159 | uint32_t exp_statsn; |
@@ -152,10 +174,11 @@ struct iscsi_conn { | |||
152 | struct iscsi_cmd_task *ctask; /* xmit ctask in progress */ | 174 | struct iscsi_cmd_task *ctask; /* xmit ctask in progress */ |
153 | 175 | ||
154 | /* xmit */ | 176 | /* xmit */ |
155 | struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */ | 177 | struct list_head mgmtqueue; /* mgmt (control) xmit queue */ |
156 | struct list_head mgmt_run_list; /* list of control tasks */ | 178 | struct list_head mgmt_run_list; /* list of control tasks */ |
157 | struct list_head xmitqueue; /* data-path cmd queue */ | 179 | struct list_head xmitqueue; /* data-path cmd queue */ |
158 | struct list_head run_list; /* list of cmds in progress */ | 180 | struct list_head run_list; /* list of cmds in progress */ |
181 | struct list_head requeue; /* tasks needing another run */ | ||
159 | struct work_struct xmitwork; /* per-conn. xmit workqueue */ | 182 | struct work_struct xmitwork; /* per-conn. xmit workqueue */ |
160 | unsigned long suspend_tx; /* suspend Tx */ | 183 | unsigned long suspend_tx; /* suspend Tx */ |
161 | unsigned long suspend_rx; /* suspend Rx */ | 184 | unsigned long suspend_rx; /* suspend Rx */ |
@@ -163,8 +186,8 @@ struct iscsi_conn { | |||
163 | /* abort */ | 186 | /* abort */ |
164 | wait_queue_head_t ehwait; /* used in eh_abort() */ | 187 | wait_queue_head_t ehwait; /* used in eh_abort() */ |
165 | struct iscsi_tm tmhdr; | 188 | struct iscsi_tm tmhdr; |
166 | struct timer_list tmabort_timer; | 189 | struct timer_list tmf_timer; |
167 | int tmabort_state; /* see TMABORT_INITIAL, etc.*/ | 190 | int tmf_state; /* see TMF_INITIAL, etc.*/ |
168 | 191 | ||
169 | /* negotiated params */ | 192 | /* negotiated params */ |
170 | unsigned max_recv_dlength; /* initiator_max_recv_dsl*/ | 193 | unsigned max_recv_dlength; /* initiator_max_recv_dsl*/ |
@@ -198,7 +221,7 @@ struct iscsi_conn { | |||
198 | uint32_t eh_abort_cnt; | 221 | uint32_t eh_abort_cnt; |
199 | }; | 222 | }; |
200 | 223 | ||
201 | struct iscsi_queue { | 224 | struct iscsi_pool { |
202 | struct kfifo *queue; /* FIFO Queue */ | 225 | struct kfifo *queue; /* FIFO Queue */ |
203 | void **pool; /* Pool of elements */ | 226 | void **pool; /* Pool of elements */ |
204 | int max; /* Max number of elements */ | 227 | int max; /* Max number of elements */ |
@@ -221,6 +244,8 @@ struct iscsi_session { | |||
221 | uint32_t queued_cmdsn; | 244 | uint32_t queued_cmdsn; |
222 | 245 | ||
223 | /* configuration */ | 246 | /* configuration */ |
247 | int abort_timeout; | ||
248 | int lu_reset_timeout; | ||
224 | int initial_r2t_en; | 249 | int initial_r2t_en; |
225 | unsigned max_r2t; | 250 | unsigned max_r2t; |
226 | int imm_data_en; | 251 | int imm_data_en; |
@@ -231,6 +256,7 @@ struct iscsi_session { | |||
231 | int pdu_inorder_en; | 256 | int pdu_inorder_en; |
232 | int dataseq_inorder_en; | 257 | int dataseq_inorder_en; |
233 | int erl; | 258 | int erl; |
259 | int fast_abort; | ||
234 | int tpgt; | 260 | int tpgt; |
235 | char *username; | 261 | char *username; |
236 | char *username_in; | 262 | char *username_in; |
@@ -256,10 +282,10 @@ struct iscsi_session { | |||
256 | 282 | ||
257 | int cmds_max; /* size of cmds array */ | 283 | int cmds_max; /* size of cmds array */ |
258 | struct iscsi_cmd_task **cmds; /* Original Cmds arr */ | 284 | struct iscsi_cmd_task **cmds; /* Original Cmds arr */ |
259 | struct iscsi_queue cmdpool; /* PDU's pool */ | 285 | struct iscsi_pool cmdpool; /* PDU's pool */ |
260 | int mgmtpool_max; /* size of mgmt array */ | 286 | int mgmtpool_max; /* size of mgmt array */ |
261 | struct iscsi_mgmt_task **mgmt_cmds; /* Original mgmt arr */ | 287 | struct iscsi_mgmt_task **mgmt_cmds; /* Original mgmt arr */ |
262 | struct iscsi_queue mgmtpool; /* Mgmt PDU's pool */ | 288 | struct iscsi_pool mgmtpool; /* Mgmt PDU's pool */ |
263 | }; | 289 | }; |
264 | 290 | ||
265 | /* | 291 | /* |
@@ -268,6 +294,7 @@ struct iscsi_session { | |||
268 | extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth); | 294 | extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth); |
269 | extern int iscsi_eh_abort(struct scsi_cmnd *sc); | 295 | extern int iscsi_eh_abort(struct scsi_cmnd *sc); |
270 | extern int iscsi_eh_host_reset(struct scsi_cmnd *sc); | 296 | extern int iscsi_eh_host_reset(struct scsi_cmnd *sc); |
297 | extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); | ||
271 | extern int iscsi_queuecommand(struct scsi_cmnd *sc, | 298 | extern int iscsi_queuecommand(struct scsi_cmnd *sc, |
272 | void (*done)(struct scsi_cmnd *)); | 299 | void (*done)(struct scsi_cmnd *)); |
273 | 300 | ||
@@ -326,11 +353,32 @@ extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *, | |||
326 | char *, int); | 353 | char *, int); |
327 | extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *, | 354 | extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *, |
328 | uint32_t *); | 355 | uint32_t *); |
356 | extern void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask); | ||
357 | extern void iscsi_free_mgmt_task(struct iscsi_conn *conn, | ||
358 | struct iscsi_mgmt_task *mtask); | ||
329 | 359 | ||
330 | /* | 360 | /* |
331 | * generic helpers | 361 | * generic helpers |
332 | */ | 362 | */ |
333 | extern void iscsi_pool_free(struct iscsi_queue *, void **); | 363 | extern void iscsi_pool_free(struct iscsi_pool *); |
334 | extern int iscsi_pool_init(struct iscsi_queue *, int, void ***, int); | 364 | extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int); |
365 | |||
366 | /* | ||
367 | * inline functions to deal with padding. | ||
368 | */ | ||
369 | static inline unsigned int | ||
370 | iscsi_padded(unsigned int len) | ||
371 | { | ||
372 | return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1); | ||
373 | } | ||
374 | |||
375 | static inline unsigned int | ||
376 | iscsi_padding(unsigned int len) | ||
377 | { | ||
378 | len &= (ISCSI_PAD_LEN - 1); | ||
379 | if (len) | ||
380 | len = ISCSI_PAD_LEN - len; | ||
381 | return len; | ||
382 | } | ||
335 | 383 | ||
336 | #endif | 384 | #endif |