2 The header file of iSCSI Protocol that defines many specific data structures.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _ISCSI_PROTO_H_
16 #define _ISCSI_PROTO_H_
19 // RFC 1982 Serial Number Arithmetic, SERIAL_BITS = 32
21 #define ISCSI_SEQ_EQ(s1, s2) ((s1) == (s2))
22 #define ISCSI_SEQ_LT(s1, s2) \
24 (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) < ((UINT32) 1 << 31)) || \
25 (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) > ((UINT32) 1 << 31)) \
27 #define ISCSI_SEQ_GT(s1, s2) \
29 (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) > ((UINT32) 1 << 31)) || \
30 (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) < ((UINT32) 1 << 31)) \
33 #define ISCSI_WELL_KNOWN_PORT 3260
34 #define ISCSI_MAX_CONNS_PER_SESSION 1
36 #define DEFAULT_MAX_RECV_DATA_SEG_LEN 8192
37 #define MAX_RECV_DATA_SEG_LEN_IN_FFP 65536
38 #define DEFAULT_MAX_OUTSTANDING_R2T 1
40 #define ISCSI_VERSION_MAX 0x00
41 #define ISCSI_VERSION_MIN 0x00
43 #define ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
44 #define ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
46 #define ISCSI_REDIRECT_ADDR_START_DELIMITER '['
47 #define ISCSI_REDIRECT_ADDR_END_DELIMITER ']'
49 #define ISCSI_KEY_AUTH_METHOD "AuthMethod"
50 #define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"
51 #define ISCSI_KEY_DATA_DIGEST "DataDigest"
52 #define ISCSI_KEY_MAX_CONNECTIONS "MaxConnections"
53 #define ISCSI_KEY_TARGET_NAME "TargetName"
54 #define ISCSI_KEY_INITIATOR_NAME "InitiatorName"
55 #define ISCSI_KEY_TARGET_ALIAS "TargetAlias"
56 #define ISCSI_KEY_INITIATOR_ALIAS "InitiatorAlias"
57 #define ISCSI_KEY_TARGET_ADDRESS "TargetAddress"
58 #define ISCSI_KEY_INITIAL_R2T "InitialR2T"
59 #define ISCSI_KEY_IMMEDIATE_DATA "ImmediateData"
60 #define ISCSI_KEY_TARGET_PORTAL_GROUP_TAG "TargetPortalGroupTag"
61 #define ISCSI_KEY_MAX_BURST_LENGTH "MaxBurstLength"
62 #define ISCSI_KEY_FIRST_BURST_LENGTH "FirstBurstLength"
63 #define ISCSI_KEY_DEFAULT_TIME2WAIT "DefaultTime2Wait"
64 #define ISCSI_KEY_DEFAULT_TIME2RETAIN "DefaultTime2Retain"
65 #define ISCSI_KEY_MAX_OUTSTANDING_R2T "MaxOutstandingR2T"
66 #define ISCSI_KEY_DATA_PDU_IN_ORDER "DataPDUInOrder"
67 #define ISCSI_KEY_DATA_SEQUENCE_IN_ORDER "DataSequenceInOrder"
68 #define ISCSI_KEY_ERROR_RECOVERY_LEVEL "ErrorRecoveryLevel"
69 #define ISCSI_KEY_SESSION_TYPE "SessionType"
70 #define ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH "MaxRecvDataSegmentLength"
72 #define ISCSI_KEY_VALUE_NONE "None"
75 /// connection state for initiator
78 #define CONN_STATE_FREE 0
79 #define CONN_STATE_XPT_WAIT 1
80 #define CONN_STATE_IN_LOGIN 2
81 #define CONN_STATE_LOGGED_IN 3
82 #define CONN_STATE_IN_LOGOUT 4
83 #define CONN_STATE_LOGOUT_REQUESTED 5
84 #define CONN_STATE_CLEANUP_WAIT 6
85 #define CONN_STATE_IN_CLEANUP 7
88 /// session state for initiator
90 #define SESSION_STATE_FREE 0
91 #define SESSION_STATE_LOGGED_IN 1
92 #define SESSION_STATE_FAILED 2
94 #define ISCSI_RESERVED_TAG 0xffffffff
96 #define ISCSI_REQ_IMMEDIATE 0x40
97 #define ISCSI_OPCODE_MASK 0x3F
99 #define ISCSI_SET_OPCODE(PduHdr, Op, Flgs) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) = ((Op) | (Flgs)))
100 #define ISCSI_GET_OPCODE(PduHdr) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) & ISCSI_OPCODE_MASK)
101 #define ISCSI_CHECK_OPCODE(PduHdr, Op) ((((PduHdr)->OpCode) & ISCSI_OPCODE_MASK) == (Op))
102 #define ISCSI_IMMEDIATE_ON(PduHdr) ((PduHdr)->OpCode & ISCSI_REQ_IMMEDIATE)
103 #define ISCSI_SET_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags |= (BOOLEAN)(Flag))
104 #define ISCSI_CLEAR_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags &= ~(Flag))
105 #define ISCSI_FLAG_ON(PduHdr, Flag) ((BOOLEAN) ((((ISCSI_BASIC_HEADER *) (PduHdr))->Flags & (Flag)) == (Flag)))
106 #define ISCSI_SET_STAGES(PduHdr, Cur, Nxt) ((PduHdr)->Flags = (UINT8) ((PduHdr)->Flags | ((Cur) << 2 | (Nxt))))
107 #define ISCSI_GET_CURRENT_STAGE(PduHdr) ((UINT8) (((PduHdr)->Flags >> 2) & 0x3))
108 #define ISCSI_GET_NEXT_STAGE(PduHdr) ((UINT8) (((PduHdr)->Flags) & 0x3))
110 #define ISCSI_GET_PAD_LEN(DataLen) ((~(DataLen) + 1) & 0x3)
111 #define ISCSI_ROUNDUP(DataLen) (((DataLen) + 3) &~(0x3))
113 #define HTON24(Dst, Src) \
115 (Dst)[0] = (UINT8) ((UINT8) ((Src) >> 16) & 0xFF); \
116 (Dst)[1] = (UINT8) ((UINT8) ((Src) >> 8) & 0xFF); \
117 (Dst)[2] = (UINT8) ((UINT8) (Src) & 0xFF); \
120 #define NTOH24(src) (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))
122 #define ISCSI_GET_DATASEG_LEN(PduHdr) NTOH24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength)
123 #define ISCSI_SET_DATASEG_LEN(PduHdr, Len) HTON24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength, (Len))
124 #define ISCSI_GET_BUFFER_OFFSET(PduHdr) NTOHL (((ISCSI_SCSI_DATA_IN *) (PduHdr))->BufferOffset)
127 // Initiator opcodes.
129 #define ISCSI_OPCODE_NOP_OUT 0x00
130 #define ISCSI_OPCODE_SCSI_CMD 0x01
131 #define ISCSI_OPCODE_SCSI_TMF_REQ 0x02
132 #define ISCSI_OPCODE_LOGIN_REQ 0x03
133 #define ISCSI_OPCODE_TEXT_REQ 0x04
134 #define ISCSI_OPCODE_SCSI_DATA_OUT 0x05
135 #define ISCSI_OPCODE_LOGOUT_REQ 0x06
136 #define ISCSI_OPCODE_SNACK_REQ 0x10
137 #define ISCSI_OPCODE_VENDOR_I0 0x1c
138 #define ISCSI_OPCODE_VENDOR_I1 0x1d
139 #define ISCSI_OPCODE_VENDOR_I2 0x1e
144 #define ISCSI_OPCODE_NOP_IN 0x20
145 #define ISCSI_OPCODE_SCSI_RSP 0x21
146 #define ISCSI_OPCODE_SCSI_TMF_RSP 0x22
147 #define ISCSI_OPCODE_LOGIN_RSP 0x23
148 #define ISCSI_OPCODE_TEXT_RSP 0x24
149 #define ISCSI_OPCODE_SCSI_DATA_IN 0x25
150 #define ISCSI_OPCODE_LOGOUT_RSP 0x26
151 #define ISCSI_OPCODE_R2T 0x31
152 #define ISCSI_OPCODE_ASYNC_MSG 0x32
153 #define ISCSI_OPCODE_VENDOR_T0 0x3c
154 #define ISCSI_OPCODE_VENDOR_T1 0x3d
155 #define ISCSI_OPCODE_VENDOR_T2 0x3e
156 #define ISCSI_OPCODE_REJECT 0x3f
158 #define ISCSI_BHS_FLAG_FINAL 0x80
161 // Defined AHS types, others are reserved.
163 #define ISCSI_AHS_TYPE_EXT_CDB 0x1
164 #define ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN 0x2
166 #define SCSI_CMD_PDU_FLAG_READ 0x40
167 #define SCSI_CMD_PDU_FLAG_WRITE 0x20
169 #define ISCSI_CMD_PDU_TASK_ATTR_MASK 0x07
174 #define ISCSI_TASK_ATTR_UNTAGGED 0x00
175 #define ISCSI_TASK_ATTR_SIMPLE 0x01
176 #define ISCSI_TASK_ATTR_ORDERD 0x02
177 #define ISCSI_TASK_ATTR_HOQ 0x03
178 #define ISCSI_TASK_ATTR_ACA 0x04
181 // Flag bit definitions in SCSI response.
183 #define SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW 0x10
184 #define SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW 0x08
185 #define SCSI_RSP_PDU_FLAG_OVERFLOW 0x04
186 #define SCSI_RSP_PDU_FLAG_UNDERFLOW 0x02
189 // iSCSI service response codes.
191 #define ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET 0x00
192 #define ISCSI_SERVICE_RSP_TARGET_FAILURE 0x01
194 #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_COMPLETE 0
195 #define ISCSI_TMF_RSP_PDU_RSP_TASK_NOT_EXIST 1
196 #define ISCSI_TMF_RSP_PDU_RSP_LUN_NOT_EXIST 2
197 #define ISCSI_TMF_RSP_PDU_RSP_TASK_STILL_ALLEGIANT 3
198 #define ISCSI_TMF_RSP_PDU_RSP_TASK_REASSGIN_NOT_SUPPORTED 4
199 #define ISCSI_TMF_RSP_PDU_RSP_NOT_SUPPORTED 5
200 #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_AHTH_FAILED 6
201 #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_REJECTED 255
203 #define SCSI_DATA_IN_PDU_FLAG_ACKKNOWLEDGE 0x40
204 #define SCSI_DATA_IN_PDU_FLAG_OVERFLOW SCSI_RSP_PDU_FLAG_OVERFLOW
205 #define SCSI_DATA_IN_PDU_FLAG_UNDERFLOW SCSI_RSP_PDU_FLAG_UNDERFLOW
206 #define SCSI_DATA_IN_PDU_FLAG_STATUS_VALID 0x01
208 #define ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT 0x80
209 #define ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE 0x40
211 #define ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT
212 #define ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE
214 #define ISCSI_LOGIN_STATUS_SUCCESS 0
215 #define ISCSI_LOGIN_STATUS_REDIRECTION 1
216 #define ISCSI_LOGIN_STATUS_INITIATOR_ERROR 2
217 #define ISCSI_LOGIN_STATUS_TARGET_ERROR 3
219 #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
220 #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
221 #define ISCSI_LOGOUT_REASON_REMOVE_CONNECTION_FOR_RECOVERY 2
223 #define ISCSI_LOGOUT_RESPONSE_SESSION_CLOSED_SUCCESS 0
224 #define ISCSI_LOGOUT_RESPONSE_CID_NOT_FOUND 1
225 #define ISCSI_LOGOUT_RESPONSE_RECOVERY_NOT_SUPPORTED 2
226 #define ISCSI_LOGOUT_RESPONSE_CLEANUP_FAILED 3
228 #define ISCSI_SNACK_REQUEST_TYPE_DATA_OR_R2T 0
229 #define ISCSI_SNACK_REQUEST_TYPE_STATUS 1
230 #define ISCSI_SNACK_REQUEST_TYPE_DATA_ACK 2
231 #define ISCSI_SNACK_REQUEST_TYPE_RDATA 3
233 #define ISCSI_SECURITY_NEGOTIATION 0
234 #define ISCSI_LOGIN_OPERATIONAL_NEGOTIATION 1
235 #define ISCSI_FULL_FEATURE_PHASE 3
237 typedef struct _ISCSI_SESSION ISCSI_SESSION
;
238 typedef struct _ISCSI_CONNECTION ISCSI_CONNECTION
;
247 /// iSCSI Basic Header Segment
249 typedef struct _ISCSI_BASIC_HEADER
{
252 UINT16 OpCodeSpecific1
;
253 UINT8 TotalAHSLength
;
254 UINT8 DataSegmentLength
[3];
256 UINT32 InitiatorTaskTag
;
257 UINT32 OpCodeSpecific2
[7];
258 } ISCSI_BASIC_HEADER
;
260 typedef struct _ISCSI_ADDTIONAL_HEADER
{
263 UINT8 TypeSpecific
[1];
264 } ISCSI_ADDITIONAL_HEADER
;
266 typedef struct _ISCSI_BI_EXP_READ_DATA_LEN_AHS
{
270 UINT32 ExpReadDataLength
;
271 } ISCSI_BI_EXP_READ_DATA_LEN_AHS
;
276 typedef struct _SCSI_COMMAND
{
280 UINT8 TotalAHSLength
;
281 UINT8 DataSegmentLength
[3];
283 UINT32 InitiatorTaskTag
;
284 UINT32 ExpDataXferLength
;
293 typedef struct _SCSI_RESPONSE
{
298 UINT8 TotalAHSLength
;
299 UINT8 DataSegmentLength
[3];
301 UINT32 InitiatorTaskTag
;
307 UINT32 BiReadResidualCount
;
308 UINT32 ResidualCount
;
311 typedef struct _ISCSI_SENSE_DATA
{
317 /// iSCSI Task Managment Function Request.
319 typedef struct _ISCSI_TMF_REQUEST
{
323 UINT8 TotalAHSLength
;
324 UINT8 DataSegmentLength
[3];
326 UINT32 InitiatorTaskTag
;
327 UINT32 ReferencedTaskTag
;
336 /// iSCSI Task Management Function Response.
338 typedef struct _ISCSI_TMF_RESPONSE
{
343 UINT8 TotalAHSLength
;
344 UINT8 DataSegmentLength
[3];
346 UINT32 InitiatorTaskTag
;
352 } ISCSI_TMF_RESPONSE
;
357 typedef struct _ISCSI_SCSI_DATA_OUT
{
360 UINT8 TotalAHSLength
;
361 UINT8 DataSegmentLength
[3];
363 UINT32 InitiatorTaskTag
;
364 UINT32 TargetTransferTag
;
371 } ISCSI_SCSI_DATA_OUT
;
376 typedef struct _ISCSI_SCSI_DATA_IN
{
381 UINT8 TotalAHSLength
;
382 UINT8 DataSegmentLength
[3];
384 UINT32 InitiatorTaskTag
;
385 UINT32 TargetTransferTag
;
391 UINT32 ResidualCount
;
392 } ISCSI_SCSI_DATA_IN
;
395 /// Ready To Transfer.
397 typedef struct _ISCSI_READY_TO_TRANSFER
{
400 UINT8 TotalAHSLength
;
401 UINT8 DataSegmentLength
[3];
403 UINT32 InitiatorTaskTag
;
404 UINT32 TargetTransferTag
;
410 UINT32 DesiredDataTransferLength
;
411 } ISCSI_READY_TO_TRANSFER
;
413 typedef struct _ISCSI_ASYNC_MESSAGE
{
416 UINT8 TotalAHSLength
;
417 UINT8 DataSegmentLength
[3];
419 UINT32 InitiatorTaskTag
;
430 } ISCSI_ASYNC_MESSAGE
;
435 typedef struct _ISCSI_LOGIN_REQUEST
{
440 UINT8 TotalAHSLength
;
441 UINT8 DataSegmentLength
[3];
444 UINT32 InitiatorTaskTag
;
450 } ISCSI_LOGIN_REQUEST
;
455 typedef struct _ISCSI_LOGIN_RESPONSE
{
460 UINT8 TotalAHSLength
;
461 UINT8 DataSegmentLength
[3];
464 UINT32 InitiatorTaskTag
;
472 } ISCSI_LOGIN_RESPONSE
;
477 typedef struct _ISCSI_LOGOUT_REQUEST
{
481 UINT8 TotalAHSLength
;
482 UINT8 DataSegmentLength
[3];
484 UINT32 InitiatorTaskTag
;
490 } ISCSI_LOGOUT_REQUEST
;
495 typedef struct _ISCSI_LOGOUT_RESPONSE
{
500 UINT8 TotalAHSLength
;
501 UINT8 DataSegmentLength
[3];
503 UINT32 InitiatorTaskTag
;
512 } ISCSI_LOGOUT_RESPONSE
;
517 typedef struct _ISCSI_SNACK_REQUEST
{
521 UINT8 TotalAHSLength
;
522 UINT8 DataSegmentLength
[3];
524 UINT32 InitiatorTaskTag
;
525 UINT32 TargetTransferTag
;
531 } ISCSI_SNACK_REQUEST
;
536 typedef struct _ISCSI_REJECT
{
541 UINT8 TotalAHSLength
;
542 UINT8 DataSegmentLength
[3];
544 UINT32 InitiatorTaskTag
;
556 typedef struct _ISCSI_NOP_OUT
{
559 UINT8 TotalAHSLength
;
560 UINT8 DataSegmentLength
[3];
562 UINT32 InitiatorTaskTag
;
563 UINT32 TargetTransferTag
;
572 typedef struct _ISCSI_NOP_IN
{
575 UINT8 TotalAHSLength
;
576 UINT8 DataSegmentLength
[3];
578 UINT32 InitiatorTaskTag
;
579 UINT32 TargetTransferTag
;
591 typedef struct _ISCSI_XFER_CONTEXT
{
592 UINT32 TargetTransferTag
;
594 UINT32 DesiredLength
;
596 } ISCSI_XFER_CONTEXT
;
598 typedef struct _ISCSI_IN_BUFFER_CONTEXT
{
601 } ISCSI_IN_BUFFER_CONTEXT
;
603 typedef struct _ISCSI_TCB
{
606 BOOLEAN SoFarInOrder
;
608 BOOLEAN FbitReceived
;
613 UINT32 InitiatorTaskTag
;
617 ISCSI_XFER_CONTEXT XferContext
;
619 ISCSI_CONNECTION
*Conn
;
622 typedef struct _ISCSI_KEY_VALUE_PAIR
{
627 } ISCSI_KEY_VALUE_PAIR
;
630 Attach the iSCSI connection to the iSCSI session.
632 @param[in, out] Session The iSCSI session.
633 @param[in, out] Conn The iSCSI connection.
637 IScsiAttatchConnection (
638 IN OUT ISCSI_SESSION
*Session
,
639 IN OUT ISCSI_CONNECTION
*Conn
643 Detach the iSCSI connection from the session it belongs to.
645 @param[in, out] Conn The iSCSI connection.
649 IScsiDetatchConnection (
650 IN OUT ISCSI_CONNECTION
*Conn
654 This function performs the iSCSI connection login.
656 @param[in, out] Conn The iSCSI connection to login.
657 @param Timeout The timeout value in milliseconds.
659 @retval EFI_SUCCESS The iSCSI connection is logged into the iSCSI target.
660 @retval EFI_TIMEOUT Timeout occurred during the login procedure.
661 @retval Others Other errors as indicated.
666 IN OUT ISCSI_CONNECTION
*Conn
,
671 Create a TCP connection for the iSCSI session.
673 @param[in] Session Points to the iSCSI session.
675 @return The newly created iSCSI connection.
679 IScsiCreateConnection (
680 IN ISCSI_SESSION
*Session
684 Destroy an iSCSI connection.
686 @param[in] Conn The connection to destroy.
690 IScsiDestroyConnection (
691 IN ISCSI_CONNECTION
*Conn
695 Login the iSCSI session.
697 @param[in] Session The iSCSI session
699 @retval EFI_SUCCESS The iSCSI session login procedure finished.
700 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
701 @retval EFI_NO_MEDIA There was a media error.
702 @retval Others Other errors as indicated.
707 IN ISCSI_SESSION
*Session
711 Wait for IPsec negotiation, then try to login the iSCSI session again.
713 @param[in] Session The iSCSI session
715 @retval EFI_SUCCESS The iSCSI session login procedure finished.
716 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
717 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
721 IScsiSessionReLogin (
722 IN ISCSI_SESSION
*Session
726 Build and send the iSCSI login request to the iSCSI target according to
727 the current login stage.
729 @param[in] Conn The connection in the iSCSI login phase.
731 @retval EFI_SUCCESS The iSCSI login request PDU is built and sent on this
733 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
734 @retval EFI_DEVICE_ERROR Some kind of device error happened.
739 IN ISCSI_CONNECTION
*Conn
743 Receive and process the iSCSI login response.
745 @param[in] Conn The connection in the iSCSI login phase.
747 @retval EFI_SUCCESS The iSCSI login response PDU is received and processed.
748 @retval Others Other errors as indicated.
752 IScsiReceiveLoginRsp (
753 IN ISCSI_CONNECTION
*Conn
757 Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU.
758 The DataSegmentLength and the actual size of the net buffer containing this PDU will be
761 @param[in, out] Pdu The iSCSI PDU whose data segment the key-value pair will
763 @param[in] Key The key name string.
764 @param[in] Value The value string.
766 @retval EFI_SUCCESS The key-valu pair is added to the PDU's datasegment and
767 the correspondence length fields are updated.
768 @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to add the key-value
772 IScsiAddKeyValuePair (
779 Prepare the iSCSI login request to be sent according to the current login status.
781 @param[in, out] Conn The connection in the iSCSI login phase.
783 @return The pointer to the net buffer containing the iSCSI login request built.
784 @retval NULL Other errors as indicated.
788 IScsiPrepareLoginReq (
789 IN OUT ISCSI_CONNECTION
*Conn
793 Process the iSCSI Login Response.
795 @param[in, out] Conn The connection on which the iSCSI login response is received.
796 @param[in, out] Pdu The iSCSI login response PDU.
798 @retval EFI_SUCCESS The iSCSI login response PDU is processed and all check are passed.
799 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
800 @retval EFI_MEDIA_CHANGED Target is redirected.
801 @retval Others Other errors as indicated.
805 IScsiProcessLoginRsp (
806 IN OUT ISCSI_CONNECTION
*Conn
,
811 Updated the target information according the data received in the iSCSI
812 login response with an target redirection status.
814 @param[in, out] Session The iSCSI session.
815 @param[in] Data The data segment which should contain the
816 TargetAddress key-value list.
817 @param[in] Len Length of the data.
819 @retval EFI_SUCCESS The target address is updated.
820 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
821 @retval EFI_NOT_FOUND The TargetAddress key is not found.
822 @retval Others Other errors as indicated.
826 IScsiUpdateTargetAddress (
827 IN OUT ISCSI_SESSION
*Session
,
833 The callback function to free the net buffer list.
835 @param[in] Arg The opaque parameter.
845 Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and
846 an optional data segment. The two parts will be put into two blocks of buffers in the
847 net buffer. The digest check will be conducted in this function if needed and the digests
848 will be trimmed from the PDU buffer.
850 @param[in] Conn The iSCSI connection to receive data from.
851 @param[out] Pdu The received iSCSI pdu.
852 @param[in] Context The context used to describe information on the caller provided
853 buffer to receive data segment of the iSCSI pdu, it's optional.
854 @param[in] HeaderDigest Whether there will be header digest received.
855 @param[in] DataDigest Whether there will be data digest.
856 @param[in] TimeoutEvent The timeout event, it's optional.
858 @retval EFI_SUCCESS An iSCSI pdu is received.
859 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
860 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error occurred.
861 @retval Others Other errors as indicated.
866 IN ISCSI_CONNECTION
*Conn
,
868 IN ISCSI_IN_BUFFER_CONTEXT
*Context
, OPTIONAL
869 IN BOOLEAN HeaderDigest
,
870 IN BOOLEAN DataDigest
,
871 IN EFI_EVENT TimeoutEvent OPTIONAL
875 Check and get the result of the parameter negotiation.
877 @param[in, out] Conn The connection in iSCSI login.
879 @retval EFI_SUCCESS The parmeter check is passed and negotiation is finished.
880 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error occurred.
881 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
886 IN OUT ISCSI_CONNECTION
*Conn
890 Fill the operational parameters.
892 @param[in] Conn The connection in iSCSI login.
893 @param[in, out] Pdu The iSCSI login request PDU to fill the parameters.
898 IN ISCSI_CONNECTION
*Conn
,
903 Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
905 @param[in, out] Pdu The iSCSI pdu which contains segments to pad.
906 @param[in] Len The length of the last semgnet in the PDU.
908 @retval EFI_SUCCESS The segment is padded or no need to pad it.
909 @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space to add the
919 Build a key-value list from the data segment.
921 @param[in] Data The data segment containing the key-value pairs.
922 @param[in] Len Length of the data segment.
924 @return The key-value list.
925 @retval NULL Other errors as indicated.
929 IScsiBuildKeyValueList (
935 Get the value string by the key name from the key-value list. If found,
936 the key-value entry will be removed from the list.
938 @param[in, out] KeyValueList The key-value list.
939 @param[in] Key The key name to find.
941 @return The value string.
942 @retval NULL The key value pair can not be found.
946 IScsiGetValueByKeyFromList (
947 IN OUT LIST_ENTRY
*KeyValueList
,
952 Free the key-value list.
954 @param[in] KeyValueList The key-value list.
958 IScsiFreeKeyValueList (
959 IN LIST_ENTRY
*KeyValueList
963 Normalize the iSCSI name according to RFC.
965 @param[in, out] Name The iSCSI name.
966 @param[in] Len length of the iSCSI name.
968 @retval EFI_SUCCESS The iSCSI name is valid and normalized.
969 @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the IQN format.
979 Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
981 @param[in] PassThru The EXT SCSI PASS THRU protocol.
982 @param[in] Target The target ID.
983 @param[in] Lun The LUN.
984 @param[in, out] Packet The request packet containing IO request, SCSI command
985 buffer and buffers to read/write.
987 @retval EFI_SUCCES The SCSI command is executed and the result is updated to
989 @retval EFI_DEVICE_ERROR Session state was not as required.
990 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
991 @retval EFI_NOT_READY The target can not accept new commands.
992 @retval Others Other errors as indicated.
996 IScsiExecuteScsiCommand (
997 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*PassThru
,
1000 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1004 Reinstate the session on some error.
1006 @param[in] Session The iSCSI session
1008 @retval EFI_SUCCES The session is reinstated from some error.
1009 @retval Other Reinstatement failed.
1013 IScsiSessionReinstatement (
1014 IN ISCSI_SESSION
*Session
1018 Initialize some session parameters before login.
1020 @param[in, out] Session The iSCSI session.
1021 @param[in] Recovery Whether the request is from a fresh new start or recovery.
1026 IN OUT ISCSI_SESSION
*Session
,
1031 Abort the iSCSI session, that is, reset all the connection and free the
1034 @param[in, out] Session The iSCSI session.
1039 IN OUT ISCSI_SESSION
*Session