2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2005-2010 Daniel Braniss <danny@cs.huji.ac.il>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 | $Id: iscsi.h 743 2009-08-08 10:54:53Z danny $
36 typedef int boolean_t;
41 #define ISCSIDEV "iscsi"
42 #define ISCSI_MAX_TARGETS 64
50 #define ISCSI_NOP_OUT 0x00
51 #define ISCSI_SCSI_CMD 0x01
52 #define ISCSI_TASK_CMD 0x02
53 #define ISCSI_LOGIN_CMD 0x03
54 #define ISCSI_TEXT_CMD 0x04
55 #define ISCSI_WRITE_DATA 0x05
56 #define ISCSI_LOGOUT_CMD 0x06
57 #define ISCSI_SNACK 0x10
61 #define ISCSI_NOP_IN 0x20
62 #define ISCSI_SCSI_RSP 0x21
63 #define ISCSI_TASK_RSP 0x22
64 #define ISCSI_LOGIN_RSP 0x23
65 #define ISCSI_TEXT_RSP 0x24
66 #define ISCSI_READ_DATA 0x25
67 #define ISCSI_LOGOUT_RSP 0x26
68 #define ISCSI_R2T 0x31
69 #define ISCSI_ASYNC 0x32
70 #define ISCSI_REJECT 0x3f
75 | BHS Basic Header Segment
78 // the order is network byte order!
83 u_char F:1; // Final bit
86 u_int AHSLength:8; // in 4byte words
87 u_int DSLength:24; // in bytes
89 u_int LUN[2]; // or Opcode-specific fields
91 u_int OpcodeSpecificFields[7];
92 #define CmdSN OpcodeSpecificFields[1]
93 #define ExpStSN OpcodeSpecificFields[2]
94 #define MaxCmdSN OpcodeSpecificFields[3]
106 // (computers were invented to count, right?)
114 // (computers were invented to count, right?)
120 typedef struct scsi_req {
121 u_char opcode:6; // 0x01
130 #define iSCSI_TASK_UNTAGGED 0
131 #define iSCSI_TASK_SIMPLE 1
132 #define iSCSI_TASK_ORDER 2
133 #define iSCSI_TASK_HOFQ 3
134 #define iSCSI_TASK_ACA 4
139 int edtlen; // expectect data transfere length
145 typedef struct scsi_rsp {
157 int bdrcnt; // bidirectional residual count
158 int rcnt; // residual count
161 typedef struct nop_out {
162 // the order is network byte order!
167 u_char F:1; // Final bit
178 typedef struct nop_in {
179 // the order is network byte order!
184 u_char F:1; // Final bit
201 u_char F:1; // Final bit
214 typedef struct data_out {
219 u_char F:1; // Final bit
227 u_int dsn; // data seq. number
232 typedef struct data_in {
242 u_char F:1; // Final bit
256 typedef struct reject {
266 u_int tt[2]; // must be -1
268 u_int dataSN; // or R2TSN or reserved
272 typedef struct async {
281 u_int itt; // must be -1
295 typedef struct login_req {
307 int len; // remapped via standard bhs
310 int itt; // Initiator Task Tag;
320 typedef struct login_rsp {
331 int len; // remapped via standard bhs
334 int itt; // Initiator Task Tag;
342 typedef struct text_req {
346 u_char C:1; // Continuation
351 int itt; // Initiator Task Tag
353 int ttt; // Target Transfer Tag
359 typedef struct logout_req {
361 u_char reason; // 0 - close session
362 // 1 - close connection
363 // 2 - remove the connection for recovery
368 int itt; // Initiator Task Tag;
378 typedef struct logout_rsp {
419 | in-core version of a Protocol Data Unit
423 u_int hdr_dig; // header digest
427 u_int ahs_size; // the allocated size
431 u_int ds_size; // the allocated size
432 u_int ds_dig; // data digest
435 typedef struct opvals {
442 int maxRecvDataSegmentLength;
443 int maxXmitDataSegmentLength; // pseudo ...
445 int firstBurstLength;
446 int defaultTime2Wait;
447 int defaultTime2Retain;
448 int maxOutstandingR2T;
449 int errorRecoveryLevel;
450 int targetPortalGroupTag;
452 boolean_t initialR2T;
453 boolean_t immediateData;
454 boolean_t dataPDUInOrder;
455 boolean_t dataSequenceInOrder;
464 char *initiatorAlias;
481 #define ISCSISETSES _IOR('i', 1, int)
482 #define ISCSISETSOC _IOW('i', 2, int)
483 #define ISCSISETOPT _IOW('i', 5, isc_opt_t)
484 #define ISCSIGETOPT _IOR('i', 6, isc_opt_t)
486 #define ISCSISEND _IOW('i', 10, pdu_t)
487 #define ISCSIRECV _IOWR('i', 11, pdu_t)
489 #define ISCSIPING _IO('i', 20)
490 #define ISCSISIGNAL _IOW('i', 21, int *)
492 #define ISCSISTART _IO('i', 30)
493 #define ISCSIRESTART _IO('i', 31)
494 #define ISCSISTOP _IO('i', 32)
496 typedef struct iscsi_cam {
498 target_id_t target_id;
502 #define ISCSIGETCAM _IOR('i', 33, iscsi_cam_t)