mirror of https://github.com/acidanthera/audk.git
OvmfPkg/VirtioLib: take VirtIo instance in VirtioRingInit/VirtioRingUninit
Passing the VirtIo protocol instance will allow the vring to use VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () to allocate vring buffer. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
0a78d754ed
commit
fc2c1543e5
|
@ -35,6 +35,8 @@
|
|||
- 1.1 Virtqueues,
|
||||
- 2.3 Virtqueue Configuration.
|
||||
|
||||
@param[in] VirtIo The virtio device which will use the ring.
|
||||
|
||||
@param[in] The number of descriptors to allocate for the
|
||||
virtio ring, as requested by the host.
|
||||
|
||||
|
@ -52,8 +54,9 @@
|
|||
EFI_STATUS
|
||||
EFIAPI
|
||||
VirtioRingInit (
|
||||
IN UINT16 QueueSize,
|
||||
OUT VRING *Ring
|
||||
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||
IN UINT16 QueueSize,
|
||||
OUT VRING *Ring
|
||||
);
|
||||
|
||||
|
||||
|
@ -65,13 +68,16 @@ VirtioRingInit (
|
|||
invoking this function: the VSTAT_DRIVER_OK bit must be clear in
|
||||
VhdrDeviceStatus.
|
||||
|
||||
@param[out] Ring The virtio ring to clean up.
|
||||
@param[in] VirtIo The virtio device which was using the ring.
|
||||
|
||||
@param[out] Ring The virtio ring to clean up.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
VirtioRingUninit (
|
||||
IN OUT VRING *Ring
|
||||
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||
IN OUT VRING *Ring
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
- 1.1 Virtqueues,
|
||||
- 2.3 Virtqueue Configuration.
|
||||
|
||||
@param[in] VirtIo The virtio device which will use the ring.
|
||||
|
||||
@param[in] The number of descriptors to allocate for the
|
||||
virtio ring, as requested by the host.
|
||||
|
||||
|
@ -54,8 +56,9 @@
|
|||
EFI_STATUS
|
||||
EFIAPI
|
||||
VirtioRingInit (
|
||||
IN UINT16 QueueSize,
|
||||
OUT VRING *Ring
|
||||
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||
IN UINT16 QueueSize,
|
||||
OUT VRING *Ring
|
||||
)
|
||||
{
|
||||
UINTN RingSize;
|
||||
|
@ -128,13 +131,16 @@ VirtioRingInit (
|
|||
invoking this function: the VSTAT_DRIVER_OK bit must be clear in
|
||||
VhdrDeviceStatus.
|
||||
|
||||
@param[out] Ring The virtio ring to clean up.
|
||||
@param[in] VirtIo The virtio device which was using the ring.
|
||||
|
||||
@param[out] Ring The virtio ring to clean up.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
VirtioRingUninit (
|
||||
IN OUT VRING *Ring
|
||||
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||
IN OUT VRING *Ring
|
||||
)
|
||||
{
|
||||
FreePages (Ring->Base, Ring->NumPages);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
Copyright (C) 2012, Red Hat, Inc.
|
||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
|
@ -722,7 +723,7 @@ VirtioBlkInit (
|
|||
goto Failed;
|
||||
}
|
||||
|
||||
Status = VirtioRingInit (QueueSize, &Dev->Ring);
|
||||
Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Failed;
|
||||
}
|
||||
|
@ -811,7 +812,7 @@ VirtioBlkInit (
|
|||
return EFI_SUCCESS;
|
||||
|
||||
ReleaseQueue:
|
||||
VirtioRingUninit (&Dev->Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||
|
||||
Failed:
|
||||
//
|
||||
|
@ -848,7 +849,7 @@ VirtioBlkUninit (
|
|||
//
|
||||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||
|
||||
VirtioRingUninit (&Dev->Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||
|
||||
SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00);
|
||||
SetMem (&Dev->BlockIoMedia, sizeof Dev->BlockIoMedia, 0x00);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
VirtIo GPU initialization, and commands (primitives) for the GPU device.
|
||||
|
||||
Copyright (C) 2016, Red Hat, Inc.
|
||||
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
|
@ -127,7 +128,7 @@ VirtioGpuInit (
|
|||
//
|
||||
// [...] population of virtqueues [...]
|
||||
//
|
||||
Status = VirtioRingInit (QueueSize, &VgpuDev->Ring);
|
||||
Status = VirtioRingInit (VgpuDev->VirtIo, QueueSize, &VgpuDev->Ring);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Failed;
|
||||
}
|
||||
|
@ -148,7 +149,7 @@ VirtioGpuInit (
|
|||
return EFI_SUCCESS;
|
||||
|
||||
ReleaseQueue:
|
||||
VirtioRingUninit (&VgpuDev->Ring);
|
||||
VirtioRingUninit (VgpuDev->VirtIo, &VgpuDev->Ring);
|
||||
|
||||
Failed:
|
||||
//
|
||||
|
@ -183,7 +184,7 @@ VirtioGpuUninit (
|
|||
// configuration.
|
||||
//
|
||||
VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, 0);
|
||||
VirtioRingUninit (&VgpuDev->Ring);
|
||||
VirtioRingUninit (VgpuDev->VirtIo, &VgpuDev->Ring);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
Copyright (C) 2013, Red Hat, Inc.
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
|
@ -73,7 +74,7 @@ VirtioNetInitRing (
|
|||
if (QueueSize < 2) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
Status = VirtioRingInit (QueueSize, Ring);
|
||||
Status = VirtioRingInit (Dev->VirtIo, QueueSize, Ring);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ VirtioNetInitRing (
|
|||
return EFI_SUCCESS;
|
||||
|
||||
ReleaseQueue:
|
||||
VirtioRingUninit (Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, Ring);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -509,10 +510,10 @@ AbortDevice:
|
|||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||
|
||||
ReleaseTxRing:
|
||||
VirtioRingUninit (&Dev->TxRing);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->TxRing);
|
||||
|
||||
ReleaseRxRing:
|
||||
VirtioRingUninit (&Dev->RxRing);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->RxRing);
|
||||
|
||||
DeviceFailed:
|
||||
//
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
Copyright (C) 2013, Red Hat, Inc.
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
|
@ -66,8 +67,8 @@ VirtioNetShutdown (
|
|||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||
VirtioNetShutdownRx (Dev);
|
||||
VirtioNetShutdownTx (Dev);
|
||||
VirtioRingUninit (&Dev->TxRing);
|
||||
VirtioRingUninit (&Dev->RxRing);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->TxRing);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->RxRing);
|
||||
|
||||
Dev->Snm.State = EfiSimpleNetworkStarted;
|
||||
Status = EFI_SUCCESS;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
Copyright (C) 2012, Red Hat, Inc.
|
||||
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||
|
||||
This driver:
|
||||
|
||||
|
@ -275,7 +276,7 @@ VirtioRngInit (
|
|||
goto Failed;
|
||||
}
|
||||
|
||||
Status = VirtioRingInit (QueueSize, &Dev->Ring);
|
||||
Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Failed;
|
||||
}
|
||||
|
@ -331,7 +332,7 @@ VirtioRngInit (
|
|||
return EFI_SUCCESS;
|
||||
|
||||
ReleaseQueue:
|
||||
VirtioRingUninit (&Dev->Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||
|
||||
Failed:
|
||||
//
|
||||
|
@ -358,7 +359,7 @@ VirtioRngUninit (
|
|||
// the old comms area.
|
||||
//
|
||||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||
VirtioRingUninit (&Dev->Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
Copyright (C) 2012, Red Hat, Inc.
|
||||
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
|
@ -832,7 +833,7 @@ VirtioScsiInit (
|
|||
goto Failed;
|
||||
}
|
||||
|
||||
Status = VirtioRingInit (QueueSize, &Dev->Ring);
|
||||
Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Failed;
|
||||
}
|
||||
|
@ -926,7 +927,7 @@ VirtioScsiInit (
|
|||
return EFI_SUCCESS;
|
||||
|
||||
ReleaseQueue:
|
||||
VirtioRingUninit (&Dev->Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||
|
||||
Failed:
|
||||
//
|
||||
|
@ -964,7 +965,7 @@ VirtioScsiUninit (
|
|||
Dev->MaxLun = 0;
|
||||
Dev->MaxSectors = 0;
|
||||
|
||||
VirtioRingUninit (&Dev->Ring);
|
||||
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||
|
||||
SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00);
|
||||
SetMem (&Dev->PassThruMode, sizeof Dev->PassThruMode, 0x00);
|
||||
|
|
Loading…
Reference in New Issue