]>
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 | |
80682e9b LE |
33 | EFI_STATUS\r |
34 | EFIAPI\r | |
35 | VirtioNetShutdown (\r | |
ac0a286f | 36 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This\r |
80682e9b LE |
37 | )\r |
38 | {\r | |
ac0a286f MK |
39 | VNET_DEV *Dev;\r |
40 | EFI_TPL OldTpl;\r | |
41 | EFI_STATUS Status;\r | |
80682e9b LE |
42 | \r |
43 | if (This == NULL) {\r | |
44 | return EFI_INVALID_PARAMETER;\r | |
45 | }\r | |
46 | \r | |
ac0a286f | 47 | Dev = VIRTIO_NET_FROM_SNP (This);\r |
80682e9b LE |
48 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r |
49 | switch (Dev->Snm.State) {\r | |
ac0a286f MK |
50 | case EfiSimpleNetworkStopped:\r |
51 | Status = EFI_NOT_STARTED;\r | |
52 | goto Exit;\r | |
53 | case EfiSimpleNetworkStarted:\r | |
54 | Status = EFI_DEVICE_ERROR;\r | |
55 | goto Exit;\r | |
56 | default:\r | |
57 | break;\r | |
80682e9b LE |
58 | }\r |
59 | \r | |
56f65ed8 | 60 | Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);\r |
80682e9b LE |
61 | VirtioNetShutdownRx (Dev);\r |
62 | VirtioNetShutdownTx (Dev);\r | |
940baec0 BS |
63 | VirtioNetUninitRing (Dev, &Dev->TxRing, Dev->TxRingMap);\r |
64 | VirtioNetUninitRing (Dev, &Dev->RxRing, Dev->RxRingMap);\r | |
80682e9b LE |
65 | \r |
66 | Dev->Snm.State = EfiSimpleNetworkStarted;\r | |
ac0a286f | 67 | Status = EFI_SUCCESS;\r |
80682e9b LE |
68 | \r |
69 | Exit:\r | |
70 | gBS->RestoreTPL (OldTpl);\r | |
71 | return Status;\r | |
72 | }\r |