[Linaro-uefi,v2,2/2] Platforms/AMD/Cello: add Realtek MAC override driver

Message ID 20170628191349.5233-3-ard.biesheuvel@linaro.org
State New
Headers show
Series
  • Platforms/AMD/Cello: implement MAC override
Related show

Commit Message

Ard Biesheuvel June 28, 2017, 7:13 p.m.
Deal with the missing MAC address on the Cello Realtek NIC by
incorporating an alternative driver that programs another MAC
address, either the hardcoded default, or a custom value taken
from a UEFI variable.

To build the platform with this driver incorporated, and with the
default MAC set to 00:E0:4C:97:3C:DC

  build -p OpenPlatformPkg/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc \
        -D RENESAS_XHCI_FW_DIR=~/Downloads \
        -D RTK8169_MAC_OVERRIDE=0x0,0xE0,0x4C,0x97,0x3C,0xDC

On the individual boards, the MAC can be overridden locally by issuing
the following command in the UEFI Shell (all on a single line)

  setvar Rtk8169MacOverride
     -guid 2a5e4deb-4445-4fb6-8b14-366b8e779b69
     -nv -bs =00E04C973CDD

which will set the local MAC to 00:E0:4C:97:3C:DD instead.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc | 15 ++++++++++++---
 Platforms/AMD/Styx/CelloBoard/CelloBoard.fdf |  4 ++++
 2 files changed, 16 insertions(+), 3 deletions(-)

Patch

diff --git a/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc b/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc
index 90cda24ae49d..a7b3e4bb2e32 100644
--- a/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc
+++ b/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc
@@ -17,9 +17,10 @@ 
 ################################################################################
 [Defines]
 
-DEFINE NUM_CORES    = 4
-DEFINE DO_KCS       = 0
-DEFINE DO_FLASHER   = FALSE
+DEFINE NUM_CORES            = 4
+DEFINE DO_KCS               = 0
+DEFINE DO_FLASHER           = FALSE
+DEFINE RTK8169_MAC_OVERRIDE = 0x0
 
   PLATFORM_NAME                  = Cello
   PLATFORM_GUID                  = 77861b3e-74b0-4ff3-8d18-c5ba5803e1bf
@@ -476,6 +477,10 @@  DEFINE DO_FLASHER   = FALSE
 
   gAmdStyxTokenSpaceGuid.PcdEnableSmmus|L"StyxEnableSmmus"|gAmdStyxVariableGuid|0x0|FALSE
 
+!if "$(RTK8169_MAC_OVERRIDE)" != "0x0"
+  gOpenPlatformTokenSpaceGuid.PcdMacOverride|L"Rtk8169MacOverride"|gAmdStyxVariableGuid|0x0|{$(RTK8169_MAC_OVERRIDE)}
+!endif
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform
@@ -698,3 +703,7 @@  DEFINE DO_FLASHER   = FALSE
       ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
   }
 !endif
+
+!if "$(RTK8169_MAC_OVERRIDE)" != "0x0"
+  OpenPlatformPkg/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.inf
+!endif
diff --git a/Platforms/AMD/Styx/CelloBoard/CelloBoard.fdf b/Platforms/AMD/Styx/CelloBoard/CelloBoard.fdf
index 6f7428f0c4ca..30ea6ac08ab4 100644
--- a/Platforms/AMD/Styx/CelloBoard/CelloBoard.fdf
+++ b/Platforms/AMD/Styx/CelloBoard/CelloBoard.fdf
@@ -240,6 +240,10 @@  READ_LOCK_STATUS   = TRUE
   }
 !endif
 
+!if "$(RTK8169_MAC_OVERRIDE)" != "0x0"
+  INF OpenPlatformPkg/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.inf
+!endif
+
 [FV.STYX_EFI]
 FvAlignment        = 16
 ERASE_POLARITY     = 1