From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=vijayenthiran.subramaniam@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 5353E211982F7 for ; Tue, 4 Dec 2018 01:12:42 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9BC941688; Tue, 4 Dec 2018 01:12:42 -0800 (PST) Received: from usa.arm.com (a074939-lin.blr.arm.com [10.162.0.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1B3333F5AF; Tue, 4 Dec 2018 01:12:40 -0800 (PST) From: Vijayenthiran Subramaniam To: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Date: Tue, 4 Dec 2018 14:42:23 +0530 Message-Id: <1543914749-8252-3-git-send-email-vijayenthiran.subramaniam@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543914749-8252-1-git-send-email-vijayenthiran.subramaniam@arm.com> References: <1543914749-8252-1-git-send-email-vijayenthiran.subramaniam@arm.com> Subject: [PATCH v1 edk2-platforms 2/8] Platform/ARM/SgiPkg: Add support for virtio net device X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 X-List-Received-Date: Tue, 04 Dec 2018 09:12:43 -0000 From: Daniil Egranov Add support for virtio net device by adding PCDs to specify the data required to setup the virtio net device and register it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Daniil Egranov --- Platform/ARM/SgiPkg/SgiPlatform.dec | 6 +++ Platform/ARM/SgiPkg/SgiPlatform.dsc | 18 +++++-- Platform/ARM/SgiPkg/SgiPlatform.fdf | 4 ++ Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 3 ++ Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h | 3 ++ Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c | 54 ++++++++++++++++++++ 6 files changed, 84 insertions(+), 4 deletions(-) diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec index ed29a4d5d91f..39cc3f89fd57 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dec +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec @@ -38,6 +38,7 @@ [Guids.common] [PcdsFeatureFlag.common] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001 + gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|FALSE|BOOLEAN|0x00000010 [PcdsFixedAtBuild] gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002 @@ -48,5 +49,10 @@ [PcdsFixedAtBuild] gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005 gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006 + # Virtio Network device + gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress|0x00000000|UINT32|0x00000007 + gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x00000000|UINT32|0x00000008 + gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|0x00000000|UINT32|0x00000009 + [Ppis] gHwConfigDtInfoPpiGuid = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } } diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc index ada72be72f8a..0c794c6b299d 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc @@ -45,6 +45,7 @@ [LibraryClasses.common] VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf [LibraryClasses.common.SEC] HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf @@ -99,6 +100,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr [PcdsFeatureFlag.common] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE + gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|TRUE [PcdsFixedAtBuild.common] gArmTokenSpaceGuid.PcdVFPEnabled|1 @@ -177,14 +179,19 @@ [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PcdCoreCount|4 gArmPlatformTokenSpaceGuid.PcdClusterCount|2 - # Ethernet - gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000 - # Virtio Disk gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000 gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000 gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202 + # Ethernet / Virtio Network +!ifdef EDK2_ENABLE_SMSC_91X + gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000 +!endif + gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress|0x1c150000 + gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x10000 + gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|204 + ################################################################################ # # Components Section - list of all EDK II Modules needed by this Platform @@ -288,8 +295,11 @@ [Components.common] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf } - # SMSC LAN 91C111 + # SMSC LAN 91C111 / Virtio Network +!ifdef EDK2_ENABLE_SMSC_91X EmbeddedPkg/Drivers/Lan91xDxe/Lan91xDxe.inf +!endif + OvmfPkg/VirtioNetDxe/VirtioNet.inf # # Required by PCI diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf b/Platform/ARM/SgiPkg/SgiPlatform.fdf index b7af4a2a5925..ddf1fda5a16e 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.fdf +++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf @@ -191,7 +191,11 @@ [FV.FvMain] INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf INF NetworkPkg/TcpDxe/TcpDxe.inf INF NetworkPkg/IScsiDxe/IScsiDxe.inf + +!ifdef EDK2_ENABLE_SMSC_91X INF EmbeddedPkg/Drivers/Lan91xDxe/Lan91xDxe.inf +!endif + INF OvmfPkg/VirtioNetDxe/VirtioNet.inf [FV.FVMAIN_COMPACT] FvAlignment = 16 diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf index f920f6ecafb8..3283ff045372 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf @@ -42,10 +42,13 @@ [Guids] [FeaturePcd] gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported + gArmSgiTokenSpaceGuid.PcdVirtioNetSupported [FixedPcd] gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress gArmSgiTokenSpaceGuid.PcdVirtioBlkSize + gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress + gArmSgiTokenSpaceGuid.PcdVirtioNetSize [Depex] TRUE diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h index 80d3e3ae4f91..b7aab64d7bf7 100644 --- a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h @@ -18,4 +18,7 @@ #define SGI_VIRTIO_BLOCK_GUID \ { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } } +#define SGI_VIRTIO_NET_GUID \ + { 0xf5a453e8, 0x5f5f, 0x4e7b, { 0x89, 0x4f, 0x3a, 0x23, 0x74, 0xc7, 0x28, 0xb1 } } + #endif diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c index 4703aec06968..e2efc4e18e13 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c @@ -49,6 +49,29 @@ STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath = } }; +STATIC VIRTIO_DEVICE_PATH mVirtioNetDevicePath = +{ + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)(sizeof (VENDOR_DEVICE_PATH)), + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) + } + }, + SGI_VIRTIO_NET_GUID, + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + sizeof (EFI_DEVICE_PATH_PROTOCOL), + 0 + } + } +}; + /** Initialize platform Virtio devices. @@ -60,6 +83,7 @@ InitVirtioDevices ( { EFI_STATUS Status; STATIC EFI_HANDLE mVirtIoBlkController = NULL; + STATIC EFI_HANDLE mVirtIoNetController = NULL; // Install protocol interface for storage device if ((FeaturePcdGet (PcdVirtioBlkSupported)) && @@ -89,4 +113,34 @@ InitVirtioDevices ( } } } + + // Install protocol interface for network device + if ((FeaturePcdGet (PcdVirtioNetSupported)) && + (FixedPcdGet32 (PcdVirtioNetBaseAddress))) { + Status = gBS->InstallProtocolInterface (&mVirtIoNetController, + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, + &mVirtioNetDevicePath); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol " + "for Virtio Network device (Status = %r)\n", + __FUNCTION__, Status)); + } else { + // Declare the Virtio Net device + Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioNetBaseAddress), + mVirtIoNetController); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Network MMIO device " + "(Status == %r)\n", + __FUNCTION__, Status)); + gBS->UninstallProtocolInterface ( + mVirtIoNetController, + &gEfiDevicePathProtocolGuid, + &mVirtioNetDevicePath + ); + } else { + DEBUG ((DEBUG_INIT, "%a: Installed Virtio Network device\n", + __FUNCTION__)); + } + } + } } -- 2.7.4