]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Fix the issue cannot boot to UEFI Network after reset
authorZhang Lubo <lubo.zhang@intel.com>
Wed, 29 Jul 2015 04:10:09 +0000 (04:10 +0000)
committerluobozhang <luobozhang@Edk2>
Wed, 29 Jul 2015 04:10:09 +0000 (04:10 +0000)
DHCP4 service allows only one of its children to be configured
in the active state,If the DHCP4 D.O.R.A started by IP4 auto
configuration and has not been completed, the Dhcp4 state machine
will not be in the right state for the PXE to start a new round D.O.R.A.
so we need to switch it's policy to static.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18104 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf

index c0277706f2aae21f51cd57a1569d0de4aa58ca8b..587566d4e0d8a5cba7fb6a1269a6a84de223b979 100644 (file)
@@ -1506,6 +1506,52 @@ PxeBcDhcp4Discover (
   return Status;\r
 }\r
 \r
+/**\r
+  Switch the Ip4 policy to static.\r
+\r
+  @param[in]  Private             The pointer to PXEBC_PRIVATE_DATA.\r
+\r
+  @retval     EFI_SUCCESS         The policy is already configured to static.\r
+  @retval     Others              Other error as indicated..\r
+\r
+**/\r
+EFI_STATUS\r
+PxeBcSetIp4Policy (   \r
+  IN PXEBC_PRIVATE_DATA            *Private\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_IP4_CONFIG2_PROTOCOL     *Ip4Config2;\r
+  EFI_IP4_CONFIG2_POLICY       Policy;\r
+  UINTN                        DataSize;\r
+\r
+  Ip4Config2 = Private->Ip4Config2;\r
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);\r
+  Status = Ip4Config2->GetData (\r
+                       Ip4Config2,\r
+                       Ip4Config2DataTypePolicy,\r
+                       &DataSize,\r
+                       &Policy\r
+                       );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
+  if (Policy != Ip4Config2PolicyStatic) {\r
+    Policy = Ip4Config2PolicyStatic;\r
+    Status= Ip4Config2->SetData (\r
+                          Ip4Config2,\r
+                          Ip4Config2DataTypePolicy,\r
+                          sizeof (EFI_IP4_CONFIG2_POLICY),\r
+                          &Policy\r
+                          );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    } \r
+  }\r
+\r
+  return  EFI_SUCCESS;\r
+}\r
 \r
 /**\r
   Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other PXE boot information.\r
index 8e4e101806b4e8875b3e9082b2a9de164f4f4b6c..248dc60d2c165ade18a2968e31247799f78d47fb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Functions declaration related with DHCPv4 for UefiPxeBc Driver.\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -374,6 +374,20 @@ PxeBcDhcp4Discover (
   IN  EFI_PXE_BASE_CODE_SRVLIST       *SrvList\r
   );\r
 \r
+/**\r
+  Switch the Ip4 policy to static.\r
+\r
+  @param[in]  Private             The pointer to PXEBC_PRIVATE_DATA.\r
+\r
+  @retval     EFI_SUCCESS         The policy is already configured to static.\r
+  @retval     Others              Other error as indicated..\r
+\r
+**/\r
+EFI_STATUS\r
+PxeBcSetIp4Policy (   \r
+  IN PXEBC_PRIVATE_DATA            *Private\r
+  );\r
+\r
 \r
 /**\r
   Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other PXE boot information.\r
index c2987b8734a8986cbba9e0e776ca08842fa919ab..a6f66682f3b8f2fc108d6d3c9b75e54f94de180a 100644 (file)
@@ -742,6 +742,18 @@ PxeBcCreateIp4Children (
   Private->Ip4Nic->Private   = Private;\r
   Private->Ip4Nic->Signature = PXEBC_VIRTUAL_NIC_SIGNATURE;\r
 \r
+   //\r
+  // Locate Ip4->Ip4Config2 and store it for set IPv4 Policy.\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiIp4Config2ProtocolGuid,\r
+                  (VOID **) &Private->Ip4Config2\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
+\r
   //\r
   // Create a device path node for Ipv4 virtual nic, and append it.\r
   //\r
index 374b4a1667d0c8630f3f92e88679a15f054635e4..cdcf2f0d3eadd6dd15afcd0d1522e823c852f387 100644 (file)
@@ -204,6 +204,18 @@ EfiPxeBcStart (
     if (EFI_ERROR (Status)) {\r
       goto ON_ERROR;\r
     }\r
+\r
+    //\r
+    //DHCP4 service allows only one of its children to be configured in  \r
+    //the active state, If the DHCP4 D.O.R.A started by IP4 auto  \r
+    //configuration and has not been completed, the Dhcp4 state machine \r
+    //will not be in the right state for the PXE to start a new round D.O.R.A. \r
+    //so we need to switch it's policy to static.\r
+    //\r
+    Status = PxeBcSetIp4Policy (Private);\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_ERROR;\r
+    }\r
   }\r
 \r
   //\r
index 4aa3ce2f5b13310a2a70be2e01775212b261fe29..ac7dc8781a2f754e5145c1791f0922ac45ad6e3d 100644 (file)
@@ -24,6 +24,7 @@
 #include <Protocol/NetworkInterfaceIdentifier.h>\r
 #include <Protocol/Arp.h>\r
 #include <Protocol/Ip4.h>\r
+#include <Protocol/Ip4Config2.h>\r
 #include <Protocol/Ip6.h>\r
 #include <Protocol/Ip6Config.h>\r
 #include <Protocol/Udp4.h>\r
@@ -116,6 +117,7 @@ struct _PXEBC_PRIVATE_DATA {
 \r
   EFI_ARP_PROTOCOL                          *Arp;\r
   EFI_IP4_PROTOCOL                          *Ip4;\r
+  EFI_IP4_CONFIG2_PROTOCOL                  *Ip4Config2;\r
   EFI_DHCP4_PROTOCOL                        *Dhcp4;\r
   EFI_MTFTP4_PROTOCOL                       *Mtftp4;\r
   EFI_UDP4_PROTOCOL                         *Udp4Read;\r
index ea083bf1c58458ac477acbf98993c3aec26f00c6..c3ca218ba3e5b7f63f9fa0c24eb8f32c4778f312 100644 (file)
@@ -79,6 +79,7 @@
   gEfiArpProtocolGuid                                  ## TO_START\r
   gEfiIp4ServiceBindingProtocolGuid                    ## TO_START\r
   gEfiIp4ProtocolGuid                                  ## TO_START\r
+  gEfiIp4Config2ProtocolGuid                           ## TO_START\r
   gEfiIp6ServiceBindingProtocolGuid                    ## TO_START\r
   gEfiIp6ProtocolGuid                                  ## TO_START\r
   gEfiIp6ConfigProtocolGuid                            ## TO_START\r