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