]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c
BaseTools: Fix bug when converting iSCSI node
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiExtScsiPassThru.c
index c4aed4c4ab5820d0fda796ff7802440b6b997361..90e26d4611a50e73c00df7c1869deeef66ab4510 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, 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
@@ -86,6 +86,9 @@ IScsiExtScsiPassThruFunction (
   IN EFI_EVENT                                                Event     OPTIONAL\r
   )\r
 {\r
+  EFI_STATUS         Status;\r
+  ISCSI_DRIVER_DATA  *Private;\r
+  \r
   if (Target[0] != 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -94,7 +97,20 @@ IScsiExtScsiPassThruFunction (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  return IScsiExecuteScsiCommand (This, Target, Lun, Packet);\r
+  Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);\r
+  if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {\r
+    //\r
+    // Try to reinstate the session and re-execute the Scsi command.\r
+    //\r
+    Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
+    if (EFI_ERROR (IScsiSessionReinstatement (Private->Session))) {\r
+      return EFI_DEVICE_ERROR;\r
+    }\r
+\r
+    Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 \r
@@ -203,7 +219,7 @@ IScsiExtScsiPassThruBuildDevicePath (
   EFI_DEV_PATH                  *Node;\r
   UINTN                         DevPathNodeLen;\r
 \r
-  if ((DevicePath == NULL)) {\r
+  if (DevicePath == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -257,7 +273,7 @@ IScsiExtScsiPassThruBuildDevicePath (
 \r
   CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));\r
   Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;\r
-  AsciiStrCpy ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), ConfigNvData->TargetName);\r
+  AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);\r
 \r
   *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;\r
 \r