X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FSnpDxe%2FSnp.c;h=a23af05078bc8939c7ea42dc83f2d26ad9489888;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hp=a63dd10b296d8b7d7a1d0332336467868e3dc253;hpb=3f103c08bac599bd68d28fb5dde982049469b983;p=mirror_edk2.git
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
index a63dd10b29..a23af05078 100644
--- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
+++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c
@@ -1,14 +1,8 @@
/** @file
Implementation of driver entry point and driver binding protocol.
-Copyright (c) 2004 - 2014, 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 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -273,7 +267,9 @@ SimpleNetworkDriverStart (
PXE_STATFLAGS InitStatFlags;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc;
-
+ BOOLEAN FoundIoBar;
+ BOOLEAN FoundMemoryBar;
+
DEBUG ((EFI_D_NET, "\nSnpNotifyNetworkInterfaceIdentifier() "));
Status = gBS->OpenProtocol (
@@ -401,9 +397,17 @@ SimpleNetworkDriverStart (
Snp->TxRxBufferSize = 0;
Snp->TxRxBuffer = NULL;
-
+
+ Snp->RecycledTxBuf = AllocatePool (sizeof (UINT64) * SNP_TX_BUFFER_INCREASEMENT);
+ if (Snp->RecycledTxBuf == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error_DeleteSNP;
+ }
+ Snp->MaxRecycledTxBuf = SNP_TX_BUFFER_INCREASEMENT;
+ Snp->RecycledTxBufCount = 0;
+
if (Nii->Revision >= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION) {
- Snp->IfNum = Nii->IfNum;
+ Snp->IfNum = Nii->IfNum;
} else {
Snp->IfNum = (UINT8) (Nii->IfNum & 0xFF);
@@ -463,6 +467,8 @@ SimpleNetworkDriverStart (
//
Snp->MemoryBarIndex = 0;
Snp->IoBarIndex = 1;
+ FoundMemoryBar = FALSE;
+ FoundIoBar = FALSE;
for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {
Status = PciIo->GetBarAttributes (
PciIo,
@@ -476,13 +482,19 @@ SimpleNetworkDriverStart (
goto Error_DeleteSNP;
}
- if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
+ if ((!FoundMemoryBar) && (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM)) {
Snp->MemoryBarIndex = BarIndex;
- } else if (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {
+ FoundMemoryBar = TRUE;
+ } else if ((!FoundIoBar) && (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_IO)) {
Snp->IoBarIndex = BarIndex;
+ FoundIoBar = TRUE;
}
FreePool (BarDesc);
+
+ if (FoundMemoryBar && FoundIoBar) {
+ break;
+ }
}
Status = PxeStart (Snp);
@@ -536,12 +548,12 @@ SimpleNetworkDriverStart (
switch (InitStatFlags & PXE_STATFLAGS_CABLE_DETECT_MASK) {
case PXE_STATFLAGS_CABLE_DETECT_SUPPORTED:
- Snp->Mode.MediaPresentSupported = TRUE;
+ Snp->CableDetectSupported = TRUE;
break;
case PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED:
default:
- Snp->Mode.MediaPresentSupported = FALSE;
+ Snp->CableDetectSupported = FALSE;
}
switch (InitStatFlags & PXE_STATFLAGS_GET_STATUS_NO_MEDIA_MASK) {
@@ -554,6 +566,10 @@ SimpleNetworkDriverStart (
Snp->MediaStatusSupported = FALSE;
}
+ if (Snp->CableDetectSupported || Snp->MediaStatusSupported) {
+ Snp->Mode.MediaPresentSupported = TRUE;
+ }
+
if ((Pxe->hw.Implementation & PXE_ROMID_IMP_STATION_ADDR_SETTABLE) != 0) {
Snp->Mode.MacAddressChangeable = TRUE;
} else {
@@ -668,6 +684,10 @@ SimpleNetworkDriverStart (
Error_DeleteSNP:
+ if (Snp->RecycledTxBuf != NULL) {
+ FreePool (Snp->RecycledTxBuf);
+ }
+
PciIo->FreeBuffer (
PciIo,
SNP_MEM_PAGES (sizeof (SNP_DRIVER)),
@@ -780,6 +800,8 @@ SimpleNetworkDriverStop (
PxeShutdown (Snp);
PxeStop (Snp);
+ FreePool (Snp->RecycledTxBuf);
+
PciIo = Snp->PciIo;
PciIo->FreeBuffer (
PciIo,