]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioNetDxe/SnpStop.c
IntelFsp2Pkg/SplitFspBin.py: Support rebasing 1.x binary.
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpStop.c
1 /** @file
2
3 Implementation of the SNP.Stop() 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
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #include <Library/UefiBootServicesTableLib.h>
13
14 #include "VirtioNet.h"
15
16 /**
17 Changes the state of a network interface from "started" to "stopped".
18
19 @param This Protocol instance pointer.
20
21 @retval EFI_SUCCESS The network interface was stopped.
22 @retval EFI_ALREADY_STARTED The network interface is already in the stopped
23 state.
24 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
25 unsupported value.
26 @retval EFI_DEVICE_ERROR The command could not be sent to the network
27 interface.
28 @retval EFI_UNSUPPORTED This function is not supported by the network
29 interface.
30
31 **/
32
33 EFI_STATUS
34 EFIAPI
35 VirtioNetStop (
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 if (Dev->Snm.State != EfiSimpleNetworkStarted) {
50 Status = EFI_NOT_STARTED;
51 }
52 else {
53 Dev->Snm.State = EfiSimpleNetworkStopped;
54 Status = EFI_SUCCESS;
55 }
56
57 gBS->RestoreTPL (OldTpl);
58 return Status;
59 }