public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/3] *** SUBJECT HERE ***
@ 2017-12-12  8:53 fanwang2
  2017-12-12  8:54 ` [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout fanwang2
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: fanwang2 @ 2017-12-12  8:53 UTC (permalink / raw)
  To: edk2-devel

This patch updates the Api NetLibDetectMedia to NetLibDetectMediaWaitTimeout.

Wang Fan (3):
  NetworkPkg: Update Api from NetLibDetectMedia to
    NetLibDetectMediaWaitTimeout.
  MdeModulePkg: Update Api from NetLibDetectMedia to
    NetLibDetectMediaWaitTimeout.
  ShellPkg: Update Api from NetLibDetectMedia to
    NetLibDetectMediaWaitTimeout.

 MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c  | 10 +++++-----
 MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c | 10 +++++-----
 .../Universal/Network/UefiPxeBcDxe/PxeBcImpl.c       | 10 +++++-----
 NetworkPkg/DnsDxe/DnsDhcp.c                          | 20 ++++++++++----------
 NetworkPkg/HttpBootDxe/HttpBootImpl.c                | 10 +++++-----
 NetworkPkg/IScsiDxe/IScsiDhcp.c                      | 11 ++++++-----
 NetworkPkg/IScsiDxe/IScsiDhcp6.c                     | 11 ++++++-----
 NetworkPkg/IScsiDxe/IScsiProto.c                     |  8 ++++----
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c                  | 10 +++++-----
 .../Library/UefiShellNetwork1CommandsLib/Ifconfig.c  |  8 ++++----
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c |  8 ++++----
 .../Library/UefiShellNetwork2CommandsLib/Ping6.c     |  8 ++++----
 12 files changed, 63 insertions(+), 61 deletions(-)

-- 
1.9.5.msysgit.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
  2017-12-12  8:53 [Patch 0/3] *** SUBJECT HERE *** fanwang2
@ 2017-12-12  8:54 ` fanwang2
  2017-12-13  1:43   ` Fu, Siyuan
  2017-12-12  8:54 ` [Patch 2/3] MdeModulePkg: " fanwang2
  2017-12-12  8:54 ` [Patch 3/3] ShellPkg: " fanwang2
  2 siblings, 1 reply; 5+ messages in thread
From: fanwang2 @ 2017-12-12  8:54 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin, Wang Fan

Since new Api NetLibDetectMediaWaitTimeout was involved to support connecting
state handling, and it is forward compatible. So apply this Api in Network.

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>
---
 NetworkPkg/DnsDxe/DnsDhcp.c           | 20 ++++++++++----------
 NetworkPkg/HttpBootDxe/HttpBootImpl.c | 10 +++++-----
 NetworkPkg/IScsiDxe/IScsiDhcp.c       | 11 ++++++-----
 NetworkPkg/IScsiDxe/IScsiDhcp6.c      | 11 ++++++-----
 NetworkPkg/IScsiDxe/IScsiProto.c      |  8 ++++----
 NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c   | 10 +++++-----
 6 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c
index 93779be..604047c 100644
--- a/NetworkPkg/DnsDxe/DnsDhcp.c
+++ b/NetworkPkg/DnsDxe/DnsDhcp.c
@@ -267,11 +267,11 @@ GetDns4ServerFromDhcp4 (
   )
 {
   EFI_STATUS                          Status;
   EFI_HANDLE                          Image;
   EFI_HANDLE                          Controller;
-  BOOLEAN                             MediaPresent;
+  EFI_STATUS                          MediaStatus;
   EFI_HANDLE                          MnpChildHandle;  
   EFI_MANAGED_NETWORK_PROTOCOL        *Mnp;
   EFI_MANAGED_NETWORK_CONFIG_DATA     MnpConfigData;
   EFI_HANDLE                          Dhcp4Handle;  
   EFI_DHCP4_PROTOCOL                  *Dhcp4;
@@ -312,15 +312,15 @@ GetDns4ServerFromDhcp4 (
   DnsServerInfor.ServerCount = DnsServerCount;
 
   IsDone = FALSE;
 
   //
-  // Check media.
+  // Check media status, 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 Mnp child instance, get the protocol and config for it.
@@ -618,11 +618,11 @@ GetDns6ServerFromDhcp6 (
   EFI_STATUS                Status;
   EFI_STATUS                TimerStatus;
   EFI_DHCP6_PACKET_OPTION   *Oro;
   EFI_DHCP6_RETRANSMISSION  InfoReqReXmit;
   EFI_EVENT                 Timer;
-  BOOLEAN                   MediaPresent;
+  EFI_STATUS                MediaStatus;
   DNS6_SERVER_INFOR         DnsServerInfor;
 
   Dhcp6Handle = NULL;
   Dhcp6       = NULL;
   Oro         = NULL;
@@ -631,15 +631,15 @@ GetDns6ServerFromDhcp6 (
   ZeroMem (&DnsServerInfor, sizeof (DNS6_SERVER_INFOR));
 
   DnsServerInfor.ServerCount = DnsServerCount;
 
   //
-  // Check media status before doing DHCP.
+  // Check media, 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 DHCP6 child instance and get the protocol.
diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index d591db5..05fea28 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -546,11 +546,11 @@ HttpBootDxeLoadFile (
   IN VOID                             *Buffer OPTIONAL
   )
 {
   HTTP_BOOT_PRIVATE_DATA        *Private;
   HTTP_BOOT_VIRTUAL_NIC         *VirtualNic;
-  BOOLEAN                       MediaPresent;
+  EFI_STATUS                    MediaStatus;
   BOOLEAN                       UsingIpv6;
   EFI_STATUS                    Status;
   HTTP_BOOT_IMAGE_TYPE          ImageType;
 
   if (This == NULL || BufferSize == NULL || FilePath == NULL) {
@@ -566,15 +566,15 @@ HttpBootDxeLoadFile (
 
   VirtualNic = HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE (This);
   Private = VirtualNic->Private;
   
   //
-  // Check media status before HTTP boot start
+  // Check media status before HTTP boot start, 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) {
     AsciiPrint ("\n  Error: Could not detect network connection.\n");
     return EFI_NO_MEDIA;
   }
   
   //
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhcp.c
index 309ce0d..6d25cde 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
@@ -441,23 +441,24 @@ IScsiDoDhcp (
   EFI_DHCP4_PROTOCOL            *Dhcp4;
   EFI_STATUS                    Status;
   EFI_DHCP4_PACKET_OPTION       *ParaList;
   EFI_DHCP4_CONFIG_DATA         Dhcp4ConfigData;
   ISCSI_SESSION_CONFIG_NVDATA   *NvData;
-  BOOLEAN                       MediaPresent;
+  EFI_STATUS                    MediaStatus;
 
   Dhcp4Handle = NULL;
   Ip4Config2  = NULL;
   Dhcp4       = NULL;
   ParaList    = NULL;
 
   //
-  // Check media status before doing DHCP.
+  // Check media status, 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) {
+    AsciiPrint ("\n  Error: Could not detect network connection.\n");
     return EFI_NO_MEDIA;
   }
 
   //
   // DHCP4 service allows only one of its children to be configured in  
diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c b/NetworkPkg/IScsiDxe/IScsiDhcp6.c
index 06c634c..0d57704 100644
--- a/NetworkPkg/IScsiDxe/IScsiDhcp6.c
+++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.c
@@ -399,18 +399,19 @@ IScsiDoDhcp6 (
   EFI_STATUS                Status;
   EFI_STATUS                TimerStatus;
   EFI_DHCP6_PACKET_OPTION   *Oro;
   EFI_DHCP6_RETRANSMISSION  InfoReqReXmit;
   EFI_EVENT                 Timer;
-  BOOLEAN                   MediaPresent;
+  EFI_STATUS                MediaStatus;
 
   //
-  // Check media status before doing DHCP.
+  // Check media status, 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) {
+    AsciiPrint ("\n  Error: Could not detect network connection.\n");
     return EFI_NO_MEDIA;
   }
 
   //
   // iSCSI will only request target info from DHCPv6 server.
diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiProto.c
index 1602a26..ccdd5df 100644
--- a/NetworkPkg/IScsiDxe/IScsiProto.c
+++ b/NetworkPkg/IScsiDxe/IScsiProto.c
@@ -442,18 +442,18 @@ IScsiSessionLogin (
   EFI_STATUS        Status;
   ISCSI_CONNECTION  *Conn;
   VOID              *Tcp;
   EFI_GUID          *ProtocolGuid;
   UINT8             RetryCount;
-  BOOLEAN           MediaPresent;
+  EFI_STATUS        MediaStatus;
 
   //
   // Check media status before session login.
   //
-  MediaPresent = TRUE;
-  NetLibDetectMedia (Session->Private->Controller, &MediaPresent);
-  if (!MediaPresent) {
+  MediaStatus = EFI_SUCCESS;
+  NetLibDetectMediaWaitTimeout (Session->Private->Controller, EFI_TIMER_PERIOD_SECONDS(20), &MediaStatus);
+  if (MediaStatus != EFI_SUCCESS) {
     return EFI_NO_MEDIA;
   }
 
   //
   // Set session identifier
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
index ab9e494..7940cbe 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
@@ -2345,11 +2345,11 @@ EfiPxeLoadFile (
   PXEBC_PRIVATE_DATA          *Private;
   PXEBC_VIRTUAL_NIC           *VirtualNic;
   EFI_PXE_BASE_CODE_PROTOCOL  *PxeBc;
   BOOLEAN                     UsingIpv6;
   EFI_STATUS                  Status;
-  BOOLEAN                     MediaPresent;
+  EFI_STATUS                  MediaStatus;
 
   if (FilePath == NULL || !IsDevicePathEnd (FilePath)) {
     return EFI_INVALID_PARAMETER;
   }
   
@@ -2369,15 +2369,15 @@ EfiPxeLoadFile (
   if (!BootPolicy) {
     return EFI_UNSUPPORTED;
   }
 
   //
-  // Check media status before PXE start
+  // Check media status before PXE start, 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;
   }
 
   //
   // Check whether the virtual nic is using IPv6 or not.
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Patch 2/3] MdeModulePkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
  2017-12-12  8:53 [Patch 0/3] *** SUBJECT HERE *** fanwang2
  2017-12-12  8:54 ` [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout fanwang2
@ 2017-12-12  8:54 ` fanwang2
  2017-12-12  8:54 ` [Patch 3/3] ShellPkg: " fanwang2
  2 siblings, 0 replies; 5+ messages in thread
From: fanwang2 @ 2017-12-12  8:54 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin, Wang Fan

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Patch 3/3] ShellPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
  2017-12-12  8:53 [Patch 0/3] *** SUBJECT HERE *** fanwang2
  2017-12-12  8:54 ` [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout fanwang2
  2017-12-12  8:54 ` [Patch 2/3] MdeModulePkg: " fanwang2
@ 2017-12-12  8:54 ` fanwang2
  2 siblings, 0 replies; 5+ messages in thread
From: fanwang2 @ 2017-12-12  8:54 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin, Wang Fan

Since new Api NetLibDetectMediaWaitTimeout was involved to support connecting
state handling, and it is forward compatible. So apply this Api in ShellPkg.

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>
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 8 ++++----
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c     | 8 ++++----
 ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c    | 8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 082ab72..ab6ab8b 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -548,15 +548,15 @@ IfConfigShowInterfaceInfo (
   )
 {
   LIST_ENTRY                   *Entry;
   LIST_ENTRY                   *Next;
   IFCONFIG_INTERFACE_CB        *IfCb;
-  BOOLEAN                       MediaPresent;
+  EFI_STATUS                    MediaStatus;
   EFI_IPv4_ADDRESS              Gateway;
   UINT32                        Index;
   
-  MediaPresent = TRUE;
+  MediaStatus = EFI_SUCCESS;
 
   if (IsListEmpty (IfList)) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_INTERFACE), gShellNetwork1HiiHandle);
   }
 
@@ -574,12 +574,12 @@ IfConfigShowInterfaceInfo (
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_IF_NAME), gShellNetwork1HiiHandle, IfCb->IfInfo->Name); 
 
     //
     // Get Media State.
     //
-    if (EFI_SUCCESS == NetLibDetectMedia (IfCb->NicHandle, &MediaPresent)) {
-      if (!MediaPresent) {
+    if (EFI_SUCCESS == NetLibDetectMediaWaitTimeout (IfCb->NicHandle, 0, &MediaStatus)) {
+      if (MediaStatus != EFI_SUCCESS) {
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media disconnected");
       } else {
         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
       }
     } else {
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
index 10d291c..bec9535 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c
@@ -964,11 +964,11 @@ PingCreateIpInstance (
   EFI_STATUS                       Status;
   UINTN                            HandleIndex;
   UINTN                            HandleNum;
   EFI_HANDLE                       *HandleBuffer;
   BOOLEAN                          UnspecifiedSrc;
-  BOOLEAN                          MediaPresent;
+  EFI_STATUS                       MediaStatus;
   EFI_SERVICE_BINDING_PROTOCOL     *EfiSb;
   VOID                             *IpXCfg;
   EFI_IP6_CONFIG_DATA              Ip6Config;
   EFI_IP4_CONFIG_DATA              Ip4Config;
   VOID                             *IpXInterfaceInfo;
@@ -976,11 +976,11 @@ PingCreateIpInstance (
   EFI_IPv6_ADDRESS                 *Addr;
   UINTN                            AddrIndex;
 
   HandleBuffer      = NULL;
   UnspecifiedSrc    = FALSE;
-  MediaPresent      = TRUE;
+  MediaStatus       = EFI_SUCCESS;
   EfiSb             = NULL;
   IpXInterfaceInfo  = NULL;
   IfInfoSize        = 0;
 
   //
@@ -1033,12 +1033,12 @@ PingCreateIpInstance (
 
     if (UnspecifiedSrc) {
       //
       // Check media.
       //
-      NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
-      if (!MediaPresent) {
+      NetLibDetectMediaWaitTimeout (HandleBuffer[HandleIndex], 0, &MediaStatus);
+      if (MediaStatus != EFI_SUCCESS) {
         //
         // Skip this one.
         //
         continue;
       }
diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
index b784696..fa27c82 100644
--- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
+++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ping6.c
@@ -753,22 +753,22 @@ Ping6CreateIpInstance (
   EFI_STATUS                       Status;
   UINTN                            HandleIndex;
   UINTN                            HandleNum;
   EFI_HANDLE                       *HandleBuffer;
   BOOLEAN                          UnspecifiedSrc;
-  BOOLEAN                          MediaPresent;
+  EFI_STATUS                       MediaStatus;
   EFI_SERVICE_BINDING_PROTOCOL     *Ip6Sb;
   EFI_IP6_CONFIG_PROTOCOL          *Ip6Cfg;
   EFI_IP6_CONFIG_DATA              Ip6Config;
   EFI_IP6_CONFIG_INTERFACE_INFO    *IfInfo;
   UINTN                            IfInfoSize;
   EFI_IPv6_ADDRESS                 *Addr;
   UINTN                            AddrIndex;
 
   HandleBuffer      = NULL;
   UnspecifiedSrc    = FALSE;
-  MediaPresent      = TRUE;
+  MediaStatus       = EFI_SUCCESS
   Ip6Sb             = NULL;
   IfInfo            = NULL;
   IfInfoSize        = 0;
 
   //
@@ -812,12 +812,12 @@ Ping6CreateIpInstance (
 
     if (UnspecifiedSrc) {
       //
       // Check media.
       //
-      NetLibDetectMedia (HandleBuffer[HandleIndex], &MediaPresent);
-      if (!MediaPresent) {
+      NetLibDetectMediaWaitTimeout (HandleBuffer[HandleIndex], 0, &MediaStatus);
+      if (MediaStatus != EFI_SUCCESS) {
         //
         // Skip this one.
         //
         continue;
       }
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
  2017-12-12  8:54 ` [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout fanwang2
@ 2017-12-13  1:43   ` Fu, Siyuan
  0 siblings, 0 replies; 5+ messages in thread
From: Fu, Siyuan @ 2017-12-13  1:43 UTC (permalink / raw)
  To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wu, Jiaxin

Hi, Fan

We'd better to define a macro for the timeout, instead of using 20 in each place.

BestRegards
Fu Siyuan


> -----Original Message-----
> From: Wang, Fan
> Sent: Tuesday, December 12, 2017 4:54 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>; Wang, Fan <fan.wang@intel.com>
> Subject: [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to
> NetLibDetectMediaWaitTimeout.
> 
> Since new Api NetLibDetectMediaWaitTimeout was involved to support
> connecting
> state handling, and it is forward compatible. So apply this Api in Network.
> 
> 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>
> ---
>  NetworkPkg/DnsDxe/DnsDhcp.c           | 20 ++++++++++----------
>  NetworkPkg/HttpBootDxe/HttpBootImpl.c | 10 +++++-----
>  NetworkPkg/IScsiDxe/IScsiDhcp.c       | 11 ++++++-----
>  NetworkPkg/IScsiDxe/IScsiDhcp6.c      | 11 ++++++-----
>  NetworkPkg/IScsiDxe/IScsiProto.c      |  8 ++++----
>  NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c   | 10 +++++-----
>  6 files changed, 36 insertions(+), 34 deletions(-)
> 
> diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c
> index 93779be..604047c 100644
> --- a/NetworkPkg/DnsDxe/DnsDhcp.c
> +++ b/NetworkPkg/DnsDxe/DnsDhcp.c
> @@ -267,11 +267,11 @@ GetDns4ServerFromDhcp4 (
>    )
>  {
>    EFI_STATUS                          Status;
>    EFI_HANDLE                          Image;
>    EFI_HANDLE                          Controller;
> -  BOOLEAN                             MediaPresent;
> +  EFI_STATUS                          MediaStatus;
>    EFI_HANDLE                          MnpChildHandle;
>    EFI_MANAGED_NETWORK_PROTOCOL        *Mnp;
>    EFI_MANAGED_NETWORK_CONFIG_DATA     MnpConfigData;
>    EFI_HANDLE                          Dhcp4Handle;
>    EFI_DHCP4_PROTOCOL                  *Dhcp4;
> @@ -312,15 +312,15 @@ GetDns4ServerFromDhcp4 (
>    DnsServerInfor.ServerCount = DnsServerCount;
> 
>    IsDone = FALSE;
> 
>    //
> -  // Check media.
> +  // Check media status, 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 Mnp child instance, get the protocol and config for it.
> @@ -618,11 +618,11 @@ GetDns6ServerFromDhcp6 (
>    EFI_STATUS                Status;
>    EFI_STATUS                TimerStatus;
>    EFI_DHCP6_PACKET_OPTION   *Oro;
>    EFI_DHCP6_RETRANSMISSION  InfoReqReXmit;
>    EFI_EVENT                 Timer;
> -  BOOLEAN                   MediaPresent;
> +  EFI_STATUS                MediaStatus;
>    DNS6_SERVER_INFOR         DnsServerInfor;
> 
>    Dhcp6Handle = NULL;
>    Dhcp6       = NULL;
>    Oro         = NULL;
> @@ -631,15 +631,15 @@ GetDns6ServerFromDhcp6 (
>    ZeroMem (&DnsServerInfor, sizeof (DNS6_SERVER_INFOR));
> 
>    DnsServerInfor.ServerCount = DnsServerCount;
> 
>    //
> -  // Check media status before doing DHCP.
> +  // Check media, 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 DHCP6 child instance and get the protocol.
> diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> index d591db5..05fea28 100644
> --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
> @@ -546,11 +546,11 @@ HttpBootDxeLoadFile (
>    IN VOID                             *Buffer OPTIONAL
>    )
>  {
>    HTTP_BOOT_PRIVATE_DATA        *Private;
>    HTTP_BOOT_VIRTUAL_NIC         *VirtualNic;
> -  BOOLEAN                       MediaPresent;
> +  EFI_STATUS                    MediaStatus;
>    BOOLEAN                       UsingIpv6;
>    EFI_STATUS                    Status;
>    HTTP_BOOT_IMAGE_TYPE          ImageType;
> 
>    if (This == NULL || BufferSize == NULL || FilePath == NULL) {
> @@ -566,15 +566,15 @@ HttpBootDxeLoadFile (
> 
>    VirtualNic = HTTP_BOOT_VIRTUAL_NIC_FROM_LOADFILE (This);
>    Private = VirtualNic->Private;
> 
>    //
> -  // Check media status before HTTP boot start
> +  // Check media status before HTTP boot start, 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) {
>      AsciiPrint ("\n  Error: Could not detect network connection.\n");
>      return EFI_NO_MEDIA;
>    }
> 
>    //
> diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c
> b/NetworkPkg/IScsiDxe/IScsiDhcp.c
> index 309ce0d..6d25cde 100644
> --- a/NetworkPkg/IScsiDxe/IScsiDhcp.c
> +++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c
> @@ -441,23 +441,24 @@ IScsiDoDhcp (
>    EFI_DHCP4_PROTOCOL            *Dhcp4;
>    EFI_STATUS                    Status;
>    EFI_DHCP4_PACKET_OPTION       *ParaList;
>    EFI_DHCP4_CONFIG_DATA         Dhcp4ConfigData;
>    ISCSI_SESSION_CONFIG_NVDATA   *NvData;
> -  BOOLEAN                       MediaPresent;
> +  EFI_STATUS                    MediaStatus;
> 
>    Dhcp4Handle = NULL;
>    Ip4Config2  = NULL;
>    Dhcp4       = NULL;
>    ParaList    = NULL;
> 
>    //
> -  // Check media status before doing DHCP.
> +  // Check media status, 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) {
> +    AsciiPrint ("\n  Error: Could not detect network connection.\n");
>      return EFI_NO_MEDIA;
>    }
> 
>    //
>    // DHCP4 service allows only one of its children to be configured in
> diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c
> b/NetworkPkg/IScsiDxe/IScsiDhcp6.c
> index 06c634c..0d57704 100644
> --- a/NetworkPkg/IScsiDxe/IScsiDhcp6.c
> +++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.c
> @@ -399,18 +399,19 @@ IScsiDoDhcp6 (
>    EFI_STATUS                Status;
>    EFI_STATUS                TimerStatus;
>    EFI_DHCP6_PACKET_OPTION   *Oro;
>    EFI_DHCP6_RETRANSMISSION  InfoReqReXmit;
>    EFI_EVENT                 Timer;
> -  BOOLEAN                   MediaPresent;
> +  EFI_STATUS                MediaStatus;
> 
>    //
> -  // Check media status before doing DHCP.
> +  // Check media status, 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) {
> +    AsciiPrint ("\n  Error: Could not detect network connection.\n");
>      return EFI_NO_MEDIA;
>    }
> 
>    //
>    // iSCSI will only request target info from DHCPv6 server.
> diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c
> b/NetworkPkg/IScsiDxe/IScsiProto.c
> index 1602a26..ccdd5df 100644
> --- a/NetworkPkg/IScsiDxe/IScsiProto.c
> +++ b/NetworkPkg/IScsiDxe/IScsiProto.c
> @@ -442,18 +442,18 @@ IScsiSessionLogin (
>    EFI_STATUS        Status;
>    ISCSI_CONNECTION  *Conn;
>    VOID              *Tcp;
>    EFI_GUID          *ProtocolGuid;
>    UINT8             RetryCount;
> -  BOOLEAN           MediaPresent;
> +  EFI_STATUS        MediaStatus;
> 
>    //
>    // Check media status before session login.
>    //
> -  MediaPresent = TRUE;
> -  NetLibDetectMedia (Session->Private->Controller, &MediaPresent);
> -  if (!MediaPresent) {
> +  MediaStatus = EFI_SUCCESS;
> +  NetLibDetectMediaWaitTimeout (Session->Private->Controller,
> EFI_TIMER_PERIOD_SECONDS(20), &MediaStatus);
> +  if (MediaStatus != EFI_SUCCESS) {
>      return EFI_NO_MEDIA;
>    }
> 
>    //
>    // Set session identifier
> diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> index ab9e494..7940cbe 100644
> --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
> @@ -2345,11 +2345,11 @@ EfiPxeLoadFile (
>    PXEBC_PRIVATE_DATA          *Private;
>    PXEBC_VIRTUAL_NIC           *VirtualNic;
>    EFI_PXE_BASE_CODE_PROTOCOL  *PxeBc;
>    BOOLEAN                     UsingIpv6;
>    EFI_STATUS                  Status;
> -  BOOLEAN                     MediaPresent;
> +  EFI_STATUS                  MediaStatus;
> 
>    if (FilePath == NULL || !IsDevicePathEnd (FilePath)) {
>      return EFI_INVALID_PARAMETER;
>    }
> 
> @@ -2369,15 +2369,15 @@ EfiPxeLoadFile (
>    if (!BootPolicy) {
>      return EFI_UNSUPPORTED;
>    }
> 
>    //
> -  // Check media status before PXE start
> +  // Check media status before PXE start, 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;
>    }
> 
>    //
>    // Check whether the virtual nic is using IPv6 or not.
> --
> 1.9.5.msysgit.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-13  1:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-12  8:53 [Patch 0/3] *** SUBJECT HERE *** fanwang2
2017-12-12  8:54 ` [Patch 1/3] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout fanwang2
2017-12-13  1:43   ` Fu, Siyuan
2017-12-12  8:54 ` [Patch 2/3] MdeModulePkg: " fanwang2
2017-12-12  8:54 ` [Patch 3/3] ShellPkg: " fanwang2

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox