From nobody Fri Dec 27 02:16:14 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 1504264468351106.53435037815063; Fri, 1 Sep 2017 04:14:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5ED9521E7490D; Fri, 1 Sep 2017 04:11:41 -0700 (PDT) Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com [IPv6:2a00:1450:4010:c07::22a]) (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 1FA7821E74907 for ; Fri, 1 Sep 2017 04:11:40 -0700 (PDT) Received: by mail-lf0-x22a.google.com with SMTP id d17so8064833lfe.1 for ; Fri, 01 Sep 2017 04:14:24 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Sep 2017 04:14:20 -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=FQLB7LTx57hct95H6W/FFEC04MZBc1kP3J0UbcCjXKo=; b=XmGYdbVfkl1sXHD07Tv5bjdiU4eQVSr6z9TZOZ5WXgCcOINalWxvV84W65t+zP4uOK JT72Kdm7FwtY95cdSjSU6+icpBxoCkXXbnuj/HdahoXbcWsyxU/xryxve+OCERq3XOsL zAD/ZG0lJmi8XvRrpsK/SIAmHSIT8D3ebCE2p5DjPhJzwVPQDmrXG7Hj+U8HFY3laKPv 3FQgoFbhCDjG3sKQd5ga7tygDbq/FBJDUNJctkzjbdHc7iALEDdywBAPPcEIQf3hy7vW jPVCw5hpvFljM4fqF1HKtgeV4BY9Wyu7K9v4siptAKKyzn2f/0uepvyCnnyL25vC2j24 289g== 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=FQLB7LTx57hct95H6W/FFEC04MZBc1kP3J0UbcCjXKo=; b=EqHWnbCOoYP09ZFJt7PPpB9rV4GFTlHy8OP4MgwiwnvG3LLKi/Dqt6uaIzTVNJzHBt SYxWiAIwFpx7SzzGfk8RFNjSbs6ffSI7E1V72ZlkSVSJYCHE/kbujTDMkdYy2yWhCG0y 9WQDkdx91mpTwx2m88M9C3z+Huq4DiGFz3J9upMgC7HCJCvu1ZlAp1O3NOKcc8W7yHoS kawaipBttoGxDG/W4tHDgFZ4rCJy2JQruJWDesynEGBHqRT+z3X3rmoWQuexaolEg9zJ FMjS8kCXRVuI/nkDznf0oVGfh09vCxFLhuCylK0mX5hrTAiBd0Ha06RSc8OlkBTRA9LC 6uCA== X-Gm-Message-State: AHPjjUjLpaUcTXyZMe5obzq6MyukUWEgqFETTjFsE5SNKg41FxLcMhxA EuxOsZIrY1UHKXGYnSOyTw== X-Google-Smtp-Source: ADKCNb7sPae6cmLiML9wpkH4HAf32DTPuUUaIQy7KFJDK93ROJeJ+Z8HaAnXuL87i7+zNZDLEWvA1A== X-Received: by 10.46.83.5 with SMTP id h5mr649084ljb.104.1504264462530; Fri, 01 Sep 2017 04:14:22 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Date: Fri, 1 Sep 2017 13:17:55 +0200 Message-Id: <1504264679-13613-4-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 3/7] Drivers/Net/Pp2Dxe: Support multiple ethernet ports simultaneously 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, Joe Zhou , 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" From: Joe Zhou In order to operate simultaneously properly, all ports should use their own resources instead of shared BM Pool and queues. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Joe Zhou Signed-off-by: Marcin Wojtas Reviewed-by: Ard Biesheuvel --- Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c | 2 +- Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 110 ++++++++++++++++-----= ---- Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h | 10 ++- 3 files changed, 77 insertions(+), 45 deletions(-) diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c b/Platform/Marv= ell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c index 27ae6b8..53154db 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c @@ -2747,7 +2747,7 @@ Mvpp2BmStop ( UINT32 Val, i; =20 for (i =3D 0; i < MVPP2_BM_SIZE; i++) { - Mvpp2Read (Priv, MVPP2_BM_PHY_ALLOC_REG(0)); + Mvpp2Read (Priv, MVPP2_BM_PHY_ALLOC_REG(Pool)); } =20 Val =3D Mvpp2Read (Priv, MVPP2_BM_POOL_CTRL_REG(Pool)); diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Platform/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.c index bdaf1a0..42cf0f9 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -189,32 +189,43 @@ Pp2DxeBmPoolInit ( Mvpp2BmIrqClear(Mvpp2Shared, Index); } =20 - Mvpp2Shared->BmPools =3D AllocateZeroPool (sizeof(MVPP2_BMS_POOL)); + for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { + Mvpp2Shared->BmPools[Index] =3D AllocateZeroPool (sizeof(MVPP2_BMS_POO= L)); =20 - if (Mvpp2Shared->BmPools =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } + if (Mvpp2Shared->BmPools[Index] =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto FreePools; + } =20 - Status =3D DmaAllocateAlignedBuffer (EfiBootServicesData, - EFI_SIZE_TO_PAGES (PoolSize), - MVPP2_BM_POOL_PTR_ALIGN, - (VOID **)&PoolAddr); - if (EFI_ERROR (Status)) { - goto FreePools; - } + Status =3D DmaAllocateAlignedBuffer (EfiBootServicesData, + EFI_SIZE_TO_PAGES (PoolSize), + MVPP2_BM_POOL_PTR_ALIGN, + (VOID **)&PoolAddr); + if (EFI_ERROR (Status)) { + goto FreeBmPools; + } =20 - ZeroMem (PoolAddr, PoolSize); + ZeroMem (PoolAddr, PoolSize); =20 - Mvpp2Shared->BmPools->Id =3D MVPP2_BM_POOL; - Mvpp2Shared->BmPools->VirtAddr =3D (UINT32 *)PoolAddr; - Mvpp2Shared->BmPools->PhysAddr =3D (UINTN)PoolAddr; + Mvpp2Shared->BmPools[Index]->Id =3D Index; + Mvpp2Shared->BmPools[Index]->VirtAddr =3D (UINT32 *)PoolAddr; + Mvpp2Shared->BmPools[Index]->PhysAddr =3D (UINTN)PoolAddr; =20 - Mvpp2BmPoolHwCreate(Mvpp2Shared, Mvpp2Shared->BmPools, MVPP2_BM_SIZE); + Mvpp2BmPoolHwCreate(Mvpp2Shared, Mvpp2Shared->BmPools[Index], MVPP2_BM= _SIZE); + } =20 return EFI_SUCCESS; =20 +FreeBmPools: + FreePool (Mvpp2Shared->BmPools[Index]); FreePools: - FreePool (Mvpp2Shared->BmPools); + while (Index-- >=3D 0) { + FreePool (Mvpp2Shared->BmPools[Index]); + DmaFreeBuffer ( + EFI_SIZE_TO_PAGES (PoolSize), + Mvpp2Shared->BmPools[Index]->VirtAddr + ); + } return Status; } =20 @@ -226,22 +237,24 @@ Pp2DxeBmStart ( ) { UINT8 *Buff, *BuffPhys; - INTN Index; + INTN Index, Pool; =20 ASSERT(BM_ALIGN >=3D sizeof(UINTN)); =20 - Mvpp2BmPoolCtrl(Mvpp2Shared, MVPP2_BM_POOL, MVPP2_START); - Mvpp2BmPoolBufsizeSet(Mvpp2Shared, Mvpp2Shared->BmPools, RX_BUFFER_SIZE); + for (Pool =3D 0; Pool < MVPP2_MAX_PORT; Pool++) { + Mvpp2BmPoolCtrl(Mvpp2Shared, Pool, MVPP2_START); + Mvpp2BmPoolBufsizeSet(Mvpp2Shared, Mvpp2Shared->BmPools[Pool], RX_BUFF= ER_SIZE); =20 - /* Fill BM pool with Buffers */ - for (Index =3D 0; Index < MVPP2_BM_SIZE; Index++) { - Buff =3D (UINT8 *)(BufferLocation.RxBuffers + (Index * RX_BUFFER_SIZE)= ); - if (Buff =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } + /* Fill BM pool with Buffers */ + for (Index =3D 0; Index < MVPP2_BM_SIZE; Index++) { + Buff =3D (UINT8 *)(BufferLocation.RxBuffers[Pool] + (Index * RX_BUFF= ER_SIZE)); + if (Buff =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } =20 - BuffPhys =3D ALIGN_POINTER(Buff, BM_ALIGN); - Mvpp2BmPoolPut(Mvpp2Shared, MVPP2_BM_POOL, (UINTN)BuffPhys, (UINTN)Buf= fPhys); + BuffPhys =3D ALIGN_POINTER(Buff, BM_ALIGN); + Mvpp2BmPoolPut(Mvpp2Shared, Pool, (UINTN)BuffPhys, (UINTN)BuffPhys); + } } =20 return EFI_SUCCESS; @@ -415,7 +428,7 @@ Pp2DxeLatePortInitialize ( } =20 /* Use preallocated area */ - Port->Txqs[0].Descs =3D BufferLocation.TxDescs; + Port->Txqs[0].Descs =3D BufferLocation.TxDescs[Port->Id]; =20 for (Queue =3D 0; Queue < TxqNumber; Queue++) { MVPP2_TX_QUEUE *Txq =3D &Port->Txqs[Queue]; @@ -431,7 +444,7 @@ Pp2DxeLatePortInitialize ( return EFI_OUT_OF_RESOURCES; } =20 - Port->Rxqs[0].Descs =3D BufferLocation.RxDescs; + Port->Rxqs[0].Descs =3D BufferLocation.RxDescs[Port->Id]; =20 for (Queue =3D 0; Queue < TxqNumber; Queue++) { MVPP2_RX_QUEUE *Rxq =3D &Port->Rxqs[Queue]; @@ -465,8 +478,8 @@ Pp2DxeLateInitialize ( } =20 /* Attach pool to Rxq */ - Mvpp2RxqLongPoolSet(Port, 0, MVPP2_BM_POOL); - Mvpp2RxqShortPoolSet(Port, 0, MVPP2_BM_POOL); + Mvpp2RxqLongPoolSet(Port, 0, Port->Id); + Mvpp2RxqShortPoolSet(Port, 0, Port->Id); =20 /* * Mark this port being fully initialized, @@ -654,9 +667,13 @@ Pp2DxeHalt ( PP2DXE_CONTEXT *Pp2Context =3D Context; PP2DXE_PORT *Port =3D &Pp2Context->Port; STATIC BOOLEAN CommonPartHalted =3D FALSE; + INTN Index; =20 if (!CommonPartHalted) { - Mvpp2BmStop(Mvpp2Shared, MVPP2_BM_POOL); + for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { + Mvpp2BmStop(Mvpp2Shared, Index); + } + CommonPartHalted =3D TRUE; } =20 @@ -1188,13 +1205,26 @@ Pp2DxeInitialise ( =20 ZeroMem (BufferSpace, BD_SPACE); =20 - BufferLocation.TxDescs =3D BufferSpace; - BufferLocation.AggrTxDescs =3D (MVPP2_TX_DESC *)((UINTN)BufferSpace + MV= PP2_MAX_TXD * sizeof(MVPP2_TX_DESC)); - BufferLocation.RxDescs =3D (MVPP2_RX_DESC *)((UINTN)BufferSpace + - (MVPP2_MAX_TXD + MVPP2_AGGR_T= XQ_SIZE) * sizeof(MVPP2_TX_DESC)); - BufferLocation.RxBuffers =3D (DmaAddrT)(BufferSpace + - (MVPP2_MAX_TXD + MVPP2_AGGR_TXQ_SI= ZE) * sizeof(MVPP2_TX_DESC) + - MVPP2_MAX_RXD * sizeof(MVPP2_RX_DE= SC)); + for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { + BufferLocation.TxDescs[Index] =3D (MVPP2_TX_DESC *) + (BufferSpace + Index * MVPP2_MAX_TXD * sizeof(MVPP2_TX_DESC)); + } + + BufferLocation.AggrTxDescs =3D (MVPP2_TX_DESC *) + ((UINTN)BufferSpace + MVPP2_MAX_TXD * MVPP2_MAX_PORT * sizeof(MVPP2_TX= _DESC)); + + for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { + BufferLocation.RxDescs[Index] =3D (MVPP2_RX_DESC *) + ((UINTN)BufferSpace + (MVPP2_MAX_TXD * MVPP2_MAX_PORT + MVPP2_AGGR_T= XQ_SIZE) * + sizeof(MVPP2_TX_DESC) + Index * MVPP2_MAX_RXD * sizeof(MVPP2_RX_DESC= )); + } + + for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { + BufferLocation.RxBuffers[Index] =3D (DmaAddrT) + (BufferSpace + (MVPP2_MAX_TXD * MVPP2_MAX_PORT + MVPP2_AGGR_TXQ_SIZE= ) * + sizeof(MVPP2_TX_DESC) + MVPP2_MAX_RXD * MVPP2_MAX_PORT * sizeof(MVPP= 2_RX_DESC) + + Index * MVPP2_BM_SIZE * RX_BUFFER_SIZE); + } =20 /* Initialize HW */ Mvpp2AxiConfig(Mvpp2Shared); diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h b/Platform/Marvel= l/Drivers/Net/Pp2Dxe/Pp2Dxe.h index 1e03a69..b85cff7 100644 --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.h @@ -56,6 +56,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. =20 #include "Mvpp2LibHw.h" =20 +#define MVPP2_MAX_PORT 3 + #define PP2DXE_SIGNATURE SIGNATURE_32('P', 'P', '2', 'D= ') #define INSTANCE_FROM_SNP(a) CR((a), PP2DXE_CONTEXT, Snp, P= P2DXE_SIGNATURE) =20 @@ -276,7 +278,7 @@ typedef struct { MVPP2_TX_QUEUE *AggrTxqs; =20 /* BM pools */ - MVPP2_BMS_POOL *BmPools; + MVPP2_BMS_POOL *BmPools[MVPP2_MAX_PORT]; =20 /* PRS shadow table */ MVPP2_PRS_SHADOW *PrsShadow; @@ -330,10 +332,10 @@ struct Pp2DxePort { =20 /* Structure for preallocation for buffer */ typedef struct { - MVPP2_TX_DESC *TxDescs; + MVPP2_TX_DESC *TxDescs[MVPP2_MAX_PORT]; MVPP2_TX_DESC *AggrTxDescs; - MVPP2_RX_DESC *RxDescs; - DmaAddrT RxBuffers; + MVPP2_RX_DESC *RxDescs[MVPP2_MAX_PORT]; + DmaAddrT RxBuffers[MVPP2_MAX_PORT]; } BUFFER_LOCATION; =20 typedef struct { --=20 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel