VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/VirtioNetDxe/SnpShutdown.c

Last change on this file was 99404, checked in by vboxsync, 22 months ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/** @file
2
3 Implementation of the SNP.Shutdown() function and its private helpers if any.
4
5 Copyright (C) 2013, Red Hat, Inc.
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
7 Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
8
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11**/
12
13#include <Library/UefiBootServicesTableLib.h>
14
15#include "VirtioNet.h"
16
17/**
18 Resets a network adapter and leaves it in a state that is safe for another
19 driver to initialize.
20
21 @param This Protocol instance pointer.
22
23 @retval EFI_SUCCESS The network interface was shutdown.
24 @retval EFI_NOT_STARTED The network interface has not been started.
25 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
26 unsupported value.
27 @retval EFI_DEVICE_ERROR The command could not be sent to the network
28 interface.
29 @retval EFI_UNSUPPORTED This function is not supported by the network
30 interface.
31
32**/
33EFI_STATUS
34EFIAPI
35VirtioNetShutdown (
36 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
37 )
38{
39 VNET_DEV *Dev;
40 EFI_TPL OldTpl;
41 EFI_STATUS Status;
42
43 if (This == NULL) {
44 return EFI_INVALID_PARAMETER;
45 }
46
47 Dev = VIRTIO_NET_FROM_SNP (This);
48 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
49 switch (Dev->Snm.State) {
50 case EfiSimpleNetworkStopped:
51 Status = EFI_NOT_STARTED;
52 goto Exit;
53 case EfiSimpleNetworkStarted:
54 Status = EFI_DEVICE_ERROR;
55 goto Exit;
56 default:
57 break;
58 }
59
60 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
61 VirtioNetShutdownRx (Dev);
62 VirtioNetShutdownTx (Dev);
63 VirtioNetUninitRing (Dev, &Dev->TxRing, Dev->TxRingMap);
64 VirtioNetUninitRing (Dev, &Dev->RxRing, Dev->RxRingMap);
65
66 Dev->Snm.State = EfiSimpleNetworkStarted;
67 Status = EFI_SUCCESS;
68
69Exit:
70 gBS->RestoreTPL (OldTpl);
71 return Status;
72}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette