]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Making the HTTP IO timeout value programmable with PCD
authorZachary Clark-Williams <zachary.clark-williams@intel.com>
Wed, 28 Jul 2021 12:16:13 +0000 (20:16 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 28 Jul 2021 16:19:19 +0000 (16:19 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3507

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 <zachary.clark-williams@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/HttpBootDxe/HttpBootClient.c
NetworkPkg/HttpBootDxe/HttpBootClient.h
NetworkPkg/HttpBootDxe/HttpBootDxe.inf
NetworkPkg/HttpDxe/HttpDxe.inf
NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg/HttpDxe/HttpProto.h
NetworkPkg/NetworkPkg.dec
NetworkPkg/NetworkPkg.dsc
NetworkPkg/NetworkPkg.uni

index 8f21f7766ed1fe34bd585455cfd184374f33bda5..aa0a1530199bde7c9e0c2c28aa58100f3abc0b30 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of the boot file download function.\r
 \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -596,19 +596,25 @@ HttpBootCreateHttpIo (
   HTTP_IO_CONFIG_DATA          ConfigData;\r
   EFI_STATUS                   Status;\r
   EFI_HANDLE                   ImageHandle;\r
+  UINT32                       TimeoutValue;\r
 \r
   ASSERT (Private != NULL);\r
 \r
+  //\r
+  // Get HTTP timeout value\r
+  //\r
+  TimeoutValue = PcdGet32 (PcdHttpIoTimeout);\r
+\r
   ZeroMem (&ConfigData, sizeof (HTTP_IO_CONFIG_DATA));\r
   if (!Private->UsingIpv6) {\r
     ConfigData.Config4.HttpVersion    = HttpVersion11;\r
-    ConfigData.Config4.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT;\r
+    ConfigData.Config4.RequestTimeOut = TimeoutValue;\r
     IP4_COPY_ADDRESS (&ConfigData.Config4.LocalIp, &Private->StationIp.v4);\r
     IP4_COPY_ADDRESS (&ConfigData.Config4.SubnetMask, &Private->SubnetMask.v4);\r
     ImageHandle = Private->Ip4Nic->ImageHandle;\r
   } else {\r
     ConfigData.Config6.HttpVersion    = HttpVersion11;\r
-    ConfigData.Config6.RequestTimeOut = HTTP_BOOT_REQUEST_TIMEOUT;\r
+    ConfigData.Config6.RequestTimeOut = TimeoutValue;\r
     IP6_COPY_ADDRESS (&ConfigData.Config6.LocalIp, &Private->StationIp.v6);\r
     ImageHandle = Private->Ip6Nic->ImageHandle;\r
   }\r
index 971b2dc80019738999813e46853f433864f23c74..3a98f0f557fb260e01a291257e783df88b9c3aa4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Declaration of the boot file download function.\r
 \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -10,12 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #ifndef __EFI_HTTP_BOOT_HTTP_H__\r
 #define __EFI_HTTP_BOOT_HTTP_H__\r
 \r
-#define HTTP_BOOT_REQUEST_TIMEOUT            5000      // 5 seconds in uints of millisecond.\r
-#define HTTP_BOOT_RESPONSE_TIMEOUT           5000      // 5 seconds in uints of millisecond.\r
 #define HTTP_BOOT_BLOCK_SIZE                 1500\r
-\r
-\r
-\r
 #define HTTP_USER_AGENT_EFI_HTTP_BOOT        "UefiHttpBoot/1.0"\r
 \r
 //\r
index a27a5617224de8004c8196250ad69a6eb313db75..cffa642a4bf79fc80ab5e1f37ea69bcd75e8ce50 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  This modules produce the Load File Protocol for UEFI HTTP boot.\r
 #\r
-#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 #  (C) Copyright 2020 Hewlett-Packard Development Company, L.P.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -96,6 +96,7 @@
 \r
 [Pcd]\r
   gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections       ## CONSUMES\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout              ## CONSUMES\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   HttpBootDxeExtra.uni\r
index 35fe31af182243ea7c33d36ab5e0da85f94cd5e4..8dd38387930d07f5198eb22c0f56e32cda3ae943 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Implementation of EFI HTTP protocol interfaces.\r
 #\r
-#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
@@ -73,6 +73,7 @@
 \r
 [Pcd]\r
   gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections       ## CONSUMES\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout              ## CONSUMES\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   HttpDxeExtra.uni\r
index 5a6ecbc9d982c1db09c96ddeb61c04220a00ca1b..8790e9b4e04a6ffbda90fb47a1eeebb6a60f4e35 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
 \r
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -983,6 +983,7 @@ HttpResponseWorker (
   HTTP_TOKEN_WRAP               *ValueInItem;\r
   UINTN                         HdrLen;\r
   NET_FRAGMENT                  Fragment;\r
+  UINT32                        TimeoutValue;\r
 \r
   if (Wrap == NULL || Wrap->HttpInstance == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1052,10 +1053,15 @@ HttpResponseWorker (
       }\r
     }\r
 \r
+    //\r
+    // Get HTTP timeout value\r
+    //\r
+    TimeoutValue = PcdGet32 (PcdHttpIoTimeout);\r
+\r
     //\r
     // Start the timer, and wait Timeout seconds to receive the header packet.\r
     //\r
-    Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, HTTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);\r
+    Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, TimeoutValue * TICKS_PER_MS);\r
     if (EFI_ERROR (Status)) {\r
       goto Error;\r
     }\r
@@ -1329,10 +1335,15 @@ HttpResponseWorker (
       }\r
     }\r
 \r
+    //\r
+    // Get HTTP timeout value\r
+    //\r
+    TimeoutValue = PcdGet32 (PcdHttpIoTimeout);\r
+\r
     //\r
     // Start the timer, and wait Timeout seconds to receive the body packet.\r
     //\r
-    Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, HTTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);\r
+    Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, TimeoutValue * TICKS_PER_MS);\r
     if (EFI_ERROR (Status)) {\r
       goto Error2;\r
     }\r
index 00ba26aca49a77e55a77ec2809747fc8a7b74a14..6b3e49090e6a7d2de2b88c56a299394c0e7965a4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header files of miscellaneous routines for HttpDxe driver.\r
 \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -41,7 +41,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define HTTP_BUFFER_SIZE_DEAULT      65535\r
 #define HTTP_MAX_SYN_BACK_LOG        5\r
 #define HTTP_CONNECTION_TIMEOUT      60\r
-#define HTTP_RESPONSE_TIMEOUT        5\r
 #define HTTP_DATA_RETRIES            12\r
 #define HTTP_FIN_TIMEOUT             2\r
 #define HTTP_KEEP_ALIVE_PROBES       6\r
index b81f10ef6ec0dbf47e2647ca4a9948c339976037..3e1f5c101d5b8fa31e8b21332453f85d9178b54f 100644 (file)
   # @Prompt Max size of total HTTP chunk transfer. the default value is 12MB.\r
   gEfiNetworkPkgTokenSpaceGuid.PcdMaxHttpChunkTransfer|0x0C00000|UINT32|0x0000000E\r
 \r
-  ## The Timeout value of HTTP IO.\r
-  # @Prompt The Timeout value of HTTP Io. Default value is 5000.\r
-  gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout|5000|UINT32|0x0000000F\r
-\r
 [PcdsFixedAtBuild, PcdsPatchableInModule]\r
   ## Indicates whether HTTP connections (i.e., unsecured) are permitted or not.\r
   # TRUE  - HTTP connections are allowed. Both the "https://" and "http://" URI schemes are permitted.\r
   # 0x00 = PXE Disabled\r
   gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01|UINT8|0x1000000a\r
 \r
+  ## The Timeout value of HTTP IO.\r
+  # @Prompt The Timeout value of HTTP Io. Default value is 5000.\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout|5000|UINT32|0x0000000F\r
+\r
 [UserExtensions.TianoCore."ExtraFiles"]\r
   NetworkPkgExtra.uni\r
index 5e6619ad85aebac18364544fe709016f6285529f..cf2164aefe250fe49ce4e1d8ca85b0a6a5d2a2e4 100644 (file)
@@ -87,6 +87,9 @@
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f\r
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000\r
 \r
+[PcdsDynamicDefault]\r
+  gEfiNetworkPkgTokenSpaceGuid.PcdHttpIoTimeout|5000\r
+\r
 ###################################################################################################\r
 #\r
 # Components Section - list of the modules and components that will be processed by compilation\r
index 328d8cb54a6e6925bda1699d7b2faed2c40a988a..6d0fa67c6f93554d953a45c19e127cd544bd5222 100644 (file)
@@ -3,7 +3,7 @@
 //\r
 // This package provides network modules that conform to UEFI 2.4 specification.\r
 //\r
-// Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.<BR>\r
 //\r
 // SPDX-License-Identifier: BSD-2-Clause-Patent\r
 //\r
 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdTftpBlockSize_HELP  #language en-US "This setting can override the default TFTP block size. A value of 0 computes "\r
                                                                                   "the default from MTU information. A non-zero value will be used as block size "\r
                                                                                   "in bytes."\r
+\r
+#string STR_gEfiNetworkPkgTokenSpaceGuid_PcdHttpIoTimeout_PROMPT  #language en-US "HTTP Boot Image Request and Response Timeout"\r
+\r
+#string STR_gEfiNetworkPkgTokenSpaceGuid_PcdHttpIoTimeout_HELP  #language en-US "This value is used to configure the request and response timeout when getting "\r
+                                                                               "the recovery image from the remote source during an HTTP recovery boot."\r
+                                                                               "The default value set is 5 seconds."\r