Commit | Line | Data |
---|---|---|
39e84790 AA |
1 | /* |
2 | * RFC 3720 (iSCSI) protocol data types | |
3 | * | |
4 | * Copyright (C) 2005 Dmitry Yusupov | |
5 | * Copyright (C) 2005 Alex Aizman | |
6 | * maintained by open-iscsi@googlegroups.com | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published | |
10 | * by the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * See the file COPYING included with this distribution for more details. | |
19 | */ | |
20 | ||
21 | #ifndef ISCSI_PROTO_H | |
22 | #define ISCSI_PROTO_H | |
23 | ||
39e84790 AA |
24 | #define ISCSI_DRAFT20_VERSION 0x00 |
25 | ||
26 | /* default iSCSI listen port for incoming connections */ | |
27 | #define ISCSI_LISTEN_PORT 3260 | |
28 | ||
29 | /* Padding word length */ | |
30 | #define PAD_WORD_LEN 4 | |
31 | ||
32 | /* | |
33 | * useful common(control and data pathes) macro | |
34 | */ | |
35 | #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) | |
36 | #define hton24(p, v) { \ | |
37 | p[0] = (((v) >> 16) & 0xFF); \ | |
38 | p[1] = (((v) >> 8) & 0xFF); \ | |
39 | p[2] = ((v) & 0xFF); \ | |
40 | } | |
41 | #define zero_data(p) {p[0]=0;p[1]=0;p[2]=0;} | |
42 | ||
b4377356 AV |
43 | /* initiator tags; opaque for target */ |
44 | typedef uint32_t __bitwise__ itt_t; | |
45 | /* below makes sense only for initiator that created this tag */ | |
46 | #define build_itt(itt, id, age) ((__force itt_t)\ | |
47 | ((itt) | ((id) << ISCSI_CID_SHIFT) | ((age) << ISCSI_AGE_SHIFT))) | |
48 | #define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK) | |
49 | #define RESERVED_ITT ((__force itt_t)0xffffffff) | |
50 | ||
39e84790 AA |
51 | /* |
52 | * iSCSI Template Message Header | |
53 | */ | |
54 | struct iscsi_hdr { | |
55 | uint8_t opcode; | |
56 | uint8_t flags; /* Final bit */ | |
57 | uint8_t rsvd2[2]; | |
58 | uint8_t hlength; /* AHSs total length */ | |
59 | uint8_t dlength[3]; /* Data length */ | |
60 | uint8_t lun[8]; | |
b4377356 | 61 | itt_t itt; /* Initiator Task Tag, opaque for target */ |
39e84790 AA |
62 | __be32 ttt; /* Target Task Tag */ |
63 | __be32 statsn; | |
64 | __be32 exp_statsn; | |
baebc497 MC |
65 | __be32 max_statsn; |
66 | uint8_t other[12]; | |
39e84790 AA |
67 | }; |
68 | ||
69 | /************************* RFC 3720 Begin *****************************/ | |
70 | ||
71 | #define ISCSI_RESERVED_TAG 0xffffffff | |
72 | ||
73 | /* Opcode encoding bits */ | |
74 | #define ISCSI_OP_RETRY 0x80 | |
75 | #define ISCSI_OP_IMMEDIATE 0x40 | |
76 | #define ISCSI_OPCODE_MASK 0x3F | |
77 | ||
78 | /* Initiator Opcode values */ | |
79 | #define ISCSI_OP_NOOP_OUT 0x00 | |
80 | #define ISCSI_OP_SCSI_CMD 0x01 | |
81 | #define ISCSI_OP_SCSI_TMFUNC 0x02 | |
82 | #define ISCSI_OP_LOGIN 0x03 | |
83 | #define ISCSI_OP_TEXT 0x04 | |
84 | #define ISCSI_OP_SCSI_DATA_OUT 0x05 | |
85 | #define ISCSI_OP_LOGOUT 0x06 | |
86 | #define ISCSI_OP_SNACK 0x10 | |
87 | ||
baebc497 MC |
88 | #define ISCSI_OP_VENDOR1_CMD 0x1c |
89 | #define ISCSI_OP_VENDOR2_CMD 0x1d | |
90 | #define ISCSI_OP_VENDOR3_CMD 0x1e | |
91 | #define ISCSI_OP_VENDOR4_CMD 0x1f | |
92 | ||
39e84790 AA |
93 | /* Target Opcode values */ |
94 | #define ISCSI_OP_NOOP_IN 0x20 | |
95 | #define ISCSI_OP_SCSI_CMD_RSP 0x21 | |
96 | #define ISCSI_OP_SCSI_TMFUNC_RSP 0x22 | |
97 | #define ISCSI_OP_LOGIN_RSP 0x23 | |
98 | #define ISCSI_OP_TEXT_RSP 0x24 | |
99 | #define ISCSI_OP_SCSI_DATA_IN 0x25 | |
100 | #define ISCSI_OP_LOGOUT_RSP 0x26 | |
101 | #define ISCSI_OP_R2T 0x31 | |
102 | #define ISCSI_OP_ASYNC_EVENT 0x32 | |
103 | #define ISCSI_OP_REJECT 0x3f | |
104 | ||
baebc497 MC |
105 | struct iscsi_ahs_hdr { |
106 | __be16 ahslength; | |
107 | uint8_t ahstype; | |
108 | uint8_t ahspec[5]; | |
109 | }; | |
110 | ||
111 | #define ISCSI_AHSTYPE_CDB 1 | |
112 | #define ISCSI_AHSTYPE_RLENGTH 2 | |
113 | ||
39e84790 AA |
114 | /* iSCSI PDU Header */ |
115 | struct iscsi_cmd { | |
116 | uint8_t opcode; | |
117 | uint8_t flags; | |
baebc497 | 118 | __be16 rsvd2; |
39e84790 AA |
119 | uint8_t hlength; |
120 | uint8_t dlength[3]; | |
121 | uint8_t lun[8]; | |
b4377356 | 122 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
123 | __be32 data_length; |
124 | __be32 cmdsn; | |
125 | __be32 exp_statsn; | |
126 | uint8_t cdb[16]; /* SCSI Command Block */ | |
127 | /* Additional Data (Command Dependent) */ | |
128 | }; | |
129 | ||
130 | /* Command PDU flags */ | |
131 | #define ISCSI_FLAG_CMD_FINAL 0x80 | |
132 | #define ISCSI_FLAG_CMD_READ 0x40 | |
133 | #define ISCSI_FLAG_CMD_WRITE 0x20 | |
134 | #define ISCSI_FLAG_CMD_ATTR_MASK 0x07 /* 3 bits */ | |
135 | ||
136 | /* SCSI Command Attribute values */ | |
137 | #define ISCSI_ATTR_UNTAGGED 0 | |
138 | #define ISCSI_ATTR_SIMPLE 1 | |
139 | #define ISCSI_ATTR_ORDERED 2 | |
140 | #define ISCSI_ATTR_HEAD_OF_QUEUE 3 | |
141 | #define ISCSI_ATTR_ACA 4 | |
142 | ||
baebc497 MC |
143 | struct iscsi_rlength_ahdr { |
144 | __be16 ahslength; | |
145 | uint8_t ahstype; | |
146 | uint8_t reserved; | |
147 | __be32 read_length; | |
148 | }; | |
149 | ||
39e84790 AA |
150 | /* SCSI Response Header */ |
151 | struct iscsi_cmd_rsp { | |
152 | uint8_t opcode; | |
153 | uint8_t flags; | |
154 | uint8_t response; | |
155 | uint8_t cmd_status; | |
156 | uint8_t hlength; | |
157 | uint8_t dlength[3]; | |
158 | uint8_t rsvd[8]; | |
b4377356 | 159 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
160 | __be32 rsvd1; |
161 | __be32 statsn; | |
162 | __be32 exp_cmdsn; | |
163 | __be32 max_cmdsn; | |
164 | __be32 exp_datasn; | |
165 | __be32 bi_residual_count; | |
166 | __be32 residual_count; | |
167 | /* Response or Sense Data (optional) */ | |
168 | }; | |
169 | ||
170 | /* Command Response PDU flags */ | |
171 | #define ISCSI_FLAG_CMD_BIDI_OVERFLOW 0x10 | |
172 | #define ISCSI_FLAG_CMD_BIDI_UNDERFLOW 0x08 | |
173 | #define ISCSI_FLAG_CMD_OVERFLOW 0x04 | |
174 | #define ISCSI_FLAG_CMD_UNDERFLOW 0x02 | |
175 | ||
176 | /* iSCSI Status values. Valid if Rsp Selector bit is not set */ | |
177 | #define ISCSI_STATUS_CMD_COMPLETED 0 | |
178 | #define ISCSI_STATUS_TARGET_FAILURE 1 | |
179 | #define ISCSI_STATUS_SUBSYS_FAILURE 2 | |
180 | ||
181 | /* Asynchronous Event Header */ | |
182 | struct iscsi_async { | |
183 | uint8_t opcode; | |
184 | uint8_t flags; | |
185 | uint8_t rsvd2[2]; | |
186 | uint8_t rsvd3; | |
187 | uint8_t dlength[3]; | |
188 | uint8_t lun[8]; | |
189 | uint8_t rsvd4[8]; | |
190 | __be32 statsn; | |
191 | __be32 exp_cmdsn; | |
192 | __be32 max_cmdsn; | |
193 | uint8_t async_event; | |
194 | uint8_t async_vcode; | |
195 | __be16 param1; | |
196 | __be16 param2; | |
197 | __be16 param3; | |
198 | uint8_t rsvd5[4]; | |
199 | }; | |
200 | ||
201 | /* iSCSI Event Codes */ | |
202 | #define ISCSI_ASYNC_MSG_SCSI_EVENT 0 | |
203 | #define ISCSI_ASYNC_MSG_REQUEST_LOGOUT 1 | |
204 | #define ISCSI_ASYNC_MSG_DROPPING_CONNECTION 2 | |
205 | #define ISCSI_ASYNC_MSG_DROPPING_ALL_CONNECTIONS 3 | |
206 | #define ISCSI_ASYNC_MSG_PARAM_NEGOTIATION 4 | |
207 | #define ISCSI_ASYNC_MSG_VENDOR_SPECIFIC 255 | |
208 | ||
209 | /* NOP-Out Message */ | |
210 | struct iscsi_nopout { | |
211 | uint8_t opcode; | |
212 | uint8_t flags; | |
213 | __be16 rsvd2; | |
214 | uint8_t rsvd3; | |
215 | uint8_t dlength[3]; | |
216 | uint8_t lun[8]; | |
b4377356 | 217 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
218 | __be32 ttt; /* Target Transfer Tag */ |
219 | __be32 cmdsn; | |
220 | __be32 exp_statsn; | |
221 | uint8_t rsvd4[16]; | |
222 | }; | |
223 | ||
224 | /* NOP-In Message */ | |
225 | struct iscsi_nopin { | |
226 | uint8_t opcode; | |
227 | uint8_t flags; | |
228 | __be16 rsvd2; | |
229 | uint8_t rsvd3; | |
230 | uint8_t dlength[3]; | |
231 | uint8_t lun[8]; | |
b4377356 | 232 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
233 | __be32 ttt; /* Target Transfer Tag */ |
234 | __be32 statsn; | |
235 | __be32 exp_cmdsn; | |
236 | __be32 max_cmdsn; | |
237 | uint8_t rsvd4[12]; | |
238 | }; | |
239 | ||
240 | /* SCSI Task Management Message Header */ | |
241 | struct iscsi_tm { | |
242 | uint8_t opcode; | |
243 | uint8_t flags; | |
244 | uint8_t rsvd1[2]; | |
245 | uint8_t hlength; | |
246 | uint8_t dlength[3]; | |
247 | uint8_t lun[8]; | |
b4377356 AV |
248 | itt_t itt; /* Initiator Task Tag */ |
249 | itt_t rtt; /* Reference Task Tag */ | |
39e84790 AA |
250 | __be32 cmdsn; |
251 | __be32 exp_statsn; | |
252 | __be32 refcmdsn; | |
253 | __be32 exp_datasn; | |
254 | uint8_t rsvd2[8]; | |
255 | }; | |
256 | ||
baebc497 | 257 | #define ISCSI_FLAG_TM_FUNC_MASK 0x7F |
39e84790 AA |
258 | |
259 | /* Function values */ | |
260 | #define ISCSI_TM_FUNC_ABORT_TASK 1 | |
261 | #define ISCSI_TM_FUNC_ABORT_TASK_SET 2 | |
262 | #define ISCSI_TM_FUNC_CLEAR_ACA 3 | |
263 | #define ISCSI_TM_FUNC_CLEAR_TASK_SET 4 | |
264 | #define ISCSI_TM_FUNC_LOGICAL_UNIT_RESET 5 | |
265 | #define ISCSI_TM_FUNC_TARGET_WARM_RESET 6 | |
266 | #define ISCSI_TM_FUNC_TARGET_COLD_RESET 7 | |
267 | #define ISCSI_TM_FUNC_TASK_REASSIGN 8 | |
268 | ||
269 | /* SCSI Task Management Response Header */ | |
270 | struct iscsi_tm_rsp { | |
271 | uint8_t opcode; | |
272 | uint8_t flags; | |
273 | uint8_t response; /* see Response values below */ | |
274 | uint8_t qualifier; | |
275 | uint8_t hlength; | |
276 | uint8_t dlength[3]; | |
277 | uint8_t rsvd2[8]; | |
b4377356 AV |
278 | itt_t itt; /* Initiator Task Tag */ |
279 | itt_t rtt; /* Reference Task Tag */ | |
39e84790 AA |
280 | __be32 statsn; |
281 | __be32 exp_cmdsn; | |
282 | __be32 max_cmdsn; | |
283 | uint8_t rsvd3[12]; | |
284 | }; | |
285 | ||
286 | /* Response values */ | |
baebc497 MC |
287 | #define ISCSI_TMF_RSP_COMPLETE 0x00 |
288 | #define ISCSI_TMF_RSP_NO_TASK 0x01 | |
289 | #define ISCSI_TMF_RSP_NO_LUN 0x02 | |
290 | #define ISCSI_TMF_RSP_TASK_ALLEGIANT 0x03 | |
291 | #define ISCSI_TMF_RSP_NO_FAILOVER 0x04 | |
292 | #define ISCSI_TMF_RSP_NOT_SUPPORTED 0x05 | |
293 | #define ISCSI_TMF_RSP_AUTH_FAILED 0x06 | |
294 | #define ISCSI_TMF_RSP_REJECTED 0xff | |
39e84790 AA |
295 | |
296 | /* Ready To Transfer Header */ | |
297 | struct iscsi_r2t_rsp { | |
298 | uint8_t opcode; | |
299 | uint8_t flags; | |
300 | uint8_t rsvd2[2]; | |
301 | uint8_t hlength; | |
302 | uint8_t dlength[3]; | |
303 | uint8_t lun[8]; | |
b4377356 | 304 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
305 | __be32 ttt; /* Target Transfer Tag */ |
306 | __be32 statsn; | |
307 | __be32 exp_cmdsn; | |
308 | __be32 max_cmdsn; | |
309 | __be32 r2tsn; | |
310 | __be32 data_offset; | |
311 | __be32 data_length; | |
312 | }; | |
313 | ||
314 | /* SCSI Data Hdr */ | |
315 | struct iscsi_data { | |
316 | uint8_t opcode; | |
317 | uint8_t flags; | |
318 | uint8_t rsvd2[2]; | |
319 | uint8_t rsvd3; | |
320 | uint8_t dlength[3]; | |
321 | uint8_t lun[8]; | |
b4377356 | 322 | itt_t itt; |
39e84790 AA |
323 | __be32 ttt; |
324 | __be32 rsvd4; | |
325 | __be32 exp_statsn; | |
326 | __be32 rsvd5; | |
327 | __be32 datasn; | |
328 | __be32 offset; | |
329 | __be32 rsvd6; | |
330 | /* Payload */ | |
331 | }; | |
332 | ||
333 | /* SCSI Data Response Hdr */ | |
334 | struct iscsi_data_rsp { | |
335 | uint8_t opcode; | |
336 | uint8_t flags; | |
337 | uint8_t rsvd2; | |
338 | uint8_t cmd_status; | |
339 | uint8_t hlength; | |
340 | uint8_t dlength[3]; | |
341 | uint8_t lun[8]; | |
b4377356 | 342 | itt_t itt; |
39e84790 AA |
343 | __be32 ttt; |
344 | __be32 statsn; | |
345 | __be32 exp_cmdsn; | |
346 | __be32 max_cmdsn; | |
347 | __be32 datasn; | |
348 | __be32 offset; | |
349 | __be32 residual_count; | |
350 | }; | |
351 | ||
352 | /* Data Response PDU flags */ | |
353 | #define ISCSI_FLAG_DATA_ACK 0x40 | |
354 | #define ISCSI_FLAG_DATA_OVERFLOW 0x04 | |
355 | #define ISCSI_FLAG_DATA_UNDERFLOW 0x02 | |
356 | #define ISCSI_FLAG_DATA_STATUS 0x01 | |
357 | ||
358 | /* Text Header */ | |
359 | struct iscsi_text { | |
360 | uint8_t opcode; | |
361 | uint8_t flags; | |
362 | uint8_t rsvd2[2]; | |
363 | uint8_t hlength; | |
364 | uint8_t dlength[3]; | |
365 | uint8_t rsvd4[8]; | |
b4377356 | 366 | itt_t itt; |
39e84790 AA |
367 | __be32 ttt; |
368 | __be32 cmdsn; | |
369 | __be32 exp_statsn; | |
370 | uint8_t rsvd5[16]; | |
371 | /* Text - key=value pairs */ | |
372 | }; | |
373 | ||
374 | #define ISCSI_FLAG_TEXT_CONTINUE 0x40 | |
375 | ||
376 | /* Text Response Header */ | |
377 | struct iscsi_text_rsp { | |
378 | uint8_t opcode; | |
379 | uint8_t flags; | |
380 | uint8_t rsvd2[2]; | |
381 | uint8_t hlength; | |
382 | uint8_t dlength[3]; | |
383 | uint8_t rsvd4[8]; | |
b4377356 | 384 | itt_t itt; |
39e84790 AA |
385 | __be32 ttt; |
386 | __be32 statsn; | |
387 | __be32 exp_cmdsn; | |
388 | __be32 max_cmdsn; | |
389 | uint8_t rsvd5[12]; | |
390 | /* Text Response - key:value pairs */ | |
391 | }; | |
392 | ||
393 | /* Login Header */ | |
394 | struct iscsi_login { | |
395 | uint8_t opcode; | |
396 | uint8_t flags; | |
397 | uint8_t max_version; /* Max. version supported */ | |
398 | uint8_t min_version; /* Min. version supported */ | |
399 | uint8_t hlength; | |
400 | uint8_t dlength[3]; | |
401 | uint8_t isid[6]; /* Initiator Session ID */ | |
402 | __be16 tsih; /* Target Session Handle */ | |
b4377356 | 403 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
404 | __be16 cid; |
405 | __be16 rsvd3; | |
406 | __be32 cmdsn; | |
407 | __be32 exp_statsn; | |
408 | uint8_t rsvd5[16]; | |
409 | }; | |
410 | ||
411 | /* Login PDU flags */ | |
412 | #define ISCSI_FLAG_LOGIN_TRANSIT 0x80 | |
413 | #define ISCSI_FLAG_LOGIN_CONTINUE 0x40 | |
414 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */ | |
415 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */ | |
416 | ||
417 | #define ISCSI_LOGIN_CURRENT_STAGE(flags) \ | |
418 | ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2) | |
419 | #define ISCSI_LOGIN_NEXT_STAGE(flags) \ | |
420 | (flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK) | |
421 | ||
422 | /* Login Response Header */ | |
423 | struct iscsi_login_rsp { | |
424 | uint8_t opcode; | |
425 | uint8_t flags; | |
426 | uint8_t max_version; /* Max. version supported */ | |
427 | uint8_t active_version; /* Active version */ | |
428 | uint8_t hlength; | |
429 | uint8_t dlength[3]; | |
430 | uint8_t isid[6]; /* Initiator Session ID */ | |
431 | __be16 tsih; /* Target Session Handle */ | |
b4377356 | 432 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
433 | __be32 rsvd3; |
434 | __be32 statsn; | |
435 | __be32 exp_cmdsn; | |
436 | __be32 max_cmdsn; | |
437 | uint8_t status_class; /* see Login RSP ststus classes below */ | |
438 | uint8_t status_detail; /* see Login RSP Status details below */ | |
439 | uint8_t rsvd4[10]; | |
440 | }; | |
441 | ||
442 | /* Login stage (phase) codes for CSG, NSG */ | |
443 | #define ISCSI_INITIAL_LOGIN_STAGE -1 | |
444 | #define ISCSI_SECURITY_NEGOTIATION_STAGE 0 | |
445 | #define ISCSI_OP_PARMS_NEGOTIATION_STAGE 1 | |
446 | #define ISCSI_FULL_FEATURE_PHASE 3 | |
447 | ||
448 | /* Login Status response classes */ | |
449 | #define ISCSI_STATUS_CLS_SUCCESS 0x00 | |
450 | #define ISCSI_STATUS_CLS_REDIRECT 0x01 | |
451 | #define ISCSI_STATUS_CLS_INITIATOR_ERR 0x02 | |
452 | #define ISCSI_STATUS_CLS_TARGET_ERR 0x03 | |
453 | ||
454 | /* Login Status response detail codes */ | |
455 | /* Class-0 (Success) */ | |
456 | #define ISCSI_LOGIN_STATUS_ACCEPT 0x00 | |
457 | ||
458 | /* Class-1 (Redirection) */ | |
459 | #define ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP 0x01 | |
460 | #define ISCSI_LOGIN_STATUS_TGT_MOVED_PERM 0x02 | |
461 | ||
462 | /* Class-2 (Initiator Error) */ | |
463 | #define ISCSI_LOGIN_STATUS_INIT_ERR 0x00 | |
464 | #define ISCSI_LOGIN_STATUS_AUTH_FAILED 0x01 | |
465 | #define ISCSI_LOGIN_STATUS_TGT_FORBIDDEN 0x02 | |
466 | #define ISCSI_LOGIN_STATUS_TGT_NOT_FOUND 0x03 | |
467 | #define ISCSI_LOGIN_STATUS_TGT_REMOVED 0x04 | |
468 | #define ISCSI_LOGIN_STATUS_NO_VERSION 0x05 | |
469 | #define ISCSI_LOGIN_STATUS_ISID_ERROR 0x06 | |
470 | #define ISCSI_LOGIN_STATUS_MISSING_FIELDS 0x07 | |
471 | #define ISCSI_LOGIN_STATUS_CONN_ADD_FAILED 0x08 | |
472 | #define ISCSI_LOGIN_STATUS_NO_SESSION_TYPE 0x09 | |
473 | #define ISCSI_LOGIN_STATUS_NO_SESSION 0x0a | |
474 | #define ISCSI_LOGIN_STATUS_INVALID_REQUEST 0x0b | |
475 | ||
476 | /* Class-3 (Target Error) */ | |
477 | #define ISCSI_LOGIN_STATUS_TARGET_ERROR 0x00 | |
478 | #define ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE 0x01 | |
479 | #define ISCSI_LOGIN_STATUS_NO_RESOURCES 0x02 | |
480 | ||
481 | /* Logout Header */ | |
482 | struct iscsi_logout { | |
483 | uint8_t opcode; | |
484 | uint8_t flags; | |
485 | uint8_t rsvd1[2]; | |
486 | uint8_t hlength; | |
487 | uint8_t dlength[3]; | |
488 | uint8_t rsvd2[8]; | |
b4377356 | 489 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
490 | __be16 cid; |
491 | uint8_t rsvd3[2]; | |
492 | __be32 cmdsn; | |
493 | __be32 exp_statsn; | |
494 | uint8_t rsvd4[16]; | |
495 | }; | |
496 | ||
497 | /* Logout PDU flags */ | |
498 | #define ISCSI_FLAG_LOGOUT_REASON_MASK 0x7F | |
499 | ||
500 | /* logout reason_code values */ | |
501 | ||
502 | #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0 | |
503 | #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1 | |
504 | #define ISCSI_LOGOUT_REASON_RECOVERY 2 | |
505 | #define ISCSI_LOGOUT_REASON_AEN_REQUEST 3 | |
506 | ||
507 | /* Logout Response Header */ | |
508 | struct iscsi_logout_rsp { | |
509 | uint8_t opcode; | |
510 | uint8_t flags; | |
511 | uint8_t response; /* see Logout response values below */ | |
512 | uint8_t rsvd2; | |
513 | uint8_t hlength; | |
514 | uint8_t dlength[3]; | |
515 | uint8_t rsvd3[8]; | |
b4377356 | 516 | itt_t itt; /* Initiator Task Tag */ |
39e84790 AA |
517 | __be32 rsvd4; |
518 | __be32 statsn; | |
519 | __be32 exp_cmdsn; | |
520 | __be32 max_cmdsn; | |
521 | __be32 rsvd5; | |
522 | __be16 t2wait; | |
523 | __be16 t2retain; | |
524 | __be32 rsvd6; | |
525 | }; | |
526 | ||
527 | /* logout response status values */ | |
528 | ||
529 | #define ISCSI_LOGOUT_SUCCESS 0 | |
530 | #define ISCSI_LOGOUT_CID_NOT_FOUND 1 | |
531 | #define ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2 | |
532 | #define ISCSI_LOGOUT_CLEANUP_FAILED 3 | |
533 | ||
534 | /* SNACK Header */ | |
535 | struct iscsi_snack { | |
536 | uint8_t opcode; | |
537 | uint8_t flags; | |
538 | uint8_t rsvd2[14]; | |
b4377356 | 539 | itt_t itt; |
39e84790 AA |
540 | __be32 begrun; |
541 | __be32 runlength; | |
542 | __be32 exp_statsn; | |
543 | __be32 rsvd3; | |
544 | __be32 exp_datasn; | |
545 | uint8_t rsvd6[8]; | |
546 | }; | |
547 | ||
548 | /* SNACK PDU flags */ | |
549 | #define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */ | |
550 | ||
551 | /* Reject Message Header */ | |
552 | struct iscsi_reject { | |
553 | uint8_t opcode; | |
554 | uint8_t flags; | |
555 | uint8_t reason; | |
556 | uint8_t rsvd2; | |
fa0a6957 | 557 | uint8_t hlength; |
39e84790 | 558 | uint8_t dlength[3]; |
fa0a6957 MC |
559 | uint8_t rsvd3[8]; |
560 | __be32 ffffffff; | |
561 | uint8_t rsvd4[4]; | |
39e84790 AA |
562 | __be32 statsn; |
563 | __be32 exp_cmdsn; | |
564 | __be32 max_cmdsn; | |
565 | __be32 datasn; | |
566 | uint8_t rsvd5[8]; | |
567 | /* Text - Rejected hdr */ | |
568 | }; | |
569 | ||
570 | /* Reason for Reject */ | |
fa0a6957 MC |
571 | #define ISCSI_REASON_CMD_BEFORE_LOGIN 1 |
572 | #define ISCSI_REASON_DATA_DIGEST_ERROR 2 | |
573 | #define ISCSI_REASON_DATA_SNACK_REJECT 3 | |
574 | #define ISCSI_REASON_PROTOCOL_ERROR 4 | |
575 | #define ISCSI_REASON_CMD_NOT_SUPPORTED 5 | |
576 | #define ISCSI_REASON_IMM_CMD_REJECT 6 | |
577 | #define ISCSI_REASON_TASK_IN_PROGRESS 7 | |
578 | #define ISCSI_REASON_INVALID_SNACK 8 | |
579 | #define ISCSI_REASON_BOOKMARK_INVALID 9 | |
580 | #define ISCSI_REASON_BOOKMARK_NO_RESOURCES 10 | |
581 | #define ISCSI_REASON_NEGOTIATION_RESET 11 | |
39e84790 AA |
582 | |
583 | /* Max. number of Key=Value pairs in a text message */ | |
584 | #define MAX_KEY_VALUE_PAIRS 8192 | |
585 | ||
586 | /* maximum length for text keys/values */ | |
587 | #define KEY_MAXLEN 64 | |
588 | #define VALUE_MAXLEN 255 | |
589 | #define TARGET_NAME_MAXLEN VALUE_MAXLEN | |
590 | ||
bf32ed33 MC |
591 | #define ISCSI_DEF_MAX_RECV_SEG_LEN 8192 |
592 | #define ISCSI_MIN_MAX_RECV_SEG_LEN 512 | |
593 | #define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215 | |
594 | ||
595 | #define ISCSI_DEF_FIRST_BURST_LEN 65536 | |
596 | #define ISCSI_MIN_FIRST_BURST_LEN 512 | |
597 | #define ISCSI_MAX_FIRST_BURST_LEN 16777215 | |
598 | ||
599 | #define ISCSI_DEF_MAX_BURST_LEN 262144 | |
600 | #define ISCSI_MIN_MAX_BURST_LEN 512 | |
601 | #define ISCSI_MAX_MAX_BURST_LEN 16777215 | |
39e84790 AA |
602 | |
603 | /************************* RFC 3720 End *****************************/ | |
604 | ||
605 | #endif /* ISCSI_PROTO_H */ |