]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
MdeModulePkg: Fix issue about current Ip4Dxe implementation for DHCP DORA process
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiProto.c
index ffe0c6e1a84ad44e68ae85becc89cb2e5ace408f..1ac79e7ca179701ab6f7f37918c9e0fb8b788c24 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -393,6 +393,8 @@ IScsiReceiveLoginRsp (
   EFI_STATUS  Status;\r
   NET_BUF     *Pdu;\r
 \r
+  Pdu = NULL;\r
+\r
   //\r
   // Receive the iSCSI login response.\r
   //\r
@@ -1223,12 +1225,14 @@ IScsiCheckOpParams (
   //\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
@@ -1238,7 +1242,7 @@ IScsiCheckOpParams (
     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
@@ -1263,13 +1267,15 @@ IScsiCheckOpParams (
   // 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
@@ -1289,22 +1295,26 @@ IScsiCheckOpParams (
   //\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
@@ -1354,11 +1364,24 @@ IScsiCheckOpParams (
   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
@@ -2504,6 +2527,7 @@ IScsiOnNopInRcvd (
                                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
@@ -2679,15 +2703,6 @@ ON_EXIT:
     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