From nobody Fri Nov 1 16:36:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1513245229630491.281250374279; Thu, 14 Dec 2017 01:53:49 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DBF6B2034B9FE; Thu, 14 Dec 2017 01:49:07 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5534C2034B9FC for ; Thu, 14 Dec 2017 01:49:07 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2017 01:53:48 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga002.jf.intel.com with ESMTP; 14 Dec 2017 01:53:46 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,400,1508828400"; d="scan'208";a="18149669" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 14 Dec 2017 17:53:09 +0800 Message-Id: <1513245190-8172-3-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1513245190-8172-1-git-send-email-fan.wang@intel.com> References: <1513245190-8172-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 2/3 V2] NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wang Fan V2: *Define time period in a macro instead of hard code. Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c | 8 ++++---- NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h | 2 ++ NetworkPkg/DnsDxe/DnsDhcp.c | 16 ++++++++-------- NetworkPkg/DnsDxe/DnsDhcp.h | 2 ++ NetworkPkg/HttpBootDxe/HttpBootImpl.c | 8 ++++---- NetworkPkg/HttpBootDxe/HttpBootImpl.h | 2 ++ NetworkPkg/IScsiDxe/IScsiDhcp.c | 9 +++++---- NetworkPkg/IScsiDxe/IScsiDhcp6.c | 9 +++++---- NetworkPkg/IScsiDxe/IScsiProto.c | 8 ++++---- NetworkPkg/IScsiDxe/IScsiProto.h | 3 +++ NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c | 8 ++++---- NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h | 2 ++ 12 files changed, 45 insertions(+), 32 deletions(-) diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Imp= l.c index 1107865..b479421 100644 --- a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c +++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c @@ -74,11 +74,11 @@ EfiDhcp6Start ( { EFI_STATUS Status; EFI_TPL OldTpl; DHCP6_INSTANCE *Instance; DHCP6_SERVICE *Service; - BOOLEAN MediaPresent; + EFI_STATUS MediaStatus; =20 if (This =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 @@ -104,13 +104,13 @@ EfiDhcp6Start ( OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 // // Check Media Satus. // - MediaPresent =3D TRUE; - NetLibDetectMedia (Service->Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Service->Controller, DHCP_CHECK_MEDIA_WAIT= ING_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { Status =3D EFI_NO_MEDIA; goto ON_ERROR; } =20 Instance->UdpSts =3D EFI_ALREADY_STARTED; diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h b/NetworkPkg/Dhcp6Dxe/Dhcp6Imp= l.h index 06780b6..7110bf8 100644 --- a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h +++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h @@ -60,10 +60,12 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE; #define DHCP6_BASE_PACKET_SIZE 1024 =20 #define DHCP6_PORT_CLIENT 546 #define DHCP6_PORT_SERVER 547 =20 +#define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) + #define DHCP6_INSTANCE_FROM_THIS(Instance) CR ((Instance), DHCP6_INSTANCE,= Dhcp6, DHCP6_INSTANCE_SIGNATURE) #define DHCP6_SERVICE_FROM_THIS(Service) CR ((Service), DHCP6_SERVICE, S= erviceBinding, DHCP6_SERVICE_SIGNATURE) =20 extern EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress; extern EFI_IPv6_ADDRESS mAllDhcpServersAddress; diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c index 93779be..951477b 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; =20 EFI_MANAGED_NETWORK_PROTOCOL *Mnp; EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData; EFI_HANDLE Dhcp4Handle; =20 EFI_DHCP4_PROTOCOL *Dhcp4; @@ -314,13 +314,13 @@ GetDns4ServerFromDhcp4 ( IsDone =3D FALSE; =20 // // Check media. // - MediaPresent =3D TRUE; - NetLibDetectMedia (Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Controller, DNS_CHECK_MEDIA_GET_DHCP_WAITI= NG_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { return EFI_NO_MEDIA; } =20 // // 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; =20 Dhcp6Handle =3D NULL; Dhcp6 =3D NULL; Oro =3D NULL; @@ -633,13 +633,13 @@ GetDns6ServerFromDhcp6 ( DnsServerInfor.ServerCount =3D DnsServerCount; =20 // // Check media status before doing DHCP. // - MediaPresent =3D TRUE; - NetLibDetectMedia (Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Controller, DNS_CHECK_MEDIA_GET_DHCP_WAITI= NG_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { return EFI_NO_MEDIA; } =20 // // Create a DHCP6 child instance and get the protocol. diff --git a/NetworkPkg/DnsDxe/DnsDhcp.h b/NetworkPkg/DnsDxe/DnsDhcp.h index 62bf717..9c61f84 100644 --- a/NetworkPkg/DnsDxe/DnsDhcp.h +++ b/NetworkPkg/DnsDxe/DnsDhcp.h @@ -35,10 +35,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 =20 #define DHCP6_TAG_DNS_REQUEST 6 #define DHCP6_TAG_DNS_SERVER 23 =20 +#define DNS_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(= 20) + // // The required Dns4 server information. // typedef struct { UINT32 *ServerCount; diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe= /HttpBootImpl.c index d591db5..7f0616d 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; =20 if (This =3D=3D NULL || BufferSize =3D=3D NULL || FilePath =3D=3D NULL) { @@ -568,13 +568,13 @@ HttpBootDxeLoadFile ( Private =3D VirtualNic->Private; =20 // // Check media status before HTTP boot start // - MediaPresent =3D TRUE; - NetLibDetectMedia (Private->Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Private->Controller, HTTP_BOOT_CHECK_MEDIA= _WAITING_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { AsciiPrint ("\n Error: Could not detect network connection.\n"); return EFI_NO_MEDIA; } =20 // diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.h b/NetworkPkg/HttpBootDxe= /HttpBootImpl.h index da58bb6..5316035 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.h +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.h @@ -12,10 +12,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 **/ #ifndef __EFI_HTTP_BOOT_IMPL_H__ #define __EFI_HTTP_BOOT_IMPL_H__ =20 +#define HTTP_BOOT_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECON= DS(20) + /** Attempt to complete a DHCPv4 D.O.R.A or DHCPv6 S.R.A.A sequence to retri= eve the boot resource information. =20 @param[in] Private The pointer to the driver's private dat= a. =20 diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiDhc= p.c index 309ce0d..e6f6972 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; =20 Dhcp4Handle =3D NULL; Ip4Config2 =3D NULL; Dhcp4 =3D NULL; ParaList =3D NULL; =20 // // Check media status before doing DHCP. // - MediaPresent =3D TRUE; - NetLibDetectMedia (Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAI= TING_TIME, &MediaStatus); + if (MediaStatus!=3D EFI_SUCCESS) { + AsciiPrint ("\n Error: Could not detect network connection.\n"); return EFI_NO_MEDIA; } =20 // // DHCP4 service allows only one of its children to be configured in =20 diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c b/NetworkPkg/IScsiDxe/IScsiDh= cp6.c index 06c634c..90acb94 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; =20 // // Check media status before doing DHCP. // - MediaPresent =3D TRUE; - NetLibDetectMedia (Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAI= TING_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { + AsciiPrint ("\n Error: Could not detect network connection.\n"); return EFI_NO_MEDIA; } =20 // // iSCSI will only request target info from DHCPv6 server. diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c b/NetworkPkg/IScsiDxe/IScsiPr= oto.c index 1602a26..38e4af2 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; =20 // // Check media status before session login. // - MediaPresent =3D TRUE; - NetLibDetectMedia (Session->Private->Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Session->Private->Controller, ISCSI_CHECK_= MEDIA_LOGIN_WAITING_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { return EFI_NO_MEDIA; } =20 // // Set session identifier diff --git a/NetworkPkg/IScsiDxe/IScsiProto.h b/NetworkPkg/IScsiDxe/IScsiPr= oto.h index 367914d..d57bda5 100644 --- a/NetworkPkg/IScsiDxe/IScsiProto.h +++ b/NetworkPkg/IScsiDxe/IScsiProto.h @@ -38,10 +38,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #define DEFAULT_MAX_OUTSTANDING_R2T 1 =20 #define ISCSI_VERSION_MAX 0x00 #define ISCSI_VERSION_MIN 0x00 =20 +#define ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME EFI_TIMER_PERIOD_SECOND= S(20) +#define ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECOND= S(20) + #define ISCSI_REDIRECT_ADDR_START_DELIMITER '[' #define ISCSI_REDIRECT_ADDR_END_DELIMITER ']' =20 #define ISCSI_KEY_AUTH_METHOD "AuthMethod" #define ISCSI_KEY_HEADER_DIGEST "HeaderDigest" diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c b/NetworkPkg/UefiPxeBcDxe/= PxeBcImpl.c index ab9e494..5a0fb32 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; =20 if (FilePath =3D=3D NULL || !IsDevicePathEnd (FilePath)) { return EFI_INVALID_PARAMETER; } =20 @@ -2371,13 +2371,13 @@ EfiPxeLoadFile ( } =20 // // Check media status before PXE start // - MediaPresent =3D TRUE; - NetLibDetectMedia (Private->Controller, &MediaPresent); - if (!MediaPresent) { + MediaStatus =3D EFI_SUCCESS; + NetLibDetectMediaWaitTimeout (Private->Controller, PXEBC_CHECK_MEDIA_WAI= TING_TIME, &MediaStatus); + if (MediaStatus !=3D EFI_SUCCESS) { return EFI_NO_MEDIA; } =20 // // Check whether the virtual nic is using IPv6 or not. diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h b/NetworkPkg/UefiPxeBcDxe/= PxeBcImpl.h index 2cdc8bf..7f1ecfb 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h @@ -74,10 +74,12 @@ typedef struct _PXEBC_VIRTUAL_NIC PXEBC_VIRTUAL_NIC; #define PXEBC_MTFTP_RETRIES 6 #define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeou= t, also by PXE2.1 spec. #define PXEBC_MENU_MAX_NUM 24 #define PXEBC_OFFER_MAX_NUM 16 =20 +#define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) + #define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E',= 'P') #define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E',= 'V') #define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, P= xeBc, PXEBC_PRIVATE_DATA_SIGNATURE) #define PXEBC_PRIVATE_DATA_FROM_ID(a) CR (a, PXEBC_PRIVATE_DATA, I= d, PXEBC_PRIVATE_DATA_SIGNATURE) #define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, Lo= adFile, PXEBC_VIRTUAL_NIC_SIGNATURE) --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel