From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by mx.groups.io with SMTP id smtpd.web09.27888.1647272341361631965 for ; Mon, 14 Mar 2022 08:39:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20210112.gappssmtp.com header.s=20210112 header.b=6n/tdhS4; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.208.171, mailfrom: mw@semihalf.com) Received: by mail-lj1-f171.google.com with SMTP id z26so22491521lji.8 for ; Mon, 14 Mar 2022 08:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mgiYqqMEZTzOA1ugcigSnXbhDzB3nsHC6siNdkhWbuc=; b=6n/tdhS4HTFppRKquiw0Bwj8sEqS04HaFJhRhrPxMtw5Svi8/r2t6YldCexw82yr5l cLfuq6eUBeAa6i/NNP8t1bxYkDEuJ21ibXjzGS1b/wxDnb4ErgxtnY2+J3OJp7c4O8dq OJGefV4QYKmYY9aVSc3IDBhRuoDslYNzHKeXSQj6N1W6zEGy0aCEK9bTym9hHZrRzYC1 GW9XIjf/G7IJa1VbsKkak3HWZCWpt3nGlyBrNa3UIKwH3SnbtlqupW2CPgb1wHQMPtA6 M1jtMfmL6SFLQiFtiHMtnVxhSkcMnzgzYmt5Zbyj1QGuBZKzkcyMwEHamC3C7k6xNkwJ TZ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mgiYqqMEZTzOA1ugcigSnXbhDzB3nsHC6siNdkhWbuc=; b=gwkQZgw7WGMJ9rJRvDWdH7oG0a3Q9fpIzXdaYaVrwFbmZ5jNzeCRhO07F3B60/nzGp eEwk4y34XnR3w5dGBVYUTt3sTzwDMGXRIpP/S8s10bDydnddHUNulzT8daC/V6DSCQZv gaFF2bb20SkHCtRLbYDsRtJe1CSNBtHly9kvDDhdpgT6mXMJGitSqiPreY60OAqWZ9HZ jofoM9Hw0EBgVCY/WSH+My8wceIxVXiDyR9724V8SmOiklXFn3UdoPRl3zNykc6DA+Nq X2Klcp/62KgLT8ulIDMUhaqK1bMPUVsTnv8+kgSJdsBYy+JPQyL8jXB0z6Cl0Kg3HfQv iOzQ== X-Gm-Message-State: AOAM531A/stCq5uKLLshTLfuveZ/7xtu3/Ufj+gLSH6M43N98XsVWqJr uavwGZY2zEbIKl2kWXq5Gq1Elg/foib33w== X-Google-Smtp-Source: ABdhPJx4bt+61rYN0OVTY61Ef3BUmbSOiRZjr1f84Vg+N8I2BCZwI0eUZSF36drcMi++saqdTdJDpQ== X-Received: by 2002:a05:651c:1989:b0:247:933b:3938 with SMTP id bx9-20020a05651c198900b00247933b3938mr14281117ljb.228.1647272339521; Mon, 14 Mar 2022 08:38:59 -0700 (PDT) Return-Path: Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id b8-20020ac25628000000b004484bd1be5esm3325401lff.256.2022.03.14.08.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 08:38:59 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, mw@semihalf.com, jaz@semihalf.com, gjb@semihalf.com, upstream@semihalf.com, sunny.Wang@arm.com Subject: [edk2-platforms PATCH 8/8] Marvell/Drivers: Pp2Dxe: Fix Pp2SnpReceive Date: Mon, 14 Mar 2022 16:38:37 +0100 Message-Id: <20220314153837.1885852-9-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220314153837.1885852-1-mw@semihalf.com> References: <20220314153837.1885852-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable This patch adds missing parameter's and SNP instance status checks in SnpReceive callback. Additionally, the local variables declarations are cleaned-up. Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 43 ++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.c index 841a1c8f84..5e463ac932 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -1214,23 +1214,50 @@ Pp2SnpReceive ( )=0D {=0D INTN ReceivedPackets;=0D - PP2DXE_CONTEXT *Pp2Context =3D INSTANCE_FROM_SNP(This);=0D - PP2DXE_PORT *Port =3D &Pp2Context->Port;=0D - MVPP2_SHARED *Mvpp2Shared =3D Pp2Context->Port.Priv;=0D + PP2DXE_CONTEXT *Pp2Context;=0D + PP2DXE_PORT *Port;=0D UINTN PhysAddr, VirtAddr;=0D - EFI_STATUS Status =3D EFI_SUCCESS;=0D + EFI_STATUS Status;=0D EFI_TPL SavedTpl;=0D UINT32 StatusReg;=0D INTN PoolId;=0D UINTN PktLength;=0D UINT8 *DataPtr;=0D MVPP2_RX_DESC *RxDesc;=0D - MVPP2_RX_QUEUE *Rxq =3D &Port->Rxqs[0];=0D + MVPP2_RX_QUEUE *Rxq;=0D +=0D + /* Check input parameters. */=0D + if (This =3D=3D NULL || Buffer =3D=3D NULL || BufferSize =3D=3D NULL) {= =0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + SavedTpl =3D gBS->RaiseTPL (TPL_CALLBACK);=0D +=0D + Pp2Context =3D INSTANCE_FROM_SNP (This);=0D =0D + /* Check whether the driver was started and initialized. */=0D + if (This->Mode->State !=3D EfiSimpleNetworkInitialized) {=0D + switch (This->Mode->State) {=0D + case EfiSimpleNetworkStopped:=0D + DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not started\n", Pp2Context->Instance)= );=0D + ReturnUnlock (SavedTpl, EFI_NOT_STARTED);=0D + case EfiSimpleNetworkStarted:=0D + DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not initialized\n", Pp2Context->Insta= nce));=0D + ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);=0D + default:=0D + DEBUG ((DEBUG_WARN,=0D + "Pp2Dxe%d: wrong state: %u\n",=0D + Pp2Context->Instance,=0D + This->Mode->State));=0D + ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);=0D + }=0D + }=0D +=0D + Port =3D &Pp2Context->Port;=0D ASSERT (Port !=3D NULL);=0D + Rxq =3D &Port->Rxqs[0];=0D ASSERT (Rxq !=3D NULL);=0D =0D - SavedTpl =3D gBS->RaiseTPL (TPL_CALLBACK);=0D ReceivedPackets =3D Mvpp2RxqReceived(Port, Rxq->Id);=0D =0D if (ReceivedPackets =3D=3D 0) {=0D @@ -1285,10 +1312,12 @@ Pp2SnpReceive ( *EtherType =3D NTOHS (*(UINT16 *)(&DataPtr[12]));=0D }=0D =0D + Status =3D EFI_SUCCESS;=0D +=0D drop:=0D /* Refill: pass packet back to BM */=0D PoolId =3D (StatusReg & MVPP2_RXD_BM_POOL_ID_MASK) >> MVPP2_RXD_BM_POOL_= ID_OFFS;=0D - Mvpp2BmPoolPut(Mvpp2Shared, PoolId, PhysAddr, VirtAddr);=0D + Mvpp2BmPoolPut (Pp2Context->Port.Priv, PoolId, PhysAddr, VirtAddr);=0D =0D /* Update counters with 1 packet received and 1 packet refilled */=0D Mvpp2RxqStatusUpdate(Port, Rxq->Id, 1, 1);=0D --=20 2.29.0