[edk2] [Patch 2/3] MdeModulePkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.

fanwang2 posted 3 patches 7 years, 1 month ago
[edk2] [Patch 2/3] MdeModulePkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
Posted by fanwang2 7 years, 1 month ago
Since new Api NetLibDetectMediaWaitTimeout was involved to support connecting
state handling, and it is forward compatible. So apply this Api in MdeModulePkg.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
---
 MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c     | 10 +++++-----
 MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c    | 10 +++++-----
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 10 +++++-----
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
index 869a56a..25b7e0a 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
@@ -358,23 +358,23 @@ IScsiDoDhcp (
   EFI_HANDLE              Dhcp4Handle;
   EFI_DHCP4_PROTOCOL      *Dhcp4;
   EFI_STATUS              Status;
   EFI_DHCP4_PACKET_OPTION *ParaList;
   EFI_DHCP4_CONFIG_DATA   Dhcp4ConfigData;
-  BOOLEAN                 MediaPresent;
+  EFI_STATUS              MediaStatus;
   UINT8                   *Data;
 
   Dhcp4Handle = NULL;
   Dhcp4       = NULL;
   ParaList    = NULL;
 
   //
-  // Check media status before do DHCP
+  // Check media status before do DHCP, wait no more than 20 seconds
   //
-  MediaPresent = TRUE;
-  NetLibDetectMedia (Controller, &MediaPresent);
-  if (!MediaPresent) {
+  MediaStatus = EFI_SUCCESS;
+  NetLibDetectMediaWaitTimeout (Controller, EFI_TIMER_PERIOD_SECONDS(20), &MediaStatus);
+  if (MediaStatus != EFI_SUCCESS) {
     return EFI_NO_MEDIA;
   }
 
   //
   // Create a DHCP4 child instance and get the protocol.
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
index 14f13f8..3406bee 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
@@ -287,20 +287,20 @@ IScsiSessionLogin (
 {
   EFI_STATUS        Status;
   ISCSI_SESSION     *Session;
   ISCSI_CONNECTION  *Conn;
   EFI_TCP4_PROTOCOL *Tcp4;
-  BOOLEAN           MediaPresent;
+  EFI_STATUS        MediaStatus;
 
   Session = &Private->Session;
 
   //
-  // Check media status before session login
+  // Check media status before session login, wait no more than 20 seconds
   //
-  MediaPresent = TRUE;
-  NetLibDetectMedia (Private->Controller, &MediaPresent);
-  if (!MediaPresent) {
+  MediaStatus = EFI_SUCCESS;
+  NetLibDetectMediaWaitTimeout (Private->Controller, EFI_TIMER_PERIOD_SECONDS(20), &MediaStatus);
+  if (MediaStatus != EFI_SUCCESS) {
     return EFI_NO_MEDIA;
   }
 
   //
   // Set session identifier
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
index 6d4f33f..da52310 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
@@ -2799,11 +2799,11 @@ EfiPxeLoadFile (
   PXEBC_PRIVATE_DATA          *Private;
   EFI_PXE_BASE_CODE_PROTOCOL  *PxeBc;
   BOOLEAN                     NewMakeCallback;
   EFI_STATUS                  Status;
   UINT64                      TmpBufSize;
-  BOOLEAN                     MediaPresent;
+  EFI_STATUS                  MediaStatus;
 
   if (FilePath == NULL || !IsDevicePathEnd (FilePath)) {
     return EFI_INVALID_PARAMETER;
   }
   
@@ -2823,15 +2823,15 @@ EfiPxeLoadFile (
   if (!BootPolicy) {
     return EFI_UNSUPPORTED;
   }
 
   //
-  // Check media status before PXE start
+  // Check media status before PXE start, no more than 20 seconds
   //
-  MediaPresent = TRUE;
-  NetLibDetectMedia (Private->Controller, &MediaPresent);
-  if (!MediaPresent) {
+  MediaStatus = EFI_SUCCESS;
+  NetLibDetectMediaWaitTimeout (Private->Controller, EFI_TIMER_PERIOD_SECONDS(20), &MediaStatus);
+  if (MediaStatus != EFI_SUCCESS) {
     return EFI_NO_MEDIA;
   }
 
   Status = PxeBc->Start (PxeBc, FALSE);
   if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel