Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Silicon/Broadcom/BcmGenetDxe: implement media state adapter info prot…
…ocol NetLibDetectMedia () in DxeNetLib is used as a fallback on implementations of the SNP protocol that do not also carry an implementation of the adapter info protocol to provide media state information, and it does all kinds of terrible things to the network interface (stopping and restarting multiple times, reprogramming the multicast filters etc etc) to workaround some alleged UNDI shortcoming. Although our GENET code should be bullet proof and therefore able to take this kind of abuse, it is better to avoid it, and provide an implementation of the adapter info protocol that returns the media state directly, without the need to mistreat the SNP layer. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com> Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Tested-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
- Loading branch information
Ard Biesheuvel
committed
Jun 18, 2020
1 parent
daec244
commit 743f501b66db712d486347ddca781ffc705c1766
Showing
4 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** @file | ||
Copyright (c) 2020 Arm, Limited. All rights reserved. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Uefi.h> | ||
#include <Library/BaseMemoryLib.h> | ||
#include <Library/DebugLib.h> | ||
#include <Library/MemoryAllocationLib.h> | ||
|
||
#include "BcmGenetDxe.h" | ||
|
||
STATIC | ||
EFI_STATUS | ||
EFIAPI | ||
GenetAipGetInformation ( | ||
IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, | ||
IN EFI_GUID *InformationType, | ||
OUT VOID **InformationBlock, | ||
OUT UINTN *InformationBlockSize | ||
) | ||
{ | ||
EFI_ADAPTER_INFO_MEDIA_STATE *AdapterInfo; | ||
GENET_PRIVATE_DATA *Genet; | ||
|
||
if (This == NULL || InformationBlock == NULL || | ||
InformationBlockSize == NULL) { | ||
return EFI_INVALID_PARAMETER; | ||
} | ||
|
||
if (!CompareGuid (InformationType, &gEfiAdapterInfoMediaStateGuid)) { | ||
return EFI_UNSUPPORTED; | ||
} | ||
|
||
AdapterInfo = AllocateZeroPool (sizeof (EFI_ADAPTER_INFO_MEDIA_STATE)); | ||
if (AdapterInfo == NULL) { | ||
return EFI_OUT_OF_RESOURCES; | ||
} | ||
|
||
*InformationBlock = AdapterInfo; | ||
*InformationBlockSize = sizeof (EFI_ADAPTER_INFO_MEDIA_STATE); | ||
|
||
Genet = GENET_PRIVATE_DATA_FROM_AIP_THIS (This); | ||
AdapterInfo->MediaState = GenericPhyUpdateConfig (&Genet->Phy); | ||
|
||
return EFI_SUCCESS; | ||
} | ||
|
||
STATIC | ||
EFI_STATUS | ||
EFIAPI | ||
GenetAipSetInformation ( | ||
IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, | ||
IN EFI_GUID *InformationType, | ||
IN VOID *InformationBlock, | ||
IN UINTN InformationBlockSize | ||
) | ||
{ | ||
if (This == NULL || InformationBlock == NULL) { | ||
return EFI_INVALID_PARAMETER; | ||
} | ||
|
||
if (CompareGuid (InformationType, &gEfiAdapterInfoMediaStateGuid)) { | ||
return EFI_WRITE_PROTECTED; | ||
} | ||
|
||
return EFI_UNSUPPORTED; | ||
} | ||
|
||
STATIC | ||
EFI_STATUS | ||
EFIAPI | ||
GenetAipGetSupportedTypes ( | ||
IN EFI_ADAPTER_INFORMATION_PROTOCOL *This, | ||
OUT EFI_GUID **InfoTypesBuffer, | ||
OUT UINTN *InfoTypesBufferCount | ||
) | ||
{ | ||
EFI_GUID *Guid; | ||
|
||
if (This == NULL || InfoTypesBuffer == NULL || | ||
InfoTypesBufferCount == NULL) { | ||
return EFI_INVALID_PARAMETER; | ||
} | ||
|
||
Guid = AllocatePool (sizeof *Guid); | ||
if (Guid == NULL) { | ||
return EFI_OUT_OF_RESOURCES; | ||
} | ||
|
||
CopyGuid (Guid, &gEfiAdapterInfoMediaStateGuid); | ||
|
||
*InfoTypesBuffer = Guid; | ||
*InfoTypesBufferCount = 1; | ||
|
||
return EFI_SUCCESS; | ||
} | ||
|
||
CONST EFI_ADAPTER_INFORMATION_PROTOCOL gGenetAdapterInfoTemplate = { | ||
GenetAipGetInformation, | ||
GenetAipSetInformation, | ||
GenetAipGetSupportedTypes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters