diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:09 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | ac0a286f4d747a4c6c603a7b225917293cbe1e9f (patch) | |
tree | 32654f2b35755afc961e2c97296b2dec5762da75 /OvmfPkg/VirtioNetDxe | |
parent | d1050b9dff1cace252aff86630bfdb59dff5f507 (diff) | |
download | edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.gz edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.tar.bz2 edk2-ac0a286f4d747a4c6c603a7b225917293cbe1e9f.zip |
OvmfPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737
Apply uncrustify changes to .c/.h files in the OvmfPkg package
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'OvmfPkg/VirtioNetDxe')
-rw-r--r-- | OvmfPkg/VirtioNetDxe/ComponentName.c | 39 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/DriverBinding.c | 294 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/EntryPoint.c | 5 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/Events.c | 15 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpGetStatus.c | 56 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpInitialize.c | 115 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c | 46 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpReceive.c | 79 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c | 43 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 101 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpShutdown.c | 29 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpStart.c | 16 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpStop.c | 16 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpTransmit.c | 64 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpUnsupported.c | 35 | ||||
-rw-r--r-- | OvmfPkg/VirtioNetDxe/VirtioNet.h | 188 |
16 files changed, 596 insertions, 545 deletions
diff --git a/OvmfPkg/VirtioNetDxe/ComponentName.c b/OvmfPkg/VirtioNetDxe/ComponentName.c index 483d4f7038..e340ca2f8f 100644 --- a/OvmfPkg/VirtioNetDxe/ComponentName.c +++ b/OvmfPkg/VirtioNetDxe/ComponentName.c @@ -14,13 +14,13 @@ #include "VirtioNet.h"
STATIC
-EFI_UNICODE_STRING_TABLE mVirtioNetDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE mVirtioNetDriverNameTable[] = {
{ "eng;en", L"Virtio Network Driver" },
{ NULL, NULL }
};
STATIC
-EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = {
+EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = {
{ "eng;en", L"Virtio Network Device" },
{ NULL, NULL }
};
@@ -48,14 +48,13 @@ EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = { the language specified by Language.
**/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
return (Language == NULL || DriverName == NULL) ?
@@ -65,11 +64,10 @@ VirtioNetGetDriverName ( This->SupportedLanguages,
mVirtioNetDriverNameTable,
DriverName,
- (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language
+ (BOOLEAN)(This == &gVirtioNetComponentName) // Iso639Language
);
}
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an EFI Driver.
@@ -114,21 +112,20 @@ VirtioNetGetDriverName ( the language specified by Language.
**/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- if (ControllerHandle == NULL || Language == NULL || ControllerName == NULL) {
+ if ((ControllerHandle == NULL) || (Language == NULL) || (ControllerName == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -154,18 +151,18 @@ VirtioNetGetControllerName ( This->SupportedLanguages,
mVirtioNetControllerNameTable,
ControllerName,
- (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language
+ (BOOLEAN)(This == &gVirtioNetComponentName) // Iso639Language
);
}
-EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName = {
+EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName = {
&VirtioNetGetDriverName,
&VirtioNetGetControllerName,
"eng" // SupportedLanguages, ISO 639-2 language codes
};
-EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioNetGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioNetGetControllerName,
+EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&VirtioNetGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&VirtioNetGetControllerName,
"en" // SupportedLanguages, RFC 4646 language codes
};
diff --git a/OvmfPkg/VirtioNetDxe/DriverBinding.c b/OvmfPkg/VirtioNetDxe/DriverBinding.c index 3c400a6046..ac9ac2d7fb 100644 --- a/OvmfPkg/VirtioNetDxe/DriverBinding.c +++ b/OvmfPkg/VirtioNetDxe/DriverBinding.c @@ -16,7 +16,7 @@ #include "VirtioNet.h"
-#define RECEIVE_FILTERS_NO_MCAST ((UINT32) ( \
+#define RECEIVE_FILTERS_NO_MCAST ((UINT32) ( \
EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | \
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | \
EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS \
@@ -50,36 +50,36 @@ STATIC EFI_STATUS
EFIAPI
VirtioNetGetFeatures (
- IN OUT VNET_DEV *Dev,
- OUT EFI_MAC_ADDRESS *MacAddress,
- OUT BOOLEAN *MediaPresentSupported,
- OUT BOOLEAN *MediaPresent
+ IN OUT VNET_DEV *Dev,
+ OUT EFI_MAC_ADDRESS *MacAddress,
+ OUT BOOLEAN *MediaPresentSupported,
+ OUT BOOLEAN *MediaPresent
)
{
- EFI_STATUS Status;
- UINT8 NextDevStat;
- UINT64 Features;
- UINTN MacIdx;
- UINT16 LinkStatus;
+ EFI_STATUS Status;
+ UINT8 NextDevStat;
+ UINT64 Features;
+ UINTN MacIdx;
+ UINT16 LinkStatus;
//
// Interrogate the device for features (virtio-0.9.5, 2.2.1 Device
// Initialization Sequence), but don't complete setting it up.
//
NextDevStat = 0; // step 1 -- reset device
- Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
return Status;
}
NextDevStat |= VSTAT_ACK; // step 2 -- acknowledge device presence
- Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
- Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
@@ -99,8 +99,10 @@ VirtioNetGetFeatures ( Status = EFI_UNSUPPORTED;
goto YieldDevice;
}
+
for (MacIdx = 0; MacIdx < SIZE_OF_VNET (Mac); ++MacIdx) {
- Status = Dev->VirtIo->ReadDevice (Dev->VirtIo,
+ Status = Dev->VirtIo->ReadDevice (
+ Dev->VirtIo,
OFFSET_OF_VNET (Mac) + MacIdx, // Offset
1, // FieldSize
1, // BufferSize
@@ -116,24 +118,25 @@ VirtioNetGetFeatures ( //
if ((Features & VIRTIO_NET_F_STATUS) == 0) {
*MediaPresentSupported = FALSE;
- }
- else {
+ } else {
*MediaPresentSupported = TRUE;
- Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus);
+ Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus);
if (EFI_ERROR (Status)) {
goto YieldDevice;
}
- *MediaPresent = (BOOLEAN) ((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0);
+
+ *MediaPresent = (BOOLEAN)((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0);
}
YieldDevice:
- Dev->VirtIo->SetDeviceStatus (Dev->VirtIo,
- EFI_ERROR (Status) ? VSTAT_FAILED : 0);
+ Dev->VirtIo->SetDeviceStatus (
+ Dev->VirtIo,
+ EFI_ERROR (Status) ? VSTAT_FAILED : 0
+ );
return Status;
}
-
/**
Set up the Simple Network Protocol fields, the Simple Network Mode fields,
and the Exit Boot Services Event of the virtio-net driver instance.
@@ -151,10 +154,10 @@ STATIC EFI_STATUS
EFIAPI
VirtioNetSnpPopulate (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// We set up a function here that is asynchronously callable by an
@@ -177,8 +180,13 @@ VirtioNetSnpPopulate ( // I/O)". Because none of our functions block, we'd satisfy an even stronger
// requirement.
//
- Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_CALLBACK,
- &VirtioNetIsPacketAvailable, Dev, &Dev->Snp.WaitForPacket);
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_WAIT,
+ TPL_CALLBACK,
+ &VirtioNetIsPacketAvailable,
+ Dev,
+ &Dev->Snp.WaitForPacket
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -199,31 +207,39 @@ VirtioNetSnpPopulate ( Dev->Snp.Receive = &VirtioNetReceive;
Dev->Snp.Mode = &Dev->Snm;
- Dev->Snm.State = EfiSimpleNetworkStopped;
- Dev->Snm.HwAddressSize = SIZE_OF_VNET (Mac);
- Dev->Snm.MediaHeaderSize = SIZE_OF_VNET (Mac) + // dst MAC
- SIZE_OF_VNET (Mac) + // src MAC
- 2; // Ethertype
- Dev->Snm.MaxPacketSize = 1500;
- Dev->Snm.NvRamSize = 0;
- Dev->Snm.NvRamAccessSize = 0;
- Dev->Snm.ReceiveFilterMask = RECEIVE_FILTERS_NO_MCAST;
- Dev->Snm.ReceiveFilterSetting = RECEIVE_FILTERS_NO_MCAST;
- Dev->Snm.MaxMCastFilterCount = 0;
- Dev->Snm.MCastFilterCount = 0;
- Dev->Snm.IfType = 1; // ethernet
- Dev->Snm.MacAddressChangeable = FALSE;
- Dev->Snm.MultipleTxSupported = TRUE;
+ Dev->Snm.State = EfiSimpleNetworkStopped;
+ Dev->Snm.HwAddressSize = SIZE_OF_VNET (Mac);
+ Dev->Snm.MediaHeaderSize = SIZE_OF_VNET (Mac) + // dst MAC
+ SIZE_OF_VNET (Mac) + // src MAC
+ 2; // Ethertype
+ Dev->Snm.MaxPacketSize = 1500;
+ Dev->Snm.NvRamSize = 0;
+ Dev->Snm.NvRamAccessSize = 0;
+ Dev->Snm.ReceiveFilterMask = RECEIVE_FILTERS_NO_MCAST;
+ Dev->Snm.ReceiveFilterSetting = RECEIVE_FILTERS_NO_MCAST;
+ Dev->Snm.MaxMCastFilterCount = 0;
+ Dev->Snm.MCastFilterCount = 0;
+ Dev->Snm.IfType = 1; // ethernet
+ Dev->Snm.MacAddressChangeable = FALSE;
+ Dev->Snm.MultipleTxSupported = TRUE;
ASSERT (SIZE_OF_VNET (Mac) <= sizeof (EFI_MAC_ADDRESS));
- Status = VirtioNetGetFeatures (Dev, &Dev->Snm.CurrentAddress,
- &Dev->Snm.MediaPresentSupported, &Dev->Snm.MediaPresent);
+ Status = VirtioNetGetFeatures (
+ Dev,
+ &Dev->Snm.CurrentAddress,
+ &Dev->Snm.MediaPresentSupported,
+ &Dev->Snm.MediaPresent
+ );
if (EFI_ERROR (Status)) {
goto CloseWaitForPacket;
}
- CopyMem (&Dev->Snm.PermanentAddress, &Dev->Snm.CurrentAddress,
- SIZE_OF_VNET (Mac));
+
+ CopyMem (
+ &Dev->Snm.PermanentAddress,
+ &Dev->Snm.CurrentAddress,
+ SIZE_OF_VNET (Mac)
+ );
SetMem (&Dev->Snm.BroadcastAddress, SIZE_OF_VNET (Mac), 0xFF);
//
@@ -235,8 +251,13 @@ VirtioNetSnpPopulate ( // could be entered immediately. VirtioNetExitBoot() checks Dev->Snm.State,
// so we're safe.
//
- Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
- &VirtioNetExitBoot, Dev, &Dev->ExitBoot);
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_CALLBACK,
+ &VirtioNetExitBoot,
+ Dev,
+ &Dev->ExitBoot
+ );
if (EFI_ERROR (Status)) {
goto CloseWaitForPacket;
}
@@ -248,7 +269,6 @@ CloseWaitForPacket: return Status;
}
-
/**
Release any resources allocated by VirtioNetSnpPopulate().
@@ -263,7 +283,7 @@ STATIC VOID
EFIAPI
VirtioNetSnpEvacuate (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
)
{
//
@@ -276,7 +296,6 @@ VirtioNetSnpEvacuate ( gBS->CloseEvent (Dev->Snp.WaitForPacket);
}
-
/**
Tests to see if this driver supports a given controller. If a child device is
provided, it further tests to see if this driver supports creating a handle
@@ -330,18 +349,17 @@ VirtioNetSnpEvacuate ( RemainingDevicePath is not supported by the
driver specified by This.
**/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- VIRTIO_DEVICE_PROTOCOL *VirtIo;
+ EFI_STATUS Status;
+ VIRTIO_DEVICE_PROTOCOL *VirtIo;
//
// Attempt to open the device with the VirtIo set of interfaces. On success,
@@ -370,12 +388,15 @@ VirtioNetDriverBindingSupported ( // We needed VirtIo access only transitorily, to see whether we support the
// device or not.
//
- gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, DeviceHandle);
+ gBS->CloseProtocol (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ DeviceHandle
+ );
return Status;
}
-
/**
Starts a device controller or a bus controller.
@@ -422,34 +443,39 @@ VirtioNetDriverBindingSupported ( @retval Others The driver failed to start the device.
**/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- VNET_DEV *Dev;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- MAC_ADDR_DEVICE_PATH MacNode;
- VOID *ChildVirtIo;
+ EFI_STATUS Status;
+ VNET_DEV *Dev;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ MAC_ADDR_DEVICE_PATH MacNode;
+ VOID *ChildVirtIo;
//
// allocate space for the driver instance
//
- Dev = (VNET_DEV *) AllocateZeroPool (sizeof *Dev);
+ Dev = (VNET_DEV *)AllocateZeroPool (sizeof *Dev);
if (Dev == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Dev->Signature = VNET_SIG;
- Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
- (VOID **)&Dev->VirtIo, This->DriverBindingHandle,
- DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ (VOID **)&Dev->VirtIo,
+ This->DriverBindingHandle,
+ DeviceHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
goto FreeVirtioNet;
}
@@ -466,9 +492,14 @@ VirtioNetDriverBindingStart ( //
// get the device path of the virtio-net device -- one-shot open
//
- Status = gBS->OpenProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid,
- (VOID **)&DevicePath, This->DriverBindingHandle,
- DeviceHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath,
+ This->DriverBindingHandle,
+ DeviceHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
goto Evacuate;
}
@@ -479,9 +510,12 @@ VirtioNetDriverBindingStart ( MacNode.Header.Type = MESSAGING_DEVICE_PATH;
MacNode.Header.SubType = MSG_MAC_ADDR_DP;
SetDevicePathNodeLength (&MacNode, sizeof MacNode);
- CopyMem (&MacNode.MacAddress, &Dev->Snm.CurrentAddress,
- sizeof (EFI_MAC_ADDRESS));
- MacNode.IfType = Dev->Snm.IfType;
+ CopyMem (
+ &MacNode.MacAddress,
+ &Dev->Snm.CurrentAddress,
+ sizeof (EFI_MAC_ADDRESS)
+ );
+ MacNode.IfType = Dev->Snm.IfType;
Dev->MacDevicePath = AppendDevicePathNode (DevicePath, &MacNode.Header);
if (Dev->MacDevicePath == NULL) {
@@ -493,10 +527,14 @@ VirtioNetDriverBindingStart ( // create a child handle with the Simple Network Protocol and the new
// device path installed on it
//
- Status = gBS->InstallMultipleProtocolInterfaces (&Dev->MacHandle,
- &gEfiSimpleNetworkProtocolGuid, &Dev->Snp,
- &gEfiDevicePathProtocolGuid, Dev->MacDevicePath,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Dev->MacHandle,
+ &gEfiSimpleNetworkProtocolGuid,
+ &Dev->Snp,
+ &gEfiDevicePathProtocolGuid,
+ Dev->MacDevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto FreeMacDevicePath;
}
@@ -505,9 +543,14 @@ VirtioNetDriverBindingStart ( // make a note that we keep this device open with VirtIo for the sake of this
// child
//
- Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
- &ChildVirtIo, This->DriverBindingHandle,
- Dev->MacHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ &ChildVirtIo,
+ This->DriverBindingHandle,
+ Dev->MacHandle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
if (EFI_ERROR (Status)) {
goto UninstallMultiple;
}
@@ -515,10 +558,14 @@ VirtioNetDriverBindingStart ( return EFI_SUCCESS;
UninstallMultiple:
- gBS->UninstallMultipleProtocolInterfaces (Dev->MacHandle,
- &gEfiDevicePathProtocolGuid, Dev->MacDevicePath,
- &gEfiSimpleNetworkProtocolGuid, &Dev->Snp,
- NULL);
+ gBS->UninstallMultipleProtocolInterfaces (
+ Dev->MacHandle,
+ &gEfiDevicePathProtocolGuid,
+ Dev->MacDevicePath,
+ &gEfiSimpleNetworkProtocolGuid,
+ &Dev->Snp,
+ NULL
+ );
FreeMacDevicePath:
FreePool (Dev->MacDevicePath);
@@ -527,8 +574,12 @@ Evacuate: VirtioNetSnpEvacuate (Dev);
CloseVirtIo:
- gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, DeviceHandle);
+ gBS->CloseProtocol (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ DeviceHandle
+ );
FreeVirtioNet:
FreePool (Dev);
@@ -536,7 +587,6 @@ FreeVirtioNet: return Status;
}
-
/**
Stops a device controller or a bus controller.
@@ -574,10 +624,10 @@ STATIC EFI_STATUS
EFIAPI
VirtioNetDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE DeviceHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE DeviceHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
if (NumberOfChildren > 0) {
@@ -585,17 +635,21 @@ VirtioNetDriverBindingStop ( // free all resources for whose access we need the child handle, because
// the child handle is going away
//
- EFI_STATUS Status;
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
ASSERT (NumberOfChildren == 1);
- Status = gBS->OpenProtocol (ChildHandleBuffer[0],
- &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp,
- This->DriverBindingHandle, DeviceHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ChildHandleBuffer[0],
+ &gEfiSimpleNetworkProtocolGuid,
+ (VOID **)&Snp,
+ This->DriverBindingHandle,
+ DeviceHandle,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
ASSERT_EFI_ERROR (Status);
Dev = VIRTIO_NET_FROM_SNP (Snp);
@@ -610,14 +664,21 @@ VirtioNetDriverBindingStop ( // device in use, cannot stop driver instance
//
Status = EFI_DEVICE_ERROR;
- }
- else {
- gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, Dev->MacHandle);
- gBS->UninstallMultipleProtocolInterfaces (Dev->MacHandle,
- &gEfiDevicePathProtocolGuid, Dev->MacDevicePath,
- &gEfiSimpleNetworkProtocolGuid, &Dev->Snp,
- NULL);
+ } else {
+ gBS->CloseProtocol (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ Dev->MacHandle
+ );
+ gBS->UninstallMultipleProtocolInterfaces (
+ Dev->MacHandle,
+ &gEfiDevicePathProtocolGuid,
+ Dev->MacDevicePath,
+ &gEfiSimpleNetworkProtocolGuid,
+ &Dev->Snp,
+ NULL
+ );
FreePool (Dev->MacDevicePath);
VirtioNetSnpEvacuate (Dev);
FreePool (Dev);
@@ -630,14 +691,17 @@ VirtioNetDriverBindingStop ( //
// release remaining resources, tied directly to the parent handle
//
- gBS->CloseProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
- This->DriverBindingHandle, DeviceHandle);
+ gBS->CloseProtocol (
+ DeviceHandle,
+ &gVirtioDeviceProtocolGuid,
+ This->DriverBindingHandle,
+ DeviceHandle
+ );
return EFI_SUCCESS;
}
-
-EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding = {
&VirtioNetDriverBindingSupported,
&VirtioNetDriverBindingStart,
&VirtioNetDriverBindingStop,
diff --git a/OvmfPkg/VirtioNetDxe/EntryPoint.c b/OvmfPkg/VirtioNetDxe/EntryPoint.c index 95e8bda6de..c3f41dab57 100644 --- a/OvmfPkg/VirtioNetDxe/EntryPoint.c +++ b/OvmfPkg/VirtioNetDxe/EntryPoint.c @@ -25,12 +25,11 @@ @retval EFI_SUCCESS The operation completed successfully.
@retval Others An unexpected error occurred.
**/
-
EFI_STATUS
EFIAPI
VirtioNetEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
diff --git a/OvmfPkg/VirtioNetDxe/Events.c b/OvmfPkg/VirtioNetDxe/Events.c index 83e96e5e5d..4c93607a38 100644 --- a/OvmfPkg/VirtioNetDxe/Events.c +++ b/OvmfPkg/VirtioNetDxe/Events.c @@ -26,12 +26,11 @@ context, which is implementation-dependent.
**/
-
VOID
EFIAPI
VirtioNetIsPacketAvailable (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -42,8 +41,8 @@ VirtioNetIsPacketAvailable ( // 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;
+ VNET_DEV *Dev;
+ UINT16 RxCurUsed;
Dev = Context;
if (Dev->Snm.State != EfiSimpleNetworkInitialized) {
@@ -65,8 +64,8 @@ VirtioNetIsPacketAvailable ( VOID
EFIAPI
VirtioNetExitBoot (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -76,7 +75,7 @@ VirtioNetExitBoot ( // Shut down pending transfers according to DWG-2.3.1, "25.5.1 Exit Boot
// Services Event".
//
- VNET_DEV *Dev;
+ VNET_DEV *Dev;
DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));
Dev = Context;
diff --git a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c index 333a522d50..0e13bdc78c 100644 --- a/OvmfPkg/VirtioNetDxe/SnpGetStatus.c +++ b/OvmfPkg/VirtioNetDxe/SnpGetStatus.c @@ -46,51 +46,51 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetGetStatus (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- OUT UINT32 *InterruptStatus OPTIONAL,
- OUT VOID **TxBuf OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- UINT16 RxCurUsed;
- UINT16 TxCurUsed;
- EFI_PHYSICAL_ADDRESS DeviceAddress;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ UINT16 RxCurUsed;
+ UINT16 TxCurUsed;
+ EFI_PHYSICAL_ADDRESS DeviceAddress;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
- case EfiSimpleNetworkStopped:
- Status = EFI_NOT_STARTED;
- goto Exit;
- case EfiSimpleNetworkStarted:
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- default:
- break;
+ case EfiSimpleNetworkStopped:
+ Status = EFI_NOT_STARTED;
+ goto Exit;
+ case EfiSimpleNetworkStarted:
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ default:
+ break;
}
//
// update link status
//
if (Dev->Snm.MediaPresentSupported) {
- UINT16 LinkStatus;
+ UINT16 LinkStatus;
Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus);
if (EFI_ERROR (Status)) {
goto Exit;
}
+
Dev->Snm.MediaPresent =
- (BOOLEAN) ((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0);
+ (BOOLEAN)((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0);
}
//
@@ -110,6 +110,7 @@ VirtioNetGetStatus ( if (Dev->RxLastUsed != RxCurUsed) {
*InterruptStatus |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT;
}
+
if (Dev->TxLastUsed != TxCurUsed) {
ASSERT (Dev->TxCurPending > 0);
*InterruptStatus |= EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT;
@@ -119,10 +120,9 @@ VirtioNetGetStatus ( if (TxBuf != NULL) {
if (Dev->TxLastUsed == TxCurUsed) {
*TxBuf = NULL;
- }
- else {
- UINT16 UsedElemIdx;
- UINT32 DescIdx;
+ } else {
+ UINT16 UsedElemIdx;
+ UINT32 DescIdx;
//
// fetch the first descriptor among those that the hypervisor reports
@@ -132,8 +132,8 @@ VirtioNetGetStatus ( ASSERT (Dev->TxCurPending <= Dev->TxMaxPending);
UsedElemIdx = Dev->TxLastUsed++ % Dev->TxRing.QueueSize;
- DescIdx = Dev->TxRing.Used.UsedElem[UsedElemIdx].Id;
- ASSERT (DescIdx < (UINT32) (2 * Dev->TxMaxPending - 1));
+ DescIdx = Dev->TxRing.Used.UsedElem[UsedElemIdx].Id;
+ ASSERT (DescIdx < (UINT32)(2 * Dev->TxMaxPending - 1));
//
// get the device address that has been enqueued for the caller's
@@ -144,7 +144,7 @@ VirtioNetGetStatus ( //
// now this descriptor can be used again to enqueue a transmit buffer
//
- Dev->TxFreeStack[--Dev->TxCurPending] = (UINT16) DescIdx;
+ Dev->TxFreeStack[--Dev->TxCurPending] = (UINT16)DescIdx;
//
// Unmap the device address and perform the reverse mapping to find the
diff --git a/OvmfPkg/VirtioNetDxe/SnpInitialize.c b/OvmfPkg/VirtioNetDxe/SnpInitialize.c index bb3b552d68..c77aeea826 100644 --- a/OvmfPkg/VirtioNetDxe/SnpInitialize.c +++ b/OvmfPkg/VirtioNetDxe/SnpInitialize.c @@ -39,21 +39,20 @@ VirtioRingMap().
@retval EFI_SUCCESS Ring initialized.
*/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetInitRing (
- IN OUT VNET_DEV *Dev,
- IN UINT16 Selector,
- OUT VRING *Ring,
- OUT VOID **Mapping
+ IN OUT VNET_DEV *Dev,
+ IN UINT16 Selector,
+ OUT VRING *Ring,
+ OUT VOID **Mapping
)
{
- EFI_STATUS Status;
- UINT16 QueueSize;
- UINT64 RingBaseShift;
- VOID *MapInfo;
+ EFI_STATUS Status;
+ UINT16 QueueSize;
+ UINT64 RingBaseShift;
+ VOID *MapInfo;
//
// step 4b -- allocate selected queue
@@ -62,6 +61,7 @@ VirtioNetInitRing ( if (EFI_ERROR (Status)) {
return Status;
}
+
Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize);
if (EFI_ERROR (Status)) {
return Status;
@@ -74,6 +74,7 @@ VirtioNetInitRing ( if (QueueSize < 2) {
return EFI_UNSUPPORTED;
}
+
Status = VirtioRingInit (Dev->VirtIo, QueueSize, Ring);
if (EFI_ERROR (Status)) {
return Status;
@@ -122,7 +123,6 @@ ReleaseQueue: return Status;
}
-
/**
Set up static scaffolding for the VirtioNetTransmit() and
VirtioNetGetStatus() SNP methods.
@@ -148,12 +148,11 @@ ReleaseQueue: VirtioMapAllBytesInSharedBuffer()
@retval EFI_SUCCESS TX setup successful.
*/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetInitTx (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
)
{
UINTN TxSharedReqSize;
@@ -162,11 +161,15 @@ VirtioNetInitTx ( EFI_PHYSICAL_ADDRESS DeviceAddress;
VOID *TxSharedReqBuffer;
- Dev->TxMaxPending = (UINT16) MIN (Dev->TxRing.QueueSize / 2,
- VNET_MAX_PENDING);
+ Dev->TxMaxPending = (UINT16)MIN (
+ Dev->TxRing.QueueSize / 2,
+ VNET_MAX_PENDING
+ );
Dev->TxCurPending = 0;
- Dev->TxFreeStack = AllocatePool (Dev->TxMaxPending *
- sizeof *Dev->TxFreeStack);
+ Dev->TxFreeStack = AllocatePool (
+ Dev->TxMaxPending *
+ sizeof *Dev->TxFreeStack
+ );
if (Dev->TxFreeStack == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -209,7 +212,6 @@ VirtioNetInitTx ( Dev->TxSharedReq = TxSharedReqBuffer;
-
//
// In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depends on
// VIRTIO_NET_F_MRG_RXBUF, which we never negotiate.
@@ -219,9 +221,9 @@ VirtioNetInitTx ( sizeof *Dev->TxSharedReq;
for (PktIdx = 0; PktIdx < Dev->TxMaxPending; ++PktIdx) {
- UINT16 DescIdx;
+ UINT16 DescIdx;
- DescIdx = (UINT16) (2 * PktIdx);
+ DescIdx = (UINT16)(2 * PktIdx);
Dev->TxFreeStack[PktIdx] = DescIdx;
//
@@ -229,9 +231,9 @@ VirtioNetInitTx ( // (unmodified by the host) virtio-net request header.
//
Dev->TxRing.Desc[DescIdx].Addr = DeviceAddress;
- Dev->TxRing.Desc[DescIdx].Len = (UINT32) TxSharedReqSize;
+ Dev->TxRing.Desc[DescIdx].Len = (UINT32)TxSharedReqSize;
Dev->TxRing.Desc[DescIdx].Flags = VRING_DESC_F_NEXT;
- Dev->TxRing.Desc[DescIdx].Next = (UINT16) (DescIdx + 1);
+ Dev->TxRing.Desc[DescIdx].Next = (UINT16)(DescIdx + 1);
//
// The second descriptor of each pending TX packet is updated on the fly,
@@ -261,7 +263,7 @@ VirtioNetInitTx ( //
// want no interrupt when a transmit completes
//
- *Dev->TxRing.Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT;
+ *Dev->TxRing.Avail.Flags = (UINT16)VRING_AVAIL_F_NO_INTERRUPT;
return EFI_SUCCESS;
@@ -281,7 +283,6 @@ FreeTxFreeStack: return Status;
}
-
/**
Set up static scaffolding for the VirtioNetReceive() SNP method and enable
live device operation.
@@ -304,12 +305,11 @@ FreeTxFreeStack: @retval EFI_SUCCESS RX setup successful. The device is live and may
already be writing to the receive area.
*/
-
STATIC
EFI_STATUS
EFIAPI
VirtioNetInitRx (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
)
{
EFI_STATUS Status;
@@ -343,7 +343,7 @@ VirtioNetInitRx ( // Limit the number of pending RX packets if the queue is big. The division
// by two is due to the above "two descriptors per packet" trait.
//
- RxAlwaysPending = (UINT16) MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PENDING);
+ RxAlwaysPending = (UINT16)MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PENDING);
//
// The RxBuf is shared between guest and hypervisor, use
@@ -351,13 +351,13 @@ VirtioNetInitRx ( // BusMasterCommonBuffer so that it can be accessed by both guest and
// hypervisor.
//
- NumBytes = RxAlwaysPending * RxBufSize;
+ NumBytes = RxAlwaysPending * RxBufSize;
Dev->RxBufNrPages = EFI_SIZE_TO_PAGES (NumBytes);
- Status = Dev->VirtIo->AllocateSharedPages (
- Dev->VirtIo,
- Dev->RxBufNrPages,
- &RxBuffer
- );
+ Status = Dev->VirtIo->AllocateSharedPages (
+ Dev->VirtIo,
+ Dev->RxBufNrPages,
+ &RxBuffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -390,13 +390,13 @@ VirtioNetInitRx ( // the host should not send interrupts, we'll poll in VirtioNetReceive()
// and VirtioNetIsPacketAvailable().
//
- *Dev->RxRing.Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT;
+ *Dev->RxRing.Avail.Flags = (UINT16)VRING_AVAIL_F_NO_INTERRUPT;
//
// now set up a separate, two-part descriptor chain for each RX packet, and
// link each chain into (from) the available ring as well
//
- DescIdx = 0;
+ DescIdx = 0;
RxBufDeviceAddress = Dev->RxBufDeviceBase;
for (PktIdx = 0; PktIdx < RxAlwaysPending; ++PktIdx) {
//
@@ -409,15 +409,15 @@ VirtioNetInitRx ( // virtio-0.9.5, 2.4.1.1 Placing Buffers into the Descriptor Table
//
Dev->RxRing.Desc[DescIdx].Addr = RxBufDeviceAddress;
- Dev->RxRing.Desc[DescIdx].Len = (UINT32) VirtioNetReqSize;
+ Dev->RxRing.Desc[DescIdx].Len = (UINT32)VirtioNetReqSize;
Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE | VRING_DESC_F_NEXT;
- Dev->RxRing.Desc[DescIdx].Next = (UINT16) (DescIdx + 1);
- RxBufDeviceAddress += Dev->RxRing.Desc[DescIdx++].Len;
+ Dev->RxRing.Desc[DescIdx].Next = (UINT16)(DescIdx + 1);
+ RxBufDeviceAddress += Dev->RxRing.Desc[DescIdx++].Len;
Dev->RxRing.Desc[DescIdx].Addr = RxBufDeviceAddress;
- Dev->RxRing.Desc[DescIdx].Len = (UINT32) (RxBufSize - VirtioNetReqSize);
+ Dev->RxRing.Desc[DescIdx].Len = (UINT32)(RxBufSize - VirtioNetReqSize);
Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE;
- RxBufDeviceAddress += Dev->RxRing.Desc[DescIdx++].Len;
+ RxBufDeviceAddress += Dev->RxRing.Desc[DescIdx++].Len;
}
//
@@ -455,7 +455,6 @@ FreeSharedBuffer: return Status;
}
-
/**
Resets a network adapter and allocates the transmit and receive buffers
required by the network interface; optionally, also requests allocation of
@@ -485,29 +484,29 @@ FreeSharedBuffer: interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetInitialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- UINT8 NextDevStat;
- UINT64 Features;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ UINT8 NextDevStat;
+ UINT64 Features;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (ExtraRxBufferSize > 0 || ExtraTxBufferSize > 0) {
+
+ if ((ExtraRxBufferSize > 0) || (ExtraTxBufferSize > 0)) {
return EFI_UNSUPPORTED;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (Dev->Snm.State != EfiSimpleNetworkStarted) {
Status = EFI_NOT_STARTED;
@@ -524,13 +523,13 @@ VirtioNetInitialize ( // virtio-0.9.5 spec, 2.2.1 Device Initialization Sequence.
//
NextDevStat = VSTAT_ACK; // step 2 -- acknowledge device presence
- Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto InitFailed;
}
NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
- Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto DeviceFailed;
}
@@ -553,8 +552,10 @@ VirtioNetInitialize ( }
ASSERT (Features & VIRTIO_NET_F_MAC);
- ASSERT (Dev->Snm.MediaPresentSupported ==
- !!(Features & VIRTIO_NET_F_STATUS));
+ ASSERT (
+ Dev->Snm.MediaPresentSupported ==
+ !!(Features & VIRTIO_NET_F_STATUS)
+ );
Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1 |
VIRTIO_F_IOMMU_PLATFORM;
@@ -598,7 +599,7 @@ VirtioNetInitialize ( //
if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) {
Features &= ~(UINT64)(VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM);
- Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
+ Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
if (EFI_ERROR (Status)) {
goto ReleaseTxRing;
}
@@ -608,7 +609,7 @@ VirtioNetInitialize ( // step 6 -- virtio-net initialization complete
//
NextDevStat |= VSTAT_DRIVER_OK;
- Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
+ Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
if (EFI_ERROR (Status)) {
goto ReleaseTxRing;
}
diff --git a/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c b/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c index e16c61c6ba..6870ffa19e 100644 --- a/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c +++ b/OvmfPkg/VirtioNetDxe/SnpMcastIpToMac.c @@ -38,41 +38,41 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetMcastIpToMac (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN IPv6,
- IN EFI_IP_ADDRESS *Ip,
- OUT EFI_MAC_ADDRESS *Mac
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS *Ip,
+ OUT EFI_MAC_ADDRESS *Mac
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
//
// http://en.wikipedia.org/wiki/Multicast_address
//
- if (This == NULL || Ip == NULL || Mac == NULL ||
- ( IPv6 && (Ip->v6.Addr[0] ) != 0xFF) || // invalid IPv6 mcast addr
- (!IPv6 && (Ip->v4.Addr[0] & 0xF0) != 0xE0) // invalid IPv4 mcast addr
- ) {
+ if ((This == NULL) || (Ip == NULL) || (Mac == NULL) ||
+ (IPv6 && ((Ip->v6.Addr[0]) != 0xFF)) || // invalid IPv6 mcast addr
+ (!IPv6 && ((Ip->v4.Addr[0] & 0xF0) != 0xE0)) // invalid IPv4 mcast addr
+ )
+ {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
- case EfiSimpleNetworkStopped:
- Status = EFI_NOT_STARTED;
- goto Exit;
- case EfiSimpleNetworkStarted:
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- default:
- break;
+ case EfiSimpleNetworkStopped:
+ Status = EFI_NOT_STARTED;
+ goto Exit;
+ case EfiSimpleNetworkStarted:
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ default:
+ break;
}
//
@@ -85,8 +85,7 @@ VirtioNetMcastIpToMac ( Mac->Addr[3] = Ip->v6.Addr[13];
Mac->Addr[4] = Ip->v6.Addr[14];
Mac->Addr[5] = Ip->v6.Addr[15];
- }
- else {
+ } else {
Mac->Addr[0] = 0x01;
Mac->Addr[1] = 0x00;
Mac->Addr[2] = 0x5E;
@@ -94,6 +93,7 @@ VirtioNetMcastIpToMac ( Mac->Addr[4] = Ip->v4.Addr[2];
Mac->Addr[5] = Ip->v4.Addr[3];
}
+
Status = EFI_SUCCESS;
Exit:
diff --git a/OvmfPkg/VirtioNetDxe/SnpReceive.c b/OvmfPkg/VirtioNetDxe/SnpReceive.c index cdee9a2aee..cc0e1da14f 100644 --- a/OvmfPkg/VirtioNetDxe/SnpReceive.c +++ b/OvmfPkg/VirtioNetDxe/SnpReceive.c @@ -52,47 +52,46 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetReceive (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- UINT16 RxCurUsed;
- UINT16 UsedElemIdx;
- UINT32 DescIdx;
- UINT32 RxLen;
- UINTN OrigBufferSize;
- UINT8 *RxPtr;
- UINT16 AvailIdx;
- EFI_STATUS NotifyStatus;
- UINTN RxBufOffset;
-
- if (This == NULL || BufferSize == NULL || Buffer == NULL) {
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ UINT16 RxCurUsed;
+ UINT16 UsedElemIdx;
+ UINT32 DescIdx;
+ UINT32 RxLen;
+ UINTN OrigBufferSize;
+ UINT8 *RxPtr;
+ UINT16 AvailIdx;
+ EFI_STATUS NotifyStatus;
+ UINTN RxBufOffset;
+
+ if ((This == NULL) || (BufferSize == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
- case EfiSimpleNetworkStopped:
- Status = EFI_NOT_STARTED;
- goto Exit;
- case EfiSimpleNetworkStarted:
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- default:
- break;
+ case EfiSimpleNetworkStopped:
+ Status = EFI_NOT_STARTED;
+ goto Exit;
+ case EfiSimpleNetworkStarted:
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ default:
+ break;
}
//
@@ -108,8 +107,8 @@ VirtioNetReceive ( }
UsedElemIdx = Dev->RxLastUsed % Dev->RxRing.QueueSize;
- DescIdx = Dev->RxRing.Used.UsedElem[UsedElemIdx].Id;
- RxLen = Dev->RxRing.Used.UsedElem[UsedElemIdx].Len;
+ DescIdx = Dev->RxRing.Used.UsedElem[UsedElemIdx].Id;
+ RxLen = Dev->RxRing.Used.UsedElem[UsedElemIdx].Len;
//
// the virtio-net request header must be complete; we skip it
@@ -122,7 +121,7 @@ VirtioNetReceive ( ASSERT (RxLen <= Dev->RxRing.Desc[DescIdx + 1].Len);
OrigBufferSize = *BufferSize;
- *BufferSize = RxLen;
+ *BufferSize = RxLen;
if (OrigBufferSize < RxLen) {
Status = EFI_BUFFER_TOO_SMALL;
@@ -146,16 +145,19 @@ VirtioNetReceive ( if (DestAddr != NULL) {
CopyMem (DestAddr, RxPtr, SIZE_OF_VNET (Mac));
}
+
RxPtr += SIZE_OF_VNET (Mac);
if (SrcAddr != NULL) {
CopyMem (SrcAddr, RxPtr, SIZE_OF_VNET (Mac));
}
+
RxPtr += SIZE_OF_VNET (Mac);
if (Protocol != NULL) {
- *Protocol = (UINT16) ((RxPtr[0] << 8) | RxPtr[1]);
+ *Protocol = (UINT16)((RxPtr[0] << 8) | RxPtr[1]);
}
+
RxPtr += sizeof (UINT16);
Status = EFI_SUCCESS;
@@ -166,16 +168,17 @@ RecycleDesc: //
// virtio-0.9.5, 2.4.1 Supplying Buffers to The Device
//
- AvailIdx = *Dev->RxRing.Avail.Idx;
+ AvailIdx = *Dev->RxRing.Avail.Idx;
Dev->RxRing.Avail.Ring[AvailIdx++ % Dev->RxRing.QueueSize] =
- (UINT16) DescIdx;
+ (UINT16)DescIdx;
MemoryFence ();
*Dev->RxRing.Avail.Idx = AvailIdx;
MemoryFence ();
NotifyStatus = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX);
- if (!EFI_ERROR (Status)) { // earlier error takes precedence
+ if (!EFI_ERROR (Status)) {
+ // earlier error takes precedence
Status = NotifyStatus;
}
diff --git a/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c b/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c index 9d5ce29b79..18027a563a 100644 --- a/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c +++ b/OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c @@ -45,37 +45,36 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetReceiveFilters (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
- case EfiSimpleNetworkStopped:
- Status = EFI_NOT_STARTED;
- goto Exit;
- case EfiSimpleNetworkStarted:
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- default:
- break;
+ case EfiSimpleNetworkStopped:
+ Status = EFI_NOT_STARTED;
+ goto Exit;
+ case EfiSimpleNetworkStarted:
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ default:
+ break;
}
//
@@ -89,9 +88,9 @@ VirtioNetReceiveFilters ( // discarding any packets getting through the filter.
//
Status = (
- ((Enable | Disable) & ~Dev->Snm.ReceiveFilterMask) != 0 ||
- (!ResetMCastFilter && MCastFilterCnt > Dev->Snm.MaxMCastFilterCount)
- ) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
+ ((Enable | Disable) & ~Dev->Snm.ReceiveFilterMask) != 0 ||
+ (!ResetMCastFilter && MCastFilterCnt > Dev->Snm.MaxMCastFilterCount)
+ ) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
Exit:
gBS->RestoreTPL (OldTpl);
diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c index d1e3ecfa5a..d03255ab50 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -17,9 +17,9 @@ // info of the packets queued in TxRing
//
typedef struct {
- VOID *Buffer;
- EFI_PHYSICAL_ADDRESS DeviceAddress; // lookup key for reverse mapping
- VOID *BufMap;
+ VOID *Buffer;
+ EFI_PHYSICAL_ADDRESS DeviceAddress; // lookup key for reverse mapping
+ VOID *BufMap;
} TX_BUF_MAP_INFO;
/**
@@ -36,11 +36,10 @@ typedef struct { @param[in,out] Dev The VNET_DEV driver instance being shut down, or whose
partial, failed initialization is being rolled back.
*/
-
VOID
EFIAPI
VirtioNetShutdownRx (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
)
{
Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap);
@@ -51,16 +50,15 @@ VirtioNetShutdownRx ( );
}
-
VOID
EFIAPI
VirtioNetShutdownTx (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
)
{
- ORDERED_COLLECTION_ENTRY *Entry, *Entry2;
- TX_BUF_MAP_INFO *TxBufMapInfo;
- VOID *UserStruct;
+ ORDERED_COLLECTION_ENTRY *Entry, *Entry2;
+ TX_BUF_MAP_INFO *TxBufMapInfo;
+ VOID *UserStruct;
Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap);
Dev->VirtIo->FreeSharedPages (
@@ -71,13 +69,15 @@ VirtioNetShutdownTx ( for (Entry = OrderedCollectionMin (Dev->TxBufCollection);
Entry != NULL;
- Entry = Entry2) {
+ Entry = Entry2)
+ {
Entry2 = OrderedCollectionNext (Entry);
OrderedCollectionDelete (Dev->TxBufCollection, Entry, &UserStruct);
TxBufMapInfo = UserStruct;
Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, TxBufMapInfo->BufMap);
FreePool (TxBufMapInfo);
}
+
OrderedCollectionUninit (Dev->TxBufCollection);
FreePool (Dev->TxFreeStack);
@@ -94,16 +94,15 @@ VirtioNetShutdownTx ( VOID
EFIAPI
VirtioNetUninitRing (
- IN OUT VNET_DEV *Dev,
- IN OUT VRING *Ring,
- IN VOID *RingMap
+ IN OUT VNET_DEV *Dev,
+ IN OUT VRING *Ring,
+ IN VOID *RingMap
)
{
Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, RingMap);
VirtioRingUninit (Dev->VirtIo, Ring);
}
-
/**
Map Caller-supplied TxBuf buffer to the device-mapped address
@@ -129,10 +128,10 @@ VirtioNetMapTxBuf ( OUT EFI_PHYSICAL_ADDRESS *DeviceAddress
)
{
- EFI_STATUS Status;
- TX_BUF_MAP_INFO *TxBufMapInfo;
- EFI_PHYSICAL_ADDRESS Address;
- VOID *Mapping;
+ EFI_STATUS Status;
+ TX_BUF_MAP_INFO *TxBufMapInfo;
+ EFI_PHYSICAL_ADDRESS Address;
+ VOID *Mapping;
TxBufMapInfo = AllocatePool (sizeof (*TxBufMapInfo));
if (TxBufMapInfo == NULL) {
@@ -146,14 +145,14 @@ VirtioNetMapTxBuf ( NumberOfBytes,
&Address,
&Mapping
- );
+ );
if (EFI_ERROR (Status)) {
goto FreeTxBufMapInfo;
}
- TxBufMapInfo->Buffer = Buffer;
+ TxBufMapInfo->Buffer = Buffer;
TxBufMapInfo->DeviceAddress = Address;
- TxBufMapInfo->BufMap = Mapping;
+ TxBufMapInfo->BufMap = Mapping;
Status = OrderedCollectionInsert (
Dev->TxBufCollection,
@@ -161,26 +160,26 @@ VirtioNetMapTxBuf ( TxBufMapInfo
);
switch (Status) {
- case EFI_OUT_OF_RESOURCES:
- goto UnmapTxBuf;
- case EFI_ALREADY_STARTED:
- //
- // This should never happen: it implies
- //
- // - an identity-mapping VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer()
- // implementation -- which is fine,
- //
- // - and an SNP client that queues multiple instances of the exact same
- // buffer address with SNP.Transmit() -- which is undefined behavior,
- // based on the TxBuf language in UEFI-2.7,
- // EFI_SIMPLE_NETWORK.GetStatus().
- //
- ASSERT (FALSE);
- Status = EFI_INVALID_PARAMETER;
- goto UnmapTxBuf;
- default:
- ASSERT_EFI_ERROR (Status);
- break;
+ case EFI_OUT_OF_RESOURCES:
+ goto UnmapTxBuf;
+ case EFI_ALREADY_STARTED:
+ //
+ // This should never happen: it implies
+ //
+ // - an identity-mapping VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer()
+ // implementation -- which is fine,
+ //
+ // - and an SNP client that queues multiple instances of the exact same
+ // buffer address with SNP.Transmit() -- which is undefined behavior,
+ // based on the TxBuf language in UEFI-2.7,
+ // EFI_SIMPLE_NETWORK.GetStatus().
+ //
+ ASSERT (FALSE);
+ Status = EFI_INVALID_PARAMETER;
+ goto UnmapTxBuf;
+ default:
+ ASSERT_EFI_ERROR (Status);
+ break;
}
*DeviceAddress = Address;
@@ -253,12 +252,12 @@ VirtioNetUnmapTxBuf ( INTN
EFIAPI
VirtioNetTxBufMapInfoCompare (
- IN CONST VOID *UserStruct1,
- IN CONST VOID *UserStruct2
+ IN CONST VOID *UserStruct1,
+ IN CONST VOID *UserStruct2
)
{
- CONST TX_BUF_MAP_INFO *MapInfo1;
- CONST TX_BUF_MAP_INFO *MapInfo2;
+ CONST TX_BUF_MAP_INFO *MapInfo1;
+ CONST TX_BUF_MAP_INFO *MapInfo2;
MapInfo1 = UserStruct1;
MapInfo2 = UserStruct2;
@@ -287,15 +286,15 @@ VirtioNetTxBufMapInfoCompare ( INTN
EFIAPI
VirtioNetTxBufDeviceAddressCompare (
- IN CONST VOID *StandaloneKey,
- IN CONST VOID *UserStruct
+ IN CONST VOID *StandaloneKey,
+ IN CONST VOID *UserStruct
)
{
- CONST EFI_PHYSICAL_ADDRESS *DeviceAddress;
- CONST TX_BUF_MAP_INFO *MapInfo;
+ CONST EFI_PHYSICAL_ADDRESS *DeviceAddress;
+ CONST TX_BUF_MAP_INFO *MapInfo;
DeviceAddress = StandaloneKey;
- MapInfo = UserStruct;
+ MapInfo = UserStruct;
return *DeviceAddress < MapInfo->DeviceAddress ? -1 :
*DeviceAddress > MapInfo->DeviceAddress ? 1 :
diff --git a/OvmfPkg/VirtioNetDxe/SnpShutdown.c b/OvmfPkg/VirtioNetDxe/SnpShutdown.c index a217b83799..a589d458ab 100644 --- a/OvmfPkg/VirtioNetDxe/SnpShutdown.c +++ b/OvmfPkg/VirtioNetDxe/SnpShutdown.c @@ -30,32 +30,31 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetShutdown (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
- case EfiSimpleNetworkStopped:
- Status = EFI_NOT_STARTED;
- goto Exit;
- case EfiSimpleNetworkStarted:
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- default:
- break;
+ case EfiSimpleNetworkStopped:
+ Status = EFI_NOT_STARTED;
+ goto Exit;
+ case EfiSimpleNetworkStarted:
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ default:
+ break;
}
Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
@@ -65,7 +64,7 @@ VirtioNetShutdown ( VirtioNetUninitRing (Dev, &Dev->RxRing, Dev->RxRingMap);
Dev->Snm.State = EfiSimpleNetworkStarted;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
Exit:
gBS->RestoreTPL (OldTpl);
diff --git a/OvmfPkg/VirtioNetDxe/SnpStart.c b/OvmfPkg/VirtioNetDxe/SnpStart.c index b8161fbe32..a45953eeb1 100644 --- a/OvmfPkg/VirtioNetDxe/SnpStart.c +++ b/OvmfPkg/VirtioNetDxe/SnpStart.c @@ -28,29 +28,27 @@ @retval EFI_UNSUPPORTED This function is not supported by the network
interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetStart (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (Dev->Snm.State != EfiSimpleNetworkStopped) {
Status = EFI_ALREADY_STARTED;
- }
- else {
+ } else {
Dev->Snm.State = EfiSimpleNetworkStarted;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
gBS->RestoreTPL (OldTpl);
diff --git a/OvmfPkg/VirtioNetDxe/SnpStop.c b/OvmfPkg/VirtioNetDxe/SnpStop.c index 3dc7bec8fd..b1ca3c86af 100644 --- a/OvmfPkg/VirtioNetDxe/SnpStop.c +++ b/OvmfPkg/VirtioNetDxe/SnpStop.c @@ -29,29 +29,27 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetStop (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
)
{
- VNET_DEV *Dev;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
+ VNET_DEV *Dev;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (Dev->Snm.State != EfiSimpleNetworkStarted) {
Status = EFI_NOT_STARTED;
- }
- else {
+ } else {
Dev->Snm.State = EfiSimpleNetworkStopped;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
}
gBS->RestoreTPL (OldTpl);
diff --git a/OvmfPkg/VirtioNetDxe/SnpTransmit.c b/OvmfPkg/VirtioNetDxe/SnpTransmit.c index 2218139b33..315e0b7425 100644 --- a/OvmfPkg/VirtioNetDxe/SnpTransmit.c +++ b/OvmfPkg/VirtioNetDxe/SnpTransmit.c @@ -54,17 +54,16 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetTransmit (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN /* +OUT! */ VOID *Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN /* +OUT! */ VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
)
{
VNET_DEV *Dev;
@@ -74,27 +73,28 @@ VirtioNetTransmit ( UINT16 AvailIdx;
EFI_PHYSICAL_ADDRESS DeviceAddress;
- if (This == NULL || BufferSize == 0 || Buffer == NULL) {
+ if ((This == NULL) || (BufferSize == 0) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
- Dev = VIRTIO_NET_FROM_SNP (This);
+ Dev = VIRTIO_NET_FROM_SNP (This);
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Dev->Snm.State) {
- case EfiSimpleNetworkStopped:
- Status = EFI_NOT_STARTED;
- goto Exit;
- case EfiSimpleNetworkStarted:
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- default:
- break;
+ case EfiSimpleNetworkStopped:
+ Status = EFI_NOT_STARTED;
+ goto Exit;
+ case EfiSimpleNetworkStarted:
+ Status = EFI_DEVICE_ERROR;
+ goto Exit;
+ default:
+ break;
}
if (BufferSize < Dev->Snm.MediaHeaderSize) {
Status = EFI_BUFFER_TOO_SMALL;
goto Exit;
}
+
if (BufferSize > Dev->Snm.MediaHeaderSize + Dev->Snm.MaxPacketSize) {
Status = EFI_INVALID_PARAMETER;
goto Exit;
@@ -114,28 +114,32 @@ VirtioNetTransmit ( // dst MAC, src MAC, Ethertype
//
if (HeaderSize != 0) {
- UINT8 *Ptr;
+ UINT8 *Ptr;
- if (HeaderSize != Dev->Snm.MediaHeaderSize ||
- DestAddr == NULL || Protocol == NULL) {
+ if ((HeaderSize != Dev->Snm.MediaHeaderSize) ||
+ (DestAddr == NULL) || (Protocol == NULL))
+ {
Status = EFI_INVALID_PARAMETER;
goto Exit;
}
+
Ptr = Buffer;
ASSERT (SIZE_OF_VNET (Mac) <= sizeof (EFI_MAC_ADDRESS));
CopyMem (Ptr, DestAddr, SIZE_OF_VNET (Mac));
Ptr += SIZE_OF_VNET (Mac);
- CopyMem (Ptr,
+ CopyMem (
+ Ptr,
(SrcAddr == NULL) ? &Dev->Snm.CurrentAddress : SrcAddr,
- SIZE_OF_VNET (Mac));
+ SIZE_OF_VNET (Mac)
+ );
Ptr += SIZE_OF_VNET (Mac);
- *Ptr++ = (UINT8) (*Protocol >> 8);
- *Ptr++ = (UINT8) *Protocol;
+ *Ptr++ = (UINT8)(*Protocol >> 8);
+ *Ptr++ = (UINT8)*Protocol;
- ASSERT ((UINTN) (Ptr - (UINT8 *) Buffer) == Dev->Snm.MediaHeaderSize);
+ ASSERT ((UINTN)(Ptr - (UINT8 *)Buffer) == Dev->Snm.MediaHeaderSize);
}
//
@@ -155,15 +159,15 @@ VirtioNetTransmit ( //
// virtio-0.9.5, 2.4.1 Supplying Buffers to The Device
//
- DescIdx = Dev->TxFreeStack[Dev->TxCurPending++];
- Dev->TxRing.Desc[DescIdx + 1].Addr = DeviceAddress;
- Dev->TxRing.Desc[DescIdx + 1].Len = (UINT32) BufferSize;
+ DescIdx = Dev->TxFreeStack[Dev->TxCurPending++];
+ Dev->TxRing.Desc[DescIdx + 1].Addr = DeviceAddress;
+ Dev->TxRing.Desc[DescIdx + 1].Len = (UINT32)BufferSize;
//
// the available index is never written by the host, we can read it back
// without a barrier
//
- AvailIdx = *Dev->TxRing.Avail.Idx;
+ AvailIdx = *Dev->TxRing.Avail.Idx;
Dev->TxRing.Avail.Ring[AvailIdx++ % Dev->TxRing.QueueSize] = DescIdx;
MemoryFence ();
diff --git a/OvmfPkg/VirtioNetDxe/SnpUnsupported.c b/OvmfPkg/VirtioNetDxe/SnpUnsupported.c index e41cc31b27..2d0c1ab913 100644 --- a/OvmfPkg/VirtioNetDxe/SnpUnsupported.c +++ b/OvmfPkg/VirtioNetDxe/SnpUnsupported.c @@ -32,18 +32,16 @@ interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetReset (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
return EFI_UNSUPPORTED;
}
-
/**
Modifies or resets the current station address, if supported.
@@ -63,19 +61,17 @@ VirtioNetReset ( interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetStationAddress (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *New OPTIONAL
)
{
return EFI_UNSUPPORTED;
}
-
/**
Resets or collects the statistics on a network interface.
@@ -102,20 +98,18 @@ VirtioNetStationAddress ( interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetStatistics (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
)
{
return EFI_UNSUPPORTED;
}
-
/**
Performs read and write operations on the NVRAM device attached to a network
interface.
@@ -139,15 +133,14 @@ VirtioNetStatistics ( interface.
**/
-
EFI_STATUS
EFIAPI
VirtioNetNvData (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN ReadWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
)
{
return EFI_UNSUPPORTED;
diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/VirtioNet.h index 711b7c4cfa..719c575132 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -22,12 +22,12 @@ #include <Protocol/SimpleNetwork.h>
#include <Library/OrderedCollectionLib.h>
-#define VNET_SIG SIGNATURE_32 ('V', 'N', 'E', 'T')
+#define VNET_SIG SIGNATURE_32 ('V', 'N', 'E', 'T')
//
// maximum number of pending packets, separately for each direction
//
-#define VNET_MAX_PENDING 64
+#define VNET_MAX_PENDING 64
//
// State diagram:
@@ -69,36 +69,35 @@ typedef struct { //
// field init function
// ------------------ ------------------------------
- UINT32 Signature; // VirtioNetDriverBindingStart
- VIRTIO_DEVICE_PROTOCOL *VirtIo; // VirtioNetDriverBindingStart
- EFI_SIMPLE_NETWORK_PROTOCOL Snp; // VirtioNetSnpPopulate
- EFI_SIMPLE_NETWORK_MODE Snm; // VirtioNetSnpPopulate
- EFI_EVENT ExitBoot; // VirtioNetSnpPopulate
- EFI_DEVICE_PATH_PROTOCOL *MacDevicePath; // VirtioNetDriverBindingStart
- EFI_HANDLE MacHandle; // VirtioNetDriverBindingStart
-
- VRING RxRing; // VirtioNetInitRing
- VOID *RxRingMap; // VirtioRingMap and
- // VirtioNetInitRing
- UINT8 *RxBuf; // VirtioNetInitRx
- UINT16 RxLastUsed; // VirtioNetInitRx
- UINTN RxBufNrPages; // VirtioNetInitRx
- EFI_PHYSICAL_ADDRESS RxBufDeviceBase; // VirtioNetInitRx
- VOID *RxBufMap; // VirtioNetInitRx
-
- VRING TxRing; // VirtioNetInitRing
- VOID *TxRingMap; // VirtioRingMap and
- // VirtioNetInitRing
- UINT16 TxMaxPending; // VirtioNetInitTx
- UINT16 TxCurPending; // VirtioNetInitTx
- UINT16 *TxFreeStack; // VirtioNetInitTx
- VIRTIO_1_0_NET_REQ *TxSharedReq; // VirtioNetInitTx
- VOID *TxSharedReqMap; // VirtioNetInitTx
- UINT16 TxLastUsed; // VirtioNetInitTx
- ORDERED_COLLECTION *TxBufCollection; // VirtioNetInitTx
+ UINT32 Signature; // VirtioNetDriverBindingStart
+ VIRTIO_DEVICE_PROTOCOL *VirtIo; // VirtioNetDriverBindingStart
+ EFI_SIMPLE_NETWORK_PROTOCOL Snp; // VirtioNetSnpPopulate
+ EFI_SIMPLE_NETWORK_MODE Snm; // VirtioNetSnpPopulate
+ EFI_EVENT ExitBoot; // VirtioNetSnpPopulate
+ EFI_DEVICE_PATH_PROTOCOL *MacDevicePath; // VirtioNetDriverBindingStart
+ EFI_HANDLE MacHandle; // VirtioNetDriverBindingStart
+
+ VRING RxRing; // VirtioNetInitRing
+ VOID *RxRingMap; // VirtioRingMap and
+ // VirtioNetInitRing
+ UINT8 *RxBuf; // VirtioNetInitRx
+ UINT16 RxLastUsed; // VirtioNetInitRx
+ UINTN RxBufNrPages; // VirtioNetInitRx
+ EFI_PHYSICAL_ADDRESS RxBufDeviceBase; // VirtioNetInitRx
+ VOID *RxBufMap; // VirtioNetInitRx
+
+ VRING TxRing; // VirtioNetInitRing
+ VOID *TxRingMap; // VirtioRingMap and
+ // VirtioNetInitRing
+ UINT16 TxMaxPending; // VirtioNetInitTx
+ UINT16 TxCurPending; // VirtioNetInitTx
+ UINT16 *TxFreeStack; // VirtioNetInitTx
+ VIRTIO_1_0_NET_REQ *TxSharedReq; // VirtioNetInitTx
+ VOID *TxSharedReqMap; // VirtioNetInitTx
+ UINT16 TxLastUsed; // VirtioNetInitTx
+ ORDERED_COLLECTION *TxBufCollection; // VirtioNetInitTx
} VNET_DEV;
-
//
// In order to avoid duplication of interface documentation, please find all
// leading comments near the respective function / variable definitions (not
@@ -119,7 +118,7 @@ typedef struct { (Value) \
))
-#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \
+#define VIRTIO_CFG_READ(Dev, Field, Pointer) ((Dev)->VirtIo->ReadDevice ( \
(Dev)->VirtIo, \
OFFSET_OF_VNET (Field), \
SIZE_OF_VNET (Field), \
@@ -130,13 +129,13 @@ typedef struct { //
// component naming
//
-extern EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2;
+extern EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2;
//
// driver binding
//
-extern EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding;
+extern EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding;
//
// member functions implementing the Simple Network Protocol
@@ -144,113 +143,113 @@ extern EFI_DRIVER_BINDING_PROTOCOL gVirtioNetDriverBinding; EFI_STATUS
EFIAPI
VirtioNetStart (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
VirtioNetStop (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
VirtioNetInitialize (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINTN ExtraRxBufferSize OPTIONAL,
- IN UINTN ExtraTxBufferSize OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
);
EFI_STATUS
EFIAPI
VirtioNetReset (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
EFI_STATUS
EFIAPI
VirtioNetShutdown (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This
);
EFI_STATUS
EFIAPI
VirtioNetReceiveFilters (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINT32 Enable,
- IN UINT32 Disable,
- IN BOOLEAN ResetMCastFilter,
- IN UINTN MCastFilterCnt OPTIONAL,
- IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
);
EFI_STATUS
EFIAPI
VirtioNetStationAddress (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN EFI_MAC_ADDRESS *New OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS *New OPTIONAL
);
EFI_STATUS
EFIAPI
VirtioNetStatistics (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN Reset,
- IN OUT UINTN *StatisticsSize OPTIONAL,
- OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
);
EFI_STATUS
EFIAPI
VirtioNetMcastIpToMac (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN IPv6,
- IN EFI_IP_ADDRESS *Ip,
- OUT EFI_MAC_ADDRESS *Mac
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS *Ip,
+ OUT EFI_MAC_ADDRESS *Mac
);
EFI_STATUS
EFIAPI
VirtioNetNvData (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN BOOLEAN ReadWrite,
- IN UINTN Offset,
- IN UINTN BufferSize,
- IN OUT VOID *Buffer
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
);
EFI_STATUS
EFIAPI
VirtioNetGetStatus (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- OUT UINT32 *InterruptStatus OPTIONAL,
- OUT VOID **TxBuf OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
);
EFI_STATUS
EFIAPI
VirtioNetTransmit (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- IN UINTN HeaderSize,
- IN UINTN BufferSize,
- IN /* +OUT! */ VOID *Buffer,
- IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- IN UINT16 *Protocol OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN /* +OUT! */ VOID *Buffer,
+ IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
);
EFI_STATUS
EFIAPI
VirtioNetReceive (
- IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
- OUT UINTN *HeaderSize OPTIONAL,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer,
- OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
- OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
- OUT UINT16 *Protocol OPTIONAL
+ IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
);
//
@@ -259,21 +258,21 @@ VirtioNetReceive ( VOID
EFIAPI
VirtioNetShutdownRx (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
);
VOID
EFIAPI
VirtioNetShutdownTx (
- IN OUT VNET_DEV *Dev
+ IN OUT VNET_DEV *Dev
);
VOID
EFIAPI
VirtioNetUninitRing (
- IN OUT VNET_DEV *Dev,
- IN OUT VRING *Ring,
- IN VOID *RingMap
+ IN OUT VNET_DEV *Dev,
+ IN OUT VRING *Ring,
+ IN VOID *RingMap
);
//
@@ -300,33 +299,32 @@ VirtioNetUnmapTxBuf ( INTN
EFIAPI
VirtioNetTxBufMapInfoCompare (
- IN CONST VOID *UserStruct1,
- IN CONST VOID *UserStruct2
+ IN CONST VOID *UserStruct1,
+ IN CONST VOID *UserStruct2
);
INTN
EFIAPI
VirtioNetTxBufDeviceAddressCompare (
- IN CONST VOID *StandaloneKey,
- IN CONST VOID *UserStruct
+ IN CONST VOID *StandaloneKey,
+ IN CONST VOID *UserStruct
);
-
//
// event callbacks
//
VOID
EFIAPI
VirtioNetIsPacketAvailable (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
VOID
EFIAPI
VirtioNetExitBoot (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
#endif // _VIRTIO_NET_DXE_H_
|