public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Jian J" <jian.j.wang@intel.com>
To: "Fu, Siyuan" <siyuan.fu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Hao A" <hao.a.wu@intel.com>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"Zeng, Star" <star.zeng@intel.com>,
	"Wu, Jiaxin" <jiaxin.wu@intel.com>
Subject: Re: [PATCH v2 3/6] MdeModulePkg: Delete IScsiDxe in MdeModulePkg.
Date: Thu, 20 Dec 2018 04:43:01 +0000	[thread overview]
Message-ID: <D827630B58408649ACB04F44C510003624ECE8F0@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20181220014110.20324-4-siyuan.fu@intel.com>



Reviewed-by: Jian J Wang <jian.j.wang@intel.com>


> -----Original Message-----
> From: Fu, Siyuan
> Sent: Thursday, December 20, 2018 9:41 AM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Wu, Jiaxin
> <jiaxin.wu@intel.com>
> Subject: [PATCH v2 3/6] MdeModulePkg: Delete IScsiDxe in MdeModulePkg.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1278
> 
> This patch is to delete the IScsiDxe driver in MdeModulePkg. The driver
> will not be maintained and can't co-work with the dual-stack IScsiDxe in
> NetworkPkg.
> 
> People should use below NetworkPkg drivers instead:
>   NetworkPkg/IScsiDxe/IScsiDxe.inf
> Which is actively maintained with more bug fixes and new feature support.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> ---
> 
> Notes:
>     v2:
>     Break original patch to separate commits per module.
> 
>  MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c           |  283 --
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c               |  430 ---
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c             | 1264 --------
> -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c               |  472 ----
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c             |  676 -----
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c    |  412 ---
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c               |  539 ----
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.c      |  116 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c               |  948 -------
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c              | 2799 ---------
> -----------
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.c             |  487 ----
>  MdeModulePkg/Universal/Network/IScsiDxe/Md5.c                     |  350 ---
>  MdeModulePkg/MdeModulePkg.dsc                                     |    1 -
>  MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.h           |  165 --
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsi4Dxe.uni             |   25 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsi4DxeExtra.uni        |   20 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h               |  106 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiCommon.h             |   22 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h             |  166 --
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr        |  219 --
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni |   62 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h  |  109 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h               |   55 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.h             |  140 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf              |  134 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.h    |   22 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.h               |   38 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiImpl.h               |  168 --
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.h      |   74 -
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h               |  317 ---
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h              | 1005 -------
>  MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.h             |  142 -
>  MdeModulePkg/Universal/Network/IScsiDxe/Md5.h                     |   80 -
>  33 files changed, 11846 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c
> deleted file mode 100644
> index 3f561e93439d..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c
> +++ /dev/null
> @@ -1,283 +0,0 @@
> -/** @file
> -  UEFI Component Name(2) protocol implementation for iSCSI.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -//
> -// EFI Component Name Protocol
> -//
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL
> gIScsiComponentName = {
> -  IScsiComponentNameGetDriverName,
> -  IScsiComponentNameGetControllerName,
> -  "eng"
> -};
> -
> -//
> -// EFI Component Name 2 Protocol
> -//
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL
> gIScsiComponentName2 = {
> -  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)
> IScsiComponentNameGetDriverName,
> -  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)
> IScsiComponentNameGetControllerName,
> -  "en"
> -};
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
> mIScsiDriverNameTable[] = {
> -  {"eng;en", L"iSCSI Driver"},
> -  {NULL, NULL}
> -};
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
> *mIScsiControllerNameTable = NULL;
> -
> -/**
> -  Retrieves a Unicode string that is the user readable name of the EFI Driver.
> -
> -  This function retrieves the user readable name of a driver in the form of a
> -  Unicode string. If the driver specified by This has a user readable name in
> -  the language specified by Language, then a pointer to the driver name is
> -  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
> -  by This does not support the language specified by Language,
> -  then EFI_UNSUPPORTED is returned.
> -
> -  @param[in]  This        A pointer to the EFI_COMPONENT_NAME_PROTOCOL
> instance.
> -  @param[in]  Language    A pointer to a three character ISO 639-2 language
> identifier.
> -                          This is the language of the driver name that that the caller
> -                          is requesting, and it must match one of the languages specified
> -                          in SupportedLanguages.  The number of languages supported by
> a
> -                          driver is up to the driver writer.
> -  @param[out]  DriverName A pointer to the Unicode string to return.  This
> Unicode string
> -                          is the name of the driver specified by This in the language
> -                          specified by Language.
> -
> -  @retval EFI_SUCCESS           The Unicode string for the Driver specified by This
> -                                and the language specified by Language was returned
> -                                in DriverName.
> -  @retval EFI_INVALID_PARAMETER Language is NULL.
> -  @retval EFI_INVALID_PARAMETER DriverName is NULL.
> -  @retval EFI_UNSUPPORTED       The driver specified by This does not support
> the
> -                                language specified by Language.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiComponentNameGetDriverName (
> -  IN  EFI_COMPONENT_NAME_PROTOCOL   *This,
> -  IN  CHAR8                         *Language,
> -  OUT CHAR16                        **DriverName
> -  )
> -{
> -  return LookupUnicodeString2 (
> -          Language,
> -          This->SupportedLanguages,
> -          mIScsiDriverNameTable,
> -          DriverName,
> -          (BOOLEAN)(This == &gIScsiComponentName)
> -          );
> -}
> -
> -/**
> -  Update the component name for the iSCSI instance.
> -
> -  @param[in]  IScsiExtScsiPassThru  A pointer to the
> EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
> -
> -  @retval EFI_SUCCESS               Update the ControllerNameTable of this
> instance successfully.
> -  @retval EFI_INVALID_PARAMETER     The input parameter is invalid.
> -  @retval EFI_UNSUPPORTED           Can't get the corresponding NIC info from
> the Controller handle.
> -
> -**/
> -EFI_STATUS
> -UpdateName (
> -  IN   EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru
> -  )
> -{
> -  EFI_STATUS                       Status;
> -  CHAR16                           HandleName[150];
> -  ISCSI_DRIVER_DATA                *Private;
> -  EFI_MAC_ADDRESS                  MacAddress;
> -  UINTN                            HwAddressSize;
> -  UINT16                           VlanId;
> -  CHAR16                           MacString[70];
> -
> -  if (IScsiExtScsiPassThru == NULL) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  Private  = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU
> (IScsiExtScsiPassThru);
> -
> -  //
> -  // Get the mac string, it's the name of various variable
> -  //
> -  Status = NetLibGetMacAddress (Private->Controller, &MacAddress,
> &HwAddressSize);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -  VlanId = NetLibGetVlanId (Private->Controller);
> -  IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId,
> MacString);
> -
> -  UnicodeSPrint (
> -    HandleName,
> -    sizeof (HandleName),
> -    L"iSCSI IPv4 (MacString=%s)",
> -    MacString
> -  );
> -
> -  if (mIScsiControllerNameTable != NULL) {
> -    FreeUnicodeStringTable (mIScsiControllerNameTable);
> -    mIScsiControllerNameTable = NULL;
> -  }
> -
> -  Status = AddUnicodeString2 (
> -             "eng",
> -             gIScsiComponentName.SupportedLanguages,
> -             &mIScsiControllerNameTable,
> -             HandleName,
> -             TRUE
> -             );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  return AddUnicodeString2 (
> -           "en",
> -           gIScsiComponentName2.SupportedLanguages,
> -           &mIScsiControllerNameTable,
> -           HandleName,
> -           FALSE
> -           );
> -}
> -
> -/**
> -  Retrieves a Unicode string that is the user readable name of the controller
> -  that is being managed by an EFI Driver.Currently not implemented.
> -
> -  @param[in]  This             A pointer to the EFI_COMPONENT_NAME_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle The handle of a controller that the driver
> specified by
> -                               This is managing.  This handle specifies the controller
> -                               whose name is to be returned.
> -  @param[in]  ChildHandle      The handle of the child controller to retrieve the
> name
> -                               of.  This is an optional parameter that may be NULL.  It
> -                               will be NULL for device drivers.  It will also be NULL
> -                               for a bus drivers that wish to retrieve the name of the
> -                               bus controller.  It will not be NULL for a bus driver
> -                               that wishes to retrieve the name of a child controller.
> -  @param[in]  Language         A pointer to a three character ISO 639-2 language
> -                               identifier.  This is the language of the controller name
> -                               that that the caller is requesting, and it must match one
> -                               of the languages specified in SupportedLanguages.  The
> -                               number of languages supported by a driver is up to the
> -                               driver writer.
> -  @param[out]  ControllerName  A pointer to the Unicode string to return.  This
> Unicode
> -                               string is the name of the controller specified by
> -                               ControllerHandle and ChildHandle in the language specified
> -                               by Language from the point of view of the driver specified
> -                               by This.
> -
> -  @retval EFI_SUCCESS           The Unicode string for the user readable name in
> the
> -                                language specified by Language for the driver
> -                                specified by This was returned in DriverName.
> -  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
> -  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
> EFI_HANDLE.
> -  @retval EFI_INVALID_PARAMETER Language is NULL.
> -  @retval EFI_INVALID_PARAMETER ControllerName is NULL.
> -  @retval EFI_UNSUPPORTED       The driver specified by This is not currently
> managing
> -                                the controller specified by ControllerHandle and
> -                                ChildHandle.
> -  @retval EFI_UNSUPPORTED       The driver specified by This does not support
> the
> -                                language specified by Language.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiComponentNameGetControllerName (
> -  IN  EFI_COMPONENT_NAME_PROTOCOL   *This,
> -  IN  EFI_HANDLE                    ControllerHandle,
> -  IN  EFI_HANDLE                    ChildHandle        OPTIONAL,
> -  IN  CHAR8                         *Language,
> -  OUT CHAR16                        **ControllerName
> -  )
> -{
> -  EFI_STATUS                      Status;
> -
> -  EFI_HANDLE                      IScsiController;
> -  ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;
> -
> -  EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru;
> -
> -  if (ControllerHandle == NULL) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  //
> -  // Get the handle of the controller we are controling.
> -  //
> -  IScsiController = NetLibGetNicHandle (ControllerHandle,
> &gEfiTcp4ProtocolGuid);
> -  if (IScsiController == NULL) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  Status = gBS->OpenProtocol (
> -                  IScsiController,
> -                  &gEfiCallerIdGuid,
> -                  (VOID **)&IScsiIdentifier,
> -                  NULL,
> -                  NULL,
> -                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  if (ChildHandle != NULL) {
> -    //
> -    // Make sure this driver produced ChildHandle
> -    //
> -    Status = EfiTestChildHandle (
> -               ControllerHandle,
> -               ChildHandle,
> -               &gEfiTcp4ProtocolGuid
> -               );
> -    if (!EFI_ERROR (Status)) {
> -      //
> -      // Retrieve an instance of a produced protocol from ChildHandle
> -      //
> -      Status = gBS->OpenProtocol (
> -                      ChildHandle,
> -                      &gEfiExtScsiPassThruProtocolGuid,
> -                     (VOID **)&IScsiExtScsiPassThru,
> -                      NULL,
> -                      NULL,
> -                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -                      );
> -      if (EFI_ERROR (Status)) {
> -        return Status;
> -      }
> -
> -      //
> -      // Update the component name for this child handle.
> -      //
> -      Status = UpdateName (IScsiExtScsiPassThru);
> -      if (EFI_ERROR (Status)) {
> -        return Status;
> -      }
> -    } else {
> -      return Status;
> -    }
> -  }
> -
> -  return LookupUnicodeString2 (
> -           Language,
> -           This->SupportedLanguages,
> -           mIScsiControllerNameTable,
> -           ControllerName,
> -           (BOOLEAN)(This == &gIScsiComponentName)
> -           );
> -}
> -
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c
> deleted file mode 100644
> index 6307684ff05b..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c
> +++ /dev/null
> @@ -1,430 +0,0 @@
> -/** @file
> -  This file is for Challenge-Handshake Authentication Protocol (CHAP)
> Configuration.
> -
> -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -#include "Md5.h"
> -
> -/**
> -  Initator calculates its own expected hash value.
> -
> -  @param[in]   ChapIdentifier     iSCSI CHAP identifier sent by authenticator.
> -  @param[in]   ChapSecret         iSCSI CHAP secret of the authenticator.
> -  @param[in]   SecretLength       The length of iSCSI CHAP secret.
> -  @param[in]   ChapChallenge      The challenge message sent by authenticator.
> -  @param[in]   ChallengeLength    The length of iSCSI CHAP challenge message.
> -  @param[out]  ChapResponse       The calculation of the expected hash value.
> -
> -  @retval EFI_SUCCESS             The expected hash value was calculatedly
> successfully.
> -  @retval EFI_PROTOCOL_ERROR      The length of the secret should be at least
> the
> -                                  length of the hash value for the hashing algorithm chosen.
> -  @retval Others                  Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiCHAPCalculateResponse (
> -  IN  UINT32  ChapIdentifier,
> -  IN  CHAR8   *ChapSecret,
> -  IN  UINT32  SecretLength,
> -  IN  UINT8   *ChapChallenge,
> -  IN  UINT32  ChallengeLength,
> -  OUT UINT8   *ChapResponse
> -  )
> -{
> -  MD5_CTX     Md5Ctx;
> -  CHAR8       IdByte[1];
> -  EFI_STATUS  Status;
> -
> -  Status = MD5Init (&Md5Ctx);
> -
> -  //
> -  // Hash Identifier - Only calculate 1 byte data (RFC1994)
> -  //
> -  IdByte[0] = (CHAR8) ChapIdentifier;
> -  MD5Update (&Md5Ctx, IdByte, 1);
> -
> -  //
> -  // Hash Secret
> -  //
> -  if (SecretLength < ISCSI_CHAP_SECRET_MIN_LEN - 1) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  MD5Update (&Md5Ctx, ChapSecret, SecretLength);
> -
> -  //
> -  // Hash Challenge received from Target
> -  //
> -  MD5Update (&Md5Ctx, ChapChallenge, ChallengeLength);
> -
> -  Status = MD5Final (&Md5Ctx, ChapResponse);
> -
> -  return Status;
> -}
> -
> -/**
> -  The initator checks the CHAP response replied by target against its own
> -  calculation of the expected hash value.
> -
> -  @param[in]   AuthData             iSCSI CHAP authentication data.
> -  @param[in]   TargetResponse       The response from target.
> -
> -  @retval EFI_SUCCESS               The response from target passed authentication.
> -  @retval EFI_SECURITY_VIOLATION    The response from target was not
> expected value.
> -  @retval Others                    Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiCHAPAuthTarget (
> -  IN  ISCSI_CHAP_AUTH_DATA  *AuthData,
> -  IN  UINT8                 *TargetResponse
> -  )
> -{
> -  EFI_STATUS  Status;
> -  UINT32      SecretSize;
> -  UINT8       VerifyRsp[ISCSI_CHAP_RSP_LEN];
> -
> -  Status      = EFI_SUCCESS;
> -
> -  SecretSize  = (UINT32) AsciiStrLen (AuthData->AuthConfig.ReverseCHAPSecret);
> -  Status = IScsiCHAPCalculateResponse (
> -            AuthData->OutIdentifier,
> -            AuthData->AuthConfig.ReverseCHAPSecret,
> -            SecretSize,
> -            AuthData->OutChallenge,
> -            AuthData->OutChallengeLength,
> -            VerifyRsp
> -            );
> -
> -  if (CompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN) != 0) {
> -    Status = EFI_SECURITY_VIOLATION;
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  This function checks the received iSCSI Login Response during the security
> -  negotiation stage.
> -
> -  @param[in] Conn             The iSCSI connection.
> -
> -  @retval EFI_SUCCESS          The Login Response passed the CHAP validation.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of protocol error happend.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiCHAPOnRspReceived (
> -  IN ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  EFI_STATUS                Status;
> -  ISCSI_SESSION             *Session;
> -  ISCSI_CHAP_AUTH_DATA      *AuthData;
> -  CHAR8                     *Value;
> -  UINT8                     *Data;
> -  UINT32                    Len;
> -  LIST_ENTRY                *KeyValueList;
> -  UINTN                     Algorithm;
> -  CHAR8                     *Identifier;
> -  CHAR8                     *Challenge;
> -  CHAR8                     *Name;
> -  CHAR8                     *Response;
> -  UINT8                     TargetRsp[ISCSI_CHAP_RSP_LEN];
> -  UINT32                    RspLen;
> -
> -  ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
> -  ASSERT (Conn->RspQue.BufNum != 0);
> -
> -  Session     = Conn->Session;
> -  AuthData    = &Session->AuthData;
> -
> -  Len         = Conn->RspQue.BufSize;
> -  Data        = AllocatePool (Len);
> -  if (Data == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -  //
> -  // Copy the data in case the data spans over multiple PDUs.
> -  //
> -  NetbufQueCopy (&Conn->RspQue, 0, Len, Data);
> -
> -  //
> -  // Build the key-value list from the data segment of the Login Response.
> -  //
> -  KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len);
> -  if (KeyValueList == NULL) {
> -    FreePool (Data);
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  Status = EFI_PROTOCOL_ERROR;
> -
> -  switch (Conn->CHAPStep) {
> -  case ISCSI_CHAP_INITIAL:
> -    //
> -    // The first Login Response.
> -    //
> -    Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
> -    if (Value == NULL) {
> -      goto ON_EXIT;
> -    }
> -
> -    Session->TargetPortalGroupTag = (UINT16) AsciiStrDecimalToUintn (Value);
> -
> -    Value                         = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_AUTH_METHOD);
> -    if (Value == NULL) {
> -      goto ON_EXIT;
> -    }
> -    //
> -    // Initiator mandates CHAP authentication but target replies without "CHAP"
> or
> -    // initiator suggets "None" but target replies with some kind of auth method.
> -    //
> -    if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) == 0) {
> -      if (AuthData->AuthConfig.CHAPType == ISCSI_CHAP_NONE) {
> -        goto ON_EXIT;
> -      }
> -    } else {
> -      if (AuthData->AuthConfig.CHAPType != ISCSI_CHAP_NONE) {
> -        goto ON_EXIT;
> -      }
> -    }
> -    //
> -    // Transit to CHAP step one.
> -    //
> -    Conn->CHAPStep  = ISCSI_CHAP_STEP_ONE;
> -    Status          = EFI_SUCCESS;
> -    break;
> -
> -  case ISCSI_CHAP_STEP_TWO:
> -    //
> -    // The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
> -    //
> -    Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_CHAP_ALGORITHM);
> -    if (Value == NULL) {
> -      goto ON_EXIT;
> -    }
> -
> -    Algorithm = AsciiStrDecimalToUintn (Value);
> -    if (Algorithm != ISCSI_CHAP_ALGORITHM_MD5) {
> -      //
> -      // Unsupported algorithm is chosen by target.
> -      //
> -      goto ON_EXIT;
> -    }
> -
> -    Identifier = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_CHAP_IDENTIFIER);
> -    if (Identifier == NULL) {
> -      goto ON_EXIT;
> -    }
> -
> -    Challenge = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_CHAP_CHALLENGE);
> -    if (Challenge == NULL) {
> -      goto ON_EXIT;
> -    }
> -    //
> -    // Process the CHAP identifier and CHAP Challenge from Target
> -    // Calculate Response value
> -    //
> -    AuthData->InIdentifier      = (UINT32) AsciiStrDecimalToUintn (Identifier);
> -    AuthData->InChallengeLength = ISCSI_CHAP_AUTH_MAX_LEN;
> -    IScsiHexToBin ((UINT8 *) AuthData->InChallenge, &AuthData-
> >InChallengeLength, Challenge);
> -    Status = IScsiCHAPCalculateResponse (
> -              AuthData->InIdentifier,
> -              AuthData->AuthConfig.CHAPSecret,
> -              (UINT32) AsciiStrLen (AuthData->AuthConfig.CHAPSecret),
> -              AuthData->InChallenge,
> -              AuthData->InChallengeLength,
> -              AuthData->CHAPResponse
> -              );
> -
> -    //
> -    // Transit to next step.
> -    //
> -    Conn->CHAPStep = ISCSI_CHAP_STEP_THREE;
> -    break;
> -
> -  case ISCSI_CHAP_STEP_THREE:
> -    //
> -    // one way CHAP authentication and the target would like to
> -    // authenticate us.
> -    //
> -    Status = EFI_SUCCESS;
> -    break;
> -
> -  case ISCSI_CHAP_STEP_FOUR:
> -    ASSERT (AuthData->AuthConfig.CHAPType == ISCSI_CHAP_MUTUAL);
> -    //
> -    // The forth step, CHAP_N=<N> CHAP_R=<R> is received from Target.
> -    //
> -    Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME);
> -    if (Name == NULL) {
> -      goto ON_EXIT;
> -    }
> -
> -    Response = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_CHAP_RESPONSE);
> -    if (Response == NULL) {
> -      goto ON_EXIT;
> -    }
> -
> -    RspLen = ISCSI_CHAP_RSP_LEN;
> -    IScsiHexToBin (TargetRsp, &RspLen, Response);
> -
> -    //
> -    // Check the CHAP Response replied by Target.
> -    //
> -    Status = IScsiCHAPAuthTarget (AuthData, TargetRsp);
> -    break;
> -
> -  default:
> -    break;
> -  }
> -
> -ON_EXIT:
> -
> -  IScsiFreeKeyValueList (KeyValueList);
> -
> -  FreePool (Data);
> -
> -  return Status;
> -}
> -
> -/**
> -  This function fills the CHAP authentication information into the login PDU
> -  during the security negotiation stage in the iSCSI connection login.
> -
> -  @param[in]       Conn        The iSCSI connection.
> -  @param[in, out]  Pdu         The PDU to send out.
> -
> -  @retval EFI_SUCCESS          All check passed and the phase-related CHAP
> -                               authentication info is filled into the iSCSI PDU.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of protocol error happend.
> -**/
> -EFI_STATUS
> -IScsiCHAPToSendReq (
> -  IN      ISCSI_CONNECTION  *Conn,
> -  IN OUT  NET_BUF           *Pdu
> -  )
> -{
> -  EFI_STATUS                Status;
> -  ISCSI_SESSION             *Session;
> -  ISCSI_LOGIN_REQUEST       *LoginReq;
> -  ISCSI_CHAP_AUTH_DATA      *AuthData;
> -  CHAR8                     *Value;
> -  CHAR8                     ValueStr[256];
> -  CHAR8                     *Response;
> -  UINT32                    RspLen;
> -  CHAR8                     *Challenge;
> -  UINT32                    ChallengeLen;
> -
> -  ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
> -
> -  Session     = Conn->Session;
> -  AuthData    = &Session->AuthData;
> -  LoginReq    = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);
> -  if (LoginReq == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  Status      = EFI_SUCCESS;
> -
> -  RspLen      = 2 * ISCSI_CHAP_RSP_LEN + 3;
> -  Response    = AllocatePool (RspLen);
> -  if (Response == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  ChallengeLen  = 2 * ISCSI_CHAP_RSP_LEN + 3;
> -  Challenge     = AllocatePool (ChallengeLen);
> -  if (Challenge == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  switch (Conn->CHAPStep) {
> -  case ISCSI_CHAP_INITIAL:
> -    //
> -    // It's the initial Login Request. Fill in the key=value pairs mandatory
> -    // for the initial Login Request.
> -    //
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_INITIATOR_NAME, Session-
> >InitiatorName);
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_TARGET_NAME, Session-
> >ConfigData.NvData.TargetName);
> -
> -    if (AuthData->AuthConfig.CHAPType == ISCSI_CHAP_NONE) {
> -      Value = ISCSI_KEY_VALUE_NONE;
> -      ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
> -    } else {
> -      Value = ISCSI_AUTH_METHOD_CHAP;
> -    }
> -
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value);
> -
> -    break;
> -
> -  case ISCSI_CHAP_STEP_ONE:
> -    //
> -    // First step, send the Login Request with CHAP_A=<A1,A2...> key-value pair.
> -    //
> -    AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", ISCSI_CHAP_ALGORITHM_MD5);
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, ValueStr);
> -
> -    Conn->CHAPStep = ISCSI_CHAP_STEP_TWO;
> -    break;
> -
> -  case ISCSI_CHAP_STEP_THREE:
> -    //
> -    // Third step, send the Login Request with CHAP_N=<N> CHAP_R=<R> or
> -    // CHAP_N=<N> CHAP_R=<R> CHAP_I=<I> CHAP_C=<C> if target
> ahtentication is
> -    // required too.
> -    //
> -    // CHAP_N=<N>
> -    //
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_NAME, (CHAR8 *) &AuthData-
> >AuthConfig.CHAPName);
> -    //
> -    // CHAP_R=<R>
> -    //
> -    IScsiBinToHex ((UINT8 *) AuthData->CHAPResponse, ISCSI_CHAP_RSP_LEN,
> Response, &RspLen);
> -    IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
> -
> -    if (AuthData->AuthConfig.CHAPType == ISCSI_CHAP_MUTUAL) {
> -      //
> -      // CHAP_I=<I>
> -      //
> -      IScsiGenRandom ((UINT8 *) &AuthData->OutIdentifier, 1);
> -      AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier);
> -      IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr);
> -      //
> -      // CHAP_C=<C>
> -      //
> -      IScsiGenRandom ((UINT8 *) AuthData->OutChallenge,
> ISCSI_CHAP_RSP_LEN);
> -      AuthData->OutChallengeLength = ISCSI_CHAP_RSP_LEN;
> -      IScsiBinToHex ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN,
> Challenge, &ChallengeLen);
> -      IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
> -
> -      Conn->CHAPStep = ISCSI_CHAP_STEP_FOUR;
> -    }
> -    //
> -    // set the stage transition flag.
> -    //
> -    ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
> -    break;
> -
> -  default:
> -    Status = EFI_PROTOCOL_ERROR;
> -    break;
> -  }
> -
> -  FreePool (Response);
> -  FreePool (Challenge);
> -
> -  return Status;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
> deleted file mode 100644
> index cb1eff1b690c..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
> +++ /dev/null
> @@ -1,1264 +0,0 @@
> -/** @file
> -  Helper functions for configuring or getting the parameters relating to iSCSI.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -CHAR16          mVendorStorageName[]     = L"ISCSI_CONFIG_IFR_NVDATA";
> -BOOLEAN         mIScsiDeviceListUpdated  = FALSE;
> -UINTN           mNumberOfIScsiDevices    = 0;
> -ISCSI_FORM_CALLBACK_INFO  *mCallbackInfo = NULL;
> -
> -LIST_ENTRY      mIScsiConfigFormList = {
> -  &mIScsiConfigFormList,
> -  &mIScsiConfigFormList
> -};
> -
> -HII_VENDOR_DEVICE_PATH  mIScsiHiiVendorDevicePath = {
> -  {
> -    {
> -      HARDWARE_DEVICE_PATH,
> -      HW_VENDOR_DP,
> -      {
> -        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
> -        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> -      }
> -    },
> -    IP4_ISCSI_CONFIG_GUID
> -  },
> -  {
> -    END_DEVICE_PATH_TYPE,
> -    END_ENTIRE_DEVICE_PATH_SUBTYPE,
> -    {
> -      (UINT8) (END_DEVICE_PATH_LENGTH),
> -      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
> -    }
> -  }
> -};
> -
> -/**
> -  Convert the IPv4 address into a dotted string.
> -
> -  @param[in]   Ip   The IPv4 address.
> -  @param[out]  Str  The dotted IP string.
> -**/
> -VOID
> -IScsiIpToStr (
> -  IN  EFI_IPv4_ADDRESS  *Ip,
> -  OUT CHAR16            *Str
> -  )
> -{
> -  UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip-
> >Addr[1], Ip->Addr[2], Ip->Addr[3]);
> -}
> -
> -
> -/**
> -  Parse IsId in string format and convert it to binary.
> -
> -  @param[in]        String  The buffer of the string to be parsed.
> -  @param[in, out]   IsId    The buffer to store IsId.
> -
> -  @retval EFI_SUCCESS              The operation finished successfully.
> -  @retval EFI_INVALID_PARAMETER    Any input parameter is invalid.
> -
> -**/
> -EFI_STATUS
> -IScsiParseIsIdFromString (
> -  IN CONST CHAR16                    *String,
> -  IN OUT   UINT8                     *IsId
> -  )
> -{
> -  UINT8                          Index;
> -  CHAR16                         *IsIdStr;
> -  CHAR16                         TempStr[3];
> -  UINTN                          NodeVal;
> -  CHAR16                         PortString[ISCSI_NAME_IFR_MAX_SIZE];
> -  EFI_INPUT_KEY                  Key;
> -
> -  if ((String == NULL) || (IsId == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  IsIdStr = (CHAR16 *) String;
> -
> -  if (StrLen (IsIdStr) != 6) {
> -    UnicodeSPrint (
> -      PortString,
> -      (UINTN) sizeof (PortString),
> -      L"Error! Input is incorrect, please input 6 hex numbers!\n"
> -      );
> -
> -    CreatePopUp (
> -      EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
> -      &Key,
> -      PortString,
> -      NULL
> -      );
> -
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  for (Index = 3; Index < 6; Index++) {
> -    CopyMem (TempStr, IsIdStr, sizeof (TempStr));
> -    TempStr[2] = L'\0';
> -
> -    //
> -    // Convert the string to IsId. StrHexToUintn stops at the first character
> -    // that is not a valid hex character, '\0' here.
> -    //
> -    NodeVal = StrHexToUintn (TempStr);
> -
> -    IsId[Index] = (UINT8) NodeVal;
> -
> -    IsIdStr = IsIdStr + 2;
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Convert IsId from binary to string format.
> -
> -  @param[out]      String  The buffer to store the converted string.
> -  @param[in]       IsId    The buffer to store IsId.
> -
> -  @retval EFI_SUCCESS              The string converted successfully.
> -  @retval EFI_INVALID_PARAMETER    Any input parameter is invalid.
> -
> -**/
> -EFI_STATUS
> -IScsiConvertIsIdToString (
> -  OUT CHAR16                         *String,
> -  IN  UINT8                          *IsId
> -  )
> -{
> -  UINT8                          Index;
> -  UINTN                          Number;
> -
> -  if ((String == NULL) || (IsId == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  for (Index = 0; Index < 6; Index++) {
> -    if (IsId[Index] <= 0xF) {
> -      Number = UnicodeSPrint (
> -                 String,
> -                 2 * ISID_CONFIGURABLE_STORAGE,
> -                 L"0%X",
> -                 (UINTN) IsId[Index]
> -                 );
> -    } else {
> -      Number = UnicodeSPrint (
> -                 String,
> -                 2 * ISID_CONFIGURABLE_STORAGE,
> -                 L"%X",
> -                 (UINTN) IsId[Index]
> -                 );
> -
> -    }
> -
> -    String = String + Number;
> -  }
> -
> -  *String = L'\0';
> -
> -  return EFI_SUCCESS;
> -}
> -
> -
> -/**
> -  Update the list of iSCSI devices the iSCSI driver is controlling.
> -
> -  @retval EFI_SUCCESS            The callback successfully handled the action.
> -  @retval Others                 Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiUpdateDeviceList (
> -  VOID
> -  )
> -{
> -  EFI_STATUS                  Status;
> -  ISCSI_DEVICE_LIST           *DeviceList;
> -  UINTN                       DataSize;
> -  UINTN                       NumHandles;
> -  EFI_HANDLE                  *Handles;
> -  UINTN                       HandleIndex;
> -  UINTN                       Index;
> -  UINTN                       LastDeviceIndex;
> -  EFI_MAC_ADDRESS             MacAddress;
> -  UINTN                       HwAddressSize;
> -  UINT16                      VlanId;
> -  ISCSI_MAC_INFO              *CurMacInfo;
> -  ISCSI_MAC_INFO              TempMacInfo;
> -  CHAR16                      MacString[70];
> -  UINTN                       DeviceListSize;
> -
> -  //
> -  // Dump all the handles the Managed Network Service Binding Protocol is
> installed on.
> -  //
> -  Status = gBS->LocateHandleBuffer (
> -                  ByProtocol,
> -                  &gEfiManagedNetworkServiceBindingProtocolGuid,
> -                  NULL,
> -                  &NumHandles,
> -                  &Handles
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  DataSize = 0;
> -  Status = gRT->GetVariable (
> -                  L"iSCSIDeviceList",
> -                  &gIp4IScsiConfigGuid,
> -                  NULL,
> -                  &DataSize,
> -                  NULL
> -                  );
> -  if (Status == EFI_BUFFER_TOO_SMALL) {
> -    DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DataSize);
> -    ASSERT (DeviceList != NULL);
> -
> -    gRT->GetVariable (
> -          L"iSCSIDeviceList",
> -          &gIp4IScsiConfigGuid,
> -          NULL,
> -          &DataSize,
> -          DeviceList
> -          );
> -
> -    LastDeviceIndex = 0;
> -
> -    for (HandleIndex = 0; HandleIndex < NumHandles; HandleIndex++) {
> -      Status = NetLibGetMacAddress (Handles[HandleIndex], &MacAddress,
> &HwAddressSize);
> -      ASSERT (Status == EFI_SUCCESS);
> -      VlanId = NetLibGetVlanId (Handles[HandleIndex]);
> -
> -      for (Index = LastDeviceIndex; Index < DeviceList->NumDevice; Index++) {
> -        CurMacInfo = &DeviceList->MacInfo[Index];
> -        if ((CurMacInfo->Len == HwAddressSize) &&
> -            (CurMacInfo->VlanId == VlanId) &&
> -            (NET_MAC_EQUAL (&CurMacInfo->Mac, MacAddress.Addr,
> HwAddressSize))
> -            ) {
> -          //
> -          // The previous configured NIC is still here.
> -          //
> -          if (Index != LastDeviceIndex) {
> -            //
> -            // Swap the current MAC address entry with the one indexed by
> -            // LastDeviceIndex.
> -            //
> -            CopyMem (&TempMacInfo, CurMacInfo, sizeof (ISCSI_MAC_INFO));
> -            CopyMem (CurMacInfo, &DeviceList->MacInfo[LastDeviceIndex], sizeof
> (ISCSI_MAC_INFO));
> -            CopyMem (&DeviceList->MacInfo[LastDeviceIndex], &TempMacInfo,
> sizeof (ISCSI_MAC_INFO));
> -          }
> -
> -          LastDeviceIndex++;
> -        }
> -      }
> -
> -      if (LastDeviceIndex == DeviceList->NumDevice) {
> -        break;
> -      }
> -    }
> -
> -    for (Index = LastDeviceIndex; Index < DeviceList->NumDevice; Index++) {
> -      //
> -      // delete the variables
> -      //
> -      CurMacInfo = &DeviceList->MacInfo[Index];
> -      IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, CurMacInfo-
> >VlanId, MacString);
> -      gRT->SetVariable (MacString, &gEfiIScsiInitiatorNameProtocolGuid, 0, 0,
> NULL);
> -      gRT->SetVariable (MacString, &gIScsiCHAPAuthInfoGuid, 0, 0, NULL);
> -    }
> -
> -    FreePool (DeviceList);
> -  } else if (Status != EFI_NOT_FOUND) {
> -    FreePool (Handles);
> -    return Status;
> -  }
> -  //
> -  // Construct the new iSCSI device list.
> -  //
> -  DeviceListSize        = sizeof (ISCSI_DEVICE_LIST) + (NumHandles - 1) * sizeof
> (ISCSI_MAC_INFO);
> -  DeviceList            = (ISCSI_DEVICE_LIST *) AllocatePool (DeviceListSize);
> -  ASSERT (DeviceList != NULL);
> -  DeviceList->NumDevice = (UINT8) NumHandles;
> -
> -  for (Index = 0; Index < NumHandles; Index++) {
> -    NetLibGetMacAddress (Handles[Index], &MacAddress, &HwAddressSize);
> -
> -    CurMacInfo  = &DeviceList->MacInfo[Index];
> -    CopyMem (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize);
> -    CurMacInfo->Len = (UINT8) HwAddressSize;
> -    CurMacInfo->VlanId = NetLibGetVlanId (Handles[Index]);
> -  }
> -
> -  gRT->SetVariable (
> -        L"iSCSIDeviceList",
> -        &gIp4IScsiConfigGuid,
> -        ISCSI_CONFIG_VAR_ATTR,
> -        DeviceListSize,
> -        DeviceList
> -        );
> -
> -  FreePool (DeviceList);
> -  FreePool (Handles);
> -
> -  return Status;
> -}
> -
> -/**
> -  Get the iSCSI configuration form entry by the index of the goto opcode actived.
> -
> -  @param[in]  Index The 0-based index of the goto opcode actived.
> -
> -  @return The iSCSI configuration form entry found.
> -**/
> -ISCSI_CONFIG_FORM_ENTRY *
> -IScsiGetConfigFormEntryByIndex (
> -  IN UINT32 Index
> -  )
> -{
> -  UINT32                  CurrentIndex;
> -  LIST_ENTRY              *Entry;
> -  ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry;
> -
> -  CurrentIndex    = 0;
> -  ConfigFormEntry = NULL;
> -
> -  NET_LIST_FOR_EACH (Entry, &mIScsiConfigFormList) {
> -    if (CurrentIndex == Index) {
> -      ConfigFormEntry = NET_LIST_USER_STRUCT (Entry,
> ISCSI_CONFIG_FORM_ENTRY, Link);
> -      break;
> -    }
> -
> -    CurrentIndex++;
> -  }
> -
> -  return ConfigFormEntry;
> -}
> -
> -/**
> -  Convert the iSCSI configuration data into the IFR data.
> -
> -  @param[in]   ConfigFormEntry The iSCSI configuration form entry.
> -  @param[out]  IfrNvData       The IFR nv data.
> -
> -**/
> -VOID
> -IScsiConvertDeviceConfigDataToIfrNvData (
> -  IN ISCSI_CONFIG_FORM_ENTRY      *ConfigFormEntry,
> -  OUT ISCSI_CONFIG_IFR_NVDATA     *IfrNvData
> -  )
> -{
> -  ISCSI_SESSION_CONFIG_NVDATA   *SessionConfigData;
> -  ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData;
> -
> -  //
> -  // Normal session configuration parameters.
> -  //
> -  SessionConfigData                 = &ConfigFormEntry->SessionConfigData;
> -  IfrNvData->Enabled                = SessionConfigData->Enabled;
> -
> -  IfrNvData->InitiatorInfoFromDhcp  = SessionConfigData-
> >InitiatorInfoFromDhcp;
> -  IfrNvData->TargetInfoFromDhcp     = SessionConfigData-
> >TargetInfoFromDhcp;
> -  IfrNvData->TargetPort             = SessionConfigData->TargetPort;
> -
> -  IScsiIpToStr (&SessionConfigData->LocalIp, IfrNvData->LocalIp);
> -  IScsiIpToStr (&SessionConfigData->SubnetMask, IfrNvData->SubnetMask);
> -  IScsiIpToStr (&SessionConfigData->Gateway, IfrNvData->Gateway);
> -  IScsiIpToStr (&SessionConfigData->TargetIp, IfrNvData->TargetIp);
> -
> -  IScsiAsciiStrToUnicodeStr (SessionConfigData->TargetName, IfrNvData-
> >TargetName);
> -
> -  IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun);
> -
> -  IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId);
> -
> -  //
> -  // CHAP authentication parameters.
> -  //
> -  AuthConfigData      = &ConfigFormEntry->AuthConfigData;
> -
> -  IfrNvData->CHAPType = AuthConfigData->CHAPType;
> -
> -  IScsiAsciiStrToUnicodeStr (AuthConfigData->CHAPName, IfrNvData-
> >CHAPName);
> -  IScsiAsciiStrToUnicodeStr (AuthConfigData->CHAPSecret, IfrNvData-
> >CHAPSecret);
> -  IScsiAsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPName, IfrNvData-
> >ReverseCHAPName);
> -  IScsiAsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPSecret, IfrNvData-
> >ReverseCHAPSecret);
> -}
> -
> -/**
> -  This function allows the caller to request the current
> -  configuration for one or more named elements. The resulting
> -  string is in <ConfigAltResp> format. Any and all alternative
> -  configuration strings shall also be appended to the end of the
> -  current configuration string. If they are, they must appear
> -  after the current configuration. They must contain the same
> -  routing (GUID, NAME, PATH) as the current configuration string.
> -  They must have an additional description indicating the type of
> -  alternative configuration the string represents,
> -  "ALTCFG=<StringToken>". That <StringToken> (when
> -  converted from Hex UNICODE to binary) is a reference to a
> -  string in the associated string pack.
> -
> -  @param[in] This       Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
> -  @param[in] Request    A null-terminated Unicode string in
> -                        <ConfigRequest> format. Note that this
> -                        includes the routing information as well as
> -                        the configurable name / value pairs. It is
> -                        invalid for this string to be in
> -                        <MultiConfigRequest> format.
> -  @param[out] Progress  On return, points to a character in the
> -                        Request string. Points to the string's null
> -                        terminator if request was successful. Points
> -                        to the most recent "&" before the first
> -                        failing name / value pair (or the beginning
> -                        of the string if the failure is in the first
> -                        name / value pair) if the request was not
> -                        successful.
> -  @param[out] Results   A null-terminated Unicode string in
> -                        <ConfigAltResp> format which has all values
> -                        filled in for the names in the Request string.
> -                        String to be allocated by the called function.
> -
> -  @retval EFI_SUCCESS             The Results string is filled with the
> -                                  values corresponding to all requested
> -                                  names.
> -  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the
> -                                  parts of the results that must be
> -                                  stored awaiting possible future
> -                                  protocols.
> -  @retval EFI_INVALID_PARAMETER   For example, passing in a NULL
> -                                  for the Request parameter
> -                                  would result in this type of
> -                                  error. In this case, the
> -                                  Progress parameter would be
> -                                  set to NULL.
> -  @retval EFI_NOT_FOUND           Routing data doesn't match any
> -                                  known driver. Progress set to the
> -                                  first character in the routing header.
> -                                  Note: There is no requirement that the
> -                                  driver validate the routing data. It
> -                                  must skip the <ConfigHdr> in order to
> -                                  process the names.
> -  @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set
> -                                  to most recent & before the
> -                                  error or the beginning of the
> -                                  string.
> -  @retval EFI_INVALID_PARAMETER   Unknown name. Progress points
> -                                  to the & before the name in
> -                                  question.Currently not implemented.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiFormExtractConfig (
> -  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
> -  IN  CONST EFI_STRING                       Request,
> -  OUT EFI_STRING                             *Progress,
> -  OUT EFI_STRING                             *Results
> -  )
> -{
> -  EFI_STATUS                       Status;
> -  CHAR8                            InitiatorName[ISCSI_NAME_MAX_SIZE];
> -  UINTN                            BufferSize;
> -  ISCSI_CONFIG_IFR_NVDATA          *IfrNvData;
> -  ISCSI_FORM_CALLBACK_INFO         *Private;
> -  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;
> -  EFI_STRING                       ConfigRequestHdr;
> -  EFI_STRING                       ConfigRequest;
> -  BOOLEAN                          AllocatedRequest;
> -  UINTN                            Size;
> -
> -  if (Progress == NULL || Results == NULL) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  *Progress = Request;
> -  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request,
> &gIp4IScsiConfigGuid, mVendorStorageName)) {
> -    return EFI_NOT_FOUND;
> -  }
> -
> -  ConfigRequestHdr = NULL;
> -  ConfigRequest    = NULL;
> -  AllocatedRequest = FALSE;
> -  Size             = 0;
> -
> -  if (!mIScsiDeviceListUpdated) {
> -    //
> -    // Update the device list.
> -    //
> -    IScsiUpdateDeviceList ();
> -    mIScsiDeviceListUpdated = TRUE;
> -  }
> -
> -  Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
> -  IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));
> -  ASSERT (IfrNvData != NULL);
> -  if (Private->Current != NULL) {
> -    IScsiConvertDeviceConfigDataToIfrNvData (Private->Current, IfrNvData);
> -  }
> -
> -  BufferSize  = ISCSI_NAME_MAX_SIZE;
> -  Status      = gIScsiInitiatorName.Get (&gIScsiInitiatorName, &BufferSize,
> InitiatorName);
> -  if (EFI_ERROR (Status)) {
> -    IfrNvData->InitiatorName[0] = L'\0';
> -  } else {
> -    IScsiAsciiStrToUnicodeStr (InitiatorName, IfrNvData->InitiatorName);
> -  }
> -
> -  //
> -  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
> -  //
> -  HiiConfigRouting = Private->ConfigRouting;
> -  BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
> -  ConfigRequest = Request;
> -  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
> -    //
> -    // Request has no request element, construct full request string.
> -    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
> -    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW"
> followed by a Null-terminator
> -    //
> -    ConfigRequestHdr = HiiConstructConfigHdr (&gIp4IScsiConfigGuid,
> mVendorStorageName, Private->DriverHandle);
> -    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
> -    ConfigRequest = AllocateZeroPool (Size);
> -    ASSERT (ConfigRequest != NULL);
> -    AllocatedRequest = TRUE;
> -    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX",
> ConfigRequestHdr, (UINT64)BufferSize);
> -    FreePool (ConfigRequestHdr);
> -  }
> -  Status = HiiConfigRouting->BlockToConfig (
> -                               HiiConfigRouting,
> -                               ConfigRequest,
> -                               (UINT8 *) IfrNvData,
> -                               BufferSize,
> -                               Results,
> -                               Progress
> -                               );
> -  FreePool (IfrNvData);
> -  //
> -  // Free the allocated config request string.
> -  //
> -  if (AllocatedRequest) {
> -    FreePool (ConfigRequest);
> -    ConfigRequest = NULL;
> -  }
> -
> -  //
> -  // Set Progress string to the original request string.
> -  //
> -  if (Request == NULL) {
> -    *Progress = NULL;
> -  } else if (StrStr (Request, L"OFFSET") == NULL) {
> -    *Progress = Request + StrLen (Request);
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  This function applies changes in a driver's configuration.
> -  Input is a Configuration, which has the routing data for this
> -  driver followed by name / value configuration pairs. The driver
> -  must apply those pairs to its configurable storage. If the
> -  driver's configuration is stored in a linear block of data
> -  and the driver's name / value pairs are in <BlockConfig>
> -  format, it may use the ConfigToBlock helper function (above) to
> -  simplify the job. Currently not implemented.
> -
> -  @param[in]  This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
> -  @param[in]  Configuration  A null-terminated Unicode string in
> -                             <ConfigString> format.
> -  @param[out] Progress       A pointer to a string filled in with the
> -                             offset of the most recent '&' before the
> -                             first failing name / value pair (or the
> -                             beginn ing of the string if the failure
> -                             is in the first name / value pair) or
> -                             the terminating NULL if all was
> -                             successful.
> -
> -  @retval EFI_SUCCESS             The results have been distributed or are
> -                                  awaiting distribution.
> -  @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the
> -                                  parts of the results that must be
> -                                  stored awaiting possible future
> -                                  protocols.
> -  @retval EFI_INVALID_PARAMETERS  Passing in a NULL for the
> -                                  Results parameter would result
> -                                  in this type of error.
> -  @retval EFI_NOT_FOUND           Target for the specified routing data
> -                                  was not found.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiFormRouteConfig (
> -  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
> -  IN  CONST EFI_STRING                       Configuration,
> -  OUT EFI_STRING                             *Progress
> -  )
> -{
> -  if (Configuration == NULL || Progress == NULL) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  //
> -  // Check routing data in <ConfigHdr>.
> -  // Note: if only one Storage is used, then this checking could be skipped.
> -  //
> -  if (!HiiIsConfigHdrMatch (Configuration, &gIp4IScsiConfigGuid,
> mVendorStorageName)) {
> -    *Progress = Configuration;
> -    return EFI_NOT_FOUND;
> -  }
> -
> -  *Progress = Configuration + StrLen (Configuration);
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  This function is called to provide results data to the driver.
> -  This data consists of a unique key that is used to identify
> -  which data is either being passed back or being asked for.
> -
> -  @param[in]  This               Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
> -  @param[in]  Action             Specifies the type of action taken by the browser.
> -  @param[in]  QuestionId         A unique value which is sent to the original
> -                                 exporting driver so that it can identify the type
> -                                 of data to expect. The format of the data tends to
> -                                 vary based on the opcode that enerated the callback.
> -  @param[in]  Type               The type of value for the question.
> -  @param[in]  Value              A pointer to the data being sent to the original
> -                                 exporting driver.
> -  @param[out]  ActionRequest     On return, points to the action requested by
> the
> -                                 callback function.
> -
> -  @retval EFI_SUCCESS            The callback successfully handled the action.
> -  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold
> the
> -                                 variable and its data.
> -  @retval EFI_DEVICE_ERROR       The variable could not be saved.
> -  @retval EFI_UNSUPPORTED        The specified Action is not supported by the
> -                                 callback.Currently not implemented.
> -  @retval EFI_INVALID_PARAMETERS Passing in wrong parameter.
> -  @retval Others                 Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiFormCallback (
> -  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
> -  IN  EFI_BROWSER_ACTION                     Action,
> -  IN  EFI_QUESTION_ID                        QuestionId,
> -  IN  UINT8                                  Type,
> -  IN  EFI_IFR_TYPE_VALUE                     *Value,
> -  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest
> -  )
> -{
> -  ISCSI_FORM_CALLBACK_INFO  *Private;
> -  UINTN                     BufferSize;
> -  CHAR8                     IScsiName[ISCSI_NAME_MAX_SIZE];
> -  CHAR16                    PortString[128];
> -  CHAR8                     Ip4String[IP4_STR_MAX_SIZE];
> -  CHAR8                     LunString[ISCSI_LUN_STR_MAX_LEN];
> -  UINT64                    Lun;
> -  EFI_STRING_ID             DeviceFormTitleToken;
> -  ISCSI_CONFIG_IFR_NVDATA   *IfrNvData;
> -  ISCSI_CONFIG_FORM_ENTRY   *ConfigFormEntry;
> -  EFI_IP_ADDRESS            HostIp;
> -  EFI_IP_ADDRESS            SubnetMask;
> -  EFI_IP_ADDRESS            Gateway;
> -  EFI_STATUS                Status;
> -  EFI_INPUT_KEY             Key;
> -
> -  if (Action != EFI_BROWSER_ACTION_CHANGING && Action !=
> EFI_BROWSER_ACTION_CHANGED) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  Private   = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
> -  //
> -  // Retrieve uncommitted data from Browser
> -  //
> -  IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));
> -  ASSERT (IfrNvData != NULL);
> -  if (!HiiGetBrowserData (&gIp4IScsiConfigGuid, mVendorStorageName, sizeof
> (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData)) {
> -    FreePool (IfrNvData);
> -    return EFI_NOT_FOUND;
> -  }
> -  Status = EFI_SUCCESS;
> -
> -  if (Action == EFI_BROWSER_ACTION_CHANGING) {
> -    if ((QuestionId >= KEY_DEVICE_ENTRY_BASE) && (QuestionId <
> (mNumberOfIScsiDevices + KEY_DEVICE_ENTRY_BASE))) {
> -      //
> -      // In case goto the device configuration form, update the device form title.
> -      //
> -      ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (QuestionId -
> KEY_DEVICE_ENTRY_BASE));
> -      ASSERT (ConfigFormEntry != NULL);
> -
> -      UnicodeSPrint (PortString, (UINTN) sizeof (PortString), L"Port %s",
> ConfigFormEntry->MacString);
> -      DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE;
> -      HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString,
> NULL);
> -
> -      IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);
> -
> -      Private->Current = ConfigFormEntry;
> -    }
> -  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
> -    switch (QuestionId) {
> -    case KEY_INITIATOR_NAME:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName);
> -      BufferSize  = AsciiStrSize (IScsiName);
> -
> -      Status      = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize,
> IScsiName);
> -      if (EFI_ERROR (Status)) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> iSCSI Name!", NULL);
> -      }
> -
> -      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
> -      break;
> -
> -    case KEY_LOCAL_IP:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);
> -      Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);
> -      if (EFI_ERROR (Status) ||
> -          ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
> -           !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private-
> >Current->SessionConfigData.SubnetMask.Addr)))) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> IP address!", NULL);
> -        Status = EFI_INVALID_PARAMETER;
> -      } else {
> -        CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4,
> sizeof (HostIp.v4));
> -      }
> -
> -      break;
> -
> -    case KEY_SUBNET_MASK:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->SubnetMask, Ip4String);
> -      Status = IScsiAsciiStrToIp (Ip4String, &SubnetMask.v4);
> -      if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) &&
> (IScsiGetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> Subnet Mask!", NULL);
> -        Status = EFI_INVALID_PARAMETER;
> -      } else {
> -        CopyMem (&Private->Current->SessionConfigData.SubnetMask,
> &SubnetMask.v4, sizeof (SubnetMask.v4));
> -      }
> -
> -      break;
> -
> -    case KEY_GATE_WAY:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);
> -      Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);
> -      if (EFI_ERROR (Status) ||
> -          ((Gateway.Addr[0] != 0) &&
> -           (Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
> -           !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private-
> >Current->SessionConfigData.SubnetMask.Addr)))) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> Gateway!", NULL);
> -        Status = EFI_INVALID_PARAMETER;
> -      } else {
> -        CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4,
> sizeof (Gateway.v4));
> -      }
> -
> -      break;
> -
> -    case KEY_TARGET_IP:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);
> -      Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);
> -      if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST (EFI_NTOHL(HostIp.v4))
> || IP4_IS_UNSPECIFIED (EFI_NTOHL(HostIp.v4))) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> IP address!", NULL);
> -        Status = EFI_INVALID_PARAMETER;
> -      } else {
> -        CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp.v4,
> sizeof (HostIp.v4));
> -      }
> -
> -      break;
> -
> -    case KEY_TARGET_NAME:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->TargetName, IScsiName);
> -      Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName));
> -      if (EFI_ERROR (Status)) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> iSCSI Name!", NULL);
> -      } else {
> -        AsciiStrCpyS (Private->Current->SessionConfigData.TargetName,
> ISCSI_NAME_MAX_SIZE, IScsiName);
> -      }
> -
> -      break;
> -
> -    case KEY_DHCP_ENABLE:
> -      if (IfrNvData->InitiatorInfoFromDhcp == 0) {
> -        IfrNvData->TargetInfoFromDhcp = 0;
> -      }
> -
> -      break;
> -
> -    case KEY_BOOT_LUN:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->BootLun, LunString);
> -      Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);
> -      if (EFI_ERROR (Status)) {
> -        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid
> LUN string!", NULL);
> -      } else {
> -        CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof
> (Lun));
> -      }
> -
> -      break;
> -
> -    case KEY_CHAP_NAME:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->CHAPName, Private->Current-
> >AuthConfigData.CHAPName);
> -      break;
> -
> -    case KEY_CHAP_SECRET:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->CHAPSecret, Private->Current-
> >AuthConfigData.CHAPSecret);
> -      break;
> -
> -    case KEY_REVERSE_CHAP_NAME:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->ReverseCHAPName, Private-
> >Current->AuthConfigData.ReverseCHAPName);
> -      break;
> -
> -    case KEY_REVERSE_CHAP_SECRET:
> -      IScsiUnicodeStrToAsciiStr (IfrNvData->ReverseCHAPSecret, Private-
> >Current->AuthConfigData.ReverseCHAPSecret);
> -      break;
> -
> -    case KEY_CONFIG_ISID:
> -      IScsiParseIsIdFromString (IfrNvData->IsId, Private->Current-
> >SessionConfigData.IsId);
> -      IScsiConvertIsIdToString (IfrNvData->IsId, Private->Current-
> >SessionConfigData.IsId);
> -
> -      break;
> -
> -    case KEY_SAVE_CHANGES:
> -      //
> -      // First, update those fields which don't have INTERACTIVE set.
> -      //
> -      Private->Current->SessionConfigData.Enabled               = IfrNvData->Enabled;
> -      Private->Current->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData-
> >InitiatorInfoFromDhcp;
> -      Private->Current->SessionConfigData.TargetPort            = IfrNvData-
> >TargetPort;
> -      if (Private->Current->SessionConfigData.TargetPort == 0) {
> -        Private->Current->SessionConfigData.TargetPort =
> ISCSI_WELL_KNOWN_PORT;
> -      }
> -
> -      Private->Current->SessionConfigData.TargetInfoFromDhcp  = IfrNvData-
> >TargetInfoFromDhcp;
> -      Private->Current->AuthConfigData.CHAPType               = IfrNvData-
> >CHAPType;
> -
> -      //
> -      // Only do full parameter validation if iSCSI is enabled on this device.
> -      //
> -      if (Private->Current->SessionConfigData.Enabled) {
> -        //
> -        // Validate the address configuration of the Initiator if DHCP isn't
> -        // deployed.
> -        //
> -        if (!Private->Current->SessionConfigData.InitiatorInfoFromDhcp) {
> -          CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.LocalIp,
> sizeof (HostIp.v4));
> -          CopyMem (&SubnetMask.v4, &Private->Current-
> >SessionConfigData.SubnetMask, sizeof (SubnetMask.v4));
> -          CopyMem (&Gateway.v4, &Private->Current-
> >SessionConfigData.Gateway, sizeof (Gateway.v4));
> -
> -          if ((Gateway.Addr[0] != 0)) {
> -            if (SubnetMask.Addr[0] == 0) {
> -              CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key,
> L"Gateway address is set but subnet mask is zero.", NULL);
> -              Status = EFI_INVALID_PARAMETER;
> -              break;
> -            } else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0],
> SubnetMask.Addr[0])) {
> -              CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key,
> L"Local IP and Gateway are not in the same subnet.", NULL);
> -              Status = EFI_INVALID_PARAMETER;
> -              break;
> -            }
> -          }
> -        }
> -        //
> -        // Validate target configuration if DHCP isn't deployed.
> -        //
> -        if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {
> -          CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp,
> sizeof (HostIp.v4));
> -          if (IP4_IS_UNSPECIFIED (NTOHL (HostIp.Addr[0])) ||
> IP4_IS_LOCAL_BROADCAST (NTOHL (HostIp.Addr[0]))) {
> -            CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key,
> L"Target IP is invalid!", NULL);
> -            Status = EFI_INVALID_PARAMETER;
> -            break;
> -          }
> -
> -          //
> -          // Validate iSCSI target name configuration again:
> -          // The format of iSCSI target name is already verified when user input the
> name;
> -          // here we only check the case user does not input the name.
> -          //
> -          if (Private->Current->SessionConfigData.TargetName[0] == '\0') {
> -            CreatePopUp (
> -              EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
> -              &Key,
> -              L"iSCSI target name is NULL!",
> -              NULL
> -              );
> -            Status = EFI_INVALID_PARAMETER;
> -            break;
> -          }
> -
> -        }
> -
> -        if (IfrNvData->CHAPType != ISCSI_CHAP_NONE) {
> -          if ((IfrNvData->CHAPName[0] == '\0') || (IfrNvData->CHAPSecret[0] ==
> '\0')) {
> -            CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key,
> L"CHAP Name or CHAP Secret is invalid!", NULL);
> -            Status = EFI_INVALID_PARAMETER;
> -            break;
> -          }
> -
> -          if ((IfrNvData->CHAPType == ISCSI_CHAP_MUTUAL) &&
> -              ((IfrNvData->ReverseCHAPName[0] == '\0') || (IfrNvData-
> >ReverseCHAPSecret[0] == '\0'))
> -              ) {
> -            CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key,
> L"Reverse CHAP Name or Reverse CHAP Secret is invalid!", NULL);
> -            Status = EFI_INVALID_PARAMETER;
> -            break;
> -          }
> -        }
> -      }
> -
> -      BufferSize = sizeof (Private->Current->SessionConfigData);
> -      gRT->SetVariable (
> -            Private->Current->MacString,
> -            &gEfiIScsiInitiatorNameProtocolGuid,
> -            ISCSI_CONFIG_VAR_ATTR,
> -            BufferSize,
> -            &Private->Current->SessionConfigData
> -            );
> -
> -      BufferSize = sizeof (Private->Current->AuthConfigData);
> -      gRT->SetVariable (
> -            Private->Current->MacString,
> -            &gIScsiCHAPAuthInfoGuid,
> -            ISCSI_CONFIG_VAR_ATTR,
> -            BufferSize,
> -            &Private->Current->AuthConfigData
> -            );
> -      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
> -      break;
> -
> -    default:
> -      break;
> -    }
> -  }
> -
> -  if (!EFI_ERROR (Status)) {
> -    //
> -    // Pass changed uncommitted data back to Form Browser
> -    //
> -    HiiSetBrowserData (&gIp4IScsiConfigGuid, mVendorStorageName, sizeof
> (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData, NULL);
> -  }
> -
> -  FreePool (IfrNvData);
> -
> -  return Status;
> -}
> -
> -/**
> -  Updates the iSCSI configuration form to add/delete an entry for the iSCSI
> -  device specified by the Controller.
> -
> -  @param[in]  DriverBindingHandle The driverbinding handle.
> -  @param[in]  Controller          The controller handle of the iSCSI device.
> -  @param[in]  AddForm             Whether to add or delete a form entry.
> -
> -  @retval EFI_SUCCESS             The iSCSI configuration form is updated.
> -  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> -  @retval Others                  Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiConfigUpdateForm (
> -  IN EFI_HANDLE  DriverBindingHandle,
> -  IN EFI_HANDLE  Controller,
> -  IN BOOLEAN     AddForm
> -  )
> -{
> -  LIST_ENTRY                  *Entry;
> -  ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;
> -  BOOLEAN                     EntryExisted;
> -  EFI_STATUS                  Status;
> -  EFI_MAC_ADDRESS             MacAddress;
> -  UINTN                       HwAddressSize;
> -  UINT16                      VlanId;
> -  CHAR16                      PortString[128];
> -  UINT16                      FormIndex;
> -  UINTN                       BufferSize;
> -  VOID                        *StartOpCodeHandle;
> -  VOID                        *EndOpCodeHandle;
> -  EFI_IFR_GUID_LABEL          *StartLabel;
> -  EFI_IFR_GUID_LABEL          *EndLabel;
> -
> -  ConfigFormEntry = NULL;
> -  EntryExisted    = FALSE;
> -
> -  NET_LIST_FOR_EACH (Entry, &mIScsiConfigFormList) {
> -    ConfigFormEntry = NET_LIST_USER_STRUCT (Entry,
> ISCSI_CONFIG_FORM_ENTRY, Link);
> -
> -    if (ConfigFormEntry->Controller == Controller) {
> -      EntryExisted = TRUE;
> -      break;
> -    }
> -  }
> -
> -  if (AddForm) {
> -    if (EntryExisted) {
> -      return EFI_SUCCESS;
> -    } else {
> -      //
> -      // Add a new form.
> -      //
> -      ConfigFormEntry = (ISCSI_CONFIG_FORM_ENTRY *) AllocateZeroPool
> (sizeof (ISCSI_CONFIG_FORM_ENTRY));
> -      if (ConfigFormEntry == NULL) {
> -        return EFI_OUT_OF_RESOURCES;
> -      }
> -
> -      InitializeListHead (&ConfigFormEntry->Link);
> -      ConfigFormEntry->Controller = Controller;
> -
> -      //
> -      // Get the MAC address and convert it into the formatted string.
> -      //
> -      Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);
> -      ASSERT (Status == EFI_SUCCESS);
> -      VlanId = NetLibGetVlanId (Controller);
> -
> -      IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId,
> ConfigFormEntry->MacString);
> -
> -      //
> -      // Get the normal session configuration data.
> -      //
> -      BufferSize = sizeof (ConfigFormEntry->SessionConfigData);
> -      Status = gRT->GetVariable (
> -                      ConfigFormEntry->MacString,
> -                      &gEfiIScsiInitiatorNameProtocolGuid,
> -                      NULL,
> -                      &BufferSize,
> -                      &ConfigFormEntry->SessionConfigData
> -                      );
> -      if (EFI_ERROR (Status)) {
> -        ZeroMem (&ConfigFormEntry->SessionConfigData, sizeof
> (ConfigFormEntry->SessionConfigData));
> -
> -        //
> -        // Generate OUI-format ISID based on MAC address.
> -        //
> -        CopyMem (ConfigFormEntry->SessionConfigData.IsId, &MacAddress, 6);
> -        ConfigFormEntry->SessionConfigData.IsId[0] =
> -          (UINT8) (ConfigFormEntry->SessionConfigData.IsId[0] & 0x3F);
> -      }
> -      //
> -      // Get the CHAP authentication configuration data.
> -      //
> -      BufferSize = sizeof (ConfigFormEntry->AuthConfigData);
> -      Status = gRT->GetVariable (
> -                      ConfigFormEntry->MacString,
> -                      &gIScsiCHAPAuthInfoGuid,
> -                      NULL,
> -                      &BufferSize,
> -                      &ConfigFormEntry->AuthConfigData
> -                      );
> -      if (EFI_ERROR (Status)) {
> -        ZeroMem (&ConfigFormEntry->AuthConfigData, sizeof (ConfigFormEntry-
> >AuthConfigData));
> -      }
> -      //
> -      // Compose the Port string and create a new EFI_STRING_ID.
> -      //
> -      UnicodeSPrint (PortString, sizeof (PortString), L"Port %s", ConfigFormEntry-
> >MacString);
> -      ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo-
> >RegisteredHandle, 0, PortString, NULL);
> -
> -      //
> -      // Compose the help string of this port and create a new EFI_STRING_ID.
> -      //
> -      UnicodeSPrint (PortString, sizeof (PortString), L"Set the iSCSI parameters on
> port %s", ConfigFormEntry->MacString);
> -      ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo-
> >RegisteredHandle, 0, PortString, NULL);
> -
> -      InsertTailList (&mIScsiConfigFormList, &ConfigFormEntry->Link);
> -      mNumberOfIScsiDevices++;
> -    }
> -  } else {
> -    ASSERT (EntryExisted);
> -
> -    mNumberOfIScsiDevices--;
> -    RemoveEntryList (&ConfigFormEntry->Link);
> -    FreePool (ConfigFormEntry);
> -    mCallbackInfo->Current = NULL;
> -  }
> -  //
> -  // Allocate space for creation of Buffer
> -  //
> -
> -  //
> -  // Init OpCode Handle
> -  //
> -  StartOpCodeHandle = HiiAllocateOpCodeHandle ();
> -  ASSERT (StartOpCodeHandle != NULL);
> -
> -  EndOpCodeHandle = HiiAllocateOpCodeHandle ();
> -  ASSERT (EndOpCodeHandle != NULL);
> -
> -  //
> -  // Create Hii Extend Label OpCode as the start opcode
> -  //
> -  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode
> (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
> -  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
> -  StartLabel->Number       = DEVICE_ENTRY_LABEL;
> -
> -  //
> -  // Create Hii Extend Label OpCode as the end opcode
> -  //
> -  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle,
> &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
> -  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
> -  EndLabel->Number       = LABEL_END;
> -
> -  FormIndex = 0;
> -  NET_LIST_FOR_EACH (Entry, &mIScsiConfigFormList) {
> -    ConfigFormEntry = NET_LIST_USER_STRUCT (Entry,
> ISCSI_CONFIG_FORM_ENTRY, Link);
> -
> -    HiiCreateGotoOpCode (
> -      StartOpCodeHandle,                            // Container for dynamic created
> opcodes
> -      FORMID_DEVICE_FORM,                           // Target Form ID
> -      ConfigFormEntry->PortTitleToken,              // Prompt text
> -      ConfigFormEntry->PortTitleHelpToken,          // Help text
> -      EFI_IFR_FLAG_CALLBACK,                        // Question flag
> -      (UINT16)(KEY_DEVICE_ENTRY_BASE + FormIndex)   // Question ID
> -      );
> -
> -    FormIndex++;
> -  }
> -
> -  HiiUpdateForm (
> -    mCallbackInfo->RegisteredHandle,
> -    &gIp4IScsiConfigGuid,
> -    FORMID_MAIN_FORM,
> -    StartOpCodeHandle, // Label DEVICE_ENTRY_LABEL
> -    EndOpCodeHandle    // LABEL_END
> -    );
> -
> -  HiiFreeOpCodeHandle (StartOpCodeHandle);
> -  HiiFreeOpCodeHandle (EndOpCodeHandle);
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Initialize the iSCSI configuration form.
> -
> -  @param[in]  DriverBindingHandle  The iSCSI driverbinding handle.
> -
> -  @retval EFI_SUCCESS              The iSCSI configuration form is initialized.
> -  @retval EFI_OUT_OF_RESOURCES     Failed to allocate memory.
> -  @retval Others                   Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiConfigFormInit (
> -  VOID
> -  )
> -{
> -  EFI_STATUS                  Status;
> -  EFI_HII_DATABASE_PROTOCOL   *HiiDatabase;
> -  ISCSI_FORM_CALLBACK_INFO    *CallbackInfo;
> -
> -  Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID
> **)&HiiDatabase);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) AllocateZeroPool (sizeof
> (ISCSI_FORM_CALLBACK_INFO));
> -  if (CallbackInfo == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  CallbackInfo->Signature   = ISCSI_FORM_CALLBACK_INFO_SIGNATURE;
> -  CallbackInfo->HiiDatabase = HiiDatabase;
> -  CallbackInfo->Current     = NULL;
> -
> -  CallbackInfo->ConfigAccess.ExtractConfig = IScsiFormExtractConfig;
> -  CallbackInfo->ConfigAccess.RouteConfig = IScsiFormRouteConfig;
> -  CallbackInfo->ConfigAccess.Callback = IScsiFormCallback;
> -
> -  Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL,
> (VOID **)&CallbackInfo->ConfigRouting);
> -  if (EFI_ERROR (Status)) {
> -    FreePool(CallbackInfo);
> -    return Status;
> -  }
> -
> -  //
> -  // Install Device Path Protocol and Config Access protocol to driver handle
> -  //
> -  Status = gBS->InstallMultipleProtocolInterfaces (
> -                  &CallbackInfo->DriverHandle,
> -                  &gEfiDevicePathProtocolGuid,
> -                  &mIScsiHiiVendorDevicePath,
> -                  &gEfiHiiConfigAccessProtocolGuid,
> -                  &CallbackInfo->ConfigAccess,
> -                  NULL
> -                  );
> -  ASSERT_EFI_ERROR (Status);
> -
> -  //
> -  // Publish our HII data
> -  //
> -  CallbackInfo->RegisteredHandle = HiiAddPackages (
> -                                     &gIp4IScsiConfigGuid,
> -                                     CallbackInfo->DriverHandle,
> -                                     IScsi4DxeStrings,
> -                                     IScsiConfigDxeBin,
> -                                     NULL
> -                                     );
> -  if (CallbackInfo->RegisteredHandle == NULL) {
> -    FreePool(CallbackInfo);
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  mCallbackInfo = CallbackInfo;
> -
> -  return Status;
> -}
> -
> -/**
> -  Unload the iSCSI configuration form, this includes: delete all the iSCSI
> -  device configuration entries, uninstall the form callback protocol and
> -  free the resources used.
> -
> -  @param[in]  DriverBindingHandle The iSCSI driverbinding handle.
> -
> -  @retval EFI_SUCCESS             The iSCSI configuration form is unloaded.
> -  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> -**/
> -EFI_STATUS
> -IScsiConfigFormUnload (
> -  IN EFI_HANDLE  DriverBindingHandle
> -  )
> -{
> -  ISCSI_CONFIG_FORM_ENTRY     *ConfigFormEntry;
> -
> -  while (!IsListEmpty (&mIScsiConfigFormList)) {
> -    //
> -    // Uninstall the device forms as the iSCSI driver instance may fail to
> -    // control the controller but still install the device configuration form.
> -    // In such case, upon driver unloading, the driver instance's driverbinding.
> -    // stop () won't be called, so we have to take this chance here to uninstall
> -    // the device form.
> -    //
> -    ConfigFormEntry = NET_LIST_USER_STRUCT
> (mIScsiConfigFormList.ForwardLink, ISCSI_CONFIG_FORM_ENTRY, Link);
> -    IScsiConfigUpdateForm (DriverBindingHandle, ConfigFormEntry->Controller,
> FALSE);
> -  }
> -
> -  //
> -  // Remove HII package list
> -  //
> -  mCallbackInfo->HiiDatabase->RemovePackageList (
> -                                mCallbackInfo->HiiDatabase,
> -                                mCallbackInfo->RegisteredHandle
> -                                );
> -
> -  //
> -  // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
> -  //
> -  gBS->UninstallMultipleProtocolInterfaces (
> -         mCallbackInfo->DriverHandle,
> -         &gEfiDevicePathProtocolGuid,
> -         &mIScsiHiiVendorDevicePath,
> -         &gEfiHiiConfigAccessProtocolGuid,
> -         &mCallbackInfo->ConfigAccess,
> -         NULL
> -         );
> -  FreePool (mCallbackInfo);
> -
> -  return EFI_SUCCESS;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
> deleted file mode 100644
> index 6a876c8b69dd..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
> +++ /dev/null
> @@ -1,472 +0,0 @@
> -/** @file
> -  iSCSI DHCP related configuration routines.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -/**
> -  Extract the Root Path option and get the required target information.
> -
> -  @param[in]        RootPath         The RootPath.
> -  @param[in]        Length           Length of the RootPath option payload.
> -  @param[in, out]   ConfigNvData     The iSCSI session configuration data read
> from nonvolatile device.
> -
> -  @retval EFI_SUCCESS           All required information is extracted from the
> RootPath option.
> -  @retval EFI_NOT_FOUND         The RootPath is not an iSCSI RootPath.
> -  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.
> -  @retval EFI_INVALID_PARAMETER The RootPath is mal-formatted.
> -**/
> -EFI_STATUS
> -IScsiDhcpExtractRootPath (
> -  IN      CHAR8                        *RootPath,
> -  IN      UINT8                        Length,
> -  IN OUT  ISCSI_SESSION_CONFIG_NVDATA  *ConfigNvData
> -  )
> -{
> -  EFI_STATUS            Status;
> -  UINT8                 IScsiRootPathIdLen;
> -  CHAR8                 *TmpStr;
> -  ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
> -  ISCSI_ROOT_PATH_FIELD *Field;
> -  UINT32                FieldIndex;
> -  UINT8                 Index;
> -
> -  //
> -  // "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
> -  //
> -  IScsiRootPathIdLen = (UINT8) AsciiStrLen (ISCSI_ROOT_PATH_ID);
> -
> -  if ((Length <= IScsiRootPathIdLen) || (CompareMem (RootPath,
> ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {
> -    return EFI_NOT_FOUND;
> -  }
> -  //
> -  // Skip the iSCSI RootPath ID "iscsi:".
> -  //
> -  RootPath += IScsiRootPathIdLen;
> -  Length  = (UINT8) (Length - IScsiRootPathIdLen);
> -
> -  TmpStr  = (CHAR8 *) AllocatePool (Length + 1);
> -  if (TmpStr == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  CopyMem (TmpStr, RootPath, Length);
> -  TmpStr[Length]  = '\0';
> -
> -  Index           = 0;
> -  FieldIndex      = RP_FIELD_IDX_SERVERNAME;
> -  ZeroMem (&Fields[0], sizeof (Fields));
> -
> -  //
> -  // Extract the fields in the Root Path option string.
> -  //
> -  for (FieldIndex = RP_FIELD_IDX_SERVERNAME; (FieldIndex <
> RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
> -    if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
> -      Fields[FieldIndex].Str = &TmpStr[Index];
> -    }
> -
> -    while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index <
> Length)) {
> -      Index++;
> -    }
> -
> -    if (TmpStr[Index] == ISCSI_ROOT_PATH_FIELD_DELIMITER) {
> -      if (FieldIndex != RP_FIELD_IDX_TARGETNAME) {
> -        TmpStr[Index] = '\0';
> -        Index++;
> -      }
> -
> -      if (Fields[FieldIndex].Str != NULL) {
> -        Fields[FieldIndex].Len = (UINT8) AsciiStrLen (Fields[FieldIndex].Str);
> -      }
> -    }
> -  }
> -
> -  if (FieldIndex != RP_FIELD_IDX_MAX) {
> -    Status = EFI_INVALID_PARAMETER;
> -    goto ON_EXIT;
> -  }
> -
> -    if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||
> -      (Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
> -      (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
> -      ) {
> -
> -    Status = EFI_INVALID_PARAMETER;
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Get the IP address of the target.
> -  //
> -  Field   = &Fields[RP_FIELD_IDX_SERVERNAME];
> -  Status  = IScsiAsciiStrToIp (Field->Str, &ConfigNvData->TargetIp);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Check the protocol type.
> -  //
> -  Field = &Fields[RP_FIELD_IDX_PROTOCOL];
> -  if ((Field->Str != NULL) && ((*(Field->Str) - '0') != EFI_IP_PROTO_TCP)) {
> -    Status = EFI_INVALID_PARAMETER;
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Get the port of the iSCSI target.
> -  //
> -  Field = &Fields[RP_FIELD_IDX_PORT];
> -  if (Field->Str != NULL) {
> -    ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
> -  } else {
> -    ConfigNvData->TargetPort = ISCSI_WELL_KNOWN_PORT;
> -  }
> -  //
> -  // Get the LUN.
> -  //
> -  Field = &Fields[RP_FIELD_IDX_LUN];
> -  if (Field->Str != NULL) {
> -    Status = IScsiAsciiStrToLun (Field->Str, ConfigNvData->BootLun);
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -  } else {
> -    ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));
> -  }
> -  //
> -  // Get the target iSCSI Name.
> -  //
> -  Field = &Fields[RP_FIELD_IDX_TARGETNAME];
> -
> -  if (AsciiStrLen (Field->Str) > ISCSI_NAME_MAX_SIZE - 1) {
> -    Status = EFI_INVALID_PARAMETER;
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Validate the iSCSI name.
> -  //
> -  Status = IScsiNormalizeName (Field->Str, AsciiStrLen (Field->Str));
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str);
> -
> -ON_EXIT:
> -
> -  FreePool (TmpStr);
> -
> -  return Status;
> -}
> -
> -/**
> -  The callback function registerd to the DHCP4 instance which is used to select
> -  the qualified DHCP OFFER.
> -
> -  @param[in]  This         The DHCP4 protocol.
> -  @param[in]  Context      The context set when configuring the DHCP4 protocol.
> -  @param[in]  CurrentState The current state of the DHCP4 protocol.
> -  @param[in]  Dhcp4Event   The event occurs in the current state.
> -  @param[in]  Packet       The DHCP packet that is to be sent or already received.
> -  @param[out] NewPacket    The packet used to replace the above Packet.
> -
> -  @retval EFI_SUCCESS      Either the DHCP OFFER is qualified or we're not
> intereseted
> -                           in the Dhcp4Event.
> -  @retval EFI_NOT_READY    The DHCP OFFER packet doesn't match our
> requirements.
> -  @retval Others           Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDhcpSelectOffer (
> -  IN  EFI_DHCP4_PROTOCOL  * This,
> -  IN  VOID                *Context,
> -  IN  EFI_DHCP4_STATE     CurrentState,
> -  IN  EFI_DHCP4_EVENT     Dhcp4Event,
> -  IN  EFI_DHCP4_PACKET    * Packet, OPTIONAL
> -  OUT EFI_DHCP4_PACKET    **NewPacket OPTIONAL
> -  )
> -{
> -  EFI_STATUS              Status;
> -  UINT32                  OptionCount;
> -  EFI_DHCP4_PACKET_OPTION **OptionList;
> -  UINT32                  Index;
> -
> -  if ((Dhcp4Event != Dhcp4RcvdOffer) && (Dhcp4Event != Dhcp4SelectOffer)) {
> -    return EFI_SUCCESS;
> -  }
> -
> -  OptionCount = 0;
> -
> -  Status      = This->Parse (This, Packet, &OptionCount, NULL);
> -  if (Status != EFI_BUFFER_TOO_SMALL) {
> -    return EFI_NOT_READY;
> -  }
> -
> -  OptionList = AllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION
> *));
> -  if (OptionList == NULL) {
> -    return EFI_NOT_READY;
> -  }
> -
> -  Status = This->Parse (This, Packet, &OptionCount, OptionList);
> -  if (EFI_ERROR (Status)) {
> -    FreePool (OptionList);
> -    return EFI_NOT_READY;
> -  }
> -
> -  for (Index = 0; Index < OptionCount; Index++) {
> -    if (OptionList[Index]->OpCode != DHCP4_TAG_ROOTPATH) {
> -      continue;
> -    }
> -
> -    Status = IScsiDhcpExtractRootPath (
> -              (CHAR8 *) &OptionList[Index]->Data[0],
> -              OptionList[Index]->Length,
> -              (ISCSI_SESSION_CONFIG_NVDATA *) Context
> -              );
> -
> -    break;
> -  }
> -
> -  if (Index == OptionCount) {
> -    Status = EFI_NOT_READY;
> -  }
> -
> -  FreePool (OptionList);
> -
> -  return Status;
> -}
> -
> -/**
> -  Parse the DHCP ACK to get the address configuration and DNS information.
> -
> -  @param[in]       Dhcp4        The DHCP4 protocol.
> -  @param[in, out]  ConfigData   The session configuration data.
> -
> -  @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.
> -  @retval EFI_NO_MAPPING        DHCP failed to acquire address and other
> information.
> -  @retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-
> formatted.
> -  @retval EFI_DEVICE_ERROR      Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiParseDhcpAck (
> -  IN      EFI_DHCP4_PROTOCOL         *Dhcp4,
> -  IN OUT  ISCSI_SESSION_CONFIG_DATA  *ConfigData
> -  )
> -{
> -  EFI_STATUS              Status;
> -  EFI_DHCP4_MODE_DATA     Dhcp4ModeData;
> -  UINT32                  OptionCount;
> -  EFI_DHCP4_PACKET_OPTION **OptionList;
> -  UINT32                  Index;
> -
> -  Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4ModeData);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  if (Dhcp4ModeData.State != Dhcp4Bound) {
> -    return EFI_NO_MAPPING;
> -  }
> -
> -  CopyMem (&ConfigData->NvData.LocalIp, &Dhcp4ModeData.ClientAddress,
> sizeof (EFI_IPv4_ADDRESS));
> -  CopyMem (&ConfigData->NvData.SubnetMask,
> &Dhcp4ModeData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
> -  CopyMem (&ConfigData->NvData.Gateway,
> &Dhcp4ModeData.RouterAddress, sizeof (EFI_IPv4_ADDRESS));
> -
> -  OptionCount = 0;
> -  OptionList  = NULL;
> -
> -  Status      = Dhcp4->Parse (Dhcp4, Dhcp4ModeData.ReplyPacket,
> &OptionCount, OptionList);
> -  if (Status != EFI_BUFFER_TOO_SMALL) {
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  OptionList = AllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION
> *));
> -  if (OptionList == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  Status = Dhcp4->Parse (Dhcp4, Dhcp4ModeData.ReplyPacket, &OptionCount,
> OptionList);
> -  if (EFI_ERROR (Status)) {
> -    FreePool (OptionList);
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  for (Index = 0; Index < OptionCount; Index++) {
> -    //
> -    // Get DNS server addresses and DHCP server address from this offer.
> -    //
> -    if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
> -
> -      if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length ==
> 0)) {
> -        Status = EFI_INVALID_PARAMETER;
> -        break;
> -      }
> -      //
> -      // Primary DNS server address.
> -      //
> -      CopyMem (&ConfigData->PrimaryDns, &OptionList[Index]->Data[0], sizeof
> (EFI_IPv4_ADDRESS));
> -
> -      if (OptionList[Index]->Length > 4) {
> -        //
> -        // Secondary DNS server address
> -        //
> -        CopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[4],
> sizeof (EFI_IPv4_ADDRESS));
> -      }
> -    } else if (OptionList[Index]->OpCode == DHCP4_TAG_SERVER_ID) {
> -      if (OptionList[Index]->Length != 4) {
> -        Status = EFI_INVALID_PARAMETER;
> -        break;
> -      }
> -
> -      CopyMem (&ConfigData->DhcpServer, &OptionList[Index]->Data[0], sizeof
> (EFI_IPv4_ADDRESS));
> -    }
> -  }
> -
> -  FreePool (OptionList);
> -
> -  return Status;
> -}
> -
> -/**
> -  Parse the DHCP ACK to get the address configuration and DNS information.
> -
> -  @param[in]       Image            The handle of the driver image.
> -  @param[in]       Controller       The handle of the controller;
> -  @param[in, out]  ConfigData       The session configuration data.
> -
> -  @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.
> -  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.
> -  @retval EFI_NO_MEDIA          There was a media error.
> -  @retval Others                Other errors as indicated.
> -
> -**/
> -EFI_STATUS
> -IScsiDoDhcp (
> -  IN     EFI_HANDLE                 Image,
> -  IN     EFI_HANDLE                 Controller,
> -  IN OUT ISCSI_SESSION_CONFIG_DATA  *ConfigData
> -  )
> -{
> -  EFI_HANDLE              Dhcp4Handle;
> -  EFI_DHCP4_PROTOCOL      *Dhcp4;
> -  EFI_STATUS              Status;
> -  EFI_DHCP4_PACKET_OPTION *ParaList;
> -  EFI_DHCP4_CONFIG_DATA   Dhcp4ConfigData;
> -  EFI_STATUS              MediaStatus;
> -  UINT8                   *Data;
> -
> -  Dhcp4Handle = NULL;
> -  Dhcp4       = NULL;
> -  ParaList    = NULL;
> -
> -  //
> -  // Check media status before do DHCP
> -  //
> -  MediaStatus = EFI_SUCCESS;
> -  NetLibDetectMediaWaitTimeout (Controller,
> ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus);
> -  if (MediaStatus != EFI_SUCCESS) {
> -    return EFI_NO_MEDIA;
> -  }
> -
> -  //
> -  // Create a DHCP4 child instance and get the protocol.
> -  //
> -  Status = NetLibCreateServiceChild (
> -            Controller,
> -            Image,
> -            &gEfiDhcp4ServiceBindingProtocolGuid,
> -            &Dhcp4Handle
> -            );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  Status = gBS->OpenProtocol (
> -                  Dhcp4Handle,
> -                  &gEfiDhcp4ProtocolGuid,
> -                  (VOID **)&Dhcp4,
> -                  Image,
> -                  Controller,
> -                  EFI_OPEN_PROTOCOL_BY_DRIVER
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  ParaList = AllocatePool (sizeof (EFI_DHCP4_PACKET_OPTION) + 3);
> -  if (ParaList == NULL) {
> -    Status = EFI_OUT_OF_RESOURCES;
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Ask the server to reply with Netmask, Router, DNS and RootPath options.
> -  //
> -  ParaList->OpCode  = DHCP4_TAG_PARA_LIST;
> -  ParaList->Length  = (UINT8) (ConfigData->NvData.TargetInfoFromDhcp ? 4 : 3);
> -  Data = &ParaList->Data[0];
> -  Data[0] = DHCP4_TAG_NETMASK;
> -  Data[1] = DHCP4_TAG_ROUTER;
> -  Data[2] = DHCP4_TAG_DNS_SERVER;
> -  Data[3] = DHCP4_TAG_ROOTPATH;
> -
> -  ZeroMem (&Dhcp4ConfigData, sizeof (EFI_DHCP4_CONFIG_DATA));
> -  Dhcp4ConfigData.OptionCount = 1;
> -  Dhcp4ConfigData.OptionList  = &ParaList;
> -
> -  if (ConfigData->NvData.TargetInfoFromDhcp) {
> -    //
> -    // Use callback to select an offer which contains target information.
> -    //
> -    Dhcp4ConfigData.Dhcp4Callback   = IScsiDhcpSelectOffer;
> -    Dhcp4ConfigData.CallbackContext = &ConfigData->NvData;
> -  }
> -
> -  Status = Dhcp4->Configure (Dhcp4, &Dhcp4ConfigData);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  Status = Dhcp4->Start (Dhcp4, NULL);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Parse the ACK to get required information.
> -  //
> -  Status = IScsiParseDhcpAck (Dhcp4, ConfigData);
> -
> -ON_EXIT:
> -
> -  if (ParaList != NULL) {
> -    FreePool (ParaList);
> -  }
> -
> -  if (Dhcp4 != NULL) {
> -    Dhcp4->Stop (Dhcp4);
> -    Dhcp4->Configure (Dhcp4, NULL);
> -
> -    gBS->CloseProtocol (
> -          Dhcp4Handle,
> -          &gEfiDhcp4ProtocolGuid,
> -          Image,
> -          Controller
> -          );
> -  }
> -
> -  NetLibDestroyServiceChild (
> -    Controller,
> -    Image,
> -    &gEfiDhcp4ServiceBindingProtocolGuid,
> -    Dhcp4Handle
> -    );
> -
> -  return Status;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
> deleted file mode 100644
> index 730f3e506bbc..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c
> +++ /dev/null
> @@ -1,676 +0,0 @@
> -/** @file
> -  The entry point of IScsi driver.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = {
> -  IScsiDriverBindingSupported,
> -  IScsiDriverBindingStart,
> -  IScsiDriverBindingStop,
> -  0xa,
> -  NULL,
> -  NULL
> -};
> -
> -/**
> -  Tests to see if this driver supports the RemainingDevicePath.
> -
> -  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a
> device path.  This
> -                                   parameter is ignored by device drivers, and is optional for
> bus
> -                                   drivers. For bus drivers, if this parameter is not NULL, then
> -                                   the bus driver must determine if the bus controller specified
> -                                   by ControllerHandle and the child controller specified
> -                                   by RemainingDevicePath are both supported by this
> -                                   bus driver.
> -
> -  @retval EFI_SUCCESS              The RemainingDevicePath is supported or NULL.
> -  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
> -                                   RemainingDevicePath is not supported by the driver
> specified by This.
> -**/
> -EFI_STATUS
> -IScsiIsDevicePathSupported (
> -  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
> -  )
> -{
> -  EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;
> -
> -  CurrentDevicePath = RemainingDevicePath;
> -  if (CurrentDevicePath != NULL) {
> -    while (!IsDevicePathEnd (CurrentDevicePath)) {
> -      if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) &&
> (CurrentDevicePath->SubType == MSG_ISCSI_DP)) {
> -        return EFI_SUCCESS;
> -      }
> -
> -      CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
> -    }
> -
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Tests to see if this driver supports a given controller. If a child device is
> provided,
> -  it further tests to see if this driver supports creating a handle for the specified
> child device.
> -
> -  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle     The handle of the controller to test. This
> handle
> -                                   must support a protocol interface that supplies
> -                                   an I/O abstraction to the driver.
> -  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a
> device path.
> -                                   This parameter is ignored by device drivers, and is optional
> for bus drivers.
> -
> -
> -  @retval EFI_SUCCESS              The device specified by ControllerHandle and
> -                                   RemainingDevicePath is supported by the driver specified by
> This.
> -  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle
> and
> -                                   RemainingDevicePath is already being managed by the
> driver
> -                                   specified by This.
> -  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
> -                                   RemainingDevicePath is already being managed by a
> different
> -                                   driver or an application that requires exclusive acces.
> -                                   Currently not implemented.
> -  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
> -                                   RemainingDevicePath is not supported by the driver
> specified by This.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverBindingSupported (
> -  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
> -  IN EFI_HANDLE                   ControllerHandle,
> -  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
> -  )
> -{
> -  EFI_STATUS                Status;
> -
> -  Status = gBS->OpenProtocol (
> -                  ControllerHandle,
> -                  &gEfiCallerIdGuid,
> -                  NULL,
> -                  This->DriverBindingHandle,
> -                  ControllerHandle,
> -                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> -                  );
> -  if (!EFI_ERROR (Status)) {
> -    return EFI_ALREADY_STARTED;
> -  }
> -
> -  Status = gBS->OpenProtocol (
> -                  ControllerHandle,
> -                  &gEfiTcp4ServiceBindingProtocolGuid,
> -                  NULL,
> -                  This->DriverBindingHandle,
> -                  ControllerHandle,
> -                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  Status = IScsiIsDevicePathSupported (RemainingDevicePath);
> -  if (EFI_ERROR (Status)) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  if (IScsiDhcpIsConfigured (ControllerHandle)) {
> -    Status = gBS->OpenProtocol (
> -                    ControllerHandle,
> -                    &gEfiDhcp4ServiceBindingProtocolGuid,
> -                    NULL,
> -                    This->DriverBindingHandle,
> -                    ControllerHandle,
> -                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> -                    );
> -    if (EFI_ERROR (Status)) {
> -      return EFI_UNSUPPORTED;
> -    }
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Start this driver on ControllerHandle.
> -
> -  The Start() function is designed to be invoked from the EFI boot service
> ConnectController().
> -  As a result, much of the error checking on the parameters to Start() has been
> moved into this
> -  common boot service. It is legal to call Start() from other locations, but the
> following calling
> -  restrictions must be followed or the system behavior will not be deterministic.
> -  1. ControllerHandle must be a valid EFI_HANDLE.
> -  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
> aligned
> -     EFI_DEVICE_PATH_PROTOCOL.
> -  3. Prior to calling Start(), the Supported() function for the driver specified by
> This must
> -     have been called with the same calling parameters, and Supported() must
> have returned EFI_SUCCESS.
> -
> -  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle     The handle of the controller to start. This
> handle
> -                                   must support a protocol interface that supplies
> -                                   an I/O abstraction to the driver.
> -  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a
> device path.
> -                                   This parameter is ignored by device drivers, and is optional
> for bus drivers.
> -
> -  @retval EFI_SUCCESS              The device was started.
> -  @retval EFI_DEVICE_ERROR         The device could not be started due to a
> device error.
> -                                   Currently not implemented.
> -  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due
> to a lack of resources.
> -  @retval Others                   The driver failded to start the device.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverBindingStart (
> -  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
> -  IN EFI_HANDLE                   ControllerHandle,
> -  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
> -  )
> -{
> -  EFI_STATUS        Status;
> -  ISCSI_DRIVER_DATA *Private;
> -  VOID              *Interface;
> -
> -  Private = IScsiCreateDriverData (This->DriverBindingHandle, ControllerHandle);
> -  if (Private == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  //
> -  // Create a underlayer child instance, but not need to configure it. Just open
> ChildHandle
> -  // via BY_DRIVER. That is, establishing the relationship between
> ControllerHandle and ChildHandle.
> -  // Therefore, when DisconnectController(), especially VLAN virtual controller
> handle,
> -  // IScsiDriverBindingStop() will be called.
> -  //
> -  Status = NetLibCreateServiceChild (
> -             ControllerHandle,
> -             This->DriverBindingHandle,
> -             &gEfiTcp4ServiceBindingProtocolGuid,
> -             &Private->ChildHandle
> -             );
> -
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Status = gBS->OpenProtocol (
> -                  Private->ChildHandle,
> -                  &gEfiTcp4ProtocolGuid,
> -                  &Interface,
> -                  This->DriverBindingHandle,
> -                  ControllerHandle,
> -                  EFI_OPEN_PROTOCOL_BY_DRIVER
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  //
> -  // Always install private protocol no matter what happens later. We need to
> -  // keep the relationship between ControllerHandle and ChildHandle.
> -  //
> -  Status = gBS->InstallProtocolInterface (
> -                  &ControllerHandle,
> -                  &gEfiCallerIdGuid,
> -                  EFI_NATIVE_INTERFACE,
> -                  &Private->IScsiIdentifier
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  //
> -  // Try to add a port configuration page for this controller.
> -  //
> -  IScsiConfigUpdateForm (This->DriverBindingHandle, ControllerHandle, TRUE);
> -
> -  //
> -  // Get the iSCSI configuration data of this controller.
> -  //
> -  Status = IScsiGetConfigData (Private);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -  //
> -  // Try to login and create an iSCSI session according to the configuration.
> -  //
> -  Status = IScsiSessionLogin (Private);
> -  if (Status == EFI_MEDIA_CHANGED) {
> -    //
> -    // The specified target is not available and the redirection information is
> -    // got, login the session again with the updated target address.
> -    //
> -    Status = IScsiSessionLogin (Private);
> -  }
> -
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -  //
> -  // Duplicate the Session's tcp connection device path. The source port field
> -  // will be set to zero as one iSCSI session is comprised of several iSCSI
> -  // connections.
> -  //
> -  Private->DevicePath = IScsiGetTcpConnDevicePath (Private);
> -  if (Private->DevicePath == NULL) {
> -    goto ON_ERROR;
> -  }
> -  //
> -  // Install the updated device path onto the ExtScsiPassThruHandle.
> -  //
> -  Status = gBS->InstallProtocolInterface (
> -                  &Private->ExtScsiPassThruHandle,
> -                  &gEfiDevicePathProtocolGuid,
> -                  EFI_NATIVE_INTERFACE,
> -                  Private->DevicePath
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  //
> -  // ISCSI children should share the default Tcp child, just open the default Tcp
> child via BY_CHILD_CONTROLLER.
> -  //
> -  Status = gBS->OpenProtocol (
> -                  Private->ChildHandle, /// Default Tcp child
> -                  &gEfiTcp4ProtocolGuid,
> -                  &Interface,
> -                  This->DriverBindingHandle,
> -                  Private->ExtScsiPassThruHandle,
> -                  EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    gBS->UninstallMultipleProtocolInterfaces (
> -           Private->ExtScsiPassThruHandle,
> -           &gEfiExtScsiPassThruProtocolGuid,
> -           &Private->IScsiExtScsiPassThru,
> -           &gEfiDevicePathProtocolGuid,
> -           Private->DevicePath,
> -           NULL
> -           );
> -
> -    goto ON_ERROR;
> -  }
> -
> -  //
> -  // Update/Publish the iSCSI Boot Firmware Table.
> -  //
> -  IScsiPublishIbft ();
> -
> -  return EFI_SUCCESS;
> -
> -ON_ERROR:
> -
> -  IScsiSessionAbort (&Private->Session);
> -
> -  return Status;
> -}
> -
> -/**
> -  Stop this driver on ControllerHandle.
> -
> -  Release the control of this controller and remove the IScsi functions. The Stop()
> -  function is designed to be invoked from the EFI boot service
> DisconnectController().
> -  As a result, much of the error checking on the parameters to Stop() has been
> moved
> -  into this common boot service. It is legal to call Stop() from other locations,
> -  but the following calling restrictions must be followed or the system behavior
> will not be deterministic.
> -  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous
> call to this
> -     same driver's Start() function.
> -  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
> -     EFI_HANDLE. In addition, all of these handles must have been created in this
> driver's
> -     Start() function, and the Start() function must have called OpenProtocol() on
> -     ControllerHandle with an Attribute of
> EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
> -
> -  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle  A handle to the device being stopped. The
> handle must
> -                                support a bus specific I/O protocol for the driver
> -                                to use to stop the device.
> -  @param[in]  NumberOfChildren  The number of child device handles in
> ChildHandleBuffer.Not used.
> -  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be
> NULL
> -                                if NumberOfChildren is 0.Not used.
> -
> -  @retval EFI_SUCCESS           The device was stopped.
> -  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a
> device error.
> -  @retval EFI_INVALID_PARAMETER Child handle is NULL.
> -  @retval EFI_ACCESS_DENIED     The protocol could not be removed from the
> Handle
> -                                because its interfaces are being used.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverBindingStop (
> -  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
> -  IN EFI_HANDLE                   ControllerHandle,
> -  IN UINTN                        NumberOfChildren,
> -  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
> -  )
> -{
> -  EFI_HANDLE                      IScsiController;
> -  EFI_STATUS                      Status;
> -  ISCSI_PRIVATE_PROTOCOL          *IScsiIdentifier;
> -  ISCSI_DRIVER_DATA               *Private;
> -  EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
> -  ISCSI_CONNECTION                *Conn;
> -
> -  if (NumberOfChildren != 0) {
> -    //
> -    // We should have only one child.
> -    //
> -    Status = gBS->OpenProtocol (
> -                    ChildHandleBuffer[0],
> -                    &gEfiExtScsiPassThruProtocolGuid,
> -                    (VOID **) &PassThru,
> -                    This->DriverBindingHandle,
> -                    ControllerHandle,
> -                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -                    );
> -    if (EFI_ERROR (Status)) {
> -      return EFI_DEVICE_ERROR;
> -    }
> -
> -    Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
> -    Conn    = NET_LIST_HEAD (&Private->Session.Conns, ISCSI_CONNECTION,
> Link);
> -
> -    //
> -    // Previously the TCP4 protocol is opened BY_CHILD_CONTROLLER. Just
> close
> -    // the protocol here but not uninstall the device path protocol and
> -    // EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle.
> -    //
> -    gBS->CloseProtocol (
> -           Private->ChildHandle,
> -           &gEfiTcp4ProtocolGuid,
> -           Private->Image,
> -           Private->ExtScsiPassThruHandle
> -           );
> -
> -    gBS->CloseProtocol (
> -          Conn->Tcp4Io.Handle,
> -          &gEfiTcp4ProtocolGuid,
> -          Private->Image,
> -          Private->ExtScsiPassThruHandle
> -          );
> -
> -    return EFI_SUCCESS;
> -  }
> -  //
> -  // Get the handle of the controller we are controling.
> -  //
> -  IScsiController = NetLibGetNicHandle (ControllerHandle,
> &gEfiTcp4ProtocolGuid);
> -
> -  Status = gBS->OpenProtocol (
> -                  IScsiController,
> -                  &gEfiCallerIdGuid,
> -                  (VOID **)&IScsiIdentifier,
> -                  This->DriverBindingHandle,
> -                  ControllerHandle,
> -                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  Private = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
> -
> -  if (Private->ChildHandle != NULL) {
> -    Status = gBS->CloseProtocol (
> -                    Private->ChildHandle,
> -                    &gEfiTcp4ProtocolGuid,
> -                    This->DriverBindingHandle,
> -                    IScsiController
> -                    );
> -
> -    ASSERT (!EFI_ERROR (Status));
> -
> -    Status = NetLibDestroyServiceChild (
> -               IScsiController,
> -               This->DriverBindingHandle,
> -               &gEfiTcp4ServiceBindingProtocolGuid,
> -               Private->ChildHandle
> -               );
> -    ASSERT (!EFI_ERROR (Status));
> -  }
> -
> -  IScsiConfigUpdateForm (This->DriverBindingHandle, IScsiController, FALSE);
> -
> -  //
> -  // Uninstall the private protocol.
> -  //
> -  gBS->UninstallProtocolInterface (
> -        IScsiController,
> -        &gEfiCallerIdGuid,
> -        &Private->IScsiIdentifier
> -        );
> -
> -  //
> -  // Update the iSCSI Boot Firware Table.
> -  //
> -  IScsiPublishIbft ();
> -
> -  IScsiSessionAbort (&Private->Session);
> -  Status = IScsiCleanDriverData (Private);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Unloads an image(the iSCSI driver).
> -
> -  @param[in]  ImageHandle       Handle that identifies the image to be unloaded.
> -
> -  @retval EFI_SUCCESS           The image has been unloaded.
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiIScsiUnload (
> -  IN EFI_HANDLE  ImageHandle
> -  )
> -{
> -  EFI_STATUS                        Status;
> -  UINTN                             DeviceHandleCount;
> -  EFI_HANDLE                        *DeviceHandleBuffer;
> -  UINTN                             Index;
> -  EFI_COMPONENT_NAME_PROTOCOL       *ComponentName;
> -  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;
> -
> -  //
> -  // Try to disonnect the driver from the devices it's controlling.
> -  //
> -  Status = gBS->LocateHandleBuffer (
> -                  AllHandles,
> -                  NULL,
> -                  NULL,
> -                  &DeviceHandleCount,
> -                  &DeviceHandleBuffer
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  for (Index = 0; Index < DeviceHandleCount; Index++) {
> -    Status = IScsiTestManagedDevice (
> -               DeviceHandleBuffer[Index],
> -               gIScsiDriverBinding.DriverBindingHandle,
> -               &gEfiTcp4ProtocolGuid
> -               );
> -    if (EFI_ERROR (Status)) {
> -      continue;
> -    }
> -    Status = gBS->DisconnectController (
> -                    DeviceHandleBuffer[Index],
> -                    gIScsiDriverBinding.DriverBindingHandle,
> -                    NULL
> -                    );
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -  }
> -
> -  //
> -  // Unload the iSCSI configuration form.
> -  //
> -  Status = IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  //
> -  // Uninstall the ComponentName and ComponentName2 protocol from iSCSI4
> driver binding handle
> -  // if it has been installed.
> -  //
> -  Status = gBS->HandleProtocol (
> -                  gIScsiDriverBinding.DriverBindingHandle,
> -                  &gEfiComponentNameProtocolGuid,
> -                  (VOID **) &ComponentName
> -                  );
> -  if (!EFI_ERROR (Status)) {
> -    Status = gBS->UninstallMultipleProtocolInterfaces (
> -           gIScsiDriverBinding.DriverBindingHandle,
> -           &gEfiComponentNameProtocolGuid,
> -           ComponentName,
> -           NULL
> -           );
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -  }
> -
> -  Status = gBS->HandleProtocol (
> -                  gIScsiDriverBinding.DriverBindingHandle,
> -                  &gEfiComponentName2ProtocolGuid,
> -                  (VOID **) &ComponentName2
> -                  );
> -  if (!EFI_ERROR (Status)) {
> -    gBS->UninstallMultipleProtocolInterfaces (
> -           gIScsiDriverBinding.DriverBindingHandle,
> -           &gEfiComponentName2ProtocolGuid,
> -           ComponentName2,
> -           NULL
> -           );
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -  }
> -
> -  Status = gBS->UninstallMultipleProtocolInterfaces (
> -                  ImageHandle,
> -                  &gEfiDriverBindingProtocolGuid,
> -                  &gIScsiDriverBinding,
> -                  &gEfiIScsiInitiatorNameProtocolGuid,
> -                  &gIScsiInitiatorName,
> -                  NULL
> -                  );
> -ON_EXIT:
> -
> -  if (DeviceHandleBuffer != NULL) {
> -    FreePool (DeviceHandleBuffer);
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  This is the declaration of an EFI image entry point. This entry point is
> -  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
> -  both device drivers and bus drivers. It initialize the global variables and
> -  publish the driver binding protocol.
> -
> -  @param[in]   ImageHandle      The firmware allocated handle for the UEFI
> image.
> -  @param[in]   SystemTable      A pointer to the EFI System Table.
> -
> -  @retval EFI_SUCCESS           The operation completed successfully.
> -  @retval EFI_ACCESS_DENIED     EFI_ISCSI_INITIATOR_NAME_PROTOCOL was
> installed unexpectedly.
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverEntryPoint (
> -  IN EFI_HANDLE         ImageHandle,
> -  IN EFI_SYSTEM_TABLE   *SystemTable
> -  )
> -{
> -  EFI_STATUS                         Status;
> -  EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *IScsiInitiatorName;
> -
> -  //
> -  // There should be only one EFI_ISCSI_INITIATOR_NAME_PROTOCOL.
> -  //
> -  Status = gBS->LocateProtocol (
> -                   &gEfiIScsiInitiatorNameProtocolGuid,
> -                   NULL,
> -                   (VOID**) &IScsiInitiatorName
> -                   );
> -
> -  if (!EFI_ERROR (Status)) {
> -    return EFI_ACCESS_DENIED;
> -  }
> -
> -  //
> -  // Initialize the EFI Driver Library
> -  //
> -  Status = EfiLibInstallDriverBindingComponentName2 (
> -             ImageHandle,
> -             SystemTable,
> -             &gIScsiDriverBinding,
> -             ImageHandle,
> -             &gIScsiComponentName,
> -             &gIScsiComponentName2
> -           );
> -
> -  if (!EFI_ERROR (Status)) {
> -    //
> -    // Install the iSCSI Initiator Name Protocol.
> -    //
> -    Status = gBS->InstallProtocolInterface (
> -                    &ImageHandle,
> -                    &gEfiIScsiInitiatorNameProtocolGuid,
> -                    EFI_NATIVE_INTERFACE,
> -                    &gIScsiInitiatorName
> -                    );
> -    if (EFI_ERROR (Status)) {
> -      gBS->UninstallMultipleProtocolInterfaces (
> -            ImageHandle,
> -            &gEfiDriverBindingProtocolGuid,
> -            &gIScsiDriverBinding,
> -            &gEfiComponentName2ProtocolGuid,
> -            &gIScsiComponentName2,
> -            &gEfiComponentNameProtocolGuid,
> -            &gIScsiComponentName,
> -            NULL
> -            );
> -      return Status;
> -    }
> -
> -    //
> -    // Initialize the configuration form of iSCSI.
> -    //
> -    Status = IScsiConfigFormInit ();
> -    if (EFI_ERROR (Status)) {
> -      gBS->UninstallMultipleProtocolInterfaces (
> -            ImageHandle,
> -            &gEfiDriverBindingProtocolGuid,
> -            &gIScsiDriverBinding,
> -            &gEfiComponentName2ProtocolGuid,
> -            &gIScsiComponentName2,
> -            &gEfiComponentNameProtocolGuid,
> -            &gIScsiComponentName,
> -            &gEfiIScsiInitiatorNameProtocolGuid,
> -            &gIScsiInitiatorName,
> -            NULL
> -            );
> -    }
> -  }
> -  return Status;
> -}
> -
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
> deleted file mode 100644
> index db2d6d19366e..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
> +++ /dev/null
> @@ -1,412 +0,0 @@
> -/** @file
> -  The IScsi's EFI_EXT_SCSI_PASS_THRU_PROTOCOL driver.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -/**
> -  Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI
> channel. This function
> -  supports both blocking I/O and nonblocking I/O. The blocking I/O functionality
> is required, and the
> -  nonblocking I/O functionality is optional.
> -
> -  @param[in]      This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> instance.
> -  @param[in]      Target  The Target is an array of size TARGET_MAX_BYTES and
> it represents
> -                          the id of the SCSI device to send the SCSI Request Packet. Each
> -                          transport driver may chose to utilize a subset of this size to suit
> the needs
> -                          of transport target representation. For example, a Fibre Channel
> driver
> -                          may use only 8 bytes (WWN) to represent an FC target.
> -  @param[in]       Lun    The LUN of the SCSI device to send the SCSI Request
> Packet.
> -  @param[in, out]  Packet A pointer to the SCSI Request Packet to send to the
> SCSI device
> -                          specified by Target and Lun.
> -  @param[in]       Event  If nonblocking I/O is not supported then Event is
> ignored, and blocking
> -                          I/O is performed. If Event is NULL, then blocking I/O is performed.
> If
> -                          Event is not NULL and non blocking I/O is supported, then
> -                          nonblocking I/O is performed, and Event will be signaled when
> the
> -                          SCSI Request Packet completes.
> -
> -  @retval EFI_SUCCESS           The SCSI Request Packet was sent by the host. For
> bi-directional
> -                                commands, InTransferLength bytes were transferred from
> -                                InDataBuffer. For write and bi-directional commands,
> -                                OutTransferLength bytes were transferred by
> -                                OutDataBuffer.
> -  @retval EFI_BAD_BUFFER_SIZE   The SCSI Request Packet was not executed.
> The number of bytes that
> -                                could be transferred is returned in InTransferLength. For write
> -                                and bi-directional commands, OutTransferLength bytes were
> -                                transferred by OutDataBuffer. Currently not implemeted.
> -  @retval EFI_NOT_READY         The SCSI Request Packet could not be sent
> because there are too many
> -                                SCSI Request Packets already queued. The caller may retry
> again later.
> -  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to
> send the SCSI Request
> -                                Packet.
> -  @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of
> ScsiRequestPacket are invalid.
> -  @retval EFI_UNSUPPORTED       The command described by the SCSI Request
> Packet is not supported
> -                                by the host adapter. This includes the case of Bi-directional
> SCSI
> -                                commands not supported by the implementation. The SCSI
> Request
> -                                Packet was not sent, so no additional status information is
> available.
> -                                Currently not implemeted.
> -  @retval EFI_TIMEOUT           A timeout occurred while waiting for the SCSI
> Request Packet to execute.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruFunction (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                          *This,
> -  IN UINT8                                                    *Target,
> -  IN UINT64                                                   Lun,
> -  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET           *Packet,
> -  IN EFI_EVENT                                                Event     OPTIONAL
> -  )
> -{
> -  ISCSI_DRIVER_DATA           *Private;
> -  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
> -  EFI_STATUS                  Status;
> -
> -  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
> -  ConfigNvData  = &Private->Session.ConfigData.NvData;
> -
> -  if (Target[0] != 0 || (CompareMem (&Lun, ConfigNvData->BootLun, sizeof
> (UINT64)) != 0)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  if ((Packet == NULL) || (Packet->Cdb == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);
> -  if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {
> -    //
> -    // Try to reinstate the session and re-execute the Scsi command.
> -    //
> -    if (EFI_ERROR (IScsiSessionReinstatement (Private))) {
> -      return EFI_DEVICE_ERROR;
> -    }
> -
> -    Status = IScsiExecuteScsiCommand (This, Target, Lun, Packet);
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI
> channel. These
> -  can either be the list SCSI devices that are actually present on the SCSI channel,
> or the list of legal
> -  Target Ids and LUNs for the SCSI channel. Regardless, the caller of this
> function must probe the
> -  Target ID and LUN returned to see if a SCSI device is actually present at that
> location on the SCSI
> -  channel.
> -
> -  @param[in]       This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> instance.
> -  @param[in, out]  Target  On input, a pointer to the Target ID (an array of size
> -                           TARGET_MAX_BYTES) of a SCSI device present on the SCSI
> channel.
> -                           On output, a pointer to the Target ID (an array of
> -                           TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
> -                           channel. An input value of 0xF(all bytes in the array are 0xF) in
> the
> -                           Target array retrieves the Target ID of the first SCSI device
> present on a
> -                           SCSI channel.
> -  @param[in, out]  Lun     On input, a pointer to the LUN of a SCSI device
> present on the SCSI
> -                           channel. On output, a pointer to the LUN of the next SCSI device
> present
> -                           on a SCSI channel.
> -
> -  @retval EFI_SUCCESS           The Target ID and LUN of the next SCSI device on
> the SCSI
> -                                channel was returned in Target and Lun.
> -  @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and
> Lun were
> -                                not returned on a previous call to GetNextTargetLun().
> -  @retval EFI_NOT_FOUND         There are no more SCSI devices on this SCSI
> channel.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruGetNextTargetLun (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,
> -  IN OUT UINT8                        **Target,
> -  IN OUT UINT64                       *Lun
> -  )
> -{
> -  ISCSI_DRIVER_DATA           *Private;
> -  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
> -  UINT8                       TargetId[TARGET_MAX_BYTES];
> -
> -  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
> -  ConfigNvData  = &Private->Session.ConfigData.NvData;
> -
> -  if ((*Target)[0] == 0 && (CompareMem (Lun, ConfigNvData->BootLun, sizeof
> (UINT64)) == 0)) {
> -    //
> -    // Only one <Target, Lun> pair per iSCSI Driver instance.
> -    //
> -    return EFI_NOT_FOUND;
> -  }
> -
> -  SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);
> -  if (CompareMem (*Target, TargetId, TARGET_MAX_BYTES) == 0) {
> -    (*Target)[0] = 0;
> -    CopyMem (Lun, ConfigNvData->BootLun, sizeof (UINT64));
> -
> -    return EFI_SUCCESS;
> -  }
> -
> -  return EFI_INVALID_PARAMETER;
> -}
> -
> -/**
> -  Used to allocate and build a device path node for a SCSI device on a SCSI
> channel.
> -
> -  @param[in]      This        A pointer to the
> EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
> -  @param[in]      Target      The Target is an array of size TARGET_MAX_BYTES
> and it specifies the
> -                              Target ID of the SCSI device for which a device path node is to
> be
> -                              allocated and built. Transport drivers may chose to utilize a
> subset of
> -                              this size to suit the representation of targets. For example, a
> Fibre
> -                              Channel driver may use only 8 bytes (WWN) in the array to
> represent a
> -                              FC target.
> -  @param[in]       Lun        The LUN of the SCSI device for which a device path
> node is to be
> -                              allocated and built.
> -  @param[in, out]  DevicePath A pointer to a single device path node that
> describes the SCSI device
> -                              specified by Target and Lun. This function is responsible for
> -                              allocating the buffer DevicePath with the boot service
> -                              AllocatePool(). It is the caller's responsibility to free
> -                              DevicePath when the caller is finished with DevicePath.
> -
> -  @retval EFI_SUCCESS           The device path node that describes the SCSI
> device specified by
> -                                Target and Lun was allocated and returned in
> -                                DevicePath.
> -  @retval EFI_INVALID_PARAMETER DevicePath is NULL.
> -  @retval EFI_NOT_FOUND         The SCSI devices specified by Target and Lun
> does not exist
> -                                on the SCSI channel.
> -  @retval EFI_OUT_OF_RESOURCES  There are not enough resources to
> allocate DevicePath.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruBuildDevicePath (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,
> -  IN UINT8                            *Target,
> -  IN UINT64                           Lun,
> -  IN OUT EFI_DEVICE_PATH_PROTOCOL     **DevicePath
> -  )
> -{
> -  ISCSI_DRIVER_DATA             *Private;
> -  ISCSI_SESSION                 *Session;
> -  ISCSI_SESSION_CONFIG_NVDATA   *ConfigNvData;
> -  ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
> -  EFI_DEV_PATH                  *Node;
> -  UINTN                         DevPathNodeLen;
> -
> -  if (DevicePath == NULL) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  if (Target[0] != 0) {
> -    return EFI_NOT_FOUND;
> -  }
> -
> -  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
> -  Session       = &Private->Session;
> -  ConfigNvData  = &Session->ConfigData.NvData;
> -  AuthConfig    = &Session->AuthData.AuthConfig;
> -
> -  if (CompareMem (&Lun, ConfigNvData->BootLun, sizeof (UINT64)) != 0) {
> -    return EFI_NOT_FOUND;
> -  }
> -
> -  DevPathNodeLen  = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData-
> >TargetName) + 1;
> -  Node            = AllocatePool (DevPathNodeLen);
> -  if (Node == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  Node->DevPath.Type    = MESSAGING_DEVICE_PATH;
> -  Node->DevPath.SubType = MSG_ISCSI_DP;
> -  SetDevicePathNodeLength (&Node->DevPath, (UINT16)DevPathNodeLen);
> -
> -  //
> -  // 0 for TCP, others are reserved.
> -  //
> -  Node->Iscsi.NetworkProtocol = 0;
> -
> -  Node->Iscsi.LoginOption     = 0;
> -  switch (AuthConfig->CHAPType) {
> -  case ISCSI_CHAP_NONE:
> -    Node->Iscsi.LoginOption |= 0x0800;
> -    break;
> -
> -  case ISCSI_CHAP_UNI:
> -    Node->Iscsi.LoginOption |= 0x1000;
> -    break;
> -
> -  default:
> -    break;
> -  }
> -
> -  CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));
> -  Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;
> -  AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen
> (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName);
> -
> -  *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Used to translate a device path node to a Target ID and LUN.
> -
> -  @param[in]  This       A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> instance.
> -  @param[in]  DevicePath A pointer to a single device path node that describes
> the SCSI device
> -                         on the SCSI channel.
> -  @param[out] Target     A pointer to the Target Array which represents the ID
> of a SCSI device
> -                         on the SCSI channel.
> -  @param[out]  Lun       A pointer to the LUN of a SCSI device on the SCSI
> channel.
> -
> -  @retval EFI_SUCCESS           DevicePath was successfully translated to a Target
> ID and
> -                                LUN, and they were returned in Target and Lun.
> -  @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.
> -  @retval EFI_NOT_FOUND         A valid translation from DevicePath to a Target
> ID and LUN
> -                                does not exist.Currently not implemented.
> -  @retval EFI_UNSUPPORTED       This driver does not support the device path
> node type in
> -                                DevicePath.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruGetTargetLun (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,
> -  IN EFI_DEVICE_PATH_PROTOCOL         *DevicePath,
> -  OUT UINT8                           **Target,
> -  OUT UINT64                          *Lun
> -  )
> -{
> -  ISCSI_DRIVER_DATA           *Private;
> -  ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
> -
> -  if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
> -      (DevicePath->SubType != MSG_ISCSI_DP) ||
> -      (DevicePathNodeLength (DevicePath) <= sizeof (ISCSI_DEVICE_PATH))
> -      ) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
> -  ConfigNvData  = &Private->Session.ConfigData.NvData;
> -
> -  SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
> -  (*Target)[0] = 0;
> -
> -  if (AsciiStrCmp (ConfigNvData->TargetName, (CHAR8 *) DevicePath + sizeof
> (ISCSI_DEVICE_PATH)) != 0) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  CopyMem (Lun, ConfigNvData->BootLun, sizeof (UINT64));
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Resets a SCSI channel. This operation resets all the SCSI devices connected to
> the SCSI channel.
> -  Currently not implemented.
> -
> -  @param[in]  This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> instance.
> -
> -  @retval EFI_SUCCESS      The SCSI channel was reset.
> -  @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset
> the SCSI channel.
> -  @retval EFI_TIMEOUT      A timeout occurred while attempting to reset the
> SCSI channel.
> -  @retval EFI_UNSUPPORTED  The SCSI channel does not support a channel
> reset operation.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruResetChannel (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This
> -  )
> -{
> -  return EFI_UNSUPPORTED;
> -}
> -
> -/**
> -  Resets a SCSI logical unit that is connected to a SCSI channel. Currently not
> implemented.
> -
> -  @param[in]  This   A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> instance.
> -  @param[in]  Target The Target is an array of size TARGET_MAX_BYTE and it
> represents the
> -                     target port ID of the SCSI device containing the SCSI logical unit to
> -                     reset. Transport drivers may chose to utilize a subset of this array to
> suit
> -                     the representation of their targets.
> -  @param[in]  Lun    The LUN of the SCSI device to reset.
> -
> -  @retval EFI_SUCCESS           The SCSI device specified by Target and Lun was
> reset.
> -  @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
> -  @retval EFI_TIMEOUT           A timeout occurred while attempting to reset the
> SCSI device
> -                                specified by Target and Lun.
> -  @retval EFI_UNSUPPORTED       The SCSI channel does not support a target
> reset operation.
> -  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to
> reset the SCSI device
> -                                specified by Target and Lun.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruResetTargetLun (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,
> -  IN UINT8                            *Target,
> -  IN UINT64                           Lun
> -  )
> -{
> -  return EFI_UNSUPPORTED;
> -}
> -
> -/**
> -  Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel.
> These can either
> -  be the list SCSI devices that are actually present on the SCSI channel, or the list
> of legal Target IDs
> -  for the SCSI channel. Regardless, the caller of this function must probe the
> Target ID returned to
> -  see if a SCSI device is actually present at that location on the SCSI channel.
> -
> -  @param[in]       This    A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> instance.
> -  @param[in, out]  Target  (TARGET_MAX_BYTES) of a SCSI device present on
> the SCSI channel.
> -                           On output, a pointer to the Target ID (an array of
> -                           TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
> -                           channel. An input value of 0xF(all bytes in the array are 0xF) in
> the
> -                           Target array retrieves the Target ID of the first SCSI device
> present on a
> -                           SCSI channel.
> -
> -  @retval EFI_SUCCESS           The Target ID of the next SCSI device on the SCSI
> -                                channel was returned in Target.
> -  @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
> -  @retval EFI_TIMEOUT           Target array is not all 0xF, and Target were not
> -                                returned on a previous call to GetNextTarget().
> -                                Currently not implemented.
> -  @retval EFI_NOT_FOUND         There are no more SCSI devices on this SCSI
> channel.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiExtScsiPassThruGetNextTarget (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,
> -  IN OUT UINT8                        **Target
> -  )
> -{
> -  UINT8 TargetId[TARGET_MAX_BYTES];
> -
> -  SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);
> -
> -  if (CompareMem (*Target, TargetId, TARGET_MAX_BYTES) == 0) {
> -    (*Target)[0] = 0;
> -    return EFI_SUCCESS;
> -  } else if ((*Target)[0] == 0) {
> -    return EFI_NOT_FOUND;
> -  } else {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -}
> -
> -EFI_EXT_SCSI_PASS_THRU_PROTOCOL gIScsiExtScsiPassThruProtocolTemplate
> = {
> -  NULL,
> -  IScsiExtScsiPassThruFunction,
> -  IScsiExtScsiPassThruGetNextTargetLun,
> -  IScsiExtScsiPassThruBuildDevicePath,
> -  IScsiExtScsiPassThruGetTargetLun,
> -  IScsiExtScsiPassThruResetChannel,
> -  IScsiExtScsiPassThruResetTargetLun,
> -  IScsiExtScsiPassThruGetNextTarget
> -};
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
> deleted file mode 100644
> index 58c5447dcbd1..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
> +++ /dev/null
> @@ -1,539 +0,0 @@
> -/** @file
> -  Implementation for iSCSI Boot Firmware Table publication.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -BOOLEAN mIbftInstalled = FALSE;
> -UINTN   mTableKey;
> -
> -/**
> -  Initialize the header of the iSCSI Boot Firmware Table.
> -
> -  @param[out]  Header     The header of the iSCSI Boot Firmware Table.
> -  @param[in]   OemId      The OEM ID.
> -  @param[in]   OemTableId The OEM table ID for the iBFT.
> -**/
> -VOID
> -IScsiInitIbfTableHeader (
> -  OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER   *Header,
> -  IN  UINT8                                       *OemId,
> -  IN  UINT64                                      *OemTableId
> -  )
> -{
> -  ZeroMem (Header, sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER));
> -
> -  Header->Signature =
> EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE;
> -  Header->Length    = IBFT_HEAP_OFFSET;
> -  Header->Revision  = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION;
> -  Header->Checksum  = 0;
> -
> -  CopyMem (Header->OemId, OemId, sizeof (Header->OemId));
> -  CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
> -}
> -
> -/**
> -  Initialize the control section of the iSCSI Boot Firmware Table.
> -
> -  @param[in]  Table       The ACPI table.
> -  @param[in]  HandleCount The number of the handles associated with iSCSI
> sessions, it's
> -                          equal to the number of iSCSI sessions.
> -**/
> -VOID
> -IScsiInitControlSection (
> -  IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER  *Table,
> -  IN UINTN                                      HandleCount
> -  )
> -{
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE  *Control;
> -  UINTN                                                 NumOffset;
> -
> -  Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE
> *) (Table + 1);
> -
> -  ZeroMem (Control, sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE));
> -
> -  Control->Header.StructureId =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID;
> -  Control->Header.Version     =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION;
> -  Control->Header.Length      = (UINT16) sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE);
> -
> -  //
> -  // Each session occupies two offsets, one for the NIC section,
> -  // the other for the Target section.
> -  //
> -  NumOffset = 2 * HandleCount;
> -  if (NumOffset > 4) {
> -    //
> -    // Need expand the control section if more than 2 NIC/Target sections
> -    // exist.
> -    //
> -    Control->Header.Length = (UINT16) (Control->Header.Length + (NumOffset -
> 4) * sizeof (UINT16));
> -  }
> -}
> -
> -/**
> -  Add one item into the heap.
> -
> -  @param[in, out]  Heap  On input, the current address of the heap; On output,
> the address of
> -                         the heap after the item is added.
> -  @param[in]       Data  The data to add into the heap.
> -  @param[in]       Len   Length of the Data in byte.
> -**/
> -VOID
> -IScsiAddHeapItem (
> -  IN OUT UINT8  **Heap,
> -  IN     VOID   *Data,
> -  IN     UINTN  Len
> -  )
> -{
> -  //
> -  // Add one byte for the NULL delimiter.
> -  //
> -  *Heap -= Len + 1;
> -
> -  CopyMem (*Heap, Data, Len);
> -  *(*Heap + Len) = 0;
> -}
> -
> -/**
> -  Fill the Initiator section of the iSCSI Boot Firmware Table.
> -
> -  @param[in]       Table    The ACPI table.
> -  @param[in, out]  Heap     The heap.
> -  @param[in]       Handle   The handle associated with the iSCSI session.
> -**/
> -VOID
> -IScsiFillInitiatorSection (
> -  IN     EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER  *Table,
> -  IN OUT UINT8                                      **Heap,
> -  IN     EFI_HANDLE                                 Handle
> -  )
> -{
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE    *Control;
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE  *Initiator;
> -  ISCSI_DRIVER_DATA                                       *DriverData;
> -  ISCSI_SESSION                                           *Session;
> -  ISCSI_PRIVATE_PROTOCOL                                  *IScsiIdentifier;
> -  EFI_STATUS                                              Status;
> -
> -  Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE
> *) (Table + 1);
> -
> -  //
> -  // Initiator section immediately follows the control section.
> -  //
> -  Initiator = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE
> *) ((UINT8 *) Control + IBFT_ROUNDUP (Control->Header.Length));
> -
> -  Control->InitiatorOffset = (UINT16) ((UINTN) Initiator - (UINTN) Table);
> -
> -  ZeroMem (Initiator, sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE));
> -
> -  Initiator->Header.StructureId =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID;
> -  Initiator->Header.Version     =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION;
> -  Initiator->Header.Length      = (UINT16) sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE);
> -  Initiator->Header.Flags       =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOC
> K_VALID |
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOO
> T_SELECTED;
> -
> -  //
> -  // Get the identifier from the handle.
> -  //
> -  Status = gBS->HandleProtocol (Handle, &gEfiCallerIdGuid, (VOID **)
> &IScsiIdentifier);
> -  if (EFI_ERROR (Status)) {
> -    ASSERT (FALSE);
> -    return ;
> -  }
> -
> -  DriverData  = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
> -  Session     = &DriverData->Session;
> -
> -  //
> -  // Fill the iSCSI Initiator Name into the heap.
> -  //
> -  IScsiAddHeapItem (Heap, Session->InitiatorName, Session-
> >InitiatorNameLength - 1);
> -
> -  Initiator->IScsiNameLength  = (UINT16) (Session->InitiatorNameLength - 1);
> -  Initiator->IScsiNameOffset  = (UINT16) ((UINTN) *Heap - (UINTN) Table);
> -}
> -
> -/**
> -  Map the v4 IP address into v6 IP address.
> -
> -  @param[in]   V4 The v4 IP address.
> -  @param[out]  V6 The v6 IP address.
> -**/
> -VOID
> -IScsiMapV4ToV6Addr (
> -  IN  EFI_IPv4_ADDRESS *V4,
> -  OUT EFI_IPv6_ADDRESS *V6
> -  )
> -{
> -  UINTN Index;
> -
> -  ZeroMem (V6, sizeof (EFI_IPv6_ADDRESS));
> -
> -  V6->Addr[10]  = 0xff;
> -  V6->Addr[11]  = 0xff;
> -
> -  for (Index = 0; Index < 4; Index++) {
> -    V6->Addr[12 + Index] = V4->Addr[Index];
> -  }
> -}
> -
> -/**
> -  Get the NIC's PCI location and return it according to the composited
> -  format defined in iSCSI Boot Firmware Table.
> -
> -  @param[in]  Controller  The handle of the controller.
> -
> -  @return UINT16          The composited representation of the NIC PCI location.
> -  @retval 0               Other errors as indicated.
> -**/
> -UINT16
> -IScsiGetNICPciLocation (
> -  IN EFI_HANDLE  Controller
> -  )
> -{
> -  EFI_STATUS                Status;
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> -  EFI_HANDLE                PciIoHandle;
> -  EFI_PCI_IO_PROTOCOL       *PciIo;
> -  UINTN                     Segment;
> -  UINTN                     Bus;
> -  UINTN                     Device;
> -  UINTN                     Function;
> -
> -  Status = gBS->HandleProtocol (
> -                  Controller,
> -                  &gEfiDevicePathProtocolGuid,
> -                  (VOID **)&DevicePath
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return 0;
> -  }
> -
> -  Status = gBS->LocateDevicePath (
> -                  &gEfiPciIoProtocolGuid,
> -                  &DevicePath,
> -                  &PciIoHandle
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return 0;
> -  }
> -
> -  Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID
> **)&PciIo);
> -  if (EFI_ERROR (Status)) {
> -    return 0;
> -  }
> -
> -  Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
> -  if (EFI_ERROR (Status)) {
> -    return 0;
> -  }
> -
> -  return (UINT16) ((Bus << 8) | (Device << 3) | Function);
> -}
> -
> -/**
> -  Fill the NIC and target sections in iSCSI Boot Firmware Table.
> -
> -  @param[in]       Table       The buffer of the ACPI table.
> -  @param[in, out]  Heap        The heap buffer used to store the variable length
> parameters such as iSCSI name.
> -  @param[in]       HandleCount Count The number of handles having iSCSI
> private protocol installed.
> -  @param[in]       Handles     The handle buffer.
> -**/
> -VOID
> -IScsiFillNICAndTargetSections (
> -  IN     EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER  *Table,
> -  IN OUT UINT8                                      **Heap,
> -  IN     UINTN                                      HandleCount,
> -  IN     EFI_HANDLE                                 *Handles
> -  )
> -{
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE  *Control;
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE      *Nic;
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE   *Target;
> -  ISCSI_DRIVER_DATA                                     *DriverData;
> -  ISCSI_SESSION_CONFIG_DATA                             *SessionConfigData;
> -  ISCSI_CHAP_AUTH_CONFIG_NVDATA                         *AuthConfig;
> -  UINT16                                                *SectionOffset;
> -  UINTN                                                 Index;
> -  UINT16                                                Length;
> -  EFI_MAC_ADDRESS                                       MacAddress;
> -  UINTN                                                 HwAddressSize;
> -  ISCSI_PRIVATE_PROTOCOL                                *IScsiIdentifier;
> -  EFI_STATUS                                            Status;
> -
> -  //
> -  // Get the offset of the first Nic and Target section.
> -  //
> -  Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE
> *) (Table + 1);
> -  Nic     = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)
> ((UINTN) Table +
> -          Control->InitiatorOffset + IBFT_ROUNDUP (sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE)));
> -  Target  = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *)
> ((UINTN) Nic +
> -          IBFT_ROUNDUP (sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
> -
> -  SectionOffset = &Control->NIC0Offset;
> -
> -  for (Index = 0; Index < HandleCount; Index++) {
> -    Status = gBS->HandleProtocol (Handles[Index], &gEfiCallerIdGuid, (VOID
> **)&IScsiIdentifier);
> -    if (EFI_ERROR (Status)) {
> -      ASSERT (FALSE);
> -      return ;
> -    }
> -
> -    DriverData        = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
> -    SessionConfigData = &DriverData->Session.ConfigData;
> -    AuthConfig        = &DriverData->Session.AuthData.AuthConfig;
> -
> -    //
> -    // Fill the Nic section.
> -    //
> -    ZeroMem (Nic, sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE));
> -
> -    Nic->Header.StructureId =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID;
> -    Nic->Header.Version     =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION;
> -    Nic->Header.Length      = (UINT16) sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);
> -    Nic->Header.Index       = (UINT8) Index;
> -    Nic->Header.Flags       =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VAL
> ID |
> -
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BOOT_SELE
> CTED |
> -
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL;
> -
> -    //
> -    // Get the subnet mask prefix length.
> -    //
> -    Nic->SubnetMaskPrefixLength = IScsiGetSubnetMaskPrefixLength
> (&SessionConfigData->NvData.SubnetMask);
> -
> -    if (SessionConfigData->NvData.InitiatorInfoFromDhcp) {
> -      Nic->Origin = IpPrefixOriginDhcp;
> -    } else {
> -      Nic->Origin = IpPrefixOriginManual;
> -    }
> -    //
> -    // Map the various v4 addresses into v6 addresses.
> -    //
> -    IScsiMapV4ToV6Addr (&SessionConfigData->NvData.LocalIp, &Nic->Ip);
> -    IScsiMapV4ToV6Addr (&SessionConfigData->NvData.Gateway, &Nic-
> >Gateway);
> -    IScsiMapV4ToV6Addr (&SessionConfigData->PrimaryDns, &Nic->PrimaryDns);
> -    IScsiMapV4ToV6Addr (&SessionConfigData->SecondaryDns, &Nic-
> >SecondaryDns);
> -    IScsiMapV4ToV6Addr (&SessionConfigData->DhcpServer, &Nic->DhcpServer);
> -
> -    Nic->VLanTag = NetLibGetVlanId (DriverData->Controller);
> -
> -    Status = NetLibGetMacAddress (DriverData->Controller, &MacAddress,
> &HwAddressSize);
> -    ASSERT (Status == EFI_SUCCESS);
> -    CopyMem (Nic->Mac, MacAddress.Addr, sizeof (Nic->Mac));
> -
> -    //
> -    // Get the PCI location of the Nic.
> -    //
> -    Nic->PciLocation  = IScsiGetNICPciLocation (DriverData->Controller);
> -
> -    *SectionOffset    = (UINT16) ((UINTN) Nic - (UINTN) Table);
> -    SectionOffset++;
> -
> -    //
> -    // Fill the Target section.
> -    //
> -    ZeroMem (Target, sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE));
> -
> -    Target->Header.StructureId  =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID;
> -    Target->Header.Version      =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION;
> -    Target->Header.Length       = (UINT16) sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);
> -    Target->Header.Index        = (UINT8) Index;
> -    Target->Header.Flags        =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_
> VALID |
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_
> SELECTED;
> -    Target->Port                = SessionConfigData->NvData.TargetPort;
> -    Target->NicIndex            = (UINT8) Index;
> -
> -    if (AuthConfig->CHAPType == ISCSI_CHAP_NONE) {
> -      Target->CHAPType =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_
> NO_CHAP;
> -    } if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
> -      Target->CHAPType =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_C
> HAP;
> -    } else if (AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
> -      Target->CHAPType =
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_
> MUTUAL_CHAP;
> -    }
> -
> -    IScsiMapV4ToV6Addr (&SessionConfigData->NvData.TargetIp, &Target->Ip);
> -    CopyMem (Target->BootLun, SessionConfigData->NvData.BootLun, sizeof
> (Target->BootLun));
> -
> -    //
> -    // Target iSCSI Name, CHAP name/secret, reverse CHAP name/secret.
> -    //
> -    Length = (UINT16) AsciiStrLen (SessionConfigData->NvData.TargetName);
> -    IScsiAddHeapItem (Heap, SessionConfigData->NvData.TargetName, Length);
> -
> -    Target->IScsiNameLength = Length;
> -    Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);
> -
> -    if (Target->CHAPType !=
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_
> NO_CHAP) {
> -      //
> -      // CHAP Name
> -      //
> -      Length = (UINT16) AsciiStrLen (AuthConfig->CHAPName);
> -      IScsiAddHeapItem (Heap, AuthConfig->CHAPName, Length);
> -      Target->CHAPNameLength  = Length;
> -      Target->CHAPNameOffset  = (UINT16) ((UINTN) *Heap - (UINTN) Table);
> -
> -      //
> -      // CHAP Secret
> -      //
> -      Length = (UINT16) AsciiStrLen (AuthConfig->CHAPSecret);
> -      IScsiAddHeapItem (Heap, AuthConfig->CHAPSecret, Length);
> -      Target->CHAPSecretLength  = Length;
> -      Target->CHAPSecretOffset  = (UINT16) ((UINTN) *Heap - (UINTN) Table);
> -
> -      if (Target->CHAPType ==
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_
> MUTUAL_CHAP) {
> -        //
> -        // Reverse CHAP Name
> -        //
> -        Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPName);
> -        IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPName, Length);
> -        Target->ReverseCHAPNameLength = Length;
> -        Target->ReverseCHAPNameOffset = (UINT16) ((UINTN) *Heap - (UINTN)
> Table);
> -
> -        //
> -        // Reverse CHAP Secret
> -        //
> -        Length = (UINT16) AsciiStrLen (AuthConfig->ReverseCHAPSecret);
> -        IScsiAddHeapItem (Heap, AuthConfig->ReverseCHAPSecret, Length);
> -        Target->ReverseCHAPSecretLength = Length;
> -        Target->ReverseCHAPSecretOffset = (UINT16) ((UINTN) *Heap - (UINTN)
> Table);
> -      }
> -    }
> -
> -    *SectionOffset = (UINT16) ((UINTN) Target - (UINTN) Table);
> -    SectionOffset++;
> -
> -    //
> -    // Advance to the next NIC/Target pair
> -    //
> -    Nic    = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *)
> ((UINTN) Target +
> -           IBFT_ROUNDUP (sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE)));
> -    Target = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE *)
> ((UINTN) Nic +
> -           IBFT_ROUNDUP (sizeof
> (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)));
> -  }
> -}
> -
> -/**
> -  Publish and remove the iSCSI Boot Firmware Table according to the iSCSI
> -  session status.
> -**/
> -VOID
> -IScsiPublishIbft (
> -  VOID
> -  )
> -{
> -  EFI_STATUS                                Status;
> -  EFI_ACPI_TABLE_PROTOCOL                   *AcpiTableProtocol;
> -  EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table;
> -  UINTN                                     HandleCount;
> -  EFI_HANDLE                                *HandleBuffer;
> -  UINT8                                     *Heap;
> -  UINT8                                     Checksum;
> -  EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
> -  EFI_ACPI_DESCRIPTION_HEADER                   *Rsdt;
> -  EFI_ACPI_DESCRIPTION_HEADER                   *Xsdt;
> -
> -  Rsdt = NULL;
> -  Xsdt = NULL;
> -
> -  Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID
> **)&AcpiTableProtocol);
> -  if (EFI_ERROR (Status)) {
> -    return ;
> -  }
> -
> -
> -  //
> -  // Find ACPI table RSD_PTR from system table
> -  //
> -  Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **)
> &Rsdp);
> -  if (EFI_ERROR (Status)) {
> -    Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **)
> &Rsdp);
> -  }
> -
> -  if (EFI_ERROR (Status) || (Rsdp == NULL)) {
> -    return ;
> -  } else if (Rsdp->Revision >=
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp-
> >XsdtAddress != 0) {
> -    Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress;
> -  } else if (Rsdp->RsdtAddress != 0) {
> -    Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress;
> -  }
> -
> -  if ((Xsdt == NULL) && (Rsdt == NULL)) {
> -    return ;
> -  }
> -
> -  if (mIbftInstalled) {
> -    Status = AcpiTableProtocol->UninstallAcpiTable (
> -                                  AcpiTableProtocol,
> -                                  mTableKey
> -                                  );
> -    if (EFI_ERROR (Status)) {
> -      return ;
> -    }
> -    mIbftInstalled = FALSE;
> -  }
> -
> -  //
> -  // Get all iSCSI private protocols.
> -  //
> -  Status = gBS->LocateHandleBuffer (
> -                  ByProtocol,
> -                  &gEfiCallerIdGuid,
> -                  NULL,
> -                  &HandleCount,
> -                  &HandleBuffer
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return ;
> -  }
> -  //
> -  // Allocate 4k bytes to hold the ACPI table.
> -  //
> -  Table = AllocateZeroPool (IBFT_MAX_SIZE);
> -  if (Table == NULL) {
> -    return ;
> -  }
> -
> -  Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
> -
> -  //
> -  // Fill in the various section of the iSCSI Boot Firmware Table.
> -  //
> -  if (Rsdp->Revision >=
> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) {
> -    IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId);
> -  } else {
> -    IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId);
> -  }
> -
> -  IScsiInitControlSection (Table, HandleCount);
> -  IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]);
> -  IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer);
> -
> -  Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length);
> -  Table->Checksum = Checksum;
> -
> -  FreePool (HandleBuffer);
> -
> -  //
> -  // Install or update the iBFT table.
> -  //
> -  Status = AcpiTableProtocol->InstallAcpiTable (
> -                                AcpiTableProtocol,
> -                                Table,
> -                                Table->Length,
> -                                &mTableKey
> -                                );
> -  if (EFI_ERROR(Status)) {
> -    return;
> -  }
> -
> -  mIbftInstalled = TRUE;
> -  FreePool (Table);
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.c
> deleted file mode 100644
> index e753d9eebdbe..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.c
> +++ /dev/null
> @@ -1,116 +0,0 @@
> -/** @file
> -  Implementation for EFI iSCSI Initiator Name Protocol.
> -
> -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName = {
> -  IScsiGetInitiatorName,
> -  IScsiSetInitiatorName
> -};
> -
> -/**
> -  Retrieves the current set value of iSCSI Initiator Name.
> -
> -  @param[in]       This       Pointer to the
> EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
> -  @param[in, out]  BufferSize Size of the buffer in bytes pointed to by Buffer /
> Actual size of the
> -                              variable data buffer.
> -  @param[out]      Buffer     Pointer to the buffer for data to be read. The data is
> a null-terminated UTF-8 encoded string.
> -                              The maximum length is 223 characters, including the null-
> terminator.
> -
> -  @retval EFI_SUCCESS           Data was successfully retrieved into the provided
> buffer and the
> -                                BufferSize was sufficient to handle the iSCSI initiator name.
> -  @retval EFI_BUFFER_TOO_SMALL  BufferSize is too small for the result.
> -  @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL.
> -  @retval EFI_DEVICE_ERROR      The iSCSI initiator name could not be retrieved
> due to a hardware error.
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiGetInitiatorName (
> -  IN     EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *This,
> -  IN OUT UINTN                              *BufferSize,
> -  OUT    VOID                               *Buffer
> -  )
> -{
> -  EFI_STATUS  Status;
> -
> -  if ((BufferSize == NULL) || (Buffer == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  Status = gRT->GetVariable (
> -                  ISCSI_INITIATOR_NAME_VAR_NAME,
> -                  &gEfiIScsiInitiatorNameProtocolGuid,
> -                  NULL,
> -                  BufferSize,
> -                  Buffer
> -                  );
> -
> -  return Status;
> -}
> -
> -/**
> -  Sets the iSCSI Initiator Name.
> -
> -  @param[in]       This       Pointer to the
> EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
> -  @param[in, out]  BufferSize Size of the buffer in bytes pointed to by Buffer.
> -  @param[in]       Buffer     Pointer to the buffer for data to be written. The data
> is a null-terminated UTF-8 encoded string.
> -                              The maximum length is 223 characters, including the null-
> terminator.
> -
> -  @retval EFI_SUCCESS           Data was successfully stored by the protocol.
> -  @retval EFI_UNSUPPORTED       Platform policies do not allow for data to be
> written.
> -                                Currently not implemented.
> -  @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL, or BufferSize
> exceeds the maximum allowed limit.
> -  @retval EFI_DEVICE_ERROR      The data could not be stored due to a
> hardware error.
> -  @retval EFI_OUT_OF_RESOURCES  Not enough storage is available to hold
> the data.
> -  @retval EFI_PROTOCOL_ERROR    Input iSCSI initiator name does not adhere
> to RFC 3720
> -                                (and other related protocols).
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiSetInitiatorName (
> -  IN     EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *This,
> -  IN OUT UINTN                              *BufferSize,
> -  IN     VOID                               *Buffer
> -  )
> -{
> -  EFI_STATUS  Status;
> -
> -  if ((BufferSize == NULL) || (Buffer == NULL)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  if (*BufferSize > ISCSI_NAME_MAX_SIZE) {
> -    *BufferSize = ISCSI_NAME_MAX_SIZE;
> -    return EFI_INVALID_PARAMETER;
> -  }
> -  //
> -  // only support iqn iSCSI names.
> -  //
> -  Status = IScsiNormalizeName ((CHAR8 *) Buffer, *BufferSize - 1);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  Status = gRT->SetVariable (
> -                  ISCSI_INITIATOR_NAME_VAR_NAME,
> -                  &gEfiIScsiInitiatorNameProtocolGuid,
> -                  EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> -                  *BufferSize,
> -                  Buffer
> -                  );
> -
> -  return Status;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> deleted file mode 100644
> index d924a8b82427..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
> +++ /dev/null
> @@ -1,948 +0,0 @@
> -/** @file
> -  Miscellaneous routines for iSCSI driver.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8  IScsiHexString[] =
> "0123456789ABCDEFabcdef";
> -
> -/**
> -  Removes (trims) specified leading and trailing characters from a string.
> -
> -  @param[in, out]  Str  Pointer to the null-terminated string to be trimmed. On
> return,
> -                        Str will hold the trimmed string.
> -
> -  @param[in]      CharC Character will be trimmed from str.
> -**/
> -VOID
> -StrTrim (
> -  IN OUT CHAR16   *Str,
> -  IN     CHAR16   CharC
> -  )
> -{
> -  CHAR16  *Pointer1;
> -  CHAR16  *Pointer2;
> -
> -  if (*Str == 0) {
> -    return;
> -  }
> -
> -  //
> -  // Trim off the leading and trailing characters c
> -  //
> -  for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) {
> -    ;
> -  }
> -
> -  Pointer2 = Str;
> -  if (Pointer2 == Pointer1) {
> -    while (*Pointer1 != 0) {
> -      Pointer2++;
> -      Pointer1++;
> -    }
> -  } else {
> -    while (*Pointer1 != 0) {
> -    *Pointer2 = *Pointer1;
> -    Pointer1++;
> -    Pointer2++;
> -    }
> -    *Pointer2 = 0;
> -  }
> -
> -
> -  for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC;
> Pointer1--) {
> -    ;
> -  }
> -  if  (Pointer1 !=  Str + StrLen(Str) - 1) {
> -    *(Pointer1 + 1) = 0;
> -  }
> -}
> -
> -/**
> -  Calculate the prefix length of the IPv4 subnet mask.
> -
> -  @param[in]  SubnetMask The IPv4 subnet mask.
> -
> -  @return The prefix length of the subnet mask.
> -  @retval 0 Other errors as indicated.
> -**/
> -UINT8
> -IScsiGetSubnetMaskPrefixLength (
> -  IN EFI_IPv4_ADDRESS  *SubnetMask
> -  )
> -{
> -  UINT8   Len;
> -  UINT32  ReverseMask;
> -
> -  //
> -  // The SubnetMask is in network byte order.
> -  //
> -  ReverseMask = (SubnetMask->Addr[0] << 24) | (SubnetMask->Addr[1] << 16) |
> (SubnetMask->Addr[2] << 8) | (SubnetMask->Addr[3]);
> -
> -  //
> -  // Reverse it.
> -  //
> -  ReverseMask = ~ReverseMask;
> -
> -  if ((ReverseMask & (ReverseMask + 1)) != 0) {
> -    return 0;
> -  }
> -
> -  Len = 0;
> -
> -  while (ReverseMask != 0) {
> -    ReverseMask = ReverseMask >> 1;
> -    Len++;
> -  }
> -
> -  return (UINT8) (32 - Len);
> -}
> -
> -/**
> -  Convert the hexadecimal encoded LUN string into the 64-bit LUN.
> -
> -  @param[in]   Str             The hexadecimal encoded LUN string.
> -  @param[out]  Lun             Storage to return the 64-bit LUN.
> -
> -  @retval EFI_SUCCESS           The 64-bit LUN is stored in Lun.
> -  @retval EFI_INVALID_PARAMETER The string is malformatted.
> -**/
> -EFI_STATUS
> -IScsiAsciiStrToLun (
> -  IN  CHAR8  *Str,
> -  OUT UINT8  *Lun
> -  )
> -{
> -  UINTN   Index, IndexValue, IndexNum, SizeStr;
> -  CHAR8   TemStr[2];
> -  UINT8   TemValue;
> -  UINT16  Value[4];
> -
> -  ZeroMem (Lun, 8);
> -  ZeroMem (TemStr, 2);
> -  ZeroMem ((UINT8 *) Value, sizeof (Value));
> -  SizeStr    = AsciiStrLen (Str);
> -  IndexValue = 0;
> -  IndexNum   = 0;
> -
> -  for (Index = 0; Index < SizeStr; Index ++) {
> -    TemStr[0] = Str[Index];
> -    TemValue = (UINT8) AsciiStrHexToUint64 (TemStr);
> -    if (TemValue == 0 && TemStr[0] != '0') {
> -      if ((TemStr[0] != '-') || (IndexNum == 0)) {
> -        //
> -        // Invalid Lun Char
> -        //
> -        return EFI_INVALID_PARAMETER;
> -      }
> -    }
> -
> -    if ((TemValue == 0) && (TemStr[0] == '-')) {
> -      //
> -      // Next Lun value
> -      //
> -      if (++IndexValue >= 4) {
> -        //
> -        // Max 4 Lun value
> -        //
> -        return EFI_INVALID_PARAMETER;
> -      }
> -      //
> -      // Restart str index for the next lun value
> -      //
> -      IndexNum = 0;
> -      continue;
> -    }
> -
> -    if (++IndexNum > 4) {
> -      //
> -      // Each Lun Str can't exceed size 4, because it will be as UINT16 value
> -      //
> -      return EFI_INVALID_PARAMETER;
> -    }
> -
> -    //
> -    // Combine UINT16 value
> -    //
> -    Value[IndexValue] = (UINT16) ((Value[IndexValue] << 4) + TemValue);
> -  }
> -
> -  for (Index = 0; Index <= IndexValue; Index ++) {
> -    *((UINT16 *) &Lun[Index * 2]) =  HTONS (Value[Index]);
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Convert the 64-bit LUN into the hexadecimal encoded LUN string.
> -
> -  @param[in]   Lun The 64-bit LUN.
> -  @param[out]  Str The storage to return the hexadecimal encoded LUN string.
> -**/
> -VOID
> -IScsiLunToUnicodeStr (
> -  IN UINT8    *Lun,
> -  OUT CHAR16  *Str
> -  )
> -{
> -  UINTN   Index;
> -  CHAR16  *TempStr;
> -
> -  TempStr = Str;
> -
> -  for (Index = 0; Index < 4; Index++) {
> -
> -    if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) {
> -      CopyMem(TempStr, L"0-", sizeof (L"0-"));
> -    } else {
> -      TempStr[0]  = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];
> -      TempStr[1]  = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F];
> -      TempStr[2]  = (CHAR16) IScsiHexString[Lun[2 * Index + 1] >> 4];
> -      TempStr[3]  = (CHAR16) IScsiHexString[Lun[2 * Index + 1] & 0x0F];
> -      TempStr[4]  = L'-';
> -      TempStr[5]  = 0;
> -
> -      StrTrim (TempStr, L'0');
> -    }
> -
> -    TempStr += StrLen (TempStr);
> -  }
> -
> -  ASSERT (StrLen(Str) >= 1);
> -  Str[StrLen (Str) - 1] = 0;
> -
> -  for (Index = StrLen (Str) - 1; Index > 1; Index = Index - 2) {
> -    if ((Str[Index] == L'0') && (Str[Index - 1] == L'-')) {
> -      Str[Index - 1] = 0;
> -    } else {
> -      break;
> -    }
> -  }
> -}
> -
> -/**
> -  Convert the ASCII string into a UNICODE string.
> -
> -  @param[in]   Source      The ASCII string.
> -  @param[out]  Destination The storage to return the UNICODE string.
> -
> -  @return CHAR16 *         Pointer to the UNICODE string.
> -**/
> -CHAR16 *
> -IScsiAsciiStrToUnicodeStr (
> -  IN  CHAR8   *Source,
> -  OUT CHAR16  *Destination
> -  )
> -{
> -  ASSERT (Destination != NULL);
> -  ASSERT (Source != NULL);
> -
> -  while (*Source != '\0') {
> -    *(Destination++) = (CHAR16) *(Source++);
> -  }
> -
> -  *Destination = '\0';
> -
> -  return Destination;
> -}
> -
> -/**
> -  Convert the UNICODE string into an ASCII string.
> -
> -  @param[in]  Source       The UNICODE string.
> -  @param[out] Destination  The storage to return the ASCII string.
> -
> -  @return CHAR8 *          Pointer to the ASCII string.
> -**/
> -CHAR8 *
> -IScsiUnicodeStrToAsciiStr (
> -  IN  CHAR16  *Source,
> -  OUT CHAR8   *Destination
> -  )
> -{
> -  ASSERT (Destination != NULL);
> -  ASSERT (Source != NULL);
> -
> -  while (*Source != '\0') {
> -    //
> -    // If any Unicode characters in Source contain
> -    // non-zero value in the upper 8 bits, then ASSERT().
> -    //
> -    ASSERT (*Source < 0x100);
> -    *(Destination++) = (CHAR8) *(Source++);
> -  }
> -
> -  *Destination = '\0';
> -
> -  return Destination;
> -}
> -
> -/**
> -  Convert the decimal dotted IPv4 address into the binary IPv4 address.
> -
> -  @param[in]   Str             The UNICODE string.
> -  @param[out]  Ip              The storage to return the ASCII string.
> -
> -  @retval EFI_SUCCESS           The binary IP address is returned in Ip.
> -  @retval EFI_INVALID_PARAMETER The IP string is malformatted.
> -**/
> -EFI_STATUS
> -IScsiAsciiStrToIp (
> -  IN  CHAR8             *Str,
> -  OUT EFI_IPv4_ADDRESS  *Ip
> -  )
> -{
> -  UINTN Index;
> -  UINTN Number;
> -
> -  Index = 0;
> -
> -  while (*Str != 0) {
> -
> -    if (Index > 3) {
> -      return EFI_INVALID_PARAMETER;
> -    }
> -
> -    Number = 0;
> -    while (NET_IS_DIGIT (*Str)) {
> -      Number = Number * 10 + (*Str - '0');
> -      Str++;
> -    }
> -
> -    if (Number > 0xFF) {
> -      return EFI_INVALID_PARAMETER;
> -    }
> -
> -    Ip->Addr[Index] = (UINT8) Number;
> -
> -    if ((*Str != '\0') && (*Str != '.')) {
> -      //
> -      // The current character should be either the NULL terminator or
> -      // the dot delimiter.
> -      //
> -      return EFI_INVALID_PARAMETER;
> -    }
> -
> -    if (*Str == '.') {
> -      //
> -      // Skip the delimiter.
> -      //
> -      Str++;
> -    }
> -
> -    Index++;
> -  }
> -
> -  if (Index != 4) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Convert the mac address into a hexadecimal encoded "-" seperated string.
> -
> -  @param[in]  Mac     The mac address.
> -  @param[in]  Len     Length in bytes of the mac address.
> -  @param[in]  VlanId  VLAN ID of the network device.
> -  @param[out] Str     The storage to return the mac string.
> -**/
> -VOID
> -IScsiMacAddrToStr (
> -  IN  EFI_MAC_ADDRESS  *Mac,
> -  IN  UINT32           Len,
> -  IN  UINT16           VlanId,
> -  OUT CHAR16           *Str
> -  )
> -{
> -  UINT32  Index;
> -  CHAR16  *String;
> -
> -  for (Index = 0; Index < Len; Index++) {
> -    Str[3 * Index]      = (CHAR16) IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F];
> -    Str[3 * Index + 1]  = (CHAR16) IScsiHexString[Mac->Addr[Index] & 0x0F];
> -    Str[3 * Index + 2]  = L'-';
> -  }
> -
> -  String = &Str[3 * Index - 1] ;
> -  if (VlanId != 0) {
> -    String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN)
> VlanId);
> -  }
> -
> -  *String = L'\0';
> -}
> -
> -/**
> -  Convert the binary encoded buffer into a hexadecimal encoded string.
> -
> -  @param[in]       BinBuffer   The buffer containing the binary data.
> -  @param[in]       BinLength   Length of the binary buffer.
> -  @param[in, out]  HexStr      Pointer to the string.
> -  @param[in, out]  HexLength   The length of the string.
> -
> -  @retval EFI_SUCCESS          The binary data is converted to the hexadecimal
> string
> -                               and the length of the string is updated.
> -  @retval EFI_BUFFER_TOO_SMALL The string is too small.
> -  @retval EFI_INVALID_PARAMETER The IP string is malformatted.
> -**/
> -EFI_STATUS
> -IScsiBinToHex (
> -  IN     UINT8  *BinBuffer,
> -  IN     UINT32 BinLength,
> -  IN OUT CHAR8  *HexStr,
> -  IN OUT UINT32 *HexLength
> -  )
> -{
> -  UINTN Index;
> -
> -  if ((HexStr == NULL) || (BinBuffer == NULL) || (BinLength == 0)) {
> -    return EFI_INVALID_PARAMETER;
> -  }
> -
> -  if (((*HexLength) - 3) < BinLength * 2) {
> -    *HexLength = BinLength * 2 + 3;
> -    return EFI_BUFFER_TOO_SMALL;
> -  }
> -
> -  *HexLength = BinLength * 2 + 3;
> -  //
> -  // Prefix for Hex String
> -  //
> -  HexStr[0] = '0';
> -  HexStr[1] = 'x';
> -
> -  for (Index = 0; Index < BinLength; Index++) {
> -    HexStr[Index * 2 + 2] = IScsiHexString[BinBuffer[Index] >> 4];
> -    HexStr[Index * 2 + 3] = IScsiHexString[BinBuffer[Index] & 0x0F];
> -  }
> -
> -  HexStr[Index * 2 + 2] = '\0';
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Convert the hexadecimal string into a binary encoded buffer.
> -
> -  @param[in, out]  BinBuffer   The binary buffer.
> -  @param[in, out]  BinLength   Length of the binary buffer.
> -  @param[in]       HexStr      The hexadecimal string.
> -
> -  @retval EFI_SUCCESS          The hexadecimal string is converted into a binary
> -                               encoded buffer.
> -  @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the
> converted data.
> -**/
> -EFI_STATUS
> -IScsiHexToBin (
> -  IN OUT UINT8  *BinBuffer,
> -  IN OUT UINT32 *BinLength,
> -  IN     CHAR8  *HexStr
> -  )
> -{
> -  UINTN   Index;
> -  UINTN   Length;
> -  UINT8   Digit;
> -  CHAR8   TemStr[2];
> -
> -  ZeroMem (TemStr, sizeof (TemStr));
> -
> -  //
> -  // Find out how many hex characters the string has.
> -  //
> -  if ((HexStr[0] == '0') && ((HexStr[1] == 'x') || (HexStr[1] == 'X'))) {
> -    HexStr += 2;
> -  }
> -
> -  Length = AsciiStrLen (HexStr);
> -
> -  for (Index = 0; Index < Length; Index ++) {
> -    TemStr[0] = HexStr[Index];
> -    Digit = (UINT8) AsciiStrHexToUint64 (TemStr);
> -    if (Digit == 0 && TemStr[0] != '0') {
> -      //
> -      // Invalid Lun Char
> -      //
> -      break;
> -    }
> -    if ((Index & 1) == 0) {
> -      BinBuffer [Index/2] = Digit;
> -    } else {
> -      BinBuffer [Index/2] = (UINT8) ((BinBuffer [Index/2] << 4) + Digit);
> -    }
> -  }
> -
> -  *BinLength = (UINT32) ((Index + 1)/2);
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Generate random numbers.
> -
> -  @param[in, out]  Rand       The buffer to contain random numbers.
> -  @param[in]       RandLength The length of the Rand buffer.
> -**/
> -VOID
> -IScsiGenRandom (
> -  IN OUT UINT8  *Rand,
> -  IN     UINTN  RandLength
> -  )
> -{
> -  UINT32  Random;
> -
> -  while (RandLength > 0) {
> -    Random  = NET_RANDOM (NetRandomInitSeed ());
> -    *Rand++ = (UINT8) (Random);
> -    RandLength--;
> -  }
> -}
> -
> -/**
> -  Create the iSCSI driver data..
> -
> -  @param[in] Image      The handle of the driver image.
> -  @param[in] Controller The handle of the controller.
> -
> -  @return The iSCSI driver data created.
> -  @retval NULL Other errors as indicated.
> -**/
> -ISCSI_DRIVER_DATA *
> -IScsiCreateDriverData (
> -  IN EFI_HANDLE  Image,
> -  IN EFI_HANDLE  Controller
> -  )
> -{
> -  ISCSI_DRIVER_DATA *Private;
> -  EFI_STATUS        Status;
> -
> -  Private = AllocateZeroPool (sizeof (ISCSI_DRIVER_DATA));
> -  if (Private == NULL) {
> -    return NULL;
> -  }
> -
> -  Private->Signature  = ISCSI_DRIVER_DATA_SIGNATURE;
> -  Private->Image      = Image;
> -  Private->Controller = Controller;
> -
> -  //
> -  // Create an event to be signal when the BS to RT transition is triggerd so
> -  // as to abort the iSCSI session.
> -  //
> -  Status = gBS->CreateEventEx (
> -                  EVT_NOTIFY_SIGNAL,
> -                  TPL_CALLBACK,
> -                  IScsiOnExitBootService,
> -                  Private,
> -                  &gEfiEventExitBootServicesGuid,
> -                  &Private->ExitBootServiceEvent
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    FreePool (Private);
> -    return NULL;
> -  }
> -
> -  CopyMem(&Private->IScsiExtScsiPassThru,
> &gIScsiExtScsiPassThruProtocolTemplate,
> sizeof(EFI_EXT_SCSI_PASS_THRU_PROTOCOL));
> -
> -  //
> -  // 0 is designated to the TargetId, so use another value for the AdapterId.
> -  //
> -  Private->ExtScsiPassThruMode.AdapterId = 2;
> -  Private->ExtScsiPassThruMode.Attributes =
> EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL |
> EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL;
> -  Private->ExtScsiPassThruMode.IoAlign  = 4;
> -  Private->IScsiExtScsiPassThru.Mode    = &Private->ExtScsiPassThruMode;
> -
> -  //
> -  // Install the Ext SCSI PASS THRU protocol.
> -  //
> -  Status = gBS->InstallProtocolInterface (
> -                  &Private->ExtScsiPassThruHandle,
> -                  &gEfiExtScsiPassThruProtocolGuid,
> -                  EFI_NATIVE_INTERFACE,
> -                  &Private->IScsiExtScsiPassThru
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    gBS->CloseEvent (Private->ExitBootServiceEvent);
> -    FreePool (Private);
> -
> -    return NULL;
> -  }
> -
> -  IScsiSessionInit (&Private->Session, FALSE);
> -
> -  return Private;
> -}
> -
> -/**
> -  Clean the iSCSI driver data.
> -
> -  @param[in]              Private The iSCSI driver data.
> -
> -  @retval EFI_SUCCESS     The clean operation is successful.
> -  @retval Others          Other errors as indicated.
> -
> -**/
> -EFI_STATUS
> -IScsiCleanDriverData (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  )
> -{
> -  EFI_STATUS             Status;
> -
> -  Status = EFI_SUCCESS;
> -
> -  if (Private->DevicePath != NULL) {
> -    Status = gBS->UninstallProtocolInterface (
> -                    Private->ExtScsiPassThruHandle,
> -                    &gEfiDevicePathProtocolGuid,
> -                    Private->DevicePath
> -                    );
> -    if (EFI_ERROR (Status)) {
> -      goto EXIT;
> -    }
> -
> -    FreePool (Private->DevicePath);
> -  }
> -
> -  if (Private->ExtScsiPassThruHandle != NULL) {
> -    Status = gBS->UninstallProtocolInterface (
> -                    Private->ExtScsiPassThruHandle,
> -                    &gEfiExtScsiPassThruProtocolGuid,
> -                    &Private->IScsiExtScsiPassThru
> -                    );
> -  }
> -
> -EXIT:
> -  if (Private->ExitBootServiceEvent != NULL) {
> -    gBS->CloseEvent (Private->ExitBootServiceEvent);
> -  }
> -
> -  FreePool (Private);
> -  return Status;
> -}
> -
> -/**
> -  Check wheather the Controller is configured to use DHCP protocol.
> -
> -  @param[in]  Controller           The handle of the controller.
> -
> -  @retval TRUE                     The handle of the controller need the Dhcp protocol.
> -  @retval FALSE                    The handle of the controller does not need the Dhcp
> protocol.
> -
> -**/
> -BOOLEAN
> -IScsiDhcpIsConfigured (
> -  IN EFI_HANDLE  Controller
> -  )
> -{
> -  EFI_STATUS                  Status;
> -  EFI_MAC_ADDRESS             MacAddress;
> -  UINTN                       HwAddressSize;
> -  UINT16                      VlanId;
> -  CHAR16                      MacString[70];
> -  ISCSI_SESSION_CONFIG_NVDATA *ConfigDataTmp;
> -
> -  //
> -  // Get the mac string, it's the name of various variable
> -  //
> -  Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);
> -  if (EFI_ERROR (Status)) {
> -    return FALSE;
> -  }
> -  VlanId = NetLibGetVlanId (Controller);
> -  IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId,
> MacString);
> -
> -  //
> -  // Get the normal configuration.
> -  //
> -  Status = GetVariable2 (
> -             MacString,
> -             &gEfiIScsiInitiatorNameProtocolGuid,
> -             (VOID**)&ConfigDataTmp,
> -             NULL
> -             );
> -  if (ConfigDataTmp == NULL || EFI_ERROR (Status)) {
> -    return FALSE;
> -  }
> -
> -  if (ConfigDataTmp->Enabled && ConfigDataTmp->InitiatorInfoFromDhcp) {
> -    FreePool (ConfigDataTmp);
> -    return TRUE;
> -  }
> -
> -  FreePool (ConfigDataTmp);
> -  return FALSE;
> -}
> -
> -/**
> -  Get the various configuration data of this iSCSI instance.
> -
> -  @param[in]  Private   The iSCSI driver data.
> -
> -  @retval EFI_SUCCESS   The configuration of this instance is got.
> -  @retval EFI_ABORTED   The operation was aborted.
> -  @retval Others        Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiGetConfigData (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  )
> -{
> -  EFI_STATUS                  Status;
> -  ISCSI_SESSION               *Session;
> -  UINTN                       BufferSize;
> -  EFI_MAC_ADDRESS             MacAddress;
> -  UINTN                       HwAddressSize;
> -  UINT16                      VlanId;
> -  CHAR16                      MacString[70];
> -
> -  //
> -  // get the iSCSI Initiator Name
> -  //
> -  Session                       = &Private->Session;
> -  Session->InitiatorNameLength  = ISCSI_NAME_MAX_SIZE;
> -  Status = gIScsiInitiatorName.Get (
> -                                &gIScsiInitiatorName,
> -                                &Session->InitiatorNameLength,
> -                                Session->InitiatorName
> -                                );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  //
> -  // Get the mac string, it's the name of various variable
> -  //
> -  Status = NetLibGetMacAddress (Private->Controller, &MacAddress,
> &HwAddressSize);
> -  ASSERT (Status == EFI_SUCCESS);
> -  VlanId = NetLibGetVlanId (Private->Controller);
> -  IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId,
> MacString);
> -
> -  //
> -  // Get the normal configuration.
> -  //
> -  BufferSize = sizeof (Session->ConfigData.NvData);
> -  Status = gRT->GetVariable (
> -                  MacString,
> -                  &gEfiIScsiInitiatorNameProtocolGuid,
> -                  NULL,
> -                  &BufferSize,
> -                  &Session->ConfigData.NvData
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  if (!Session->ConfigData.NvData.Enabled) {
> -    return EFI_ABORTED;
> -  }
> -  //
> -  // Get the CHAP Auth information.
> -  //
> -  BufferSize = sizeof (Session->AuthData.AuthConfig);
> -  Status = gRT->GetVariable (
> -                  MacString,
> -                  &gIScsiCHAPAuthInfoGuid,
> -                  NULL,
> -                  &BufferSize,
> -                  &Session->AuthData.AuthConfig
> -                  );
> -
> -  if (!EFI_ERROR (Status) && Session-
> >ConfigData.NvData.InitiatorInfoFromDhcp) {
> -    //
> -    // Start dhcp.
> -    //
> -    Status = IScsiDoDhcp (Private->Image, Private->Controller, &Session-
> >ConfigData);
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Get the device path of the iSCSI tcp connection and update it.
> -
> -  @param[in]  Private The iSCSI driver data.
> -
> -  @return The updated device path.
> -  @retval NULL Other errors as indicated.
> -**/
> -EFI_DEVICE_PATH_PROTOCOL *
> -IScsiGetTcpConnDevicePath (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  )
> -{
> -  ISCSI_SESSION             *Session;
> -  ISCSI_CONNECTION          *Conn;
> -  TCP4_IO                   *Tcp4Io;
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> -  EFI_STATUS                Status;
> -  EFI_DEV_PATH              *DPathNode;
> -
> -  Session = &Private->Session;
> -  if (Session->State != SESSION_STATE_LOGGED_IN) {
> -    return NULL;
> -  }
> -
> -  Conn = NET_LIST_USER_STRUCT_S (
> -          Session->Conns.ForwardLink,
> -          ISCSI_CONNECTION,
> -          Link,
> -          ISCSI_CONNECTION_SIGNATURE
> -          );
> -  Tcp4Io = &Conn->Tcp4Io;
> -
> -  Status = gBS->HandleProtocol (
> -                  Tcp4Io->Handle,
> -                  &gEfiDevicePathProtocolGuid,
> -                  (VOID **)&DevicePath
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    return NULL;
> -  }
> -  //
> -  // Duplicate it.
> -  //
> -  DevicePath  = DuplicateDevicePath (DevicePath);
> -  if (DevicePath == NULL) {
> -    return NULL;
> -  }
> -
> -  DPathNode   = (EFI_DEV_PATH *) DevicePath;
> -
> -  while (!IsDevicePathEnd (&DPathNode->DevPath)) {
> -    if ((DevicePathType (&DPathNode->DevPath) == MESSAGING_DEVICE_PATH)
> &&
> -        (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP)
> -        ) {
> -
> -      DPathNode->Ipv4.LocalPort       = 0;
> -      DPathNode->Ipv4.StaticIpAddress =
> -        (BOOLEAN) (!Session->ConfigData.NvData.InitiatorInfoFromDhcp);
> -
> -      //
> -      //  Add a judgement here to support previous versions of IPv4_DEVICE_PATH.
> -      //  In previous versions of IPv4_DEVICE_PATH, GatewayIpAddress and
> SubnetMask
> -      //  do not exist.
> -      //  In new version of IPv4_DEVICE_PATH, structcure length is 27.
> -      //
> -      if (DevicePathNodeLength (&DPathNode->Ipv4) ==
> IP4_NODE_LEN_NEW_VERSIONS) {
> -
> -        IP4_COPY_ADDRESS (
> -          &DPathNode->Ipv4.GatewayIpAddress,
> -          &Session->ConfigData.NvData.Gateway
> -          );
> -
> -        IP4_COPY_ADDRESS (
> -          &DPathNode->Ipv4.SubnetMask,
> -          &Session->ConfigData.NvData.SubnetMask
> -          );
> -      }
> -
> -      break;
> -    }
> -
> -    DPathNode = (EFI_DEV_PATH *) NextDevicePathNode (&DPathNode-
> >DevPath);
> -  }
> -
> -  return DevicePath;
> -}
> -
> -/**
> -  Abort the session when the transition from BS to RT is initiated.
> -
> -  @param[in]   Event  The event signaled.
> -  @param[in]  Context The iSCSI driver data.
> -**/
> -VOID
> -EFIAPI
> -IScsiOnExitBootService (
> -  IN EFI_EVENT  Event,
> -  IN VOID       *Context
> -  )
> -{
> -  ISCSI_DRIVER_DATA *Private;
> -
> -  Private = (ISCSI_DRIVER_DATA *) Context;
> -
> -  gBS->CloseEvent (Private->ExitBootServiceEvent);
> -  Private->ExitBootServiceEvent = NULL;
> -
> -  IScsiSessionAbort (&Private->Session);
> -}
> -
> -/**
> -  Tests whether a controller handle is being managed by IScsi driver.
> -
> -  This function tests whether the driver specified by DriverBindingHandle is
> -  currently managing the controller specified by ControllerHandle.  This test
> -  is performed by evaluating if the the protocol specified by ProtocolGuid is
> -  present on ControllerHandle and is was opened by DriverBindingHandle and
> Nic
> -  Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
> -  If ProtocolGuid is NULL, then ASSERT().
> -
> -  @param  ControllerHandle     A handle for a controller to test.
> -  @param  DriverBindingHandle  Specifies the driver binding handle for the
> -                               driver.
> -  @param  ProtocolGuid         Specifies the protocol that the driver specified
> -                               by DriverBindingHandle opens in its Start()
> -                               function.
> -
> -  @retval EFI_SUCCESS          ControllerHandle is managed by the driver
> -                               specified by DriverBindingHandle.
> -  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver
> -                               specified by DriverBindingHandle.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiTestManagedDevice (
> -  IN  EFI_HANDLE       ControllerHandle,
> -  IN  EFI_HANDLE       DriverBindingHandle,
> -  IN  EFI_GUID         *ProtocolGuid
> -  )
> -{
> -  EFI_STATUS     Status;
> -  VOID           *ManagedInterface;
> -  EFI_HANDLE     NicControllerHandle;
> -
> -  ASSERT (ProtocolGuid != NULL);
> -
> -  NicControllerHandle = NetLibGetNicHandle (ControllerHandle, ProtocolGuid);
> -  if (NicControllerHandle == NULL) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  Status = gBS->OpenProtocol (
> -                  ControllerHandle,
> -                  (EFI_GUID *) ProtocolGuid,
> -                  &ManagedInterface,
> -                  DriverBindingHandle,
> -                  NicControllerHandle,
> -                  EFI_OPEN_PROTOCOL_BY_DRIVER
> -                  );
> -  if (!EFI_ERROR (Status)) {
> -    gBS->CloseProtocol (
> -           ControllerHandle,
> -           (EFI_GUID *) ProtocolGuid,
> -           DriverBindingHandle,
> -           NicControllerHandle
> -           );
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  if (Status != EFI_ALREADY_STARTED) {
> -    return EFI_UNSUPPORTED;
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
> deleted file mode 100644
> index b4a5c2d02413..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
> +++ /dev/null
> @@ -1,2799 +0,0 @@
> -/** @file
> -  The implementation of iSCSI protocol based on RFC3720.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -UINT32 mDataSegPad = 0;
> -
> -/**
> -  Attach the iSCSI connection to the iSCSI session.
> -
> -  @param[in, out]  Session The iSCSI session.
> -  @param[in, out]  Conn    The iSCSI connection.
> -**/
> -VOID
> -IScsiAttatchConnection (
> -  IN OUT ISCSI_SESSION     *Session,
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  InsertTailList (&Session->Conns, &Conn->Link);
> -  Conn->Session = Session;
> -  Session->NumConns++;
> -}
> -
> -/**
> -  Detach the iSCSI connection from the session it belongs to.
> -
> -  @param[in, out]  Conn The iSCSI connection.
> -**/
> -VOID
> -IScsiDetatchConnection (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  RemoveEntryList (&Conn->Link);
> -  Conn->Session->NumConns--;
> -  Conn->Session = NULL;
> -}
> -
> -/**
> -  Check the sequence number according to RFC3720.
> -
> -  @param[in, out]  ExpSN   The currently expected sequence number.
> -  @param[in]       NewSN   The sequence number to check.
> -
> -  @retval EFI_SUCCESS         The check passed and the ExpSN is increased.
> -  @retval EFI_NOT_READY       Response was sent due to a retransmission
> request.
> -  @retval EFI_PROTOCOL_ERROR  Some kind of iSCSI protocol error happened.
> -**/
> -EFI_STATUS
> -IScsiCheckSN (
> -  IN OUT UINT32  *ExpSN,
> -  IN UINT32      NewSN
> -  )
> -{
> -  if (!ISCSI_SEQ_EQ (NewSN, *ExpSN)) {
> -    if (ISCSI_SEQ_LT (NewSN, *ExpSN)) {
> -      //
> -      // Duplicate
> -      //
> -      return EFI_NOT_READY;
> -    } else {
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -  } else {
> -    //
> -    // Advance the ExpSN
> -    //
> -    (*ExpSN)++;
> -    return EFI_SUCCESS;
> -  }
> -}
> -
> -/**
> -  Update the sequence numbers for the iSCSI command.
> -
> -  @param[in, out]  Session  The iSCSI session.
> -  @param[in]       MaxCmdSN Maximum CmdSN from the target.
> -  @param[in]       ExpCmdSN Next expected CmdSN from the target.
> -**/
> -VOID
> -IScsiUpdateCmdSN (
> -  IN OUT ISCSI_SESSION  *Session,
> -  IN UINT32             MaxCmdSN,
> -  IN UINT32             ExpCmdSN
> -  )
> -{
> -  if (ISCSI_SEQ_LT (MaxCmdSN, ExpCmdSN - 1)) {
> -    return ;
> -  }
> -
> -  if (ISCSI_SEQ_GT (MaxCmdSN, Session->MaxCmdSN)) {
> -    Session->MaxCmdSN = MaxCmdSN;
> -  }
> -
> -  if (ISCSI_SEQ_GT (ExpCmdSN, Session->ExpCmdSN)) {
> -    Session->ExpCmdSN = ExpCmdSN;
> -  }
> -}
> -
> -/**
> -  This function does the iSCSI connection login.
> -
> -  @param[in, out]  Conn      The iSCSI connection to login.
> -
> -  @retval EFI_SUCCESS        The iSCSI connection is logged into the iSCSI target.
> -  @retval EFI_TIMEOUT        Timeout happened during the login procedure.
> -  @retval Others             Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiConnLogin (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  EFI_STATUS  Status;
> -
> -  //
> -  // Start the timer, wait 16 seconds to establish the TCP connection.
> -  //
> -  Status = gBS->SetTimer (Conn->TimeoutEvent, TimerRelative, 16 *
> TICKS_PER_SECOND);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -  //
> -  // try to establish the tcp connection
> -  //
> -  Status = Tcp4IoConnect (&Conn->Tcp4Io, Conn->TimeoutEvent);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  gBS->SetTimer (Conn->TimeoutEvent, TimerCancel, 0);
> -  Conn->State = CONN_STATE_IN_LOGIN;
> -
> -  //
> -  // connection is established, start the iSCSI Login
> -  //
> -  do {
> -    Status = IScsiSendLoginReq (Conn);
> -    if (EFI_ERROR (Status)) {
> -      break;
> -    }
> -
> -    Status = IScsiReceiveLoginRsp (Conn);
> -    if (EFI_ERROR (Status)) {
> -      break;
> -    }
> -  } while (Conn->CurrentStage != ISCSI_FULL_FEATURE_PHASE);
> -
> -  return Status;
> -}
> -
> -/**
> -  Reset the iSCSI connection.
> -
> -  @param[in, out]  Conn The iSCSI connection to reset.
> -**/
> -VOID
> -IScsiConnReset (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  Tcp4IoReset (&Conn->Tcp4Io);
> -}
> -
> -/**
> -  Create a TCP connection for the iSCSI session.
> -
> -  @param[in]  Private The iSCSI driver data.
> -  @param[in]  Session Maximum CmdSN from the target.
> -
> -  @return The newly created iSCSI connection.
> -**/
> -ISCSI_CONNECTION *
> -IScsiCreateConnection (
> -  IN ISCSI_DRIVER_DATA  *Private,
> -  IN ISCSI_SESSION      *Session
> -  )
> -{
> -  ISCSI_CONNECTION    *Conn;
> -  TCP4_IO_CONFIG_DATA Tcp4IoConfig;
> -  EFI_STATUS          Status;
> -
> -  Conn = AllocatePool (sizeof (ISCSI_CONNECTION));
> -  if (Conn == NULL) {
> -    return NULL;
> -  }
> -
> -  Conn->Signature       = ISCSI_CONNECTION_SIGNATURE;
> -  Conn->State           = CONN_STATE_FREE;
> -  Conn->CurrentStage    = ISCSI_SECURITY_NEGOTIATION;
> -  Conn->NextStage       = ISCSI_LOGIN_OPERATIONAL_NEGOTIATION;
> -  Conn->CHAPStep        = ISCSI_CHAP_INITIAL;
> -  Conn->ExpStatSN       = 0;
> -  Conn->PartialReqSent  = FALSE;
> -  Conn->PartialRspRcvd  = FALSE;
> -  Conn->Cid             = Session->NextCid++;
> -
> -  Status = gBS->CreateEvent (
> -                  EVT_TIMER,
> -                  TPL_CALLBACK,
> -                  NULL,
> -                  NULL,
> -                  &Conn->TimeoutEvent
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    FreePool (Conn);
> -    return NULL;
> -  }
> -
> -  NetbufQueInit (&Conn->RspQue);
> -
> -  //
> -  // set the default connection-only parameters
> -  //
> -  Conn->MaxRecvDataSegmentLength  = DEFAULT_MAX_RECV_DATA_SEG_LEN;
> -  Conn->HeaderDigest              = IScsiDigestNone;
> -  Conn->DataDigest                = IScsiDigestNone;
> -
> -  CopyMem (&Tcp4IoConfig.LocalIp, &Session->ConfigData.NvData.LocalIp,
> sizeof (EFI_IPv4_ADDRESS));
> -  CopyMem (&Tcp4IoConfig.SubnetMask, &Session-
> >ConfigData.NvData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
> -  CopyMem (&Tcp4IoConfig.Gateway, &Session->ConfigData.NvData.Gateway,
> sizeof (EFI_IPv4_ADDRESS));
> -  CopyMem (&Tcp4IoConfig.RemoteIp, &Session->ConfigData.NvData.TargetIp,
> sizeof (EFI_IPv4_ADDRESS));
> -
> -  Tcp4IoConfig.RemotePort = Session->ConfigData.NvData.TargetPort;
> -
> -  //
> -  // Create the tcp4 IO for this connection
> -  //
> -  Status = Tcp4IoCreateSocket (
> -            Private->Image,
> -            Private->Controller,
> -            &Tcp4IoConfig,
> -            &Conn->Tcp4Io
> -            );
> -  if (EFI_ERROR (Status)) {
> -    gBS->CloseEvent (Conn->TimeoutEvent);
> -    FreePool (Conn);
> -    Conn = NULL;
> -  }
> -
> -  return Conn;
> -}
> -
> -/**
> -  Destroy an iSCSI connection.
> -
> -  @param[in]  Conn The connection to destroy.
> -**/
> -VOID
> -IScsiDestroyConnection (
> -  IN ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  Tcp4IoDestroySocket (&Conn->Tcp4Io);
> -  NetbufQueFlush (&Conn->RspQue);
> -  gBS->CloseEvent (Conn->TimeoutEvent);
> -  FreePool (Conn);
> -}
> -
> -/**
> -  Login the iSCSI session.
> -
> -  @param[in]  Private          The iSCSI driver data.
> -
> -  @retval EFI_SUCCESS          The iSCSI session login procedure finished.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NO_MEDIA         There was a media error.
> -  @retval Others               Other errors as indicated.
> -
> -**/
> -EFI_STATUS
> -IScsiSessionLogin (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  )
> -{
> -  EFI_STATUS        Status;
> -  ISCSI_SESSION     *Session;
> -  ISCSI_CONNECTION  *Conn;
> -  EFI_TCP4_PROTOCOL *Tcp4;
> -  EFI_STATUS        MediaStatus;
> -
> -  Session = &Private->Session;
> -
> -  //
> -  // Check media status before session login
> -  //
> -  MediaStatus = EFI_SUCCESS;
> -  NetLibDetectMediaWaitTimeout (Private->Controller,
> ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME, &MediaStatus);
> -  if (MediaStatus != EFI_SUCCESS) {
> -    return EFI_NO_MEDIA;
> -  }
> -
> -  //
> -  // Set session identifier
> -  //
> -  CopyMem (Session->Isid, Session->ConfigData.NvData.IsId, 6);
> -
> -  //
> -  // Create a connection for the session.
> -  //
> -  Conn = IScsiCreateConnection (Private, Session);
> -  if (Conn == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  IScsiAttatchConnection (Session, Conn);
> -
> -  //
> -  // Login througth the newly created connection.
> -  //
> -  Status = IScsiConnLogin (Conn);
> -  if (EFI_ERROR (Status)) {
> -    IScsiConnReset (Conn);
> -    IScsiDetatchConnection (Conn);
> -    IScsiDestroyConnection (Conn);
> -  } else {
> -    Session->State = SESSION_STATE_LOGGED_IN;
> -
> -    gBS->OpenProtocol (
> -          Conn->Tcp4Io.Handle,
> -          &gEfiTcp4ProtocolGuid,
> -          (VOID **)&Tcp4,
> -          Private->Image,
> -          Private->ExtScsiPassThruHandle,
> -          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
> -          );
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Build and send the iSCSI login request to the iSCSI target according to
> -  the current login stage.
> -
> -  @param[in]  Conn             The connection in the iSCSI login phase.
> -
> -  @retval EFI_SUCCESS          The iSCSI login request PDU is built and sent on this
> -                               connection.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_DEVICE_ERROR     Some kind of device error happened.
> -**/
> -EFI_STATUS
> -IScsiSendLoginReq (
> -  IN ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  NET_BUF     *Pdu;
> -  EFI_STATUS  Status;
> -
> -  //
> -  // build the Login Request PDU
> -  //
> -  Pdu = IScsiPrepareLoginReq (Conn);
> -  if (Pdu == NULL) {
> -    return EFI_DEVICE_ERROR;
> -  }
> -  //
> -  // Send it to the iSCSI target.
> -  //
> -  Status = Tcp4IoTransmit (&Conn->Tcp4Io, Pdu);
> -
> -  NetbufFree (Pdu);
> -
> -  return Status;
> -}
> -
> -/**
> -  Receive and process the iSCSI login response.
> -
> -  @param[in]  Conn             The connection in the iSCSI login phase.
> -
> -  @retval EFI_SUCCESS          The iSCSI login response PDU is received and
> processed.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiReceiveLoginRsp (
> -  IN ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  EFI_STATUS  Status;
> -  NET_BUF     *Pdu;
> -
> -  Pdu = NULL;
> -
> -  //
> -  // Receive the iSCSI login response.
> -  //
> -  Status = IScsiReceivePdu (Conn, &Pdu, NULL, FALSE, FALSE, NULL);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -  //
> -  // A Login Response is received, process it.
> -  //
> -  ASSERT (Pdu != NULL);
> -  Status = IScsiProcessLoginRsp (Conn, Pdu);
> -
> -  NetbufFree (Pdu);
> -
> -  return Status;
> -}
> -
> -/**
> -  Add an iSCSI key-value pair as a string into the data segment of the Login
> Request PDU.
> -  The DataSegmentLength and the actual size of the net buffer containing this
> PDU will be
> -  updated.
> -
> -  @param[in, out]  Pdu         The iSCSI PDU whose data segment the key-value
> pair will
> -                               be added to.
> -  @param[in]       Key         The key name string.
> -  @param[in]       Value       The value string.
> -
> -  @retval EFI_SUCCESS          The key-valu pair is added to the PDU's
> datasegment and
> -                               the correspondence length fields are updated.
> -  @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to
> add the key-value
> -                               pair.
> -**/
> -EFI_STATUS
> -IScsiAddKeyValuePair (
> -  IN OUT NET_BUF      *Pdu,
> -  IN CHAR8            *Key,
> -  IN CHAR8            *Value
> -  )
> -{
> -  UINT32              DataSegLen;
> -  UINT32              KeyLen;
> -  UINT32              ValueLen;
> -  UINT32              TotalLen;
> -  ISCSI_LOGIN_REQUEST *LoginReq;
> -  CHAR8               *Data;
> -
> -  LoginReq    = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, NULL);
> -  if (LoginReq == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  DataSegLen  = NTOH24 (LoginReq->DataSegmentLength);
> -
> -  KeyLen      = (UINT32) AsciiStrLen (Key);
> -  ValueLen    = (UINT32) AsciiStrLen (Value);
> -
> -  //
> -  // 1 byte for the key value separator '=' and 1 byte for the null
> -  // delimiter after the value.
> -  //
> -  TotalLen = KeyLen + 1 + ValueLen + 1;
> -
> -  //
> -  // Allocate the space for the key-value pair.
> -  //
> -  Data = (CHAR8 *)NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
> -  if (Data == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -  //
> -  // Add the key.
> -  //
> -  CopyMem (Data, Key, KeyLen);
> -  Data += KeyLen;
> -
> -  *Data = '=';
> -  Data++;
> -
> -  //
> -  // Add the value.
> -  //
> -  CopyMem (Data, Value, ValueLen);
> -  Data += ValueLen;
> -
> -  *Data = '\0';
> -
> -  //
> -  // update the DataSegmentLength
> -  //
> -  ISCSI_SET_DATASEG_LEN (LoginReq, DataSegLen + TotalLen);
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Prepare the iSCSI login request to be sent according to the current login status.
> -
> -  @param[in, out]  Conn The connection in the iSCSI login phase.
> -
> -  @return The pointer to the net buffer containing the iSCSI login request built.
> -  @retval Others    Other errors as indicated.
> -**/
> -NET_BUF *
> -IScsiPrepareLoginReq (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  ISCSI_SESSION       *Session;
> -  NET_BUF             *Nbuf;
> -  ISCSI_LOGIN_REQUEST *LoginReq;
> -  EFI_STATUS          Status;
> -
> -  Session = Conn->Session;
> -
> -  Nbuf    = NetbufAlloc (sizeof (ISCSI_LOGIN_REQUEST) +
> DEFAULT_MAX_RECV_DATA_SEG_LEN);
> -  if (Nbuf == NULL) {
> -    return NULL;
> -  }
> -
> -  LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufAllocSpace (Nbuf, sizeof
> (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL);
> -  ASSERT (LoginReq != NULL);
> -  ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
> -
> -  //
> -  // Init the login request pdu
> -  //
> -  ISCSI_SET_OPCODE (LoginReq, ISCSI_OPCODE_LOGIN_REQ,
> ISCSI_REQ_IMMEDIATE);
> -  ISCSI_SET_STAGES (LoginReq, Conn->CurrentStage, Conn->NextStage);
> -  LoginReq->VersionMax        = ISCSI_VERSION_MAX;
> -  LoginReq->VersionMin        = ISCSI_VERSION_MIN;
> -  LoginReq->Tsih              = HTONS (Session->Tsih);
> -  LoginReq->InitiatorTaskTag  = HTONL (Session->InitiatorTaskTag);
> -  LoginReq->Cid               = HTONS (Conn->Cid);
> -  LoginReq->CmdSN             = HTONL (Session->CmdSN);
> -
> -  //
> -  // For the first Login Request on a coonection this is ExpStatSN for the
> -  // old connection and this field is only valid if the Login Request restarts
> -  // a connection.
> -  // For subsequent Login Requests it is used to acknowledge the Login
> Responses
> -  // with their increasing StatSN values.
> -  //
> -  LoginReq->ExpStatSN = HTONL (Conn->ExpStatSN);
> -  CopyMem (LoginReq->Isid, Session->Isid, sizeof (LoginReq->Isid));
> -
> -  if (Conn->PartialRspRcvd) {
> -    //
> -    // A partial response, initiator must send an empty Login Request.
> -    //
> -    return Nbuf;
> -  }
> -
> -  switch (Conn->CurrentStage) {
> -  case ISCSI_SECURITY_NEGOTIATION:
> -    Status = IScsiCHAPToSendReq (Conn, Nbuf);
> -    break;
> -
> -  case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
> -    Status = IScsiFillOpParams (Conn, Nbuf);
> -    ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
> -    break;
> -
> -  default:
> -    //
> -    // something error happens...
> -    //
> -    Status = EFI_DEVICE_ERROR;
> -    break;
> -  }
> -
> -  if (EFI_ERROR (Status)) {
> -    NetbufFree (Nbuf);
> -    Nbuf = NULL;
> -  } else {
> -    //
> -    // Pad the data segment if needed.
> -    //
> -    IScsiPadSegment (Nbuf, ISCSI_GET_DATASEG_LEN (LoginReq));
> -    //
> -    // Check whether we will issue the stage transition signal?
> -    //
> -    Conn->TransitInitiated = (BOOLEAN) ISCSI_FLAG_ON (LoginReq,
> ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
> -  }
> -
> -  return Nbuf;
> -}
> -
> -/**
> -  Process the iSCSI Login Response.
> -
> -  @param[in, out]  Conn The connection on which the iSCSI login response is
> received.
> -  @param[in, out]  Pdu  The iSCSI login response PDU.
> -
> -  @retval EFI_SUCCESS        The iSCSI login response PDU is processed and all
> check are passed.
> -  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
> -  @retval EFI_MEDIA_CHANGED  Target is redirected.
> -  @retval Others             Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiProcessLoginRsp (
> -  IN OUT ISCSI_CONNECTION  *Conn,
> -  IN OUT NET_BUF           *Pdu
> -  )
> -{
> -  EFI_STATUS            Status;
> -  ISCSI_SESSION         *Session;
> -  ISCSI_LOGIN_RESPONSE  *LoginRsp;
> -  BOOLEAN               Transit;
> -  BOOLEAN               Continue;
> -  UINT8                 CurrentStage;
> -  UINT8                 NextStage;
> -  UINT8                 *DataSeg;
> -  UINT32                DataSegLen;
> -
> -  Session   = Conn->Session;
> -
> -  LoginRsp  = (ISCSI_LOGIN_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
> -  if (LoginRsp == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  if (!ISCSI_CHECK_OPCODE (LoginRsp, ISCSI_OPCODE_LOGIN_RSP)) {
> -    //
> -    // It's not a Login Response
> -    //
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  //
> -  // Get the data segment if any.
> -  //
> -  DataSegLen = ISCSI_GET_DATASEG_LEN (LoginRsp);
> -  if (DataSegLen != 0) {
> -    DataSeg = NetbufGetByte (Pdu, sizeof (ISCSI_LOGIN_RESPONSE), NULL);
> -  } else {
> -    DataSeg = NULL;
> -  }
> -  //
> -  // Check the status class in the login response PDU.
> -  //
> -  switch (LoginRsp->StatusClass) {
> -  case ISCSI_LOGIN_STATUS_SUCCESS:
> -    //
> -    // Just break here, the response and the data segment will be processed later.
> -    //
> -    break;
> -
> -  case ISCSI_LOGIN_STATUS_REDIRECTION:
> -    //
> -    // The target may be moved to a different address
> -    //
> -    if (DataSeg == NULL) {
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -    //
> -    // Process the TargetAddress key-value strings in the data segment to update
> the
> -    // target address info.
> -    //
> -    Status = IScsiUpdateTargetAddress (Session, (CHAR8 *)DataSeg, DataSegLen);
> -    if (EFI_ERROR (Status)) {
> -      return Status;
> -    }
> -    //
> -    // Session will be restarted on this error status because the Target is
> -    // redirected by this Login Response.
> -    //
> -    return EFI_MEDIA_CHANGED;
> -
> -  default:
> -    //
> -    // Initiator Error, Target Error, or any other undefined error code.
> -    //
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  //
> -  // The status is sucess, extract the wanted fields from the header segment.
> -  //
> -  Transit                     = (BOOLEAN) ISCSI_FLAG_ON (LoginRsp,
> ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT);
> -  Continue                    = (BOOLEAN) ISCSI_FLAG_ON (LoginRsp,
> ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE);
> -
> -  CurrentStage                = (UINT8) ISCSI_GET_CURRENT_STAGE (LoginRsp);
> -  NextStage                   = (UINT8) ISCSI_GET_NEXT_STAGE (LoginRsp);
> -
> -  LoginRsp->InitiatorTaskTag  = NTOHL (LoginRsp->InitiatorTaskTag);
> -
> -  if ((Transit && Continue) ||
> -      (CurrentStage != Conn->CurrentStage) ||
> -      (!Conn->TransitInitiated && Transit) ||
> -      (Transit && (NextStage != Conn->NextStage)) ||
> -      (CompareMem (Session->Isid, LoginRsp->Isid, sizeof (LoginRsp->Isid)) != 0)
> ||
> -      (LoginRsp->InitiatorTaskTag != Session->InitiatorTaskTag)
> -      ) {
> -    //
> -    // A Login Response with the C bit set to 1 MUST have the T bit set to 0;
> -    // The CSG in the Login Response MUST be the same with the I-end of this
> connection;
> -    // The T bit can't be 1 if the last Login Response sent by the initiator doesn't
> -    // initiate the transistion;
> -    // The NSG MUST be the same with the I-end of this connection if Transit is
> required.
> -    // The ISID in the Login Response MUST be the same with this session.
> -    //
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  LoginRsp->StatSN    = NTOHL (LoginRsp->StatSN);
> -  LoginRsp->ExpCmdSN  = NTOHL (LoginRsp->ExpCmdSN);
> -  LoginRsp->MaxCmdSN  = NTOHL (LoginRsp->MaxCmdSN);
> -
> -  if ((Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION) && (Conn-
> >CHAPStep == ISCSI_CHAP_INITIAL)) {
> -    //
> -    // If the Login Request is a leading Login Request, the target MUST use
> -    // the value presented in CmdSN as the target value for ExpCmdSN.
> -    //
> -    if ((Session->State == SESSION_STATE_FREE) && (Session->CmdSN !=
> LoginRsp->ExpCmdSN)) {
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -
> -    //
> -    // It's the initial Login Response, initialize the local ExpStatSN, MaxCmdSN
> -    // and ExpCmdSN.
> -    //
> -    Conn->ExpStatSN   = LoginRsp->StatSN + 1;
> -    Session->MaxCmdSN = LoginRsp->MaxCmdSN;
> -    Session->ExpCmdSN = LoginRsp->ExpCmdSN;
> -  } else {
> -    //
> -    // Check the StatSN of this PDU
> -    //
> -    Status = IScsiCheckSN (&Conn->ExpStatSN, LoginRsp->StatSN);
> -    if (!EFI_ERROR (Status)) {
> -      //
> -      // Update the MaxCmdSN and ExpCmdSN
> -      //
> -      IScsiUpdateCmdSN (Session, LoginRsp->MaxCmdSN, LoginRsp->ExpCmdSN);
> -    } else {
> -      return Status;
> -    }
> -  }
> -  //
> -  // Trim off the header segment.
> -  //
> -  NetbufTrim (Pdu, sizeof (ISCSI_LOGIN_RESPONSE), NET_BUF_HEAD);
> -
> -  //
> -  // Queue this login response first in case it's a partial response so that
> -  // later when the full response list is received we can combine these scattered
> -  // responses' data segment and then process it.
> -  //
> -  NET_GET_REF (Pdu);
> -  NetbufQueAppend (&Conn->RspQue, Pdu);
> -
> -  Conn->PartialRspRcvd = Continue;
> -  if (Continue) {
> -    //
> -    // It's a partial response, have to wait for another or more Request/Response
> -    // conversations to get the full response.
> -    //
> -    return EFI_SUCCESS;
> -  }
> -
> -  switch (CurrentStage) {
> -  case ISCSI_SECURITY_NEGOTIATION:
> -    //
> -    // In security negotiation stage, let CHAP module handle it.
> -    //
> -    Status = IScsiCHAPOnRspReceived (Conn);
> -    break;
> -
> -  case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION:
> -    //
> -    // Response received with negotiation resonse on iSCSI parameters, check
> them.
> -    //
> -    Status = IScsiCheckOpParams (Conn);
> -    break;
> -
> -  default:
> -    //
> -    // Should never get here.
> -    //
> -    Status = EFI_PROTOCOL_ERROR;
> -    break;
> -  }
> -
> -  if (Transit && (Status == EFI_SUCCESS)) {
> -    //
> -    // Do the state transition.
> -    //
> -    Conn->CurrentStage = Conn->NextStage;
> -
> -    if (Conn->CurrentStage == ISCSI_LOGIN_OPERATIONAL_NEGOTIATION) {
> -      Conn->NextStage = ISCSI_FULL_FEATURE_PHASE;
> -    } else {
> -      //
> -      // CurrentStage is iSCSI Full Feature, it's the Login-Final Response,
> -      // get the TSIH from the Login Response.
> -      //
> -      Session->Tsih = NTOHS (LoginRsp->Tsih);
> -    }
> -  }
> -  //
> -  // Flush the response(s) received.
> -  //
> -  NetbufQueFlush (&Conn->RspQue);
> -
> -  return Status;
> -}
> -
> -/**
> -  Updated the target information according the data received in the iSCSI
> -  login response with an target redirection status.
> -
> -  @param[in, out] Session      The iSCSI session.
> -  @param[in]      Data         The data segment which should contain the
> -                               TargetAddress key-value list.
> -  @param[in]      Len          Length of the data.
> -
> -  @retval EFI_SUCCESS          The target address is updated.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NOT_FOUND        The TargetAddress key is not found.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiUpdateTargetAddress (
> -  IN OUT ISCSI_SESSION  *Session,
> -  IN CHAR8              *Data,
> -  IN UINT32             Len
> -  )
> -{
> -  LIST_ENTRY      *KeyValueList;
> -  CHAR8           *TargetAddress;
> -  CHAR8           *IpStr;
> -  EFI_STATUS      Status;
> -  UINTN           Number;
> -
> -  KeyValueList = IScsiBuildKeyValueList (Data, Len);
> -  if (KeyValueList == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  Status = EFI_NOT_FOUND;
> -
> -  while (TRUE) {
> -    TargetAddress = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_TARGET_ADDRESS);
> -    if (TargetAddress == NULL) {
> -      break;
> -    }
> -
> -    if (!NET_IS_DIGIT (TargetAddress[0])) {
> -      //
> -      // The domainname of the target may be presented in three formats: a DNS
> host name,
> -      // a dotted-decimal IPv4 address, or a bracketed IPv6 address. Only accept
> dotted
> -      // IPv4 address.
> -      //
> -      continue;
> -    }
> -
> -    IpStr = TargetAddress;
> -
> -    while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress !=
> ',')) {
> -      //
> -      // NULL, ':' or ',' ends the IPv4 string.
> -      //
> -      TargetAddress++;
> -    }
> -
> -    if (*TargetAddress == ',') {
> -      //
> -      // Comma and the portal group tag MUST be ommitted if the TargetAddress
> is sent
> -      // as the result of a redirection.
> -      //
> -      continue;
> -    } else if (*TargetAddress == ':') {
> -      *TargetAddress = '\0';
> -
> -      TargetAddress++;
> -
> -      Number = AsciiStrDecimalToUintn (TargetAddress);
> -      if (Number > 0xFFFF) {
> -        continue;
> -      } else {
> -        Session->ConfigData.NvData.TargetPort = (UINT16) Number;
> -      }
> -    } else {
> -      //
> -      // The string only contains the IPv4 address. Use the well known port.
> -      //
> -      Session->ConfigData.NvData.TargetPort = ISCSI_WELL_KNOWN_PORT;
> -    }
> -    //
> -    // Update the target IP address.
> -    //
> -    Status = IScsiAsciiStrToIp (IpStr, &Session->ConfigData.NvData.TargetIp);
> -    if (EFI_ERROR (Status)) {
> -      continue;
> -    } else {
> -      break;
> -    }
> -  }
> -
> -  IScsiFreeKeyValueList (KeyValueList);
> -
> -  return Status;
> -}
> -
> -/**
> -  The callback function to free the net buffer list.
> -
> -  @param[in]  Arg The opaque parameter.
> -**/
> -VOID
> -EFIAPI
> -IScsiFreeNbufList (
> -  VOID *Arg
> -  )
> -{
> -  ASSERT (Arg != NULL);
> -
> -  NetbufFreeList ((LIST_ENTRY     *) Arg);
> -  FreePool (Arg);
> -}
> -
> -/**
> -  The callback function called in NetBufFree, it does nothing.
> -
> -  @param[in]   Arg  The opaque parameter.
> -**/
> -VOID
> -EFIAPI
> -IScsiNbufExtFree (
> -  VOID *Arg
> -  )
> -{
> -}
> -
> -/**
> -  Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU
> header and
> -  an optional data segment. The two parts will be put into two blocks of buffers
> in the
> -  net buffer. The digest check will be conducted in this function if needed and
> the digests
> -  will be trimmed from the PDU buffer.
> -
> -  @param[in]   Conn        The iSCSI connection to receive data from.
> -  @param[out]  Pdu         The received iSCSI pdu.
> -  @param[in]   Context     The context used to describe information on the caller
> provided
> -                           buffer to receive data segment of the iSCSI pdu, it's optional.
> -  @param[in]  HeaderDigest Whether there will be header digest received.
> -  @param[in]  DataDigest   Whether there will be data digest.
> -  @param[in]  TimeoutEvent The timeout event, it's optional.
> -
> -  @retval EFI_SUCCESS          An iSCSI pdu is received.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiReceivePdu (
> -  IN ISCSI_CONNECTION                      *Conn,
> -  OUT NET_BUF                              **Pdu,
> -  IN ISCSI_IN_BUFFER_CONTEXT               *Context, OPTIONAL
> -  IN BOOLEAN                               HeaderDigest,
> -  IN BOOLEAN                               DataDigest,
> -  IN EFI_EVENT                             TimeoutEvent OPTIONAL
> -  )
> -{
> -  LIST_ENTRY      *NbufList;
> -  UINT32          Len;
> -  NET_BUF         *PduHdr;
> -  UINT8           *Header;
> -  EFI_STATUS      Status;
> -  UINT32          PadLen;
> -  UINT32          InDataOffset;
> -  NET_FRAGMENT    Fragment[2];
> -  UINT32          FragmentCount;
> -  NET_BUF         *DataSeg;
> -  UINT32          PadAndCRC32[2];
> -
> -  NbufList = AllocatePool (sizeof (LIST_ENTRY));
> -  if (NbufList == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  InitializeListHead (NbufList);
> -
> -  //
> -  // The header digest will be received together with the PDU header if exists.
> -  //
> -  Len     = sizeof (ISCSI_BASIC_HEADER) + (HeaderDigest ? sizeof (UINT32) : 0);
> -  PduHdr  = NetbufAlloc (Len);
> -  if (PduHdr == NULL) {
> -    FreePool (NbufList);
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  Header = NetbufAllocSpace (PduHdr, Len, NET_BUF_TAIL);
> -  ASSERT (Header != NULL);
> -  InsertTailList (NbufList, &PduHdr->List);
> -
> -  //
> -  // First step, receive the BHS of the PDU.
> -  //
> -  Status = Tcp4IoReceive (&Conn->Tcp4Io, PduHdr, FALSE, TimeoutEvent);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  if (HeaderDigest) {
> -    //
> -    // TODO: check the header-digest.
> -    //
> -    //
> -    // Trim off the digest.
> -    //
> -    NetbufTrim (PduHdr, sizeof (UINT32), NET_BUF_TAIL);
> -  }
> -
> -  Len = ISCSI_GET_DATASEG_LEN (Header);
> -  if (Len == 0) {
> -    //
> -    // No data segment.Form the pdu from a list of pdu segments.
> -    //
> -    *Pdu = NetbufFromBufList (NbufList, 0, 0, IScsiFreeNbufList, NbufList);
> -    if (*Pdu == NULL) {
> -      Status = EFI_OUT_OF_RESOURCES;
> -      goto ON_EXIT;
> -    }
> -    return Status;
> -  }
> -  //
> -  // Get the length of the padding bytes of the data segment.
> -  //
> -  PadLen = ISCSI_GET_PAD_LEN (Len);
> -
> -  switch (ISCSI_GET_OPCODE (Header)) {
> -  case ISCSI_OPCODE_SCSI_DATA_IN:
> -    //
> -    // Try to use the buffer described by Context if the PDU is an
> -    // iSCSI SCSI data in pdu so as to reduce memory copy overhead.
> -    //
> -    InDataOffset = ISCSI_GET_BUFFER_OFFSET (Header);
> -    if ((Context == NULL) || ((InDataOffset + Len) > Context->InDataLen)) {
> -      Status = EFI_PROTOCOL_ERROR;
> -      goto ON_EXIT;
> -    }
> -
> -    Fragment[0].Len   = Len;
> -    Fragment[0].Bulk  = Context->InData + InDataOffset;
> -
> -    if (DataDigest || (PadLen != 0)) {
> -      //
> -      // The data segment is padded, use two fragments to receive it.
> -      // The first to receive the useful data. The second to receive the padding.
> -      //
> -      Fragment[1].Len   = PadLen + (DataDigest ? sizeof (UINT32) : 0);
> -      Fragment[1].Bulk  = (UINT8 *)PadAndCRC32 + (4 - PadLen);
> -      FragmentCount     = 2;
> -    } else {
> -      FragmentCount = 1;
> -    }
> -
> -    DataSeg = NetbufFromExt (&Fragment[0], FragmentCount, 0, 0,
> IScsiNbufExtFree, NULL);
> -    if (DataSeg == NULL) {
> -      Status = EFI_OUT_OF_RESOURCES;
> -      goto ON_EXIT;
> -    }
> -
> -    break;
> -
> -  case ISCSI_OPCODE_SCSI_RSP:
> -  case ISCSI_OPCODE_NOP_IN:
> -  case ISCSI_OPCODE_LOGIN_RSP:
> -  case ISCSI_OPCODE_TEXT_RSP:
> -  case ISCSI_OPCODE_ASYNC_MSG:
> -  case ISCSI_OPCODE_REJECT:
> -  case ISCSI_OPCODE_VENDOR_T0:
> -  case ISCSI_OPCODE_VENDOR_T1:
> -  case ISCSI_OPCODE_VENDOR_T2:
> -    //
> -    // Allocate buffer to receive the data segment.
> -    //
> -    Len += PadLen + (DataDigest ? sizeof (UINT32) : 0);
> -    DataSeg = NetbufAlloc (Len);
> -    if (DataSeg == NULL) {
> -      Status = EFI_OUT_OF_RESOURCES;
> -      goto ON_EXIT;
> -    }
> -
> -    NetbufAllocSpace (DataSeg, Len, NET_BUF_TAIL);
> -    break;
> -
> -  default:
> -    Status = EFI_PROTOCOL_ERROR;
> -    goto ON_EXIT;
> -  }
> -
> -  InsertTailList (NbufList, &DataSeg->List);
> -
> -  //
> -  // Receive the data segment with the data digest if any.
> -  //
> -  Status = Tcp4IoReceive (&Conn->Tcp4Io, DataSeg, FALSE, TimeoutEvent);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  if (DataDigest) {
> -    //
> -    // TODO: Check the data digest.
> -    //
> -    NetbufTrim (DataSeg, sizeof (UINT32), NET_BUF_TAIL);
> -  }
> -
> -  if (PadLen != 0) {
> -    //
> -    // Trim off the padding bytes in the data segment.
> -    //
> -    NetbufTrim (DataSeg, PadLen, NET_BUF_TAIL);
> -  }
> -
> -  //
> -  // Form the pdu from a list of pdu segments.
> -  //
> -  *Pdu = NetbufFromBufList (NbufList, 0, 0, IScsiFreeNbufList, NbufList);
> -  if (*Pdu == NULL) {
> -    Status = EFI_OUT_OF_RESOURCES;
> -  }
> -
> -ON_EXIT:
> -
> -  if (EFI_ERROR (Status)) {
> -    //
> -    // Free the Nbufs in this NbufList and the NbufList itself.
> -    //
> -    IScsiFreeNbufList (NbufList);
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Check and get the result of the prameter negotiation.
> -
> -  @param[in, out]  Conn          The connection in iSCSI login.
> -
> -  @retval EFI_SUCCESS          The parmeter check is passed and negotiation is
> finished.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -**/
> -EFI_STATUS
> -IScsiCheckOpParams (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  )
> -{
> -  EFI_STATUS      Status;
> -  LIST_ENTRY      *KeyValueList;
> -  CHAR8           *Data;
> -  UINT32          Len;
> -  ISCSI_SESSION   *Session;
> -  CHAR8           *Value;
> -  UINTN           NumericValue;
> -
> -  ASSERT (Conn->RspQue.BufNum != 0);
> -
> -  Session = Conn->Session;
> -
> -  Len     = Conn->RspQue.BufSize;
> -  Data    = AllocatePool (Len);
> -  if (Data == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *) Data);
> -
> -  Status = EFI_PROTOCOL_ERROR;
> -
> -  //
> -  // Extract the Key-Value pairs into a list.
> -  //
> -  KeyValueList = IScsiBuildKeyValueList (Data, Len);
> -  if (KeyValueList == NULL) {
> -    FreePool (Data);
> -    return Status;
> -  }
> -  //
> -  // HeaderDigest
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_HEADER_DIGEST);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  if (AsciiStrCmp (Value, "CRC32") == 0) {
> -    if (Conn->HeaderDigest != IScsiDigestCRC32) {
> -      goto ON_ERROR;
> -    }
> -  } else if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) == 0) {
> -    Conn->HeaderDigest = IScsiDigestNone;
> -  } else {
> -    goto ON_ERROR;
> -  }
> -  //
> -  // DataDigest
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_DIGEST);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  if (AsciiStrCmp (Value, "CRC32") == 0) {
> -    if (Conn->DataDigest != IScsiDigestCRC32) {
> -      goto ON_ERROR;
> -    }
> -  } else if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) == 0) {
> -    Conn->DataDigest = IScsiDigestNone;
> -  } else {
> -    goto ON_ERROR;
> -  }
> -  //
> -  // ErrorRecoveryLevel, result fuction is Minimum.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_ERROR_RECOVERY_LEVEL);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  NumericValue = AsciiStrDecimalToUintn (Value);
> -  if (NumericValue > 2) {
> -    goto ON_ERROR;
> -  }
> -
> -  Session->ErrorRecoveryLevel = (UINT8) MIN (Session->ErrorRecoveryLevel,
> NumericValue);
> -
> -  //
> -  // InitialR2T, result function is OR.
> -  //
> -  if (!Session->InitialR2T) {
> -    Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
> -    if (Value == NULL) {
> -      goto ON_ERROR;
> -    }
> -
> -    Session->InitialR2T = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
> -  }
> -
> -  //
> -  // ImmediateData, result function is AND.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_IMMEDIATE_DATA);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  Session->ImmediateData = (BOOLEAN) (Session->ImmediateData &&
> (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0));
> -
> -  //
> -  // MaxRecvDataSegmentLength is declarative.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH);
> -  if (Value != NULL) {
> -    Conn->MaxRecvDataSegmentLength = (UINT32) AsciiStrDecimalToUintn
> (Value);
> -  }
> -  //
> -  // MaxBurstLength, result funtion is Mininum.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_MAX_BURST_LENGTH);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  NumericValue            = AsciiStrDecimalToUintn (Value);
> -  Session->MaxBurstLength = (UINT32) MIN (Session->MaxBurstLength,
> NumericValue);
> -
> -  //
> -  // FirstBurstLength, result function is Minimum. Irrelevant when InitialR2T=Yes
> and
> -  // ImmediateData=No.
> -  // This Key/Value is negotiation type.
> -  //
> -  if (!(Session->InitialR2T && !Session->ImmediateData)) {
> -    Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_FIRST_BURST_LENGTH);
> -    if (Value == NULL) {
> -      goto ON_ERROR;
> -    }
> -
> -    NumericValue              = AsciiStrDecimalToUintn (Value);
> -    Session->FirstBurstLength = (UINT32) MIN (Session->FirstBurstLength,
> NumericValue);
> -  }
> -
> -  //
> -  // MaxConnections, result function is Minimum.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_MAX_CONNECTIONS);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  NumericValue = AsciiStrDecimalToUintn (Value);
> -  if ((NumericValue == 0) || (NumericValue > 65535)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Session->MaxConnections = (UINT32) MIN (Session->MaxConnections,
> NumericValue);
> -
> -  //
> -  // DataPDUInOrder, result function is OR.
> -  //
> -  if (!Session->DataPDUInOrder) {
> -    Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_DATA_PDU_IN_ORDER);
> -    if (Value == NULL) {
> -      goto ON_ERROR;
> -    }
> -
> -    Session->DataPDUInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
> -  }
> -
> -  //
> -  // DataSequenceInorder, result function is OR.
> -  //
> -  if (!Session->DataSequenceInOrder) {
> -    Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);
> -    if (Value == NULL) {
> -      goto ON_ERROR;
> -    }
> -
> -    Session->DataSequenceInOrder = (BOOLEAN) (AsciiStrCmp (Value, "Yes") ==
> 0);
> -  }
> -
> -  //
> -  // DefaultTime2Wait, result function is Maximum.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_DEFAULT_TIME2WAIT);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  NumericValue = AsciiStrDecimalToUintn (Value);
> -  if (NumericValue == 0) {
> -    Session->DefaultTime2Wait = 0;
> -  } else if (NumericValue > 3600) {
> -    goto ON_ERROR;
> -  } else {
> -    Session->DefaultTime2Wait = (UINT32) MAX (Session->DefaultTime2Wait,
> NumericValue);
> -  }
> -  //
> -  // DefaultTime2Retain, result function is Minimum.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_DEFAULT_TIME2RETAIN);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  NumericValue = AsciiStrDecimalToUintn (Value);
> -  if (NumericValue == 0) {
> -    Session->DefaultTime2Retain = 0;
> -  } else if (NumericValue > 3600) {
> -    goto ON_ERROR;
> -  } else {
> -    Session->DefaultTime2Retain = (UINT32) MIN (Session->DefaultTime2Retain,
> NumericValue);
> -  }
> -  //
> -  // MaxOutstandingR2T, result function is Minimum.
> -  //
> -  Value = IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_MAX_OUTSTANDING_R2T);
> -  if (Value == NULL) {
> -    goto ON_ERROR;
> -  }
> -
> -  NumericValue = AsciiStrDecimalToUintn (Value);
> -  if ((NumericValue == 0) || (NumericValue > 65535)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Session->MaxOutstandingR2T = (UINT16) MIN (Session->MaxOutstandingR2T,
> NumericValue);
> -
> -  //
> -  // Remove declarative key-value pairs, if any.
> -  //
> -  IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_SESSION_TYPE);
> -  IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_ALIAS);
> -  IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
> -  //
> -  // Remove the key-value that may not needed for result function is OR.
> -  //
> -  IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_INITIAL_R2T);
> -  IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_DATA_PDU_IN_ORDER);
> -  IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_DATA_SEQUENCE_IN_ORDER);
> -
> -  //
> -  // Remove irrelevant parameter, if any.
> -  //
> -  if (Session->InitialR2T && !Session->ImmediateData) {
> -    IScsiGetValueByKeyFromList (KeyValueList,
> ISCSI_KEY_FIRST_BURST_LENGTH);
> -  }
> -
> -  if (IsListEmpty (KeyValueList)) {
> -    //
> -    // Succeed if no more keys in the list.
> -    //
> -    Status = EFI_SUCCESS;
> -  }
> -
> -ON_ERROR:
> -
> -  IScsiFreeKeyValueList (KeyValueList);
> -
> -  FreePool (Data);
> -
> -  return Status;
> -}
> -
> -/**
> -  Fill the oprational prameters.
> -
> -  @param[in]       Conn        The connection in iSCSI login.
> -  @param[in, out]  Pdu         The iSCSI login request PDU to fill the parameters.
> -
> -  @retval EFI_SUCCESS          The parmeters are filled into the iSCSI login request
> PDU.
> -**/
> -EFI_STATUS
> -IScsiFillOpParams (
> -  IN ISCSI_CONNECTION  *Conn,
> -  IN OUT NET_BUF       *Pdu
> -  )
> -{
> -  ISCSI_SESSION *Session;
> -  CHAR8         Value[256];
> -
> -  Session = Conn->Session;
> -
> -  AsciiSPrint (Value, sizeof (Value), "%a", (Conn->HeaderDigest ==
> IScsiDigestCRC32) ? "None,CRC32" : "None");
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_HEADER_DIGEST, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%a", (Conn->DataDigest ==
> IScsiDigestCRC32) ? "None,CRC32" : "None");
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_DATA_DIGEST, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->ErrorRecoveryLevel);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_ERROR_RECOVERY_LEVEL, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%a", Session->InitialR2T ? "Yes" : "No");
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_INITIAL_R2T, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%a", Session->ImmediateData ? "Yes" :
> "No");
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_IMMEDIATE_DATA, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", MAX_RECV_DATA_SEG_LEN_IN_FFP);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH,
> Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->MaxBurstLength);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_BURST_LENGTH, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->FirstBurstLength);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_FIRST_BURST_LENGTH, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->MaxConnections);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_CONNECTIONS, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%a", Session->DataPDUInOrder ? "Yes" :
> "No");
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_DATA_PDU_IN_ORDER, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%a", Session->DataSequenceInOrder ?
> "Yes" : "No");
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_DATA_SEQUENCE_IN_ORDER, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->DefaultTime2Wait);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_DEFAULT_TIME2WAIT, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->DefaultTime2Retain);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_DEFAULT_TIME2RETAIN, Value);
> -
> -  AsciiSPrint (Value, sizeof (Value), "%d", Session->MaxOutstandingR2T);
> -  IScsiAddKeyValuePair (Pdu, ISCSI_KEY_MAX_OUTSTANDING_R2T, Value);
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
> -
> -  @param[in, out]  Pdu         The iSCSI pdu which contains segments to pad.
> -  @param[in]       Len         The length of the last semgnet in the PDU.
> -
> -  @retval EFI_SUCCESS          The segment is padded or no need to pad it.
> -  @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space
> to add the
> -                               padding bytes.
> -**/
> -EFI_STATUS
> -IScsiPadSegment (
> -  IN OUT NET_BUF  *Pdu,
> -  IN UINT32       Len
> -  )
> -{
> -  UINT32  PadLen;
> -  UINT8   *Data;
> -
> -  PadLen = ISCSI_GET_PAD_LEN (Len);
> -
> -  if (PadLen != 0) {
> -    Data = NetbufAllocSpace (Pdu, PadLen, NET_BUF_TAIL);
> -    if (Data == NULL) {
> -      return EFI_OUT_OF_RESOURCES;
> -    }
> -
> -    ZeroMem (Data, PadLen);
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Build a key-value list from the data segment.
> -
> -  @param[in]  Data The data segment containing the key-value pairs.
> -  @param[in]  Len  Length of the data segment.
> -
> -  @return The key-value list.
> -  @retval NULL Other errors as indicated.
> -**/
> -LIST_ENTRY *
> -IScsiBuildKeyValueList (
> -  IN CHAR8  *Data,
> -  IN UINT32 Len
> -  )
> -{
> -  LIST_ENTRY            *ListHead;
> -  ISCSI_KEY_VALUE_PAIR  *KeyValuePair;
> -
> -  ListHead = AllocatePool (sizeof (LIST_ENTRY));
> -  if (ListHead == NULL) {
> -    return NULL;
> -  }
> -
> -  InitializeListHead (ListHead);
> -
> -  while (Len > 0) {
> -    KeyValuePair = AllocatePool (sizeof (ISCSI_KEY_VALUE_PAIR));
> -    if (KeyValuePair == NULL) {
> -      goto ON_ERROR;
> -    }
> -
> -    InitializeListHead (&KeyValuePair->List);
> -
> -    KeyValuePair->Key = Data;
> -
> -    while ((Len > 0) && (*Data != '=')) {
> -      Len--;
> -      Data++;
> -    }
> -
> -    if (*Data == '=') {
> -      *Data = '\0';
> -
> -      Data++;
> -      Len--;
> -    } else {
> -      FreePool (KeyValuePair);
> -      goto ON_ERROR;
> -    }
> -
> -    KeyValuePair->Value = Data;
> -
> -    InsertTailList (ListHead, &KeyValuePair->List);;
> -
> -    Data += AsciiStrLen (KeyValuePair->Value) + 1;
> -    Len -= (UINT32) AsciiStrLen (KeyValuePair->Value) + 1;
> -  }
> -
> -  return ListHead;
> -
> -ON_ERROR:
> -
> -  IScsiFreeKeyValueList (ListHead);
> -
> -  return NULL;
> -}
> -
> -/**
> -  Get the value string by the key name from the key-value list. If found,
> -  the key-value entry will be removed from the list.
> -
> -  @param[in, out]  KeyValueList  The key-value list.
> -  @param[in]       Key           The key name to find.
> -
> -  @return The value string.
> -**/
> -CHAR8 *
> -IScsiGetValueByKeyFromList (
> -  IN OUT LIST_ENTRY  *KeyValueList,
> -  IN CHAR8           *Key
> -  )
> -{
> -  LIST_ENTRY            *Entry;
> -  ISCSI_KEY_VALUE_PAIR  *KeyValuePair;
> -  CHAR8                 *Value;
> -
> -  Value = NULL;
> -
> -  NET_LIST_FOR_EACH (Entry, KeyValueList) {
> -    KeyValuePair = NET_LIST_USER_STRUCT (Entry, ISCSI_KEY_VALUE_PAIR, List);
> -
> -    if (AsciiStrCmp (KeyValuePair->Key, Key) == 0) {
> -      Value = KeyValuePair->Value;
> -
> -      RemoveEntryList (&KeyValuePair->List);
> -      FreePool (KeyValuePair);
> -      break;
> -    }
> -  }
> -
> -  return Value;
> -}
> -
> -/**
> -  Free the key-value list.
> -
> -  @param[in]  KeyValueList The key-value list.
> -**/
> -VOID
> -IScsiFreeKeyValueList (
> -  IN LIST_ENTRY      *KeyValueList
> -  )
> -{
> -  LIST_ENTRY            *Entry;
> -  ISCSI_KEY_VALUE_PAIR  *KeyValuePair;
> -
> -  while (!IsListEmpty (KeyValueList)) {
> -    Entry         = NetListRemoveHead (KeyValueList);
> -    KeyValuePair  = NET_LIST_USER_STRUCT (Entry, ISCSI_KEY_VALUE_PAIR,
> List);
> -
> -    FreePool (KeyValuePair);
> -  }
> -
> -  FreePool (KeyValueList);
> -}
> -
> -/**
> -  Normalize the iSCSI name according to RFC.
> -
> -  @param[in, out]  Name       The iSCSI name.
> -  @param[in]       Len        length of the iSCSI name.
> -
> -  @retval EFI_SUCCESS        The iSCSI name is valid and normalized.
> -  @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the
> IQN format.
> -**/
> -EFI_STATUS
> -IScsiNormalizeName (
> -  IN OUT CHAR8  *Name,
> -  IN UINTN      Len
> -  )
> -{
> -  UINTN Index;
> -
> -  for (Index = 0; Index < Len; Index++) {
> -    if (NET_IS_UPPER_CASE_CHAR (Name[Index])) {
> -      //
> -      // Convert the upper-case characters to lower-case ones
> -      //
> -      Name[Index] = (CHAR8) (Name[Index] - 'A' + 'a');
> -    }
> -
> -    if (!NET_IS_LOWER_CASE_CHAR (Name[Index]) &&
> -        !NET_IS_DIGIT (Name[Index]) &&
> -        (Name[Index] != '-') &&
> -        (Name[Index] != '.') &&
> -        (Name[Index] != ':')
> -        ) {
> -      //
> -      // ASCII dash, dot, colon lower-case characters and digit characters
> -      // are allowed.
> -      //
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -  }
> -
> -  if ((Len < 4) || (CompareMem (Name, "iqn.", 4) != 0)) {
> -    //
> -    // Only IQN format is accepted now.
> -    //
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Create an iSCSI task control block.
> -
> -  @param[in]   Conn           The connection on which the task control block will
> be created.
> -  @param[out]  Tcb            The newly created task control block.
> -
> -  @retval EFI_SUCCESS          The task control block is created.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NOT_READY        The target can not accept new commands.
> -**/
> -EFI_STATUS
> -IScsiNewTcb (
> -  IN  ISCSI_CONNECTION  *Conn,
> -  OUT ISCSI_TCB         **Tcb
> -  )
> -{
> -  ISCSI_SESSION *Session;
> -  ISCSI_TCB     *NewTcb;
> -
> -  ASSERT (Tcb != NULL);
> -
> -  Session = Conn->Session;
> -
> -  if (ISCSI_SEQ_GT (Session->CmdSN, Session->MaxCmdSN)) {
> -    return EFI_NOT_READY;
> -  }
> -
> -  NewTcb = AllocateZeroPool (sizeof (ISCSI_TCB));
> -  if (NewTcb == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  InitializeListHead (&NewTcb->Link);
> -
> -  NewTcb->SoFarInOrder      = TRUE;
> -  NewTcb->InitiatorTaskTag  = Session->InitiatorTaskTag;
> -  NewTcb->CmdSN             = Session->CmdSN;
> -  NewTcb->Conn              = Conn;
> -
> -  InsertTailList (&Session->TcbList, &NewTcb->Link);
> -
> -  //
> -  // Advance the initiator task tag.
> -  //
> -  Session->InitiatorTaskTag++;
> -  Session->CmdSN++;
> -
> -  *Tcb = NewTcb;
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Delete the tcb from the connection and destroy it.
> -
> -  @param[in]  Tcb The tcb to delete.
> -**/
> -VOID
> -IScsiDelTcb (
> -  IN ISCSI_TCB  *Tcb
> -  )
> -{
> -  RemoveEntryList (&Tcb->Link);
> -
> -  FreePool (Tcb);
> -}
> -
> -
> -/**
> -  Create a data segment, pad it and calculate the CRC if needed.
> -
> -  @param[in]  Data       The data to fill into the data segment.
> -  @param[in]  Len        Length of the data.
> -  @param[in]  DataDigest Whether to calculate CRC for this data segment.
> -
> -  @return The net buffer wrapping the data segment.
> -**/
> -NET_BUF *
> -IScsiNewDataSegment (
> -  IN UINT8    *Data,
> -  IN UINT32   Len,
> -  IN BOOLEAN  DataDigest
> -  )
> -{
> -  NET_FRAGMENT  Fragment[2];
> -  UINT32        FragmentCount;
> -  UINT32        PadLen;
> -  NET_BUF       *DataSeg;
> -
> -  Fragment[0].Len   = Len;
> -  Fragment[0].Bulk  = Data;
> -
> -  PadLen            = ISCSI_GET_PAD_LEN (Len);
> -  if (PadLen != 0) {
> -    Fragment[1].Len   = PadLen;
> -    Fragment[1].Bulk  = (UINT8 *) &mDataSegPad;
> -
> -    FragmentCount     = 2;
> -  } else {
> -    FragmentCount = 1;
> -  }
> -
> -  DataSeg = NetbufFromExt (&Fragment[0], FragmentCount, 0, 0,
> IScsiNbufExtFree, NULL);
> -
> -  return DataSeg;
> -}
> -
> -/**
> -  Create a iSCSI SCSI command PDU to encapsulate the command issued
> -  by SCSI through the EXT SCSI PASS THRU Protocol.
> -
> -  @param[in]  Packet The EXT SCSI PASS THRU request packet containing the
> SCSI command.
> -  @param[in]  Lun    The LUN.
> -  @param[in]  Tcb    The tcb associated with this SCSI command.
> -
> -  @return The  created iSCSI SCSI command PDU.
> -  @retval NULL Other errors as indicated.
> -**/
> -NET_BUF *
> -IScsiNewScsiCmdPdu (
> -  IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
> -  IN UINT64                                     Lun,
> -  IN ISCSI_TCB                                  *Tcb
> -  )
> -{
> -  LIST_ENTRY                      *NbufList;
> -  NET_BUF                         *Pdu;
> -  NET_BUF                         *PduHeader;
> -  NET_BUF                         *DataSeg;
> -  SCSI_COMMAND                    *ScsiCmd;
> -  UINT8                           AHSLength;
> -  UINT32                          Length;
> -  ISCSI_ADDITIONAL_HEADER         *Header;
> -  ISCSI_BI_EXP_READ_DATA_LEN_AHS  *BiExpReadDataLenAHS;
> -  ISCSI_SESSION                   *Session;
> -  UINT32                          ImmediateDataLen;
> -
> -  AHSLength = 0;
> -
> -  if (Packet->DataDirection == DataBi) {
> -    //
> -    // Bi directional Read/Write command, the bidirectional expected
> -    // read data length AHS is required.
> -    //
> -    AHSLength += sizeof (ISCSI_BI_EXP_READ_DATA_LEN_AHS);
> -  }
> -
> -  if (Packet->CdbLength > 16) {
> -    //
> -    // The CDB exceeds 16 bytes, an extended CDB AHS is required.
> -    //
> -    AHSLength = (UINT8) (AHSLength + (ISCSI_ROUNDUP (Packet->CdbLength -
> 16) + sizeof (ISCSI_ADDITIONAL_HEADER)));
> -  }
> -
> -  Length    = sizeof (SCSI_COMMAND) + AHSLength;
> -  PduHeader = NetbufAlloc (Length);
> -  if (PduHeader == NULL) {
> -    return NULL;
> -  }
> -
> -  ScsiCmd = (SCSI_COMMAND *) NetbufAllocSpace (PduHeader, Length,
> NET_BUF_TAIL);
> -  if (ScsiCmd == NULL) {
> -    NetbufFree (PduHeader);
> -    return NULL;
> -  }
> -  Header  = (ISCSI_ADDITIONAL_HEADER *) (ScsiCmd + 1);
> -
> -  ZeroMem (ScsiCmd, Length);
> -
> -  ISCSI_SET_OPCODE (ScsiCmd, ISCSI_OPCODE_SCSI_CMD, 0);
> -  ISCSI_SET_FLAG (ScsiCmd, ISCSI_TASK_ATTR_SIMPLE);
> -
> -  //
> -  // Set the READ/WRITE flags according to the IO type of this request.
> -  //
> -  switch (Packet->DataDirection) {
> -  case DataIn:
> -    ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_READ);
> -    ScsiCmd->ExpDataXferLength = NTOHL (Packet->InTransferLength);
> -    break;
> -
> -  case DataOut:
> -    ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_WRITE);
> -    ScsiCmd->ExpDataXferLength = NTOHL (Packet->OutTransferLength);
> -    break;
> -
> -  case DataBi:
> -    ISCSI_SET_FLAG (ScsiCmd, SCSI_CMD_PDU_FLAG_READ |
> SCSI_CMD_PDU_FLAG_WRITE);
> -    ScsiCmd->ExpDataXferLength = NTOHL (Packet->OutTransferLength);
> -
> -    //
> -    // Fill the bidirectional expected read data length AHS.
> -    //
> -    BiExpReadDataLenAHS                     = (ISCSI_BI_EXP_READ_DATA_LEN_AHS *)
> Header;
> -    Header = (ISCSI_ADDITIONAL_HEADER *) (BiExpReadDataLenAHS + 1);
> -
> -    BiExpReadDataLenAHS->Length = NTOHS (5);
> -    BiExpReadDataLenAHS->Type = ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN;
> -    BiExpReadDataLenAHS->ExpReadDataLength = NTOHL (Packet-
> >InTransferLength);
> -
> -    break;
> -  }
> -
> -  ScsiCmd->TotalAHSLength = AHSLength;
> -  CopyMem (ScsiCmd->Lun, &Lun, sizeof (ScsiCmd->Lun));
> -  ScsiCmd->InitiatorTaskTag = NTOHL (Tcb->InitiatorTaskTag);
> -  ScsiCmd->CmdSN            = NTOHL (Tcb->CmdSN);
> -  ScsiCmd->ExpStatSN        = NTOHL (Tcb->Conn->ExpStatSN);
> -
> -  CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
> -
> -  if (Packet->CdbLength > 16) {
> -    Header->Length  = NTOHS ((UINT16) (Packet->CdbLength - 15));
> -    Header->Type    = ISCSI_AHS_TYPE_EXT_CDB;
> -
> -    CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16);
> -  }
> -
> -  Pdu               = PduHeader;
> -  Session           = Tcb->Conn->Session;
> -  ImmediateDataLen  = 0;
> -
> -  if (Session->ImmediateData && (Packet->OutTransferLength != 0)) {
> -    //
> -    // Send immediate data in this SCSI Command PDU. The length of the
> immeidate
> -    // data is the minimum of FirstBurstLength, the data length to be xfered and
> -    // the MaxRecvdataSegmentLength on this connection.
> -    //
> -    ImmediateDataLen  = MIN (Session->FirstBurstLength, Packet-
> >OutTransferLength);
> -    ImmediateDataLen  = MIN (ImmediateDataLen, Tcb->Conn-
> >MaxRecvDataSegmentLength);
> -
> -    //
> -    // Update the data segment length in the PDU header.
> -    //
> -    ISCSI_SET_DATASEG_LEN (ScsiCmd, ImmediateDataLen);
> -
> -    //
> -    // Create the data segment.
> -    //
> -    DataSeg = IScsiNewDataSegment ((UINT8 *) Packet->OutDataBuffer,
> ImmediateDataLen, FALSE);
> -    if (DataSeg == NULL) {
> -      NetbufFree (PduHeader);
> -      Pdu = NULL;
> -      goto ON_EXIT;
> -    }
> -
> -    NbufList = AllocatePool (sizeof (LIST_ENTRY));
> -    if (NbufList == NULL) {
> -      NetbufFree (PduHeader);
> -      NetbufFree (DataSeg);
> -
> -      Pdu = NULL;
> -      goto ON_EXIT;
> -    }
> -
> -    InitializeListHead (NbufList);
> -    InsertTailList (NbufList, &PduHeader->List);
> -    InsertTailList (NbufList, &DataSeg->List);
> -
> -    Pdu = NetbufFromBufList (NbufList, 0, 0, IScsiFreeNbufList, NbufList);
> -    if (Pdu == NULL) {
> -      IScsiFreeNbufList (NbufList);
> -    }
> -  }
> -
> -  if (Session->InitialR2T ||
> -      (ImmediateDataLen == Session->FirstBurstLength) ||
> -      (ImmediateDataLen == Packet->OutTransferLength)
> -      ) {
> -    //
> -    // Unsolicited data out sequence is not allowed,
> -    // or FirstBurstLength data is already sent out by immediate data
> -    // or all the OUT data accompany this SCSI packet is sent as
> -    // immediate data, the final flag should be set on this SCSI Command
> -    // PDU.
> -    //
> -    ISCSI_SET_FLAG (ScsiCmd, ISCSI_BHS_FLAG_FINAL);
> -  }
> -
> -ON_EXIT:
> -
> -  return Pdu;
> -}
> -
> -/**
> -  Create a new iSCSI SCSI Data Out PDU.
> -
> -  @param[in]  Data   The data to put into the Data Out PDU.
> -  @param[in]  Len    Length of the data.
> -  @param[in]  DataSN The DataSN of the Data Out PDU.
> -  @param[in]  Tcb    The task control block of this Data Out PDU.
> -  @param[in]  Lun    The LUN.
> -
> -  @return The net buffer wrapping the Data Out PDU.
> -  @retval NULL Other errors as indicated.
> -**/
> -NET_BUF *
> -IScsiNewDataOutPdu (
> -  IN UINT8      *Data,
> -  IN UINT32     Len,
> -  IN UINT32     DataSN,
> -  IN ISCSI_TCB  *Tcb,
> -  IN UINT64     Lun
> -  )
> -{
> -  LIST_ENTRY          *NbufList;
> -  NET_BUF             *PduHdr;
> -  NET_BUF             *DataSeg;
> -  NET_BUF             *Pdu;
> -  ISCSI_SCSI_DATA_OUT *DataOutHdr;
> -  ISCSI_XFER_CONTEXT  *XferContext;
> -
> -  NbufList = AllocatePool (sizeof (LIST_ENTRY));
> -  if (NbufList == NULL) {
> -    return NULL;
> -  }
> -
> -  InitializeListHead (NbufList);
> -
> -  //
> -  // Allocate memory for the BHS.
> -  //
> -  PduHdr = NetbufAlloc (sizeof (ISCSI_SCSI_DATA_OUT));
> -  if (PduHdr == NULL) {
> -    FreePool (NbufList);
> -    return NULL;
> -  }
> -  //
> -  // Insert the BHS into the buffer list.
> -  //
> -  InsertTailList (NbufList, &PduHdr->List);
> -
> -  DataOutHdr  = (ISCSI_SCSI_DATA_OUT *) NetbufAllocSpace (PduHdr, sizeof
> (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL);
> -  ASSERT (DataOutHdr != NULL);
> -  XferContext = &Tcb->XferContext;
> -
> -  ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
> -
> -  //
> -  // Set the flags and fields of the Data Out PDU BHS.
> -  //
> -  ISCSI_SET_OPCODE (DataOutHdr, ISCSI_OPCODE_SCSI_DATA_OUT, 0);
> -  ISCSI_SET_DATASEG_LEN (DataOutHdr, Len);
> -
> -  DataOutHdr->InitiatorTaskTag  = HTONL (Tcb->InitiatorTaskTag);
> -  DataOutHdr->TargetTransferTag = HTONL (XferContext->TargetTransferTag);
> -  DataOutHdr->ExpStatSN         = HTONL (Tcb->Conn->ExpStatSN);
> -  DataOutHdr->DataSN            = HTONL (DataSN);
> -  DataOutHdr->BufferOffset      = HTONL (XferContext->Offset);
> -
> -  if (XferContext->TargetTransferTag != ISCSI_RESERVED_TAG) {
> -    CopyMem (&DataOutHdr->Lun, &Lun, sizeof (DataOutHdr->Lun));
> -  }
> -  //
> -  // Build the data segment for this Data Out PDU.
> -  //
> -  DataSeg = IScsiNewDataSegment (Data, Len, FALSE);
> -  if (DataSeg == NULL) {
> -    IScsiFreeNbufList (NbufList);
> -    return NULL;
> -  }
> -  //
> -  // Put the data segment into the buffer list and combine it with the BHS
> -  // into a full Data Out PDU.
> -  //
> -  InsertTailList (NbufList, &DataSeg->List);
> -  Pdu = NetbufFromBufList (NbufList, 0, 0, IScsiFreeNbufList, NbufList);
> -  if (Pdu == NULL) {
> -    IScsiFreeNbufList (NbufList);
> -  }
> -
> -  return Pdu;
> -}
> -
> -/**
> -  Generate a consecutive sequence of iSCSI SCSI Data Out PDUs.
> -
> -  @param[in]  Data The data  which will be carried by the sequence of iSCSI SCSI
> Data Out PDUs.
> -  @param[in]  Tcb  The task control block of the data to send out.
> -  @param[in]  Lun  The LUN the data will be sent to.
> -
> -  @return A list of net buffers with each of them wraps an iSCSI SCSI Data Out
> PDU.
> -  @retval NULL Other errors as indicated.
> -**/
> -LIST_ENTRY *
> -IScsiGenerateDataOutPduSequence (
> -  IN UINT8      *Data,
> -  IN ISCSI_TCB  *Tcb,
> -  IN UINT64     Lun
> -  )
> -{
> -  LIST_ENTRY          *PduList;
> -  UINT32              DataSN;
> -  UINT32              DataLen;
> -  NET_BUF             *DataOutPdu;
> -  ISCSI_CONNECTION    *Conn;
> -  ISCSI_XFER_CONTEXT  *XferContext;
> -  UINT8               *DataOutPacket;
> -
> -  PduList = AllocatePool (sizeof (LIST_ENTRY));
> -  if (PduList == NULL) {
> -    return NULL;
> -  }
> -
> -  InitializeListHead (PduList);
> -
> -  DataSN      = 0;
> -  Conn        = Tcb->Conn;
> -  DataOutPdu  = NULL;
> -  XferContext = &Tcb->XferContext;
> -
> -  while (XferContext->DesiredLength > 0) {
> -    //
> -    // Determine the length of data this Data Out PDU can carry.
> -    //
> -    DataLen = MIN (XferContext->DesiredLength, Conn-
> >MaxRecvDataSegmentLength);
> -
> -    //
> -    // Create a Data Out PDU.
> -    //
> -    DataOutPdu = IScsiNewDataOutPdu (Data, DataLen, DataSN, Tcb, Lun);
> -    if (DataOutPdu == NULL) {
> -      IScsiFreeNbufList (PduList);
> -      PduList = NULL;
> -
> -      goto ON_EXIT;
> -    }
> -
> -    InsertTailList (PduList, &DataOutPdu->List);
> -
> -    //
> -    // Update the context and DataSN.
> -    //
> -    XferContext->Offset += DataLen;
> -    XferContext->DesiredLength -= DataLen;
> -    DataSN++;
> -    Data += DataLen;
> -  }
> -  //
> -  // Set the F bit for the last data out PDU in this sequence.
> -  //
> -  DataOutPacket = NetbufGetByte (DataOutPdu, 0, NULL);
> -  if (DataOutPacket == NULL) {
> -    IScsiFreeNbufList (PduList);
> -    PduList = NULL;
> -    goto ON_EXIT;
> -  }
> -
> -  ISCSI_SET_FLAG (DataOutPacket, ISCSI_BHS_FLAG_FINAL);
> -
> -ON_EXIT:
> -
> -  return PduList;
> -}
> -
> -/**
> -  Send the Data in a sequence of Data Out PDUs one by one.
> -
> -  @param[in]  Data            The data to carry by Data Out PDUs.
> -  @param[in]  Lun             The LUN the data will be sent to.
> -  @param[in]  Tcb             The task control block.
> -
> -  @retval EFI_SUCCES           The data is sent out to the LUN.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiSendDataOutPduSequence (
> -  IN UINT8      *Data,
> -  IN UINT64     Lun,
> -  IN ISCSI_TCB  *Tcb
> -  )
> -{
> -  LIST_ENTRY      *DataOutPduList;
> -  LIST_ENTRY      *Entry;
> -  NET_BUF         *Pdu;
> -  EFI_STATUS      Status;
> -
> -  //
> -  // Generate the Data Out PDU sequence.
> -  //
> -  DataOutPduList = IScsiGenerateDataOutPduSequence (Data, Tcb, Lun);
> -  if (DataOutPduList == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  Status = EFI_SUCCESS;
> -
> -  //
> -  // Send the Data Out PDU's one by one.
> -  //
> -  NET_LIST_FOR_EACH (Entry, DataOutPduList) {
> -    Pdu     = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
> -
> -    Status  = Tcp4IoTransmit (&Tcb->Conn->Tcp4Io, Pdu);
> -    if (EFI_ERROR (Status)) {
> -      break;
> -    }
> -  }
> -
> -  IScsiFreeNbufList (DataOutPduList);
> -
> -  return Status;
> -}
> -
> -/**
> -  Process the received iSCSI SCSI Data In PDU.
> -
> -  @param[in]        Pdu      The Data In PDU received.
> -  @param[in]        Tcb      The task control block.
> -  @param[in, out]   Packet   The EXT SCSI PASS THRU request packet.
> -
> -  @retval EFI_SUCCES           The check on the Data IN PDU is passed and some
> update
> -                               actions are taken.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol errror happened.
> -  @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the
> request.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiOnDataInRcvd (
> -  IN NET_BUF                                         *Pdu,
> -  IN ISCSI_TCB                                       *Tcb,
> -  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  *Packet
> -  )
> -{
> -  ISCSI_SCSI_DATA_IN  *DataInHdr;
> -  EFI_STATUS          Status;
> -
> -  DataInHdr                   = (ISCSI_SCSI_DATA_IN *) NetbufGetByte (Pdu, 0, NULL);
> -  if (DataInHdr == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  DataInHdr->InitiatorTaskTag = NTOHL (DataInHdr->InitiatorTaskTag);
> -  DataInHdr->ExpCmdSN         = NTOHL (DataInHdr->ExpCmdSN);
> -  DataInHdr->MaxCmdSN         = NTOHL (DataInHdr->MaxCmdSN);
> -  DataInHdr->DataSN           = NTOHL (DataInHdr->DataSN);
> -
> -  //
> -  // Check the DataSN.
> -  //
> -  Status = IScsiCheckSN (&Tcb->ExpDataSN, DataInHdr->DataSN);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  if (DataInHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  //
> -  // Update the command related sequence numbers.
> -  //
> -  IScsiUpdateCmdSN (Tcb->Conn->Session, DataInHdr->MaxCmdSN, DataInHdr-
> >ExpCmdSN);
> -
> -  if (ISCSI_FLAG_ON (DataInHdr, SCSI_DATA_IN_PDU_FLAG_STATUS_VALID)) {
> -    if (!ISCSI_FLAG_ON (DataInHdr, ISCSI_BHS_FLAG_FINAL)) {
> -      //
> -      // The S bit is on but the F bit is off.
> -      //
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -
> -    Tcb->StatusXferd = TRUE;
> -
> -    if (ISCSI_FLAG_ON (DataInHdr, SCSI_DATA_IN_PDU_FLAG_OVERFLOW |
> SCSI_DATA_IN_PDU_FLAG_UNDERFLOW)) {
> -      //
> -      // Underflow and Overflow are mutual flags.
> -      //
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -    //
> -    // S bit is on, the StatSN is valid.
> -    //
> -    Status = IScsiCheckSN (&Tcb->Conn->ExpStatSN, NTOHL (DataInHdr-
> >StatSN));
> -    if (EFI_ERROR (Status)) {
> -      return Status;
> -    }
> -
> -    Packet->HostAdapterStatus = 0;
> -    Packet->TargetStatus      = DataInHdr->Status;
> -
> -    if (ISCSI_FLAG_ON (DataInHdr, SCSI_RSP_PDU_FLAG_OVERFLOW)) {
> -      Packet->InTransferLength += NTOHL (DataInHdr->ResidualCount);
> -      Status = EFI_BAD_BUFFER_SIZE;
> -    }
> -
> -    if (ISCSI_FLAG_ON (DataInHdr, SCSI_RSP_PDU_FLAG_UNDERFLOW)) {
> -      Packet->InTransferLength -= NTOHL (DataInHdr->ResidualCount);
> -    }
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Process the received iSCSI R2T PDU.
> -
> -  @param[in]       Pdu       The R2T PDU received.
> -  @param[in]       Tcb       The task control block.
> -  @param[in]       Lun       The Lun.
> -  @param[in, out]  Packet    The EXT SCSI PASS THRU request packet.
> -
> -  @retval EFI_SUCCES         The R2T PDU is valid and the solicited data is sent out.
> -  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.
> -  @retval Others             Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiOnR2TRcvd (
> -  IN NET_BUF                                         *Pdu,
> -  IN ISCSI_TCB                                       *Tcb,
> -  IN UINT64                                          Lun,
> -  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  *Packet
> -  )
> -{
> -  ISCSI_READY_TO_TRANSFER *R2THdr;
> -  EFI_STATUS              Status;
> -  ISCSI_XFER_CONTEXT      *XferContext;
> -  UINT8                   *Data;
> -
> -  R2THdr = (ISCSI_READY_TO_TRANSFER *) NetbufGetByte (Pdu, 0, NULL);
> -  if (R2THdr == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  R2THdr->InitiatorTaskTag = NTOHL (R2THdr->InitiatorTaskTag);
> -  R2THdr->TargetTransferTag = NTOHL (R2THdr->TargetTransferTag);
> -  R2THdr->StatSN = NTOHL (R2THdr->StatSN);
> -  R2THdr->R2TSeqNum = NTOHL (R2THdr->R2TSeqNum);
> -  R2THdr->BufferOffset = NTOHL (R2THdr->BufferOffset);
> -  R2THdr->DesiredDataTransferLength = NTOHL (R2THdr-
> >DesiredDataTransferLength);
> -
> -  if ((R2THdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) || !ISCSI_SEQ_EQ
> (R2THdr->StatSN, Tcb->Conn->ExpStatSN)) {
> -    return EFI_PROTOCOL_ERROR;;
> -  }
> -  //
> -  // Check the sequence number.
> -  //
> -  Status = IScsiCheckSN (&Tcb->ExpDataSN, R2THdr->R2TSeqNum);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  XferContext                     = &Tcb->XferContext;
> -  XferContext->TargetTransferTag  = R2THdr->TargetTransferTag;
> -  XferContext->Offset             = R2THdr->BufferOffset;
> -  XferContext->DesiredLength      = R2THdr->DesiredDataTransferLength;
> -
> -  if (((XferContext->Offset + XferContext->DesiredLength) > Packet-
> >OutTransferLength) ||
> -      (XferContext->DesiredLength > Tcb->Conn->Session->MaxBurstLength)
> -      ) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -  //
> -  // Send the data solicited by this R2T.
> -  //
> -  Data    = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset;
> -  Status  = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
> -
> -  return Status;
> -}
> -
> -/**
> -  Process the received iSCSI SCSI Response PDU.
> -
> -  @param[in]       Pdu      The Response PDU received.
> -  @param[in]       Tcb      The task control block.
> -  @param[in, out]  Packet   The EXT SCSI PASS THRU request packet.
> -
> -  @retval EFI_SUCCES         The Response PDU is processed.
> -  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.
> -  @retval EFI_BAD_BUFFER_SIZEE The buffer was not the proper size for the
> request.
> -  @retval Others             Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiOnScsiRspRcvd (
> -  IN NET_BUF                                         *Pdu,
> -  IN ISCSI_TCB                                       *Tcb,
> -  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  *Packet
> -  )
> -{
> -  SCSI_RESPONSE     *ScsiRspHdr;
> -  ISCSI_SENSE_DATA  *SenseData;
> -  EFI_STATUS        Status;
> -  UINT32            DataSegLen;
> -
> -  ScsiRspHdr                    = (SCSI_RESPONSE *) NetbufGetByte (Pdu, 0, NULL);
> -  if (ScsiRspHdr == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  ScsiRspHdr->InitiatorTaskTag  = NTOHL (ScsiRspHdr->InitiatorTaskTag);
> -  if (ScsiRspHdr->InitiatorTaskTag != Tcb->InitiatorTaskTag) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  ScsiRspHdr->StatSN  = NTOHL (ScsiRspHdr->StatSN);
> -
> -  Status              = IScsiCheckSN (&Tcb->Conn->ExpStatSN, ScsiRspHdr->StatSN);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  ScsiRspHdr->MaxCmdSN  = NTOHL (ScsiRspHdr->MaxCmdSN);
> -  ScsiRspHdr->ExpCmdSN  = NTOHL (ScsiRspHdr->ExpCmdSN);
> -  IScsiUpdateCmdSN (Tcb->Conn->Session, ScsiRspHdr->MaxCmdSN,
> ScsiRspHdr->ExpCmdSN);
> -
> -  Tcb->StatusXferd          = TRUE;
> -
> -  Packet->HostAdapterStatus = ScsiRspHdr->Response;
> -  if (Packet->HostAdapterStatus !=
> ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET) {
> -    return EFI_SUCCESS;
> -  }
> -
> -  Packet->TargetStatus = ScsiRspHdr->Status;
> -
> -  if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW |
> SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW) ||
> -      ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_OVERFLOW |
> SCSI_RSP_PDU_FLAG_UNDERFLOW)
> -        ) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW)) {
> -    Packet->InTransferLength += NTOHL (ScsiRspHdr->BiReadResidualCount);
> -    Status = EFI_BAD_BUFFER_SIZE;
> -  }
> -
> -  if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW))
> {
> -    Packet->InTransferLength -= NTOHL (ScsiRspHdr->BiReadResidualCount);
> -  }
> -
> -  if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_OVERFLOW)) {
> -    if (Packet->DataDirection == DataIn) {
> -      Packet->InTransferLength += NTOHL (ScsiRspHdr->ResidualCount);
> -    } else {
> -      Packet->OutTransferLength += NTOHL (ScsiRspHdr->ResidualCount);
> -    }
> -
> -    Status = EFI_BAD_BUFFER_SIZE;
> -  }
> -
> -  if (ISCSI_FLAG_ON (ScsiRspHdr, SCSI_RSP_PDU_FLAG_UNDERFLOW)) {
> -    if (Packet->DataDirection == DataIn) {
> -      Packet->InTransferLength -= NTOHL (ScsiRspHdr->ResidualCount);
> -    } else {
> -      Packet->OutTransferLength -= NTOHL (ScsiRspHdr->ResidualCount);
> -    }
> -  }
> -
> -  DataSegLen = ISCSI_GET_DATASEG_LEN (ScsiRspHdr);
> -  if (DataSegLen != 0) {
> -    SenseData               = (ISCSI_SENSE_DATA *) NetbufGetByte (Pdu, sizeof
> (SCSI_RESPONSE), NULL);
> -    if (SenseData == NULL) {
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -
> -    SenseData->Length       = NTOHS (SenseData->Length);
> -
> -    Packet->SenseDataLength = (UINT8) MIN (SenseData->Length, Packet-
> >SenseDataLength);
> -    if (Packet->SenseDataLength != 0) {
> -      CopyMem (Packet->SenseData, &SenseData->Data[0], Packet-
> >SenseDataLength);
> -    }
> -  } else {
> -    Packet->SenseDataLength = 0;
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Process the received NOP In PDU.
> -
> -  @param[in]  Pdu            The NOP In PDU received.
> -  @param[in]  Tcb            The task control block.
> -
> -  @retval EFI_SUCCES         The NOP In PDU is processed and the related
> sequence
> -                             numbers are updated.
> -  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol errror happened.
> -**/
> -EFI_STATUS
> -IScsiOnNopInRcvd (
> -  IN NET_BUF    *Pdu,
> -  IN ISCSI_TCB  *Tcb
> -  )
> -{
> -  ISCSI_NOP_IN  *NopInHdr;
> -  EFI_STATUS    Status;
> -
> -  NopInHdr            = (ISCSI_NOP_IN *) NetbufGetByte (Pdu, 0, NULL);
> -  if (NopInHdr == NULL) {
> -    return EFI_PROTOCOL_ERROR;
> -  }
> -
> -  NopInHdr->StatSN    = NTOHL (NopInHdr->StatSN);
> -  NopInHdr->ExpCmdSN  = NTOHL (NopInHdr->ExpCmdSN);
> -  NopInHdr->MaxCmdSN  = NTOHL (NopInHdr->MaxCmdSN);
> -
> -  if (NopInHdr->InitiatorTaskTag == ISCSI_RESERVED_TAG) {
> -    if (NopInHdr->StatSN != Tcb->Conn->ExpStatSN) {
> -      return EFI_PROTOCOL_ERROR;
> -    }
> -  } else {
> -    Status = IScsiCheckSN (&Tcb->Conn->ExpStatSN, NopInHdr->StatSN);
> -    if (EFI_ERROR (Status)) {
> -      return Status;
> -    }
> -  }
> -
> -  IScsiUpdateCmdSN (Tcb->Conn->Session, NopInHdr->MaxCmdSN, NopInHdr-
> >ExpCmdSN);
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
> -
> -  @param[in]       PassThru  The EXT SCSI PASS THRU protocol.
> -  @param[in]       Target    The target ID.
> -  @param[in]       Lun       The LUN.
> -  @param[in, out]  Packet    The request packet containing IO request, SCSI
> command
> -                             buffer and buffers to read/write.
> -
> -  @retval EFI_SUCCES           The SCSI command is executed and the result is
> updated to
> -                               the Packet.
> -  @retval EFI_DEVICE_ERROR     Session state was not as required.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NOT_READY        The target can not accept new commands.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiExecuteScsiCommand (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                 *PassThru,
> -  IN UINT8                                           *Target,
> -  IN UINT64                                          Lun,
> -  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  *Packet
> -  )
> -{
> -  EFI_STATUS              Status;
> -  ISCSI_DRIVER_DATA       *Private;
> -  ISCSI_SESSION           *Session;
> -  EFI_EVENT               TimeoutEvent;
> -  ISCSI_CONNECTION        *Conn;
> -  ISCSI_TCB               *Tcb;
> -  NET_BUF                 *Pdu;
> -  ISCSI_XFER_CONTEXT      *XferContext;
> -  UINT8                   *Data;
> -  ISCSI_IN_BUFFER_CONTEXT InBufferContext;
> -  UINT64                  Timeout;
> -  UINT8                   *PduHdr;
> -
> -  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
> -  Session       = &Private->Session;
> -  Status        = EFI_SUCCESS;
> -  Tcb           = NULL;
> -  TimeoutEvent  = NULL;
> -  Timeout       = 0;
> -
> -  if (Session->State != SESSION_STATE_LOGGED_IN) {
> -    Status = EFI_DEVICE_ERROR;
> -    goto ON_EXIT;
> -  }
> -
> -  Conn = NET_LIST_USER_STRUCT_S (
> -          Session->Conns.ForwardLink,
> -          ISCSI_CONNECTION,
> -          Link,
> -          ISCSI_CONNECTION_SIGNATURE
> -          );
> -
> -  if (Packet->Timeout != 0) {
> -    Timeout = MultU64x32 (Packet->Timeout, 2);
> -  }
> -
> -  Status = IScsiNewTcb (Conn, &Tcb);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -  //
> -  // Encapsulate the SCSI request packet into an iSCSI SCSI Command PDU.
> -  //
> -  Pdu = IScsiNewScsiCmdPdu (Packet, Lun, Tcb);
> -  if (Pdu == NULL) {
> -    Status = EFI_OUT_OF_RESOURCES;
> -    goto ON_EXIT;
> -  }
> -
> -  XferContext         = &Tcb->XferContext;
> -  PduHdr              = NetbufGetByte (Pdu, 0, NULL);
> -  if (PduHdr == NULL) {
> -    Status = EFI_PROTOCOL_ERROR;
> -    NetbufFree (Pdu);
> -    goto ON_EXIT;
> -  }
> -  XferContext->Offset = ISCSI_GET_DATASEG_LEN (PduHdr);
> -
> -  //
> -  // Transmit the SCSI Command PDU.
> -  //
> -  Status = Tcp4IoTransmit (&Conn->Tcp4Io, Pdu);
> -
> -  NetbufFree (Pdu);
> -
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  if (!Session->InitialR2T &&
> -      (XferContext->Offset < Session->FirstBurstLength) &&
> -      (XferContext->Offset < Packet->OutTransferLength)
> -      ) {
> -    //
> -    // Unsolicited Data-Out sequence is allowed, there is remaining SCSI
> -    // OUT data and the limit of FirstBurstLength is not reached.
> -    //
> -    XferContext->TargetTransferTag = ISCSI_RESERVED_TAG;
> -    XferContext->DesiredLength = MIN (
> -                                  Session->FirstBurstLength,
> -                                  Packet->OutTransferLength - XferContext->Offset
> -                                  );
> -
> -    Data    = (UINT8 *) Packet->OutDataBuffer + XferContext->Offset;
> -    Status  = IScsiSendDataOutPduSequence (Data, Lun, Tcb);
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -  }
> -
> -  InBufferContext.InData    = (UINT8 *) Packet->InDataBuffer;
> -  InBufferContext.InDataLen = Packet->InTransferLength;
> -
> -  while (!Tcb->StatusXferd) {
> -    //
> -    // Start the timeout timer.
> -    //
> -    if (Timeout != 0) {
> -      Status = gBS->SetTimer (Conn->TimeoutEvent, TimerRelative, Timeout);
> -      if (EFI_ERROR (Status)) {
> -        goto ON_EXIT;
> -      }
> -      TimeoutEvent = Conn->TimeoutEvent;
> -    }
> -    //
> -    // try to receive PDU from target.
> -    //
> -    Status = IScsiReceivePdu (Conn, &Pdu, &InBufferContext, FALSE, FALSE,
> TimeoutEvent);
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -
> -    PduHdr = NetbufGetByte (Pdu, 0, NULL);
> -    if (PduHdr == NULL) {
> -      Status = EFI_PROTOCOL_ERROR;
> -      NetbufFree (Pdu);
> -      goto ON_EXIT;
> -    }
> -    switch (ISCSI_GET_OPCODE (PduHdr)) {
> -    case ISCSI_OPCODE_SCSI_DATA_IN:
> -      Status = IScsiOnDataInRcvd (Pdu, Tcb, Packet);
> -      break;
> -
> -    case ISCSI_OPCODE_R2T:
> -      Status = IScsiOnR2TRcvd (Pdu, Tcb, Lun, Packet);
> -      break;
> -
> -    case ISCSI_OPCODE_SCSI_RSP:
> -      Status = IScsiOnScsiRspRcvd (Pdu, Tcb, Packet);
> -      break;
> -
> -    case ISCSI_OPCODE_NOP_IN:
> -      Status = IScsiOnNopInRcvd (Pdu, Tcb);
> -      break;
> -
> -    case ISCSI_OPCODE_VENDOR_T0:
> -    case ISCSI_OPCODE_VENDOR_T1:
> -    case ISCSI_OPCODE_VENDOR_T2:
> -      //
> -      // These messages are vendor specific, skip them.
> -      //
> -      break;
> -
> -    default:
> -      Status = EFI_PROTOCOL_ERROR;
> -      break;
> -    }
> -
> -    NetbufFree (Pdu);
> -
> -    if (EFI_ERROR (Status)) {
> -      break;
> -    }
> -  }
> -
> -ON_EXIT:
> -
> -  if (TimeoutEvent != NULL) {
> -    gBS->SetTimer (TimeoutEvent, TimerCancel, 0);
> -  }
> -
> -  if (Tcb != NULL) {
> -    IScsiDelTcb (Tcb);
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Reinstate the session on some error.
> -
> -  @param[in, out]  Private The iSCSI driver data.
> -
> -  @retval EFI_SUCCES  The session is reinstated from some error.
> -  @retval Other       Reinstatement failed.
> -**/
> -EFI_STATUS
> -IScsiSessionReinstatement (
> -  IN OUT ISCSI_DRIVER_DATA  *Private
> -  )
> -{
> -  ISCSI_SESSION *Session;
> -  EFI_STATUS    Status;
> -
> -  Session = &Private->Session;
> -  ASSERT (Session->State != SESSION_STATE_FREE);
> -
> -  //
> -  // Abort the session and re-init it.
> -  //
> -  IScsiSessionAbort (Session);
> -  IScsiSessionInit (Session, TRUE);
> -
> -  //
> -  // Login again.
> -  //
> -  Status = IScsiSessionLogin (Private);
> -
> -  return Status;
> -}
> -
> -/**
> -  Initialize some session parameters before login.
> -
> -  @param[in, out]  Session  The iSCSI session.
> -  @param[in]       Recovery Whether the request is from a fresh new start or
> recovery.
> -**/
> -VOID
> -IScsiSessionInit (
> -  IN OUT ISCSI_SESSION  *Session,
> -  IN BOOLEAN            Recovery
> -  )
> -{
> -  if (!Recovery) {
> -    Session->Signature  = ISCSI_SESSION_SIGNATURE;
> -    Session->State      = SESSION_STATE_FREE;
> -
> -    InitializeListHead (&Session->Conns);
> -    InitializeListHead (&Session->TcbList);
> -  }
> -
> -  Session->Tsih                 = 0;
> -
> -  Session->CmdSN                = 1;
> -  Session->InitiatorTaskTag     = 1;
> -  Session->NextCid              = 1;
> -
> -  Session->TargetPortalGroupTag = 0;
> -  Session->MaxConnections       = ISCSI_MAX_CONNS_PER_SESSION;
> -  Session->InitialR2T           = FALSE;
> -  Session->ImmediateData        = TRUE;
> -  Session->MaxBurstLength       = 262144;
> -  Session->FirstBurstLength     = MAX_RECV_DATA_SEG_LEN_IN_FFP;
> -  Session->DefaultTime2Wait     = 2;
> -  Session->DefaultTime2Retain   = 20;
> -  Session->MaxOutstandingR2T    = DEFAULT_MAX_OUTSTANDING_R2T;
> -  Session->DataPDUInOrder       = TRUE;
> -  Session->DataSequenceInOrder  = TRUE;
> -  Session->ErrorRecoveryLevel   = 0;
> -}
> -
> -/**
> -  Abort the iSCSI session, that is, reset all the connection and free the
> -  resources.
> -
> -  @param[in, out]  Session The iSCSI session.
> -
> -  @retval EFI_SUCCES  The session is aborted.
> -**/
> -EFI_STATUS
> -IScsiSessionAbort (
> -  IN OUT ISCSI_SESSION  *Session
> -  )
> -{
> -  ISCSI_DRIVER_DATA *Private;
> -  ISCSI_CONNECTION  *Conn;
> -
> -  if (Session->State != SESSION_STATE_LOGGED_IN) {
> -    return EFI_SUCCESS;
> -  }
> -
> -  ASSERT (!IsListEmpty (&Session->Conns));
> -
> -  Private = ISCSI_DRIVER_DATA_FROM_SESSION (Session);
> -
> -  while (!IsListEmpty (&Session->Conns)) {
> -    Conn = NET_LIST_USER_STRUCT_S (
> -            Session->Conns.ForwardLink,
> -            ISCSI_CONNECTION,
> -            Link,
> -            ISCSI_CONNECTION_SIGNATURE
> -            );
> -
> -    gBS->CloseProtocol (
> -          Conn->Tcp4Io.Handle,
> -          &gEfiTcp4ProtocolGuid,
> -          Private->Image,
> -          Private->ExtScsiPassThruHandle
> -          );
> -
> -    IScsiConnReset (Conn);
> -
> -    IScsiDetatchConnection (Conn);
> -    IScsiDestroyConnection (Conn);
> -  }
> -
> -  Session->State = SESSION_STATE_FAILED;
> -
> -  return EFI_SUCCESS;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.c
> deleted file mode 100644
> index 901b38e92fc0..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.c
> +++ /dev/null
> @@ -1,487 +0,0 @@
> -/** @file
> -  The wrap of TCP/IP Socket interface.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "IScsiImpl.h"
> -
> -/**
> -  The common notify function associated with various Tcp4Io events.
> -
> -  @param[in]  Event   The event signaled.
> -  @param[in]  Context The context.
> -**/
> -VOID
> -EFIAPI
> -Tcp4IoCommonNotify (
> -  IN EFI_EVENT  Event,
> -  IN VOID       *Context
> -  )
> -{
> -  *((BOOLEAN *) Context) = TRUE;
> -}
> -
> -/**
> -  Create a TCP socket with the specified configuration data.
> -
> -  @param[in]  Image      The handle of the driver image.
> -  @param[in]  Controller The handle of the controller.
> -  @param[in]  ConfigData The Tcp4 configuration data.
> -  @param[in]  Tcp4Io     The Tcp4Io.
> -
> -  @retval EFI_SUCCESS    The TCP socket is created and configured.
> -  @retval Others         Failed to create the TCP socket or configure it.
> -**/
> -EFI_STATUS
> -Tcp4IoCreateSocket (
> -  IN EFI_HANDLE           Image,
> -  IN EFI_HANDLE           Controller,
> -  IN TCP4_IO_CONFIG_DATA  *ConfigData,
> -  IN TCP4_IO              *Tcp4Io
> -  )
> -{
> -  EFI_STATUS            Status;
> -  EFI_TCP4_PROTOCOL     *Tcp4;
> -  EFI_TCP4_CONFIG_DATA  Tcp4ConfigData;
> -  EFI_TCP4_OPTION       ControlOption;
> -  EFI_TCP4_ACCESS_POINT *AccessPoint;
> -
> -  Tcp4Io->Handle = NULL;
> -  Tcp4Io->ConnToken.CompletionToken.Event = NULL;
> -  Tcp4Io->TxToken.CompletionToken.Event = NULL;
> -  Tcp4Io->RxToken.CompletionToken.Event = NULL;
> -  Tcp4Io->CloseToken.CompletionToken.Event = NULL;
> -  Tcp4 = NULL;
> -
> -  //
> -  // Create the TCP4 child instance and get the TCP4 protocol.
> -  //
> -  Status = NetLibCreateServiceChild (
> -            Controller,
> -            Image,
> -            &gEfiTcp4ServiceBindingProtocolGuid,
> -            &Tcp4Io->Handle
> -            );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  Status = gBS->OpenProtocol (
> -                  Tcp4Io->Handle,
> -                  &gEfiTcp4ProtocolGuid,
> -                  (VOID **)&Tcp4Io->Tcp4,
> -                  Image,
> -                  Controller,
> -                  EFI_OPEN_PROTOCOL_BY_DRIVER
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Tcp4Io->Image       = Image;
> -  Tcp4Io->Controller  = Controller;
> -  Tcp4                = Tcp4Io->Tcp4;
> -
> -  //
> -  // Set the configuration parameters.
> -  //
> -  ControlOption.ReceiveBufferSize       = 0x200000;
> -  ControlOption.SendBufferSize          = 0x200000;
> -  ControlOption.MaxSynBackLog           = 0;
> -  ControlOption.ConnectionTimeout       = 0;
> -  ControlOption.DataRetries             = 6;
> -  ControlOption.FinTimeout              = 0;
> -  ControlOption.TimeWaitTimeout         = 0;
> -  ControlOption.KeepAliveProbes         = 4;
> -  ControlOption.KeepAliveTime           = 0;
> -  ControlOption.KeepAliveInterval       = 0;
> -  ControlOption.EnableNagle             = FALSE;
> -  ControlOption.EnableTimeStamp         = FALSE;
> -  ControlOption.EnableWindowScaling     = TRUE;
> -  ControlOption.EnableSelectiveAck      = FALSE;
> -  ControlOption.EnablePathMtuDiscovery  = FALSE;
> -
> -  Tcp4ConfigData.TypeOfService          = 8;
> -  Tcp4ConfigData.TimeToLive             = 255;
> -  Tcp4ConfigData.ControlOption          = &ControlOption;
> -
> -  AccessPoint = &Tcp4ConfigData.AccessPoint;
> -
> -  AccessPoint->UseDefaultAddress = FALSE;
> -  AccessPoint->StationPort = 0;
> -  AccessPoint->RemotePort = ConfigData->RemotePort;
> -  AccessPoint->ActiveFlag = TRUE;
> -
> -  CopyMem (&AccessPoint->StationAddress, &ConfigData->LocalIp, sizeof
> (EFI_IPv4_ADDRESS));
> -  CopyMem (&AccessPoint->SubnetMask, &ConfigData->SubnetMask, sizeof
> (EFI_IPv4_ADDRESS));
> -  CopyMem (&AccessPoint->RemoteAddress, &ConfigData->RemoteIp, sizeof
> (EFI_IPv4_ADDRESS));
> -
> -  //
> -  // Configure the TCP4 protocol.
> -  //
> -  Status = Tcp4->Configure (Tcp4, &Tcp4ConfigData);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  if (!EFI_IP4_EQUAL (&ConfigData->Gateway, &mZeroIp4Addr)) {
> -    //
> -    // the gateway is not zero, add the default route by hand
> -    //
> -    Status = Tcp4->Routes (Tcp4, FALSE, &mZeroIp4Addr, &mZeroIp4Addr,
> &ConfigData->Gateway);
> -    if (EFI_ERROR (Status)) {
> -      goto ON_ERROR;
> -    }
> -  }
> -  //
> -  // Create events for variuos asynchronous operations.
> -  //
> -  Status = gBS->CreateEvent (
> -                  EVT_NOTIFY_SIGNAL,
> -                  TPL_NOTIFY,
> -                  Tcp4IoCommonNotify,
> -                  &Tcp4Io->IsConnDone,
> -                  &Tcp4Io->ConnToken.CompletionToken.Event
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Status = gBS->CreateEvent (
> -                  EVT_NOTIFY_SIGNAL,
> -                  TPL_NOTIFY,
> -                  Tcp4IoCommonNotify,
> -                  &Tcp4Io->IsTxDone,
> -                  &Tcp4Io->TxToken.CompletionToken.Event
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Status = gBS->CreateEvent (
> -                  EVT_NOTIFY_SIGNAL,
> -                  TPL_NOTIFY,
> -                  Tcp4IoCommonNotify,
> -                  &Tcp4Io->IsRxDone,
> -                  &Tcp4Io->RxToken.CompletionToken.Event
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Status = gBS->CreateEvent (
> -                  EVT_NOTIFY_SIGNAL,
> -                  TPL_NOTIFY,
> -                  Tcp4IoCommonNotify,
> -                  &Tcp4Io->IsCloseDone,
> -                  &Tcp4Io->CloseToken.CompletionToken.Event
> -                  );
> -  if (EFI_ERROR (Status)) {
> -    goto ON_ERROR;
> -  }
> -
> -  Tcp4Io->IsTxDone  = FALSE;
> -  Tcp4Io->IsRxDone  = FALSE;
> -
> -  return EFI_SUCCESS;
> -
> -ON_ERROR:
> -
> -  if (Tcp4Io->RxToken.CompletionToken.Event != NULL) {
> -    gBS->CloseEvent (Tcp4Io->RxToken.CompletionToken.Event);
> -  }
> -
> -  if (Tcp4Io->TxToken.CompletionToken.Event != NULL) {
> -    gBS->CloseEvent (Tcp4Io->TxToken.CompletionToken.Event);
> -  }
> -
> -  if (Tcp4Io->ConnToken.CompletionToken.Event != NULL) {
> -    gBS->CloseEvent (Tcp4Io->ConnToken.CompletionToken.Event);
> -  }
> -
> -  if (Tcp4 != NULL) {
> -    Tcp4->Configure (Tcp4, NULL);
> -
> -    gBS->CloseProtocol (
> -          Tcp4Io->Handle,
> -          &gEfiTcp4ProtocolGuid,
> -          Image,
> -          Controller
> -          );
> -  }
> -
> -  NetLibDestroyServiceChild (
> -    Controller,
> -    Image,
> -    &gEfiTcp4ServiceBindingProtocolGuid,
> -    Tcp4Io->Handle
> -    );
> -
> -  return Status;
> -}
> -
> -/**
> -  Destroy the socket.
> -
> -  @param[in]  Tcp4Io The Tcp4Io which wraps the socket to be destroyeds.
> -**/
> -VOID
> -Tcp4IoDestroySocket (
> -  IN TCP4_IO  *Tcp4Io
> -  )
> -{
> -  EFI_TCP4_PROTOCOL *Tcp4;
> -
> -  Tcp4 = Tcp4Io->Tcp4;
> -
> -  Tcp4->Configure (Tcp4, NULL);
> -
> -  gBS->CloseEvent (Tcp4Io->TxToken.CompletionToken.Event);
> -  gBS->CloseEvent (Tcp4Io->RxToken.CompletionToken.Event);
> -  gBS->CloseEvent (Tcp4Io->ConnToken.CompletionToken.Event);
> -
> -  gBS->CloseProtocol (
> -        Tcp4Io->Handle,
> -        &gEfiTcp4ProtocolGuid,
> -        Tcp4Io->Image,
> -        Tcp4Io->Controller
> -        );
> -
> -  NetLibDestroyServiceChild (
> -    Tcp4Io->Controller,
> -    Tcp4Io->Image,
> -    &gEfiTcp4ServiceBindingProtocolGuid,
> -    Tcp4Io->Handle
> -    );
> -}
> -
> -/**
> -  Connect to the other endpoint of the TCP socket.
> -
> -  @param[in, out]  Tcp4Io    The Tcp4Io wrapping the TCP socket.
> -  @param[in]       Timeout   The time to wait for connection done.
> -
> -  @retval EFI_SUCCESS          Connect to the other endpoint of the TCP socket
> successfully.
> -  @retval EFI_TIMEOUT          Failed to connect to the other endpoint of the TCP
> socket in the                               specified time period.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -Tcp4IoConnect (
> -  IN OUT TCP4_IO    *Tcp4Io,
> -  IN EFI_EVENT      Timeout
> -  )
> -{
> -  EFI_TCP4_PROTOCOL *Tcp4;
> -  EFI_STATUS        Status;
> -
> -  Tcp4Io->IsConnDone  = FALSE;
> -  Tcp4                = Tcp4Io->Tcp4;
> -  Status              = Tcp4->Connect (Tcp4, &Tcp4Io->ConnToken);
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  while (!Tcp4Io->IsConnDone && EFI_ERROR (gBS->CheckEvent (Timeout))) {
> -    Tcp4->Poll (Tcp4);
> -  }
> -
> -  if (!Tcp4Io->IsConnDone) {
> -    Status = EFI_TIMEOUT;
> -  } else {
> -    Status = Tcp4Io->ConnToken.CompletionToken.Status;
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Reset the socket.
> -
> -  @param[in, out]  Tcp4Io The Tcp4Io wrapping the TCP socket.
> -**/
> -VOID
> -Tcp4IoReset (
> -  IN OUT TCP4_IO  *Tcp4Io
> -  )
> -{
> -  EFI_STATUS        Status;
> -  EFI_TCP4_PROTOCOL *Tcp4;
> -
> -  Tcp4Io->CloseToken.AbortOnClose = TRUE;
> -  Tcp4Io->IsCloseDone             = FALSE;
> -
> -  Tcp4 = Tcp4Io->Tcp4;
> -  Status = Tcp4->Close (Tcp4, &Tcp4Io->CloseToken);
> -  if (EFI_ERROR (Status)) {
> -    return ;
> -  }
> -
> -  while (!Tcp4Io->IsCloseDone) {
> -    Tcp4->Poll (Tcp4);
> -  }
> -}
> -
> -/**
> -  Transmit the Packet to the other endpoint of the socket.
> -
> -  @param[in]   Tcp4Io          The Tcp4Io wrapping the TCP socket.
> -  @param[in]   Packet          The packet to transmit.
> -
> -  @retval EFI_SUCCESS          The packet is trasmitted.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -Tcp4IoTransmit (
> -  IN TCP4_IO  *Tcp4Io,
> -  IN NET_BUF  *Packet
> -  )
> -{
> -  EFI_TCP4_TRANSMIT_DATA  *TxData;
> -  EFI_TCP4_PROTOCOL       *Tcp4;
> -  EFI_STATUS              Status;
> -
> -  TxData = AllocatePool (sizeof (EFI_TCP4_TRANSMIT_DATA) + (Packet-
> >BlockOpNum - 1) * sizeof (EFI_TCP4_FRAGMENT_DATA));
> -  if (TxData == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -
> -  TxData->Push        = TRUE;
> -  TxData->Urgent      = FALSE;
> -  TxData->DataLength  = Packet->TotalSize;
> -
> -  //
> -  // Build the fragment table.
> -  //
> -  TxData->FragmentCount = Packet->BlockOpNum;
> -  NetbufBuildExt (Packet, (NET_FRAGMENT *) &TxData->FragmentTable[0],
> &TxData->FragmentCount);
> -
> -  Tcp4Io->TxToken.Packet.TxData = TxData;
> -
> -  //
> -  // Trasnmit the packet.
> -  //
> -  Tcp4    = Tcp4Io->Tcp4;
> -  Status  = Tcp4->Transmit (Tcp4, &Tcp4Io->TxToken);
> -  if (EFI_ERROR (Status)) {
> -    goto ON_EXIT;
> -  }
> -
> -  while (!Tcp4Io->IsTxDone) {
> -    Tcp4->Poll (Tcp4);
> -  }
> -
> -  Tcp4Io->IsTxDone  = FALSE;
> -
> -  Status            = Tcp4Io->TxToken.CompletionToken.Status;
> -
> -ON_EXIT:
> -
> -  FreePool (TxData);
> -
> -  return Status;
> -}
> -
> -/**
> -  Receive data from the socket.
> -
> -  @param[in]  Tcp4Io           The Tcp4Io which wraps the socket to be destroyed.
> -  @param[in]  Packet           The buffer to hold the data copy from the soket rx
> buffer.
> -  @param[in]  AsyncMode        Is this receive asyncronous or not.
> -  @param[in]  Timeout          The time to wait for receiving the amount of data
> the Packet
> -                               can hold.
> -
> -  @retval EFI_SUCCESS          The required amount of data is received from the
> socket.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.
> -  @retval EFI_TIMEOUT          Failed to receive the required amount of data in
> the
> -                               specified time period.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -Tcp4IoReceive (
> -  IN TCP4_IO    *Tcp4Io,
> -  IN NET_BUF    *Packet,
> -  IN BOOLEAN    AsyncMode,
> -  IN EFI_EVENT  Timeout
> -  )
> -{
> -  EFI_TCP4_PROTOCOL     *Tcp4;
> -  EFI_TCP4_RECEIVE_DATA RxData;
> -  EFI_STATUS            Status;
> -  NET_FRAGMENT          *Fragment;
> -  UINT32                FragmentCount;
> -  UINT32                CurrentFragment;
> -
> -  FragmentCount = Packet->BlockOpNum;
> -  Fragment      = AllocatePool (FragmentCount * sizeof (NET_FRAGMENT));
> -  if (Fragment == NULL) {
> -    return EFI_OUT_OF_RESOURCES;
> -  }
> -  //
> -  // Build the fragment table.
> -  //
> -  NetbufBuildExt (Packet, Fragment, &FragmentCount);
> -
> -  RxData.FragmentCount          = 1;
> -  Tcp4Io->RxToken.Packet.RxData = &RxData;
> -  CurrentFragment               = 0;
> -  Tcp4                          = Tcp4Io->Tcp4;
> -  Status                        = EFI_SUCCESS;
> -
> -  while (CurrentFragment < FragmentCount) {
> -    RxData.DataLength                       = Fragment[CurrentFragment].Len;
> -    RxData.FragmentTable[0].FragmentLength  =
> Fragment[CurrentFragment].Len;
> -    RxData.FragmentTable[0].FragmentBuffer  =
> Fragment[CurrentFragment].Bulk;
> -
> -    Status = Tcp4->Receive (Tcp4, &Tcp4Io->RxToken);
> -    if (EFI_ERROR (Status)) {
> -      goto ON_EXIT;
> -    }
> -
> -    while (!Tcp4Io->IsRxDone && ((Timeout == NULL) || EFI_ERROR (gBS-
> >CheckEvent (Timeout)))) {
> -      //
> -      // Poll until some data is received or something error happens.
> -      //
> -      Tcp4->Poll (Tcp4);
> -    }
> -
> -    if (!Tcp4Io->IsRxDone) {
> -      //
> -      // Timeout occurs, cancel the receive request.
> -      //
> -      Tcp4->Cancel (Tcp4, &Tcp4Io->RxToken.CompletionToken);
> -
> -      Status = EFI_TIMEOUT;
> -      goto ON_EXIT;
> -    } else {
> -      Tcp4Io->IsRxDone = FALSE;
> -    }
> -
> -    if (EFI_ERROR (Tcp4Io->RxToken.CompletionToken.Status)) {
> -      Status = Tcp4Io->RxToken.CompletionToken.Status;
> -      goto ON_EXIT;
> -    }
> -
> -    Fragment[CurrentFragment].Len -=
> RxData.FragmentTable[0].FragmentLength;
> -    if (Fragment[CurrentFragment].Len == 0) {
> -      CurrentFragment++;
> -    } else {
> -      Fragment[CurrentFragment].Bulk +=
> RxData.FragmentTable[0].FragmentLength;
> -    }
> -  }
> -
> -ON_EXIT:
> -  Tcp4Io->RxToken.Packet.RxData = NULL;
> -  FreePool (Fragment);
> -
> -  return Status;
> -}
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/Md5.c
> b/MdeModulePkg/Universal/Network/IScsiDxe/Md5.c
> deleted file mode 100644
> index 3555f1a2ebe3..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/Md5.c
> +++ /dev/null
> @@ -1,350 +0,0 @@
> -/** @file
> -  Implementation of MD5 algorithm.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "Md5.h"
> -
> -CONST UINT32  Md5_Data[][2] = {
> -  { 0, 1 },
> -  { 1, 5 },
> -  { 5, 3 },
> -  { 0, 7 }
> -};
> -
> -CONST UINT32  Md5_S[][4] = {
> -  { 7, 22, 17, 12 },
> -  { 5, 20, 14, 9 },
> -  { 4, 23, 16 ,11 },
> -  { 6, 21, 15, 10 },
> -};
> -
> -CONST UINT32  Md5_T[] = {
> -  0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE,
> -  0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501,
> -  0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE,
> -  0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821,
> -  0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA,
> -  0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8,
> -  0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED,
> -  0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A,
> -  0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C,
> -  0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70,
> -  0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05,
> -  0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665,
> -  0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039,
> -  0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1,
> -  0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1,
> -  0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391
> -};
> -
> -CONST UINT8 Md5HashPadding[] =
> -{
> -  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
> -  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> -};
> -
> -//
> -// ROTATE_LEFT rotates x left n bits.
> -//
> -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
> -
> -#define SA            MedStates[Index2 & 3]
> -#define SB            MedStates[(Index2 + 1) & 3]
> -#define SC            MedStates[(Index2 + 2) & 3]
> -#define SD            MedStates[(Index2 + 3) & 3]
> -
> -/**
> -  Tf1 is one basic MD5 transform function.
> -
> -  @param[in]  A      A  32-bit quantity.
> -  @param[in]  B      A  32-bit quantity.
> -  @param[in]  C      A  32-bit quantity.
> -
> -  @return             Output was produced as a 32-bit quantity based on the
> -                      three 32-bit input quantity.
> -**/
> -UINT32
> -Tf1 (
> -  IN UINT32 A,
> -  IN UINT32 B,
> -  IN UINT32 C
> -  )
> -{
> -  return (A & B) | (~A & C);
> -}
> -
> -/**
> -  Tf2 is one basic MD5 transform function.
> -
> -  @param[in]  A      A  32-bit quantity.
> -  @param[in]  B      A  32-bit quantity.
> -  @param[in]  C      A  32-bit quantity.
> -
> -  @return             Output was produced as a 32-bit quantity based on the
> -                      three 32-bit input quantity.
> -**/
> -UINT32
> -Tf2 (
> -  IN UINT32 A,
> -  IN UINT32 B,
> -  IN UINT32 C
> -  )
> -{
> -  return (A & C) | (B & ~C);
> -}
> -
> -/**
> -  Tf3 is one basic MD5 transform function.
> -
> -  @param[in]  A      A  32-bit quantity.
> -  @param[in]  B      A  32-bit quantity.
> -  @param[in]  C      A  32-bit quantity.
> -
> -  @return             Output was produced as a 32-bit quantity based on the
> -                      three 32-bit input quantity.
> -**/
> -UINT32
> -Tf3 (
> -  IN UINT32 A,
> -  IN UINT32 B,
> -  IN UINT32 C
> -  )
> -{
> -  return A ^ B ^ C;
> -}
> -
> -/**
> -  Tf4 is one basic MD5 transform function.
> -
> -  @param[in]  A      A  32-bit quantity.
> -  @param[in]  B      A  32-bit quantity.
> -  @param[in]  C      A  32-bit quantity.
> -
> -  @return             Output was produced as a 32-bit quantity based on the
> -                      three 32-bit input quantity.
> -**/
> -UINT32
> -Tf4 (
> -  IN UINT32 A,
> -  IN UINT32 B,
> -  IN UINT32 C
> -  )
> -{
> -  return B ^ (A | ~C);
> -}
> -
> -typedef
> -UINT32
> -(*MD5_TRANSFORM_FUNC) (
> -  IN UINT32  A,
> -  IN UINT32  B,
> -  IN UINT32  C
> -  );
> -
> -CONST MD5_TRANSFORM_FUNC Md5_F[] = {
> -  Tf1,
> -  Tf2,
> -  Tf3,
> -  Tf4
> -};
> -
> -/**
> -  Perform the MD5 transform on 64 bytes data segment.
> -
> -  @param[in, out]  Md5Ctx  It includes the data segment for Md5 transform.
> -**/
> -VOID
> -MD5Transform (
> -  IN OUT MD5_CTX  *Md5Ctx
> -  )
> -{
> -  UINT32  Index1;
> -  UINT32  Index2;
> -  UINT32  MedStates[MD5_HASHSIZE >> 2];
> -  UINT32  *Data;
> -  UINT32  IndexD;
> -  UINT32  IndexT;
> -
> -  Data = (UINT32 *) Md5Ctx->M;
> -
> -  //
> -  // Copy MD5 states to MedStates
> -  //
> -  CopyMem (MedStates, Md5Ctx->States, MD5_HASHSIZE);
> -
> -  IndexT = 0;
> -  for (Index1 = 0; Index1 < 4; Index1++) {
> -    IndexD = Md5_Data[Index1][0];
> -    for (Index2 = 16; Index2 > 0; Index2--) {
> -      SA += (*Md5_F[Index1]) (SB, SC, SD) + Data[IndexD] + Md5_T[IndexT];
> -      SA  = ROTATE_LEFT (SA, Md5_S[Index1][Index2 & 3]);
> -      SA += SB;
> -
> -      IndexD += Md5_Data[Index1][1];
> -      IndexD &= 15;
> -
> -      IndexT++;
> -    }
> -  }
> -
> -  for (Index1 = 0; Index1 < 4; Index1++) {
> -    Md5Ctx->States[Index1] += MedStates[Index1];
> -  }
> -}
> -
> -/**
> -  Copy data segment into the M field of MD5_CTX structure for later transform.
> -  If the length of data segment is larger than 64 bytes, then does the transform
> -  immediately and the generated Md5 code is stored in the States field of
> MD5_CTX
> -  data struct for later accumulation.
> -  All of Md5 code generated for the sequential 64-bytes data segaments are be
> -  accumulated in MD5Final() function.
> -
> -  @param[in, out]  Md5Ctx  The data structure of storing the original data
> -                           segment and the final result.
> -  @param[in]       Data    The data wanted to be transformed.
> -  @param[in]       DataLen The length of data.
> -**/
> -VOID
> -MD5UpdateBlock (
> -  IN OUT MD5_CTX  *Md5Ctx,
> -  IN CONST UINT8  *Data,
> -  IN       UINTN  DataLen
> -  )
> -{
> -  UINTN Limit;
> -
> -  for (Limit = 64 - Md5Ctx->Count; DataLen >= 64 - Md5Ctx->Count; Limit = 64) {
> -    CopyMem (Md5Ctx->M + Md5Ctx->Count, (VOID *)Data, Limit);
> -    MD5Transform (Md5Ctx);
> -
> -    Md5Ctx->Count = 0;
> -    Data         += Limit;
> -    DataLen      -= Limit;
> -  }
> -
> -  CopyMem (Md5Ctx->M + Md5Ctx->Count, (VOID *)Data, DataLen);
> -  Md5Ctx->Count += DataLen;
> -}
> -
> -/**
> -  Initialize four 32-bits chaining variables and use them to do the Md5 transform.
> -
> -  @param[out]  Md5Ctx The data structure of Md5.
> -
> -  @retval EFI_SUCCESS Initialization is ok.
> -**/
> -EFI_STATUS
> -MD5Init (
> -  OUT MD5_CTX  *Md5Ctx
> -  )
> -{
> -  ZeroMem (Md5Ctx, sizeof (*Md5Ctx));
> -
> -  //
> -  // Set magic initialization constants.
> -  //
> -  Md5Ctx->States[0] = 0x67452301;
> -  Md5Ctx->States[1] = 0xefcdab89;
> -  Md5Ctx->States[2] = 0x98badcfe;
> -  Md5Ctx->States[3] = 0x10325476;
> -
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  the external interface of Md5 algorithm
> -
> -  @param[in, out]  Md5Ctx  The data structure of storing the original data
> -                           segment and the final result.
> -  @param[in]       Data    The data wanted to be transformed.
> -  @param[in]       DataLen The length of data.
> -
> -  @retval EFI_SUCCESS The transform is ok.
> -  @retval Others      Other errors as indicated.
> -**/
> -EFI_STATUS
> -MD5Update (
> -  IN  OUT MD5_CTX  *Md5Ctx,
> -  IN  VOID         *Data,
> -  IN  UINTN        DataLen
> -  )
> -{
> -  if (EFI_ERROR (Md5Ctx->Status)) {
> -    return Md5Ctx->Status;
> -  }
> -
> -  MD5UpdateBlock (Md5Ctx, (CONST UINT8 *) Data, DataLen);
> -  Md5Ctx->Length += DataLen;
> -  return EFI_SUCCESS;
> -}
> -
> -/**
> -  Accumulate the MD5 value of every data segment and generate the finial
> -  result according to MD5 algorithm.
> -
> -  @param[in, out]   Md5Ctx  The data structure of storing the original data
> -                            segment and the final result.
> -  @param[out]      HashVal  The final 128-bits output.
> -
> -  @retval EFI_SUCCESS  The transform is ok.
> -  @retval Others       Other errors as indicated.
> -**/
> -EFI_STATUS
> -MD5Final (
> -  IN  OUT MD5_CTX  *Md5Ctx,
> -  OUT UINT8        *HashVal
> -  )
> -{
> -  UINTN PadLength;
> -
> -  if (Md5Ctx->Status == EFI_ALREADY_STARTED) {
> -    //
> -    // Store Hashed value & Zeroize sensitive context information.
> -    //
> -    CopyMem (HashVal, (UINT8 *) Md5Ctx->States, MD5_HASHSIZE);
> -    ZeroMem ((UINT8 *)Md5Ctx, sizeof (*Md5Ctx));
> -
> -    return EFI_SUCCESS;
> -  }
> -
> -  if (EFI_ERROR (Md5Ctx->Status)) {
> -    return Md5Ctx->Status;
> -  }
> -
> -  PadLength  = Md5Ctx->Count >= 56 ? 120 : 56;
> -  PadLength -= Md5Ctx->Count;
> -  MD5UpdateBlock (Md5Ctx, Md5HashPadding, PadLength);
> -  Md5Ctx->Length = LShiftU64 (Md5Ctx->Length, 3);
> -  MD5UpdateBlock (Md5Ctx, (CONST UINT8 *) &Md5Ctx->Length, 8);
> -
> -  ZeroMem (Md5Ctx->M, sizeof (Md5Ctx->M));
> -  Md5Ctx->Length  = 0;
> -  Md5Ctx->Status  = EFI_ALREADY_STARTED;
> -  return MD5Final (Md5Ctx, HashVal);
> -}
> -
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc
> index 3529c8d30365..b787fb5692d3 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -354,7 +354,6 @@ [Components]
>    MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
>    MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
>    MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
> -  MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
>    MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
>    MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
>    MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.h
> deleted file mode 100644
> index ee371d26744c..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.h
> +++ /dev/null
> @@ -1,165 +0,0 @@
> -/** @file
> -  The header file of UEFI Component Name(2) protocol.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _COMPONENT_NAME_H_
> -#define _COMPONENT_NAME_H_
> -
> -#include <Protocol/ComponentName.h>
> -#include <Protocol/ComponentName2.h>
> -
> -extern EFI_COMPONENT_NAME2_PROTOCOL       gIScsiComponentName2;
> -extern EFI_COMPONENT_NAME_PROTOCOL        gIScsiComponentName;
> -
> -//
> -// EFI Component Name Protocol for iSCSI driver.
> -//
> -
> -/**
> -  Retrieves a Unicode string that is the user readable name of the EFI Driver.
> -
> -  This function retrieves the user readable name of a driver in the form of a
> -  Unicode string. If the driver specified by This has a user readable name in
> -  the language specified by Language, then a pointer to the driver name is
> -  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
> -  by This does not support the language specified by Language,
> -  then EFI_UNSUPPORTED is returned.
> -
> -  @param[in]  This        A pointer to the EFI_COMPONENT_NAME_PROTOCOL
> instance.
> -  @param[in]  Language    A pointer to a three characters ISO 639-2 language
> identifier.
> -                          This is the language of the driver name that that the caller
> -                          is requesting, and it must match one of the languages specified
> -                          in SupportedLanguages.  The number of languages supported by
> a
> -                          driver is up to the driver writer.
> -  @param[out]  DriverName A pointer to the Unicode string to return.  This
> Unicode string
> -                          is the name of the driver specified by This in the language
> -                          specified by Language.
> -
> -  @retval EFI_SUCCESS           The Unicode string for the Driver specified by This
> -                                and the language specified by Language was returned
> -                                in DriverName.
> -  @retval EFI_INVALID_PARAMETER Language is NULL.
> -  @retval EFI_INVALID_PARAMETER DriverName is NULL.
> -  @retval EFI_UNSUPPORTED       The driver specified by This does not support
> the
> -                                language specified by Language.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiComponentNameGetDriverName (
> -  IN  EFI_COMPONENT_NAME_PROTOCOL   *This,
> -  IN  CHAR8                         *Language,
> -  OUT CHAR16                        **DriverName
> -  );
> -
> -/**
> -  Retrieves a Unicode string that is the user readable name of the controller
> -  that is being managed by an EFI Driver. Currently not implemented.
> -
> -  @param[in]  This             A pointer to the EFI_COMPONENT_NAME_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle The handle of a controller that the driver
> specified by
> -                               This is managing.  This handle specifies the controller
> -                               whose name is to be returned.
> -  @param[in]  ChildHandle      The handle of the child controller to retrieve the
> name
> -                               of.  This is an optional parameter that may be NULL.  It
> -                               will be NULL for device drivers.  It will also be NULL
> -                               for a bus drivers that wish to retrieve the name of the
> -                               bus controller.  It will not be NULL for a bus driver
> -                               that wishes to retrieve the name of a child controller.
> -  @param[in]  Language         A pointer to a three characters ISO 639-2 language
> -                               identifier.  This is the language of the controller name
> -                               that that the caller is requesting, and it must match one
> -                               of the languages specified in SupportedLanguages.  The
> -                               number of languages supported by a driver is up to the
> -                               driver writer.
> -  @param[out]  ControllerName  A pointer to the Unicode string to return.  This
> Unicode
> -                               string is the name of the controller specified by
> -                               ControllerHandle and ChildHandle in the language specified
> -                               by Language from the point of view of the driver specified
> -                               by This.
> -
> -  @retval EFI_SUCCESS           The Unicode string for the user readable name in
> the
> -                                language specified by Language for the driver
> -                                specified by This was returned in DriverName.
> -  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
> -  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
> EFI_HANDLE.
> -  @retval EFI_INVALID_PARAMETER Language is NULL.
> -  @retval EFI_INVALID_PARAMETER ControllerName is NULL.
> -  @retval EFI_UNSUPPORTED       The driver specified by This is not currently
> managing
> -                                the controller specified by ControllerHandle and
> -                                ChildHandle.
> -  @retval EFI_UNSUPPORTED       The driver specified by This does not support
> the
> -                                language specified by Language.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiComponentNameGetControllerName (
> -  IN  EFI_COMPONENT_NAME_PROTOCOL   *This,
> -  IN  EFI_HANDLE                    ControllerHandle,
> -  IN  EFI_HANDLE                    ChildHandle        OPTIONAL,
> -  IN  CHAR8                         *Language,
> -  OUT CHAR16                        **ControllerName
> -  );
> -
> -//
> -// EFI iSCSI Initiator Name Protocol for IScsi driver.
> -//
> -
> -/**
> -  Retrieves the current set value of iSCSI Initiator Name.
> -
> -  @param[in]       This       Pointer to the
> EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
> -  @param[in, out]  BufferSize Size of the buffer in bytes pointed to by Buffer /
> Actual size of the
> -                              variable data buffer.
> -  @param[out]      Buffer     Pointer to the buffer for data to be read.
> -
> -  @retval EFI_SUCCESS           Data was successfully retrieved into the provided
> buffer and the
> -                                BufferSize was sufficient to handle the iSCSI initiator name
> -  @retval EFI_BUFFER_TOO_SMALL  BufferSize is too small for the result.
> -  @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL.
> -  @retval EFI_DEVICE_ERROR      The iSCSI initiator name could not be retrieved
> due to a hardware error.
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiGetInitiatorName (
> -  IN     EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *This,
> -  IN OUT UINTN                              *BufferSize,
> -  OUT    VOID                               *Buffer
> -  );
> -
> -/**
> -  Sets the iSCSI Initiator Name.
> -
> -  @param[in]       This       Pointer to the
> EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
> -  @param[in, out]  BufferSize Size of the buffer in bytes pointed to by Buffer.
> -  @param[in]       Buffer     Pointer to the buffer for data to be written.
> -
> -  @retval EFI_SUCCESS           Data was successfully stored by the protocol.
> -  @retval EFI_UNSUPPORTED       Platform policies do not allow for data to be
> written.
> -                                Currently not implemented.
> -  @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL, or BufferSize
> exceeds the maximum allowed limit.
> -  @retval EFI_DEVICE_ERROR      The data could not be stored due to a
> hardware error.
> -  @retval EFI_OUT_OF_RESOURCES  Not enough storage is available to hold
> the data.
> -  @retval EFI_PROTOCOL_ERROR    Input iSCSI initiator name does not adhere
> to RFC 3720
> -                                (and other related protocols)
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiSetInitiatorName (
> -  IN     EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *This,
> -  IN OUT UINTN                              *BufferSize,
> -  IN     VOID                               *Buffer
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsi4Dxe.uni
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsi4Dxe.uni
> deleted file mode 100644
> index d3c020e45d3b..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsi4Dxe.uni
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -// /** @file
> -// This module produces EFI iSCSI Initiator Name Protocol.
> -//
> -// This module produces EFI iSCSI Initiator Name Protocol upon EFI TCPv4
> Protocol
> -// and EFI DHCPv4 Protocol, to provide the capability to do the transport for
> SCSI
> -// data over TCP/IP. It installs EFI HII Configuration Access Protocol to provide
> -// one way to configurate the iSCSI setting.
> -//
> -// Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -//
> -// This program and the accompanying materials
> -// are licensed and made available under the terms and conditions of the BSD
> License
> -// which accompanies this distribution.  The full text of the license may be
> found at
> -// http://opensource.org/licenses/bsd-license.php
> -//
> -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -//
> -// **/
> -
> -
> -#string STR_MODULE_ABSTRACT             #language en-US "Produces EFI iSCSI
> Initiator Name Protocol"
> -
> -#string STR_MODULE_DESCRIPTION          #language en-US "This module
> produces EFI iSCSI Initiator Name Protocol upon EFI TCPv4 Protocol and EFI
> DHCPv4 Protocol, to provide the capability to do the transport for SCSI data
> over TCP/IP. It installs EFI HII Configuration Access Protocol to provide a way to
> configure the iSCSI setting."
> -
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsi4DxeExtra.uni
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsi4DxeExtra.uni
> deleted file mode 100644
> index 5ec75820a605..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsi4DxeExtra.uni
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -// /** @file
> -// IScsi4Dxe Localized Strings and Content
> -//
> -// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
> -//
> -// This program and the accompanying materials
> -// are licensed and made available under the terms and conditions of the BSD
> License
> -// which accompanies this distribution.  The full text of the license may be
> found at
> -// http://opensource.org/licenses/bsd-license.php
> -//
> -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -//
> -// **/
> -
> -#string STR_PROPERTIES_MODULE_NAME
> -#language en-US
> -"iSCSI DXE Driver"
> -
> -
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h
> deleted file mode 100644
> index 14a5658f754b..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h
> +++ /dev/null
> @@ -1,106 +0,0 @@
> -/** @file
> -  The header file of CHAP configuration.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_CHAP_H_
> -#define _ISCSI_CHAP_H_
> -
> -#define ISCSI_AUTH_METHOD_CHAP    "CHAP"
> -
> -#define ISCSI_KEY_CHAP_ALGORITHM  "CHAP_A"
> -#define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
> -#define ISCSI_KEY_CHAP_CHALLENGE  "CHAP_C"
> -#define ISCSI_KEY_CHAP_NAME       "CHAP_N"
> -#define ISCSI_KEY_CHAP_RESPONSE   "CHAP_R"
> -
> -#define ISCSI_CHAP_ALGORITHM_MD5  5
> -
> -#define ISCSI_CHAP_AUTH_MAX_LEN   1024
> -///
> -/// MD5_HASHSIZE
> -///
> -#define ISCSI_CHAP_RSP_LEN        16
> -
> -#define ISCSI_CHAP_INITIAL        0
> -#define ISCSI_CHAP_STEP_ONE       1
> -#define ISCSI_CHAP_STEP_TWO       2
> -#define ISCSI_CHAP_STEP_THREE     3
> -#define ISCSI_CHAP_STEP_FOUR      4
> -
> -#pragma pack(1)
> -
> -typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
> -  UINT8 CHAPType;
> -  CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
> -  CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
> -  CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
> -  CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
> -} ISCSI_CHAP_AUTH_CONFIG_NVDATA;
> -
> -#pragma pack()
> -
> -///
> -/// ISCSI CHAP Authentication Data
> -///
> -typedef struct _ISCSI_CHAP_AUTH_DATA {
> -  ISCSI_CHAP_AUTH_CONFIG_NVDATA AuthConfig;
> -  UINT32                        InIdentifier;
> -  UINT8                         InChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
> -  UINT32                        InChallengeLength;
> -  //
> -  // Calculated CHAP Response (CHAP_R) value
> -  //
> -  UINT8                         CHAPResponse[ISCSI_CHAP_RSP_LEN];
> -
> -  //
> -  // Auth-data to be sent out for mutual authentication
> -  //
> -  UINT32                        OutIdentifier;
> -  UINT8                         OutChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
> -  UINT32                        OutChallengeLength;
> -} ISCSI_CHAP_AUTH_DATA;
> -
> -/**
> -  This function checks the received iSCSI Login Response during the security
> -  negotiation stage.
> -
> -  @param[in] Conn             The iSCSI connection.
> -
> -  @retval EFI_SUCCESS          The Login Response passed the CHAP validation.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of protocol error happend.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiCHAPOnRspReceived (
> -  IN ISCSI_CONNECTION  *Conn
> -  );
> -/**
> -  This function fills the CHAP authentication information into the login PDU
> -  during the security negotiation stage in the iSCSI connection login.
> -
> -  @param[in]       Conn        The iSCSI connection.
> -  @param[in, out]  Pdu         The PDU to send out.
> -
> -  @retval EFI_SUCCESS          All check passed and the phase-related CHAP
> -                               authentication info is filled into the iSCSI PDU.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of protocol error happend.
> -**/
> -EFI_STATUS
> -IScsiCHAPToSendReq (
> -  IN      ISCSI_CONNECTION  *Conn,
> -  IN OUT  NET_BUF           *Pdu
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCommon.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCommon.h
> deleted file mode 100644
> index 650c68d53bab..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCommon.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/** @file
> -  The common header file of Iscsi.
> -
> -Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_COMMON_H_
> -#define _ISCSI_COMMON_H_
> -
> -typedef struct _ISCSI_SESSION             ISCSI_SESSION;
> -typedef struct _ISCSI_CONNECTION          ISCSI_CONNECTION;
> -typedef struct _ISCSI_DRIVER_DATA         ISCSI_DRIVER_DATA;
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h
> deleted file mode 100644
> index c3d07f6f4859..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.h
> +++ /dev/null
> @@ -1,166 +0,0 @@
> -/** @file
> -  The header file of IScsiConfig.c.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_CONFIG_H_
> -#define _ISCSI_CONFIG_H_
> -
> -#include <Guid/MdeModuleHii.h>
> -#include <Protocol/HiiConfigRouting.h>
> -#include <Library/HiiLib.h>
> -#include <Library/DevicePathLib.h>
> -#include <Library/DebugLib.h>
> -#include <Library/BaseLib.h>
> -#include <Library/NetLib.h>
> -
> -extern UINT8  IScsiConfigDxeBin[];
> -extern UINT8  IScsi4DxeStrings[];
> -
> -#define ISCSI_INITATOR_NAME_VAR_NAME        L"I_NAME"
> -
> -#define ISCSI_CONFIG_VAR_ATTR
> (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)
> -
> -#define ISCSI_FORM_CALLBACK_INFO_SIGNATURE  SIGNATURE_32 ('I', 'f', 'c',
> 'i')
> -
> -
> -
> -/**
> -  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
> PcdDebugProperyMask is clear,
> -  then this macro return a pointer to a data structure
> ISCSI_FORM_CALLBACK_INFO.
> -
> -  If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
> PcdDebugProperyMask is set,
> -  The Signature field of the data structure ISCSI_FORM_CALLBACK_INFO
> -  is compared to TestSignature.  If the signatures match, then a pointer
> -  to the pointer to a data structure ISCSI_FORM_CALLBACK_INFO is returned.
> -  If the signatures do not match, then DebugAssert() is called with a description
> -  of "CR has a bad signature" and Callback is returned.
> -
> -  If the data type ISCSI_FORM_CALLBACK_INFO_SIGNATURE does not contain
> the field
> -  specified by Callback, then the module will not compile.
> -
> -  If ISCSI_FORM_CALLBACK_INFO_SIGNATURE does not contain a field called
> Signature,
> -  then the module will not compile.
> -
> -  @param   Callback      Pointer to the specified field within the data
> -                         structure ISCSI_FORM_CALLBACK_INFO.
> -  @return  A pointer to the pointer to a data structure
> ISCSI_FORM_CALLBACK_INFO.
> -  @retval  Others        Some unexpected error happened.
> -**/
> -
> -#define ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \
> -  CR ( \
> -  Callback, \
> -  ISCSI_FORM_CALLBACK_INFO, \
> -  ConfigAccess, \
> -  ISCSI_FORM_CALLBACK_INFO_SIGNATURE \
> -  )
> -
> -#pragma pack(1)
> -
> -typedef struct _ISCSI_MAC_INFO {
> -  EFI_MAC_ADDRESS Mac;
> -  UINT8           Len;
> -  UINT16          VlanId;
> -} ISCSI_MAC_INFO;
> -
> -typedef struct _ISCSI_DEVICE_LIST {
> -  UINT8           NumDevice;
> -  ISCSI_MAC_INFO  MacInfo[1];
> -} ISCSI_DEVICE_LIST;
> -
> -#pragma pack()
> -
> -typedef struct _ISCSI_CONFIG_FORM_ENTRY {
> -  LIST_ENTRY                    Link;
> -  EFI_HANDLE                    Controller;
> -  CHAR16                        MacString[95];
> -  EFI_STRING_ID                 PortTitleToken;
> -  EFI_STRING_ID                 PortTitleHelpToken;
> -
> -  ISCSI_SESSION_CONFIG_NVDATA   SessionConfigData;
> -  ISCSI_CHAP_AUTH_CONFIG_NVDATA AuthConfigData;
> -} ISCSI_CONFIG_FORM_ENTRY;
> -
> -typedef struct _ISCSI_FORM_CALLBACK_INFO {
> -  UINTN                            Signature;
> -  EFI_HANDLE                       DriverHandle;
> -  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;
> -  EFI_HII_DATABASE_PROTOCOL        *HiiDatabase;
> -  EFI_HII_CONFIG_ROUTING_PROTOCOL  *ConfigRouting;
> -  UINT16                           *KeyList;
> -  VOID                             *FormBuffer;
> -  EFI_HII_HANDLE                   RegisteredHandle;
> -  ISCSI_CONFIG_FORM_ENTRY          *Current;
> -} ISCSI_FORM_CALLBACK_INFO;
> -
> -#pragma pack(1)
> -
> -///
> -/// HII specific Vendor Device Path definition.
> -///
> -typedef struct {
> -  VENDOR_DEVICE_PATH             VendorDevicePath;
> -  EFI_DEVICE_PATH_PROTOCOL       End;
> -} HII_VENDOR_DEVICE_PATH;
> -
> -#pragma pack()
> -
> -/**
> -  Updates the iSCSI configuration form to add/delete an entry for the iSCSI
> -  device specified by the Controller.
> -
> -  @param[in]  DriverBindingHandle The driverbinding handle.
> -  @param[in]  Controller          The controller handle of the iSCSI device.
> -  @param[in]  AddForm             Whether to add or delete a form entry.
> -
> -  @retval EFI_SUCCESS             The iSCSI configuration form is updated.
> -  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> -  @retval Others                  Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiConfigUpdateForm (
> -  IN EFI_HANDLE  DriverBindingHandle,
> -  IN EFI_HANDLE  Controller,
> -  IN BOOLEAN     AddForm
> -  );
> -
> -/**
> -  Initialize the iSCSI configuration form.
> -
> -  @param[in]  DriverBindingHandle  The iSCSI driverbinding handle.
> -
> -  @retval EFI_SUCCESS              The iSCSI configuration form is initialized.
> -  @retval EFI_OUT_OF_RESOURCES     Failed to allocate memory.
> -  @retval Others                   Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiConfigFormInit (
> -  VOID
> -  );
> -
> -/**
> -  Unload the iSCSI configuration form, this includes: delete all the iSCSI
> -  device configuration entries, uninstall the form callback protocol and
> -  free the resources used.
> -
> -  @param[in]  DriverBindingHandle The iSCSI driverbinding handle.
> -
> -  @retval EFI_SUCCESS             The iSCSI configuration form is unloaded.
> -  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> -**/
> -EFI_STATUS
> -IScsiConfigFormUnload (
> -  IN EFI_HANDLE  DriverBindingHandle
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
> deleted file mode 100644
> index 9e28d81fb40d..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
> +++ /dev/null
> @@ -1,219 +0,0 @@
> -/** @file
> -  Vfr file for iSCSI config.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -
> -#include "IScsiConfigNVDataStruc.h"
> -#define EFI_NETWORK_DEVICE_CLASS  0x04
> -
> -formset
> -  guid     = IP4_ISCSI_CONFIG_GUID,
> -  title    = STRING_TOKEN(STR_ISCSI_CONFIG_FORM_TITLE),
> -  help     = STRING_TOKEN(STR_ISCSI_CONFIG_FORM_HELP),
> -
> -  varstore ISCSI_CONFIG_IFR_NVDATA,
> -    name = ISCSI_CONFIG_IFR_NVDATA,
> -    guid = IP4_ISCSI_CONFIG_GUID;
> -  form formid = FORMID_MAIN_FORM,
> -    title  = STRING_TOKEN(STR_ISCSI_MAIN_FORM_TITLE);
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.InitiatorName,
> -            prompt  = STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME),
> -            help    = STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_INITIATOR_NAME,
> -            minsize = ISCSI_NAME_IFR_MIN_SIZE,
> -            maxsize = ISCSI_NAME_IFR_MAX_SIZE,
> -    endstring;
> -
> -    label DEVICE_ENTRY_LABEL;
> -    label LABEL_END;
> -
> -  endform;
> -
> -  form formid = FORMID_DEVICE_FORM,
> -    title  = STRING_TOKEN(STR_ISCSI_DEVICE_FORM_TITLE);
> -
> -    checkbox varid = ISCSI_CONFIG_IFR_NVDATA.Enabled,
> -            prompt = STRING_TOKEN(STR_ISCSI_DEVICE_ENABLE),
> -            help   = STRING_TOKEN(STR_NULL),
> -            flags  = 0,
> -    endcheckbox;
> -
> -    checkbox varid = ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp,
> -            prompt = STRING_TOKEN(STR_ISCSI_ENABLE_DHCP),
> -            help   = STRING_TOKEN(STR_ISCSI_ENABLE_DHCP),
> -            flags  = INTERACTIVE,
> -            key    = KEY_DHCP_ENABLE,
> -    endcheckbox;
> -
> -    suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp ==
> 0x01;
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.LocalIp,
> -            prompt  = STRING_TOKEN(STR_ISCSI_LOCAL_IP_ADDRESS),
> -            help    = STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_LOCAL_IP,
> -            minsize = IP_MIN_SIZE,
> -            maxsize = IP_MAX_SIZE,
> -    endstring;
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.SubnetMask,
> -            prompt  = STRING_TOKEN(STR_ISCSI_LOCAL_MASK),
> -            help    = STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_SUBNET_MASK,
> -            minsize = IP_MIN_SIZE,
> -            maxsize = IP_MAX_SIZE,
> -    endstring;
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.Gateway,
> -            prompt  = STRING_TOKEN(STR_ISCSI_LOCAL_GATEWAY),
> -            help    = STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_GATE_WAY,
> -            minsize = IP_MIN_SIZE,
> -            maxsize = IP_MAX_SIZE,
> -    endstring;
> -    endif;
> -
> -    subtitle text = STRING_TOKEN(STR_NULL);
> -
> -    suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp ==
> 0x00;
> -    checkbox varid  = ISCSI_CONFIG_IFR_NVDATA.TargetInfoFromDhcp,
> -             prompt = STRING_TOKEN(STR_ISCSI_ENABLE_DHCP_ON_TARGET),
> -             help   = STRING_TOKEN(STR_ISCSI_ENABLE_DHCP_ON_TARGET),
> -             flags  = 0,
> -    endcheckbox;
> -    endif;
> -
> -    suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.TargetInfoFromDhcp == 0x01;
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.TargetName,
> -            prompt  = STRING_TOKEN(STR_ISCSI_TARGET_NAME),
> -            help    = STRING_TOKEN(STR_ISCSI_TARGET_NAME),
> -            flags   = INTERACTIVE,
> -            key     = KEY_TARGET_NAME,
> -            minsize = ISCSI_NAME_IFR_MIN_SIZE,
> -            maxsize = ISCSI_NAME_IFR_MAX_SIZE,
> -    endstring;
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.TargetIp,
> -            prompt  = STRING_TOKEN(STR_ISCSI_TARGET_IP_ADDRESS),
> -            help    = STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_TARGET_IP,
> -            minsize = IP_MIN_SIZE,
> -            maxsize = IP_MAX_SIZE,
> -    endstring;
> -
> -    numeric varid   = ISCSI_CONFIG_IFR_NVDATA.TargetPort,
> -            prompt  = STRING_TOKEN(STR_ISCSI_TARGET_PORT),
> -            help    = STRING_TOKEN(STR_ISCSI_TARGET_PORT),
> -            flags   = 0,
> -            minimum = TARGET_PORT_MIN_NUM,
> -            maximum = TARGET_PORT_MAX_NUM,
> -            step    = 0,
> -    endnumeric;
> -
> -    string varid    = ISCSI_CONFIG_IFR_NVDATA.BootLun,
> -            prompt  = STRING_TOKEN(STR_ISCSI_BOOT_LUN),
> -            help    = STRING_TOKEN(STR_ISCSI_BOOT_LUN_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_BOOT_LUN,
> -            minsize = LUN_MIN_SIZE,
> -            maxsize = LUN_MAX_SIZE,
> -    endstring;
> -    endif;
> -
> -    subtitle text = STRING_TOKEN(STR_NULL);
> -
> -    oneof varid  = ISCSI_CONFIG_IFR_NVDATA.CHAPType,
> -          prompt = STRING_TOKEN(STR_CHAP_TYPE_PROMPT),
> -          help   = STRING_TOKEN(STR_CHAP_TYPE_HELP),
> -          option text = STRING_TOKEN(STR_CHAP_TYPE_NONE),   value =
> ISCSI_CHAP_NONE,   flags = DEFAULT;
> -          option text = STRING_TOKEN(STR_CHAP_TYPE_UNI),    value =
> ISCSI_CHAP_UNI,    flags = 0;
> -          option text = STRING_TOKEN(STR_CHAP_TYPE_MUTUAL), value =
> ISCSI_CHAP_MUTUAL, flags = 0;
> -    endoneof;
> -
> -    suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.CHAPType ==
> ISCSI_CHAP_NONE;
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.CHAPName,
> -            prompt  = STRING_TOKEN(STR_ISCSI_CHAP_NAME),
> -            help    = STRING_TOKEN(STR_ISCSI_CHAP_NAME),
> -            flags   = INTERACTIVE,
> -            key     = KEY_CHAP_NAME,
> -            minsize = 0,
> -            maxsize = ISCSI_CHAP_NAME_MAX_LEN,
> -    endstring;
> -
> -    string  varid    = ISCSI_CONFIG_IFR_NVDATA.CHAPSecret,
> -            prompt   = STRING_TOKEN(STR_ISCSI_CHAP_SECRET),
> -            help     = STRING_TOKEN(STR_ISCSI_CHAP_SECRET_HELP),
> -            flags    = INTERACTIVE,
> -            key      = KEY_CHAP_SECRET,
> -            minsize  = ISCSI_CHAP_SECRET_MIN_LEN,
> -            maxsize  = ISCSI_CHAP_SECRET_MAX_LEN,
> -    endstring;
> -
> -    endif;
> -
> -    suppressif NOT ideqval ISCSI_CONFIG_IFR_NVDATA.CHAPType ==
> ISCSI_CHAP_MUTUAL;
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.ReverseCHAPName,
> -            prompt  = STRING_TOKEN(STR_ISCSI_REVERSE_CHAP_NAME),
> -            help    = STRING_TOKEN(STR_ISCSI_REVERSE_CHAP_NAME),
> -            flags   = INTERACTIVE,
> -            key     = KEY_REVERSE_CHAP_NAME,
> -            minsize = 0,
> -            maxsize = ISCSI_CHAP_NAME_MAX_LEN,
> -    endstring;
> -
> -    string  varid    = ISCSI_CONFIG_IFR_NVDATA.ReverseCHAPSecret,
> -            prompt   = STRING_TOKEN(STR_ISCSI_REVERSE_CHAP_SECRET),
> -            help     = STRING_TOKEN(STR_ISCSI_CHAP_SECRET_HELP),
> -            flags    = INTERACTIVE,
> -            key      = KEY_REVERSE_CHAP_SECRET,
> -            minsize  = ISCSI_CHAP_SECRET_MIN_LEN,
> -            maxsize  = ISCSI_CHAP_SECRET_MAX_LEN,
> -    endstring;
> -
> -    endif;
> -
> -    subtitle text = STRING_TOKEN(STR_NULL);
> -
> -    string  varid   = ISCSI_CONFIG_IFR_NVDATA.IsId,
> -            prompt  = STRING_TOKEN(STR_ISCSI_CONFIG_ISID),
> -            help    = STRING_TOKEN(STR_ISCSI_CONFIG_ISID_HELP),
> -            flags   = INTERACTIVE,
> -            key     = KEY_CONFIG_ISID,
> -            minsize = ISID_CONFIGURABLE_MIN_LEN,
> -            maxsize = ISID_CONFIGURABLE_MAX_LEN,
> -    endstring;
> -
> -    subtitle text = STRING_TOKEN(STR_NULL);
> -
> -    text
> -      help   = STRING_TOKEN (STR_SAVE_CHANGES),
> -      text   = STRING_TOKEN (STR_SAVE_CHANGES),
> -      flags  = INTERACTIVE,
> -      key    = KEY_SAVE_CHANGES;
> -
> -    goto FORMID_MAIN_FORM,
> -    prompt = STRING_TOKEN (STR_RETURN_MAIN_FORM),
> -    help   = STRING_TOKEN (STR_RETURN_MAIN_FORM),
> -    flags  = 0;
> -
> -  endform;
> -
> -endformset;
> -
> diff --git
> a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
> deleted file mode 100644
> index 729c74ebfc1b..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
> +++ /dev/null
> @@ -1,62 +0,0 @@
> -// *++
> -//
> -// Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -// This program and the accompanying materials
> -// are licensed and made available under the terms and conditions of the BSD
> License
> -// which accompanies this distribution.  The full text of the license may be
> found at
> -// http://opensource.org/licenses/bsd-license.php
> -//
> -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -//
> -// Module Name:
> -//
> -//   IScsiConfigStrings.uni
> -//
> -// Abstract:
> -//
> -//   String definitions for iSCSI configuration.
> -//
> -// Revision History:
> -//
> -// --*/
> -
> -
> -/=#
> -
> -#langdef en-US "English"
> -
> -#string STR_ISCSI_CONFIG_FORM_TITLE     #language en-US "iSCSI
> Configuration"
> -#string STR_ISCSI_CONFIG_FORM_HELP      #language en-US "Configure the
> iSCSI parameters."
> -#string STR_ISCSI_MAIN_FORM_TITLE       #language en-US "iSCSI
> Configuration"
> -#string STR_ISCSI_CONFIG_INIT_NAME      #language en-US "iSCSI Initiator
> Name"
> -#string STR_ISCSI_CONFIG_INIT_NAME_HELP #language en-US "The worldwide
> unique name of the initiator. Only iqn. format is accepted."
> -#string STR_ISCSI_DEVICE_FORM_TITLE     #language en-US ""
> -#string STR_ISCSI_DEVICE_ENABLE         #language en-US "Enable iSCSI"
> -#string STR_ISCSI_LOCAL_IP_ADDRESS      #language en-US "  Initiator IP
> Address"
> -#string STR_ISCSI_LOCAL_MASK            #language en-US "  Initiator Subnet
> Mask"
> -#string STR_ISCSI_LOCAL_GATEWAY         #language en-US "  Gateway"
> -#string STR_ISCSI_IP_ADDRESS_HELP       #language en-US "Enter IP address in
> dotted-decimal notation."
> -#string STR_ISCSI_TARGET_NAME           #language en-US "  Target Name"
> -#string STR_ISCSI_TARGET_IP_ADDRESS     #language en-US "  Target IP
> Address"
> -#string STR_ISCSI_TARGET_PORT           #language en-US "  Target Port"
> -#string STR_ISCSI_BOOT_LUN              #language en-US "  Boot LUN"
> -#string STR_ISCSI_BOOT_LUN_HELP         #language en-US "Hexadecimal
> representation of the LU number. Examples are: 4752-3A4F-6b7e-2F99, 6734-9-
> 156f-127, 4186-9"
> -#string STR_ISCSI_ENABLE_DHCP           #language en-US "Enable DHCP"
> -#string STR_ISCSI_ENABLE_DHCP_ON_TARGET #language en-US "Get target
> info via DHCP"
> -#string STR_CHAP_TYPE_PROMPT            #language en-US "CHAP Type"
> -#string STR_CHAP_TYPE_HELP              #language en-US "None, One way CHAP
> or mutual CHAP"
> -#string STR_CHAP_TYPE_NONE              #language en-US "None"
> -#string STR_CHAP_TYPE_UNI               #language en-US "One way"
> -#string STR_CHAP_TYPE_MUTUAL            #language en-US "Mutual"
> -#string STR_ISCSI_CHAP_NAME             #language en-US "  CHAP Name"
> -#string STR_ISCSI_CHAP_SECRET           #language en-US "  CHAP Secret"
> -#string STR_ISCSI_CHAP_SECRET_HELP      #language en-US "The minimum
> length is 12 bytes and the maximum length is 16 bytes."
> -#string STR_ISCSI_REVERSE_CHAP_NAME     #language en-US "  Reverse CHAP
> Name"
> -#string STR_ISCSI_REVERSE_CHAP_SECRET   #language en-US "  Reverse CHAP
> Secret"
> -#string STR_ISCSI_CONFIG_ISID           #language en-US "ISID"
> -#string STR_ISCSI_CONFIG_ISID_HELP      #language en-US "OUI-format ISID in
> 6 bytes, default value are derived from MAC address. Only last 3 bytes are
> configurable. Example: update 0ABBCCDDEEFF to 0ABBCCF07901 by input
> F07901."
> -#string STR_RETURN_MAIN_FORM            #language en-US "Back to Previous
> Page"
> -#string STR_SAVE_CHANGES                #language en-US "Save Changes"
> -#string STR_NULL                        #language en-US ""
> -
> diff --git
> a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
> deleted file mode 100644
> index 7c2e4e65fa8e..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
> +++ /dev/null
> @@ -1,109 +0,0 @@
> -/** @file
> -  Define NVData structures used by the iSCSI configuration component
> -
> -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_NVDATASTRUC_H_
> -#define _ISCSI_NVDATASTRUC_H_
> -
> -#include <Guid/Ip4IScsiConfigHii.h>
> -
> -#define VAR_EQ_TEST_NAME    0x100
> -
> -#define FORMID_MAIN_FORM    1
> -#define FORMID_DEVICE_FORM  2
> -
> -#define ISCSI_NAME_MAX_SIZE 224
> -
> -//
> -// Vfr has a limit on the size, it's 255 bytes.
> -//
> -#define ISCSI_NAME_IFR_MIN_SIZE   4
> -#define ISCSI_NAME_IFR_MAX_SIZE   223
> -
> -#define IP_MIN_SIZE               7
> -#define IP_MAX_SIZE               15
> -#define IP4_STR_MAX_SIZE          16
> -
> -#define LUN_MIN_SIZE              1
> -#define LUN_MAX_SIZE              20
> -
> -#define ISCSI_CHAP_NONE           0
> -#define ISCSI_CHAP_UNI            1
> -#define ISCSI_CHAP_MUTUAL         2
> -
> -#define TARGET_PORT_MIN_NUM       0
> -#define TARGET_PORT_MAX_NUM       65535
> -
> -#define DEVICE_ENTRY_LABEL        0x1234
> -#define LABEL_END                 0xffff
> -
> -#define KEY_INITIATOR_NAME        0x101
> -#define KEY_DHCP_ENABLE           0x102
> -#define KEY_LOCAL_IP              0x103
> -#define KEY_SUBNET_MASK           0x104
> -#define KEY_GATE_WAY              0x105
> -#define KEY_TARGET_IP             0x106
> -#define KEY_CHAP_NAME             0x107
> -#define KEY_CHAP_SECRET           0x108
> -#define KEY_REVERSE_CHAP_NAME     0x109
> -#define KEY_REVERSE_CHAP_SECRET   0x10a
> -#define KEY_SAVE_CHANGES          0x10b
> -#define KEY_TARGET_NAME           0x10c
> -#define KEY_BOOT_LUN              0x10d
> -#define KEY_CONFIG_ISID           0x10e
> -
> -#define KEY_DEVICE_ENTRY_BASE     0x1000
> -
> -#define ISCSI_LUN_STR_MAX_LEN     21
> -#define ISCSI_CHAP_SECRET_MIN_LEN 12
> -#define ISCSI_CHAP_SECRET_MAX_LEN 16
> -//
> -//  ISCSI_CHAP_SECRET_STORAGE = ISCSI_CHAP_SECRET_MAX_LEN + sizeof
> (NULL-Terminator)
> -//
> -#define ISCSI_CHAP_SECRET_STORAGE 17
> -
> -#define ISCSI_CHAP_NAME_MAX_LEN   126
> -#define ISCSI_CHAP_NAME_STORAGE   127
> -
> -#define ISID_CONFIGURABLE_MIN_LEN 6
> -#define ISID_CONFIGURABLE_MAX_LEN 12
> -#define ISID_CONFIGURABLE_STORAGE 13
> -
> -#pragma pack(1)
> -typedef struct {
> -  CHAR16  InitiatorName[ISCSI_NAME_MAX_SIZE];
> -
> -  UINT8   Enabled;
> -
> -  UINT8   InitiatorInfoFromDhcp;
> -  CHAR16  LocalIp[IP4_STR_MAX_SIZE];
> -  CHAR16  SubnetMask[IP4_STR_MAX_SIZE];
> -  CHAR16  Gateway[IP4_STR_MAX_SIZE];
> -
> -  CHAR16  TargetName[ISCSI_NAME_MAX_SIZE];
> -  CHAR16  TargetIp[IP4_STR_MAX_SIZE];
> -  UINT16  TargetPort;
> -  CHAR16  BootLun[ISCSI_LUN_STR_MAX_LEN];
> -  UINT8   TargetInfoFromDhcp;
> -
> -  UINT8   CHAPType;
> -  CHAR16  CHAPName[ISCSI_CHAP_NAME_STORAGE];
> -  CHAR16  CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
> -  CHAR16  ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
> -  CHAR16  ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
> -
> -  CHAR16  IsId[ISID_CONFIGURABLE_STORAGE];
> -} ISCSI_CONFIG_IFR_NVDATA;
> -#pragma pack()
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h
> deleted file mode 100644
> index 4c4dcaa8f68d..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/** @file
> -  The header file of IScsiDhcp.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_DHCP_H_
> -#define _ISCSI_DHCP_H_
> -
> -#include <Protocol/Dhcp4.h>
> -
> -#define ISCSI_ROOT_PATH_ID              "iscsi:"
> -#define ISCSI_ROOT_PATH_FIELD_DELIMITER ':'
> -
> -#define RP_FIELD_IDX_SERVERNAME         0
> -#define RP_FIELD_IDX_PROTOCOL           1
> -#define RP_FIELD_IDX_PORT               2
> -#define RP_FIELD_IDX_LUN                3
> -#define RP_FIELD_IDX_TARGETNAME         4
> -#define RP_FIELD_IDX_MAX                5
> -
> -typedef struct _ISCSI_ROOT_PATH_FIELD {
> -  CHAR8 *Str;
> -  UINT8 Len;
> -} ISCSI_ROOT_PATH_FIELD;
> -
> -/**
> -  Parse the DHCP ACK to get the address configuration and DNS information.
> -
> -  @param[in]       Image            The handle of the driver image.
> -  @param[in]       Controller       The handle of the controller;
> -  @param[in, out]  ConfigData       The session configuration data.
> -
> -  @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.
> -  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.
> -  @retval EFI_NO_MEDIA          There was a media error.
> -  @retval Others                Other errors as indicated.
> -
> -**/
> -EFI_STATUS
> -IScsiDoDhcp (
> -  IN     EFI_HANDLE                 Image,
> -  IN     EFI_HANDLE                 Controller,
> -  IN OUT ISCSI_SESSION_CONFIG_DATA  *ConfigData
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.h
> deleted file mode 100644
> index d6a619f00fc0..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.h
> +++ /dev/null
> @@ -1,140 +0,0 @@
> -/** @file
> -  The header file of IScsiDriver.c.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_DRIVER_H_
> -#define _ISCSI_DRIVER_H_
> -
> -#include <Uefi.h>
> -#include <Protocol/DevicePath.h>
> -#include <Protocol/LoadedImage.h>
> -#include <Protocol/HiiConfigAccess.h>
> -#include <Protocol/HiiDatabase.h>
> -#include <Library/UefiDriverEntryPoint.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/UefiLib.h>
> -#include <Library/DevicePathLib.h>
> -#include <Protocol/DriverBinding.h>
> -#include <Protocol/ScsiPassThruExt.h>
> -
> -#define ISCSI_INITIATOR_NAME_VAR_NAME L"I_NAME"
> -
> -typedef struct _ISCSI_PRIVATE_PROTOCOL {
> -  UINT32  Reserved;
> -} ISCSI_PRIVATE_PROTOCOL;
> -
> -//
> -// EFI Driver Binding Protocol for iSCSI driver.
> -//
> -
> -/**
> -  Tests to see if this driver supports a given controller. If a child device is
> provided,
> -  it further tests to see if this driver supports creating a handle for the specified
> child device.
> -
> -  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle     The handle of the controller to test. This
> handle
> -                                   must support a protocol interface that supplies
> -                                   an I/O abstraction to the driver.
> -  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a
> device path.
> -                                   This parameter is ignored by device drivers, and is optional
> for bus drivers.
> -
> -
> -  @retval EFI_SUCCESS              The device specified by ControllerHandle and
> -                                   RemainingDevicePath is supported by the driver specified by
> This.
> -  @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle
> and
> -                                   RemainingDevicePath is already being managed by the
> driver
> -                                   specified by This.
> -  @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
> -                                   RemainingDevicePath is already being managed by a
> different
> -                                   driver or an application that requires exclusive acces.
> -                                   Currently not implemented.
> -  @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
> -                                   RemainingDevicePath is not supported by the driver
> specified by This.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverBindingSupported (
> -  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
> -  IN EFI_HANDLE                   ControllerHandle,
> -  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
> -  );
> -
> -/**
> -  Start this driver on ControllerHandle. The Start() function is designed to be
> -  invoked from the EFI boot service ConnectController(). As a result, much of
> -  the error checking on the parameters to Start() has been moved into this
> -  common boot service. It is legal to call Start() from other locations,
> -  but the following calling restrictions must be followed or the system behavior
> will not be deterministic.
> -  1. ControllerHandle must be a valid EFI_HANDLE.
> -  2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
> aligned
> -     EFI_DEVICE_PATH_PROTOCOL.
> -  3. Prior to calling Start(), the Supported() function for the driver specified by
> This must
> -     have been called with the same calling parameters, and Supported() must
> have returned EFI_SUCCESS.
> -
> -  @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle     The handle of the controller to start. This
> handle
> -                                   must support a protocol interface that supplies
> -                                   an I/O abstraction to the driver.
> -  @param[in]  RemainingDevicePath  A pointer to the remaining portion of a
> device path.
> -                                   This parameter is ignored by device drivers, and is optional
> for bus drivers.
> -
> -  @retval EFI_SUCCESS              The device was started.
> -  @retval EFI_DEVICE_ERROR         The device could not be started due to a
> device error.
> -                                   Currently not implemented.
> -  @retval EFI_OUT_OF_RESOURCES     The request could not be completed due
> to a lack of resources.
> -  @retval Others                   The driver failded to start the device.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverBindingStart (
> -  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
> -  IN EFI_HANDLE                   ControllerHandle,
> -  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
> -  );
> -
> -/**
> -  Stop this driver on ControllerHandle.
> -
> -  Release the control of this controller and remove the IScsi functions. The Stop()
> -  function is designed to be invoked from the EFI boot service
> DisconnectController().
> -  As a result, much of the error checking on the parameters to Stop() has been
> moved
> -  into this common boot service. It is legal to call Stop() from other locations,
> -  but the following calling restrictions must be followed or the system behavior
> will not be deterministic.
> -  1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous
> call to this
> -     same driver's Start() function.
> -  2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
> -     EFI_HANDLE. In addition, all of these handles must have been created in this
> driver's
> -     Start() function, and the Start() function must have called OpenProtocol() on
> -     ControllerHandle with an Attribute of
> EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
> -
> -  @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL
> instance.
> -  @param[in]  ControllerHandle  A handle to the device being stopped. The
> handle must
> -                                support a bus specific I/O protocol for the driver
> -                                to use to stop the device.
> -  @param[in]  NumberOfChildren  The number of child device handles in
> ChildHandleBuffer.Not used.
> -  @param[in]  ChildHandleBuffer An array of child handles to be freed. May be
> NULL
> -                                if NumberOfChildren is 0.Not used.
> -
> -  @retval EFI_SUCCESS           The device was stopped.
> -  @retval EFI_DEVICE_ERROR      The device could not be stopped due to a
> device error.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiDriverBindingStop (
> -  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
> -  IN EFI_HANDLE                   ControllerHandle,
> -  IN UINTN                        NumberOfChildren,
> -  IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
> deleted file mode 100644
> index 48729e3029f7..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf
> +++ /dev/null
> @@ -1,134 +0,0 @@
> -## @file
> -#  This module produces EFI iSCSI Initiator Name Protocol.
> -#
> -#  This module produces EFI iSCSI Initiator Name Protocol upon EFI TCPv4
> Protocol
> -#  and EFI DHCPv4 Protocol, to provide the capability to do the transport for
> SCSI
> -#  data over TCP/IP. It installs EFI HII Configuration Access Protocol to provide
> -#  one way to configurate the iSCSI setting. This driver only supports IPv4
> network
> -#  stack.
> -#
> -#  Notes:
> -#  1) This driver can't co-work with the IScsiDxe driver in NetworkPkg.
> -#  2) This driver might have some issues that have been fixed in the IScsiDxe
> driver
> -#     in NetworkPkg.
> -#  3) This driver supports fewer features than the IScsiDxe driver in NetworkPkg
> -#     (e.g. IPv6, Dns support for target URL configuration, iSCSI keyword support).
> -#  4) IScsiDxe driver in NetworkPkg is recommended for use instead of this one
> even
> -#     though both of them can be used.
> -#
> -#  Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -#  This program and the accompanying materials
> -#  are licensed and made available under the terms and conditions of the BSD
> License
> -#  which accompanies this distribution.  The full text of the license may be
> found at
> -#  http://opensource.org/licenses/bsd-license.php
> -#
> -#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -#
> -##
> -
> -[Defines]
> -  INF_VERSION                    = 0x00010005
> -  BASE_NAME                      = IScsi4Dxe
> -  MODULE_UNI_FILE                = IScsi4Dxe.uni
> -  FILE_GUID                      = 4579B72D-7EC4-4dd4-8486-083C86B182A7
> -  MODULE_TYPE                    = UEFI_DRIVER
> -  VERSION_STRING                 = 1.0
> -  ENTRY_POINT                    = IScsiDriverEntryPoint
> -  UNLOAD_IMAGE                   = EfiIScsiUnload
> -
> -#
> -# The following information is for reference only and not required by the build
> tools.
> -#
> -#  VALID_ARCHITECTURES           = IA32 X64 EBC
> -#
> -#  DRIVER_BINDING                =  gIScsiDriverBinding
> -#  COMPONENT_NAME                =  gIScsiComponentName
> -#  COMPONENT_NAME2               =  gIScsiComponentName2
> -#
> -
> -[Sources]
> -  IScsiTcp4Io.h
> -  IScsiProto.h
> -  IScsiMisc.h
> -  IScsiIbft.h
> -  IScsiExtScsiPassThru.h
> -  IScsiDriver.h
> -  IScsiDhcp.h
> -  IScsiCommon.h
> -  IScsiCHAP.h
> -  IScsiInitiatorName.h
> -  ComponentName.h
> -  Md5.h
> -  IScsiTcp4Io.c
> -  IScsiProto.c
> -  IScsiMisc.c
> -  IScsiInitiatorName.c
> -  IScsiIbft.c
> -  IScsiExtScsiPassThru.c
> -  IScsiDriver.c
> -  IScsiDhcp.c
> -  IScsiCHAP.c
> -  ComponentName.c
> -  Md5.c
> -  IScsiConfigDxeStrings.uni
> -  IScsiConfigDxe.vfr
> -  IScsiConfig.c
> -  IScsiConfig.h
> -  IScsiImpl.h
> -  IScsiConfigNVDataStruc.h
> -
> -[Packages]
> -  MdePkg/MdePkg.dec
> -  MdeModulePkg/MdeModulePkg.dec
> -
> -[LibraryClasses]
> -  UefiDriverEntryPoint
> -  UefiLib
> -  BaseLib
> -  UefiBootServicesTableLib
> -  UefiRuntimeServicesTableLib
> -  BaseMemoryLib
> -  MemoryAllocationLib
> -  DevicePathLib
> -  DebugLib
> -  PrintLib
> -  HiiLib
> -  NetLib
> -
> -[Protocols]
> -  ## PRODUCES
> -  ## UNDEFINED # Variable
> -  gEfiIScsiInitiatorNameProtocolGuid
> -  gEfiExtScsiPassThruProtocolGuid               ## BY_START
> -  gEfiTcp4ProtocolGuid                          ## TO_START
> -  gEfiTcp4ServiceBindingProtocolGuid            ## TO_START
> -  gEfiDhcp4ProtocolGuid                         ## TO_START
> -  gEfiDhcp4ServiceBindingProtocolGuid           ## TO_START
> -  ## TO_START
> -  ## PRODUCES
> -  gEfiDevicePathProtocolGuid
> -  gEfiHiiConfigAccessProtocolGuid               ## PRODUCES
> -  gEfiHiiDatabaseProtocolGuid                   ## CONSUMES
> -  gEfiPciIoProtocolGuid                         ## SOMETIMES_CONSUMES
> -  gEfiAcpiTableProtocolGuid                     ## SOMETIMES_CONSUMES
> -
> -[Guids]
> -  gEfiEventExitBootServicesGuid                 ## SOMETIMES_CONSUMES ## Event
> -  gEfiIfrTianoGuid                              ## SOMETIMES_PRODUCES ## UNDEFINED
> -  gEfiAcpiTableGuid                             ## SOMETIMES_CONSUMES ## SystemTable
> -  gEfiAcpi10TableGuid                           ## SOMETIMES_CONSUMES ##
> SystemTable
> -  ## SOMETIMES_PRODUCES ## Variable:L"iSCSIDeviceList"
> -  ## SOMETIMES_CONSUMES ## Variable:L"iSCSIDeviceList"
> -  ## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch
> mVendorStorageName
> -  ## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr
> mVendorStorageName
> -  ## SOMETIMES_PRODUCES ## UNDEFINED # HiiGetBrowserData
> mVendorStorageName
> -  ## SOMETIMES_CONSUMES ## UNDEFINED # HiiSetBrowserData
> mVendorStorageName
> -  ## SOMETIMES_CONSUMES ## HII
> -  gIp4IScsiConfigGuid
> -  ## SOMETIMES_PRODUCES ## Variable
> -  ## SOMETIMES_CONSUMES ## Variable
> -  gIScsiCHAPAuthInfoGuid
> -
> -[UserExtensions.TianoCore."ExtraFiles"]
> -  IScsi4DxeExtra.uni
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.h
> deleted file mode 100644
> index e635e47b9292..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/** @file
> -  The header file of IScsiExtScsiPassThru.c.
> -
> -Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_EXT_SCSI_PASS_THRU_H_
> -#define _ISCSI_EXT_SCSI_PASS_THRU_H_
> -
> -#include <Protocol/ScsiPassThruExt.h>
> -
> -extern EFI_EXT_SCSI_PASS_THRU_PROTOCOL
> gIScsiExtScsiPassThruProtocolTemplate;
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.h
> deleted file mode 100644
> index 4f3828db63c6..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.h
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -/** @file
> -  Some extra definitions for iBFT.
> -
> -Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_IBFT_H_
> -#define _ISCSI_IBFT_H_
> -
> -#include <IndustryStandard/Acpi.h>
> -#include <IndustryStandard/IScsiBootFirmwareTable.h>
> -#include <Protocol/AcpiTable.h>
> -#include <Protocol/PciIo.h>
> -
> -#define IBFT_TABLE_VAR_NAME L"iBFT"
> -#define IBFT_MAX_SIZE       4096
> -#define IBFT_HEAP_OFFSET    2048
> -
> -#define IBFT_ROUNDUP(size)  NET_ROUNDUP ((size),
> EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_ALIGNMENT)
> -
> -/**
> -  Publish and remove the iSCSI Boot Firmware Table according to the iSCSI
> -  session status.
> -**/
> -VOID
> -IScsiPublishIbft (
> -  VOID
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiImpl.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiImpl.h
> deleted file mode 100644
> index 8a5ee2149eb2..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiImpl.h
> +++ /dev/null
> @@ -1,168 +0,0 @@
> -/** @file
> -  The header file of IScsiImpl.c.
> -
> -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_IMPL_H_
> -#define _ISCSI_IMPL_H_
> -
> -#include <Uefi.h>
> -
> -#include <IndustryStandard/Dhcp.h>
> -
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/NetLib.h>
> -#include <Library/PrintLib.h>
> -#include <Library/UefiRuntimeServicesTableLib.h>
> -
> -#include <Guid/EventGroup.h>
> -
> -#include "IScsiCommon.h"
> -#include "IScsiDriver.h"
> -#include "IScsiInitiatorName.h"
> -#include "ComponentName.h"
> -#include "IScsiConfigNVDataStruc.h"
> -#include "IScsiExtScsiPassThru.h"
> -#include "IScsiProto.h"
> -#include "IScsiMisc.h"
> -#include "IScsiCHAP.h"
> -#include "IScsiConfig.h"
> -#include "IScsiDhcp.h"
> -#include "IScsiTcp4Io.h"
> -#include "IScsiIbft.h"
> -
> -
> -#define ISCSI_SESSION_SIGNATURE SIGNATURE_32 ('I', 'S', 'S', 'N')
> -
> -struct _ISCSI_SESSION {
> -  UINT32                    Signature;
> -
> -  ISCSI_SESSION_CONFIG_DATA ConfigData;
> -  ISCSI_CHAP_AUTH_DATA      AuthData;
> -
> -  CHAR8                     InitiatorName[ISCSI_NAME_MAX_SIZE];
> -  UINTN                     InitiatorNameLength;
> -  UINT8                     State;
> -
> -  UINT8                     Isid[6];
> -  UINT16                    Tsih;
> -
> -  UINT32                    CmdSN;
> -  UINT32                    ExpCmdSN;
> -  UINT32                    MaxCmdSN;
> -
> -  UINT32                    InitiatorTaskTag;
> -  UINT16                    NextCid;
> -
> -  LIST_ENTRY                Conns;
> -  UINT32                    NumConns;
> -
> -  LIST_ENTRY                TcbList;
> -
> -  //
> -  // session-wide parameters
> -  //
> -  UINT16                    TargetPortalGroupTag;
> -  UINT32                    MaxConnections;
> -  BOOLEAN                   InitialR2T;
> -  BOOLEAN                   ImmediateData;
> -  UINT32                    MaxBurstLength;
> -  UINT32                    FirstBurstLength;
> -  UINT32                    DefaultTime2Wait;
> -  UINT32                    DefaultTime2Retain;
> -  UINT16                    MaxOutstandingR2T;
> -  BOOLEAN                   DataPDUInOrder;
> -  BOOLEAN                   DataSequenceInOrder;
> -  UINT8                     ErrorRecoveryLevel;
> -};
> -
> -#define ISCSI_CONNECTION_SIGNATURE  SIGNATURE_32 ('I', 'S', 'C', 'N')
> -
> -struct _ISCSI_CONNECTION {
> -  UINT32            Signature;
> -  LIST_ENTRY        Link;
> -
> -  EFI_EVENT         TimeoutEvent;
> -
> -  ISCSI_SESSION     *Session;
> -
> -  UINT8             State;
> -  UINT8             CurrentStage;
> -  UINT8             NextStage;
> -
> -  UINT8             CHAPStep;
> -
> -  BOOLEAN           PartialReqSent;
> -  BOOLEAN           PartialRspRcvd;
> -
> -  BOOLEAN           TransitInitiated;
> -
> -  UINT16            Cid;
> -  UINT32            ExpStatSN;
> -
> -  //
> -  // queues...
> -  //
> -  NET_BUF_QUEUE     RspQue;
> -
> -  TCP4_IO           Tcp4Io;
> -
> -  //
> -  // connection-only parameters
> -  //
> -  UINT32            MaxRecvDataSegmentLength;
> -  ISCSI_DIGEST_TYPE HeaderDigest;
> -  ISCSI_DIGEST_TYPE DataDigest;
> -};
> -
> -#define ISCSI_DRIVER_DATA_SIGNATURE SIGNATURE_32 ('I', 'S', 'D', 'A')
> -
> -#define ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU(PassThru) \
> -  CR ( \
> -  PassThru, \
> -  ISCSI_DRIVER_DATA, \
> -  IScsiExtScsiPassThru, \
> -  ISCSI_DRIVER_DATA_SIGNATURE \
> -  )
> -#define ISCSI_DRIVER_DATA_FROM_IDENTIFIER(Identifier) \
> -  CR ( \
> -  Identifier, \
> -  ISCSI_DRIVER_DATA, \
> -  IScsiIdentifier, \
> -  ISCSI_DRIVER_DATA_SIGNATURE \
> -  )
> -#define ISCSI_DRIVER_DATA_FROM_SESSION(s) \
> -  CR ( \
> -  s, \
> -  ISCSI_DRIVER_DATA, \
> -  Session, \
> -  ISCSI_DRIVER_DATA_SIGNATURE \
> -  )
> -
> -struct _ISCSI_DRIVER_DATA {
> -  UINT32                          Signature;
> -  EFI_HANDLE                      Image;
> -  EFI_HANDLE                      Controller;
> -  ISCSI_PRIVATE_PROTOCOL          IScsiIdentifier;
> -  EFI_HANDLE                      ChildHandle;
> -  EFI_EVENT                       ExitBootServiceEvent;
> -
> -  EFI_EXT_SCSI_PASS_THRU_PROTOCOL IScsiExtScsiPassThru;
> -  EFI_EXT_SCSI_PASS_THRU_MODE     ExtScsiPassThruMode;
> -  EFI_HANDLE                      ExtScsiPassThruHandle;
> -  EFI_DEVICE_PATH_PROTOCOL        *DevicePath;
> -
> -  ISCSI_SESSION                   Session;
> -};
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.h
> deleted file mode 100644
> index f967fb383095..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiInitiatorName.h
> +++ /dev/null
> @@ -1,74 +0,0 @@
> -/** @file
> -  The header file for EFI iSCSI Initiator Name Protocol.
> -
> -Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_INITIATOR_NAME_H_
> -#define _ISCSI_INITIATOR_NAME_H_
> -
> -#include <Protocol/IScsiInitiatorName.h>
> -
> -extern EFI_ISCSI_INITIATOR_NAME_PROTOCOL  gIScsiInitiatorName;
> -
> -//
> -// EFI iSCSI Initiator Name Protocol for IScsi driver.
> -//
> -
> -/**
> -  Retrieves the current set value of iSCSI Initiator Name.
> -
> -  @param[in]       This       Pointer to the
> EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
> -  @param[in, out]  BufferSize Size of the buffer in bytes pointed to by Buffer /
> Actual size of the
> -                              variable data buffer.
> -  @param[out]      Buffer     Pointer to the buffer for data to be read.
> -
> -  @retval EFI_SUCCESS           Data was successfully retrieved into the provided
> buffer and the
> -                                BufferSize was sufficient to handle the iSCSI initiator name.
> -  @retval EFI_BUFFER_TOO_SMALL  BufferSize is too small for the result.
> -  @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL.
> -  @retval EFI_DEVICE_ERROR      The iSCSI initiator name could not be retrieved
> due to a hardware error.
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiGetInitiatorName (
> -  IN     EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *This,
> -  IN OUT UINTN                              *BufferSize,
> -  OUT    VOID                               *Buffer
> -  );
> -
> -/**
> -  Sets the iSCSI Initiator Name.
> -
> -  @param[in]       This       Pointer to the
> EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
> -  @param[in, out]  BufferSize Size of the buffer in bytes pointed to by Buffer.
> -  @param[in]       Buffer     Pointer to the buffer for data to be written.
> -
> -  @retval EFI_SUCCESS           Data was successfully stored by the protocol.
> -  @retval EFI_UNSUPPORTED       Platform policies do not allow for data to be
> written.
> -                                Currently not implemented.
> -  @retval EFI_INVALID_PARAMETER BufferSize or Buffer is NULL, or BufferSize
> exceeds the maximum allowed limit.
> -  @retval EFI_DEVICE_ERROR      The data could not be stored due to a
> hardware error.
> -  @retval EFI_OUT_OF_RESOURCES  Not enough storage is available to hold
> the data.
> -  @retval EFI_PROTOCOL_ERROR    Input iSCSI initiator name does not adhere
> to RFC 3720
> -                                (and other related protocols).
> -  @retval Others                Other errors as indicated.
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiSetInitiatorName (
> -  IN     EFI_ISCSI_INITIATOR_NAME_PROTOCOL  *This,
> -  IN OUT UINTN                              *BufferSize,
> -  IN     VOID                               *Buffer
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
> deleted file mode 100644
> index 500e00373b25..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
> +++ /dev/null
> @@ -1,317 +0,0 @@
> -/** @file
> -  Miscellaneous definitions for iSCSI driver.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_MISC_H_
> -#define _ISCSI_MISC_H_
> -
> -#include <Library/BaseLib.h>
> -
> -typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA;
> -
> -///
> -/// IPv4 Device Path Node Length
> -///
> -#define IP4_NODE_LEN_NEW_VERSIONS    27
> -
> -#pragma pack(1)
> -typedef struct {
> -  BOOLEAN           Enabled;
> -
> -  BOOLEAN           InitiatorInfoFromDhcp;
> -  EFI_IPv4_ADDRESS  LocalIp;
> -  EFI_IPv4_ADDRESS  SubnetMask;
> -  EFI_IPv4_ADDRESS  Gateway;
> -
> -  BOOLEAN           TargetInfoFromDhcp;
> -  CHAR8             TargetName[ISCSI_NAME_MAX_SIZE];
> -  EFI_IPv4_ADDRESS  TargetIp;
> -  UINT16            TargetPort;
> -  UINT8             BootLun[8];
> -
> -  UINT8             IsId[6];
> -} ISCSI_SESSION_CONFIG_NVDATA;
> -#pragma pack()
> -
> -struct _ISCSI_SESSION_CONFIG_DATA {
> -  ISCSI_SESSION_CONFIG_NVDATA NvData;
> -
> -  EFI_IPv4_ADDRESS            PrimaryDns;
> -  EFI_IPv4_ADDRESS            SecondaryDns;
> -  EFI_IPv4_ADDRESS            DhcpServer;
> -};
> -
> -/**
> -  Calculate the prefix length of the IPv4 subnet mask.
> -
> -  @param[in]  SubnetMask The IPv4 subnet mask.
> -
> -  @return The prefix length of the subnet mask.
> -  @retval 0 Other errors as indicated.
> -**/
> -UINT8
> -IScsiGetSubnetMaskPrefixLength (
> -  IN EFI_IPv4_ADDRESS  *SubnetMask
> -  );
> -
> -/**
> -  Convert the hexadecimal encoded LUN string into the 64-bit LUN.
> -
> -  @param[in]   Str             The hexadecimal encoded LUN string.
> -  @param[out]  Lun             Storage to return the 64-bit LUN.
> -
> -  @retval EFI_SUCCESS           The 64-bit LUN is stored in Lun.
> -  @retval EFI_INVALID_PARAMETER The string is malformatted.
> -**/
> -EFI_STATUS
> -IScsiAsciiStrToLun (
> -  IN  CHAR8  *Str,
> -  OUT UINT8  *Lun
> -  );
> -
> -/**
> -  Convert the 64-bit LUN into the hexadecimal encoded LUN string.
> -
> -  @param[in]   Lun The 64-bit LUN.
> -  @param[out]  Str The storage to return the hexadecimal encoded LUN string.
> -**/
> -VOID
> -IScsiLunToUnicodeStr (
> -  IN UINT8    *Lun,
> -  OUT CHAR16  *Str
> -  );
> -
> -/**
> -  Convert the ASCII string into a UNICODE string.
> -
> -  @param[in]   Source      The ASCII string.
> -  @param[out]  Destination The storage to return the UNICODE string.
> -
> -  @return CHAR16 *         Pointer to the UNICODE string.
> -**/
> -CHAR16 *
> -IScsiAsciiStrToUnicodeStr (
> -  IN  CHAR8   *Source,
> -  OUT CHAR16  *Destination
> -  );
> -
> -/**
> -  Convert the UNICODE string into an ASCII string.
> -
> -  @param[in]  Source       The UNICODE string.
> -  @param[out] Destination  The storage to return the ASCII string.
> -
> -  @return CHAR8 *          Pointer to the ASCII string.
> -**/
> -CHAR8 *
> -IScsiUnicodeStrToAsciiStr (
> -  IN  CHAR16  *Source,
> -  OUT CHAR8   *Destination
> -  );
> -
> -/**
> -  Convert the mac address into a hexadecimal encoded "-" seperated string.
> -
> -  @param[in]  Mac     The mac address.
> -  @param[in]  Len     Length in bytes of the mac address.
> -  @param[in]  VlanId  VLAN ID of the network device.
> -  @param[out] Str     The storage to return the mac string.
> -**/
> -VOID
> -IScsiMacAddrToStr (
> -  IN  EFI_MAC_ADDRESS  *Mac,
> -  IN  UINT32           Len,
> -  IN  UINT16           VlanId,
> -  OUT CHAR16           *Str
> -  );
> -
> -/**
> -  Convert the decimal dotted IPv4 address into the binary IPv4 address.
> -
> -  @param[in]   Str             The UNICODE string.
> -  @param[out]  Ip              The storage to return the ASCII string.
> -
> -  @retval EFI_SUCCESS           The binary IP address is returned in Ip.
> -  @retval EFI_INVALID_PARAMETER The IP string is malformatted.
> -**/
> -EFI_STATUS
> -IScsiAsciiStrToIp (
> -  IN  CHAR8             *Str,
> -  OUT EFI_IPv4_ADDRESS  *Ip
> -  );
> -
> -/**
> -  Convert the binary encoded buffer into a hexadecimal encoded string.
> -
> -  @param[in]       BinBuffer   The buffer containing the binary data.
> -  @param[in]       BinLength   Length of the binary buffer.
> -  @param[in, out]  HexStr      Pointer to the string.
> -  @param[in, out]  HexLength   The length of the string.
> -
> -  @retval EFI_SUCCESS          The binary data is converted to the hexadecimal
> string
> -                               and the length of the string is updated.
> -  @retval EFI_BUFFER_TOO_SMALL The string is too small.
> -  @retval EFI_INVALID_PARAMETER The IP string is malformatted.
> -**/
> -EFI_STATUS
> -IScsiBinToHex (
> -  IN     UINT8  *BinBuffer,
> -  IN     UINT32 BinLength,
> -  IN OUT CHAR8  *HexStr,
> -  IN OUT UINT32 *HexLength
> -  );
> -
> -/**
> -  Convert the hexadecimal string into a binary encoded buffer.
> -
> -  @param[in, out]  BinBuffer   The binary buffer.
> -  @param[in, out]  BinLength   Length of the binary buffer.
> -  @param[in]       HexStr      The hexadecimal string.
> -
> -  @retval EFI_SUCCESS          The hexadecimal string is converted into a binary
> -                               encoded buffer.
> -  @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the
> converted data.
> -**/
> -EFI_STATUS
> -IScsiHexToBin (
> -  IN OUT UINT8  *BinBuffer,
> -  IN OUT UINT32 *BinLength,
> -  IN     CHAR8  *HexStr
> -  );
> -
> -/**
> -  Generate random numbers.
> -
> -  @param[in, out]  Rand       The buffer to contain random numbers.
> -  @param[in]       RandLength The length of the Rand buffer.
> -**/
> -VOID
> -IScsiGenRandom (
> -  IN OUT UINT8  *Rand,
> -  IN     UINTN  RandLength
> -  );
> -
> -/**
> -  Create the iSCSI driver data..
> -
> -  @param[in] Image      The handle of the driver image.
> -  @param[in] Controller The handle of the controller.
> -
> -  @return The iSCSI driver data created.
> -  @retval NULL Other errors as indicated.
> -**/
> -ISCSI_DRIVER_DATA *
> -IScsiCreateDriverData (
> -  IN EFI_HANDLE  Image,
> -  IN EFI_HANDLE  Controller
> -  );
> -
> -/**
> -  Clean the iSCSI driver data.
> -
> -  @param[in]               Private The iSCSI driver data.
> -
> -  @retval EFI_SUCCES       The clean operation is successful.
> -  @retval Others           Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiCleanDriverData (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  );
> -
> -/**
> -  Check wheather the Controller is configured to use DHCP protocol.
> -
> -  @param[in]  Controller           The handle of the controller.
> -
> -  @retval TRUE                     The handle of the controller need the Dhcp protocol.
> -  @retval FALSE                    The handle of the controller does not need the Dhcp
> protocol.
> -
> -**/
> -BOOLEAN
> -IScsiDhcpIsConfigured (
> -  IN EFI_HANDLE  Controller
> -  );
> -
> -/**
> -  Get the various configuration data of this iSCSI instance.
> -
> -  @param[in]  Private   The iSCSI driver data.
> -
> -  @retval EFI_SUCCESS   The configuration of this instance is got.
> -  @retval EFI_ABORTED   The operation was aborted.
> -  @retval Others        Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiGetConfigData (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  );
> -
> -/**
> -  Get the device path of the iSCSI tcp connection and update it.
> -
> -  @param[in]  Private The iSCSI driver data.
> -
> -  @return The updated device path.
> -  @retval NULL Other errors as indicated.
> -**/
> -EFI_DEVICE_PATH_PROTOCOL *
> -IScsiGetTcpConnDevicePath (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  );
> -
> -/**
> -  Abort the session when the transition from BS to RT is initiated.
> -
> -  @param[in]   Event  The event signaled.
> -  @param[in]  Context The iSCSI driver data.
> -**/
> -VOID
> -EFIAPI
> -IScsiOnExitBootService (
> -  IN EFI_EVENT  Event,
> -  IN VOID       *Context
> -  );
> -
> -/**
> -  Tests whether a controller handle is being managed by IScsi driver.
> -
> -  This function tests whether the driver specified by DriverBindingHandle is
> -  currently managing the controller specified by ControllerHandle.  This test
> -  is performed by evaluating if the the protocol specified by ProtocolGuid is
> -  present on ControllerHandle and is was opened by DriverBindingHandle and
> Nic
> -  Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
> -  If ProtocolGuid is NULL, then ASSERT().
> -
> -  @param  ControllerHandle     A handle for a controller to test.
> -  @param  DriverBindingHandle  Specifies the driver binding handle for the
> -                               driver.
> -  @param  ProtocolGuid         Specifies the protocol that the driver specified
> -                               by DriverBindingHandle opens in its Start()
> -                               function.
> -
> -  @retval EFI_SUCCESS          ControllerHandle is managed by the driver
> -                               specified by DriverBindingHandle.
> -  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver
> -                               specified by DriverBindingHandle.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -IScsiTestManagedDevice (
> -  IN  EFI_HANDLE       ControllerHandle,
> -  IN  EFI_HANDLE       DriverBindingHandle,
> -  IN  EFI_GUID         *ProtocolGuid
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
> deleted file mode 100644
> index 6469df0434a1..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h
> +++ /dev/null
> @@ -1,1005 +0,0 @@
> -/** @file
> -  The header file of iSCSI Protocol that defines many specific data structures.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_PROTO_H_
> -#define _ISCSI_PROTO_H_
> -
> -#include <Protocol/ScsiPassThruExt.h>
> -
> -//
> -// RFC 1982 Serial Number Arithmetic, SERIAL_BITS = 32
> -//
> -#define ISCSI_SEQ_EQ(s1, s2)  ((s1) == (s2))
> -#define ISCSI_SEQ_LT(s1, s2) \
> -    ( \
> -      (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) < ((UINT32) 1 << 31)) || \
> -      (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) > ((UINT32) 1 << 31)) \
> -    )
> -#define ISCSI_SEQ_GT(s1, s2) \
> -    ( \
> -      (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) > ((UINT32) 1 << 31)) || \
> -      (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) < ((UINT32) 1 << 31)) \
> -    )
> -
> -#define ISCSI_WELL_KNOWN_PORT                   3260
> -#define ISCSI_MAX_CONNS_PER_SESSION             1
> -
> -#define DEFAULT_MAX_RECV_DATA_SEG_LEN           8192
> -#define MAX_RECV_DATA_SEG_LEN_IN_FFP            65536
> -#define DEFAULT_MAX_OUTSTANDING_R2T             1
> -
> -#define ISCSI_VERSION_MAX                       0x00
> -#define ISCSI_VERSION_MIN                       0x00
> -
> -#define ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME
> EFI_TIMER_PERIOD_SECONDS(20)
> -#define ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME
> EFI_TIMER_PERIOD_SECONDS(20)
> -
> -#define ISCSI_KEY_AUTH_METHOD                   "AuthMethod"
> -#define ISCSI_KEY_HEADER_DIGEST                 "HeaderDigest"
> -#define ISCSI_KEY_DATA_DIGEST                   "DataDigest"
> -#define ISCSI_KEY_MAX_CONNECTIONS               "MaxConnections"
> -#define ISCSI_KEY_TARGET_NAME                   "TargetName"
> -#define ISCSI_KEY_INITIATOR_NAME                "InitiatorName"
> -#define ISCSI_KEY_TARGET_ALIAS                  "TargetAlias"
> -#define ISCSI_KEY_INITIATOR_ALIAS               "InitiatorAlias"
> -#define ISCSI_KEY_TARGET_ADDRESS                "TargetAddress"
> -#define ISCSI_KEY_INITIAL_R2T                   "InitialR2T"
> -#define ISCSI_KEY_IMMEDIATE_DATA                "ImmediateData"
> -#define ISCSI_KEY_TARGET_PORTAL_GROUP_TAG       "TargetPortalGroupTag"
> -#define ISCSI_KEY_MAX_BURST_LENGTH              "MaxBurstLength"
> -#define ISCSI_KEY_FIRST_BURST_LENGTH            "FirstBurstLength"
> -#define ISCSI_KEY_DEFAULT_TIME2WAIT             "DefaultTime2Wait"
> -#define ISCSI_KEY_DEFAULT_TIME2RETAIN           "DefaultTime2Retain"
> -#define ISCSI_KEY_MAX_OUTSTANDING_R2T           "MaxOutstandingR2T"
> -#define ISCSI_KEY_DATA_PDU_IN_ORDER             "DataPDUInOrder"
> -#define ISCSI_KEY_DATA_SEQUENCE_IN_ORDER        "DataSequenceInOrder"
> -#define ISCSI_KEY_ERROR_RECOVERY_LEVEL          "ErrorRecoveryLevel"
> -#define ISCSI_KEY_SESSION_TYPE                  "SessionType"
> -#define ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH
> "MaxRecvDataSegmentLength"
> -
> -#define ISCSI_KEY_VALUE_NONE                    "None"
> -
> -///
> -/// connection state for initiator
> -///
> -
> -#define CONN_STATE_FREE                         0
> -#define CONN_STATE_XPT_WAIT                     1
> -#define CONN_STATE_IN_LOGIN                     2
> -#define CONN_STATE_LOGGED_IN                    3
> -#define CONN_STATE_IN_LOGOUT                    4
> -#define CONN_STATE_LOGOUT_REQUESTED             5
> -#define CONN_STATE_CLEANUP_WAIT                 6
> -#define CONN_STATE_IN_CLEANUP                   7
> -
> -///
> -/// session state for initiator
> -///
> -#define SESSION_STATE_FREE                      0
> -#define SESSION_STATE_LOGGED_IN                 1
> -#define SESSION_STATE_FAILED                    2
> -
> -typedef enum {
> -  DataIn  = 0,
> -  DataOut = 1,
> -  DataBi  = 2
> -} DATA_DIRECTION;
> -
> -#define ISCSI_RESERVED_TAG                  0xffffffff
> -
> -#define ISCSI_REQ_IMMEDIATE                 0x40
> -#define ISCSI_OPCODE_MASK                   0x3F
> -
> -#define ISCSI_SET_OPCODE(PduHdr, Op, Flgs)  ((((ISCSI_BASIC_HEADER *)
> (PduHdr))->OpCode) = ((Op) | (Flgs)))
> -#define ISCSI_GET_OPCODE(PduHdr)            ((((ISCSI_BASIC_HEADER *)
> (PduHdr))->OpCode) & ISCSI_OPCODE_MASK)
> -#define ISCSI_CHECK_OPCODE(PduHdr, Op)      ((((PduHdr)->OpCode) &
> ISCSI_OPCODE_MASK) == (Op))
> -#define ISCSI_IMMEDIATE_ON(PduHdr)          ((PduHdr)->OpCode &
> ISCSI_REQ_IMMEDIATE)
> -#define ISCSI_SET_FLAG(PduHdr, Flag)        (((ISCSI_BASIC_HEADER *) (PduHdr))-
> >Flags |= (BOOLEAN)(Flag))
> -#define ISCSI_CLEAR_FLAG(PduHdr, Flag)      (((ISCSI_BASIC_HEADER *)
> (PduHdr))->Flags &= ~(Flag))
> -#define ISCSI_FLAG_ON(PduHdr, Flag)         ((((ISCSI_BASIC_HEADER *)
> (PduHdr))->Flags & (Flag)) == (Flag))
> -#define ISCSI_SET_STAGES(PduHdr, Cur, Nxt)  ((PduHdr)->Flags = (UINT8)
> ((PduHdr)->Flags | ((Cur) << 2 | (Nxt))))
> -#define ISCSI_GET_CURRENT_STAGE(PduHdr)     (((PduHdr)->Flags >> 2) & 0x3)
> -#define ISCSI_GET_NEXT_STAGE(PduHdr)        (((PduHdr)->Flags) & 0x3)
> -
> -#define ISCSI_GET_PAD_LEN(DataLen)          ((~(DataLen) + 1) & 0x3)
> -#define ISCSI_ROUNDUP(DataLen)              (((DataLen) + 3) &~(0x3))
> -
> -#define HTON24(Dst, Src) \
> -  do { \
> -    (Dst)[0]  = (UINT8) (((Src) >> 16) & 0xFF); \
> -    (Dst)[1]  = (UINT8) (((Src) >> 8) & 0xFF); \
> -    (Dst)[2]  = (UINT8) ((Src) & 0xFF); \
> -  } while (0);
> -
> -#define NTOH24(src)                         (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))
> -
> -#define ISCSI_GET_DATASEG_LEN(PduHdr)       NTOH24 (((ISCSI_BASIC_HEADER
> *) (PduHdr))->DataSegmentLength)
> -#define ISCSI_SET_DATASEG_LEN(PduHdr, Len)  HTON24
> (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength, (Len))
> -
> -//
> -// initiator opcodes
> -//
> -#define ISCSI_OPCODE_NOP_OUT        0x00
> -#define ISCSI_OPCODE_SCSI_CMD       0x01
> -#define ISCSI_OPCODE_SCSI_TMF_REQ   0x02
> -#define ISCSI_OPCODE_LOGIN_REQ      0x03
> -#define ISCSI_OPCODE_TEXT_REQ       0x04
> -#define ISCSI_OPCODE_SCSI_DATA_OUT  0x05
> -#define ISCSI_OPCODE_LOGOUT_REQ     0x06
> -#define ISCSI_OPCODE_SNACK_REQ      0x10
> -#define ISCSI_OPCODE_VENDOR_I0      0x1c
> -#define ISCSI_OPCODE_VENDOR_I1      0x1d
> -#define ISCSI_OPCODE_VENDOR_I2      0x1e
> -
> -//
> -// target opcodes
> -//
> -#define ISCSI_OPCODE_NOP_IN       0x20
> -#define ISCSI_OPCODE_SCSI_RSP     0x21
> -#define ISCSI_OPCODE_SCSI_TMF_RSP 0x22
> -#define ISCSI_OPCODE_LOGIN_RSP    0x23
> -#define ISCSI_OPCODE_TEXT_RSP     0x24
> -#define ISCSI_OPCODE_SCSI_DATA_IN 0x25
> -#define ISCSI_OPCODE_LOGOUT_RSP   0x26
> -#define ISCSI_OPCODE_R2T          0x31
> -#define ISCSI_OPCODE_ASYNC_MSG    0x32
> -#define ISCSI_OPCODE_VENDOR_T0    0x3c
> -#define ISCSI_OPCODE_VENDOR_T1    0x3d
> -#define ISCSI_OPCODE_VENDOR_T2    0x3e
> -#define ISCSI_OPCODE_REJECT       0x3f
> -
> -#define ISCSI_BHS_FLAG_FINAL      0x80
> -
> -///
> -/// iSCSI Basic Header Segment
> -///
> -typedef struct _ISCSI_BASIC_HEADER {
> -  UINT8   OpCode;
> -  UINT8   Flags;
> -  UINT16  OpCodeSpecific1;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  OpCodeSpecific2[7];
> -} ISCSI_BASIC_HEADER;
> -
> -//
> -// Defined AHS types, others are reserved.
> -//
> -#define ISCSI_AHS_TYPE_EXT_CDB              0x1
> -#define ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN 0x2
> -
> -typedef struct _ISCSI_ADDTIONAL_HEADER {
> -  UINT16  Length;
> -  UINT8   Type;
> -  UINT8   TypeSpecific[1];
> -} ISCSI_ADDITIONAL_HEADER;
> -
> -typedef struct _ISCSI_BI_EXP_READ_DATA_LEN_AHS {
> -  UINT16  Length;
> -  UINT8   Type;
> -  UINT8   Reserved;
> -  UINT32  ExpReadDataLength;
> -} ISCSI_BI_EXP_READ_DATA_LEN_AHS;
> -
> -#define SCSI_CMD_PDU_FLAG_READ        0x40
> -#define SCSI_CMD_PDU_FLAG_WRITE       0x20
> -
> -#define ISCSI_CMD_PDU_TASK_ATTR_MASK  0x07
> -
> -//
> -// task attributes
> -//
> -#define ISCSI_TASK_ATTR_UNTAGGED  0x00
> -#define ISCSI_TASK_ATTR_SIMPLE    0x01
> -#define ISCSI_TASK_ATTR_ORDERD    0x02
> -#define ISCSI_TASK_ATTR_HOQ       0x03
> -#define ISCSI_TASK_ATTR_ACA       0x04
> -
> -///
> -/// SCSI Command
> -///
> -typedef struct _SCSI_COMMAND {
> -  UINT8   OpCode;
> -  UINT8   Flags;
> -  UINT16  Reserved;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  ExpDataXferLength;
> -  UINT32  CmdSN;
> -  UINT32  ExpStatSN;
> -  UINT8   Cdb[16];
> -} SCSI_COMMAND;
> -
> -//
> -// flag bit definitions in SCSI response
> -//
> -#define SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW  0x10
> -#define SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW 0x08
> -#define SCSI_RSP_PDU_FLAG_OVERFLOW          0x04
> -#define SCSI_RSP_PDU_FLAG_UNDERFLOW         0x02
> -
> -//
> -// iSCSI service response codes
> -//
> -#define ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET  0x00
> -#define ISCSI_SERVICE_RSP_TARGET_FAILURE              0x01
> -
> -///
> -/// SCSI Response
> -///
> -typedef struct _SCSI_RESPONSE {
> -  UINT8   OpCode;
> -  UINT8   Flags;
> -  UINT8   Response;
> -  UINT8   Status;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Reserved[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  SNACKTag;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  ExpDataSN;
> -  UINT32  BiReadResidualCount;
> -  UINT32  ResidualCount;
> -} SCSI_RESPONSE;
> -
> -typedef struct _ISCSI_SENSE_DATA {
> -  UINT16  Length;
> -  UINT8   Data[2];
> -} ISCSI_SENSE_DATA;
> -
> -///
> -/// iSCSI Task Managment Function Request
> -///
> -typedef struct _ISCSI_TMF_REQUEST {
> -  UINT8   OpCode;
> -  UINT8   Fuction;
> -  UINT16  Reserved1;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  ReferencedTaskTag;
> -  UINT32  CmdSN;
> -  UINT32  ExpStatSN;
> -  UINT32  RefCmdSN;
> -  UINT32  ExpDataSN;
> -  UINT32  Reserved2[2];
> -} ISCSI_TMF_REQUEST;
> -
> -#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_COMPLETE           0
> -#define ISCSI_TMF_RSP_PDU_RSP_TASK_NOT_EXIST              1
> -#define ISCSI_TMF_RSP_PDU_RSP_LUN_NOT_EXIST               2
> -#define ISCSI_TMF_RSP_PDU_RSP_TASK_STILL_ALLEGIANT        3
> -#define ISCSI_TMF_RSP_PDU_RSP_TASK_REASSGIN_NOT_SUPPORTED 4
> -#define ISCSI_TMF_RSP_PDU_RSP_NOT_SUPPORTED               5
> -#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_AHTH_FAILED        6
> -#define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_REJECTED           255
> -
> -///
> -/// iSCSI Task Management Function Response
> -///
> -typedef struct _ISCSI_TMF_RESPONSE {
> -  UINT8   OpCode;
> -  UINT8   Reserved1;
> -  UINT8   Response;
> -  UINT8   Reserved2;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT32  Reserver3[2];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  Reserved4;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  Reserved[3];
> -} ISCSI_TMF_RESPONSE;
> -
> -///
> -/// SCSI Data-Out
> -///
> -typedef struct _ISCSI_SCSI_DATA_OUT {
> -  UINT8   OpCode;
> -  UINT8   Reserved1[3];
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  TargetTransferTag;
> -  UINT32  Reserved2;
> -  UINT32  ExpStatSN;
> -  UINT32  Reserved3;
> -  UINT32  DataSN;
> -  UINT32  BufferOffset;
> -  UINT32  Reserved4;
> -} ISCSI_SCSI_DATA_OUT;
> -
> -#define SCSI_DATA_IN_PDU_FLAG_ACKKNOWLEDGE  0x40
> -#define SCSI_DATA_IN_PDU_FLAG_OVERFLOW
> SCSI_RSP_PDU_FLAG_OVERFLOW
> -#define SCSI_DATA_IN_PDU_FLAG_UNDERFLOW
> SCSI_RSP_PDU_FLAG_UNDERFLOW
> -#define SCSI_DATA_IN_PDU_FLAG_STATUS_VALID  0x01
> -
> -///
> -/// SCSI Data-In
> -///
> -typedef struct _ISCSI_SCSI_DATA_IN {
> -  UINT8   OpCode;
> -  UINT8   Flags;
> -  UINT8   Reserved1;
> -  UINT8   Status;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  TargetTransferTag;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  DataSN;
> -  UINT32  BufferOffset;
> -  UINT32  ResidualCount;
> -} ISCSI_SCSI_DATA_IN;
> -
> -#define ISCSI_GET_BUFFER_OFFSET(PduHdr) NTOHL (((ISCSI_SCSI_DATA_IN *)
> (PduHdr))->BufferOffset)
> -
> -///
> -/// Ready To Transfer
> -///
> -typedef struct _ISCSI_READY_TO_TRANSFER {
> -  UINT8   OpCode;
> -  UINT8   Reserved1[3];
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  TargetTransferTag;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  R2TSeqNum;
> -  UINT32  BufferOffset;
> -  UINT32  DesiredDataTransferLength;
> -} ISCSI_READY_TO_TRANSFER;
> -
> -typedef struct _ISCSI_ASYNC_MESSAGE {
> -  UINT8   OpCode;
> -  UINT8   Reserved1[8];
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  Reserved2;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT8   AsyncEvent;
> -  UINT8   AsyncVCode;
> -  UINT16  Parameter1;
> -  UINT16  Parameter2;
> -  UINT16  Parameter3;
> -  UINT32  Reserved3;
> -} ISCSI_ASYNC_MESSAGE;
> -
> -#define ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT  0x80
> -#define ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE 0x40
> -
> -///
> -/// Login Request
> -///
> -typedef struct _ISCSI_LOGIN_REQUEST {
> -  UINT8   OpCode;
> -  UINT8   Flags;
> -  UINT8   VersionMax;
> -  UINT8   VersionMin;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Isid[6];
> -  UINT16  Tsih;
> -  UINT32  InitiatorTaskTag;
> -  UINT16  Cid;
> -  UINT16  Reserved1;
> -  UINT32  CmdSN;
> -  UINT32  ExpStatSN;
> -  UINT32  Reserved2[4];
> -} ISCSI_LOGIN_REQUEST;
> -
> -#define ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT
> ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT
> -#define ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE
> ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE
> -
> -#define ISCSI_LOGIN_STATUS_SUCCESS          0
> -#define ISCSI_LOGIN_STATUS_REDIRECTION      1
> -#define ISCSI_LOGIN_STATUS_INITIATOR_ERROR  2
> -#define ISCSI_LOGIN_STATUS_TARGET_ERROR     3
> -
> -///
> -/// Login Response
> -///
> -typedef struct _ISCSI_LOGIN_RESPONSE {
> -  UINT8   OpCode;
> -  UINT8   Flags;
> -  UINT8   VersionMax;
> -  UINT8   VersionActive;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Isid[6];
> -  UINT16  Tsih;
> -  UINT32  InitiatorTaskTag;
> -  UINT32  Reserved1;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT8   StatusClass;
> -  UINT8   StatusDetail;
> -  UINT8   Reserved2[10];
> -} ISCSI_LOGIN_RESPONSE;
> -
> -#define ISCSI_LOGOUT_REASON_CLOSE_SESSION                   0
> -#define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION                1
> -#define ISCSI_LOGOUT_REASON_REMOVE_CONNECTION_FOR_RECOVERY  2
> -
> -///
> -/// Logout Request
> -///
> -typedef struct _ISCSI_LOGOUT_REQUEST {
> -  UINT8   OpCode;
> -  UINT8   ReasonCode;
> -  UINT16  Reserved1;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT32  Reserved2[2];
> -  UINT32  InitiatorTaskTag;
> -  UINT16  Cid;
> -  UINT16  Reserved3;
> -  UINT32  CmdSN;
> -  UINT32  ExpStatSN;
> -  UINT32  Reserved4[4];
> -} ISCSI_LOGOUT_REQUEST;
> -
> -#define ISCSI_LOGOUT_RESPONSE_SESSION_CLOSED_SUCCESS  0
> -#define ISCSI_LOGOUT_RESPONSE_CID_NOT_FOUND           1
> -#define ISCSI_LOGOUT_RESPONSE_RECOVERY_NOT_SUPPORTED  2
> -#define ISCSI_LOGOUT_RESPONSE_CLEANUP_FAILED          3
> -
> -///
> -/// Logout Response
> -///
> -typedef struct _ISCSI_LOGOUT_RESPONSE {
> -  UINT8   OpCode;
> -  UINT8   Reserved1;
> -  UINT8   Response;
> -  UINT8   Reserved2;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT32  Reserved3[2];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  Reserved4;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  Reserved5;
> -  UINT16  Time2Wait;
> -  UINT16  Time2Retain;
> -  UINT32  Reserved6;
> -} ISCSI_LOGOUT_RESPONSE;
> -
> -#define ISCSI_SNACK_REQUEST_TYPE_DATA_OR_R2T  0
> -#define ISCSI_SNACK_REQUEST_TYPE_STATUS       1
> -#define ISCSI_SNACK_REQUEST_TYPE_DATA_ACK     2
> -#define ISCSI_SNACK_REQUEST_TYPE_RDATA        3
> -
> -///
> -/// SNACK Request
> -///
> -typedef struct _ISCSI_SNACK_REQUEST {
> -  UINT8   OpCode;
> -  UINT8   Type;
> -  UINT16  Reserved1;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  TargetTransferTag;
> -  UINT32  Reserved2;
> -  UINT32  ExpStatSN;
> -  UINT32  Reserved[2];
> -  UINT32  BegRun;
> -  UINT32  RunLength;
> -} ISCSI_SNACK_REQUEST;
> -
> -///
> -/// Reject
> -///
> -typedef struct _ISCSI_REJECT {
> -  UINT8   OpCode;
> -  UINT8   Reserved1;
> -  UINT8   Reason;
> -  UINT8   Reserved2;
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT32  Reserved3[2];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  Reserved4;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  DataSN;
> -  UINT32  Reserved5[2];
> -} ISCSI_REJECT;
> -
> -///
> -/// NOP-Out
> -///
> -typedef struct _ISCSI_NOP_OUT {
> -  UINT8   OpCode;
> -  UINT8   Reserved1[3];
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  TargetTransferTag;
> -  UINT32  CmdSN;
> -  UINT32  ExpStatSN;
> -  UINT32  Reserved2[4];
> -} ISCSI_NOP_OUT;
> -
> -///
> -/// NOP-In
> -///
> -typedef struct _ISCSI_NOP_IN {
> -  UINT8   OpCode;
> -  UINT8   Reserved1[3];
> -  UINT8   TotalAHSLength;
> -  UINT8   DataSegmentLength[3];
> -  UINT8   Lun[8];
> -  UINT32  InitiatorTaskTag;
> -  UINT32  TargetTransferTag;
> -  UINT32  StatSN;
> -  UINT32  ExpCmdSN;
> -  UINT32  MaxCmdSN;
> -  UINT32  Reserved2[3];
> -} ISCSI_NOP_IN;
> -
> -#define ISCSI_SECURITY_NEGOTIATION          0
> -#define ISCSI_LOGIN_OPERATIONAL_NEGOTIATION 1
> -#define ISCSI_FULL_FEATURE_PHASE            3
> -
> -typedef enum {
> -  IScsiDigestNone,
> -  IScsiDigestCRC32
> -} ISCSI_DIGEST_TYPE;
> -
> -typedef struct _ISCSI_XFER_CONTEXT {
> -  UINT32  TargetTransferTag;
> -  UINT32  Offset;
> -  UINT32  DesiredLength;
> -  UINT32  ExpDataSN;
> -} ISCSI_XFER_CONTEXT;
> -
> -typedef struct _ISCSI_IN_BUFFER_CONTEXT {
> -  UINT8   *InData;
> -  UINT32  InDataLen;
> -} ISCSI_IN_BUFFER_CONTEXT;
> -
> -typedef struct _ISCSI_TCB {
> -  LIST_ENTRY          Link;
> -
> -  BOOLEAN             SoFarInOrder;
> -  UINT32              ExpDataSN;
> -  BOOLEAN             FbitReceived;
> -  BOOLEAN             StatusXferd;
> -  UINT32              ActiveR2Ts;
> -  UINT32              Response;
> -  CHAR8               *Reason;
> -  UINT32              InitiatorTaskTag;
> -  UINT32              CmdSN;
> -  UINT32              SNACKTag;
> -
> -  ISCSI_XFER_CONTEXT  XferContext;
> -
> -  ISCSI_CONNECTION    *Conn;
> -} ISCSI_TCB;
> -
> -typedef struct _ISCSI_KEY_VALUE_PAIR {
> -  LIST_ENTRY      List;
> -
> -  CHAR8           *Key;
> -  CHAR8           *Value;
> -} ISCSI_KEY_VALUE_PAIR;
> -
> -/**
> -  Attach the iSCSI connection to the iSCSI session.
> -
> -  @param[in, out]  Session The iSCSI session.
> -  @param[in, out]  Conn    The iSCSI connection.
> -**/
> -VOID
> -IScsiAttatchConnection (
> -  IN OUT ISCSI_SESSION     *Session,
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Detach the iSCSI connection from the session it belongs to.
> -
> -  @param[in, out]  Conn The iSCSI connection.
> -**/
> -VOID
> -IScsiDetatchConnection (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  This function does the iSCSI connection login.
> -
> -  @param[in, out]  Conn      The iSCSI connection to login.
> -
> -  @retval EFI_SUCCESS        The iSCSI connection is logged into the iSCSI target.
> -  @retval EFI_TIMEOUT        Timeout happened during the login procedure.
> -  @retval Others             Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiConnLogin (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Create a TCP connection for the iSCSI session.
> -
> -  @param[in]  Private The iSCSI driver data.
> -  @param[in]  Session Maximum CmdSN from the target.
> -
> -  @return The newly created iSCSI connection.
> -**/
> -ISCSI_CONNECTION *
> -IScsiCreateConnection (
> -  IN ISCSI_DRIVER_DATA  *Private,
> -  IN ISCSI_SESSION      *Session
> -  );
> -
> -/**
> -  Destroy an iSCSI connection.
> -
> -  @param[in]  Conn The connection to destroy.
> -**/
> -VOID
> -IScsiDestroyConnection (
> -  IN ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Login the iSCSI session.
> -
> -  @param[in]  Private          The iSCSI driver data.
> -
> -  @retval EFI_SUCCESS          The iSCSI session login procedure finished.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NO_MEDIA         There was a media error.
> -  @retval Others               Other errors as indicated.
> -
> -**/
> -EFI_STATUS
> -IScsiSessionLogin (
> -  IN ISCSI_DRIVER_DATA  *Private
> -  );
> -
> -/**
> -  Build and send the iSCSI login request to the iSCSI target according to
> -  the current login stage.
> -
> -  @param[in]  Conn             The connection in the iSCSI login phase.
> -
> -  @retval EFI_SUCCESS          The iSCSI login request PDU is built and sent on this
> -                               connection.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_DEVICE_ERROR     Some kind of device error happened.
> -**/
> -EFI_STATUS
> -IScsiSendLoginReq (
> -  IN ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Receive and process the iSCSI login response.
> -
> -  @param[in]  Conn             The connection in the iSCSI login phase.
> -
> -  @retval EFI_SUCCESS          The iSCSI login response PDU is received and
> processed.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiReceiveLoginRsp (
> -  IN ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Add an iSCSI key-value pair as a string into the data segment of the Login
> Request PDU.
> -  The DataSegmentLength and the actual size of the net buffer containing this
> PDU will be
> -  updated.
> -
> -  @param[in, out]  Pdu         The iSCSI PDU whose data segment the key-value
> pair will
> -                               be added to.
> -  @param[in]       Key         The key name string.
> -  @param[in]       Value       The value string.
> -
> -  @retval EFI_SUCCESS          The key-valu pair is added to the PDU's
> datasegment and
> -                               the correspondence length fields are updated.
> -  @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to
> add the key-value
> -                               pair.
> -**/
> -EFI_STATUS
> -IScsiAddKeyValuePair (
> -  IN OUT NET_BUF      *Pdu,
> -  IN CHAR8            *Key,
> -  IN CHAR8            *Value
> -  );
> -
> -/**
> -  Prepare the iSCSI login request to be sent according to the current login status.
> -
> -  @param[in, out]  Conn The connection in the iSCSI login phase.
> -
> -  @return The pointer to the net buffer containing the iSCSI login request built.
> -  @retval Others    Other errors as indicated.
> -**/
> -NET_BUF *
> -IScsiPrepareLoginReq (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Process the iSCSI Login Response.
> -
> -  @param[in, out]  Conn The connection on which the iSCSI login response is
> received.
> -  @param[in, out]  Pdu  The iSCSI login response PDU.
> -
> -  @retval EFI_SUCCESS        The iSCSI login response PDU is processed and all
> check are passed.
> -  @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.
> -  @retval EFI_MEDIA_CHANGED  Target is redirected.
> -  @retval Others             Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiProcessLoginRsp (
> -  IN OUT ISCSI_CONNECTION  *Conn,
> -  IN OUT NET_BUF           *Pdu
> -  );
> -
> -/**
> -  Updated the target information according the data received in the iSCSI
> -  login response with an target redirection status.
> -
> -  @param[in, out] Session      The iSCSI session.
> -  @param[in]      Data         The data segment which should contain the
> -                               TargetAddress key-value list.
> -  @param[in]      Len          Length of the data.
> -
> -  @retval EFI_SUCCESS          The target address is updated.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NOT_FOUND        The TargetAddress key is not found.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiUpdateTargetAddress (
> -  IN OUT ISCSI_SESSION  *Session,
> -  IN CHAR8              *Data,
> -  IN UINT32             Len
> -  );
> -
> -/**
> -  The callback function to free the net buffer list.
> -
> -  @param[in]  Arg The opaque parameter.
> -**/
> -VOID
> -EFIAPI
> -IScsiFreeNbufList (
> -  VOID *Arg
> -  );
> -
> -/**
> -  Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU
> header and
> -  an optional data segment. The two parts will be put into two blocks of buffers
> in the
> -  net buffer. The digest check will be conducted in this function if needed and
> the digests
> -  will be trimmed from the PDU buffer.
> -
> -  @param[in]   Conn        The iSCSI connection to receive data from.
> -  @param[out]  Pdu         The received iSCSI pdu.
> -  @param[in]   Context     The context used to describe information on the caller
> provided
> -                           buffer to receive data segment of the iSCSI pdu, it's optional.
> -  @param[in]  HeaderDigest Whether there will be header digest received.
> -  @param[in]  DataDigest   Whether there will be data digest.
> -  @param[in]  TimeoutEvent The timeout event, it's optional.
> -
> -  @retval EFI_SUCCESS          An iSCSI pdu is received.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiReceivePdu (
> -  IN ISCSI_CONNECTION                      *Conn,
> -  OUT NET_BUF                              **Pdu,
> -  IN ISCSI_IN_BUFFER_CONTEXT               *Context, OPTIONAL
> -  IN BOOLEAN                               HeaderDigest,
> -  IN BOOLEAN                               DataDigest,
> -  IN EFI_EVENT                             TimeoutEvent OPTIONAL
> -  );
> -
> -/**
> -  Check and get the result of the prameter negotiation.
> -
> -  @param[in, out]  Conn          The connection in iSCSI login.
> -
> -  @retval EFI_SUCCESS          The parmeter check is passed and negotiation is
> finished.
> -  @retval EFI_PROTOCOL_ERROR   Some kind of iSCSI protocol error happened.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -**/
> -EFI_STATUS
> -IScsiCheckOpParams (
> -  IN OUT ISCSI_CONNECTION  *Conn
> -  );
> -
> -/**
> -  Fill the oprational prameters.
> -
> -  @param[in]       Conn        The connection in iSCSI login.
> -  @param[in, out]  Pdu         The iSCSI login request PDU to fill the parameters.
> -
> -  @retval EFI_SUCCESS          The parmeters are filled into the iSCSI login request
> PDU.
> -**/
> -EFI_STATUS
> -IScsiFillOpParams (
> -  IN ISCSI_CONNECTION  *Conn,
> -  IN OUT NET_BUF       *Pdu
> -  );
> -
> -/**
> -  Pad the iSCSI AHS or data segment to an integer number of 4 byte words.
> -
> -  @param[in, out]  Pdu         The iSCSI pdu which contains segments to pad.
> -  @param[in]       Len         The length of the last semgnet in the PDU.
> -
> -  @retval EFI_SUCCESS          The segment is padded or no need to pad it.
> -  @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space
> to add the
> -                               padding bytes.
> -**/
> -EFI_STATUS
> -IScsiPadSegment (
> -  IN OUT NET_BUF  *Pdu,
> -  IN UINT32       Len
> -  );
> -
> -/**
> -  Build a key-value list from the data segment.
> -
> -  @param[in]  Data The data segment containing the key-value pairs.
> -  @param[in]  Len  Length of the data segment.
> -
> -  @return The key-value list.
> -  @retval NULL Other errors as indicated.
> -**/
> -LIST_ENTRY *
> -IScsiBuildKeyValueList (
> -  IN CHAR8  *Data,
> -  IN UINT32 Len
> -  );
> -
> -/**
> -  Get the value string by the key name from the key-value list. If found,
> -  the key-value entry will be removed from the list.
> -
> -  @param[in, out]  KeyValueList  The key-value list.
> -  @param[in]       Key           The key name to find.
> -
> -  @return The value string.
> -**/
> -CHAR8 *
> -IScsiGetValueByKeyFromList (
> -  IN OUT LIST_ENTRY  *KeyValueList,
> -  IN CHAR8           *Key
> -  );
> -
> -/**
> -  Free the key-value list.
> -
> -  @param[in]  KeyValueList The key-value list.
> -**/
> -VOID
> -IScsiFreeKeyValueList (
> -  IN LIST_ENTRY      *KeyValueList
> -  );
> -
> -/**
> -  Normalize the iSCSI name according to RFC.
> -
> -  @param[in, out]  Name       The iSCSI name.
> -  @param[in]       Len        length of the iSCSI name.
> -
> -  @retval EFI_SUCCESS        The iSCSI name is valid and normalized.
> -  @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the
> IQN format.
> -**/
> -EFI_STATUS
> -IScsiNormalizeName (
> -  IN OUT CHAR8  *Name,
> -  IN UINTN      Len
> -  );
> -
> -/**
> -  Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.
> -
> -  @param[in]       PassThru  The EXT SCSI PASS THRU protocol.
> -  @param[in]       Target    The target ID.
> -  @param[in]       Lun       The LUN.
> -  @param[in, out]  Packet    The request packet containing IO request, SCSI
> command
> -                             buffer and buffers to read/write.
> -
> -  @retval EFI_SUCCES           The SCSI command is executed and the result is
> updated to
> -                               the Packet.
> -  @retval EFI_DEVICE_ERROR     Session state was not as required.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval EFI_NOT_READY        The target can not accept new commands.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -IScsiExecuteScsiCommand (
> -  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL                 *PassThru,
> -  IN UINT8                                           *Target,
> -  IN UINT64                                          Lun,
> -  IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET  *Packet
> -  );
> -
> -/**
> -  Reinstate the session on some error.
> -
> -  @param[in, out]  Private The iSCSI driver data.
> -
> -  @retval EFI_SUCCES  The session is reinstated from some error.
> -  @retval Other       Reinstatement failed.
> -**/
> -EFI_STATUS
> -IScsiSessionReinstatement (
> -  IN OUT ISCSI_DRIVER_DATA  *Private
> -  );
> -
> -/**
> -  Initialize some session parameters before login.
> -
> -  @param[in, out]  Session  The iSCSI session.
> -  @param[in]       Recovery Whether the request is from a fresh new start or
> recovery.
> -**/
> -VOID
> -IScsiSessionInit (
> -  IN OUT ISCSI_SESSION  *Session,
> -  IN BOOLEAN            Recovery
> -  );
> -
> -/**
> -  Abort the iSCSI session, that is, reset all the connection and free the
> -  resources.
> -
> -  @param[in, out]  Session The iSCSI session.
> -
> -  @retval EFI_SUCCES  The session is aborted.
> -**/
> -EFI_STATUS
> -IScsiSessionAbort (
> -  IN OUT ISCSI_SESSION  *Session
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.h
> deleted file mode 100644
> index 9e0f1e0f02c2..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiTcp4Io.h
> +++ /dev/null
> @@ -1,142 +0,0 @@
> -/** @file
> -  iSCSI Tcp4 IO related definitions.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _ISCSI_TCP4_IO_H_
> -#define _ISCSI_TCP4_IO_H_
> -
> -#include <Library/NetLib.h>
> -#include <Protocol/Tcp4.h>
> -
> -typedef struct _TCP4_IO_CONFIG_DATA {
> -  EFI_IPv4_ADDRESS  LocalIp;
> -  EFI_IPv4_ADDRESS  SubnetMask;
> -  EFI_IPv4_ADDRESS  Gateway;
> -
> -  EFI_IPv4_ADDRESS  RemoteIp;
> -  UINT16            RemotePort;
> -} TCP4_IO_CONFIG_DATA;
> -
> -typedef struct _TCP4_IO {
> -  EFI_HANDLE                Image;
> -  EFI_HANDLE                Controller;
> -
> -  EFI_HANDLE                Handle;
> -  EFI_TCP4_PROTOCOL         *Tcp4;
> -
> -  EFI_TCP4_CONNECTION_TOKEN ConnToken;
> -  EFI_TCP4_IO_TOKEN         TxToken;
> -  EFI_TCP4_IO_TOKEN         RxToken;
> -  EFI_TCP4_CLOSE_TOKEN      CloseToken;
> -
> -  BOOLEAN                   IsConnDone;
> -  BOOLEAN                   IsTxDone;
> -  BOOLEAN                   IsRxDone;
> -  BOOLEAN                   IsCloseDone;
> -} TCP4_IO;
> -
> -/**
> -  Create a TCP socket with the specified configuration data.
> -
> -  @param[in]  Image      The handle of the driver image.
> -  @param[in]  Controller The handle of the controller.
> -  @param[in]  ConfigData The Tcp4 configuration data.
> -  @param[in]  Tcp4Io     The Tcp4Io.
> -
> -  @retval EFI_SUCCESS    The TCP socket is created and configured.
> -  @retval Others         Failed to create the TCP socket or configure it.
> -**/
> -EFI_STATUS
> -Tcp4IoCreateSocket (
> -  IN EFI_HANDLE           Image,
> -  IN EFI_HANDLE           Controller,
> -  IN TCP4_IO_CONFIG_DATA  *ConfigData,
> -  IN TCP4_IO              *Tcp4Io
> -  );
> -
> -/**
> -  Destroy the socket.
> -
> -  @param[in]  Tcp4Io The Tcp4Io which wraps the socket to be destroyeds.
> -**/
> -VOID
> -Tcp4IoDestroySocket (
> -  IN TCP4_IO  *Tcp4Io
> -  );
> -
> -/**
> -  Connect to the other endpoint of the TCP socket.
> -
> -  @param[in, out]  Tcp4Io    The Tcp4Io wrapping the TCP socket.
> -  @param[in]       Timeout   The time to wait for connection done.
> -
> -  @retval EFI_SUCCESS          Connect to the other endpoint of the TCP socket
> successfully.
> -  @retval EFI_TIMEOUT          Failed to connect to the other endpoint of the TCP
> socket in the                               specified time period.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -Tcp4IoConnect (
> -  IN OUT TCP4_IO    *Tcp4Io,
> -  IN EFI_EVENT      Timeout
> -  );
> -
> -/**
> -  Reset the socket.
> -
> -  @param[in, out]  Tcp4Io The Tcp4Io wrapping the TCP socket.
> -**/
> -VOID
> -Tcp4IoReset (
> -  IN OUT TCP4_IO  *Tcp4Io
> -  );
> -
> -/**
> -  Transmit the Packet to the other endpoint of the socket.
> -
> -  @param[in]   Tcp4Io          The Tcp4Io wrapping the TCP socket.
> -  @param[in]   Packet          The packet to transmit.
> -
> -  @retval EFI_SUCCESS          The packet is trasmitted.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -Tcp4IoTransmit (
> -  IN TCP4_IO  *Tcp4Io,
> -  IN NET_BUF  *Packet
> -  );
> -
> -/**
> -  Receive data from the socket.
> -
> -  @param[in]  Tcp4Io           The Tcp4Io which wraps the socket to be destroyed.
> -  @param[in]  Packet           The buffer to hold the data copy from the soket rx
> buffer.
> -  @param[in]  AsyncMode        Is this receive asyncronous or not.
> -  @param[in]  Timeout          The time to wait for receiving the amount of data
> the Packet
> -                               can hold.
> -
> -  @retval EFI_SUCCESS          The required amount of data is received from the
> socket.
> -  @retval EFI_OUT_OF_RESOURCES Failed to allocate momery.
> -  @retval EFI_TIMEOUT          Failed to receive the required amount of data in
> the
> -                               specified time period.
> -  @retval Others               Other errors as indicated.
> -**/
> -EFI_STATUS
> -Tcp4IoReceive (
> -  IN TCP4_IO    *Tcp4Io,
> -  IN NET_BUF    *Packet,
> -  IN BOOLEAN    AsyncMode,
> -  IN EFI_EVENT  Timeout
> -  );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/Md5.h
> b/MdeModulePkg/Universal/Network/IScsiDxe/Md5.h
> deleted file mode 100644
> index 1541b2d8ece1..000000000000
> --- a/MdeModulePkg/Universal/Network/IScsiDxe/Md5.h
> +++ /dev/null
> @@ -1,80 +0,0 @@
> -/** @file
> -  Header file for Md5.
> -
> -Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
> -This program and the accompanying materials
> -are licensed and made available under the terms and conditions of the BSD
> License
> -which accompanies this distribution.  The full text of the license may be found
> at
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef _MD5_H_
> -#define _MD5_H_
> -
> -#include <Uefi.h>
> -#include <Library/BaseLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/NetLib.h>
> -
> -#define MD5_HASHSIZE  16
> -
> -typedef struct _MD5_CTX {
> -  EFI_STATUS  Status;
> -  UINT64      Length;
> -  UINT32      States[MD5_HASHSIZE / sizeof (UINT32)];
> -  UINT8       M[64];
> -  UINTN       Count;
> -} MD5_CTX;
> -
> -/**
> -  Initialize four 32-bits chaining variables and use them to do the Md5 transform.
> -
> -  @param[out]  Md5Ctx The data structure of Md5.
> -
> -  @retval EFI_SUCCESS Initialization is ok.
> -**/
> -EFI_STATUS
> -MD5Init (
> -  OUT MD5_CTX  *Md5Ctx
> -  );
> -
> -/**
> -  the external interface of Md5 algorithm
> -
> -  @param[in, out]  Md5Ctx  The data structure of storing the original data
> -                           segment and the final result.
> -  @param[in]       Data    The data wanted to be transformed.
> -  @param[in]       DataLen The length of data.
> -
> -  @retval EFI_SUCCESS The transform is ok.
> -  @retval Others      Other errors as indicated.
> -**/
> -EFI_STATUS
> -MD5Update (
> -  IN  OUT MD5_CTX  *Md5Ctx,
> -  IN  VOID         *Data,
> -  IN  UINTN        DataLen
> -  );
> -
> -/**
> -  Accumulate the MD5 value of every data segment and generate the finial
> -  result according to MD5 algorithm.
> -
> -  @param[in, out]   Md5Ctx  The data structure of storing the original data
> -                            segment and the final result.
> -  @param[out]      HashVal  The final 128-bits output.
> -
> -  @retval EFI_SUCCESS  The transform is ok.
> -  @retval Others       Other errors as indicated.
> -**/
> -EFI_STATUS
> -MD5Final (
> -  IN  OUT MD5_CTX  *Md5Ctx,
> -  OUT UINT8        *HashVal
> -  );
> -
> -#endif
> --
> 2.19.1.windows.1



  parent reply	other threads:[~2018-12-20  4:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20  1:41 [PATCH v2 0/6] Delete TCP, PXE, iSCSI driver in MdeModulePkg Siyuan Fu
2018-12-20  1:41 ` [PATCH v2 1/6] MdeModulePkg: Delete Tcp4Dxe " Siyuan Fu
2018-12-20  2:09   ` Ni, Ruiyu
2018-12-20  4:59   ` Wang, Jian J
2018-12-20  1:41 ` [PATCH v2 2/6] NetworkPkg: Remove some clarification from TcpDxe.inf Siyuan Fu
2018-12-20  1:41 ` [PATCH v2 3/6] MdeModulePkg: Delete IScsiDxe in MdeModulePkg Siyuan Fu
2018-12-20  2:07   ` Ni, Ruiyu
2018-12-20  4:43   ` Wang, Jian J [this message]
2018-12-20  1:41 ` [PATCH v2 4/6] NetworkPkg: Remove some clarification from IScsiDxe.inf Siyuan Fu
2018-12-20  1:41 ` [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in MdeModulePkg Siyuan Fu
2018-12-20  4:56   ` Wang, Jian J
2018-12-20  1:41 ` [PATCH v2 6/6] NetworkPkg: Remove some clarification from UefiPxeBcDxe.inf Siyuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D827630B58408649ACB04F44C510003624ECE8F0@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox