SnpStop.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /** @file
  2. Implementation of the SNP.Stop() function and its private helpers if any.
  3. Copyright (C) 2013, Red Hat, Inc.
  4. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Library/UefiBootServicesTableLib.h>
  8. #include "VirtioNet.h"
  9. /**
  10. Changes the state of a network interface from "started" to "stopped".
  11. @param This Protocol instance pointer.
  12. @retval EFI_SUCCESS The network interface was stopped.
  13. @retval EFI_ALREADY_STARTED The network interface is already in the stopped
  14. state.
  15. @retval EFI_INVALID_PARAMETER One or more of the parameters has an
  16. unsupported value.
  17. @retval EFI_DEVICE_ERROR The command could not be sent to the network
  18. interface.
  19. @retval EFI_UNSUPPORTED This function is not supported by the network
  20. interface.
  21. **/
  22. EFI_STATUS
  23. EFIAPI
  24. VirtioNetStop (
  25. IN EFI_SIMPLE_NETWORK_PROTOCOL *This
  26. )
  27. {
  28. VNET_DEV *Dev;
  29. EFI_TPL OldTpl;
  30. EFI_STATUS Status;
  31. if (This == NULL) {
  32. return EFI_INVALID_PARAMETER;
  33. }
  34. Dev = VIRTIO_NET_FROM_SNP (This);
  35. OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
  36. if (Dev->Snm.State != EfiSimpleNetworkStarted) {
  37. Status = EFI_NOT_STARTED;
  38. } else {
  39. Dev->Snm.State = EfiSimpleNetworkStopped;
  40. Status = EFI_SUCCESS;
  41. }
  42. gBS->RestoreTPL (OldTpl);
  43. return Status;
  44. }