From nobody Fri Dec 27 01:46:04 2024 Delivered-To: importer@patchew.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; Authentication-Results: mx.zohomail.com; dkim=fail; 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 1504264483928863.9543973289415; Fri, 1 Sep 2017 04:14:43 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5764121E7491F; Fri, 1 Sep 2017 04:11:48 -0700 (PDT) Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com [IPv6:2a00:1450:4010:c07::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E55C720958BDC for ; Fri, 1 Sep 2017 04:11:46 -0700 (PDT) Received: by mail-lf0-x22b.google.com with SMTP id d202so7990191lfd.5 for ; Fri, 01 Sep 2017 04:14:31 -0700 (PDT) Received: from enkidu.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id i11sm442673lfk.79.2017.09.01.04.14.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Sep 2017 04:14:28 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ddo+dJRKFpVEshAY3mOy+I0Qw+EbWsI5PH35BWwxArs=; b=inQ/s5B/fboCdFIGdIE65Wq1QsjEneq6uG/hqWvWC3t4/8TeH0dRoPrcz+YO9SbxBX xY6pWIENq9bXTRCglq/k9k2spw9ZV2zNhMiJ0sTiOjUKua9M/kcdAwP3TB18kFnaghNl 7de/3/nHWNNbAPyLcgrUXeazo9F/5Y6nUfaDPjyl0So10egbmHmINbr5PzhWg60koNvE 8Hdf0TOqN15TmKAvx4Jt5kM1vuXf50YBKVO2Q2dSt8tazyCWfIA9bQfZQwVlAGyF8PZ8 0lGJ/oMtq2AgITvNqzz+ZFykgOSGA1jB9X2/0eYIj3mrNOVfSfmo0nndfiYfYQmg2sx1 tVRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ddo+dJRKFpVEshAY3mOy+I0Qw+EbWsI5PH35BWwxArs=; b=QpaBPIgspogkOzLraZlz6SHRXkBgRF4NWNiO8VVNkQekrzKCBTc/a/mE1U3IjH4zeg YjrRqyLzSe0mwnVDjmhpAcVxSnNdBcQ0aMVEybWr7ApPi39ebMVFfeY7iYZjOqZxDR2x RYuzVWpTOT7Yl3CuBlxycQtPAFSiIDsMPv2SvHt57C7Nmscm1pwbzwctC8i61fR5hNtN Kt4CAVW7eCfOyGrPRwLPHGmOVVAdV3Ip0O/UuS3kOnPiwHC4QrOKcHtx6oXmrJUbvfCh yzYYpFTrqDFbcFhEhV3fCfLWXeIQ1A7AXwbpD/9NFJnn4UYl2gEcNLeIvmiorzMf/7nU mSGQ== X-Gm-Message-State: AHPjjUiixpHkNeeLiG/czY+fkoME/zH3ZzAmQpw3T7D9PywIDvwm/gJn ksHjcJ8xXM3BqoCKSBvqvQ== X-Google-Smtp-Source: ADKCNb6nnt24fm2xPw32mfJsmyowd2960sh9JnKqV9vN9Iumb78Ubg5VQCZmWpFZQjBPon+ZuSBZ8Q== X-Received: by 10.25.178.70 with SMTP id b67mr616429lff.246.1504264469329; Fri, 01 Sep 2017 04:14:29 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Date: Fri, 1 Sep 2017 13:17:59 +0200 Message-Id: <1504264679-13613-8-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1504264679-13613-1-git-send-email-mw@semihalf.com> References: <1504264679-13613-1-git-send-email-mw@semihalf.com> Subject: [edk2] [platforms: PATCH v2 7/7] Drivers/Net/Pp2Dxe: Enable using ports from different controllers 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: jinghua@marvell.com, ard.biesheuvel@linaro.org, agraf@suse.de, leif.lindholm@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" After Pp2Dxe data migrated to MvHwDescLib, both controllers could be used, but not at the same time. It was caused by ports' insufficient description. This patch fixes this problem by introducing new PCD responsible for the mapping between port and its controller. Also it was possible to remove redundant PcdPp2NumPorts. Update documentation accordingly. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Ard Biesheuvel --- Platform/Marvell/Armada/Armada70x0.dsc | 2 +- .../Marvell/Documentation/PortingGuide/Pp2.txt | 4 +- Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 63 ++++++++++++++----= ---- Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h | 1 + Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf | 2 +- Platform/Marvell/Marvell.dec | 2 +- 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/Platform/Marvell/Armada/Armada70x0.dsc b/Platform/Marvell/Arma= da/Armada70x0.dsc index 334bfaa..f519196 100644 --- a/Platform/Marvell/Armada/Armada70x0.dsc +++ b/Platform/Marvell/Armada/Armada70x0.dsc @@ -124,7 +124,7 @@ gMarvellTokenSpaceGuid.PcdPp2GopIndexes|{ 0x0, 0x2, 0x3 } gMarvellTokenSpaceGuid.PcdPp2InterfaceAlwaysUp|{ 0x0, 0x0, 0x0 } gMarvellTokenSpaceGuid.PcdPp2InterfaceSpeed|{ 0x5, 0x3, 0x3 } - gMarvellTokenSpaceGuid.PcdPp2NumPorts|3 + gMarvellTokenSpaceGuid.PcdPp2Port2Controller|{ 0x0, 0x0, 0x0 } gMarvellTokenSpaceGuid.PcdPp2PortIds|{ 0x0, 0x1, 0x2 } gMarvellTokenSpaceGuid.PcdPp2Controllers|{ 0x1 } =20 diff --git a/Platform/Marvell/Documentation/PortingGuide/Pp2.txt b/Platform= /Marvell/Documentation/PortingGuide/Pp2.txt index 9b829c9..f05ba27 100644 --- a/Platform/Marvell/Documentation/PortingGuide/Pp2.txt +++ b/Platform/Marvell/Documentation/PortingGuide/Pp2.txt @@ -6,8 +6,8 @@ are required to operate: Array with used controllers - Set to 0x1 for enabled, 0x0 for disabled: gMarvellTokenSpaceGuid.PcdPp2Controllers =20 -Number of ports/network interfaces: - gMarvellTokenSpaceGuid.PcdPp2NumPorts +Array specifying, to which controller the port belongs to: + gMarvellTokenSpaceGuid.PcdPp2Port2Controller =20 Addresses of PHY devices: gMarvellTokenSpaceGuid.PcdPhySmiAddresses diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Platform/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.c index 8e6bfbc..620bd5c 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -508,9 +508,7 @@ Pp2DxePhyInitialize ( ) { EFI_STATUS Status; - UINT8 *PhyAddresses; =20 - PhyAddresses =3D PcdGetPtr (PcdPhySmiAddresses); Status =3D gBS->LocateProtocol ( &gMarvellPhyProtocolGuid, NULL, @@ -521,14 +519,14 @@ Pp2DxePhyInitialize ( return Status; } =20 - if (PhyAddresses[Pp2Context->Instance] =3D=3D 0xff) { + if (Pp2Context->Port.PhyAddr =3D=3D 0xff) { /* PHY iniitalization not required */ return EFI_SUCCESS; } =20 Status =3D Pp2Context->Phy->Init( Pp2Context->Phy, - PhyAddresses[Pp2Context->Instance], + Pp2Context->Port.PhyAddr, Pp2Context->Port.PhyInterface, &Pp2Context->PhyDev ); @@ -1145,14 +1143,16 @@ Pp2DxeSnpInstall ( STATIC VOID Pp2DxeParsePortPcd ( - IN PP2DXE_CONTEXT *Pp2Context + IN PP2DXE_CONTEXT *Pp2Context, + IN INTN Index ) { - UINT8 *PortIds, *GopIndexes, *PhyConnectionTypes, *AlwaysUp, *Speed; + UINT8 *PortIds, *GopIndexes, *PhyConnectionTypes, *AlwaysUp, *Speed, *Ph= yAddresses; =20 PortIds =3D PcdGetPtr (PcdPp2PortIds); GopIndexes =3D PcdGetPtr (PcdPp2GopIndexes); PhyConnectionTypes =3D PcdGetPtr (PcdPhyConnectionTypes); + PhyAddresses =3D PcdGetPtr (PcdPhySmiAddresses); AlwaysUp =3D PcdGetPtr (PcdPp2InterfaceAlwaysUp); Speed =3D PcdGetPtr (PcdPp2InterfaceSpeed); =20 @@ -1160,17 +1160,20 @@ Pp2DxeParsePortPcd ( ASSERT (PcdGetSize (PcdPhyConnectionTypes) =3D=3D PcdGetSize (PcdPp2Port= Ids)); ASSERT (PcdGetSize (PcdPp2InterfaceAlwaysUp) =3D=3D PcdGetSize (PcdPp2Po= rtIds)); ASSERT (PcdGetSize (PcdPp2InterfaceSpeed) =3D=3D PcdGetSize (PcdPp2PortI= ds)); - - Pp2Context->Port.Id =3D PortIds[Pp2Context->Instance]; - Pp2Context->Port.GopIndex =3D GopIndexes[Pp2Context->Instance]; - Pp2Context->Port.PhyInterface =3D PhyConnectionTypes[Pp2Context->Instanc= e]; - Pp2Context->Port.AlwaysUp =3D AlwaysUp[Pp2Context->Instance]; - Pp2Context->Port.Speed =3D Speed[Pp2Context->Instance]; + ASSERT (PcdGetSize (PcdPhySmiAddresses) =3D=3D PcdGetSize (PcdPp2PortIds= )); + + Pp2Context->Port.Id =3D PortIds[Index]; + Pp2Context->Port.GopIndex =3D GopIndexes[Index]; + Pp2Context->Port.PhyInterface =3D PhyConnectionTypes[Index]; + Pp2Context->Port.PhyAddr =3D PhyAddresses[Index]; + Pp2Context->Port.AlwaysUp =3D AlwaysUp[Index]; + Pp2Context->Port.Speed =3D Speed[Index]; } =20 STATIC EFI_STATUS Pp2DxeInitialiseController ( + IN UINT8 ControllerIndex, IN MVPP2_SHARED *Mvpp2Shared, IN UINTN BaseAddress, IN UINTN ClockFrequency @@ -1179,14 +1182,11 @@ Pp2DxeInitialiseController ( PP2DXE_CONTEXT *Pp2Context =3D NULL; EFI_STATUS Status; INTN Index; + INTN PortIndex =3D 0; VOID *BufferSpace; UINT32 NetCompConfig =3D 0; - UINT8 NumPorts =3D PcdGet32 (PcdPp2NumPorts); - - if (NumPorts =3D=3D 0) { - DEBUG((DEBUG_ERROR, "Pp2Dxe: port number set to 0\n")); - return EFI_INVALID_PARAMETER; - } + STATIC UINT8 DeviceInstance; + UINT8 *Pp2PortMappingTable; =20 Mvpp2Shared->Base =3D BaseAddress; Mvpp2Shared->Rfu1Base =3D Mvpp2Shared->Base + MVPP22_RFU1_OFFSET; @@ -1265,7 +1265,18 @@ Pp2DxeInitialiseController ( Mvpp2Shared->AggrTxqs->LogId =3D 0; Mvpp2Shared->AggrTxqs->Size =3D MVPP2_AGGR_TXQ_SIZE; =20 - for (Index =3D 0; Index < NumPorts; Index++) { + Pp2PortMappingTable =3D (UINT8 *)PcdGetPtr (PcdPp2Port2Controller); + + for (Index =3D 0; Index < PcdGetSize (PcdPp2Port2Controller); Index++) { + if (Pp2PortMappingTable[Index] !=3D ControllerIndex) { + continue; + } + + if (PortIndex++ > MVPP2_MAX_PORT) { + DEBUG ((DEBUG_ERROR, "Pp2Dxe: Wrong too many ports for single contro= ller\n")); + return EFI_INVALID_PARAMETER; + } + Pp2Context =3D AllocateZeroPool (sizeof (PP2DXE_CONTEXT)); if (Pp2Context =3D=3D NULL) { /* @@ -1277,7 +1288,8 @@ Pp2DxeInitialiseController ( } =20 /* Instances are enumerated from 0 */ - Pp2Context->Instance =3D Index; + Pp2Context->Instance =3D DeviceInstance; + DeviceInstance++; =20 /* Install SNP protocol */ Status =3D Pp2DxeSnpInstall(Pp2Context); @@ -1285,10 +1297,10 @@ Pp2DxeInitialiseController ( return Status; } =20 - Pp2DxeParsePortPcd(Pp2Context); + Pp2DxeParsePortPcd(Pp2Context, Index); Pp2Context->Port.TxpNum =3D 1; Pp2Context->Port.Priv =3D Mvpp2Shared; - Pp2Context->Port.FirstRxq =3D 4 * Pp2Context->Instance; + Pp2Context->Port.FirstRxq =3D 4 * (PortIndex - 1); Pp2Context->Port.GmacBase =3D Mvpp2Shared->Base + MVPP22_GMAC_OFFSET + MVPP22_GMAC_REG_SIZE * Pp2Context->Port.Go= pIndex; Pp2Context->Port.XlgBase =3D Mvpp2Shared->Base + MVPP22_XLG_OFFSET + @@ -1343,6 +1355,12 @@ Pp2DxeInitialise ( return EFI_INVALID_PARAMETER; } =20 + /* Check amount of declared ports */ + if (PcdGetSize (PcdPp2Port2Controller) > Desc->Pp2DevCount * MVPP2_MAX_P= ORT) { + DEBUG ((DEBUG_ERROR, "Pp2Dxe: Wrong too many ports declared\n")); + return EFI_INVALID_PARAMETER; + } + /* Initialize enabled chips */ for (Index =3D 0; Index < PcdGetSize (PcdPp2Controllers); Index++) { if (!MVHW_DEV_ENABLED (Pp2, Index)) { @@ -1358,6 +1376,7 @@ Pp2DxeInitialise ( } =20 Status =3D Pp2DxeInitialiseController ( + Index, Mvpp2Shared, Desc->Pp2BaseAddresses[Index], Desc->Pp2ClockFrequency[Index] diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h b/Platform/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.h index 7071cef..cde2995 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h @@ -327,6 +327,7 @@ struct Pp2DxePort { UINT16 RxRingSize; =20 INT32 PhyInterface; + UINTN PhyAddr; BOOLEAN Link; BOOLEAN Duplex; BOOLEAN AlwaysUp; diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf b/Platform/Marv= ell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf index b67162d..752fcc0 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.inf @@ -77,7 +77,7 @@ gMarvellTokenSpaceGuid.PcdPp2GopIndexes gMarvellTokenSpaceGuid.PcdPp2InterfaceAlwaysUp gMarvellTokenSpaceGuid.PcdPp2InterfaceSpeed - gMarvellTokenSpaceGuid.PcdPp2NumPorts + gMarvellTokenSpaceGuid.PcdPp2Port2Controller gMarvellTokenSpaceGuid.PcdPp2PortIds =20 [Depex] diff --git a/Platform/Marvell/Marvell.dec b/Platform/Marvell/Marvell.dec index e6a3621..4e2dd6d 100644 --- a/Platform/Marvell/Marvell.dec +++ b/Platform/Marvell/Marvell.dec @@ -173,7 +173,7 @@ gMarvellTokenSpaceGuid.PcdPp2GopIndexes|{ 0x0 }|VOID*|0x3000029 gMarvellTokenSpaceGuid.PcdPp2InterfaceAlwaysUp|{ 0x0 }|VOID*|0x300002A gMarvellTokenSpaceGuid.PcdPp2InterfaceSpeed|{ 0x0 }|VOID*|0x300002B - gMarvellTokenSpaceGuid.PcdPp2NumPorts|0|UINT32|0x300002D + gMarvellTokenSpaceGuid.PcdPp2Port2Controller|{ 0x0 }|VOID*|0x300002D gMarvellTokenSpaceGuid.PcdPp2PortIds|{ 0x0 }|VOID*|0x300002C =20 #PciEmulation --=20 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel