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 This program and the accompanying materials are licensed and made available
10 under the terms and conditions of the BSD License which accompanies this
11 distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
15 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/UefiBootServicesTableLib.h>
21 #include "VirtioNet.h"
24 Manages the multicast receive filters of a network interface.
26 @param This The protocol instance pointer.
27 @param Enable A bit mask of receive filters to enable on the
29 @param Disable A bit mask of receive filters to disable on the
31 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast
32 receive filters on the network interface to their
34 @param McastFilterCnt Number of multicast HW MAC addresses in the new
35 MCastFilter list. This value must be less than or
36 equal to the MCastFilterCnt field of
37 EFI_SIMPLE_NETWORK_MODE. This field is optional if
38 ResetMCastFilter is TRUE.
39 @param MCastFilter A pointer to a list of new multicast receive filter
40 HW MAC addresses. This list will replace any
41 existing multicast HW MAC address list. This field
42 is optional if ResetMCastFilter is TRUE.
44 @retval EFI_SUCCESS The multicast receive filter list was updated.
45 @retval EFI_NOT_STARTED The network interface has not been started.
46 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
48 @retval EFI_DEVICE_ERROR The command could not be sent to the network
50 @retval EFI_UNSUPPORTED This function is not supported by the network
57 VirtioNetReceiveFilters (
58 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
61 IN BOOLEAN ResetMCastFilter
,
62 IN UINTN MCastFilterCnt OPTIONAL
,
63 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
71 return EFI_INVALID_PARAMETER
;
74 Dev
= VIRTIO_NET_FROM_SNP (This
);
75 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
76 switch (Dev
->Snm
.State
) {
77 case EfiSimpleNetworkStopped
:
78 Status
= EFI_NOT_STARTED
;
80 case EfiSimpleNetworkStarted
:
81 Status
= EFI_DEVICE_ERROR
;
88 // MNP apparently fails to initialize on top of us if we simply return
89 // EFI_UNSUPPORTED in this function.
91 // Hence we openly refuse multicast functionality, and fake the rest by
92 // selecting a no stricter filter setting than whatever is requested. The
93 // UEFI-2.3.1+errC spec allows this. In practice we don't change our current
94 // (default) filter. Additionally, receiving software is responsible for
95 // discarding any packets getting through the filter.
98 ((Enable
| Disable
) & ~Dev
->Snm
.ReceiveFilterMask
) != 0 ||
99 (!ResetMCastFilter
&& MCastFilterCnt
> Dev
->Snm
.MaxMCastFilterCount
)
100 ) ? EFI_INVALID_PARAMETER
: EFI_SUCCESS
;
103 gBS
->RestoreTPL (OldTpl
);