From patchwork Wed Jun 28 19:13:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 106570 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp270314qge; Wed, 28 Jun 2017 12:14:42 -0700 (PDT) X-Received: by 10.237.37.174 with SMTP id x43mr15481259qtc.133.1498677282178; Wed, 28 Jun 2017 12:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498677282; cv=none; d=google.com; s=arc-20160816; b=ChfegltQDDdjW5pcYrAuqHzm1yBoFc2YGh8N5G2v84MP/40fn9q22ftm5ljR0sz7Op 2C2LQkeoPKuhvi8N2AsMnnkeFc/5Pcrt/kdx1d3XAQweVnjoxlpK1vIc+0cANlMl8MNt +UF5yUGkXwdoe2qVDfsbqk4fSlDkKQwv+QSOZVwvdleLxt4lcXN/Ik2D9+mKmYnjAm5B c4/NYz1/RMr4HrJoXNblG+CA5jF4iOk1IR9S8UckwHN+QM5ZBt3tam8n0sU+8y8oqr0o jIKJBPUIELYIPLdWTsoKpZEEGMMOBMkIIiQiOdKYCgO5DlBGevSOTafNZ5nWO1kJLAlG TBeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=qnW9tOKtyyoMouGmfQrnKmm4RcJ08cavAdZj7Zc5loA=; b=KqQEn2TzGxUim00vFe6l0acAz5g9bXaJ3uIKNAaPvOmlmiQctENzdgikXQhwNVQJXL UoMAgKoJCdECxQut60H0Mv6HPMTT0wom4IkQf3vKR3xeOZhQClLytm58zEyq40ZCUr2k DWDIJaGVuRPYZRy0ISL2APloCiyH2+AgijPyDaJgMszzYo6+Ukf3ktRp7c+TPLUtbc+r EIVU/MC4IImj044rMTKadIYI3kTzHjaEOHbBhZSnJ3nI2+WjYAxDH452mt8YBTcIrHHV VSnTKB/v20Z/zN7QVXbf/ufxeswjOSYgBWAQlrpg3BhR1oQ7Y9TZ4J1q7MlVh+CgnfA6 f7NA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l64si2839820qkl.189.2017.06.28.12.14.40; Wed, 28 Jun 2017 12:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C126060C26; Wed, 28 Jun 2017 19:14:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3EF2960D5E; Wed, 28 Jun 2017 19:14:21 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 03C1A60C1E; Wed, 28 Jun 2017 19:14:16 +0000 (UTC) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by lists.linaro.org (Postfix) with ESMTPS id 1C03B60D42 for ; Wed, 28 Jun 2017 19:14:02 +0000 (UTC) Received: by mail-wm0-f53.google.com with SMTP id t129so14348888wmt.1 for ; Wed, 28 Jun 2017 12:14:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=agt/DNIqYgBiYMPr/rJ6VxUcVrmG4G5DXKgGgnxrQJc=; b=ZGZLZ6m9pnbpVGZGYSOr2x5yxxC1P7jwLKKxG4tF289DadiXtj+xXLugrVYWXNOcCa ykPX5TQQfYi1OpcGyWUzWLIsUv9Wn9/ECzzgTsNgS9sAR43eZkb+kBZOzE6zKqEztw6L 8rfGP4UBs8HWZw4EGUzgVhiynoMZJgR8TRKW/qOidkUjRrkvbGwLP79qxDR1TSxHO9Rv aWA0wqKZu+7lsZPkSvtNBBmhvfbSjOPUU5g4trkYw9188vN3y71nlcOvkrXJO5FebKs1 hcZ8I/rbfxRlCeheaT0CzOB4GxryVVkJi+AFJNBwY7DMmDGgs97Na0hLfFbkyTOcWkWz Lu7w== X-Gm-Message-State: AKS2vOz+Ixixg/Fda8Nkm1dis1Je4cl0WLODvYFa7anSwQuRd5eK6C2R UNIC+TReqb7+FuDLM7/8Pkqi X-Received: by 10.28.10.76 with SMTP id 73mr2220953wmk.93.1498677240814; Wed, 28 Jun 2017 12:14:00 -0700 (PDT) Received: from localhost.localdomain ([105.133.250.69]) by smtp.gmail.com with ESMTPSA id s30sm4375824wrc.13.2017.06.28.12.13.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 12:14:00 -0700 (PDT) From: Ard Biesheuvel To: linaro-uefi@lists.linaro.org Date: Wed, 28 Jun 2017 19:13:48 +0000 Message-Id: <20170628191349.5233-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170628191349.5233-1-ard.biesheuvel@linaro.org> References: <20170628191349.5233-1-ard.biesheuvel@linaro.org> Cc: rfranz@cavium.com Subject: [Linaro-uefi] [PATCH v2 1/2] Drivers/Net: add MAC override driver for Realtek 8169 X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "For discussions about Linaro-related UEFI development. Not a substitute for edk2-devel." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" Sadly, the Cellos have been delivered with a Realtek NIC that lacks a MAC address in its OTP. This can be worked around from the OS, but this confuses some installers, and it is much better to deal with this in the firmware. Since network boot using the full Realtek 8169 driver is impossible anyway in this case, for the same reason, let's provide a driver that programs a MAC into the volatile NIC registers in a way that allows the OS to run unmodified. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.c | 263 ++++++++++++++++++++ Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.inf | 44 ++++ OpenPlatformPkg.dec | 3 + 3 files changed, 310 insertions(+) diff --git a/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.c b/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.c new file mode 100644 index 000000000000..12029269e490 --- /dev/null +++ b/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.c @@ -0,0 +1,263 @@ +/** @file + Realtek 8169 MAC override driver + +Copyright (c) 2017, Linaro Limited. 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. + +**/ + +#include + +#include +#include +#include +#include + +#include + +#include + +#define PCI_VENDOR_ID_REALTEK 0x10EC +#define PCI_DEVICE_ID_REALTEK_8169 0x8168 + +STATIC CONST UINT8 *mMacOverride; + +#define MAC 0x0 +#define CFG9346 0x50 + +STATIC CONST UINT8 Cfg9346_Unlock = 0xc0; +STATIC CONST UINT8 Cfg9346_Lock = 0x0; + +STATIC BOOLEAN Done; + +/** + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to test. + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval other This driver does not support this device. + +**/ +STATIC +EFI_STATUS +EFIAPI +Realtek8169MacOverrideDriverSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) +{ + EFI_STATUS Status; + EFI_PCI_IO_PROTOCOL *PciIo; + UINT32 PciID; + UINT64 Supports; + UINT32 MacWord; + + // + // Execute only once + // + if (Done) { + return EFI_UNSUPPORTED; + } + + // + // Check for the PCI IO Protocol + // + Status = gBS->OpenProtocol (Controller, &gEfiPciIoProtocolGuid, + (VOID **)&PciIo, This->DriverBindingHandle, Controller, + EFI_OPEN_PROTOCOL_BY_DRIVER); + + if (EFI_ERROR (Status)) { + return Status; + } + + Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, PCI_VENDOR_ID_OFFSET, + 1, &PciID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: Pci->Pci.Read() of vendor/device id failed (Status == %r)\n", + __FUNCTION__, Status)); + goto CloseProtocol; + } + + if ((PciID & 0xffff) != PCI_VENDOR_ID_REALTEK || + (PciID >> 16) != PCI_DEVICE_ID_REALTEK_8169) { + DEBUG ((DEBUG_INFO, "%a: ignoring unsupported PCI device 0x%04x:0x%04x\n", + __FUNCTION__, PciID & 0xffff, PciID >> 16)); + goto CloseProtocol; + } + + // + // Enable the device so we can poke at its MMIO registers + // + Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, + 0, &Supports); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, + "%a: failed to get PCI attributes, aborting (Status == %r)...\n", + __FUNCTION__, Status)); + goto CloseProtocol; + } + + Supports &= EFI_PCI_DEVICE_ENABLE; + Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable, + Supports, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, + "%a: failed to set PCI attributes, aborting (Status == %r)...\n", + __FUNCTION__, Status)); + goto CloseProtocol; + } + + // + // Program the MAC address + // + Status = PciIo->Mem.Write (PciIo, EfiPciIoWidthUint8, 2, CFG9346, 0x1, + (VOID *)&Cfg9346_Unlock); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: unlock failed, aborting (Status == %r)...\n", __FUNCTION__, Status)); + goto CloseProtocol; + } + + CopyMem (&MacWord, (UINT8 *)mMacOverride + 4, sizeof MacWord); + Status = PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 2, MAC + 4, 0x1, &MacWord); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to set MAC address (#1) ...\n", __FUNCTION__)); + } + + CopyMem (&MacWord, (UINT8 *)mMacOverride, sizeof MacWord); + Status = PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 2, MAC, 0x1, &MacWord); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to set MAC address (#2) ...\n", __FUNCTION__)); + } + + Status = PciIo->Mem.Write (PciIo, EfiPciIoWidthUint8, 2, CFG9346, 0x1, + (VOID *)&Cfg9346_Lock); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: relock failed ...\n", __FUNCTION__)); + goto CloseProtocol; + } + + Done = TRUE; + + PciIo->Attributes (PciIo, EfiPciIoAttributeOperationDisable, Supports, NULL); + +CloseProtocol: + gBS->CloseProtocol (Controller, &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, Controller); + + // + // Always return unsupported: we are not interested in driving the device, + // only in having the opportunity to updating the MAC address before the real + // driver attaches to it. + // + return EFI_UNSUPPORTED; +} + +/** + Start this driver on Controller. Not used. + + @param [in] This Protocol instance pointer. + @param [in] Controller Handle of device to work with. + @param [in] RemainingDevicePath Not used, always produce all possible children. + + @retval EFI_SUCCESS This driver is added to Controller. + @retval other This driver does not support this device. + +**/ +STATIC +EFI_STATUS +EFIAPI +Realtek8169MacOverrideDriverStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath + ) +{ + // + // We are not interested in driving the device, we only poke the firmware + // in the .Supported() callback. + // + ASSERT (FALSE); + return EFI_INVALID_PARAMETER; +} + +/** + Stop this driver on Controller. Not used. + + @param [in] This Protocol instance pointer. + @param [in] Controller Handle of device to stop driver on. + @param [in] NumberOfChildren How many children need to be stopped. + @param [in] ChildHandleBuffer Not used. + + @retval EFI_SUCCESS This driver is removed Controller. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + @retval other This driver was not removed from this device. + +**/ +STATIC +EFI_STATUS +EFIAPI +Realtek8169MacOverrideDriverStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE Controller, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ) +{ + ASSERT (FALSE); + return EFI_SUCCESS; +} + +// +// UEFI Driver Model entry point +// +STATIC EFI_DRIVER_BINDING_PROTOCOL Realtek8169MacOverrideDriverBinding = { + Realtek8169MacOverrideDriverSupported, + Realtek8169MacOverrideDriverStart, + Realtek8169MacOverrideDriverStop, + + // Version values of 0xfffffff0-0xffffffff are reserved for platform/OEM + // specific drivers. Protocol instances with higher 'Version' properties + // will be used before lower 'Version' ones. XhciDxe uses version 0x30, + // so this driver will be called in preference, and XhciDxe will be invoked + // after Realtek8169MacOverrideDriverSupported returns EFI_UNSUPPORTED. + 0xfffffff0, + NULL, + NULL +}; + +EFI_STATUS +EFIAPI +InitializeRealtek8169MacOverride ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + mMacOverride = PcdGetPtr (PcdMacOverride); + + DEBUG ((DEBUG_WARN, "%a: using MAC override value %X:%X:%X:%X:%X:%X\n", + __FUNCTION__, mMacOverride[0], mMacOverride[1], mMacOverride[2], + mMacOverride[3], mMacOverride[4], mMacOverride[5] + )); + + return EfiLibInstallDriverBinding (ImageHandle, SystemTable, + &Realtek8169MacOverrideDriverBinding, NULL); +} diff --git a/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.inf b/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.inf new file mode 100644 index 000000000000..4ff1047281d3 --- /dev/null +++ b/Drivers/Net/Realtek8169MacOverride/Realtek8169MacOverride.inf @@ -0,0 +1,44 @@ +## file +# Component description file for Realtek 8169 MAC override driver +# +# Copyright (c) 2017, Linaro Ltd. 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. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = Realtek8169MacOverride + FILE_GUID = 8d97e056-777c-4850-ab61-8166b1777f2d + MODULE_TYPE = UEFI_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = InitializeRealtek8169MacOverride + +[Sources] + Realtek8169MacOverride.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + OpenPlatformPkg/OpenPlatformPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + PcdLib + UefiBootServicesTableLib + UefiLib + UefiDriverEntryPoint + +[Protocols] + gEfiPciIoProtocolGuid + +[Pcd] + gOpenPlatformTokenSpaceGuid.PcdMacOverride diff --git a/OpenPlatformPkg.dec b/OpenPlatformPkg.dec index 2db143d637b3..34323bc90b9a 100644 --- a/OpenPlatformPkg.dec +++ b/OpenPlatformPkg.dec @@ -41,3 +41,6 @@ gOpenPlatformTokenSpaceGuid.PcdRamDiskMaxSize|0|UINT32|0x00000001 [PcdsFeatureFlag] + +[PcdsFixedAtBuild,PcdsDynamic] + gOpenPlatformTokenSpaceGuid.PcdMacOverride|{0x0,0x0,0x0,0x0,0x0,0x0}|VOID*|0x00000002 From patchwork Wed Jun 28 19:13:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 106569 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp270007qge; Wed, 28 Jun 2017 12:14:21 -0700 (PDT) X-Received: by 10.237.33.252 with SMTP id m57mr5176321qtc.33.1498677261635; Wed, 28 Jun 2017 12:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498677261; cv=none; d=google.com; s=arc-20160816; b=YWZKy+Yahbcaf+mJ+DxR0O6D7f8XnDjN5DBsUA2NDPjDRADZ56+AIW6IV1rXDNbaq6 hO2oGXjbuaMDCCkQTluzv0so8chwigfbn3zABGg6OubhDJjezZGHO9ON37D7FyY7udfM XGZmIz0/H5NA25yJquPNioCnpzHAjMwtVLMD4MelkDa2z+ibwSqfWpLc2QwL85YbS46K ay9LsHCs9VOsIjUuVLo9QevNHiEldUWxYaaHJmBU8+dfRITwy77CiyG3fZIiWzDnZRc3 28HYPcjTXerFJc1wyN1qjUjldHRg44CxOzkIyNl60aa7aH8wAiJt/mP/3P0v3xolx/tv zTyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=eeCqtujKjV+XT84S2w7kkF6NMXldge/PHCBYaHQ15eI=; b=QsgTyiMMHuqomGmeBz4KpMU8+PoHaFgX7f1we687snBTWEDSo4rjQVjPgdvJL4+A06 d1NTL6j5NlRoqa40n2Xtp5LUugCoC/RM2vUle9qhlJRw6nfvKJRqmYmdXFEP2SZ1Vdsa kYvbYti4WHJqvi6Xlsltvw7gVO3qsHyVUjBKdjesV4+0pSHcc0H03htcUVxCjOND/NT1 ebkABhnXB2RC0mtlOfjtgf4F3NZYsZUy2cn7XpfGbqa7hm37E6WAiWDwGlG5Q7bRqPdK a9zoGmOoVA3S6z8wjARmyIBQY8l3PXoVCls9dCjK1Uf/s9hDjRmbSQOeNQwkUiwSij+m Hwmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r50si2757557qtr.99.2017.06.28.12.14.21; Wed, 28 Jun 2017 12:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3D4CC60D4E; Wed, 28 Jun 2017 19:14:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0B0B160C1E; Wed, 28 Jun 2017 19:14:17 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3494E608C0; Wed, 28 Jun 2017 19:14:15 +0000 (UTC) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by lists.linaro.org (Postfix) with ESMTPS id A5BD5608C0 for ; Wed, 28 Jun 2017 19:14:03 +0000 (UTC) Received: by mail-wm0-f53.google.com with SMTP id i127so69096891wma.0 for ; Wed, 28 Jun 2017 12:14:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lueiPHtds3jcv7ZQh2y9h93M14K2feAFx7gSt3e4T0k=; b=ac3Ee2MkJVapA+E4W8a4501P1v5G2hQjF2DHpFdlNKmUl5uG+fzcvsbSLx+Od0Fk19 5mLyMSLS8aJyBx5qfV7BG90oamcVklX+vSKYqA7595ZFLLicdPycG3NYftMji/r5+L5I sDBeJmLtjpnhOmBZTFJCZFuOHKvG9cX2MtkbQWjjlJl7Q8Tvm5uyoVQ9v5oXQ8jfgSHU WO3zK/Dq9ZhZCeDO/BxckIFXNouENQ4sTNva6/wsKcC9rMkcYBWzukCGyvFhJk6DwyqH nGmpmS4McrS+xdwTunuKGhdmF9B5fxBdtrAfGPNnQLac8BRCepHcgDWYQTq+g7zaq11i wb7w== X-Gm-Message-State: AKS2vOwwBXnVqsevFlBPK/18MNmfnwi6KLdyxjQ86bJ+zEqI5k4fHZVO MU7UvlcVqDU0MnHOFtr0GbGy X-Received: by 10.28.223.86 with SMTP id w83mr7476773wmg.9.1498677242436; Wed, 28 Jun 2017 12:14:02 -0700 (PDT) Received: from localhost.localdomain ([105.133.250.69]) by smtp.gmail.com with ESMTPSA id s30sm4375824wrc.13.2017.06.28.12.14.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 12:14:01 -0700 (PDT) From: Ard Biesheuvel To: linaro-uefi@lists.linaro.org Date: Wed, 28 Jun 2017 19:13:49 +0000 Message-Id: <20170628191349.5233-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170628191349.5233-1-ard.biesheuvel@linaro.org> References: <20170628191349.5233-1-ard.biesheuvel@linaro.org> Cc: rfranz@cavium.com Subject: [Linaro-uefi] [PATCH v2 2/2] Platforms/AMD/Cello: add Realtek MAC override driver X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "For discussions about Linaro-related UEFI development. Not a substitute for edk2-devel." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" 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 Reviewed-by: Leif Lindholm --- Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc | 15 ++++++++++++--- Platforms/AMD/Styx/CelloBoard/CelloBoard.fdf | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) 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