]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/SnpReceiveFilters.c
OvmfPkg/EnrollDefaultKeys: enroll PK/KEK1 from the Type 11 SMBIOS table
[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
48\r
49EFI_STATUS\r
50EFIAPI\r
51VirtioNetReceiveFilters (\r
52 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r
53 IN UINT32 Enable,\r
54 IN UINT32 Disable,\r
55 IN BOOLEAN ResetMCastFilter,\r
56 IN UINTN MCastFilterCnt OPTIONAL,\r
57 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r
58 )\r
59{\r
60 VNET_DEV *Dev;\r
61 EFI_TPL OldTpl;\r
62 EFI_STATUS Status;\r
63\r
64 if (This == NULL) {\r
65 return EFI_INVALID_PARAMETER;\r
66 }\r
67\r
68 Dev = VIRTIO_NET_FROM_SNP (This);\r
69 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
70 switch (Dev->Snm.State) {\r
71 case EfiSimpleNetworkStopped:\r
72 Status = EFI_NOT_STARTED;\r
73 goto Exit;\r
74 case EfiSimpleNetworkStarted:\r
75 Status = EFI_DEVICE_ERROR;\r
76 goto Exit;\r
77 default:\r
78 break;\r
79 }\r
80\r
81 //\r
82 // MNP apparently fails to initialize on top of us if we simply return\r
83 // EFI_UNSUPPORTED in this function.\r
84 //\r
85 // Hence we openly refuse multicast functionality, and fake the rest by\r
86 // selecting a no stricter filter setting than whatever is requested. The\r
87 // UEFI-2.3.1+errC spec allows this. In practice we don't change our current\r
88 // (default) filter. Additionally, receiving software is responsible for\r
89 // discarding any packets getting through the filter.\r
90 //\r
91 Status = (\r
92 ((Enable | Disable) & ~Dev->Snm.ReceiveFilterMask) != 0 ||\r
93 (!ResetMCastFilter && MCastFilterCnt > Dev->Snm.MaxMCastFilterCount)\r
94 ) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;\r
95\r
96Exit:\r
97 gBS->RestoreTPL (OldTpl);\r
98 return Status;\r
99}\r