]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
MdeModulePkg: Delete IScsiDxe in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiExtScsiPassThru.c
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
deleted file mode 100644 (file)
index db2d6d1..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/** @file\r
-  The IScsi's EFI_EXT_SCSI_PASS_THRU_PROTOCOL driver.\r
-\r
-Copyright (c) 2004 - 2018, 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
-\r
-**/\r
-\r
-#include "IScsiImpl.h"\r
-\r
-/**\r
-  Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function\r
-  supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r
-  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 represents\r
-                          the id of the SCSI device to send the SCSI Request Packet. Each\r
-                          transport driver may chose to utilize a subset of this size to suit the needs\r
-                          of transport target representation. For example, a Fibre Channel driver\r
-                          may use only 8 bytes (WWN) 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 SCSI device\r
-                          specified by Target and Lun.\r
-  @param[in]       Event  If nonblocking I/O is not supported then Event is ignored, and blocking\r
-                          I/O is performed. If Event is NULL, then blocking I/O is performed. If\r
-                          Event is not NULL and non blocking I/O is supported, then\r
-                          nonblocking I/O is performed, and Event will be signaled when the\r
-                          SCSI Request Packet completes.\r
-\r
-  @retval EFI_SUCCESS           The SCSI Request Packet was sent by the host. For bi-directional\r
-                                commands, InTransferLength bytes were transferred from\r
-                                InDataBuffer. For write and bi-directional commands,\r
-                                OutTransferLength bytes were transferred by\r
-                                OutDataBuffer.\r
-  @retval EFI_BAD_BUFFER_SIZE   The SCSI Request Packet was not executed. The number of bytes that\r
-                                could be transferred is returned in InTransferLength. For write\r
-                                and bi-directional commands, OutTransferLength bytes were\r
-                                transferred by OutDataBuffer. Currently not implemeted.\r
-  @retval EFI_NOT_READY         The SCSI Request Packet could not be sent because there are too many\r
-                                SCSI Request Packets already queued. The caller may retry again later.\r
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to send the SCSI Request\r
-                                Packet.\r
-  @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.\r
-  @retval EFI_UNSUPPORTED       The command described by the SCSI Request Packet is not supported\r
-                                by the host adapter. This includes the case of Bi-directional SCSI\r
-                                commands not supported by the implementation. The SCSI Request\r
-                                Packet was not sent, so no additional status information is available.\r
-                                Currently not implemeted.\r
-  @retval EFI_TIMEOUT           A timeout occurred while waiting for the SCSI Request Packet to execute.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruFunction (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                          *This,\r
-  IN UINT8                                                    *Target,\r
-  IN UINT64                                                   Lun,\r
-  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET           *Packet,\r
-  IN EFI_EVENT                                                Event     OPTIONAL\r
-  )\r
-{\r
-  ISCSI_DRIVER_DATA           *Private;\r
-  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
-  EFI_STATUS                  Status;\r
-\r
-  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
-  ConfigNvData  = &Private->Session.ConfigData.NvData;\r
-\r
-  if (Target[0] != 0 || (CompareMem (&Lun, ConfigNvData->BootLun, sizeof (UINT64)) != 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Packet == NULL) || (Packet->Cdb == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\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
-    if (EFI_ERROR (IScsiSessionReinstatement (Private))) {\r
-      return EFI_DEVICE_ERROR;\r
-    }\r
-\r
-    Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These\r
-  can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal\r
-  Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the\r
-  Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI\r
-  channel.\r
-\r
-  @param[in]       This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
-  @param[in, out]  Target  On input, a pointer to the Target ID (an array of size\r
-                           TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r
-                           On output, a pointer to the Target ID (an array of\r
-                           TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r
-                           channel. An input value of 0xF(all bytes in the array are 0xF) in the\r
-                           Target array retrieves the Target ID of the first SCSI device present on a\r
-                           SCSI channel.\r
-  @param[in, out]  Lun     On input, a pointer to the LUN of a SCSI device present on the SCSI\r
-                           channel. On output, a pointer to the LUN of the next SCSI device present\r
-                           on a SCSI channel.\r
-\r
-  @retval EFI_SUCCESS           The Target ID and LUN of the next SCSI device on the SCSI\r
-                                channel was returned in Target and Lun.\r
-  @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were\r
-                                not returned on a previous call to GetNextTargetLun().\r
-  @retval EFI_NOT_FOUND         There are no more SCSI devices on this SCSI channel.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruGetNextTargetLun (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,\r
-  IN OUT UINT8                        **Target,\r
-  IN OUT UINT64                       *Lun\r
-  )\r
-{\r
-  ISCSI_DRIVER_DATA           *Private;\r
-  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
-  UINT8                       TargetId[TARGET_MAX_BYTES];\r
-\r
-  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
-  ConfigNvData  = &Private->Session.ConfigData.NvData;\r
-\r
-  if ((*Target)[0] == 0 && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {\r
-    //\r
-    // Only one <Target, Lun> pair per iSCSI Driver instance.\r
-    //\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);\r
-  if (CompareMem (*Target, TargetId, TARGET_MAX_BYTES) == 0) {\r
-    (*Target)[0] = 0;\r
-    CopyMem (Lun, ConfigNvData->BootLun, sizeof (UINT64));\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  return EFI_INVALID_PARAMETER;\r
-}\r
-\r
-/**\r
-  Used to allocate and build a device path node for a SCSI device on a SCSI channel.\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 specifies the\r
-                              Target ID of the SCSI device for which a device path node is to be\r
-                              allocated and built. Transport drivers may chose to utilize a subset of\r
-                              this size to suit the representation of targets. For example, a Fibre\r
-                              Channel driver may use only 8 bytes (WWN) in the array to represent a\r
-                              FC target.\r
-  @param[in]       Lun        The LUN of the SCSI device for which a device path node is to be\r
-                              allocated and built.\r
-  @param[in, out]  DevicePath A pointer to a single device path node that describes the SCSI device\r
-                              specified by Target and Lun. This function is responsible for\r
-                              allocating the buffer DevicePath with the boot service\r
-                              AllocatePool(). It is the caller's responsibility to free\r
-                              DevicePath when the caller is finished with DevicePath.\r
-\r
-  @retval EFI_SUCCESS           The device path node that describes the SCSI device specified by\r
-                                Target and Lun was allocated and returned in\r
-                                DevicePath.\r
-  @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
-  @retval EFI_NOT_FOUND         The SCSI devices specified by Target and Lun does not exist\r
-                                on the SCSI channel.\r
-  @retval EFI_OUT_OF_RESOURCES  There are not enough resources to allocate DevicePath.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruBuildDevicePath (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,\r
-  IN UINT8                            *Target,\r
-  IN UINT64                           Lun,\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL     **DevicePath\r
-  )\r
-{\r
-  ISCSI_DRIVER_DATA             *Private;\r
-  ISCSI_SESSION                 *Session;\r
-  ISCSI_SESSION_CONFIG_NVDATA   *ConfigNvData;\r
-  ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;\r
-  EFI_DEV_PATH                  *Node;\r
-  UINTN                         DevPathNodeLen;\r
-\r
-  if (DevicePath == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (Target[0] != 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
-  Session       = &Private->Session;\r
-  ConfigNvData  = &Session->ConfigData.NvData;\r
-  AuthConfig    = &Session->AuthData.AuthConfig;\r
-\r
-  if (CompareMem (&Lun, ConfigNvData->BootLun, sizeof (UINT64)) != 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  DevPathNodeLen  = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData->TargetName) + 1;\r
-  Node            = AllocatePool (DevPathNodeLen);\r
-  if (Node == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  Node->DevPath.Type    = MESSAGING_DEVICE_PATH;\r
-  Node->DevPath.SubType = MSG_ISCSI_DP;\r
-  SetDevicePathNodeLength (&Node->DevPath, (UINT16)DevPathNodeLen);\r
-\r
-  //\r
-  // 0 for TCP, others are reserved.\r
-  //\r
-  Node->Iscsi.NetworkProtocol = 0;\r
-\r
-  Node->Iscsi.LoginOption     = 0;\r
-  switch (AuthConfig->CHAPType) {\r
-  case ISCSI_CHAP_NONE:\r
-    Node->Iscsi.LoginOption |= 0x0800;\r
-    break;\r
-\r
-  case ISCSI_CHAP_UNI:\r
-    Node->Iscsi.LoginOption |= 0x1000;\r
-    break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));\r
-  Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;\r
-  AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);\r
-\r
-  *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Used to translate a device path node to a Target ID and LUN.\r
-\r
-  @param[in]  This       A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
-  @param[in]  DevicePath A pointer to a single device path node that describes the SCSI device\r
-                         on the SCSI channel.\r
-  @param[out] Target     A pointer to the Target Array which represents the ID of a SCSI device\r
-                         on the SCSI channel.\r
-  @param[out]  Lun       A pointer to the LUN of a SCSI device on the SCSI channel.\r
-\r
-  @retval EFI_SUCCESS           DevicePath was successfully translated to a Target ID and\r
-                                LUN, and they were returned in Target and Lun.\r
-  @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.\r
-  @retval EFI_NOT_FOUND         A valid translation from DevicePath to a Target ID and LUN\r
-                                does not exist.Currently not implemented.\r
-  @retval EFI_UNSUPPORTED       This driver does not support the device path node type in\r
-                                DevicePath.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruGetTargetLun (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,\r
-  IN EFI_DEVICE_PATH_PROTOCOL         *DevicePath,\r
-  OUT UINT8                           **Target,\r
-  OUT UINT64                          *Lun\r
-  )\r
-{\r
-  ISCSI_DRIVER_DATA           *Private;\r
-  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;\r
-\r
-  if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||\r
-      (DevicePath->SubType != MSG_ISCSI_DP) ||\r
-      (DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH))\r
-      ) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);\r
-  ConfigNvData  = &Private->Session.ConfigData.NvData;\r
-\r
-  SetMem (*Target, TARGET_MAX_BYTES, 0xFF);\r
-  (*Target)[0] = 0;\r
-\r
-  if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *) DevicePath + sizeof (ISCSI_DEVICE_PATH)) != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  CopyMem (Lun, ConfigNvData->BootLun, sizeof (UINT64));\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.\r
-  Currently not implemented.\r
-\r
-  @param[in]  This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
-\r
-  @retval EFI_SUCCESS      The SCSI channel was reset.\r
-  @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.\r
-  @retval EFI_TIMEOUT      A timeout occurred while attempting to reset the SCSI channel.\r
-  @retval EFI_UNSUPPORTED  The SCSI channel does not support a channel reset operation.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruResetChannel (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Resets a SCSI logical unit that is connected to a SCSI channel. Currently not implemented.\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_BYTE and it represents the\r
-                     target port ID of the SCSI device containing the SCSI logical unit to\r
-                     reset. Transport drivers may chose to utilize a subset of this array to suit\r
-                     the representation of their targets.\r
-  @param[in]  Lun    The LUN of the SCSI device to reset.\r
-\r
-  @retval EFI_SUCCESS           The SCSI device specified by Target and Lun was reset.\r
-  @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r
-  @retval EFI_TIMEOUT           A timeout occurred while attempting to reset the SCSI device\r
-                                specified by Target and Lun.\r
-  @retval EFI_UNSUPPORTED       The SCSI channel does not support a target reset operation.\r
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to reset the SCSI device\r
-                                specified by Target and Lun.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruResetTargetLun (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,\r
-  IN UINT8                            *Target,\r
-  IN UINT64                           Lun\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either\r
-  be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs\r
-  for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to\r
-  see if a SCSI device is actually present at that location on the SCSI channel.\r
-\r
-  @param[in]       This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.\r
-  @param[in, out]  Target  (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.\r
-                           On output, a pointer to the Target ID (an array of\r
-                           TARGET_MAX_BYTES) of the next SCSI device present on a SCSI\r
-                           channel. An input value of 0xF(all bytes in the array are 0xF) in the\r
-                           Target array retrieves the Target ID of the first SCSI device present on a\r
-                           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
-  @retval EFI_INVALID_PARAMETER Target or Lun is NULL.\r
-  @retval EFI_TIMEOUT           Target array is not all 0xF, and Target were not\r
-                                returned on a previous call to GetNextTarget().\r
-                                Currently not implemented.\r
-  @retval EFI_NOT_FOUND         There are no more SCSI devices on this SCSI channel.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IScsiExtScsiPassThruGetNextTarget (\r
-  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,\r
-  IN OUT UINT8                        **Target\r
-  )\r
-{\r
-  UINT8 TargetId[TARGET_MAX_BYTES];\r
-\r
-  SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);\r
-\r
-  if (CompareMem (*Target, TargetId, TARGET_MAX_BYTES) == 0) {\r
-    (*Target)[0] = 0;\r
-    return EFI_SUCCESS;\r
-  } else if ((*Target)[0] == 0) {\r
-    return EFI_NOT_FOUND;\r
-  } else {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-}\r
-\r
-EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate = {\r
-  NULL,\r
-  IScsiExtScsiPassThruFunction,\r
-  IScsiExtScsiPassThruGetNextTargetLun,\r
-  IScsiExtScsiPassThruBuildDevicePath,\r
-  IScsiExtScsiPassThruGetTargetLun,\r
-  IScsiExtScsiPassThruResetChannel,\r
-  IScsiExtScsiPassThruResetTargetLun,\r
-  IScsiExtScsiPassThruGetNextTarget\r
-};\r