2 * Copyright (c) 2005-2010 Daniel Braniss <danny@cs.huji.ac.il>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 | $Id: iscsi.h 743 2009-08-08 10:54:53Z danny $
34 typedef int boolean_t;
39 #define ISCSIDEV "iscsi"
40 #define ISCSI_MAX_TARGETS 64
48 #define ISCSI_NOP_OUT 0x00
49 #define ISCSI_SCSI_CMD 0x01
50 #define ISCSI_TASK_CMD 0x02
51 #define ISCSI_LOGIN_CMD 0x03
52 #define ISCSI_TEXT_CMD 0x04
53 #define ISCSI_WRITE_DATA 0x05
54 #define ISCSI_LOGOUT_CMD 0x06
55 #define ISCSI_SNACK 0x10
59 #define ISCSI_NOP_IN 0x20
60 #define ISCSI_SCSI_RSP 0x21
61 #define ISCSI_TASK_RSP 0x22
62 #define ISCSI_LOGIN_RSP 0x23
63 #define ISCSI_TEXT_RSP 0x24
64 #define ISCSI_READ_DATA 0x25
65 #define ISCSI_LOGOUT_RSP 0x26
66 #define ISCSI_R2T 0x31
67 #define ISCSI_ASYNC 0x32
68 #define ISCSI_REJECT 0x3f
73 | BHS Basic Header Segment
76 // the order is network byte order!
81 u_char F:1; // Final bit
84 u_int AHSLength:8; // in 4byte words
85 u_int DSLength:24; // in bytes
87 u_int LUN[2]; // or Opcode-specific fields
89 u_int OpcodeSpecificFields[7];
90 #define CmdSN OpcodeSpecificFields[1]
91 #define ExpStSN OpcodeSpecificFields[2]
92 #define MaxCmdSN OpcodeSpecificFields[3]
104 // (computers were invented to count, right?)
112 // (computers were invented to count, right?)
118 typedef struct scsi_req {
119 u_char opcode:6; // 0x01
128 #define iSCSI_TASK_UNTAGGED 0
129 #define iSCSI_TASK_SIMPLE 1
130 #define iSCSI_TASK_ORDER 2
131 #define iSCSI_TASK_HOFQ 3
132 #define iSCSI_TASK_ACA 4
137 int edtlen; // expectect data transfere length
143 typedef struct scsi_rsp {
155 int bdrcnt; // bidirectional residual count
156 int rcnt; // residual count
159 typedef struct nop_out {
160 // the order is network byte order!
165 u_char F:1; // Final bit
176 typedef struct nop_in {
177 // the order is network byte order!
182 u_char F:1; // Final bit
199 u_char F:1; // Final bit
212 typedef struct data_out {
217 u_char F:1; // Final bit
225 u_int dsn; // data seq. number
230 typedef struct data_in {
240 u_char F:1; // Final bit
254 typedef struct reject {
264 u_int tt[2]; // must be -1
266 u_int dataSN; // or R2TSN or reserved
270 typedef struct async {
279 u_int itt; // must be -1
293 typedef struct login_req {
305 int len; // remapped via standard bhs
308 int itt; // Initiator Task Tag;
318 typedef struct login_rsp {
329 int len; // remapped via standard bhs
332 int itt; // Initiator Task Tag;
340 typedef struct text_req {
344 u_char C:1; // Continuation
349 int itt; // Initiator Task Tag
351 int ttt; // Target Transfer Tag
357 typedef struct logout_req {
359 char reason; // 0 - close session
360 // 1 - close connection
361 // 2 - remove the connection for recovery
366 int itt; // Initiator Task Tag;
376 typedef struct logout_rsp {
417 | in-core version of a Protocol Data Unit
421 u_int hdr_dig; // header digest
425 u_int ahs_size; // the allocated size
429 u_int ds_size; // the allocated size
430 u_int ds_dig; // data digest
433 typedef struct opvals {
440 int maxRecvDataSegmentLength;
441 int maxXmitDataSegmentLength; // pseudo ...
443 int firstBurstLength;
444 int defaultTime2Wait;
445 int defaultTime2Retain;
446 int maxOutstandingR2T;
447 int errorRecoveryLevel;
448 int targetPortalGroupTag;
450 boolean_t initialR2T;
451 boolean_t immediateData;
452 boolean_t dataPDUInOrder;
453 boolean_t dataSequenceInOrder;
462 char *initiatorAlias;
479 #define ISCSISETSES _IOR('i', 1, int)
480 #define ISCSISETSOC _IOW('i', 2, int)
481 #define ISCSISETOPT _IOW('i', 5, isc_opt_t)
482 #define ISCSIGETOPT _IOR('i', 6, isc_opt_t)
484 #define ISCSISEND _IOW('i', 10, pdu_t)
485 #define ISCSIRECV _IOWR('i', 11, pdu_t)
487 #define ISCSIPING _IO('i', 20)
488 #define ISCSISIGNAL _IOW('i', 21, int *)
490 #define ISCSISTART _IO('i', 30)
491 #define ISCSIRESTART _IO('i', 31)
492 #define ISCSISTOP _IO('i', 32)
494 typedef struct iscsi_cam {
496 target_id_t target_id;
500 #define ISCSIGETCAM _IOR('i', 33, iscsi_cam_t)