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>
8 This program and the accompanying materials are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/UefiBootServicesTableLib.h>
20 #include "VirtioNet.h"
23 Resets a network adapter and leaves it in a state that is safe for another
26 @param This Protocol instance pointer.
28 @retval EFI_SUCCESS The network interface was shutdown.
29 @retval EFI_NOT_STARTED The network interface has not been started.
30 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
32 @retval EFI_DEVICE_ERROR The command could not be sent to the network
34 @retval EFI_UNSUPPORTED This function is not supported by the network
42 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
50 return EFI_INVALID_PARAMETER
;
53 Dev
= VIRTIO_NET_FROM_SNP (This
);
54 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
55 switch (Dev
->Snm
.State
) {
56 case EfiSimpleNetworkStopped
:
57 Status
= EFI_NOT_STARTED
;
59 case EfiSimpleNetworkStarted
:
60 Status
= EFI_DEVICE_ERROR
;
66 Dev
->VirtIo
->SetDeviceStatus (Dev
->VirtIo
, 0);
67 VirtioNetShutdownRx (Dev
);
68 VirtioNetShutdownTx (Dev
);
69 VirtioRingUninit (&Dev
->TxRing
);
70 VirtioRingUninit (&Dev
->RxRing
);
72 Dev
->Snm
.State
= EfiSimpleNetworkStarted
;
76 gBS
->RestoreTPL (OldTpl
);