2 * Copyright (c) 2005-2008 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,v 1.17 2006/12/01 09:10:17 danny Exp danny $
34 typedef int boolean_t;
39 #define ISCSIDEV "iscsi"
41 #define ISCSI_MAX_TARGETS 4 //64
43 #define ISCSI_MAX_LUNS 4
52 #define ISCSI_NOP_OUT 0x00
53 #define ISCSI_SCSI_CMD 0x01
54 #define ISCSI_TASK_CMD 0x02
55 #define ISCSI_LOGIN_CMD 0x03
56 #define ISCSI_TEXT_CMD 0x04
57 #define ISCSI_WRITE_DATA 0x05
58 #define ISCSI_LOGOUT_CMD 0x06
59 #define ISCSI_SNACK 0x10
63 #define ISCSI_NOP_IN 0x20
64 #define ISCSI_SCSI_RSP 0x21
65 #define ISCSI_TASK_RSP 0x22
66 #define ISCSI_LOGIN_RSP 0x23
67 #define ISCSI_TEXT_RSP 0x24
68 #define ISCSI_READ_DATA 0x25
69 #define ISCSI_LOGOUT_RSP 0x26
70 #define ISCSI_R2T 0x31
71 #define ISCSI_ASYNC 0x32
72 #define ISCSI_REJECT 0x3f
77 | BHS Basic Header Segment
80 // the order is network byte order!
85 u_char F:1; // Final bit
88 u_int AHSLength:8; // in 4byte words
89 u_int DSLength:24; // in bytes
91 u_int LUN[2]; // or Opcode-specific fields
93 u_int OpcodeSpecificFields[7];
94 #define CmdSN OpcodeSpecificFields[1]
95 #define ExpStSN OpcodeSpecificFields[2]
96 #define MaxCmdSN OpcodeSpecificFields[3]
108 // (computers were invented to count, right?)
116 // (computers were invented to count, right?)
122 typedef struct scsi_req {
123 u_char opcode:6; // 0x01
132 #define iSCSI_TASK_UNTAGGED 0
133 #define iSCSI_TASK_SIMPLE 1
134 #define iSCSI_TASK_ORDER 2
135 #define iSCSI_TASK_HOFQ 3
136 #define iSCSI_TASK_ACA 4
141 int edtlen; // expectect data transfere length
147 typedef struct scsi_rsp {
159 int bdrcnt; // bidirectional residual count
160 int rcnt; // residual count
163 typedef struct nop_out {
164 // the order is network byte order!
169 u_char F:1; // Final bit
180 typedef struct nop_in {
181 // the order is network byte order!
186 u_char F:1; // Final bit
203 u_char F:1; // Final bit
216 typedef struct data_out {
221 u_char F:1; // Final bit
229 u_int dsn; // data seq. number
234 typedef struct data_in {
244 u_char F:1; // Final bit
258 typedef struct reject {
268 u_int tt[2]; // must be -1
270 u_int dataSN; // or R2TSN or reserved
274 typedef struct async {
283 u_int itt; // must be -1
297 typedef struct login_req {
309 int len; // remapped via standard bhs
312 int itt; // Initiator Task Tag;
322 typedef struct login_rsp {
333 int len; // remapped via standard bhs
336 int itt; // Initiator Task Tag;
344 typedef struct text_req {
348 u_char C:1; // Continuation
353 int itt; // Initiator Task Tag
355 int ttt; // Target Transfer Tag
361 typedef struct logout_req {
363 char reason; // 0 - close session
364 // 1 - close connection
365 // 2 - remove the connection for recovery
370 int itt; // Initiator Task Tag;
380 typedef struct logout_rsp {
421 | in-core version of a Protocol Data Unit
428 u_int ahs_size; // the allocated size
429 u_int hdr_dig; // header digest
433 u_int ds_size; // the allocated size
434 u_int ds_dig; // data digest
437 typedef struct opvals {
444 int maxRecvDataSegmentLength;
445 int maxXmitDataSegmentLength; // pseudo ...
447 int firstBurstLength;
448 int defaultTime2Wait;
449 int defaultTime2Retain;
450 int maxOutstandingR2T;
451 int errorRecoveryLevel;
452 int targetPortalGroupTag;
454 boolean_t initialR2T;
455 boolean_t immediateData;
456 boolean_t dataPDUInOrder;
457 boolean_t dataSequenceInOrder;
466 char *initiatorAlias;
482 #define ISCSISETSES _IOR('i', 1, int)
483 #define ISCSISETSOC _IOW('i', 2, int)
484 #define ISCSISETOPT _IOW('i', 5, isc_opt_t)
485 #define ISCSIGETOPT _IOR('i', 6, isc_opt_t)
487 #define ISCSISEND _IOW('i', 10, pdu_t)
488 #define ISCSIRECV _IOWR('i', 11, pdu_t)
490 #define ISCSIPING _IO('i', 20)
491 #define ISCSISIGNAL _IOW('i', 21, int *)
493 #define ISCSISTART _IO('i', 30)
494 #define ISCSIRESTART _IO('i', 31)
495 #define ISCSISTOP _IO('i', 32)
497 typedef struct iscsi_cam {
499 target_id_t target_id;
501 lun_id_t target_lun[ISCSI_MAX_LUNS];
504 #define ISCSIGETCAM _IOR('i', 33, iscsi_cam_t)