public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>,
	Pete Batard <pete@akeo.ie>, Jared McNeill <jmcneill@invisible.ca>,
	Andrei Warkentin <awarkentin@vmware.com>,
	Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>,
	Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH edk2-platforms v4 3/9] Silicon/Broadcom/BcmGenetDxe: fix multicast/broadcast handling
Date: Mon, 11 May 2020 16:55:21 +0200	[thread overview]
Message-ID: <20200511145527.23453-4-ard.biesheuvel@arm.com> (raw)
In-Reply-To: <20200511145527.23453-1-ard.biesheuvel@arm.com>

Move the handling of the promiscuous receive control to the SNP
ReceiveFilters() method where it belongs. Given that we do not
support multicast filtering, only minimal handling is required to
test the promiscuous bit and program the MAC accordingly. Any
multicast handling will be done by the MNP layer above it.

For reception of broadcast frames, wire up the new helper that
programs the MDF filter bank accordingly.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c |  7 +++----
 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c | 20 +++++++++-----------
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
index c23847ba9b52..dacb3ac7d762 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
@@ -152,11 +152,10 @@ GenetDriverBindingStart (
   Genet->SnpMode.NvRamSize              = 0;
   Genet->SnpMode.NvRamAccessSize        = 0;
   Genet->SnpMode.ReceiveFilterMask      = 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;
-  Genet->SnpMode.ReceiveFilterSetting   = Genet->SnpMode.ReceiveFilterMask;
+                                          EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;
+  Genet->SnpMode.ReceiveFilterSetting   = EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
+                                          EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;
   Genet->SnpMode.MaxMCastFilterCount    = 0;
   Genet->SnpMode.MCastFilterCount       = 0;
   Genet->SnpMode.IfType                 = NET_IFTYPE_ETHERNET;
diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c
index 951495127ce9..72ab55619b0e 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c
@@ -148,10 +148,6 @@ GenetSimpleNetworkInitialize (
   }
 
   GenetSetMacAddress (Genet, &Genet->SnpMode.CurrentAddress);
-  /*
-   * TODO: this belongs in GenetSimpleNetworkReceiveFilters, not here.
-   */
-  GenetSetPromisc (Genet, TRUE);
 
   GenetDmaInitRings (Genet);
 
@@ -306,6 +302,10 @@ GenetSimpleNetworkReceiveFilters (
   }
 
   Genet = GENET_PRIVATE_DATA_FROM_SNP_THIS (This);
+  if (((Enable | Disable) & ~Genet->SnpMode.ReceiveFilterMask) != 0 ||
+      (!ResetMCastFilter && MCastFilterCnt > Genet->SnpMode.MaxMCastFilterCount)) {
+    return EFI_INVALID_PARAMETER;
+  }
   if (Genet->SnpMode.State == EfiSimpleNetworkStopped) {
     return EFI_NOT_STARTED;
   }
@@ -313,13 +313,11 @@ GenetSimpleNetworkReceiveFilters (
     return EFI_DEVICE_ERROR;
   }
 
-  //
-  // Can't actually return EFI_UNSUPPORTED, so just ignore the filters
-  // (we set promiscuous mode ON inside GenetSimpleNetworkInitialize).
-  //
-  // TODO: move promisc handling here.
-  // TODO 2: support multicast/broadcast.
-  //
+  GenetEnableBroadcastFilter (Genet,
+    (Enable & ~Disable & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) != 0);
+
+  GenetSetPromisc (Genet,
+    (Enable & ~Disable & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0);
 
   return EFI_SUCCESS;
 }
-- 
2.17.1


  parent reply	other threads:[~2020-05-11 14:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 14:55 [PATCH edk2-platforms v4 0/9] BCM genet fixes Ard Biesheuvel
2020-05-11 14:55 ` [PATCH edk2-platforms v4 1/9] Silicon/Broadcom/BcmGenetDxe: whitespace/cosmetic cleanup Ard Biesheuvel
2020-05-11 16:36   ` Samer El-Haj-Mahmoud
2020-05-11 21:14   ` [edk2-devel] " Philippe Mathieu-Daudé
2020-05-11 14:55 ` [PATCH edk2-platforms v4 2/9] Silicon/Broadcom/BcmGenetDxe: add support for broadcast filtering Ard Biesheuvel
2020-05-11 16:44   ` Andrei Warkentin
2020-05-11 20:34   ` Jeremy Linton
2020-05-11 21:21     ` Ard Biesheuvel
2020-05-11 14:55 ` Ard Biesheuvel [this message]
2020-05-11 14:55 ` [PATCH edk2-platforms v4 4/9] Silicon/Broadcom/BcmGenetDxe: avoid uncached memory for streaming DMA Ard Biesheuvel
2020-05-11 16:42   ` Andrei Warkentin
2020-05-11 16:53     ` Ard Biesheuvel
2020-05-11 14:55 ` [PATCH edk2-platforms v4 5/9] Silicon/Broadcom/BcmGenetDxe: shut down devices on ExitBootServices() Ard Biesheuvel
2020-05-11 16:32   ` Andrei Warkentin
2020-05-11 14:55 ` [PATCH edk2-platforms v4 6/9] Silicon/Broadcom/BcmGenetDxe: keep TX buffer mapped during DMA transfer Ard Biesheuvel
2020-05-11 16:19   ` Andrei Warkentin
2020-05-11 14:55 ` [PATCH edk2-platforms v4 7/9] Silicon/Broadcom/BcmGenetDxe: use MemoryFence() for MMIO write ordering Ard Biesheuvel
2020-05-11 16:55   ` [edk2-devel] " Andrei Warkentin
2020-05-11 21:11   ` Philippe Mathieu-Daudé
2020-05-11 14:55 ` [PATCH edk2-platforms v4 8/9] Silicon/Broadcom/BcmGenetDxe: add unload support Ard Biesheuvel
2020-05-11 16:17   ` Andrei Warkentin
2020-05-11 14:55 ` [PATCH edk2-platforms v4 9/9] Platform/RaspberryPi4: remove ASIX 88772b driver Ard Biesheuvel
2020-05-11 16:06   ` Andrei Warkentin
2020-05-11 16:24   ` Samer El-Haj-Mahmoud
2020-05-11 23:20 ` [PATCH edk2-platforms v4 0/9] BCM genet fixes Jeremy Linton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200511145527.23453-4-ard.biesheuvel@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox