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
36 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
44 return EFI_INVALID_PARAMETER
;
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
;
53 case EfiSimpleNetworkStarted
:
54 Status
= EFI_DEVICE_ERROR
;
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
);
66 Dev
->Snm
.State
= EfiSimpleNetworkStarted
;
70 gBS
->RestoreTPL (OldTpl
);