]>
Commit | Line | Data |
---|---|---|
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 | 8 | \r |
b26f0cf9 | 9 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
80682e9b LE |
10 | \r |
11 | **/\r | |
12 | \r | |
13 | #include <Library/UefiBootServicesTableLib.h>\r | |
14 | \r | |
15 | #include "VirtioNet.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Resets a network adapter and leaves it in a state that is safe for another\r | |
19 | driver to initialize.\r | |
20 | \r | |
21 | @param This Protocol instance pointer.\r | |
22 | \r | |
23 | @retval EFI_SUCCESS The network interface was shutdown.\r | |
24 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
25 | @retval EFI_INVALID_PARAMETER One or more of the parameters has an\r | |
26 | unsupported value.\r | |
27 | @retval EFI_DEVICE_ERROR The command could not be sent to the network\r | |
28 | interface.\r | |
29 | @retval EFI_UNSUPPORTED This function is not supported by the network\r | |
30 | interface.\r | |
31 | \r | |
32 | **/\r | |
33 | \r | |
34 | EFI_STATUS\r | |
35 | EFIAPI\r | |
36 | VirtioNetShutdown (\r | |
37 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r | |
38 | )\r | |
39 | {\r | |
40 | VNET_DEV *Dev;\r | |
41 | EFI_TPL OldTpl;\r | |
42 | EFI_STATUS Status;\r | |
43 | \r | |
44 | if (This == NULL) {\r | |
45 | return EFI_INVALID_PARAMETER;\r | |
46 | }\r | |
47 | \r | |
48 | Dev = VIRTIO_NET_FROM_SNP (This);\r | |
49 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
50 | switch (Dev->Snm.State) {\r | |
51 | case EfiSimpleNetworkStopped:\r | |
52 | Status = EFI_NOT_STARTED;\r | |
53 | goto Exit;\r | |
54 | case EfiSimpleNetworkStarted:\r | |
55 | Status = EFI_DEVICE_ERROR;\r | |
56 | goto Exit;\r | |
57 | default:\r | |
58 | break;\r | |
59 | }\r | |
60 | \r | |
56f65ed8 | 61 | Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r |
80682e9b LE |
62 | VirtioNetShutdownRx (Dev);\r |
63 | VirtioNetShutdownTx (Dev);\r | |
940baec0 BS |
64 | VirtioNetUninitRing (Dev, &Dev->TxRing, Dev->TxRingMap);\r |
65 | VirtioNetUninitRing (Dev, &Dev->RxRing, Dev->RxRingMap);\r | |
80682e9b LE |
66 | \r |
67 | Dev->Snm.State = EfiSimpleNetworkStarted;\r | |
68 | Status = EFI_SUCCESS;\r | |
69 | \r | |
70 | Exit:\r | |
71 | gBS->RestoreTPL (OldTpl);\r | |
72 | return Status;\r | |
73 | }\r |