3 Implementation of the SNP.Shutdown() function and its private helpers if any.
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>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/UefiBootServicesTableLib.h>
15 #include "VirtioNet.h"
18 Resets a network adapter and leaves it in a state that is safe for another
21 @param This Protocol instance pointer.
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
27 @retval EFI_DEVICE_ERROR The command could not be sent to the network
29 @retval EFI_UNSUPPORTED This function is not supported by the network
37 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
45 return EFI_INVALID_PARAMETER
;
48 Dev
= VIRTIO_NET_FROM_SNP (This
);
49 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
50 switch (Dev
->Snm
.State
) {
51 case EfiSimpleNetworkStopped
:
52 Status
= EFI_NOT_STARTED
;
54 case EfiSimpleNetworkStarted
:
55 Status
= EFI_DEVICE_ERROR
;
61 Dev
->VirtIo
->SetDeviceStatus (Dev
->VirtIo
, 0);
62 VirtioNetShutdownRx (Dev
);
63 VirtioNetShutdownTx (Dev
);
64 VirtioNetUninitRing (Dev
, &Dev
->TxRing
, Dev
->TxRingMap
);
65 VirtioNetUninitRing (Dev
, &Dev
->RxRing
, Dev
->RxRingMap
);
67 Dev
->Snm
.State
= EfiSimpleNetworkStarted
;
71 gBS
->RestoreTPL (OldTpl
);