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.1221.1589229276069383336 for ; Mon, 11 May 2020 13:34:36 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@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 8005D1FB; Mon, 11 May 2020 13:34:34 -0700 (PDT) Received: from [192.168.122.166] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB15C3F68F; Mon, 11 May 2020 13:34:33 -0700 (PDT) Subject: Re: [PATCH edk2-platforms v4 2/9] Silicon/Broadcom/BcmGenetDxe: add support for broadcast filtering To: Ard Biesheuvel , 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> From: "Jeremy Linton" Message-ID: <75bded16-5c51-967c-17b0-10dd73d669ce@arm.com> Date: Mon, 11 May 2020 15:34:29 -0500 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: <20200511145527.23453-3-ard.biesheuvel@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Hi, 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 > --- > Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h | 7 +++++ > Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c | 33 ++++++++++++++++++++ > 2 files changed, 40 insertions(+) > > diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h 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 @@ > #define GENET_UMAC_MDF_CTRL 0xe50 > #define GENET_UMAC_MDF_ADDR0(n) (0xe54 + (n) * 0x8) > #define GENET_UMAC_MDF_ADDR1(n) (0xe58 + (n) * 0x8) > +#define GENET_MAX_MDF_FILTER 17 > > #define GENET_DMA_DESC_COUNT 256 > #define GENET_DMA_DESC_SIZE 12 > @@ -300,6 +301,12 @@ GenetSetPromisc ( > IN BOOLEAN Enable > ); > > +VOID > +GenetEnableBroadcastFilter ( > + IN GENET_PRIVATE_DATA *Genet, > + IN BOOLEAN Enable > + ); > + > VOID > GenetDmaInitRings ( > IN GENET_PRIVATE_DATA *Genet > diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.c 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 ( > GenetMmioWrite (Genet, GENET_UMAC_CMD, Value); > } > > +/** > + Enable the MAC filter for the Ethernet broadcast address > + > + @param Genet[in] Pointer to GENET_PRIVATE_DATA. > + @param Enable[in] Promiscuous mode state. > + > +**/ > +VOID > +GenetEnableBroadcastFilter ( > + IN GENET_PRIVATE_DATA *Genet, > + IN BOOLEAN Enable > + ) > +{ > + CONST EFI_MAC_ADDRESS *MacAddr = &Genet->SnpMode.CurrentAddress; > + UINT32 Value; > + > + if (Enable) { > + 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); Is this right? Looking at the linux code, it looks like the a filter is enabled in a big endian field starting at bit 16 and working its way down. AFAIK, you want bit 16, and bit 15 set for two filters? > + } else { > + Value = 0; > + } > + GenetMmioWrite (Genet, GENET_UMAC_MDF_CTRL, Value); > +} > + > /** > Configure DMA TX and RX queues, enabling them. > >