/** @file\r
The implementation of iSCSI protocol based on RFC3720.\r
\r
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
EFI_STATUS Status;\r
NET_BUF *Pdu;\r
\r
+ Pdu = NULL;\r
+\r
//\r
// Receive the iSCSI login response.\r
//\r
//\r
// InitialR2T, result function is OR.\r
//\r
- Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);\r
- if (Value == NULL) {\r
- goto ON_ERROR;\r
- }\r
+ if (!Session->InitialR2T) {\r
+ Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);\r
+ if (Value == NULL) {\r
+ goto ON_ERROR;\r
+ }\r
\r
- Session->InitialR2T = (BOOLEAN) (Session->InitialR2T || (AsciiStrCmp (Value, "Yes") == 0));\r
+ Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);\r
+ }\r
\r
//\r
// ImmediateData, result function is AND.\r
goto ON_ERROR;\r
}\r
\r
- Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (AsciiStrCmp (Value, "Yes") == 0));\r
+ Session->ImmediateData = (BOOLEAN) (Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));\r
\r
//\r
// MaxRecvDataSegmentLength is declarative.\r
// ImmediateData=No.\r
// This Key/Value is negotiation type.\r
//\r
- Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);\r
- if (Value == NULL) {\r
- goto ON_ERROR;\r
- }\r
+ if (!(Session->InitialR2T && !Session->ImmediateData)) {\r
+ Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);\r
+ if (Value == NULL) {\r
+ goto ON_ERROR;\r
+ }\r
\r
- NumericValue = AsciiStrDecimalToUintn (Value);\r
- Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);\r
+ NumericValue = AsciiStrDecimalToUintn (Value);\r
+ Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength, NumericValue);\r
+ }\r
\r
//\r
// MaxConnections, result function is Minimum.\r
//\r
// DataPDUInOrder, result function is OR.\r
//\r
- Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);\r
- if (Value == NULL) {\r
- goto ON_ERROR;\r
- }\r
+ if (!Session->DataPDUInOrder) {\r
+ Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);\r
+ if (Value == NULL) {\r
+ goto ON_ERROR;\r
+ }\r
\r
- Session->DataPDUInOrder = (BOOLEAN) (Session->DataPDUInOrder || (AsciiStrCmp (Value, "Yes") == 0));\r
+ Session->DataPDUInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);\r
+ }\r
\r
//\r
// DataSequenceInorder, result function is OR.\r
//\r
- Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);\r
- if (Value == NULL) {\r
- goto ON_ERROR;\r
- }\r
+ if (!Session->DataSequenceInOrder) {\r
+ Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);\r
+ if (Value == NULL) {\r
+ goto ON_ERROR;\r
+ }\r
\r
- Session->DataSequenceInOrder = (BOOLEAN) (Session->DataSequenceInOrder || (AsciiStrCmp (Value, "Yes") == 0));\r
+ Session->DataSequenceInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);\r
+ }\r
\r
//\r
// DefaultTime2Wait, result function is Maximum.\r
Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T, NumericValue);\r
\r
//\r
- // Remove declarative key-value paris if any.\r
+ // Remove declarative key-value pairs, if any.\r
//\r
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_SESSION_TYPE);\r
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);\r
IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);\r
+ //\r
+ // Remove the key-value that may not needed for result function is OR.\r
+ //\r
+ IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);\r
+ IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);\r
+ IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);\r
+\r
+ //\r
+ // Remove irrelevant parameter, if any.\r
+ //\r
+ if (Session->InitialR2T && !Session->ImmediateData) {\r
+ IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_FIRST_BURST_LENGTH);\r
+ }\r
\r
if (IsListEmpty (KeyValueList)) {\r
//\r
the Packet.\r
@retval EFI_DEVICE_ERROR Session state was not as required.\r
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval EFI_NOT_READY The target can not accept new commands.\r
@retval Others Other errors as indicated.\r
**/\r
EFI_STATUS\r
IScsiDelTcb (Tcb);\r
}\r
\r
- if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {\r
- //\r
- // Reinstate the session.\r
- //\r
- if (EFI_ERROR (IScsiSessionReinstatement (Private))) {\r
- Status = EFI_DEVICE_ERROR;\r
- }\r
- }\r
-\r
return Status;\r
}\r
\r