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.2139.1589232097229942145 for ; Mon, 11 May 2020 14:21:37 -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 9CB501FB; Mon, 11 May 2020 14:21:36 -0700 (PDT) Received: from [192.168.1.81] (unknown [10.37.8.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 098AF3F68F; Mon, 11 May 2020 14:21:34 -0700 (PDT) Subject: Re: [PATCH edk2-platforms v4 2/9] Silicon/Broadcom/BcmGenetDxe: add support for broadcast filtering To: Jeremy Linton , devel@edk2.groups.io Cc: Pete Batard , Jared McNeill , Andrei Warkentin , Samer El-Haj-Mahmoud References: <20200511145527.23453-1-ard.biesheuvel@arm.com> <20200511145527.23453-3-ard.biesheuvel@arm.com> <75bded16-5c51-967c-17b0-10dd73d669ce@arm.com> From: "Ard Biesheuvel" Message-ID: Date: Mon, 11 May 2020 23:21:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <75bded16-5c51-967c-17b0-10dd73d669ce@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 5/11/20 10:34 PM, Jeremy Linton wrote: > Hi, >=20 > On 5/11/20 9:55 AM, Ard Biesheuvel wrote: >> Add a helper to configure the first MDF filter for filtering the >> broadcast Ethernet address. >> >> Signed-off-by: Ard Biesheuvel >> --- >> =C2=A0 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h |=C2=A0 7 = +++++ >> =C2=A0 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c | 33=20 >> ++++++++++++++++++++ >> =C2=A0 2 files changed, 40 insertions(+) >> >> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h=20 >> b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h >> index b21a284b6221..b491ea4665b0 100644 >> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h >> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h >> @@ -107,6 +107,7 @@ >> =C2=A0 #define GENET_UMAC_MDF_CTRL=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 0xe50 >> =C2=A0 #define GENET_UMAC_MDF_ADDR0(n)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (0xe54 + = (n) * 0x8) >> =C2=A0 #define GENET_UMAC_MDF_ADDR1(n)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (0xe58 + = (n) * 0x8) >> +#define GENET_MAX_MDF_FILTER=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = 17 >> =C2=A0 #define GENET_DMA_DESC_COUNT=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 256 >> =C2=A0 #define GENET_DMA_DESC_SIZE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 12 >> @@ -300,6 +301,12 @@ GenetSetPromisc ( >> =C2=A0=C2=A0=C2=A0 IN BOOLEAN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Enable >> =C2=A0=C2=A0=C2=A0 ); >> +VOID >> +GenetEnableBroadcastFilter ( >> +=C2=A0 IN GENET_PRIVATE_DATA=C2=A0=C2=A0 *Genet, >> +=C2=A0 IN BOOLEAN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Enable >> +=C2=A0 ); >> + >> =C2=A0 VOID >> =C2=A0 GenetDmaInitRings ( >> =C2=A0=C2=A0=C2=A0 IN GENET_PRIVATE_DATA *Genet >> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c=20 >> b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c >> index 7ae9acec4c78..71c659e7f882 100644 >> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c >> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c >> @@ -492,6 +492,39 @@ GenetSetPromisc ( >> =C2=A0=C2=A0=C2=A0 GenetMmioWrite (Genet, GENET_UMAC_CMD, Value); >> =C2=A0 } >> +/** >> +=C2=A0 Enable the MAC filter for the Ethernet broadcast address >> + >> +=C2=A0 @param=C2=A0 Genet[in]=C2=A0=C2=A0 Pointer to GENET_PRIVATE_DA= TA. >> +=C2=A0 @param=C2=A0 Enable[in]=C2=A0 Promiscuous mode state. >> + >> +**/ >> +VOID >> +GenetEnableBroadcastFilter ( >> +=C2=A0 IN GENET_PRIVATE_DATA=C2=A0=C2=A0 *Genet, >> +=C2=A0 IN BOOLEAN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Enable >> +=C2=A0 ) >> +{ >> +=C2=A0 CONST EFI_MAC_ADDRESS=C2=A0=C2=A0 *MacAddr =3D &Genet->SnpMode= .CurrentAddress; >> +=C2=A0 UINT32=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Value; >> + >> +=C2=A0 if (Enable) { >> +=C2=A0=C2=A0=C2=A0 GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR0 (0), >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MacAddr->Addr[1] | MacAddr->Addr[0] <<= 8); >> +=C2=A0=C2=A0=C2=A0 GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR1 (0), >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MacAddr->Addr[5] | MacAddr->Addr[4] <<= 8 | >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MacAddr->Addr[3] << 16 | MacAddr->Addr= [2] << 24); >> + >> +=C2=A0=C2=A0=C2=A0 GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR0 (1), 0= xffff); >> +=C2=A0=C2=A0=C2=A0 GenetMmioWrite (Genet, GENET_UMAC_MDF_ADDR1 (1), 0= xffffffff); >> + >> +=C2=A0=C2=A0=C2=A0 Value =3D (1U << GENET_MAX_MDF_FILTER) & ~(BIT1 | = BIT0); > Is this right? Looking at the linux code, it looks like the a filter is= =20 > enabled in a big endian field starting at bit 16 and working its way do= wn. >=20 > AFAIK, you want bit 16, and bit 15 set for two filters? >=20 Yeah, you're right. I was reading both the BSD code and Linux code=20 wrong. That solves the mystery why value =3D 0x0 works as expected as wel= l. So I will change this to Value =3D BIT16 | BIT15; instead. Thanks,