This patch only fixed the PXE driver in NetworkPkg, please double check the PXE 
driver in MdeModulePkg whether has the same issue. If so, another patch is also 
required.

Thanks.
Jiaxin

-----Original Message-----
From: Zhang, Lubo 
Sent: Monday, July 27, 2015 4:52 PM
To: [email protected]
Cc: Fu, Siyuan; Ye, Ting; Wu, Jiaxin
Subject: [patch] NetworkPkg: Fix the issue cannot boot to UEFI Network

If the DHCP4 DORA process has not been completed by IP4 Driver, then the Dhcp4 
state machine will not be the right state for the PXE to start D.O.R.A. process 
successfully.

Cc: Fu Siyuan<[email protected]>
Cc: Ye Ting<[email protected]>
CC: Wu Jiaxin <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <[email protected]>
---
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c     | 46 ++++++++++++++++++++++++++++++++
 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h     | 16 ++++++++++-
 NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c    | 12 +++++++++
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c      | 10 +++++++
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h      |  2 ++
 NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf |  1 +
 6 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
index c027770..587566d 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
@@ -1504,10 +1504,56 @@ PxeBcDhcp4Discover (
 
   FreePool (Token.Packet);
   return Status;
 }
 
+/**
+  Switch the Ip4 policy to static.
+
+  @param[in]  Private             The pointer to PXEBC_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         The policy is already configured to static.
+  @retval     Others              Other error as indicated..
+
+**/
+EFI_STATUS
+PxeBcSetIp4Policy (   
+  IN PXEBC_PRIVATE_DATA            *Private
+  )
+{
+  EFI_STATUS                   Status;
+  EFI_IP4_CONFIG2_PROTOCOL     *Ip4Config2;
+  EFI_IP4_CONFIG2_POLICY       Policy;
+  UINTN                        DataSize;
+
+  Ip4Config2 = Private->Ip4Config2;
+  DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);  Status = 
+ Ip4Config2->GetData (
+                       Ip4Config2,
+                       Ip4Config2DataTypePolicy,
+                       &DataSize,
+                       &Policy
+                       );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  
+  if (Policy != Ip4Config2PolicyStatic) {
+    Policy = Ip4Config2PolicyStatic;
+    Status= Ip4Config2->SetData (
+                          Ip4Config2,
+                          Ip4Config2DataTypePolicy,
+                          sizeof (EFI_IP4_CONFIG2_POLICY),
+                          &Policy
+                          );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+  }
+
+  return  EFI_SUCCESS;
+}
 
 /**
   Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other PXE 
boot information.
 
   @param[in]  Private           Pointer to PxeBc private data.
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
index 8e4e101..248dc60 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
@@ -1,9 +1,9 @@
 /** @file
   Functions declaration related with DHCPv4 for UefiPxeBc Driver.
 
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 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.
@@ -372,10 +372,24 @@ PxeBcDhcp4Discover (
   IN  EFI_IP_ADDRESS                  *DestIp,
   IN  UINT16                          IpCount,
   IN  EFI_PXE_BASE_CODE_SRVLIST       *SrvList
   );
 
+/**
+  Switch the Ip4 policy to static.
+
+  @param[in]  Private             The pointer to PXEBC_PRIVATE_DATA.
+
+  @retval     EFI_SUCCESS         The policy is already configured to static.
+  @retval     Others              Other error as indicated..
+
+**/
+EFI_STATUS
+PxeBcSetIp4Policy (   
+  IN PXEBC_PRIVATE_DATA            *Private
+  );
+
 
 /**
   Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other PXE 
boot information.
 
   @param[in]  Private           Pointer to PxeBc private data.
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
index c2987b8..a6f6668 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -740,10 +740,22 @@ PxeBcCreateIp4Children (
   }
 
   Private->Ip4Nic->Private   = Private;
   Private->Ip4Nic->Signature = PXEBC_VIRTUAL_NIC_SIGNATURE;
 
+   //
+  // Locate Ip4->Ip4Config2 and store it for set IPv4 Policy.
+  //
+  Status = gBS->HandleProtocol (
+                  ControllerHandle,
+                  &gEfiIp4Config2ProtocolGuid,
+                  (VOID **) &Private->Ip4Config2
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
   //
   // Create a device path node for Ipv4 virtual nic, and append it.
   //
   ZeroMem (&Ip4Node, sizeof (IPv4_DEVICE_PATH));
   Ip4Node.Header.Type     = MESSAGING_DEVICE_PATH;
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index 374b4a1..9a5160b 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -202,10 +202,20 @@ EfiPxeBcStart (
                     &Private->IcmpToken.Event
                     );
     if (EFI_ERROR (Status)) {
       goto ON_ERROR;
     }
+
+    //
+    //If the DHCP4 DORA process has not been completed by IP4 Configuration, 
+    //then the Dhcp4 state machine will not be the right state for the PXE  
+    //to start D.O.R.A. process successfully,so we need to switch it's policy 
to static.
+    //
+    Status = PxeBcSetIp4Policy (Private);
+    if (EFI_ERROR (Status)) {
+      goto ON_ERROR;
+    }
   }
 
   //
   // If PcdTftpBlockSize is set to non-zero, override the default value.
   //
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h 
b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
index 4aa3ce2..ac7dc87 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
@@ -22,10 +22,11 @@
 #include <Guid/SmBios.h>
 #include <IndustryStandard/SmBios.h>
 #include <Protocol/NetworkInterfaceIdentifier.h>
 #include <Protocol/Arp.h>
 #include <Protocol/Ip4.h>
+#include <Protocol/Ip4Config2.h>
 #include <Protocol/Ip6.h>
 #include <Protocol/Ip6Config.h>
 #include <Protocol/Udp4.h>
 #include <Protocol/Udp6.h>
 #include <Protocol/Dhcp4.h>
@@ -114,10 +115,11 @@ struct _PXEBC_PRIVATE_DATA {
   EFI_HANDLE                                Udp4ReadChild;
   EFI_HANDLE                                Udp4WriteChild;
 
   EFI_ARP_PROTOCOL                          *Arp;
   EFI_IP4_PROTOCOL                          *Ip4;
+  EFI_IP4_CONFIG2_PROTOCOL                  *Ip4Config2;
   EFI_DHCP4_PROTOCOL                        *Dhcp4;
   EFI_MTFTP4_PROTOCOL                       *Mtftp4;
   EFI_UDP4_PROTOCOL                         *Udp4Read;
   EFI_UDP4_PROTOCOL                         *Udp4Write;
 
diff --git a/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf 
b/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
index ea083bf..c3ca218 100644
--- a/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
+++ b/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
@@ -77,10 +77,11 @@
   gEfiNetworkInterfaceIdentifierProtocolGuid_31        ## SOMETIMES_CONSUMES
   gEfiArpServiceBindingProtocolGuid                    ## TO_START
   gEfiArpProtocolGuid                                  ## TO_START
   gEfiIp4ServiceBindingProtocolGuid                    ## TO_START
   gEfiIp4ProtocolGuid                                  ## TO_START
+  gEfiIp4Config2ProtocolGuid                           ## TO_START
   gEfiIp6ServiceBindingProtocolGuid                    ## TO_START
   gEfiIp6ProtocolGuid                                  ## TO_START
   gEfiIp6ConfigProtocolGuid                            ## TO_START
   gEfiUdp4ServiceBindingProtocolGuid                   ## TO_START
   gEfiUdp4ProtocolGuid                                 ## TO_START
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to