From: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
To: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org,
leif.lindholm@linaro.org
Subject: [PATCH v1 edk2-platforms 2/8] Platform/ARM/SgiPkg: Add support for virtio net device
Date: Tue, 4 Dec 2018 14:42:23 +0530 [thread overview]
Message-ID: <1543914749-8252-3-git-send-email-vijayenthiran.subramaniam@arm.com> (raw)
In-Reply-To: <1543914749-8252-1-git-send-email-vijayenthiran.subramaniam@arm.com>
From: Daniil Egranov <daniil.egranov@arm.com>
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 <daniil.egranov@arm.com>
---
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
next prev parent reply other threads:[~2018-12-04 9:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration Vijayenthiran Subramaniam
2018-12-04 14:46 ` Ard Biesheuvel
2018-12-05 6:10 ` Vijayenthiran Subramaniam
2018-12-06 17:17 ` Ard Biesheuvel
2018-12-07 5:49 ` Vijayenthiran Subramaniam
2018-12-11 9:07 ` Vijayenthiran Subramaniam
2018-12-14 14:55 ` Ard Biesheuvel
2018-12-14 16:50 ` Vijayenthiran Subramaniam
2018-12-04 9:12 ` Vijayenthiran Subramaniam [this message]
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 3/8] Sgi575: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 4/8] Sgi575: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 5/8] SgiClark.Ares: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 6/8] SgiClark.Ares: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 7/8] SgiClark.Helios: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
2018-12-04 9:12 ` [PATCH v1 edk2-platforms 8/8] SgiClark.Helios: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1543914749-8252-3-git-send-email-vijayenthiran.subramaniam@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox