[edk2-devel] [edk2-platforms][PATCH V2 7/7] Platform/ARM/Morello: Add virtio net support

Sami Mujawar sami.mujawar at arm.com
Mon Apr 12 09:22:41 UTC 2021


Hi Chandni,

This patch looks good to me.

Reviewed-by: Sami Mujawar <sami.mujawar at arm.com>

Regards,

Sami Mujawar

On 01/04/2021, 15:36, "Chandni Cherukuri" <chandni.cherukuri at arm.com> wrote:

    This patch registers a virtio net device for Morello
    FVP platform.

    Signed-off-by: Chandni Cherukuri <chandni.cherukuri at arm.com>
    ---
     Platform/ARM/Morello/MorelloPlatform.dec                        |  6 ++
     Platform/ARM/Morello/MorelloPlatformFvp.dsc                     |  7 +++
     Platform/ARM/Morello/MorelloPlatformFvp.fdf                     |  6 ++
     Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf     |  2 +
     Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h |  3 +
     Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c        | 58 ++++++++++++++++++++
     6 files changed, 82 insertions(+)

    diff --git a/Platform/ARM/Morello/MorelloPlatform.dec b/Platform/ARM/Morello/MorelloPlatform.dec
    index 9a674593cb3c..6f5c1c1b59fc 100644
    --- a/Platform/ARM/Morello/MorelloPlatform.dec
    +++ b/Platform/ARM/Morello/MorelloPlatform.dec
    @@ -55,6 +55,12 @@
       gArmMorelloTokenSpaceGuid.PcdPciMmio64Translation|0x0|UINT64|0x00000017
       gArmMorelloTokenSpaceGuid.PcdPciExpressBaseAddress|0x20000000|UINT64|0x00000018

    +  # Virtio Net device
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetBaseAddress|0x00000000|UINT32|0x00000019
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetSize|0x00000000|UINT32|0x0000001A
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetInterrupt|0x00000000|UINT32|0x0000001B
    +
     [PcdsFeatureFlag.common]
       gArmMorelloTokenSpaceGuid.PcdRamDiskSupported|FALSE|BOOLEAN|0x00000007
       gArmMorelloTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000008
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetSupported|FALSE|BOOLEAN|0x0000001C
    diff --git a/Platform/ARM/Morello/MorelloPlatformFvp.dsc b/Platform/ARM/Morello/MorelloPlatformFvp.dsc
    index 35e02be5d5ab..e579fb917348 100644
    --- a/Platform/ARM/Morello/MorelloPlatformFvp.dsc
    +++ b/Platform/ARM/Morello/MorelloPlatformFvp.dsc
    @@ -47,6 +47,7 @@

     [PcdsFeatureFlag.common]
       gArmMorelloTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetSupported|TRUE

     [PcdsFixedAtBuild.common]
       # Virtio Disk
    @@ -54,8 +55,14 @@
       gArmMorelloTokenSpaceGuid.PcdVirtioBlkSize|0x200
       gArmMorelloTokenSpaceGuid.PcdVirtioBlkInterrupt|128

    +  # Virtio Net
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetBaseAddress|0x1C180000
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetSize|0x200
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetInterrupt|134
    +
     [Components.common]
       OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
    +  OvmfPkg/VirtioNetDxe/VirtioNet.inf

       # Platform driver
       Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf
    diff --git a/Platform/ARM/Morello/MorelloPlatformFvp.fdf b/Platform/ARM/Morello/MorelloPlatformFvp.fdf
    index dc3eccd2f3ba..851ee3159b3d 100644
    --- a/Platform/ARM/Morello/MorelloPlatformFvp.fdf
    +++ b/Platform/ARM/Morello/MorelloPlatformFvp.fdf
    @@ -120,6 +120,12 @@ READ_LOCK_STATUS   = TRUE
       # Virtio Block Device support
       INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf

    +  # Networking stack
    +  !include NetworkPkg/Network.fdf.inc
    +
    +  # Virtio Net support
    +  INF OvmfPkg/VirtioNetDxe/VirtioNet.inf
    +
       # FAT filesystem + GPT/MBR partitioning
       INF FatPkg/EnhancedFatDxe/Fat.inf
       INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
    diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf
    index e4882343fc77..c36c62f05a39 100644
    --- a/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf
    +++ b/Platform/ARM/Morello/Drivers/PlatformDxe/PlatformDxeFvp.inf
    @@ -34,11 +34,13 @@
     [FeaturePcd]
       gArmMorelloTokenSpaceGuid.PcdRamDiskSupported
       gArmMorelloTokenSpaceGuid.PcdVirtioBlkSupported
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetSupported

     [FixedPcd]
       gArmMorelloTokenSpaceGuid.PcdRamDiskBase
       gArmMorelloTokenSpaceGuid.PcdRamDiskSize
       gArmMorelloTokenSpaceGuid.PcdVirtioBlkBaseAddress
    +  gArmMorelloTokenSpaceGuid.PcdVirtioNetBaseAddress

     [Depex]
       gEfiRamDiskProtocolGuid
    diff --git a/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h b/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h
    index 77adffbfd984..b8bd40c104a2 100644
    --- a/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h
    +++ b/Platform/ARM/Morello/Include/Guid/MorelloVirtioDevicesFormSet.h
    @@ -11,4 +11,7 @@
     #define MORELLO_VIRTIO_BLOCK_GUID  \
       { 0x2B6E62D0, 0x9346, 0x4E1A, { 0xAA, 0x1E, 0xCB, 0x01, 0xC3, 0x23, 0x4A, 0x00 } }

    +#define MORELLO_VIRTIO_NET_GUID  \
    +  { 0x4B428575, 0xD09B, 0x45EE, { 0xAC, 0x91, 0xB1, 0x36, 0xBE, 0xD6, 0x70, 0x2B } }
    +
     #endif //MORELLO_VIRTIO_DEVICES_FORMSET_H_
    diff --git a/Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c b/Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c
    index 7414e0666ce0..1566d3142fc3 100644
    --- a/Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c
    +++ b/Platform/ARM/Morello/Drivers/PlatformDxe/VirtioDevices.c
    @@ -40,6 +40,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)
    +      }
    +    },
    +    MORELLO_VIRTIO_NET_GUID,
    +  },
    +  {
    +    END_DEVICE_PATH_TYPE,
    +    END_ENTIRE_DEVICE_PATH_SUBTYPE,
    +    {
    +      sizeof (EFI_DEVICE_PATH_PROTOCOL),
    +      0
    +    }
    +  }
    +};
    +
     /**
       Initialize platform Virtio devices.

    @@ -51,8 +74,10 @@ InitVirtioDevices (
     {
       EFI_STATUS Status;
       EFI_HANDLE mVirtIoBlkController;
    +  EFI_HANDLE mVirtIoNetController;

       mVirtIoBlkController = NULL;
    +  mVirtIoNetController = NULL;

       // Install protocol interface for storage device
       if (FeaturePcdGet (PcdVirtioBlkSupported)) {
    @@ -87,4 +112,37 @@ InitVirtioDevices (
           }
         }
       }
    +
    +  // Install protocol interface for network device
    +  if (FeaturePcdGet (PcdVirtioNetSupported)) {
    +
    +    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 Net (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 Block MMIO device "
    +          "(Status == %r)\n", __FUNCTION__, Status));
    +        gBS->UninstallProtocolInterface (
    +               mVirtIoNetController,
    +               &gEfiDevicePathProtocolGuid,
    +               &mVirtioNetDevicePath
    +               );
    +      } else {
    +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Net\n", __FUNCTION__));
    +      }
    +    }
    +  }
     }
    -- 
    2.17.1




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#73943): https://edk2.groups.io/g/devel/message/73943
Mute This Topic: https://groups.io/mt/81778215/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