From nobody Wed Dec 25 13:21:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1508309874560584.2467917180845; Tue, 17 Oct 2017 23:57:54 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AC07820D77822; Tue, 17 Oct 2017 23:54:16 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0A369202E60E9 for ; Tue, 17 Oct 2017 23:54:15 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 17 Oct 2017 23:57:51 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.187]) by fmsmga005.fm.intel.com with ESMTP; 17 Oct 2017 23:57:49 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,394,1503385200"; d="scan'208";a="163910644" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Wed, 18 Oct 2017 14:57:46 +0800 Message-Id: <1508309867-24176-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1508309867-24176-1-git-send-email-jiaxin.wu@intel.com> References: <1508309867-24176-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch v2 1/2] NetworkPkg/HttpBootDxe: Add IPv6 support condition check. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Karunakar P , Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" v2: * Fix the ASSERT issue. Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=3D710, we provide this patch to IPv6 condition check by leveraging AIP Protocol. Cc: Karunakar P Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Karunakar P Signed-off-by: Wu Jiaxin --- NetworkPkg/HttpBootDxe/HttpBootDxe.c | 161 +++++++++++++++++++++++++++++= ++-- NetworkPkg/HttpBootDxe/HttpBootDxe.h | 2 + NetworkPkg/HttpBootDxe/HttpBootDxe.inf | 4 +- 3 files changed, 157 insertions(+), 10 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c b/NetworkPkg/HttpBootDxe/= HttpBootDxe.c index 642e0fe..b1f9042 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c @@ -1,9 +1,9 @@ /** @file Driver Binding functions implementation for UEFI HTTP boot. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availabl= e under=20 the terms and conditions of the BSD License that accompanies this distribu= tion. =20 The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. = =20 =20 @@ -33,10 +33,104 @@ EFI_DRIVER_BINDING_PROTOCOL gHttpBootIp6DxeDriverBindi= ng =3D { HTTP_BOOT_DXE_VERSION, NULL, NULL }; =20 + + +/** + Check whether UNDI protocol supports IPv6. + + @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA. + @param[out] Ipv6Support TRUE if UNDI supports IPv6. + + @retval EFI_SUCCESS Get the result whether UNDI supports IPv6= by NII or AIP protocol successfully. + @retval EFI_NOT_FOUND Don't know whether UNDI supports IPv6 sin= ce NII or AIP is not available. + +**/ +EFI_STATUS +HttpBootCheckIpv6Support ( + IN HTTP_BOOT_PRIVATE_DATA *Private, + OUT BOOLEAN *Ipv6Support + ) +{ + EFI_HANDLE Handle; + EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; + EFI_STATUS Status; + EFI_GUID *InfoTypesBuffer; + UINTN InfoTypeBufferCount; + UINTN TypeIndex; + BOOLEAN Supported; + VOID *InfoBlock; + UINTN InfoBlockSize; + + ASSERT (Private !=3D NULL && Ipv6Support !=3D NULL); + + // + // Check whether the UNDI supports IPv6 by NII protocol. + // + if (Private->Nii !=3D NULL) { + *Ipv6Support =3D Private->Nii->Ipv6Supported; + return EFI_SUCCESS; + } + + // + // Get the NIC handle by SNP protocol. + // =20 + Handle =3D NetLibGetSnpHandle (Private->Controller, NULL); + if (Handle =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Aip =3D NULL; + Status =3D gBS->HandleProtocol ( + Handle, + &gEfiAdapterInformationProtocolGuid, + (VOID *) &Aip + ); + if (EFI_ERROR (Status) || Aip =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + InfoTypesBuffer =3D NULL; + InfoTypeBufferCount =3D 0; + Status =3D Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBuffe= rCount); + if (EFI_ERROR (Status) || InfoTypesBuffer =3D=3D NULL) { + FreePool (InfoTypesBuffer); + return EFI_NOT_FOUND; + } + + Supported =3D FALSE; + for (TypeIndex =3D 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) { + if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoUndiIpv6= SupportGuid)) { + Supported =3D TRUE; + break; + } + } + + FreePool (InfoTypesBuffer); + if (!Supported) { + return EFI_NOT_FOUND; + } + + // + // We now have adapter information block. + // + InfoBlock =3D NULL; + InfoBlockSize =3D 0; + Status =3D Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid= , &InfoBlock, &InfoBlockSize); + if (EFI_ERROR (Status) || InfoBlock =3D=3D NULL) { + FreePool (InfoBlock); + return EFI_NOT_FOUND; + } =20 + + *Ipv6Support =3D ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv= 6Support; + FreePool (InfoBlock); + =20 + return EFI_SUCCESS; +} + /** Destroy the HTTP child based on IPv4 stack. =20 @param[in] This Pointer to the EFI_DRIVER_BINDING_PROTOCOL. @param[in] Private Pointer to HTTP_BOOT_PRIVATE_DATA. @@ -65,11 +159,11 @@ HttpBootDestroyIp4Children ( &gEfiDhcp4ServiceBindingProtocolGuid, Private->Dhcp4Child ); } =20 - if (Private->HttpCreated) { + if (Private->Ip6Nic =3D=3D NULL && Private->HttpCreated) { HttpIoDestroyIo (&Private->HttpIo); Private->HttpCreated =3D FALSE; } =20 if (Private->Ip4Nic !=3D NULL) { @@ -141,11 +235,11 @@ HttpBootDestroyIp6Children ( &gEfiDhcp6ServiceBindingProtocolGuid, Private->Dhcp6Child ); } =20 - if (Private->HttpCreated) { + if (Private->Ip4Nic =3D=3D NULL && Private->HttpCreated) { HttpIoDestroyIo(&Private->HttpIo); Private->HttpCreated =3D FALSE; } =20 if (Private->Ip6Nic !=3D NULL) { @@ -308,10 +402,13 @@ HttpBootIp4DxeDriverBindingStart ( EFI_STATUS Status; HTTP_BOOT_PRIVATE_DATA *Private; EFI_DEV_PATH *Node; EFI_DEVICE_PATH_PROTOCOL *DevicePath; UINT32 *Id; + BOOLEAN FirstStart; + + FirstStart =3D FALSE; =20 Status =3D gBS->OpenProtocol ( ControllerHandle, &gEfiCallerIdGuid, (VOID **) &Id, @@ -321,10 +418,12 @@ HttpBootIp4DxeDriverBindingStart ( ); =20 if (!EFI_ERROR (Status)) { Private =3D HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); } else { + FirstStart =3D TRUE; + =20 // // Initialize the private data structure. // Private =3D AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA)); if (Private =3D=3D NULL) { @@ -394,11 +493,12 @@ HttpBootIp4DxeDriverBindingStart ( return EFI_SUCCESS; } =20 Private->Ip4Nic =3D AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC)); if (Private->Ip4Nic =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_ERROR; } Private->Ip4Nic->Private =3D Private; Private->Ip4Nic->ImageHandle =3D This->DriverBindingHandle; Private->Ip4Nic->Signature =3D HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; =20 @@ -511,17 +611,26 @@ HttpBootIp4DxeDriverBindingStart ( if (EFI_ERROR (Status)) { goto ON_ERROR; } =20 return EFI_SUCCESS; - =20 ON_ERROR: - + if (FirstStart) { + gBS->UninstallProtocolInterface ( + ControllerHandle, + &gEfiCallerIdGuid, + &Private->Id + ); + } + =20 HttpBootDestroyIp4Children (This, Private); HttpBootConfigFormUnload (Private); - FreePool (Private); + + if (FirstStart && Private !=3D NULL) { + FreePool (Private); + } =20 return Status; } =20 =20 @@ -780,10 +889,14 @@ HttpBootIp6DxeDriverBindingStart ( EFI_STATUS Status; HTTP_BOOT_PRIVATE_DATA *Private; EFI_DEV_PATH *Node; EFI_DEVICE_PATH_PROTOCOL *DevicePath; UINT32 *Id; + BOOLEAN Ipv6Available; + BOOLEAN FirstStart; + + FirstStart =3D FALSE; =20 Status =3D gBS->OpenProtocol ( ControllerHandle, &gEfiCallerIdGuid, (VOID **) &Id, @@ -793,10 +906,12 @@ HttpBootIp6DxeDriverBindingStart ( ); =20 if (!EFI_ERROR (Status)) { Private =3D HTTP_BOOT_PRIVATE_DATA_FROM_ID(Id); } else { + FirstStart =3D TRUE; + =20 // // Initialize the private data structure. // Private =3D AllocateZeroPool (sizeof (HTTP_BOOT_PRIVATE_DATA)); if (Private =3D=3D NULL) { @@ -856,21 +971,39 @@ HttpBootIp6DxeDriverBindingStart ( if (EFI_ERROR (Status)) { goto ON_ERROR; } =20 } + + // + // Set IPv6 available flag. + //=20 + Status =3D HttpBootCheckIpv6Support (Private, &Ipv6Available); + if (EFI_ERROR (Status)) { + // + // Fail to get the data whether UNDI supports IPv6.=20 + // Set default value to TRUE. + // + Ipv6Available =3D TRUE; + } + + if (!Ipv6Available) { + Status =3D EFI_UNSUPPORTED; + goto ON_ERROR; + } =20 if (Private->Ip6Nic !=3D NULL) { // // Already created before // return EFI_SUCCESS; } =20 Private->Ip6Nic =3D AllocateZeroPool (sizeof (HTTP_BOOT_VIRTUAL_NIC)); if (Private->Ip6Nic =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_ERROR; } Private->Ip6Nic->Private =3D Private; Private->Ip6Nic->ImageHandle =3D This->DriverBindingHandle; Private->Ip6Nic->Signature =3D HTTP_BOOT_VIRTUAL_NIC_SIGNATURE; =20 @@ -1009,14 +1142,24 @@ HttpBootIp6DxeDriverBindingStart ( } =20 return EFI_SUCCESS; =20 ON_ERROR: + if (FirstStart) { + gBS->UninstallProtocolInterface ( + ControllerHandle, + &gEfiCallerIdGuid, + &Private->Id + ); + } =20 HttpBootDestroyIp6Children(This, Private); HttpBootConfigFormUnload (Private); - FreePool (Private); + + if (FirstStart && Private !=3D NULL) { + FreePool (Private); + } =20 return Status; } =20 /** diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h b/NetworkPkg/HttpBootDxe/= HttpBootDxe.h index 2c07cf7..166bc45 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h @@ -56,10 +56,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include #include #include #include #include +#include + // // Produced Protocols // #include #include diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.inf b/NetworkPkg/HttpBootDx= e/HttpBootDxe.inf index 4d6c5e5..6d2a772 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.inf +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.inf @@ -84,19 +84,21 @@ gEfiIp6ConfigProtocolGuid ## TO_START gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES gEfiRamDiskProtocolGuid ## SOMETIMES_CONSUMES gEfiHiiConfigAccessProtocolGuid ## BY_START gEfiHttpBootCallbackProtocolGuid ## SOMETIMES_PRODUCES - =20 + gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES + [Guids] ## SOMETIMES_CONSUMES ## GUID # HiiIsConfigHdrMatch mHttpBootConfigSto= rageName ## SOMETIMES_PRODUCES ## GUID # HiiConstructConfigHdr mHttpBootConfigSto= rageName ## SOMETIMES_PRODUCES ## GUID # HiiGetBrowserData mHttpBootConfigSto= rageName ## SOMETIMES_CONSUMES ## HII gHttpBootConfigGuid gEfiVirtualCdGuid ## SOMETIMES_CONSUMES ## GUID gEfiVirtualDiskGuid ## SOMETIMES_CONSUMES ## GUID + gEfiAdapterInfoUndiIpv6SupportGuid ## SOMETIMES_CONSUMES ## = GUID =20 [Pcd] gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections ## CONSUMES =20 =20 [UserExtensions.TianoCore."ExtraFiles"] --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed Dec 25 13:21:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1508309876877601.6573895843617; Tue, 17 Oct 2017 23:57:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EE43221CE740C; Tue, 17 Oct 2017 23:54:18 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 60A432095E53D for ; Tue, 17 Oct 2017 23:54:16 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 17 Oct 2017 23:57:53 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.187]) by fmsmga005.fm.intel.com with ESMTP; 17 Oct 2017 23:57:51 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,394,1503385200"; d="scan'208";a="163910654" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Wed, 18 Oct 2017 14:57:47 +0800 Message-Id: <1508309867-24176-3-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1508309867-24176-1-git-send-email-jiaxin.wu@intel.com> References: <1508309867-24176-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch v2 2/2] NetworkPkg/IScsiDxe: Add IPv6 support condition check. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Karunakar P , Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Base on the request of https://bugzilla.tianocore.org/show_bug.cgi?id=3D710, we provide this patch to IPv6 condition check by leveraging AIP Protocol. Cc: Karunakar P Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Karunakar P Signed-off-by: Wu Jiaxin --- NetworkPkg/IScsiDxe/IScsiConfig.c | 18 +++++ NetworkPkg/IScsiDxe/IScsiDriver.c | 2 +- NetworkPkg/IScsiDxe/IScsiDriver.h | 1 + NetworkPkg/IScsiDxe/IScsiDxe.inf | 2 + NetworkPkg/IScsiDxe/IScsiImpl.h | 1 + NetworkPkg/IScsiDxe/IScsiMisc.c | 135 ++++++++++++++++++++++++++++++++++= +++- NetworkPkg/IScsiDxe/IScsiMisc.h | 4 +- 7 files changed, 159 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiC= onfig.c index f20f590..3ce37c5 100644 --- a/NetworkPkg/IScsiDxe/IScsiConfig.c +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c @@ -3419,10 +3419,13 @@ IScsiFormCallback ( EFI_IP_ADDRESS Gateway; ISCSI_CONFIG_IFR_NVDATA *IfrNvData; ISCSI_CONFIG_IFR_NVDATA OldIfrNvData; EFI_STATUS Status; EFI_INPUT_KEY Key; + ISCSI_NIC_INFO *NicInfo; + + NicInfo =3D NULL; =20 if ((Action =3D=3D EFI_BROWSER_ACTION_FORM_OPEN) || (Action =3D=3D EFI_B= ROWSER_ACTION_FORM_CLOSE)) { // // Do nothing for UEFI OPEN/CLOSE Action // @@ -3589,10 +3592,25 @@ IScsiFormCallback ( break; =20 case KEY_IP_MODE: switch (Value->u8) { case IP_MODE_IP6: + NicInfo =3D IScsiGetNicInfoByIndex (Private->Current->NicIndex);=20 + if(!NicInfo->Ipv6Available) { =09 + // + // Current NIC doesn't Support IPv6, hence use IPv4. =20 + // =20 + IfrNvData->IpMode =3D IP_MODE_IP4; + =09 + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"Current NIC doesn't Support IPv6!", + NULL + ); + } + =20 case IP_MODE_IP4: ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp)); ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask)); ZeroMem (IfrNvData->Gateway, sizeof (IfrNvData->Gateway)); ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiD= river.c index 2249919..fbeef97 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.c +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c @@ -438,11 +438,11 @@ IScsiStart ( } =20 // // Record the incoming NIC info. // - Status =3D IScsiAddNic (ControllerHandle); + Status =3D IScsiAddNic (ControllerHandle, Image); if (EFI_ERROR (Status)) { return Status; } =20 // diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h b/NetworkPkg/IScsiDxe/IScsiD= river.h index 6c6e11b..2db93c5 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.h +++ b/NetworkPkg/IScsiDxe/IScsiDriver.h @@ -79,10 +79,11 @@ typedef struct { UINT8 NicIndex; UINT16 VlanId; UINTN BusNumber; UINTN DeviceNumber; UINTN FunctionNumber; + BOOLEAN Ipv6Available; } ISCSI_NIC_INFO; =20 typedef struct _ISCSI_PRIVATE_PROTOCOL { UINT32 Reserved; } ISCSI_PRIVATE_PROTOCOL; diff --git a/NetworkPkg/IScsiDxe/IScsiDxe.inf b/NetworkPkg/IScsiDxe/IScsiDx= e.inf index 01998a0..319c7fe 100644 --- a/NetworkPkg/IScsiDxe/IScsiDxe.inf +++ b/NetworkPkg/IScsiDxe/IScsiDxe.inf @@ -115,18 +115,20 @@ gEfiIScsiInitiatorNameProtocolGuid ## PRODUCES =20 gEfiAuthenticationInfoProtocolGuid ## SOMETIMES_CONSUMES gEfiAdapterInformationProtocolGuid + gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES =20 [Guids] gEfiEventExitBootServicesGuid ## SOMETIMES_CONSUMES ## E= vent gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## U= NDEFINED gEfiAcpiTableGuid ## SOMETIMES_CONSUMES ## S= ystemTable gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## S= ystemTable gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## S= ystemTable gEfiAdapterInfoNetworkBootGuid ## SOMETIMES_CONSUMES ## U= NDEFINED + gEfiAdapterInfoUndiIpv6SupportGuid ## SOMETIMES_CONSUMES ## G= UID =20 ## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder" ## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder" ## SOMETIMES_PRODUCES ## Variable:L"InitialAttemptOrder" ## SOMETIMES_CONSUMES ## Variable:L"InitialAttemptOrder" diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiImp= l.h index 741c497..9e36da0 100644 --- a/NetworkPkg/IScsiDxe/IScsiImpl.h +++ b/NetworkPkg/IScsiDxe/IScsiImpl.h @@ -37,10 +37,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 #include #include #include #include +#include =20 #include #include #include #include diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMis= c.c index 0a0a3f5..9e4164c 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -464,22 +464,128 @@ IScsiGenRandom ( } } =20 =20 /** + Check whether UNDI protocol supports IPv6. + + @param[in] ControllerHandle Controller handle. + @param[in] Image Handle of the image. + @param[out] Ipv6Support TRUE if UNDI supports IPv6. + + @retval EFI_SUCCESS Get the result whether UNDI supports IPv6= by NII or AIP protocol successfully. + @retval EFI_NOT_FOUND Don't know whether UNDI supports IPv6 sin= ce NII or AIP is not available. + +**/ +EFI_STATUS +IScsiCheckIpv6Support ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE Image, + OUT BOOLEAN *Ipv6Support + ) +{ + EFI_HANDLE Handle; + EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; + EFI_STATUS Status; + EFI_GUID *InfoTypesBuffer; + UINTN InfoTypeBufferCount; + UINTN TypeIndex; + BOOLEAN Supported; + VOID *InfoBlock; + UINTN InfoBlockSize; + =20 + EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii; + + ASSERT (Ipv6Support !=3D NULL); + + // + // Check whether the UNDI supports IPv6 by NII protocol. + // + Status =3D gBS->OpenProtocol ( + ControllerHandle, + &gEfiNetworkInterfaceIdentifierProtocolGuid_31, + (VOID **) &Nii, + Image, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (Status =3D=3D EFI_SUCCESS) { + *Ipv6Support =3D Nii->Ipv6Supported; + return EFI_SUCCESS; + } + + // + // Get the NIC handle by SNP protocol. + // =20 + Handle =3D NetLibGetSnpHandle (ControllerHandle, NULL); + if (Handle =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Aip =3D NULL; + Status =3D gBS->HandleProtocol ( + Handle, + &gEfiAdapterInformationProtocolGuid, + (VOID *) &Aip + ); + if (EFI_ERROR (Status) || Aip =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + InfoTypesBuffer =3D NULL; + InfoTypeBufferCount =3D 0; + Status =3D Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBuffe= rCount); + if (EFI_ERROR (Status) || InfoTypesBuffer =3D=3D NULL) { + FreePool (InfoTypesBuffer); + return EFI_NOT_FOUND; + } + + Supported =3D FALSE; + for (TypeIndex =3D 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) { + if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoUndiIpv6= SupportGuid)) { + Supported =3D TRUE; + break; + } + } + + FreePool (InfoTypesBuffer); + if (!Supported) { + return EFI_NOT_FOUND; + } + + // + // We now have adapter information block. + // + InfoBlock =3D NULL; + InfoBlockSize =3D 0; + Status =3D Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid= , &InfoBlock, &InfoBlockSize); + if (EFI_ERROR (Status) || InfoBlock =3D=3D NULL) { + FreePool (InfoBlock); + return EFI_NOT_FOUND; + } =20 + + *Ipv6Support =3D ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv= 6Support; + FreePool (InfoBlock); + =20 + return EFI_SUCCESS; +} + +/** Record the NIC info in global structure. =20 @param[in] Controller The handle of the controller. + @param[in] Image Handle of the image. =20 @retval EFI_SUCCESS The operation is completed. @retval EFI_OUT_OF_RESOURCES Do not have sufficient resources to finis= h this operation. =20 **/ EFI_STATUS IScsiAddNic ( - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE Image ) { EFI_STATUS Status; ISCSI_NIC_INFO *NicInfo; LIST_ENTRY *Entry; @@ -507,10 +613,23 @@ IScsiAddNic ( NicInfo =3D NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); if (NicInfo->HwAddressSize =3D=3D HwAddressSize && CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSiz= e) =3D=3D 0 && NicInfo->VlanId =3D=3D VlanId) { mPrivate->CurrentNic =3D NicInfo->NicIndex; + =20 + // + // Set IPv6 available flag. + //=20 + Status =3D IScsiCheckIpv6Support (Controller, Image, &NicInfo->Ipv6A= vailable); + if (EFI_ERROR (Status)) { + // + // Fail to get the data whether UNDI supports IPv6.=20 + // Set default value to TRUE. + // + NicInfo->Ipv6Available =3D TRUE; + } + =20 return EFI_SUCCESS; } =20 if (mPrivate->MaxNic < NicInfo->NicIndex) { mPrivate->MaxNic =3D NicInfo->NicIndex; @@ -528,11 +647,23 @@ IScsiAddNic ( CopyMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize); NicInfo->HwAddressSize =3D (UINT32) HwAddressSize; NicInfo->VlanId =3D VlanId; NicInfo->NicIndex =3D (UINT8) (mPrivate->MaxNic + 1); mPrivate->MaxNic =3D NicInfo->NicIndex; - + =20 + // + // Set IPv6 available flag. + //=20 + Status =3D IScsiCheckIpv6Support (Controller, Image, &NicInfo->Ipv6Avail= able); + if (EFI_ERROR (Status)) { + // + // Fail to get the data whether UNDI supports IPv6.=20 + // Set default value to TRUE. + // + NicInfo->Ipv6Available =3D TRUE; + } + =20 // // Get the PCI location. // IScsiGetNICPciLocation ( Controller, diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMis= c.h index caa2f94..659c026 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.h +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h @@ -215,19 +215,21 @@ IScsiGenRandom ( =20 /** Record the NIC information in a global structure. =20 @param[in] Controller The handle of the controller. + @param[in] Image Handle of the image. =20 @retval EFI_SUCCESS The operation is completed. @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish= this operation. =20 **/ EFI_STATUS IScsiAddNic ( - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE Image ); =20 /** Delete the recorded NIC information from a global structure. Also delete= corresponding attempts. --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel