public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: Jeremy Linton <jeremy.linton@arm.com>, devel@edk2.groups.io
Cc: 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>
Subject: Re: [PATCH edk2-platforms v4 2/9] Silicon/Broadcom/BcmGenetDxe: add support for broadcast filtering
Date: Mon, 11 May 2020 23:21:29 +0200	[thread overview]
Message-ID: <eef27465-7d75-43a2-c84f-fa40e1d96d69@arm.com> (raw)
In-Reply-To: <75bded16-5c51-967c-17b0-10dd73d669ce@arm.com>

On 5/11/20 10:34 PM, Jeremy Linton wrote:
> 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 <ard.biesheuvel@arm.com>
>> ---
>>   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?
> 

Yeah, you're right. I was reading both the BSD code and Linux code 
wrong. That solves the mystery why value = 0x0 works as expected as well.

So I will change this to

Value = BIT16 | BIT15;

instead.

Thanks,






  reply	other threads:[~2020-05-11 21:21 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 [this message]
2020-05-11 14:55 ` [PATCH edk2-platforms v4 3/9] Silicon/Broadcom/BcmGenetDxe: fix multicast/broadcast handling Ard Biesheuvel
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=eef27465-7d75-43a2-c84f-fa40e1d96d69@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