]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/SnpShutdown.c
BaseTools VS Makefile: Don't include ms.common in ms.app
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpShutdown.c
CommitLineData
80682e9b
LE
1/** @file\r
2\r
3 Implementation of the SNP.Shutdown() function and its private helpers if any.\r
4\r
5 Copyright (C) 2013, Red Hat, Inc.\r
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
7\r
8 This program and the accompanying materials are licensed and made available\r
9 under the terms and conditions of the BSD License which accompanies this\r
10 distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include <Library/UefiBootServicesTableLib.h>\r
19\r
20#include "VirtioNet.h"\r
21\r
22/**\r
23 Resets a network adapter and leaves it in a state that is safe for another\r
24 driver to initialize.\r
25\r
26 @param This Protocol instance pointer.\r
27\r
28 @retval EFI_SUCCESS The network interface was shutdown.\r
29 @retval EFI_NOT_STARTED The network interface has not been started.\r
30 @retval EFI_INVALID_PARAMETER One or more of the parameters has an\r
31 unsupported value.\r
32 @retval EFI_DEVICE_ERROR The command could not be sent to the network\r
33 interface.\r
34 @retval EFI_UNSUPPORTED This function is not supported by the network\r
35 interface.\r
36\r
37**/\r
38\r
39EFI_STATUS\r
40EFIAPI\r
41VirtioNetShutdown (\r
42 IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r
43 )\r
44{\r
45 VNET_DEV *Dev;\r
46 EFI_TPL OldTpl;\r
47 EFI_STATUS Status;\r
48\r
49 if (This == NULL) {\r
50 return EFI_INVALID_PARAMETER;\r
51 }\r
52\r
53 Dev = VIRTIO_NET_FROM_SNP (This);\r
54 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
55 switch (Dev->Snm.State) {\r
56 case EfiSimpleNetworkStopped:\r
57 Status = EFI_NOT_STARTED;\r
58 goto Exit;\r
59 case EfiSimpleNetworkStarted:\r
60 Status = EFI_DEVICE_ERROR;\r
61 goto Exit;\r
62 default:\r
63 break;\r
64 }\r
65\r
56f65ed8 66 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r
80682e9b
LE
67 VirtioNetShutdownRx (Dev);\r
68 VirtioNetShutdownTx (Dev);\r
69 VirtioRingUninit (&Dev->TxRing);\r
70 VirtioRingUninit (&Dev->RxRing);\r
71\r
72 Dev->Snm.State = EfiSimpleNetworkStarted;\r
73 Status = EFI_SUCCESS;\r
74\r
75Exit:\r
76 gBS->RestoreTPL (OldTpl);\r
77 return Status;\r
78}\r