2 * Copyright (C) 2002-2003 Ardis Technolgies <roman@ardistech.com>
4 * Released under the terms of the GNU GPL v2.0.
7 #ifndef __ISCSI_HDR_H__
8 #define __ISCSI_HDR_H__
10 #include <linux/types.h>
11 #include <asm/byteorder.h>
13 #define ISCSI_VERSION 0
15 #define __packed __attribute__ ((packed))
21 #if defined(__BIG_ENDIAN_BITFIELD)
23 unsigned ahslength : 8;
24 unsigned datalength : 24;
26 #elif defined(__LITTLE_ENDIAN_BITFIELD)
35 u32 spec3[3]; /* 36 */
38 /* Opcode encoding bits */
39 #define ISCSI_OP_RETRY 0x80
40 #define ISCSI_OP_IMMEDIATE 0x40
41 #define ISCSI_OPCODE_MASK 0x3F
43 /* Client to Server Message Opcode values */
44 #define ISCSI_OP_NOOP_OUT 0x00
45 #define ISCSI_OP_SCSI_CMD 0x01
46 #define ISCSI_OP_SCSI_TASK_MGT_MSG 0x02
47 #define ISCSI_OP_LOGIN_CMD 0x03
48 #define ISCSI_OP_TEXT_CMD 0x04
49 #define ISCSI_OP_SCSI_DATA_OUT 0x05
50 #define ISCSI_OP_LOGOUT_CMD 0x06
51 #define ISCSI_OP_SNACK_CMD 0x10
53 #define ISCSI_OP_VENDOR1_CMD 0x1c
54 #define ISCSI_OP_VENDOR2_CMD 0x1d
55 #define ISCSI_OP_VENDOR3_CMD 0x1e
56 #define ISCSI_OP_VENDOR4_CMD 0x1f
58 /* Server to Client Message Opcode values */
59 #define ISCSI_OP_NOOP_IN 0x20
60 #define ISCSI_OP_SCSI_RSP 0x21
61 #define ISCSI_OP_SCSI_TASK_MGT_RSP 0x22
62 #define ISCSI_OP_LOGIN_RSP 0x23
63 #define ISCSI_OP_TEXT_RSP 0x24
64 #define ISCSI_OP_SCSI_DATA_IN 0x25
65 #define ISCSI_OP_LOGOUT_RSP 0x26
66 #define ISCSI_OP_R2T 0x31
67 #define ISCSI_OP_ASYNC_MSG 0x32
68 #define ISCSI_OP_REJECT 0x3f
70 struct iscsi_ahs_hdr {
75 #define ISCSI_AHSTYPE_CDB 1
76 #define ISCSI_AHSTYPE_RLENGTH 2
80 u8 isid[6]; /* Initiator Session ID */
81 u16 tsih; /* Target Session ID */
86 struct iscsi_scsi_cmd_hdr {
100 #define ISCSI_CMD_FINAL 0x80
101 #define ISCSI_CMD_READ 0x40
102 #define ISCSI_CMD_WRITE 0x20
103 #define ISCSI_CMD_ATTR_MASK 0x07
104 #define ISCSI_CMD_UNTAGGED 0x00
105 #define ISCSI_CMD_SIMPLE 0x01
106 #define ISCSI_CMD_ORDERED 0x02
107 #define ISCSI_CMD_HEAD_OF_QUEUE 0x03
108 #define ISCSI_CMD_ACA 0x04
110 struct iscsi_cdb_ahdr {
117 struct iscsi_rlength_ahdr {
124 struct iscsi_scsi_rsp_hdr {
138 u32 bi_residual_count;
142 #define ISCSI_FLG_RESIDUAL_UNDERFLOW 0x02
143 #define ISCSI_FLG_RESIDUAL_OVERFLOW 0x04
144 #define ISCSI_FLG_BIRESIDUAL_UNDERFLOW 0x08
145 #define ISCSI_FLG_BIRESIDUAL_OVERFLOW 0x10
147 #define ISCSI_RESPONSE_COMMAND_COMPLETED 0x00
148 #define ISCSI_RESPONSE_TARGET_FAILURE 0x01
150 struct iscsi_sense_data {
155 struct iscsi_task_mgt_hdr {
171 #define ISCSI_FUNCTION_MASK 0x7f
173 #define ISCSI_FUNCTION_ABORT_TASK 1
174 #define ISCSI_FUNCTION_ABORT_TASK_SET 2
175 #define ISCSI_FUNCTION_CLEAR_ACA 3
176 #define ISCSI_FUNCTION_CLEAR_TASK_SET 4
177 #define ISCSI_FUNCTION_LOGICAL_UNIT_RESET 5
178 #define ISCSI_FUNCTION_TARGET_WARM_RESET 6
179 #define ISCSI_FUNCTION_TARGET_COLD_RESET 7
180 #define ISCSI_FUNCTION_TASK_REASSIGN 8
182 struct iscsi_task_rsp_hdr {
198 #define ISCSI_RESPONSE_FUNCTION_COMPLETE 0
199 #define ISCSI_RESPONSE_UNKNOWN_TASK 1
200 #define ISCSI_RESPONSE_UNKNOWN_LUN 2
201 #define ISCSI_RESPONSE_TASK_ALLEGIANT 3
202 #define ISCSI_RESPONSE_FAILOVER_UNSUPPORTED 4
203 #define ISCSI_RESPONSE_FUNCTION_UNSUPPORTED 5
204 #define ISCSI_RESPONSE_NO_AUTHORIZATION 6
205 #define ISCSI_RESPONSE_FUNCTION_REJECTED 255
207 struct iscsi_data_out_hdr {
224 struct iscsi_data_in_hdr {
242 #define ISCSI_FLG_STATUS 0x01
244 struct iscsi_r2t_hdr {
261 struct iscsi_async_msg_hdr {
281 #define ISCSI_ASYNC_SCSI 0
282 #define ISCSI_ASYNC_LOGOUT 1
283 #define ISCSI_ASYNC_DROP_CONNECTION 2
284 #define ISCSI_ASYNC_DROP_SESSION 3
285 #define ISCSI_ASYNC_PARAM_REQUEST 4
286 #define ISCSI_ASYNC_VENDOR 255
288 struct iscsi_text_req_hdr {
302 struct iscsi_text_rsp_hdr {
317 struct iscsi_login_req_hdr {
320 u8 max_version; /* Max. version supported */
321 u8 min_version; /* Min. version supported */
325 u32 itt; /* Initiator Task Tag */
326 u16 cid; /* Connection ID */
333 struct iscsi_login_rsp_hdr {
336 u8 max_version; /* Max. version supported */
337 u8 active_version; /* Active version */
341 u32 itt; /* Initiator Task Tag */
346 u8 status_class; /* see Login RSP ststus classes below */
347 u8 status_detail; /* see Login RSP Status details below */
351 #define ISCSI_FLG_FINAL 0x80
352 #define ISCSI_FLG_TRANSIT 0x80
353 #define ISCSI_FLG_CSG_SECURITY 0x00
354 #define ISCSI_FLG_CSG_LOGIN 0x04
355 #define ISCSI_FLG_CSG_FULL_FEATURE 0x0c
356 #define ISCSI_FLG_CSG_MASK 0x0c
357 #define ISCSI_FLG_NSG_SECURITY 0x00
358 #define ISCSI_FLG_NSG_LOGIN 0x01
359 #define ISCSI_FLG_NSG_FULL_FEATURE 0x03
360 #define ISCSI_FLG_NSG_MASK 0x03
362 /* Login Status response classes */
363 #define ISCSI_STATUS_SUCCESS 0x00
364 #define ISCSI_STATUS_REDIRECT 0x01
365 #define ISCSI_STATUS_INITIATOR_ERR 0x02
366 #define ISCSI_STATUS_TARGET_ERR 0x03
368 /* Login Status response detail codes */
369 /* Class-0 (Success) */
370 #define ISCSI_STATUS_ACCEPT 0x00
372 /* Class-1 (Redirection) */
373 #define ISCSI_STATUS_TGT_MOVED_TEMP 0x01
374 #define ISCSI_STATUS_TGT_MOVED_PERM 0x02
376 /* Class-2 (Initiator Error) */
377 #define ISCSI_STATUS_INIT_ERR 0x00
378 #define ISCSI_STATUS_AUTH_FAILED 0x01
379 #define ISCSI_STATUS_TGT_FORBIDDEN 0x02
380 #define ISCSI_STATUS_TGT_NOT_FOUND 0x03
381 #define ISCSI_STATUS_TGT_REMOVED 0x04
382 #define ISCSI_STATUS_NO_VERSION 0x05
383 #define ISCSI_STATUS_TOO_MANY_CONN 0x06
384 #define ISCSI_STATUS_MISSING_FIELDS 0x07
385 #define ISCSI_STATUS_CONN_ADD_FAILED 0x08
386 #define ISCSI_STATUS_INV_SESSION_TYPE 0x09
387 #define ISCSI_STATUS_SESSION_NOT_FOUND 0x0a
388 #define ISCSI_STATUS_INV_REQ_TYPE 0x0b
390 /* Class-3 (Target Error) */
391 #define ISCSI_STATUS_TARGET_ERROR 0x00
392 #define ISCSI_STATUS_SVC_UNAVAILABLE 0x01
393 #define ISCSI_STATUS_NO_RESOURCES 0x02
395 struct iscsi_logout_req_hdr {
410 struct iscsi_logout_rsp_hdr {
429 struct iscsi_snack_req_hdr {
445 struct iscsi_reject_hdr {
462 #define ISCSI_REASON_NO_FULL_FEATURE_PHASE 0x01
463 #define ISCSI_REASON_DATA_DIGEST_ERROR 0x02
464 #define ISCSI_REASON_DATA_SNACK_REJECT 0x03
465 #define ISCSI_REASON_PROTOCOL_ERROR 0x04
466 #define ISCSI_REASON_UNSUPPORTED_COMMAND 0x05
467 #define ISCSI_REASON_IMMEDIATE_COMMAND_REJECT 0x06
468 #define ISCSI_REASON_TASK_IN_PROGRESS 0x07
469 #define ISCSI_REASON_INVALID_SNACK 0x08
470 #define ISCSI_REASON_NO_BOOKMARK 0x09
471 #define ISCSI_REASON_BOOKMARK_REJECT 0x0a
472 #define ISCSI_REASON_NEGOTIATION_RESET 0x0b
473 #define ISCSI_REASON_WAITING_LOGOUT 0x0c
476 struct iscsi_nop_out_hdr {
490 struct iscsi_nop_in_hdr {
505 #define ISCSI_RESERVED_TAG (0xffffffffU)
507 #endif /* __ISCSI_HDR_H__ */