From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web09.6442.1627354889586173525 for ; Mon, 26 Jul 2021 20:01:29 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: heng.luo@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10057"; a="276145665" X-IronPort-AV: E=Sophos;i="5.84,272,1620716400"; d="scan'208";a="276145665" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2021 20:01:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,272,1620716400"; d="scan'208";a="505299960" Received: from hengluo-dev.ccr.corp.intel.com ([10.239.153.158]) by FMSMGA003.fm.intel.com with ESMTP; 26 Jul 2021 20:01:26 -0700 From: "Heng Luo" To: devel@edk2.groups.io Cc: Zachary Clark-Williams , Maciej Rabeda , Jiaxin Wu , Siyuan Fu Subject: [PATCH] NetworkPkg: Making the HTTP IO timeout value programmable with PCD Date: Tue, 27 Jul 2021 11:01:13 +0800 Message-Id: <20210727030113.925-1-heng.luo@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Zachary Clark-Williams HTTP boot has a default set forced timeout value of 5 seconds for getting the recovery image from a remote source. This change allows the HTTP boot flow to get the IO timeout value from the PcdHttpIoTimeout. PcdHttpIoTimeout value is set in platform code. Signed-off-by: Zachary Clark-Williams Cc: Maciej Rabeda Cc: Jiaxin Wu Cc: Siyuan Fu --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 12 +++++++++--- NetworkPkg/HttpBootDxe/HttpBootClient.h | 7 +------ NetworkPkg/HttpBootDxe/HttpBootDxe.inf | 3 ++- NetworkPkg/HttpDxe/HttpDxe.inf | 3 ++- NetworkPkg/HttpDxe/HttpImpl.c | 17 ++++++++++++++--- NetworkPkg/HttpDxe/HttpProto.h | 3 +-- NetworkPkg/NetworkPkg.dec | 8 ++++---- NetworkPkg/NetworkPkg.dsc | 3 +++ NetworkPkg/NetworkPkg.uni | 8 +++++++- 9 files changed, 43 insertions(+), 21 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootD= xe/HttpBootClient.c index 8f21f7766e..aa0a153019 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -1,7 +1,7 @@ /** @file=0D Implementation of the boot file download function.=0D =0D -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D (C) Copyright 2016 Hewlett Packard Enterprise Development LP
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -596,19 +596,25 @@ HttpBootCreateHttpIo ( HTTP_IO_CONFIG_DATA ConfigData;=0D EFI_STATUS Status;=0D EFI_HANDLE ImageHandle;=0D + UINT32 TimeoutValue;=0D =0D ASSERT (Private !=3D NULL);=0D =0D + //=0D + // Get HTTP timeout value=0D + //=0D + TimeoutValue =3D PcdGet32 (PcdHttpIoTimeout);=0D +=0D ZeroMem (&ConfigData, sizeof (HTTP_IO_CONFIG_DATA));=0D if (!Private->UsingIpv6) {=0D ConfigData.Config4.HttpVersion =3D HttpVersion11;=0D - ConfigData.Config4.RequestTimeOut =3D HTTP_BOOT_REQUEST_TIMEOUT;=0D + ConfigData.Config4.RequestTimeOut =3D TimeoutValue;=0D IP4_COPY_ADDRESS (&ConfigData.Config4.LocalIp, &Private->StationIp.v4)= ;=0D IP4_COPY_ADDRESS (&ConfigData.Config4.SubnetMask, &Private->SubnetMask= .v4);=0D ImageHandle =3D Private->Ip4Nic->ImageHandle;=0D } else {=0D ConfigData.Config6.HttpVersion =3D HttpVersion11;=0D - ConfigData.Config6.RequestTimeOut =3D HTTP_BOOT_REQUEST_TIMEOUT;=0D + ConfigData.Config6.RequestTimeOut =3D TimeoutValue;=0D IP6_COPY_ADDRESS (&ConfigData.Config6.LocalIp, &Private->StationIp.v6)= ;=0D ImageHandle =3D Private->Ip6Nic->ImageHandle;=0D }=0D diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.h b/NetworkPkg/HttpBootD= xe/HttpBootClient.h index 971b2dc800..3a98f0f557 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.h +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.h @@ -1,7 +1,7 @@ /** @file=0D Declaration of the boot file download function.=0D =0D -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D (C) Copyright 2016 Hewlett Packard Enterprise Development LP
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -10,12 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __EFI_HTTP_BOOT_HTTP_H__=0D #define __EFI_HTTP_BOOT_HTTP_H__=0D =0D -#define HTTP_BOOT_REQUEST_TIMEOUT 5000 // 5 seconds in uin= ts of millisecond.=0D -#define HTTP_BOOT_RESPONSE_TIMEOUT 5000 // 5 seconds in uin= ts of millisecond.=0D #define HTTP_BOOT_BLOCK_SIZE 1500=0D -=0D -=0D -=0D #define HTTP_USER_AGENT_EFI_HTTP_BOOT "UefiHttpBoot/1.0"=0D =0D //=0D diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.inf b/NetworkPkg/HttpBootDx= e/HttpBootDxe.inf index a27a561722..f4f80caccc 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.inf +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.inf @@ -1,7 +1,7 @@ ## @file=0D # This modules produce the Load File Protocol for UEFI HTTP boot.=0D #=0D -# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
= =0D # (C) Copyright 2020 Hewlett-Packard Development Company, L.P.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -96,6 +96,7 @@ =0D [Pcd]=0D gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections ## CONSUMES=0D + gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout ## CONSUMES=0D =0D [UserExtensions.TianoCore."ExtraFiles"]=0D HttpBootDxeExtra.uni=0D diff --git a/NetworkPkg/HttpDxe/HttpDxe.inf b/NetworkPkg/HttpDxe/HttpDxe.inf index 35fe31af18..8dd3838793 100644 --- a/NetworkPkg/HttpDxe/HttpDxe.inf +++ b/NetworkPkg/HttpDxe/HttpDxe.inf @@ -1,7 +1,7 @@ ## @file=0D # Implementation of EFI HTTP protocol interfaces.=0D #=0D -# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
= =0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -73,6 +73,7 @@ =0D [Pcd]=0D gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections ## CONSUMES=0D + gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout ## CONSUMES=0D =0D [UserExtensions.TianoCore."ExtraFiles"]=0D HttpDxeExtra.uni=0D diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 5a6ecbc9d9..8790e9b4e0 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -1,7 +1,7 @@ /** @file=0D Implementation of EFI_HTTP_PROTOCOL protocol interfaces.=0D =0D - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -983,6 +983,7 @@ HttpResponseWorker ( HTTP_TOKEN_WRAP *ValueInItem;=0D UINTN HdrLen;=0D NET_FRAGMENT Fragment;=0D + UINT32 TimeoutValue;=0D =0D if (Wrap =3D=3D NULL || Wrap->HttpInstance =3D=3D NULL) {=0D return EFI_INVALID_PARAMETER;=0D @@ -1052,10 +1053,15 @@ HttpResponseWorker ( }=0D }=0D =0D + //=0D + // Get HTTP timeout value=0D + //=0D + TimeoutValue =3D PcdGet32 (PcdHttpIoTimeout);=0D +=0D //=0D // Start the timer, and wait Timeout seconds to receive the header pac= ket.=0D //=0D - Status =3D gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, H= TTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);=0D + Status =3D gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, T= imeoutValue * TICKS_PER_MS);=0D if (EFI_ERROR (Status)) {=0D goto Error;=0D }=0D @@ -1329,10 +1335,15 @@ HttpResponseWorker ( }=0D }=0D =0D + //=0D + // Get HTTP timeout value=0D + //=0D + TimeoutValue =3D PcdGet32 (PcdHttpIoTimeout);=0D +=0D //=0D // Start the timer, and wait Timeout seconds to receive the body packe= t.=0D //=0D - Status =3D gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, H= TTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);=0D + Status =3D gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, T= imeoutValue * TICKS_PER_MS);=0D if (EFI_ERROR (Status)) {=0D goto Error2;=0D }=0D diff --git a/NetworkPkg/HttpDxe/HttpProto.h b/NetworkPkg/HttpDxe/HttpProto.h index 00ba26aca4..6b3e49090e 100644 --- a/NetworkPkg/HttpDxe/HttpProto.h +++ b/NetworkPkg/HttpDxe/HttpProto.h @@ -1,7 +1,7 @@ /** @file=0D The header files of miscellaneous routines for HttpDxe driver.=0D =0D -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D (C) Copyright 2016 Hewlett Packard Enterprise Development LP
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -41,7 +41,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define HTTP_BUFFER_SIZE_DEAULT 65535=0D #define HTTP_MAX_SYN_BACK_LOG 5=0D #define HTTP_CONNECTION_TIMEOUT 60=0D -#define HTTP_RESPONSE_TIMEOUT 5=0D #define HTTP_DATA_RETRIES 12=0D #define HTTP_FIN_TIMEOUT 2=0D #define HTTP_KEEP_ALIVE_PROBES 6=0D diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index b81f10ef6e..3e1f5c101d 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -97,10 +97,6 @@ # @Prompt Max size of total HTTP chunk transfer. the default value is 12= MB.=0D gEfiNetworkPkgTokenSpaceGuid.PcdMaxHttpChunkTransfer|0x0C00000|UINT32|0x= 0000000E=0D =0D - ## The Timeout value of HTTP IO.=0D - # @Prompt The Timeout value of HTTP Io. Default value is 5000.=0D - gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout|5000|UINT32|0x0000000F=0D -=0D [PcdsFixedAtBuild, PcdsPatchableInModule]=0D ## Indicates whether HTTP connections (i.e., unsecured) are permitted or= not.=0D # TRUE - HTTP connections are allowed. Both the "https://" and "http://= " URI schemes are permitted.=0D @@ -160,5 +156,9 @@ # 0x00 =3D PXE Disabled=0D gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01|UINT8|0x1000000a=0D =0D + ## The Timeout value of HTTP IO.=0D + # @Prompt The Timeout value of HTTP Io. Default value is 5000.=0D + gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout|5000|UINT32|0x0000000F=0D +=0D [UserExtensions.TianoCore."ExtraFiles"]=0D NetworkPkgExtra.uni=0D diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc index 5e6619ad85..04685a844d 100644 --- a/NetworkPkg/NetworkPkg.dsc +++ b/NetworkPkg/NetworkPkg.dsc @@ -87,6 +87,9 @@ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f=0D gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000=0D =0D +[PcdsDynamic]=0D + gEfiNetworkPkgTokenSpaceGuid.PcdHttpTimeout|5000=0D +=0D ##########################################################################= #########################=0D #=0D # Components Section - list of the modules and components that will be pro= cessed by compilation=0D diff --git a/NetworkPkg/NetworkPkg.uni b/NetworkPkg/NetworkPkg.uni index 328d8cb54a..6d0fa67c6f 100644 --- a/NetworkPkg/NetworkPkg.uni +++ b/NetworkPkg/NetworkPkg.uni @@ -3,7 +3,7 @@ //=0D // This package provides network modules that conform to UEFI 2.4 specific= ation.=0D //=0D -// Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
= =0D +// Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
= =0D //=0D // SPDX-License-Identifier: BSD-2-Clause-Patent=0D //=0D @@ -105,3 +105,9 @@ #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdTftpBlockSize_HELP #language = en-US "This setting can override the default TFTP block size. A value of 0 = computes "=0D = "the default from MTU information. A non-zero value will be used as= block size "=0D = "in bytes."=0D +=0D +#string STR_gEfiNetworkPkgTokenSpaceGuid_PcdHttpIoTimeout_PROMPT #languag= e en-US "HTTP Boot Image Request and Response Timeout"=0D +=0D +#string STR_gEfiNetworkPkgTokenSpaceGuid_PcdHttpIoTimeout_HELP #language = en-US "This value is used to configure the request and response timeout whe= n getting "=0D + = "the recovery image from the remote source during an HTTP recovery boo= t."=0D + = "The default value set is 5 seconds."=0D --=20 2.31.1.windows.1