[edk2-devel] [PATCH edk2-platforms 1/3] Silicon/Broadcom/BcmGenetDxe: program MAC also when not connected

Pete Batard pete at akeo.ie
Thu Jun 4 12:27:06 UTC 2020


Note: For some reason, I am getting extra empty lines in this patch 
series, which makes applying those patches problematic.

Apart from that, I have no notes on the proposal.

On 2020.06.04 10:50, Ard Biesheuvel wrote:
> In preparation of removing the EfiBootManagerConnectAll() from the
> ordinary boot path, ensure that the MAC programming of the GENET
> occurs even if the SNP driver for it is never invoked by the BDS.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel at arm.com>
> ---
>   Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 66 ++++++++++++++++++++
>   1 file changed, 66 insertions(+)
> 
> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
> index f37da3b65511..7f93c68cd608 100644
> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
> @@ -12,6 +12,7 @@
>   #include <Uefi.h>
> 
>   #include <Library/BaseMemoryLib.h>
> 
>   #include <Library/DebugLib.h>
> 
> +#include <Library/IoLib.h>
> 
>   #include <Library/MemoryAllocationLib.h>
> 
>   #include <Library/NetLib.h>
> 
>   #include <Library/UefiBootServicesTableLib.h>
> 
> @@ -20,6 +21,9 @@
>   
> 
>   #include "BcmGenetDxe.h"
> 
>   
> 
> +STATIC EFI_EVENT      mProtocolNotifyEvent;
> 
> +STATIC VOID           *mProtocolNotifyEventRegistration;
> 
> +
> 
>   /**
> 
>     Tests to see if this driver supports a given controller.
> 
>   
> 
> @@ -305,6 +309,57 @@ STATIC EFI_DRIVER_BINDING_PROTOCOL mGenetDriverBinding = {
>     NULL
> 
>   };
> 
>   
> 
> +STATIC
> 
> +VOID
> 
> +EFIAPI
> 
> +OnProtocolNotify (
> 
> +  IN  EFI_EVENT       Event,
> 
> +  IN  VOID            *Context
> 
> +  )
> 
> +{
> 
> +  BCM_GENET_PLATFORM_DEVICE_PROTOCOL  *GenetDevice;
> 
> +  EFI_STATUS                          Status;
> 
> +  EFI_HANDLE                          *HandleBuffer;
> 
> +  UINTN                               HandleCount;
> 
> +  UINTN                               Index;
> 
> +  UINT32                              Mac0, Mac1;
> 
> +
> 
> +  while (TRUE) {
> 
> +    Status = gBS->LocateHandleBuffer (ByRegisterNotify, NULL,
> 
> +                    mProtocolNotifyEventRegistration, &HandleCount,
> 
> +                    &HandleBuffer);
> 
> +    if (EFI_ERROR (Status)) {
> 
> +      break;
> 
> +    }
> 
> +
> 
> +    for (Index = 0; Index < HandleCount; Index++) {
> 
> +      Status = gBS->HandleProtocol (HandleBuffer[Index],
> 
> +                      &gBcmGenetPlatformDeviceProtocolGuid,
> 
> +                      (VOID **)&GenetDevice);
> 
> +      ASSERT_EFI_ERROR (Status);
> 
> +
> 
> +      Mac0 = (GenetDevice->MacAddress.Addr[3])       |
> 
> +             (GenetDevice->MacAddress.Addr[2] << 8)  |
> 
> +             (GenetDevice->MacAddress.Addr[1] << 16) |
> 
> +             (GenetDevice->MacAddress.Addr[0] << 24);
> 
> +      Mac1 = (GenetDevice->MacAddress.Addr[5])       |
> 
> +             (GenetDevice->MacAddress.Addr[4] << 8);
> 
> +
> 
> +      MmioOr32 (GenetDevice->BaseAddress + GENET_SYS_RBUF_FLUSH_CTRL,
> 
> +        GENET_SYS_RBUF_FLUSH_RESET);
> 
> +      gBS->Stall (10);
> 
> +      MmioAnd32 (GenetDevice->BaseAddress + GENET_SYS_RBUF_FLUSH_CTRL,
> 
> +        ~GENET_SYS_RBUF_FLUSH_RESET);
> 
> +
> 
> +      MemoryFence ();
> 
> +
> 
> +      MmioWrite32 (GenetDevice->BaseAddress + GENET_UMAC_MAC0, Mac0);
> 
> +      MmioWrite32 (GenetDevice->BaseAddress + GENET_UMAC_MAC1, Mac1);
> 
> +    }
> 
> +    FreePool (HandleBuffer);
> 
> +  }
> 
> +}
> 
> +
> 
>   /**
> 
>     The entry point of GENET UEFI Driver.
> 
>   
> 
> @@ -336,6 +391,17 @@ GenetEntryPoint (
>   
> 
>     ASSERT_EFI_ERROR (Status);
> 
>   
> 
> +  //
> 
> +  // We need to program the MAC address into each existing controller,
> 
> +  // regardless of whether UEFI ever makes use of the interface, so that
> 
> +  // the OS driver will not have to care about this.
> 
> +  //
> 
> +  mProtocolNotifyEvent = EfiCreateProtocolNotifyEvent (
> 
> +                           &gBcmGenetPlatformDeviceProtocolGuid,
> 
> +                           TPL_CALLBACK, OnProtocolNotify, NULL,
> 
> +                           &mProtocolNotifyEventRegistration);
> 
> +  ASSERT (mProtocolNotifyEvent != NULL);
> 
> +
> 
>     DEBUG ((DEBUG_INIT | DEBUG_INFO, "Installed GENET UEFI driver!\n"));
> 
>   
> 
>     return EFI_SUCCESS;
> 

Reviewed-By: Pete Batard <pete at akeo.ie>

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#60722): https://edk2.groups.io/g/devel/message/60722
Mute This Topic: https://groups.io/mt/74668020/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list