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