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