audk/OvmfPkg/VirtioNetDxe/Events.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
2.1 KiB
C
Raw Normal View History

/** @file
Implements
- the SNM.WaitForPacket EVT_NOTIFY_WAIT event,
- the EVT_SIGNAL_EXIT_BOOT_SERVICES event
for the virtio-net driver.
Copyright (C) 2013, Red Hat, Inc.
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/BaseLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "VirtioNet.h"
/**
Invoke a notification event
@param Event Event whose notification function is being
invoked.
@param Context The pointer to the notification function's
context, which is implementation-dependent.
**/
VOID
EFIAPI
VirtioNetIsPacketAvailable (
IN EFI_EVENT Event,
IN VOID *Context
)
{
//
// This callback has been enqueued by an external application and is
// running at TPL_CALLBACK already.
//
// The WaitForPacket logic is similar to that of WaitForKey. The former has
// almost no documentation in either the UEFI-2.3.1+errC spec or the
// DWG-2.3.1, but WaitForKey does have some.
//
VNET_DEV *Dev;
UINT16 RxCurUsed;
Dev = Context;
if (Dev->Snm.State != EfiSimpleNetworkInitialized) {
return;
}
//
// virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
//
MemoryFence ();
RxCurUsed = *Dev->RxRing.Used.Idx;
MemoryFence ();
if (Dev->RxLastUsed != RxCurUsed) {
gBS->SignalEvent (Dev->Snp.WaitForPacket);
}
}
VOID
EFIAPI
VirtioNetExitBoot (
IN EFI_EVENT Event,
IN VOID *Context
)
{
//
// This callback has been enqueued by ExitBootServices() and is running at
// TPL_CALLBACK already.
//
// Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
// Services Event".
//
VNET_DEV *Dev;
DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __func__, Context));
Dev = Context;
if (Dev->Snm.State == EfiSimpleNetworkInitialized) {
OvmfPkg: Make the VirtIo devices use the new VIRTIO_DEVICE_PROTOCOL This change replaces the accesses to the PCI bus from the Block, Scsi and Net drivers by the use of the new VIRTIO_DEVICE_PROTOCOL protocol that abstracts the transport layer. It means these drivers can be used on PCI and MMIO transport layer. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> v5: - VirtioFlush(): update comment block in VirtioLib.[hc]; error code is propagated from VirtIo->SetQueueNotify(). - VirtioBlkInit(): jump to Failed label if SetPageSize() fails - VirtioBlkInit(): fixup comment, and add error handling, near SetQueueNum() call - VirtioBlkDriverBindingStart(): remove redundant (always false) check for a subsystem device ID different from VIRTIO_SUBSYSTEM_BLOCK_DEVICE; VirtioBlkDriverBindingSupported() handles it already - VirtioNetGetFeatures(): update stale comment block - VirtioNetGetFeatures(): retrieve MAC address byte for byte (open-coded loop) - VirtioNetDriverBindingStart(): remove redundant (always false) check for a subsystem device ID different from VIRTIO_SUBSYSTEM_NETWORK_CARD; VirtioNetDriverBindingSupported() handles it already - VirtioNetInitRing(): call SetQueueNum() and SetQueueAlign() for proper MMIO operation - VirtioNetInitialize(): fix destination error label for when SetPageSize() fails - VirtioScsi.c: fix comment block of VIRTIO_CFG_WRITE()/VIRTIO_CFG_READ() - VirtioScsiInit(): fix destination error label for when SetPageSize() fails - VirtioScsiInit(): call SetQueueNum() and SetQueueAlign() for proper MMIO operation Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14966 6f19259b-4bc3-4df7-8a09-765794883524
2013-12-11 17:58:22 +01:00
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
}
}