]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c
Revert "EmulatorPkg: don't display the cpu current speed"
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiExtScsiPassThru.c
index c4aed4c4ab5820d0fda796ff7802440b6b997361..06fcf92bbe71ffe7e3ed9f7bd68f5549552f95b0 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   The implementation of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.\r
 \r
-Copyright (c) 2004 - 2011, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -29,19 +23,19 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
 /**\r
   Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel.\r
   This function supports both blocking I/O and nonblocking I/O. The blocking I/O\r
-  functionality is required, and the nonblocking I/O functionality is optional.  \r
+  functionality is required, and the nonblocking I/O functionality is optional.\r
 \r
   @param[in]       This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
   @param[in]       Target  The Target is an array of size TARGET_MAX_BYTES and it\r
                            represents the id of the SCSI device to send the SCSI\r
                            Request Packet. Each transport driver may choose to\r
                            utilize a subset of this size to suit the needs\r
-                           of transport target representation. For example, a \r
+                           of transport target representation. For example, a\r
                            Fibre Channel driver may use only 8 bytes (WWN)\r
                            to represent an FC target.\r
   @param[in]       Lun     The LUN of the SCSI device to send the SCSI Request Packet.\r
   @param[in, out]  Packet  A pointer to the SCSI Request Packet to send to the\r
-                           SCSI device specified by Target and Lun.                  \r
+                           SCSI device specified by Target and Lun.\r
   @param[in]       Event   If nonblocking I/O is not supported then Event is ignored,\r
                            and blocking I/O is performed. If Event is NULL, then\r
                            blocking I/O is performed. If Event is not NULL and non\r
@@ -50,7 +44,7 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
                            completes.\r
 \r
   @retval EFI_SUCCESS           The SCSI Request Packet was sent by the host. For\r
-                                bi-directional commands, InTransferLength bytes \r
+                                bi-directional commands, InTransferLength bytes\r
                                 were transferred from InDataBuffer.\r
                                 For write and bi-directional commands, OutTransferLength\r
                                 bytes were transferred by OutDataBuffer.\r
@@ -63,7 +57,7 @@ EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {
                                 there are too many SCSI Request Packets already\r
                                 queued. The caller may retry later.\r
   @retval EFI_DEVICE_ERROR      A device error occurred while attempting to send\r
-                                the SCSI Request Packet.                                \r
+                                the SCSI Request Packet.\r
   @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket,\r
                                 are invalid.\r
   @retval EFI_UNSUPPORTED       The command described by the SCSI Request Packet\r
@@ -86,6 +80,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 +91,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
@@ -102,9 +112,9 @@ IScsiExtScsiPassThruFunction (
   Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on\r
   a SCSI channel. These can either be the list SCSI devices that are actually\r
   present on the SCSI channel, or the list of legal Target Ids and LUNs for the\r
-  SCSI channel. Regardless, the caller of this function must probe the Target ID      \r
-  and LUN returned to see if a SCSI device is actually present at that location    \r
-  on the SCSI channel. \r
+  SCSI channel. Regardless, the caller of this function must probe the Target ID\r
+  and LUN returned to see if a SCSI device is actually present at that location\r
+  on the SCSI channel.\r
 \r
   @param[in]       This          The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
   @param[in, out]  Target        On input, a pointer to the Target ID of a SCSI\r
@@ -203,7 +213,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 +267,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
@@ -282,7 +292,7 @@ IScsiExtScsiPassThruBuildDevicePath (
   @retval EFI_INVALID_PARAMETER  DevicePath/Target/Lun is NULL.\r
   @retval EFI_UNSUPPORTED        This driver does not support the device path  node\r
                                  type in DevicePath.\r
-  @retval EFI_NOT_FOUND          A valid translation does not exist from DevicePath \r
+  @retval EFI_NOT_FOUND          A valid translation does not exist from DevicePath\r
                                  to a TargetID and LUN.\r
 \r
 **/\r
@@ -366,7 +376,7 @@ IScsiExtScsiPassThruResetTargetLun (
 }\r
 \r
 /**\r
-  Retrieve the list of legal Target IDs for SCSI devices on a SCSI channel.                         \r
+  Retrieve the list of legal Target IDs for SCSI devices on a SCSI channel.\r
 \r
   @param[in]       This         A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL\r
                                 instance.\r
@@ -376,7 +386,7 @@ IScsiExtScsiPassThruResetTargetLun (
                                 next SCSI device present on a SCSI channel.\r
                                 An input value of 0xF(all bytes in the array are 0xF)\r
                                 in the Target array retrieves the Target ID of the\r
-                                first SCSI device present on a SCSI channel.                 \r
+                                first SCSI device present on a SCSI channel.\r
 \r
   @retval EFI_SUCCESS           The Target ID of the next SCSI device on the SCSI\r
                                 channel was returned in Target.\r