1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at src/sun_nws/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at src/sun_nws/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _ISCSI_PROTOCOL_H
28 #define _ISCSI_PROTOCOL_H
29
30 #pragma ident "@(#)iscsi_protocol.h 1.10 08/02/29 SMI"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37 * iSCSI connection daemon
38 * Copyright (C) 2001 Cisco Systems, Inc.
39 * All rights reserved.
40 *
41 * This file sets up definitions of messages and constants used by the
42 * iSCSI protocol.
43 *
44 */
45
46 #include <sys/types.h>
47 #include <sys/isa_defs.h>
48
49 /* iSCSI listen port for incoming connections */
50 #define ISCSI_LISTEN_PORT 3260
51
52 /* assumes a pointer to a 3-byte array */
53 #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
54
55 /* assumes a pointer to a 3 byte array, and an integer value */
56 #define hton24(p, v) {\
57 p[0] = (((v) >> 16) & 0xFF); \
58 p[1] = (((v) >> 8) & 0xFF); \
59 p[2] = ((v) & 0xFF); \
60 }
61
62
63 /* for Login min, max, active version fields */
64 #define ISCSI_MIN_VERSION 0x00
65 #define ISCSI_DRAFT8_VERSION 0x02
66 #define ISCSI_DRAFT20_VERSION 0x00
67 #define ISCSI_MAX_VERSION 0x02
68
69 /* Min. and Max. length of a PDU we can support */
70 #define ISCSI_MIN_PDU_LENGTH (8 << 9) /* 4KB */
71 #define ISCSI_MAX_PDU_LENGTH (0xffffffff) /* Huge */
72
73 /* Padding word length */
74 #define ISCSI_PAD_WORD_LEN 4
75
76 /* Max. number of Key=Value pairs in a text message */
77 #define ISCSI_MAX_KEY_VALUE_PAIRS 8192
78
79 /* text separtor between key value pairs exhanged in login */
80 #define ISCSI_TEXT_SEPARATOR '='
81
82 /* reserved text constants for Text Mode Negotiation */
83 #define ISCSI_TEXT_NONE "None"
84 #define ISCSI_TEXT_REJECT "Reject"
85 #define ISCSI_TEXT_IRRELEVANT "Irrelevant"
86 #define ISCSI_TEXT_NOTUNDERSTOOD "NotUnderstood"
87
88 /* Reserved value for initiator/target task tag */
89 #define ISCSI_RSVD_TASK_TAG 0xffffffff
90
91 /* maximum length for text keys/values */
92 #define KEY_MAXLEN 64
93 #define VALUE_MAXLEN 255
94 #define TARGET_NAME_MAXLEN VALUE_MAXLEN
95
96 #define ISCSI_DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 8192
97
98 /* most PDU types have a final bit */
99 #define ISCSI_FLAG_FINAL 0x80
100
101 /*
102 * Strings used during SendTargets requests
103 */
104 #define ISCSI_TEXT_SEPARATOR '='
105 #define TARGETNAME "TargetName="
106 #define TARGETADDRESS "TargetAddress="
107
108 /* iSCSI Template Message Header */
109 typedef struct _iscsi_hdr {
110 uint8_t opcode;
111 uint8_t flags; /* Final bit */
112 uint8_t rsvd2[2];
113 uint8_t hlength; /* AHSs total length */
114 uint8_t dlength[3]; /* Data length */
115 uint8_t lun[8];
116 uint32_t itt; /* Initiator Task Tag */
117 uint8_t other[28];
118 } iscsi_hdr_t;
119
120 /* Opcode encoding bits */
121 #define ISCSI_OP_RETRY 0x80
122 #define ISCSI_OP_IMMEDIATE 0x40
123 #define ISCSI_OPCODE_MASK 0x3F
124
125 /* Client to Server Message Opcode values */
126 #define ISCSI_OP_NOOP_OUT 0x00
127 #define ISCSI_OP_SCSI_CMD 0x01
128 #define ISCSI_OP_SCSI_TASK_MGT_MSG 0x02
129 #define ISCSI_OP_LOGIN_CMD 0x03
130 #define ISCSI_OP_TEXT_CMD 0x04
131 #define ISCSI_OP_SCSI_DATA 0x05
132 #define ISCSI_OP_LOGOUT_CMD 0x06
133 #define ISCSI_OP_SNACK_CMD 0x10
134
135 /* Server to Client Message Opcode values */
136 #define ISCSI_OP_NOOP_IN 0x20
137 #define ISCSI_OP_SCSI_RSP 0x21
138 #define ISCSI_OP_SCSI_TASK_MGT_RSP 0x22
139 #define ISCSI_OP_LOGIN_RSP 0x23
140 #define ISCSI_OP_TEXT_RSP 0x24
141 #define ISCSI_OP_SCSI_DATA_RSP 0x25
142 #define ISCSI_OP_LOGOUT_RSP 0x26
143 #define ISCSI_OP_RTT_RSP 0x31
144 #define ISCSI_OP_ASYNC_EVENT 0x32
145 #define ISCSI_OP_REJECT_MSG 0x3f
146
147
148 /* SCSI Command Header */
149 typedef struct _iscsi_scsi_cmd_hdr {
150 uint8_t opcode;
151 uint8_t flags;
152 uint8_t rsvd[2];
153 uint8_t hlength;
154 uint8_t dlength[3];
155 uint8_t lun[8];
156 uint32_t itt; /* Initiator Task Tag */
157 uint32_t data_length;
158 uint32_t cmdsn;
159 uint32_t expstatsn;
160 uint8_t scb[16]; /* SCSI Command Block */
161 /*
162 * Additional Data (Command Dependent)
163 */
164 } iscsi_scsi_cmd_hdr_t;
165
166 /* Command PDU flags */
167 #define ISCSI_FLAG_CMD_READ 0x40
168 #define ISCSI_FLAG_CMD_WRITE 0x20
169 #define ISCSI_FLAG_CMD_ATTR_MASK 0x07 /* 3 bits */
170
171 /* SCSI Command Attribute values */
172 #define ISCSI_ATTR_UNTAGGED 0
173 #define ISCSI_ATTR_SIMPLE 1
174 #define ISCSI_ATTR_ORDERED 2
175 #define ISCSI_ATTR_HEAD_OF_QUEUE 3
176 #define ISCSI_ATTR_ACA 4
177
178
179 /* SCSI Response Header */
180 typedef struct _iscsi_scsi_rsp_hdr {
181 uint8_t opcode;
182 uint8_t flags;
183 uint8_t response;
184 uint8_t cmd_status;
185 uint8_t hlength;
186 uint8_t dlength[3];
187 uint8_t rsvd[8];
188 uint32_t itt; /* Initiator Task Tag */
189 uint32_t rsvd1;
190 uint32_t statsn;
191 uint32_t expcmdsn;
192 uint32_t maxcmdsn;
193 uint32_t expdatasn;
194 uint32_t bi_residual_count;
195 uint32_t residual_count;
196 /*
197 * Response or Sense Data (optional)
198 */
199 } iscsi_scsi_rsp_hdr_t;
200
201 /* 10.2.2.3 - Extended CDB Additional Header Segment */
202
203 typedef struct _iscsi_addl_hdr {
204 iscsi_scsi_cmd_hdr_t ahs_isch;
205 uint8_t ahs_hlen_hi;
206 uint8_t ahs_hlen_lo;
207 uint8_t ahs_key;
208 uint8_t ahs_resv;
209 uint8_t ahs_extscb[4];
210 } iscsi_addl_hdr_t;
211
212 /* Command Response PDU flags */
213 #define ISCSI_FLAG_CMD_BIDI_OVERFLOW 0x10
214 #define ISCSI_FLAG_CMD_BIDI_UNDERFLOW 0x08
215 #define ISCSI_FLAG_CMD_OVERFLOW 0x04
216 #define ISCSI_FLAG_CMD_UNDERFLOW 0x02
217
218 /* iSCSI Status values. Valid if Rsp Selector bit is not set */
219 #define ISCSI_STATUS_CMD_COMPLETED 0
220 #define ISCSI_STATUS_TARGET_FAILURE 1
221 #define ISCSI_STATUS_SUBSYS_FAILURE 2
222
223
224 /* Asynchronous Event Header */
225 typedef struct _iscsi_async_evt_hdr {
226 uint8_t opcode;
227 uint8_t flags;
228 uint8_t rsvd2[2];
229 uint8_t rsvd3;
230 uint8_t dlength[3];
231 uint8_t lun[8];
232 uint8_t rsvd4[8];
233 uint32_t statsn;
234 uint32_t expcmdsn;
235 uint32_t maxcmdsn;
236 uint8_t async_event;
237 uint8_t async_vcode;
238 uint16_t param1;
239 uint16_t param2;
240 uint16_t param3;
241 uint8_t rsvd5[4];
242 } iscsi_async_evt_hdr_t;
243
244 /* iSCSI Event Indicator values */
245 #define ISCSI_ASYNC_EVENT_SCSI_EVENT 0
246 #define ISCSI_ASYNC_EVENT_REQUEST_LOGOUT 1
247 #define ISCSI_ASYNC_EVENT_DROPPING_CONNECTION 2
248 #define ISCSI_ASYNC_EVENT_DROPPING_ALL_CONNECTIONS 3
249 #define ISCSI_ASYNC_EVENT_PARAM_NEGOTIATION 4
250 #define ISCSI_ASYNC_EVENT_VENDOR_SPECIFIC 255
251
252
253 /* NOP-Out Message */
254 typedef struct _iscsi_nop_out_hdr {
255 uint8_t opcode;
256 uint8_t flags;
257 uint16_t rsvd2;
258 uint8_t rsvd3;
259 uint8_t dlength[3];
260 uint8_t lun[8];
261 uint32_t itt; /* Initiator Task Tag */
262 uint32_t ttt; /* Target Transfer Tag */
263 uint32_t cmdsn;
264 uint32_t expstatsn;
265 uint8_t rsvd4[16];
266 } iscsi_nop_out_hdr_t;
267
268
269 /* NOP-In Message */
270 typedef struct _iscsi_nop_in_hdr {
271 uint8_t opcode;
272 uint8_t flags;
273 uint16_t rsvd2;
274 uint8_t rsvd3;
275 uint8_t dlength[3];
276 uint8_t lun[8];
277 uint32_t itt; /* Initiator Task Tag */
278 uint32_t ttt; /* Target Transfer Tag */
279 uint32_t statsn;
280 uint32_t expcmdsn;
281 uint32_t maxcmdsn;
282 uint8_t rsvd4[12];
283 } iscsi_nop_in_hdr_t;
284
285 /* SCSI Task Management Message Header */
286 typedef struct _iscsi_scsi_task_mgt_hdr {
287 uint8_t opcode;
288 uint8_t function;
289 uint8_t rsvd1[2];
290 uint8_t hlength;
291 uint8_t dlength[3];
292 uint8_t lun[8];
293 uint32_t itt; /* Initiator Task Tag */
294 uint32_t rtt; /* Reference Task Tag */
295 uint32_t cmdsn;
296 uint32_t expstatsn;
297 uint32_t refcmdsn;
298 uint32_t expdatasn;
299 uint8_t rsvd2[8];
300 } iscsi_scsi_task_mgt_hdr_t;
301
302 #define ISCSI_FLAG_TASK_MGMT_FUNCTION_MASK 0x7F
303
304 /* Function values */
305 #define ISCSI_TM_FUNC_ABORT_TASK 1
306 #define ISCSI_TM_FUNC_ABORT_TASK_SET 2
307 #define ISCSI_TM_FUNC_CLEAR_ACA 3
308 #define ISCSI_TM_FUNC_CLEAR_TASK_SET 4
309 #define ISCSI_TM_FUNC_LOGICAL_UNIT_RESET 5
310 #define ISCSI_TM_FUNC_TARGET_WARM_RESET 6
311 #define ISCSI_TM_FUNC_TARGET_COLD_RESET 7
312 #define ISCSI_TM_FUNC_TASK_REASSIGN 8
313
314
315 /* SCSI Task Management Response Header */
316 typedef struct _iscsi_scsi_task_mgt_rsp_hdr {
317 uint8_t opcode;
318 uint8_t flags;
319 uint8_t response; /* see Response values below */
320 uint8_t qualifier;
321 uint8_t hlength;
322 uint8_t dlength[3];
323 uint8_t rsvd2[8];
324 uint32_t itt; /* Initiator Task Tag */
325 uint32_t rtt; /* Reference Task Tag */
326 uint32_t statsn;
327 uint32_t expcmdsn;
328 uint32_t maxcmdsn;
329 uint8_t rsvd3[12];
330 } iscsi_scsi_task_mgt_rsp_hdr_t;
331
332
333 /* Response values */
334 #define SCSI_TCP_TM_RESP_COMPLETE 0x00
335 #define SCSI_TCP_TM_RESP_NO_TASK 0x01
336 #define SCSI_TCP_TM_RESP_NO_LUN 0x02
337 #define SCSI_TCP_TM_RESP_TASK_ALLEGIANT 0x03
338 #define SCSI_TCP_TM_RESP_NO_FAILOVER 0x04
339 #define SCSI_TCP_TM_RESP_IN_PRGRESS 0x05
340 #define SCSI_TCP_TM_RESP_REJECTED 0xff
341
342 /* Ready To Transfer Header */
343 typedef struct _iscsi_rtt_hdr {
344 uint8_t opcode;
345 uint8_t flags;
346 uint8_t rsvd2[2];
347 uint8_t rsvd3[12];
348 uint32_t itt; /* Initiator Task Tag */
349 uint32_t ttt; /* Target Transfer Tag */
350 uint32_t statsn;
351 uint32_t expcmdsn;
352 uint32_t maxcmdsn;
353 uint32_t rttsn;
354 uint32_t data_offset;
355 uint32_t data_length;
356 } iscsi_rtt_hdr_t;
357
358
359 /* SCSI Data Hdr */
360 typedef struct _iscsi_data_hdr {
361 uint8_t opcode;
362 uint8_t flags;
363 uint8_t rsvd2[2];
364 uint8_t rsvd3;
365 uint8_t dlength[3];
366 uint8_t lun[8];
367 uint32_t itt;
368 uint32_t ttt;
369 uint32_t rsvd4;
370 uint32_t expstatsn;
371 uint32_t rsvd5;
372 uint32_t datasn;
373 uint32_t offset;
374 uint32_t rsvd6;
375 /*
376 * Payload
377 */
378 } iscsi_data_hdr_t;
379
380 /* SCSI Data Response Hdr */
381 typedef struct _iscsi_data_rsp_hdr {
382 uint8_t opcode;
383 uint8_t flags;
384 uint8_t rsvd2;
385 uint8_t cmd_status;
386 uint8_t hlength;
387 uint8_t dlength[3];
388 uint8_t lun[8];
389 uint32_t itt;
390 uint32_t ttt;
391 uint32_t statsn;
392 uint32_t expcmdsn;
393 uint32_t maxcmdsn;
394 uint32_t datasn;
395 uint32_t offset;
396 uint32_t residual_count;
397 } iscsi_data_rsp_hdr_t;
398
399 /* Data Response PDU flags */
400 #define ISCSI_FLAG_DATA_ACK 0x40
401 #define ISCSI_FLAG_DATA_OVERFLOW 0x04
402 #define ISCSI_FLAG_DATA_UNDERFLOW 0x02
403 #define ISCSI_FLAG_DATA_STATUS 0x01
404
405
406 /* Text Header */
407 typedef struct _iscsi_text_hdr {
408 uint8_t opcode;
409 uint8_t flags;
410 uint8_t rsvd2[2];
411 uint8_t hlength;
412 uint8_t dlength[3];
413 uint8_t rsvd4[8];
414 uint32_t itt;
415 uint32_t ttt;
416 uint32_t cmdsn;
417 uint32_t expstatsn;
418 uint8_t rsvd5[16];
419 /*
420 * Text - key=value pairs
421 */
422 } iscsi_text_hdr_t;
423
424 #define ISCSI_FLAG_TEXT_CONTINUE 0x40
425
426 /* Text Response Header */
427 typedef struct _iscsi_text_rsp_hdr {
428 uint8_t opcode;
429 uint8_t flags;
430 uint8_t rsvd2[2];
431 uint8_t hlength;
432 uint8_t dlength[3];
433 uint8_t rsvd4[8];
434 uint32_t itt;
435 uint32_t ttt;
436 uint32_t statsn;
437 uint32_t expcmdsn;
438 uint32_t maxcmdsn;
439 uint8_t rsvd5[12];
440 /*
441 * Text Response - key:value pairs
442 */
443 } iscsi_text_rsp_hdr_t;
444
445 #define ISCSI_ISID_LEN 6
446
447 /* Login Header */
448 typedef struct _iscsi_login_hdr {
449 uint8_t opcode;
450 uint8_t flags;
451 uint8_t max_version; /* Max. version supported */
452 uint8_t min_version; /* Min. version supported */
453 uint8_t hlength;
454 uint8_t dlength[3];
455 uint8_t isid[ISCSI_ISID_LEN]; /* Initiator Session ID */
456 uint16_t tsid; /* Target Session ID */
457 uint32_t itt; /* Initiator Task Tag */
458 uint16_t cid;
459 uint16_t rsvd3;
460 uint32_t cmdsn;
461 uint32_t expstatsn;
462 uint8_t rsvd5[16];
463 } iscsi_login_hdr_t;
464
465 /* Login PDU flags */
466 #define ISCSI_FLAG_LOGIN_TRANSIT 0x80
467 #define ISCSI_FLAG_LOGIN_CONTINUE 0x40
468 #define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */
469 #define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */
470
471 #define ISCSI_LOGIN_CURRENT_STAGE(flags) \
472 ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2)
473 #define ISCSI_LOGIN_NEXT_STAGE(flags) \
474 (flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK)
475
476
477 /* Login Response Header */
478 typedef struct _iscsi_login_rsp_hdr {
479 uint8_t opcode;
480 uint8_t flags;
481 uint8_t max_version; /* Max. version supported */
482 uint8_t active_version; /* Active version */
483 uint8_t hlength;
484 uint8_t dlength[3];
485 uint8_t isid[ISCSI_ISID_LEN]; /* Initiator Session ID */
486 uint16_t tsid; /* Target Session ID */
487 uint32_t itt; /* Initiator Task Tag */
488 uint32_t rsvd3;
489 uint32_t statsn;
490 uint32_t expcmdsn;
491 uint32_t maxcmdsn;
492 uint8_t status_class; /* see Login RSP ststus classes below */
493 uint8_t status_detail; /* see Login RSP Status details below */
494 uint8_t rsvd4[10];
495 } iscsi_login_rsp_hdr_t;
496
497 /* Login stage (phase) codes for CSG, NSG */
498 #define ISCSI_SECURITY_NEGOTIATION_STAGE 0
499 #define ISCSI_OP_PARMS_NEGOTIATION_STAGE 1
500 #define ISCSI_FULL_FEATURE_PHASE 3
501
502 /* Login Status response classes */
503 #define ISCSI_STATUS_CLASS_SUCCESS 0x00
504 #define ISCSI_STATUS_CLASS_REDIRECT 0x01
505 #define ISCSI_STATUS_CLASS_INITIATOR_ERR 0x02
506 #define ISCSI_STATUS_CLASS_TARGET_ERR 0x03
507
508 /* Login Status response detail codes */
509 /* Class-0 (Success) */
510 #define ISCSI_LOGIN_STATUS_ACCEPT 0x00
511
512 /* Class-1 (Redirection) */
513 #define ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP 0x01
514 #define ISCSI_LOGIN_STATUS_TGT_MOVED_PERM 0x02
515
516 /* Class-2 (Initiator Error) */
517 #define ISCSI_LOGIN_STATUS_INIT_ERR 0x00
518 #define ISCSI_LOGIN_STATUS_AUTH_FAILED 0x01
519 #define ISCSI_LOGIN_STATUS_TGT_FORBIDDEN 0x02
520 #define ISCSI_LOGIN_STATUS_TGT_NOT_FOUND 0x03
521 #define ISCSI_LOGIN_STATUS_TGT_REMOVED 0x04
522 #define ISCSI_LOGIN_STATUS_NO_VERSION 0x05
523 #define ISCSI_LOGIN_STATUS_ISID_ERROR 0x06
524 #define ISCSI_LOGIN_STATUS_MISSING_FIELDS 0x07
525 #define ISCSI_LOGIN_STATUS_CONN_ADD_FAILED 0x08
526 #define ISCSI_LOGIN_STATUS_NO_SESSION_TYPE 0x09
527 #define ISCSI_LOGIN_STATUS_NO_SESSION 0x0a
528 #define ISCSI_LOGIN_STATUS_INVALID_REQUEST 0x0b
529
530 /* Class-3 (Target Error) */
531 #define ISCSI_LOGIN_STATUS_TARGET_ERROR 0x00
532 #define ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE 0x01
533 #define ISCSI_LOGIN_STATUS_NO_RESOURCES 0x02
534
535 /* Logout Header */
536 typedef struct _iscsi_logout_hdr {
537 uint8_t opcode;
538 uint8_t flags;
539 uint8_t rsvd1[2];
540 uint8_t hlength;
541 uint8_t dlength[3];
542 uint8_t rsvd2[8];
543 uint32_t itt; /* Initiator Task Tag */
544 uint16_t cid;
545 uint8_t rsvd3[2];
546 uint32_t cmdsn;
547 uint32_t expstatsn;
548 uint8_t rsvd4[16];
549 } iscsi_logout_hdr_t;
550
551 /* Logout PDU flags */
552 #define ISCSI_FLAG_LOGOUT_REASON_MASK 0x7F
553
554 /* logout reason_code values */
555
556 #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
557 #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
558 #define ISCSI_LOGOUT_REASON_RECOVERY 2
559 #define ISCSI_LOGOUT_REASON_AEN_REQUEST 3
560
561 /* Logout Response Header */
562 typedef struct _iscsi_logout_rsp_hdr {
563 uint8_t opcode;
564 uint8_t flags;
565 uint8_t response; /* see Logout response values below */
566 uint8_t rsvd2;
567 uint8_t hlength;
568 uint8_t dlength[3];
569 uint8_t rsvd3[8];
570 uint32_t itt; /* Initiator Task Tag */
571 uint32_t rsvd4;
572 uint32_t statsn;
573 uint32_t expcmdsn;
574 uint32_t maxcmdsn;
575 uint32_t rsvd5;
576 uint16_t t2wait;
577 uint16_t t2retain;
578 uint32_t rsvd6;
579 } iscsi_logout_rsp_hdr_t;
580
581 /* logout response status values */
582
583 #define ISCSI_LOGOUT_SUCCESS 0
584 #define ISCSI_LOGOUT_CID_NOT_FOUND 1
585 #define ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2
586 #define ISCSI_LOGOUT_CLEANUP_FAILED 3
587
588
589 /* SNACK Header */
590 typedef struct _iscsi_snack_hdr {
591 uint8_t opcode;
592 uint8_t flags;
593 uint8_t rsvd2[14];
594 uint32_t itt;
595 uint32_t begrun;
596 uint32_t runlength;
597 uint32_t expstatsn;
598 uint32_t rsvd3;
599 uint32_t expdatasn;
600 uint8_t rsvd6[8];
601 } iscsi_snack_hdr_t;
602
603 /* SNACK PDU flags */
604 #define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */
605
606 /* Reject Message Header */
607 typedef struct _iscsi_reject_rsp_hdr {
608 uint8_t opcode;
609 uint8_t flags;
610 uint8_t reason;
611 uint8_t rsvd2;
612 uint8_t rsvd3;
613 uint8_t dlength[3];
614 uint8_t rsvd4[16];
615 uint32_t statsn;
616 uint32_t expcmdsn;
617 uint32_t maxcmdsn;
618 uint32_t datasn;
619 uint8_t rsvd5[8];
620 /*
621 * Text - Rejected hdr
622 */
623 } iscsi_reject_rsp_hdr_t;
624
625 /* Reason for Reject */
626 #define ISCSI_REJECT_CMD_BEFORE_LOGIN 1
627 #define ISCSI_REJECT_DATA_DIGEST_ERROR 2
628 #define ISCSI_REJECT_SNACK_REJECT 3
629 #define ISCSI_REJECT_PROTOCOL_ERROR 4
630 #define ISCSI_REJECT_CMD_NOT_SUPPORTED 5
631 #define ISCSI_REJECT_IMM_CMD_REJECT 6
632 #define ISCSI_REJECT_TASK_IN_PROGRESS 7
633 #define ISCSI_REJECT_INVALID_DATA_ACK 8
634 #define ISCSI_REJECT_INVALID_PDU_FIELD 9
635 #define ISCSI_REJECT_LONG_OPERATION_REJECT 10
636 #define ISCSI_REJECT_NEGOTIATION_RESET 11
637 #define ISCSI_REJECT_WAITING_FOR_LOGOUT 12
638
639 /* Defaults as defined by the iSCSI specification */
640 #define ISCSI_DEFAULT_IMMEDIATE_DATA TRUE
641 #define ISCSI_DEFAULT_INITIALR2T TRUE
642 #define ISCSI_DEFAULT_FIRST_BURST_LENGTH (64 * 1024) /* 64kbytes */
643 #define ISCSI_DEFAULT_MAX_BURST_LENGTH (256 * 1024) /* 256kbytes */
644 #define ISCSI_DEFAULT_DATA_PDU_IN_ORDER TRUE
645 #define ISCSI_DEFAULT_DATA_SEQUENCE_IN_ORDER TRUE
646 #define ISCSI_DEFAULT_TIME_TO_WAIT 2 /* 2 seconds */
647 #define ISCSI_DEFAULT_TIME_TO_RETAIN 20 /* 20 seconds */
648 #define ISCSI_DEFAULT_HEADER_DIGEST ISCSI_DIGEST_NONE
649 #define ISCSI_DEFAULT_DATA_DIGEST ISCSI_DIGEST_NONE
650 #define ISCSI_DEFAULT_MAX_RECV_SEG_LEN (8 * 1024)
651 #define ISCSI_DEFAULT_MAX_XMIT_SEG_LEN (8 * 1024)
652 #define ISCSI_DEFAULT_MAX_CONNECTIONS 1
653 #define ISCSI_DEFAULT_MAX_OUT_R2T 1
654 #define ISCSI_DEFAULT_ERROR_RECOVERY_LEVEL 0
655 #define ISCSI_DEFAULT_IFMARKER FALSE
656 #define ISCSI_DEFAULT_OFMARKER FALSE
657
658 /*
659 * Minimum values from the iSCSI specification
660 */
661
662 #define ISCSI_MIN_TIME2RETAIN 0
663 #define ISCSI_MIN_TIME2WAIT 0
664 #define ISCSI_MIN_ERROR_RECOVERY_LEVEL 0
665 #define ISCSI_MIN_RECV_DATA_SEGMENT_LENGTH 0x200
666 #define ISCSI_MIN_FIRST_BURST_LENGTH 0x200
667 #define ISCSI_MIN_MAX_BURST_LENGTH 0x200
668 #define ISCSI_MIN_CONNECTIONS 1
669 #define ISCSI_MIN_MAX_OUTSTANDING_R2T 1
670
671 /*
672 * Maximum values from the iSCSI specification
673 */
674 #define ISCSI_MAX_HEADER_DIGEST 3
675 #define ISCSI_MAX_DATA_DIGEST 3
676 #define ISCSI_MAX_TIME2RETAIN 3600
677 #define ISCSI_MAX_TIME2WAIT 3600
678 #define ISCSI_MAX_ERROR_RECOVERY_LEVEL 2
679 #define ISCSI_MAX_FIRST_BURST_LENGTH 0xffffff
680 #define ISCSI_MAX_BURST_LENGTH 0xffffff
681 #define ISCSI_MAX_CONNECTIONS 65535
682 #define ISCSI_MAX_OUTSTANDING_R2T 65535
683 #define ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH 0xffffff
684 #define ISCSI_MAX_TPGT_VALUE 65535 /* 16 bit numeric */
685
686 /*
687 * iqn and eui name prefixes and related defines
688 */
689 #define ISCSI_IQN_NAME_PREFIX "iqn"
690 #define ISCSI_EUI_NAME_PREFIX "eui"
691 #define ISCSI_EUI_NAME_LEN 20 /* eui. plus 16 octets */
692
693 #ifdef __cplusplus
694 }
695 #endif
696
697 #endif /* _ISCSI_PROTOCOL_H */