Browse Source

[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>
tags/v1.20.1
Curtis Larsen 10 years ago
parent
commit
2ce1c70166
1 changed files with 37 additions and 11 deletions
  1. 37
    11
      src/drivers/net/efi/snpnet.c

+ 37
- 11
src/drivers/net/efi/snpnet.c View File

@@ -283,6 +283,42 @@ static void snpnet_poll ( struct net_device *netdev ) {
283 283
 	snpnet_check_link ( netdev );
284 284
 }
285 285
 
286
+/**
287
+ * Set receive filters
288
+ *
289
+ * @v netdev		Network device
290
+ * @ret rc		Return status code
291
+ */
292
+static int snpnet_rx_filters ( struct net_device *netdev ) {
293
+	struct snp_nic *snp = netdev->priv;
294
+	UINT32 filters[] = {
295
+		snp->snp->Mode->ReceiveFilterMask,
296
+		( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
297
+		  EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
298
+		  EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST ),
299
+		( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
300
+		  EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST ),
301
+		( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST ),
302
+	};
303
+	unsigned int i;
304
+	EFI_STATUS efirc;
305
+	int rc;
306
+
307
+	/* Try possible receive filters in turn */
308
+	for ( i = 0; i < ( sizeof ( filters ) / sizeof ( filters[0] ) ); i++ ) {
309
+		efirc = snp->snp->ReceiveFilters ( snp->snp, filters[i],
310
+						   0, TRUE, 0, NULL );
311
+		if ( efirc == 0 )
312
+			return 0;
313
+		rc = -EEFI ( efirc );
314
+		DBGC ( snp, "SNP %s could not set receive filters %#02x (have "
315
+		       "%#02x): %s\n", netdev->name, filters[i],
316
+		       snp->snp->Mode->ReceiveFilterSetting, strerror ( rc ) );
317
+	}
318
+
319
+	return rc;
320
+}
321
+
286 322
 /**
287 323
  * Open network device
288 324
  *
@@ -292,7 +328,6 @@ static void snpnet_poll ( struct net_device *netdev ) {
292 328
 static int snpnet_open ( struct net_device *netdev ) {
293 329
 	struct snp_nic *snp = netdev->priv;
294 330
 	EFI_MAC_ADDRESS *mac = ( ( void * ) netdev->ll_addr );
295
-	UINT32 filters;
296 331
 	EFI_STATUS efirc;
297 332
 	int rc;
298 333
 
@@ -322,16 +357,7 @@ static int snpnet_open ( struct net_device *netdev ) {
322 357
 	}
323 358
 
324 359
 	/* Set receive filters */
325
-	filters = ( EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
326
-		    EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST |
327
-		    EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
328
-		    EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS |
329
-		    EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST );
330
-	if ( ( efirc = snp->snp->ReceiveFilters ( snp->snp, filters, 0, TRUE,
331
-						  0, NULL ) ) != 0 ) {
332
-		rc = -EEFI ( efirc );
333
-		DBGC ( snp, "SNP %s could not set receive filters: %s\n",
334
-		       netdev->name, strerror ( rc ) );
360
+	if ( ( rc = snpnet_rx_filters ( netdev ) ) != 0 ) {
335 361
 		/* Ignore error */
336 362
 	}
337 363
 

Loading…
Cancel
Save