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
26 * $FreeBSD: src/sys/dev/iscsi/initiator/iscsi.h,v 1.2 2008/11/25 07:17:11 scottl Exp $
29 | $Id: iscsi.h,v 1.17 2006/12/01 09:10:17 danny Exp danny $
34 typedef int boolean_t
;
37 #include <sys/objcache.h>
38 #include <bus/cam/cam.h>
39 #include <sys/device.h>
40 #include <sys/bootmaj.h>
42 #define ISCSIDEV "iscsi"
44 #define ISCSI_CDEV_MAJOR 115
46 #define ISCSI_MAX_TARGETS 4 //64
48 #define ISCSI_MAX_LUNS 4
57 #define ISCSI_NOP_OUT 0x00
58 #define ISCSI_SCSI_CMD 0x01
59 #define ISCSI_TASK_CMD 0x02
60 #define ISCSI_LOGIN_CMD 0x03
61 #define ISCSI_TEXT_CMD 0x04
62 #define ISCSI_WRITE_DATA 0x05
63 #define ISCSI_LOGOUT_CMD 0x06
64 #define ISCSI_SNACK 0x10
68 #define ISCSI_NOP_IN 0x20
69 #define ISCSI_SCSI_RSP 0x21
70 #define ISCSI_TASK_RSP 0x22
71 #define ISCSI_LOGIN_RSP 0x23
72 #define ISCSI_TEXT_RSP 0x24
73 #define ISCSI_READ_DATA 0x25
74 #define ISCSI_LOGOUT_RSP 0x26
75 #define ISCSI_R2T 0x31
76 #define ISCSI_ASYNC 0x32
77 #define ISCSI_REJECT 0x3f
82 | BHS Basic Header Segment
85 // the order is network byte order!
90 u_char F
:1; // Final bit
93 u_int AHSLength
:8; // in 4byte words
94 u_int DSLength
:24; // in bytes
96 u_int LUN
[2]; // or Opcode-specific fields
98 u_int OpcodeSpecificFields
[7];
99 #define CmdSN OpcodeSpecificFields[1]
100 #define ExpStSN OpcodeSpecificFields[2]
101 #define MaxCmdSN OpcodeSpecificFields[3]
113 // (computers were invented to count, right?)
121 // (computers were invented to count, right?)
127 typedef struct scsi_req
{
128 u_char opcode
:6; // 0x01
137 #define iSCSI_TASK_UNTAGGED 0
138 #define iSCSI_TASK_SIMPLE 1
139 #define iSCSI_TASK_ORDER 2
140 #define iSCSI_TASK_HOFQ 3
141 #define iSCSI_TASK_ACA 4
146 int edtlen
; // expectect data transfere length
152 typedef struct scsi_rsp
{
164 int bdrcnt
; // bidirectional residual count
165 int rcnt
; // residual count
168 typedef struct nop_out
{
169 // the order is network byte order!
174 u_char F
:1; // Final bit
185 typedef struct nop_in
{
186 // the order is network byte order!
191 u_char F
:1; // Final bit
208 u_char F
:1; // Final bit
221 typedef struct data_out
{
226 u_char F
:1; // Final bit
234 u_int dsn
; // data seq. number
239 typedef struct data_in
{
249 u_char F
:1; // Final bit
263 typedef struct reject
{
273 u_int tt
[2]; // must be -1
275 u_int dataSN
; // or R2TSN or reserved
279 typedef struct async
{
288 u_int itt
; // must be -1
302 typedef struct login_req
{
314 int len
; // remapped via standard bhs
317 int itt
; // Initiator Task Tag;
327 typedef struct login_rsp
{
338 int len
; // remapped via standard bhs
341 int itt
; // Initiator Task Tag;
349 typedef struct text_req
{
353 u_char C
:1; // Continuation
358 int itt
; // Initiator Task Tag
360 int ttt
; // Target Transfer Tag
366 typedef struct logout_req
{
368 char reason
; // 0 - close session
369 // 1 - close connection
370 // 2 - remove the connection for recovery
375 int itt
; // Initiator Task Tag;
385 typedef struct logout_rsp
{
426 | in-core version of a Protocol Data Unit
433 u_int ahs_size
; // the allocated size
434 u_int hdr_dig
; // header digest
438 u_int ds_size
; // the allocated size
439 u_int ds_dig
; // data digest
442 typedef struct opvals
{
449 int maxRecvDataSegmentLength
;
450 int maxXmitDataSegmentLength
; // pseudo ...
452 int firstBurstLength
;
453 int defaultTime2Wait
;
454 int defaultTime2Retain
;
455 int maxOutstandingR2T
;
456 int errorRecoveryLevel
;
457 int targetPortalGroupTag
;
459 boolean_t initialR2T
;
460 boolean_t immediateData
;
461 boolean_t dataPDUInOrder
;
462 boolean_t dataSequenceInOrder
;
471 char *initiatorAlias
;
487 #define ISCSISETSES _IOR('i', 1, int)
488 #define ISCSISETSOC _IOW('i', 2, int)
489 #define ISCSISETOPT _IOW('i', 5, isc_opt_t)
490 #define ISCSIGETOPT _IOR('i', 6, isc_opt_t)
492 #define ISCSISEND _IOW('i', 10, pdu_t)
493 #define ISCSIRECV _IOWR('i', 11, pdu_t)
495 #define ISCSIPING _IO('i', 20)
496 #define ISCSISIGNAL _IOW('i', 21, int *)
498 #define ISCSISTART _IO('i', 30)
499 #define ISCSIRESTART _IO('i', 31)
500 #define ISCSISTOP _IO('i', 32)
502 typedef struct iscsi_cam
{
504 target_id_t target_id
;
506 lun_id_t target_lun
[ISCSI_MAX_LUNS
];
509 #define ISCSIGETCAM _IOR('i', 33, iscsi_cam_t)