X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FSnpDxe%2FReceive.c;h=28cea0d2e9722fbfa5482e7398a2a8388d7a1f9a;hp=92123b6c1fe76835bc5869a88fd88e008d4c82be;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hpb=9cff2f8d3687aeed765e1ee787c18ce70ae500bc diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Receive.c b/MdeModulePkg/Universal/Network/SnpDxe/Receive.c index 92123b6c1f..28cea0d2e9 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Receive.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/Receive.c @@ -1,14 +1,8 @@ /** @file - Implementation of receiving a packet from a network interface. + Implementation of receiving a packet from a network interface. -Copyright (c) 2004 - 2007, Intel Corporation.
-All rights reserved. This program and the accompanying materials are licensed -and made available under the terms and conditions of the BSD License which -accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -68,10 +62,10 @@ PxeReceive ( Snp->Cdb.OpCode = PXE_OPCODE_RECEIVE; Snp->Cdb.OpFlags = PXE_OPFLAGS_NOT_USED; - Snp->Cdb.CPBsize = sizeof (PXE_CPB_RECEIVE); + Snp->Cdb.CPBsize = (UINT16) sizeof (PXE_CPB_RECEIVE); Snp->Cdb.CPBaddr = (UINT64)(UINTN) Cpb; - Snp->Cdb.DBsize = sizeof (PXE_DB_RECEIVE); + Snp->Cdb.DBsize = (UINT16) sizeof (PXE_DB_RECEIVE); Snp->Cdb.DBaddr = (UINT64)(UINTN) Db; Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE; @@ -132,6 +126,16 @@ PxeReceive ( *Protocol = (UINT16) PXE_SWAP_UINT16 (Db->Protocol); } + // + // We have received a packet from network interface, which implies that the + // network cable should be present. While, some UNDI driver may not report + // correct media status during Snp->Initialize(). So, we need ensure + // MediaPresent in SNP mode data is set to correct value. + // + if (Snp->Mode.MediaPresentSupported && !Snp->Mode.MediaPresent) { + Snp->Mode.MediaPresent = TRUE; + } + return (*BufferSize <= BuffSize) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL; } @@ -225,7 +229,7 @@ SnpUndi32Receive ( goto ON_EXIT; } - if (!Snp->Mode.ReceiveFilterSetting) { + if (Snp->Mode.ReceiveFilterSetting == 0) { Status = EFI_DEVICE_ERROR; goto ON_EXIT; }