2 The header file of IScsi Protocol that defines many specific data structures.
4 Copyright (c) 2004 - 2008, Intel Corporation
5 All rights reserved. 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.
19 Protocol definitions for IScsi driver, mainly from RFC3720.
23 #ifndef _ISCSI_PROTO_H_
24 #define _ISCSI_PROTO_H_
26 #include <Protocol/ScsiPassThruExt.h>
29 // RFC 1982 Serial Number Arithmetic, SERIAL_BITS = 32
31 #define ISCSI_SEQ_EQ(s1, s2) ((s1) == (s2))
32 #define ISCSI_SEQ_LT(s1, s2) \
34 (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) < ((UINT32) 1 << 31)) || \
35 (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) > ((UINT32) 1 << 31)) \
37 #define ISCSI_SEQ_GT(s1, s2) \
39 (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) > ((UINT32) 1 << 31)) || \
40 (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) < ((UINT32) 1 << 31)) \
43 #define ISCSI_WELL_KNOWN_PORT 3260
44 #define ISCSI_MAX_CONNS_PER_SESSION 1
46 #define DEFAULT_MAX_RECV_DATA_SEG_LEN 8192
47 #define MAX_RECV_DATA_SEG_LEN_IN_FFP 65536
48 #define DEFAULT_MAX_OUTSTANDING_R2T 1
50 #define ISCSI_VERSION_MAX 0x00
51 #define ISCSI_VERSION_MIN 0x00
53 #define ISID_BYTE_0 0 // OUI format
55 #define ISID_BYTE_2 0xaa
56 #define ISID_BYTE_3 0x1
58 #define ISCSI_KEY_AUTH_METHOD "AuthMethod"
59 #define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"
60 #define ISCSI_KEY_DATA_DIGEST "DataDigest"
61 #define ISCSI_KEY_MAX_CONNECTIONS "MaxConnections"
62 #define ISCSI_KEY_TARGET_NAME "TargetName"
63 #define ISCSI_KEY_INITIATOR_NAME "InitiatorName"
64 #define ISCSI_KEY_TARGET_ALIAS "TargetAlias"
65 #define ISCSI_KEY_INITIATOR_ALIAS "InitiatorAlias"
66 #define ISCSI_KEY_TARGET_ADDRESS "TargetAddress"
67 #define ISCSI_KEY_INITIAL_R2T "InitialR2T"
68 #define ISCSI_KEY_IMMEDIATE_DATA "ImmediateData"
69 #define ISCSI_KEY_TARGET_PORTAL_GROUP_TAG "TargetPortalGroupTag"
70 #define ISCSI_KEY_MAX_BURST_LENGTH "MaxBurstLength"
71 #define ISCSI_KEY_FIRST_BURST_LENGTH "FirstBurstLength"
72 #define ISCSI_KEY_DEFAULT_TIME2WAIT "DefaultTime2Wait"
73 #define ISCSI_KEY_DEFAULT_TIME2RETAIN "DefaultTime2Retain"
74 #define ISCSI_KEY_MAX_OUTSTANDING_R2T "MaxOutstandingR2T"
75 #define ISCSI_KEY_DATA_PDU_IN_ORDER "DataPDUInOrder"
76 #define ISCSI_KEY_DATA_SEQUENCE_IN_ORDER "DataSequenceInOrder"
77 #define ISCSI_KEY_ERROR_RECOVERY_LEVEL "ErrorRecoveryLevel"
78 #define ISCSI_KEY_SESSION_TYPE "SessionType"
79 #define ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH "MaxRecvDataSegmentLength"
81 #define ISCSI_KEY_VALUE_NONE "None"
84 // connection state for initiator
92 CONN_STATE_LOGOUT_REQUESTED
,
93 CONN_STATE_CLEANUP_WAIT
,
98 // session state for initiator
102 SESSION_STATE_LOGGED_IN
,
112 #define ISCSI_RESERVED_TAG 0xffffffff
114 #define ISCSI_REQ_IMMEDIATE 0x40
115 #define ISCSI_OPCODE_MASK 0x3F
117 #define ISCSI_SET_OPCODE(PduHdr, Op, Flgs) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) = ((Op) | (Flgs)))
118 #define ISCSI_GET_OPCODE(PduHdr) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) & ISCSI_OPCODE_MASK)
119 #define ISCSI_CHECK_OPCODE(PduHdr, Op) ((((PduHdr)->OpCode) & ISCSI_OPCODE_MASK) == (Op))
120 #define ISCSI_IMMEDIATE_ON(PduHdr) ((PduHdr)->OpCode & ISCSI_REQ_IMMEDIATE)
121 #define ISCSI_SET_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags |= (BOOLEAN)(Flag))
122 #define ISCSI_CLEAR_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags &= ~(Flag))
123 #define ISCSI_FLAG_ON(PduHdr, Flag) ((((ISCSI_BASIC_HEADER *) (PduHdr))->Flags & (Flag)) == (Flag))
124 #define ISCSI_SET_STAGES(PduHdr, Cur, Nxt) ((PduHdr)->Flags = (UINT8) ((PduHdr)->Flags | ((Cur) << 2 | (Nxt))))
125 #define ISCSI_GET_CURRENT_STAGE(PduHdr) (((PduHdr)->Flags >> 2) & 0x3)
126 #define ISCSI_GET_NEXT_STAGE(PduHdr) (((PduHdr)->Flags) & 0x3)
128 #define ISCSI_GET_PAD_LEN(DataLen) ((~(DataLen) + 1) & 0x3)
129 #define ISCSI_ROUNDUP(DataLen) (((DataLen) + 3) &~(0x3))
131 #define HTON24(Dst, Src) \
133 (Dst)[0] = (UINT8) (((Src) >> 16) & 0xFF); \
134 (Dst)[1] = (UINT8) (((Src) >> 8) & 0xFF); \
135 (Dst)[2] = (UINT8) ((Src) & 0xFF); \
138 #define NTOH24(src) (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))
140 #define ISCSI_GET_DATASEG_LEN(PduHdr) NTOH24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength)
141 #define ISCSI_SET_DATASEG_LEN(PduHdr, Len) HTON24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength, (Len))
146 #define ISCSI_OPCODE_NOP_OUT 0x00
147 #define ISCSI_OPCODE_SCSI_CMD 0x01
148 #define ISCSI_OPCODE_SCSI_TMF_REQ 0x02
149 #define ISCSI_OPCODE_LOGIN_REQ 0x03
150 #define ISCSI_OPCODE_TEXT_REQ 0x04
151 #define ISCSI_OPCODE_SCSI_DATA_OUT 0x05
152 #define ISCSI_OPCODE_LOGOUT_REQ 0x06
153 #define ISCSI_OPCODE_SNACK_REQ 0x10
154 #define ISCSI_OPCODE_VENDOR_I0 0x1c
155 #define ISCSI_OPCODE_VENDOR_I1 0x1d
156 #define ISCSI_OPCODE_VENDOR_I2 0x1e
161 #define ISCSI_OPCODE_NOP_IN 0x20
162 #define ISCSI_OPCODE_SCSI_RSP 0x21
163 #define ISCSI_OPCODE_SCSI_TMF_RSP 0x22
164 #define ISCSI_OPCODE_LOGIN_RSP 0x23
165 #define ISCSI_OPCODE_TEXT_RSP 0x24
166 #define ISCSI_OPCODE_SCSI_DATA_IN 0x25
167 #define ISCSI_OPCODE_LOGOUT_RSP 0x26
168 #define ISCSI_OPCODE_R2T 0x31
169 #define ISCSI_OPCODE_ASYNC_MSG 0x32
170 #define ISCSI_OPCODE_VENDOR_T0 0x3c
171 #define ISCSI_OPCODE_VENDOR_T1 0x3d
172 #define ISCSI_OPCODE_VENDOR_T2 0x3e
173 #define ISCSI_OPCODE_REJECT 0x3f
175 #define ISCSI_BHS_FLAG_FINAL 0x80
178 // iSCSI Basic Header Segment
180 typedef struct _ISCSI_BASIC_HEADER
{
183 UINT16 OpCodeSpecific1
;
184 UINT8 TotalAHSLength
;
185 UINT8 DataSegmentLength
[3];
187 UINT32 InitiatorTaskTag
;
188 UINT32 OpCodeSpecific2
[7];
189 } ISCSI_BASIC_HEADER
;
192 // Defined AHS types, others are reserved.
194 #define ISCSI_AHS_TYPE_EXT_CDB 0x1
195 #define ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN 0x2
197 typedef struct _ISCSI_ADDTIONAL_HEADER
{
200 UINT8 TypeSpecific
[1];
201 } ISCSI_ADDITIONAL_HEADER
;
203 typedef struct _ISCSI_BI_EXP_READ_DATA_LEN_AHS
{
207 UINT32 ExpReadDataLength
;
208 } ISCSI_BI_EXP_READ_DATA_LEN_AHS
;
210 #define SCSI_CMD_PDU_FLAG_READ 0x40
211 #define SCSI_CMD_PDU_FLAG_WRITE 0x20
213 #define ISCSI_CMD_PDU_TASK_ATTR_MASK 0x07
218 #define ISCSI_TASK_ATTR_UNTAGGED 0x00
219 #define ISCSI_TASK_ATTR_SIMPLE 0x01
220 #define ISCSI_TASK_ATTR_ORDERD 0x02
221 #define ISCSI_TASK_ATTR_HOQ 0x03
222 #define ISCSI_TASK_ATTR_ACA 0x04
227 typedef struct _SCSI_COMMAND
{
231 UINT8 TotalAHSLength
;
232 UINT8 DataSegmentLength
[3];
234 UINT32 InitiatorTaskTag
;
235 UINT32 ExpDataXferLength
;
242 // flag bit definitions in SCSI response
244 #define SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW 0x10
245 #define SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW 0x08
246 #define SCSI_RSP_PDU_FLAG_OVERFLOW 0x04
247 #define SCSI_RSP_PDU_FLAG_UNDERFLOW 0x02
250 // iSCSI service response codes
252 #define ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET 0x00
253 #define ISCSI_SERVICE_RSP_TARGET_FAILURE 0x01
258 typedef struct _SCSI_RESPONSE
{
263 UINT8 TotalAHSLength
;
264 UINT8 DataSegmentLength
[3];
266 UINT32 InitiatorTaskTag
;
272 UINT32 BiReadResidualCount
;
273 UINT32 ResidualCount
;
276 typedef struct _ISCSI_SENSE_DATA
{
282 // iSCSI Task Managment Function Request
284 typedef struct _ISCSI_TMF_REQUEST
{
288 UINT8 TotalAHSLength
;
289 UINT8 DataSegmentLength
[3];
291 UINT32 InitiatorTaskTag
;
292 UINT32 ReferencedTaskTag
;
300 #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_COMPLETE 0
301 #define ISCSI_TMF_RSP_PDU_RSP_TASK_NOT_EXIST 1
302 #define ISCSI_TMF_RSP_PDU_RSP_LUN_NOT_EXIST 2
303 #define ISCSI_TMF_RSP_PDU_RSP_TASK_STILL_ALLEGIANT 3
304 #define ISCSI_TMF_RSP_PDU_RSP_TASK_REASSGIN_NOT_SUPPORTED 4
305 #define ISCSI_TMF_RSP_PDU_RSP_NOT_SUPPORTED 5
306 #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_AHTH_FAILED 6
307 #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_REJECTED 255
310 // iSCSI Task Management Function Response
312 typedef struct _ISCSI_TMF_RESPONSE
{
317 UINT8 TotalAHSLength
;
318 UINT8 DataSegmentLength
[3];
320 UINT32 InitiatorTaskTag
;
326 } ISCSI_TMF_RESPONSE
;
331 typedef struct _ISCSI_SCSI_DATA_OUT
{
334 UINT8 TotalAHSLength
;
335 UINT8 DataSegmentLength
[3];
337 UINT32 InitiatorTaskTag
;
338 UINT32 TargetTransferTag
;
345 } ISCSI_SCSI_DATA_OUT
;
347 #define SCSI_DATA_IN_PDU_FLAG_ACKKNOWLEDGE 0x40
348 #define SCSI_DATA_IN_PDU_FLAG_OVERFLOW SCSI_RSP_PDU_FLAG_OVERFLOW
349 #define SCSI_DATA_IN_PDU_FLAG_UNDERFLOW SCSI_RSP_PDU_FLAG_UNDERFLOW
350 #define SCSI_DATA_IN_PDU_FLAG_STATUS_VALID 0x01
354 typedef struct _ISCSI_SCSI_DATA_IN
{
359 UINT8 TotalAHSLength
;
360 UINT8 DataSegmentLength
[3];
362 UINT32 InitiatorTaskTag
;
363 UINT32 TargetTransferTag
;
369 UINT32 ResidualCount
;
370 } ISCSI_SCSI_DATA_IN
;
372 #define ISCSI_GET_BUFFER_OFFSET(PduHdr) NTOHL (((ISCSI_SCSI_DATA_IN *) (PduHdr))->BufferOffset)
376 typedef struct _ISCSI_READY_TO_TRANSFER
{
379 UINT8 TotalAHSLength
;
380 UINT8 DataSegmentLength
[3];
382 UINT32 InitiatorTaskTag
;
383 UINT32 TargetTransferTag
;
389 UINT32 DesiredDataTransferLength
;
390 } ISCSI_READY_TO_TRANSFER
;
392 typedef struct _ISCSI_ASYNC_MESSAGE
{
395 UINT8 TotalAHSLength
;
396 UINT8 DataSegmentLength
[3];
398 UINT32 InitiatorTaskTag
;
409 } ISCSI_ASYNC_MESSAGE
;
411 #define ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT 0x80
412 #define ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE 0x40
417 typedef struct _ISCSI_LOGIN_REQUEST
{
422 UINT8 TotalAHSLength
;
423 UINT8 DataSegmentLength
[3];
426 UINT32 InitiatorTaskTag
;
432 } ISCSI_LOGIN_REQUEST
;
434 #define ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT
435 #define ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE
437 #define ISCSI_LOGIN_STATUS_SUCCESS 0
438 #define ISCSI_LOGIN_STATUS_REDIRECTION 1
439 #define ISCSI_LOGIN_STATUS_INITIATOR_ERROR 2
440 #define ISCSI_LOGIN_STATUS_TARGET_ERROR 3
445 typedef struct _ISCSI_LOGIN_RESPONSE
{
450 UINT8 TotalAHSLength
;
451 UINT8 DataSegmentLength
[3];
454 UINT32 InitiatorTaskTag
;
462 } ISCSI_LOGIN_RESPONSE
;
464 #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
465 #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
466 #define ISCSI_LOGOUT_REASON_REMOVE_CONNECTION_FOR_RECOVERY 2
471 typedef struct _ISCSI_LOGOUT_REQUEST
{
475 UINT8 TotalAHSLength
;
476 UINT8 DataSegmentLength
[3];
478 UINT32 InitiatorTaskTag
;
484 } ISCSI_LOGOUT_REQUEST
;
486 #define ISCSI_LOGOUT_RESPONSE_SESSION_CLOSED_SUCCESS 0
487 #define ISCSI_LOGOUT_RESPONSE_CID_NOT_FOUND 1
488 #define ISCSI_LOGOUT_RESPONSE_RECOVERY_NOT_SUPPORTED 2
489 #define ISCSI_LOGOUT_RESPONSE_CLEANUP_FAILED 3
494 typedef struct _ISCSI_LOGOUT_RESPONSE
{
499 UINT8 TotalAHSLength
;
500 UINT8 DataSegmentLength
[3];
502 UINT32 InitiatorTaskTag
;
511 } ISCSI_LOGOUT_RESPONSE
;
513 #define ISCSI_SNACK_REQUEST_TYPE_DATA_OR_R2T 0
514 #define ISCSI_SNACK_REQUEST_TYPE_STATUS 1
515 #define ISCSI_SNACK_REQUEST_TYPE_DATA_ACK 2
516 #define ISCSI_SNACK_REQUEST_TYPE_RDATA 3
521 typedef struct _ISCSI_SNACK_REQUEST
{
525 UINT8 TotalAHSLength
;
526 UINT8 DataSegmentLength
[3];
528 UINT32 InitiatorTaskTag
;
529 UINT32 TargetTransferTag
;
535 } ISCSI_SNACK_REQUEST
;
540 typedef struct _ISCSI_REJECT
{
545 UINT8 TotalAHSLength
;
546 UINT8 DataSegmentLength
[3];
548 UINT32 InitiatorTaskTag
;
560 typedef struct _ISCSI_NOP_OUT
{
563 UINT8 TotalAHSLength
;
564 UINT8 DataSegmentLength
[3];
566 UINT32 InitiatorTaskTag
;
567 UINT32 TargetTransferTag
;
576 typedef struct _ISCSI_NOP_IN
{
579 UINT8 TotalAHSLength
;
580 UINT8 DataSegmentLength
[3];
582 UINT32 InitiatorTaskTag
;
583 UINT32 TargetTransferTag
;
590 #define ISCSI_SECURITY_NEGOTIATION 0
591 #define ISCSI_LOGIN_OPERATIONAL_NEGOTIATION 1
592 #define ISCSI_FULL_FEATURE_PHASE 3
599 typedef struct _ISCSI_XFER_CONTEXT
{
600 UINT32 TargetTransferTag
;
602 UINT32 DesiredLength
;
604 } ISCSI_XFER_CONTEXT
;
606 typedef struct _ISCSI_IN_BUFFER_CONTEXT
{
609 } ISCSI_IN_BUFFER_CONTEXT
;
611 typedef struct _ISCSI_TCB
{
614 BOOLEAN SoFarInOrder
;
616 BOOLEAN FbitReceived
;
621 UINT32 InitiatorTaskTag
;
625 ISCSI_XFER_CONTEXT XferContext
;
627 ISCSI_CONNECTION
*Conn
;
630 typedef struct _ISCSI_KEY_VALUE_PAIR
{
635 } ISCSI_KEY_VALUE_PAIR
;
638 // function prototypes.
641 Attach the iSCSI connection to the iSCSI session.
643 @param Session[in] The iSCSI session.
645 @param Conn[in] The iSCSI connection.
651 IScsiAttatchConnection (
652 IN ISCSI_SESSION
*Session
,
653 IN ISCSI_CONNECTION
*Conn
657 Detach the iSCSI connection from the session it belongs to.
659 @param Conn[in] The iSCSI connection.
665 IScsiDetatchConnection (
666 IN ISCSI_CONNECTION
*Conn
670 This function does the iSCSI connection login.
672 @param Conn[in] The iSCSI connection to login.
674 @retval EFI_SUCCESS The iSCSI connection is logged into the iSCSI target.
676 @retval EFI_TIMEOUT Timeout happened during the login procedure.
678 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
683 IN ISCSI_CONNECTION
*Conn
687 Create a TCP connection for the iSCSI session.
689 @param Private[in] The iSCSI driver data.
691 @param Session[in] Maximum CmdSN from the target.
693 @retval The newly created iSCSI connection.
697 IScsiCreateConnection (
698 IN ISCSI_DRIVER_DATA
*Private
,
699 IN ISCSI_SESSION
*Session
703 Destroy an iSCSI connection.
705 @param Conn[in] The connection to destroy.
711 IScsiDestroyConnection (
712 IN ISCSI_CONNECTION
*Conn
716 Login the iSCSI session.
718 @param Private[in] The iSCSI driver data.
720 @retval EFI_SUCCESS The iSCSI session login procedure finished.
722 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
724 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
729 IN ISCSI_DRIVER_DATA
*Private
733 Build and send the iSCSI login request to the iSCSI target according to
734 the current login stage.
736 @param Conn[in] The connection in the iSCSI login phase.
738 @retval EFI_SUCCESS The iSCSI login request PDU is built and sent on this
741 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
743 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
748 IN ISCSI_CONNECTION
*Conn
752 Receive and process the iSCSI login response.
754 @param Conn[in] The connection in the iSCSI login phase.
756 @retval EFI_SUCCESS The iSCSI login response PDU is received and processed.
758 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
760 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
764 IScsiReceiveLoginRsp (
765 IN ISCSI_CONNECTION
*Conn
769 Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU.
770 The DataSegmentLength and the actual size of the net buffer containing this PDU will be
773 @param Pdu[in] The iSCSI PDU whose data segment the key-value pair will
776 @param Key[in] The key name string.
778 @param Value[in] The value string.
780 @retval EFI_SUCCESS The key-valu pair is added to the PDU's datasegment and
781 the correspondence length fields are updated.
783 @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to add the key-value
788 IScsiAddKeyValuePair (
795 Prepare the iSCSI login request to be sent according to the current login status.
797 @param Conn[in] The connection in the iSCSI login phase.
799 @retval The pointer to the net buffer containing the iSCSI login request built.
803 IScsiPrepareLoginReq (
804 IN ISCSI_CONNECTION
*Conn
808 Process the iSCSI Login Response.
810 @param Conn[in] The connection on which the iSCSI login response is received.
812 @param Pdu[in] The iSCSI login response PDU.
814 @retval EFI_SUCCESS The iSCSI login response PDU is processed and all check are passed.
816 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
820 IScsiProcessLoginRsp (
821 IN ISCSI_CONNECTION
*Conn
,
826 Updated the target information according the data received in the iSCSI
827 login response with an target redirection status.
829 @param Session[in] The iSCSI session.
831 @param Data[in] The data segment which should contain the
832 TargetAddress key-value list.
834 @param Len[in] Length of the data.
836 @retval EFI_SUCCESS The target address is updated.
838 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
840 @retval EFI_NOT_FOUND The TargetAddress key is not found.
844 IScsiUpdateTargetAddress (
845 IN ISCSI_SESSION
*Session
,
851 The callback function to free the net buffer list.
853 @param Arg[in] The opaque parameter.
864 Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and
865 an optional data segment. The two parts will be put into two blocks of buffers in the
866 net buffer. The digest check will be conducted in this function if needed and the digests
867 will be trimmed from the PDU buffer.
869 @param Conn[in] The iSCSI connection to receive data from.
871 @param Pdu[out] The received iSCSI pdu.
873 @param Context[in] The context used to describe information on the caller provided
874 buffer to receive data segment of the iSCSI pdu, it's optional.
876 @param HeaderDigest[in] Whether there will be header digest received.
878 @param DataDigest[in] Whether there will be data digest.
880 @param TimeoutEvent[in] The timeout event, it's optional.
882 @retval EFI_SUCCESS An iSCSI pdu is received.
884 @retval EFI_TIMEOUT Timeout happenend.
889 IN ISCSI_CONNECTION
*Conn
,
891 IN ISCSI_IN_BUFFER_CONTEXT
*Context
, OPTIONAL
892 IN BOOLEAN HeaderDigest
,
893 IN BOOLEAN DataDigest
,
894 IN EFI_EVENT TimeoutEvent OPTIONAL
898 Check and get the result of the prameter negotiation.
900 @param Conn[in] The connection in iSCSI login.
902 @param Pdu[in] The iSCSI response PDU containing the parameter list.
904 @retval EFI_SUCCESS The parmeter check is passed and negotiation is finished.
906 @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
911 IN ISCSI_CONNECTION
*Conn
,
916 Fill the oprational prameters.
918 @param Conn[in] The connection in iSCSI login.
920 @param Pdu[in] The iSCSI login request PDU to fill the parameters.
922 @retval EFI_SUCCESS The parmeters are filled into the iSCSI login request PDU.
924 @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to hold the parameters.
929 IN ISCSI_CONNECTION
*Conn
,
934 Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
936 @param Pdu[in] The iSCSI pdu which contains segments to pad.
938 @param Len[in] The length of the last semgnet in the PDU.
940 @retval EFI_SUCCESS The segment is padded or no need to pad it.
942 @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space to add the
953 Build a key-value list from the data segment.
955 @param Data[in] The data segment containing the key-value pairs.
957 @param Len[in] Length of the data segment.
959 @retval The key-value list.
963 IScsiBuildKeyValueList (
969 Get the value string by the key name from the key-value list. If found,
970 the key-value entry will be removed from the list.
972 @param KeyValueList[in] The key-value list.
974 @param Key[in] The key name to find.
976 @retval The value string.
980 IScsiGetValueByKeyFromList (
981 IN LIST_ENTRY
*KeyValueList
,
986 Free the key-value list.
988 @param KeyValueList[in] The key-value list.
994 IScsiFreeKeyValueList (
995 IN LIST_ENTRY
*KeyValueList
999 Normalize the iSCSI name according to RFC.
1001 @param Name[in] The iSCSI name.
1003 @param Len[in] length of the iSCSI name.
1005 @retval EFI_SUCCESS The iSCSI name is valid and normalized.
1007 @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the IQN format.
1011 IScsiNormalizeName (
1017 Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
1019 @param PassThru[in] The EXT SCSI PASS THRU protocol.
1021 @param Target[in] The target ID.
1023 @param Lun[in] The LUN.
1025 @param Packet[in][out] The request packet containing IO request, SCSI command
1026 buffer and buffers to read/write.
1028 @retval EFI_SUCCES The SCSI command is executed and the result is updated to
1031 @retval EFI_DEVICE_ERROR Some unexpected error happened.
1035 IScsiExecuteScsiCommand (
1036 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*PassThru
,
1039 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1043 Reinstate the session on some error.
1045 @param Private[in] The iSCSI driver data.
1047 @retval EFI_SUCCES The session is reinstated from some error.
1049 @retval other Reinstatement failed.
1053 IScsiSessionReinstatement (
1054 IN ISCSI_DRIVER_DATA
*Private
1058 Initialize some session parameters before login.
1060 @param Session[in] The iSCSI session.
1062 @param Recovery[in] Whether the request is from a fresh new start or recovery.
1069 IN ISCSI_SESSION
*Session
,
1074 Abort the iSCSI session, that is, reset all the connection and free the
1077 @param Session[in] The iSCSI session.
1079 @retval EFI_SUCCES The session is aborted.
1084 IN ISCSI_SESSION
*Session