3 Implementation of the SNP.ReceiveFilters() function and its private helpers
6 Copyright (C) 2013, Red Hat, Inc.
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/UefiBootServicesTableLib.h>
15 #include "VirtioNet.h"
18 Manages the multicast receive filters of a network interface.
20 @param This The protocol instance pointer.
21 @param Enable A bit mask of receive filters to enable on the
23 @param Disable A bit mask of receive filters to disable on the
25 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast
26 receive filters on the network interface to their
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.
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
42 @retval EFI_DEVICE_ERROR The command could not be sent to the network
44 @retval EFI_UNSUPPORTED This function is not supported by the network
51 VirtioNetReceiveFilters (
52 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
55 IN BOOLEAN ResetMCastFilter
,
56 IN UINTN MCastFilterCnt OPTIONAL
,
57 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
65 return EFI_INVALID_PARAMETER
;
68 Dev
= VIRTIO_NET_FROM_SNP (This
);
69 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
70 switch (Dev
->Snm
.State
) {
71 case EfiSimpleNetworkStopped
:
72 Status
= EFI_NOT_STARTED
;
74 case EfiSimpleNetworkStarted
:
75 Status
= EFI_DEVICE_ERROR
;
82 // MNP apparently fails to initialize on top of us if we simply return
83 // EFI_UNSUPPORTED in this function.
85 // Hence we openly refuse multicast functionality, and fake the rest by
86 // selecting a no stricter filter setting than whatever is requested. The
87 // UEFI-2.3.1+errC spec allows this. In practice we don't change our current
88 // (default) filter. Additionally, receiving software is responsible for
89 // discarding any packets getting through the filter.
92 ((Enable
| Disable
) & ~Dev
->Snm
.ReceiveFilterMask
) != 0 ||
93 (!ResetMCastFilter
&& MCastFilterCnt
> Dev
->Snm
.MaxMCastFilterCount
)
94 ) ? EFI_INVALID_PARAMETER
: EFI_SUCCESS
;
97 gBS
->RestoreTPL (OldTpl
);