mirror of
https://github.com/ipxe/ipxe
synced 2026-01-08 13:11:17 +03:00
[efi] Try various possible SNP receive filters
The behavior observed in the Apple EFI (1.10) RecieveFilters() call
is:
- failure if any of the PROMISCUOUS or MULTICAST filters are
included
- success if only UNICAST is included, however the result is
UNICAST|BROADCAST
- success if only UNICAST and BROADCAST are included
- if UNICAST, or UNICAST|BROADCAST are used, but the previous call
tried (and failed) to set UNICAST|BROADCAST|MULTICAST, then the
result is UNICAST|BROADCAST|MULTICAST
Work around this apparently broken SNP implementation by trying
RecieveFilterMask, then falling back to UNICAST|BROADCAST|MULTICAST,
then UNICAST|BROADCAST, and finally UNICAST.
Modified-by: Michael Brown <mcb30@ipxe.org>
Tested-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
committed by
Michael Brown
parent
7b3cc18462
commit
2ce1c70166
@@ -283,6 +283,42 @@ static void snpnet_poll ( struct net_device *netdev ) {
|
||||
snpnet_check_link ( netdev );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set receive filters
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int snpnet_rx_filters ( struct net_device *netdev ) {
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
UINT32 filters[] = {
|
||||
snp->snp->Mode->ReceiveFilterMask,
|
||||
( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST ),
|
||||
( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST ),
|
||||
( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST ),
|
||||
};
|
||||
unsigned int i;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Try possible receive filters in turn */
|
||||
for ( i = 0; i < ( sizeof ( filters ) / sizeof ( filters[0] ) ); i++ ) {
|
||||
efirc = snp->snp->ReceiveFilters ( snp->snp, filters[i],
|
||||
0, TRUE, 0, NULL );
|
||||
if ( efirc == 0 )
|
||||
return 0;
|
||||
rc = -EEFI ( efirc );
|
||||
DBGC ( snp, "SNP %s could not set receive filters %#02x (have "
|
||||
"%#02x): %s\n", netdev->name, filters[i],
|
||||
snp->snp->Mode->ReceiveFilterSetting, strerror ( rc ) );
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open network device
|
||||
*
|
||||
@@ -292,7 +328,6 @@ static void snpnet_poll ( struct net_device *netdev ) {
|
||||
static int snpnet_open ( struct net_device *netdev ) {
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
EFI_MAC_ADDRESS *mac = ( ( void * ) netdev->ll_addr );
|
||||
UINT32 filters;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
@@ -322,16 +357,7 @@ static int snpnet_open ( struct net_device *netdev ) {
|
||||
}
|
||||
|
||||
/* Set receive filters */
|
||||
filters = ( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS |
|
||||
EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST );
|
||||
if ( ( efirc = snp->snp->ReceiveFilters ( snp->snp, filters, 0, TRUE,
|
||||
0, NULL ) ) != 0 ) {
|
||||
rc = -EEFI ( efirc );
|
||||
DBGC ( snp, "SNP %s could not set receive filters: %s\n",
|
||||
netdev->name, strerror ( rc ) );
|
||||
if ( ( rc = snpnet_rx_filters ( netdev ) ) != 0 ) {
|
||||
/* Ignore error */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user