From nobody Mon Feb 9 01:20:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+39929+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+39929+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1556841038; cv=none; d=zoho.com; s=zohoarc; b=WHthQTa7fa/PQXHB6Pd4QurslUd7dcFsoM75UfEn4SI5RRhwXWUaKBgwGOXpPAgZ7Da+XDMZBQXqoFqDTz1At81g6LX0yiDIV4FNnvPwNEusY5piMAHK/wsuu6ZLmVlL6QsoM/cQRWHLh9D7FZrQdG3cutTuEPVNRdetxdR/HCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556841038; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=4No68puCl+QpEc3HkFefSJSYhA7p7cpu2WlcTMdaFuE=; b=aMF0qtn0UUxMfjlkzxQAG4IJNmhbZsvZzBAn2wgJTSBag1VSsiKiWBgU//i/WjWXAjppFpPqHBnoo1PnCMb+QUn43YLVum0GYRu3eAi0PqN9p3oO7Zj490ZnPF2bWGkTnJGINr18+lbgRVaAgaEeDbIdmjMqicHtIch8oEeQ87Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+39929+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1556841038039428.25826583267815; Thu, 2 May 2019 16:50:38 -0700 (PDT) Return-Path: X-Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by groups.io with SMTP; Thu, 02 May 2019 16:50:36 -0700 X-Received: by mail-lj1-f193.google.com with SMTP id d15so3779201ljc.7 for ; Thu, 02 May 2019 16:50:36 -0700 (PDT) X-Gm-Message-State: APjAAAVP1ob9ccU/7aX9mALLst05trRptDaLAWFU7vkAlsC0udv+Gl18 K9sbI4zG62kR4/fOzDounOS1CDtqqnnvoA== X-Google-Smtp-Source: APXvYqxMCsQY1EVbStTeks5ISyfuYwBlJI8DWrL5fh0Mi+yCzZx5vJw4fdT8dSwvjI5Qus1is0zKSw== X-Received: by 2002:a2e:9f44:: with SMTP id v4mr3417061ljk.72.1556841034243; Thu, 02 May 2019 16:50:34 -0700 (PDT) X-Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id o17sm74078lji.23.2019.05.02.16.50.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 May 2019 16:50:33 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, Jici.Gao@arm.com, Tomasz Michalec Subject: [edk2-devel] [edk2-platforms: PATCH 1/4] Marvel/Drivers: Pp2Dxe: Basic support for Adapter Information Protocol Date: Fri, 3 May 2019 01:50:13 +0200 Message-Id: <1556841016-10342-2-git-send-email-mw@semihalf.com> In-Reply-To: <1556841016-10342-1-git-send-email-mw@semihalf.com> References: <1556841016-10342-1-git-send-email-mw@semihalf.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mw@semihalf.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1556841037; bh=iKgb8/zUPnPyJhVCURITl9ZMXjbRFY600RWQ6ThSzx0=; h=Cc:Date:From:Reply-To:Subject:To; b=BPOlqvX1SorRdB7AppWAmhDHCXZKHH+ooEeyNPr445Zn6dKo8DXDwPzpwBCpAMlXKOC z4YMn/+0QBa3z3gtTbsWCu+RVkP17Eql3+4kbSI0nOr9xJxAXOSVKgJoQadYVdAxX0PCg bDxms/g335o/h7cBNrDcG/1Xd/WA26OxG9U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tomasz Michalec Add implementation of Adapter Information Protocol in Armada 7k8k PP2 NIC driver. Support retrieving information about media state which allows to use NetLibDetectMediaWaitTimeout on network interface. This patch fixes possible hangs when attempting to PXE boot on unconnected interfaces. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Tomasz Michalec --- Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf | 1 + Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h | 3 + Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 157 ++++++++++++++++++++ 3 files changed, 161 insertions(+) diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Silicon/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.inf index be536ab..73aa413 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf @@ -64,6 +64,7 @@ CacheMaintenanceLib =20 [Protocols] + gEfiAdapterInformationProtocolGuid gEfiSimpleNetworkProtocolGuid gEfiDevicePathProtocolGuid gEfiCpuArchProtocolGuid diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.h index b8a5dae..66bd46a 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h @@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #ifndef __PP2_DXE_H__ #define __PP2_DXE_H__ =20 +#include #include #include #include @@ -59,6 +60,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #define MVPP2_MAX_PORT 3 =20 #define PP2DXE_SIGNATURE SIGNATURE_32('P', 'P', '2', 'D= ') +#define INSTANCE_FROM_AIP(a) CR((a), PP2DXE_CONTEXT, Aip, P= P2DXE_SIGNATURE) #define INSTANCE_FROM_SNP(a) CR((a), PP2DXE_CONTEXT, Snp, P= P2DXE_SIGNATURE) =20 /* OS API */ @@ -365,6 +367,7 @@ typedef struct { UINTN CompletionQueueTail; EFI_EVENT EfiExitBootServicesEvent; PP2_DEVICE_PATH *DevicePath; + EFI_ADAPTER_INFORMATION_PROTOCOL Aip; } PP2DXE_CONTEXT; =20 /* Inline helpers */ diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.c index 02b2798..473a2a1 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -1129,6 +1129,7 @@ Pp2DxeSnpInstall ( &Handle, &gEfiSimpleNetworkProtocolGuid, &Pp2Context->Snp, &gEfiDevicePathProtocolGuid, Pp2DevicePath, + &gEfiAdapterInformationProtocolGuid, &Pp2Context->Aip, NULL ); =20 @@ -1139,6 +1140,157 @@ Pp2DxeSnpInstall ( return Status; } =20 +/** + Returns the current state information for the adapter. + + This function returns information of type InformationType from the adapt= er. + If an adapter does not support the requested informational type, then + EFI_UNSUPPORTED is returned. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMAT= ION_PROTOCOL instance. + @param[in] InformationType A pointer to an EFI_GUID that defines= the contents of InformationBlock. + @param[out] InforamtionBlock The service returns a pointer to the = buffer with the InformationBlock + structure which contains details abou= t the data specific to InformationType. + @param[out] InforamtionBlockSize The driver returns the size of the In= formationBlock in bytes. + + @retval EFI_SUCCESS The InformationType information was r= etrieved. + @retval EFI_UNSUPPORTED The InformationType is not known. + @retval EFI_DEVICE_ERROR The device reported an error. + @retval EFI_OUT_OF_RESOURCES The request could not be completed du= e to a lack of resources. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InformationBlock is NULL. + @retval EFI_INVALID_PARAMETER InformationBlockSize is NULL. + +**/ +EFI_STATUS +EFIAPI +Pp2AipGetInformation ( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + IN EFI_GUID *InformationType, + OUT VOID **InformationBlock, + OUT UINTN *InformationBlockSize + ) +{ + EFI_ADAPTER_INFO_MEDIA_STATE *AdapterInfo; + PP2DXE_CONTEXT *Pp2Context; + EFI_STATUS Status; + + if (This =3D=3D NULL || InformationBlock =3D=3D NULL || InformationBlock= Size =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (!CompareGuid (InformationType, &gEfiAdapterInfoMediaStateGuid)) { + return EFI_UNSUPPORTED; + } + + AdapterInfo =3D AllocateZeroPool (sizeof (EFI_ADAPTER_INFO_MEDIA_STATE)); + if (AdapterInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *InformationBlock =3D AdapterInfo; + *InformationBlockSize =3D sizeof (EFI_ADAPTER_INFO_MEDIA_STATE); + + Pp2Context =3D INSTANCE_FROM_AIP (This); + + Status =3D Pp2Context->Snp.GetStatus (&(Pp2Context->Snp), NULL, NULL); + if (Status =3D=3D EFI_NOT_READY){ + AdapterInfo->MediaState =3D EFI_NOT_READY; + return EFI_SUCCESS; + } + + AdapterInfo->MediaState =3D (Pp2Context->Snp.Mode->MediaPresent ? + EFI_SUCCESS : EFI_NOT_READY); + + return EFI_SUCCESS; +} + +/** + Sets state information for an adapter. + + This function sends information of type InformationType for an adapter. + If an adapter does not support the requested information type, then EFI_= UNSUPPORTED + is returned. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMAT= ION_PROTOCOL instance. + @param[in] InformationType A pointer to an EFI_GUID that defines= the contents of InformationBlock. + @param[in] InforamtionBlock A pointer to the InformationBlock str= ucture which contains details + about the data specific to Informatio= nType. + @param[in] InforamtionBlockSize The size of the InformationBlock in b= ytes. + + @retval EFI_SUCCESS The information was received and inte= rpreted successfully. + @retval EFI_UNSUPPORTED The InformationType is not known. + @retval EFI_DEVICE_ERROR The device reported an error. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InformationBlock is NULL. + @retval EFI_WRITE_PROTECTED The InformationType cannot be modifie= d using EFI_ADAPTER_INFO_SET_INFO(). + +**/ +EFI_STATUS +EFIAPI +Pp2AipSetInformation ( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + IN EFI_GUID *InformationType, + IN VOID *InformationBlock, + IN UINTN InformationBlockSize + ) +{ + if (This =3D=3D NULL || InformationBlock =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (CompareGuid (InformationType, &gEfiAdapterInfoMediaStateGuid)) { + return EFI_WRITE_PROTECTED; + } + + return EFI_UNSUPPORTED; +} + +/** + Get a list of supported information types for this instance of the proto= col. + + This function returns a list of InformationType GUIDs that are supported= on an + adapter with this instance of EFI_ADAPTER_INFORMATION_PROTOCOL. The list= is returned + in InfoTypesBuffer, and the number of GUID pointers in InfoTypesBuffer i= s returned in + InfoTypesBufferCount. + + @param[in] This A pointer to the EFI_ADAPTER_INFORMATI= ON_PROTOCOL instance. + @param[out] InfoTypesBuffer A pointer to the array of InformationT= ype GUIDs that are supported + by This. + @param[out] InfoTypesBufferCount A pointer to the number of GUIDs prese= nt in InfoTypesBuffer. + + @retval EFI_SUCCESS The list of information type GUIDs tha= t are supported on this adapter was + returned in InfoTypesBuffer. The numbe= r of information type GUIDs was + returned in InfoTypesBufferCount. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER InfoTypesBuffer is NULL. + @retval EFI_INVALID_PARAMETER InfoTypesBufferCount is NULL. + @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to sto= re the results. + +**/ +EFI_STATUS +EFIAPI +Pp2AipGetSupportedTypes ( + IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, + OUT EFI_GUID **InfoTypesBuffer, + OUT UINTN *InfoTypesBufferCount + ) +{ + if (This =3D=3D NULL || InfoTypesBuffer =3D=3D NULL || InfoTypesBufferCo= unt =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + *InfoTypesBuffer =3D AllocateZeroPool (sizeof (EFI_GUID)); + if (*InfoTypesBuffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *InfoTypesBufferCount =3D 1; + (*InfoTypesBuffer)[0] =3D gEfiAdapterInfoMediaStateGuid; + + return EFI_SUCCESS; +} + STATIC VOID Pp2DxeParsePortPcd ( @@ -1290,6 +1442,11 @@ Pp2DxeInitialiseController ( Pp2Context->Instance =3D DeviceInstance; DeviceInstance++; =20 + /* Prepare AIP Protocol */ + Pp2Context->Aip.GetInformation =3D Pp2AipGetInformation; + Pp2Context->Aip.SetInformation =3D Pp2AipSetInformation; + Pp2Context->Aip.GetSupportedTypes =3D Pp2AipGetSupportedTypes; + /* Install SNP protocol */ Status =3D Pp2DxeSnpInstall(Pp2Context); if (EFI_ERROR(Status)) { --=20 2.7.4 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#39929): https://edk2.groups.io/g/devel/message/39929 Mute This Topic: https://groups.io/mt/31476852/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-