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,
|
- 1.1 Virtqueues,
|
||||||
- 2.3 Virtqueue Configuration.
|
- 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
|
@param[in] The number of descriptors to allocate for the
|
||||||
virtio ring, as requested by the host.
|
virtio ring, as requested by the host.
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
VirtioRingInit (
|
VirtioRingInit (
|
||||||
|
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||||
IN UINT16 QueueSize,
|
IN UINT16 QueueSize,
|
||||||
OUT VRING *Ring
|
OUT VRING *Ring
|
||||||
);
|
);
|
||||||
|
@ -65,12 +68,15 @@ VirtioRingInit (
|
||||||
invoking this function: the VSTAT_DRIVER_OK bit must be clear in
|
invoking this function: the VSTAT_DRIVER_OK bit must be clear in
|
||||||
VhdrDeviceStatus.
|
VhdrDeviceStatus.
|
||||||
|
|
||||||
|
@param[in] VirtIo The virtio device which was using the ring.
|
||||||
|
|
||||||
@param[out] Ring The virtio ring to clean up.
|
@param[out] Ring The virtio ring to clean up.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
VirtioRingUninit (
|
VirtioRingUninit (
|
||||||
|
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||||
IN OUT VRING *Ring
|
IN OUT VRING *Ring
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
- 1.1 Virtqueues,
|
- 1.1 Virtqueues,
|
||||||
- 2.3 Virtqueue Configuration.
|
- 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
|
@param[in] The number of descriptors to allocate for the
|
||||||
virtio ring, as requested by the host.
|
virtio ring, as requested by the host.
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
VirtioRingInit (
|
VirtioRingInit (
|
||||||
|
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||||
IN UINT16 QueueSize,
|
IN UINT16 QueueSize,
|
||||||
OUT VRING *Ring
|
OUT VRING *Ring
|
||||||
)
|
)
|
||||||
|
@ -128,12 +131,15 @@ VirtioRingInit (
|
||||||
invoking this function: the VSTAT_DRIVER_OK bit must be clear in
|
invoking this function: the VSTAT_DRIVER_OK bit must be clear in
|
||||||
VhdrDeviceStatus.
|
VhdrDeviceStatus.
|
||||||
|
|
||||||
|
@param[in] VirtIo The virtio device which was using the ring.
|
||||||
|
|
||||||
@param[out] Ring The virtio ring to clean up.
|
@param[out] Ring The virtio ring to clean up.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
VirtioRingUninit (
|
VirtioRingUninit (
|
||||||
|
IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
|
||||||
IN OUT VRING *Ring
|
IN OUT VRING *Ring
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
Copyright (C) 2012, Red Hat, Inc.
|
Copyright (C) 2012, Red Hat, Inc.
|
||||||
Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>
|
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
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
@ -722,7 +723,7 @@ VirtioBlkInit (
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = VirtioRingInit (QueueSize, &Dev->Ring);
|
Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
@ -811,7 +812,7 @@ VirtioBlkInit (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
ReleaseQueue:
|
ReleaseQueue:
|
||||||
VirtioRingUninit (&Dev->Ring);
|
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||||
|
|
||||||
Failed:
|
Failed:
|
||||||
//
|
//
|
||||||
|
@ -848,7 +849,7 @@ VirtioBlkUninit (
|
||||||
//
|
//
|
||||||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||||
|
|
||||||
VirtioRingUninit (&Dev->Ring);
|
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||||
|
|
||||||
SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00);
|
SetMem (&Dev->BlockIo, sizeof Dev->BlockIo, 0x00);
|
||||||
SetMem (&Dev->BlockIoMedia, sizeof Dev->BlockIoMedia, 0x00);
|
SetMem (&Dev->BlockIoMedia, sizeof Dev->BlockIoMedia, 0x00);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
VirtIo GPU initialization, and commands (primitives) for the GPU device.
|
VirtIo GPU initialization, and commands (primitives) for the GPU device.
|
||||||
|
|
||||||
Copyright (C) 2016, Red Hat, Inc.
|
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
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
@ -127,7 +128,7 @@ VirtioGpuInit (
|
||||||
//
|
//
|
||||||
// [...] population of virtqueues [...]
|
// [...] population of virtqueues [...]
|
||||||
//
|
//
|
||||||
Status = VirtioRingInit (QueueSize, &VgpuDev->Ring);
|
Status = VirtioRingInit (VgpuDev->VirtIo, QueueSize, &VgpuDev->Ring);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,7 @@ VirtioGpuInit (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
ReleaseQueue:
|
ReleaseQueue:
|
||||||
VirtioRingUninit (&VgpuDev->Ring);
|
VirtioRingUninit (VgpuDev->VirtIo, &VgpuDev->Ring);
|
||||||
|
|
||||||
Failed:
|
Failed:
|
||||||
//
|
//
|
||||||
|
@ -183,7 +184,7 @@ VirtioGpuUninit (
|
||||||
// configuration.
|
// configuration.
|
||||||
//
|
//
|
||||||
VgpuDev->VirtIo->SetDeviceStatus (VgpuDev->VirtIo, 0);
|
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) 2013, Red Hat, Inc.
|
||||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
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
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
@ -73,7 +74,7 @@ VirtioNetInitRing (
|
||||||
if (QueueSize < 2) {
|
if (QueueSize < 2) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
Status = VirtioRingInit (QueueSize, Ring);
|
Status = VirtioRingInit (Dev->VirtIo, QueueSize, Ring);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ VirtioNetInitRing (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
ReleaseQueue:
|
ReleaseQueue:
|
||||||
VirtioRingUninit (Ring);
|
VirtioRingUninit (Dev->VirtIo, Ring);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -509,10 +510,10 @@ AbortDevice:
|
||||||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||||
|
|
||||||
ReleaseTxRing:
|
ReleaseTxRing:
|
||||||
VirtioRingUninit (&Dev->TxRing);
|
VirtioRingUninit (Dev->VirtIo, &Dev->TxRing);
|
||||||
|
|
||||||
ReleaseRxRing:
|
ReleaseRxRing:
|
||||||
VirtioRingUninit (&Dev->RxRing);
|
VirtioRingUninit (Dev->VirtIo, &Dev->RxRing);
|
||||||
|
|
||||||
DeviceFailed:
|
DeviceFailed:
|
||||||
//
|
//
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
Copyright (C) 2013, Red Hat, Inc.
|
Copyright (C) 2013, Red Hat, Inc.
|
||||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
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
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
@ -66,8 +67,8 @@ VirtioNetShutdown (
|
||||||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
||||||
VirtioNetShutdownRx (Dev);
|
VirtioNetShutdownRx (Dev);
|
||||||
VirtioNetShutdownTx (Dev);
|
VirtioNetShutdownTx (Dev);
|
||||||
VirtioRingUninit (&Dev->TxRing);
|
VirtioRingUninit (Dev->VirtIo, &Dev->TxRing);
|
||||||
VirtioRingUninit (&Dev->RxRing);
|
VirtioRingUninit (Dev->VirtIo, &Dev->RxRing);
|
||||||
|
|
||||||
Dev->Snm.State = EfiSimpleNetworkStarted;
|
Dev->Snm.State = EfiSimpleNetworkStarted;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
Copyright (C) 2012, Red Hat, Inc.
|
Copyright (C) 2012, Red Hat, Inc.
|
||||||
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
|
||||||
|
|
||||||
This driver:
|
This driver:
|
||||||
|
|
||||||
|
@ -275,7 +276,7 @@ VirtioRngInit (
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = VirtioRingInit (QueueSize, &Dev->Ring);
|
Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +332,7 @@ VirtioRngInit (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
ReleaseQueue:
|
ReleaseQueue:
|
||||||
VirtioRingUninit (&Dev->Ring);
|
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||||
|
|
||||||
Failed:
|
Failed:
|
||||||
//
|
//
|
||||||
|
@ -358,7 +359,7 @@ VirtioRngUninit (
|
||||||
// the old comms area.
|
// the old comms area.
|
||||||
//
|
//
|
||||||
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
|
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, Red Hat, Inc.
|
||||||
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
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
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
@ -832,7 +833,7 @@ VirtioScsiInit (
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = VirtioRingInit (QueueSize, &Dev->Ring);
|
Status = VirtioRingInit (Dev->VirtIo, QueueSize, &Dev->Ring);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto Failed;
|
goto Failed;
|
||||||
}
|
}
|
||||||
|
@ -926,7 +927,7 @@ VirtioScsiInit (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
ReleaseQueue:
|
ReleaseQueue:
|
||||||
VirtioRingUninit (&Dev->Ring);
|
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||||
|
|
||||||
Failed:
|
Failed:
|
||||||
//
|
//
|
||||||
|
@ -964,7 +965,7 @@ VirtioScsiUninit (
|
||||||
Dev->MaxLun = 0;
|
Dev->MaxLun = 0;
|
||||||
Dev->MaxSectors = 0;
|
Dev->MaxSectors = 0;
|
||||||
|
|
||||||
VirtioRingUninit (&Dev->Ring);
|
VirtioRingUninit (Dev->VirtIo, &Dev->Ring);
|
||||||
|
|
||||||
SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00);
|
SetMem (&Dev->PassThru, sizeof Dev->PassThru, 0x00);
|
||||||
SetMem (&Dev->PassThruMode, sizeof Dev->PassThruMode, 0x00);
|
SetMem (&Dev->PassThruMode, sizeof Dev->PassThruMode, 0x00);
|
||||||
|
|
Loading…
Reference in New Issue