From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.7679.1589180829676458717 for ; Mon, 11 May 2020 00:07:09 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 675A8D6E; Mon, 11 May 2020 00:07:09 -0700 (PDT) Received: from e123331-lin.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F208B3F68F; Mon, 11 May 2020 00:07:07 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Pete Batard , Jared McNeill , Andrei Warkentin , Samer El-Haj-Mahmoud Subject: [PATCH edk2-platforms v3 3/5] Silicon/Broadcom/BcmGenetDxe: fix multicast/broadcast handling Date: Mon, 11 May 2020 09:06:54 +0200 Message-Id: <20200511070656.32141-4-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511070656.32141-1-ard.biesheuvel@arm.com> References: <20200511070656.32141-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 --- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 7 +++---- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c | 19 ++++++++++++++----- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c | 20 +++++++++----------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c index e3d015dd0820..a6102421cc26 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c @@ -154,11 +154,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/GenetUtil.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c index 2176bb451e7d..746fbfe51b1d 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c @@ -505,13 +505,22 @@ GenetEnableBroadcastFilter ( IN BOOLEAN Enable ) { - UINT32 Value; + CONST EFI_MAC_ADDRESS *MacAddr = &Genet->SnpMode.CurrentAddress; + UINT32 Value; - Value = (1U << GENET_MAX_MDF_FILTER) - 1; if (Enable) { - GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR0 (0), 0xffff); - GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR1 (0), 0xffffffff); - Value &= ~BIT0; + GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR0 (0), + MacAddr->Addr[1] | MacAddr->Addr[0] << 8); + GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR1 (0), + MacAddr->Addr[5] | MacAddr->Addr[4] << 8 | + MacAddr->Addr[3] << 16 | MacAddr->Addr[2] << 24); + + GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR0 (1), 0xffff); + GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR1 (1), 0xffffffff); + + Value = (1U << GENET_MAX_MDF_FILTER) & ~(BIT1 | BIT0); + } else { + Value = 0; } GenetMmioWrite (Genet, GENET_UMAC_MDF_CTRL, Value); } diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/SimpleNetwork.c index bf28448445d1..e6de4653cde9 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