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