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