blob: 6947082eee6d23a9895cc0dc4aa6d7f3bcece352 [file] [log] [blame]
Alex Aizman39e84792005-08-04 19:31:00 -07001/*
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
Alex Aizman39e84792005-08-04 19:31:00 -070024#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 */
Boaz Harrosh004d6532007-12-13 12:43:23 -060030#define ISCSI_PAD_LEN 4
Alex Aizman39e84792005-08-04 19:31:00 -070031
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
Al Virob4377352007-02-09 16:39:40 +000043/* initiator tags; opaque for target */
44typedef 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
Alex Aizman39e84792005-08-04 19:31:00 -070051/*
52 * iSCSI Template Message Header
53 */
54struct 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];
Al Virob4377352007-02-09 16:39:40 +000061 itt_t itt; /* Initiator Task Tag, opaque for target */
Alex Aizman39e84792005-08-04 19:31:00 -070062 __be32 ttt; /* Target Task Tag */
63 __be32 statsn;
64 __be32 exp_statsn;
Mike Christiebaebc492005-09-12 21:01:38 -050065 __be32 max_statsn;
66 uint8_t other[12];
Alex Aizman39e84792005-08-04 19:31:00 -070067};
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
Mike Christiebaebc492005-09-12 21:01:38 -050088#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
Alex Aizman39e84792005-08-04 19:31:00 -070093/* 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
Mike Christiebaebc492005-09-12 21:01:38 -0500105struct 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
Alex Aizman39e84792005-08-04 19:31:00 -0700114/* iSCSI PDU Header */
115struct iscsi_cmd {
116 uint8_t opcode;
117 uint8_t flags;
Mike Christiebaebc492005-09-12 21:01:38 -0500118 __be16 rsvd2;
Alex Aizman39e84792005-08-04 19:31:00 -0700119 uint8_t hlength;
120 uint8_t dlength[3];
121 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000122 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700123 __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
Mike Christiebaebc492005-09-12 21:01:38 -0500143struct iscsi_rlength_ahdr {
144 __be16 ahslength;
145 uint8_t ahstype;
146 uint8_t reserved;
147 __be32 read_length;
148};
149
Boaz Harrosh004d6532007-12-13 12:43:23 -0600150/* Extended CDB AHS */
151struct iscsi_ecdb_ahdr {
152 __be16 ahslength; /* CDB length - 15, including reserved byte */
153 uint8_t ahstype;
154 uint8_t reserved;
155 uint8_t ecdb[260 - 16]; /* 4-byte aligned extended CDB spillover */
156};
157
Alex Aizman39e84792005-08-04 19:31:00 -0700158/* SCSI Response Header */
159struct iscsi_cmd_rsp {
160 uint8_t opcode;
161 uint8_t flags;
162 uint8_t response;
163 uint8_t cmd_status;
164 uint8_t hlength;
165 uint8_t dlength[3];
166 uint8_t rsvd[8];
Al Virob4377352007-02-09 16:39:40 +0000167 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700168 __be32 rsvd1;
169 __be32 statsn;
170 __be32 exp_cmdsn;
171 __be32 max_cmdsn;
172 __be32 exp_datasn;
173 __be32 bi_residual_count;
174 __be32 residual_count;
175 /* Response or Sense Data (optional) */
176};
177
178/* Command Response PDU flags */
179#define ISCSI_FLAG_CMD_BIDI_OVERFLOW 0x10
180#define ISCSI_FLAG_CMD_BIDI_UNDERFLOW 0x08
181#define ISCSI_FLAG_CMD_OVERFLOW 0x04
182#define ISCSI_FLAG_CMD_UNDERFLOW 0x02
183
184/* iSCSI Status values. Valid if Rsp Selector bit is not set */
185#define ISCSI_STATUS_CMD_COMPLETED 0
186#define ISCSI_STATUS_TARGET_FAILURE 1
187#define ISCSI_STATUS_SUBSYS_FAILURE 2
188
189/* Asynchronous Event Header */
190struct iscsi_async {
191 uint8_t opcode;
192 uint8_t flags;
193 uint8_t rsvd2[2];
194 uint8_t rsvd3;
195 uint8_t dlength[3];
196 uint8_t lun[8];
197 uint8_t rsvd4[8];
198 __be32 statsn;
199 __be32 exp_cmdsn;
200 __be32 max_cmdsn;
201 uint8_t async_event;
202 uint8_t async_vcode;
203 __be16 param1;
204 __be16 param2;
205 __be16 param3;
206 uint8_t rsvd5[4];
207};
208
209/* iSCSI Event Codes */
210#define ISCSI_ASYNC_MSG_SCSI_EVENT 0
211#define ISCSI_ASYNC_MSG_REQUEST_LOGOUT 1
212#define ISCSI_ASYNC_MSG_DROPPING_CONNECTION 2
213#define ISCSI_ASYNC_MSG_DROPPING_ALL_CONNECTIONS 3
214#define ISCSI_ASYNC_MSG_PARAM_NEGOTIATION 4
215#define ISCSI_ASYNC_MSG_VENDOR_SPECIFIC 255
216
217/* NOP-Out Message */
218struct iscsi_nopout {
219 uint8_t opcode;
220 uint8_t flags;
221 __be16 rsvd2;
222 uint8_t rsvd3;
223 uint8_t dlength[3];
224 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000225 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700226 __be32 ttt; /* Target Transfer Tag */
227 __be32 cmdsn;
228 __be32 exp_statsn;
229 uint8_t rsvd4[16];
230};
231
232/* NOP-In Message */
233struct iscsi_nopin {
234 uint8_t opcode;
235 uint8_t flags;
236 __be16 rsvd2;
237 uint8_t rsvd3;
238 uint8_t dlength[3];
239 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000240 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700241 __be32 ttt; /* Target Transfer Tag */
242 __be32 statsn;
243 __be32 exp_cmdsn;
244 __be32 max_cmdsn;
245 uint8_t rsvd4[12];
246};
247
248/* SCSI Task Management Message Header */
249struct iscsi_tm {
250 uint8_t opcode;
251 uint8_t flags;
252 uint8_t rsvd1[2];
253 uint8_t hlength;
254 uint8_t dlength[3];
255 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000256 itt_t itt; /* Initiator Task Tag */
257 itt_t rtt; /* Reference Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700258 __be32 cmdsn;
259 __be32 exp_statsn;
260 __be32 refcmdsn;
261 __be32 exp_datasn;
262 uint8_t rsvd2[8];
263};
264
Mike Christiebaebc492005-09-12 21:01:38 -0500265#define ISCSI_FLAG_TM_FUNC_MASK 0x7F
Alex Aizman39e84792005-08-04 19:31:00 -0700266
267/* Function values */
268#define ISCSI_TM_FUNC_ABORT_TASK 1
269#define ISCSI_TM_FUNC_ABORT_TASK_SET 2
270#define ISCSI_TM_FUNC_CLEAR_ACA 3
271#define ISCSI_TM_FUNC_CLEAR_TASK_SET 4
272#define ISCSI_TM_FUNC_LOGICAL_UNIT_RESET 5
273#define ISCSI_TM_FUNC_TARGET_WARM_RESET 6
274#define ISCSI_TM_FUNC_TARGET_COLD_RESET 7
275#define ISCSI_TM_FUNC_TASK_REASSIGN 8
276
277/* SCSI Task Management Response Header */
278struct iscsi_tm_rsp {
279 uint8_t opcode;
280 uint8_t flags;
281 uint8_t response; /* see Response values below */
282 uint8_t qualifier;
283 uint8_t hlength;
284 uint8_t dlength[3];
285 uint8_t rsvd2[8];
Al Virob4377352007-02-09 16:39:40 +0000286 itt_t itt; /* Initiator Task Tag */
287 itt_t rtt; /* Reference Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700288 __be32 statsn;
289 __be32 exp_cmdsn;
290 __be32 max_cmdsn;
291 uint8_t rsvd3[12];
292};
293
294/* Response values */
Mike Christiebaebc492005-09-12 21:01:38 -0500295#define ISCSI_TMF_RSP_COMPLETE 0x00
296#define ISCSI_TMF_RSP_NO_TASK 0x01
297#define ISCSI_TMF_RSP_NO_LUN 0x02
298#define ISCSI_TMF_RSP_TASK_ALLEGIANT 0x03
299#define ISCSI_TMF_RSP_NO_FAILOVER 0x04
300#define ISCSI_TMF_RSP_NOT_SUPPORTED 0x05
301#define ISCSI_TMF_RSP_AUTH_FAILED 0x06
302#define ISCSI_TMF_RSP_REJECTED 0xff
Alex Aizman39e84792005-08-04 19:31:00 -0700303
304/* Ready To Transfer Header */
305struct iscsi_r2t_rsp {
306 uint8_t opcode;
307 uint8_t flags;
308 uint8_t rsvd2[2];
309 uint8_t hlength;
310 uint8_t dlength[3];
311 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000312 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700313 __be32 ttt; /* Target Transfer Tag */
314 __be32 statsn;
315 __be32 exp_cmdsn;
316 __be32 max_cmdsn;
317 __be32 r2tsn;
318 __be32 data_offset;
319 __be32 data_length;
320};
321
322/* SCSI Data Hdr */
323struct iscsi_data {
324 uint8_t opcode;
325 uint8_t flags;
326 uint8_t rsvd2[2];
327 uint8_t rsvd3;
328 uint8_t dlength[3];
329 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000330 itt_t itt;
Alex Aizman39e84792005-08-04 19:31:00 -0700331 __be32 ttt;
332 __be32 rsvd4;
333 __be32 exp_statsn;
334 __be32 rsvd5;
335 __be32 datasn;
336 __be32 offset;
337 __be32 rsvd6;
338 /* Payload */
339};
340
341/* SCSI Data Response Hdr */
342struct iscsi_data_rsp {
343 uint8_t opcode;
344 uint8_t flags;
345 uint8_t rsvd2;
346 uint8_t cmd_status;
347 uint8_t hlength;
348 uint8_t dlength[3];
349 uint8_t lun[8];
Al Virob4377352007-02-09 16:39:40 +0000350 itt_t itt;
Alex Aizman39e84792005-08-04 19:31:00 -0700351 __be32 ttt;
352 __be32 statsn;
353 __be32 exp_cmdsn;
354 __be32 max_cmdsn;
355 __be32 datasn;
356 __be32 offset;
357 __be32 residual_count;
358};
359
360/* Data Response PDU flags */
361#define ISCSI_FLAG_DATA_ACK 0x40
362#define ISCSI_FLAG_DATA_OVERFLOW 0x04
363#define ISCSI_FLAG_DATA_UNDERFLOW 0x02
364#define ISCSI_FLAG_DATA_STATUS 0x01
365
366/* Text Header */
367struct iscsi_text {
368 uint8_t opcode;
369 uint8_t flags;
370 uint8_t rsvd2[2];
371 uint8_t hlength;
372 uint8_t dlength[3];
373 uint8_t rsvd4[8];
Al Virob4377352007-02-09 16:39:40 +0000374 itt_t itt;
Alex Aizman39e84792005-08-04 19:31:00 -0700375 __be32 ttt;
376 __be32 cmdsn;
377 __be32 exp_statsn;
378 uint8_t rsvd5[16];
379 /* Text - key=value pairs */
380};
381
382#define ISCSI_FLAG_TEXT_CONTINUE 0x40
383
384/* Text Response Header */
385struct iscsi_text_rsp {
386 uint8_t opcode;
387 uint8_t flags;
388 uint8_t rsvd2[2];
389 uint8_t hlength;
390 uint8_t dlength[3];
391 uint8_t rsvd4[8];
Al Virob4377352007-02-09 16:39:40 +0000392 itt_t itt;
Alex Aizman39e84792005-08-04 19:31:00 -0700393 __be32 ttt;
394 __be32 statsn;
395 __be32 exp_cmdsn;
396 __be32 max_cmdsn;
397 uint8_t rsvd5[12];
398 /* Text Response - key:value pairs */
399};
400
401/* Login Header */
402struct iscsi_login {
403 uint8_t opcode;
404 uint8_t flags;
405 uint8_t max_version; /* Max. version supported */
406 uint8_t min_version; /* Min. version supported */
407 uint8_t hlength;
408 uint8_t dlength[3];
409 uint8_t isid[6]; /* Initiator Session ID */
410 __be16 tsih; /* Target Session Handle */
Al Virob4377352007-02-09 16:39:40 +0000411 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700412 __be16 cid;
413 __be16 rsvd3;
414 __be32 cmdsn;
415 __be32 exp_statsn;
416 uint8_t rsvd5[16];
417};
418
419/* Login PDU flags */
420#define ISCSI_FLAG_LOGIN_TRANSIT 0x80
421#define ISCSI_FLAG_LOGIN_CONTINUE 0x40
422#define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */
423#define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */
424
425#define ISCSI_LOGIN_CURRENT_STAGE(flags) \
426 ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2)
427#define ISCSI_LOGIN_NEXT_STAGE(flags) \
428 (flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK)
429
430/* Login Response Header */
431struct iscsi_login_rsp {
432 uint8_t opcode;
433 uint8_t flags;
434 uint8_t max_version; /* Max. version supported */
435 uint8_t active_version; /* Active version */
436 uint8_t hlength;
437 uint8_t dlength[3];
438 uint8_t isid[6]; /* Initiator Session ID */
439 __be16 tsih; /* Target Session Handle */
Al Virob4377352007-02-09 16:39:40 +0000440 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700441 __be32 rsvd3;
442 __be32 statsn;
443 __be32 exp_cmdsn;
444 __be32 max_cmdsn;
445 uint8_t status_class; /* see Login RSP ststus classes below */
446 uint8_t status_detail; /* see Login RSP Status details below */
447 uint8_t rsvd4[10];
448};
449
450/* Login stage (phase) codes for CSG, NSG */
451#define ISCSI_INITIAL_LOGIN_STAGE -1
452#define ISCSI_SECURITY_NEGOTIATION_STAGE 0
453#define ISCSI_OP_PARMS_NEGOTIATION_STAGE 1
454#define ISCSI_FULL_FEATURE_PHASE 3
455
456/* Login Status response classes */
457#define ISCSI_STATUS_CLS_SUCCESS 0x00
458#define ISCSI_STATUS_CLS_REDIRECT 0x01
459#define ISCSI_STATUS_CLS_INITIATOR_ERR 0x02
460#define ISCSI_STATUS_CLS_TARGET_ERR 0x03
461
462/* Login Status response detail codes */
463/* Class-0 (Success) */
464#define ISCSI_LOGIN_STATUS_ACCEPT 0x00
465
466/* Class-1 (Redirection) */
467#define ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP 0x01
468#define ISCSI_LOGIN_STATUS_TGT_MOVED_PERM 0x02
469
470/* Class-2 (Initiator Error) */
471#define ISCSI_LOGIN_STATUS_INIT_ERR 0x00
472#define ISCSI_LOGIN_STATUS_AUTH_FAILED 0x01
473#define ISCSI_LOGIN_STATUS_TGT_FORBIDDEN 0x02
474#define ISCSI_LOGIN_STATUS_TGT_NOT_FOUND 0x03
475#define ISCSI_LOGIN_STATUS_TGT_REMOVED 0x04
476#define ISCSI_LOGIN_STATUS_NO_VERSION 0x05
477#define ISCSI_LOGIN_STATUS_ISID_ERROR 0x06
478#define ISCSI_LOGIN_STATUS_MISSING_FIELDS 0x07
479#define ISCSI_LOGIN_STATUS_CONN_ADD_FAILED 0x08
480#define ISCSI_LOGIN_STATUS_NO_SESSION_TYPE 0x09
481#define ISCSI_LOGIN_STATUS_NO_SESSION 0x0a
482#define ISCSI_LOGIN_STATUS_INVALID_REQUEST 0x0b
483
484/* Class-3 (Target Error) */
485#define ISCSI_LOGIN_STATUS_TARGET_ERROR 0x00
486#define ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE 0x01
487#define ISCSI_LOGIN_STATUS_NO_RESOURCES 0x02
488
489/* Logout Header */
490struct iscsi_logout {
491 uint8_t opcode;
492 uint8_t flags;
493 uint8_t rsvd1[2];
494 uint8_t hlength;
495 uint8_t dlength[3];
496 uint8_t rsvd2[8];
Al Virob4377352007-02-09 16:39:40 +0000497 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700498 __be16 cid;
499 uint8_t rsvd3[2];
500 __be32 cmdsn;
501 __be32 exp_statsn;
502 uint8_t rsvd4[16];
503};
504
505/* Logout PDU flags */
506#define ISCSI_FLAG_LOGOUT_REASON_MASK 0x7F
507
508/* logout reason_code values */
509
510#define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
511#define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
512#define ISCSI_LOGOUT_REASON_RECOVERY 2
513#define ISCSI_LOGOUT_REASON_AEN_REQUEST 3
514
515/* Logout Response Header */
516struct iscsi_logout_rsp {
517 uint8_t opcode;
518 uint8_t flags;
519 uint8_t response; /* see Logout response values below */
520 uint8_t rsvd2;
521 uint8_t hlength;
522 uint8_t dlength[3];
523 uint8_t rsvd3[8];
Al Virob4377352007-02-09 16:39:40 +0000524 itt_t itt; /* Initiator Task Tag */
Alex Aizman39e84792005-08-04 19:31:00 -0700525 __be32 rsvd4;
526 __be32 statsn;
527 __be32 exp_cmdsn;
528 __be32 max_cmdsn;
529 __be32 rsvd5;
530 __be16 t2wait;
531 __be16 t2retain;
532 __be32 rsvd6;
533};
534
535/* logout response status values */
536
537#define ISCSI_LOGOUT_SUCCESS 0
538#define ISCSI_LOGOUT_CID_NOT_FOUND 1
539#define ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2
540#define ISCSI_LOGOUT_CLEANUP_FAILED 3
541
542/* SNACK Header */
543struct iscsi_snack {
544 uint8_t opcode;
545 uint8_t flags;
546 uint8_t rsvd2[14];
Al Virob4377352007-02-09 16:39:40 +0000547 itt_t itt;
Alex Aizman39e84792005-08-04 19:31:00 -0700548 __be32 begrun;
549 __be32 runlength;
550 __be32 exp_statsn;
551 __be32 rsvd3;
552 __be32 exp_datasn;
553 uint8_t rsvd6[8];
554};
555
556/* SNACK PDU flags */
557#define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */
558
559/* Reject Message Header */
560struct iscsi_reject {
561 uint8_t opcode;
562 uint8_t flags;
563 uint8_t reason;
564 uint8_t rsvd2;
Mike Christiefa0a6952005-09-12 21:01:57 -0500565 uint8_t hlength;
Alex Aizman39e84792005-08-04 19:31:00 -0700566 uint8_t dlength[3];
Mike Christiefa0a6952005-09-12 21:01:57 -0500567 uint8_t rsvd3[8];
568 __be32 ffffffff;
569 uint8_t rsvd4[4];
Alex Aizman39e84792005-08-04 19:31:00 -0700570 __be32 statsn;
571 __be32 exp_cmdsn;
572 __be32 max_cmdsn;
573 __be32 datasn;
574 uint8_t rsvd5[8];
575 /* Text - Rejected hdr */
576};
577
578/* Reason for Reject */
Mike Christiefa0a6952005-09-12 21:01:57 -0500579#define ISCSI_REASON_CMD_BEFORE_LOGIN 1
580#define ISCSI_REASON_DATA_DIGEST_ERROR 2
581#define ISCSI_REASON_DATA_SNACK_REJECT 3
582#define ISCSI_REASON_PROTOCOL_ERROR 4
583#define ISCSI_REASON_CMD_NOT_SUPPORTED 5
584#define ISCSI_REASON_IMM_CMD_REJECT 6
585#define ISCSI_REASON_TASK_IN_PROGRESS 7
586#define ISCSI_REASON_INVALID_SNACK 8
587#define ISCSI_REASON_BOOKMARK_INVALID 9
588#define ISCSI_REASON_BOOKMARK_NO_RESOURCES 10
589#define ISCSI_REASON_NEGOTIATION_RESET 11
Alex Aizman39e84792005-08-04 19:31:00 -0700590
591/* Max. number of Key=Value pairs in a text message */
592#define MAX_KEY_VALUE_PAIRS 8192
593
594/* maximum length for text keys/values */
595#define KEY_MAXLEN 64
596#define VALUE_MAXLEN 255
597#define TARGET_NAME_MAXLEN VALUE_MAXLEN
598
Mike Christiebf32ed32007-02-28 17:32:17 -0600599#define ISCSI_DEF_MAX_RECV_SEG_LEN 8192
600#define ISCSI_MIN_MAX_RECV_SEG_LEN 512
601#define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215
602
603#define ISCSI_DEF_FIRST_BURST_LEN 65536
604#define ISCSI_MIN_FIRST_BURST_LEN 512
605#define ISCSI_MAX_FIRST_BURST_LEN 16777215
606
607#define ISCSI_DEF_MAX_BURST_LEN 262144
608#define ISCSI_MIN_MAX_BURST_LEN 512
609#define ISCSI_MAX_MAX_BURST_LEN 16777215
Alex Aizman39e84792005-08-04 19:31:00 -0700610
Mike Christie843c0a82007-12-13 12:43:20 -0600611#define ISCSI_DEF_TIME2WAIT 2
612
Alex Aizman39e84792005-08-04 19:31:00 -0700613/************************* RFC 3720 End *****************************/
614
615#endif /* ISCSI_PROTO_H */