]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpReceiveFilters.c
1 /** @file
2
3 Implementation of the SNP.ReceiveFilters() function and its private helpers
4 if any.
5
6 Copyright (C) 2013, Red Hat, Inc.
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 **/
12
13 #include <Library/UefiBootServicesTableLib.h>
14
15 #include "VirtioNet.h"
16
17 /**
18 Manages the multicast receive filters of a network interface.
19
20 @param This The protocol instance pointer.
21 @param Enable A bit mask of receive filters to enable on the
22 network interface.
23 @param Disable A bit mask of receive filters to disable on the
24 network interface.
25 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast
26 receive filters on the network interface to their
27 default values.
28 @param McastFilterCnt Number of multicast HW MAC addresses in the new
29 MCastFilter list. This value must be less than or
30 equal to the MCastFilterCnt field of
31 EFI_SIMPLE_NETWORK_MODE. This field is optional if
32 ResetMCastFilter is TRUE.
33 @param MCastFilter A pointer to a list of new multicast receive filter
34 HW MAC addresses. This list will replace any
35 existing multicast HW MAC address list. This field
36 is optional if ResetMCastFilter is TRUE.
37
38 @retval EFI_SUCCESS The multicast receive filter list was updated.
39 @retval EFI_NOT_STARTED The network interface has not been started.
40 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
41 unsupported value.
42 @retval EFI_DEVICE_ERROR The command could not be sent to the network
43 interface.
44 @retval EFI_UNSUPPORTED This function is not supported by the network
45 interface.
46
47 **/
48 EFI_STATUS
49 EFIAPI
50 VirtioNetReceiveFilters (
51 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
52 IN UINT32 Enable,
53 IN UINT32 Disable,
54 IN BOOLEAN ResetMCastFilter,
55 IN UINTN MCastFilterCnt OPTIONAL,
56 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
57 )
58 {
59 VNET_DEV *Dev;
60 EFI_TPL OldTpl;
61 EFI_STATUS Status;
62
63 if (This == NULL) {
64 return EFI_INVALID_PARAMETER;
65 }
66
67 Dev = VIRTIO_NET_FROM_SNP (This);
68 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
69 switch (Dev->Snm.State) {
70 case EfiSimpleNetworkStopped:
71 Status = EFI_NOT_STARTED;
72 goto Exit;
73 case EfiSimpleNetworkStarted:
74 Status = EFI_DEVICE_ERROR;
75 goto Exit;
76 default:
77 break;
78 }
79
80 //
81 // MNP apparently fails to initialize on top of us if we simply return
82 // EFI_UNSUPPORTED in this function.
83 //
84 // Hence we openly refuse multicast functionality, and fake the rest by
85 // selecting a no stricter filter setting than whatever is requested. The
86 // UEFI-2.3.1+errC spec allows this. In practice we don't change our current
87 // (default) filter. Additionally, receiving software is responsible for
88 // discarding any packets getting through the filter.
89 //
90 Status = (
91 ((Enable | Disable) & ~Dev->Snm.ReceiveFilterMask) != 0 ||
92 (!ResetMCastFilter && MCastFilterCnt > Dev->Snm.MaxMCastFilterCount)
93 ) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
94
95 Exit:
96 gBS->RestoreTPL (OldTpl);
97 return Status;
98 }