cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet MAC Filtering

Pilous Droip
Senior

Good morning friends,

Now I receive multicast on STM32F437, it works. But I would like to add filtering. And I have a problem with that.

IGMP and others, I have it enabled.

Now my settings.

macinit.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_PERFECT;

 My test source MAC address. This is multicast source data

02:00:00:1A:95:A1

From the reference manual, I need to set MACA0HR and MACA0LR to enable filtering.

(heth->Instance)->MACA0LR=0x1A000002;
(heth->Instance)->MACA0HR=0x8000A195;

Reference Manual: https://www.st.com/resource/en/reference_manual/DM00031020-.pdf

And the filtering doesn't work. I am not receiving any multicast packets. Any idea, what is wrong?

My settings of MACFFR

macinit.ReceiveAll = ETH_RECEIVEAll_DISABLE;
macinit.SourceAddrFilter = ETH_SOURCEADDRFILTER_DISABLE;
macinit.PassControlFrames = ETH_PASSCONTROLFRAMES_BLOCKALL;
macinit.BroadcastFramesReception = ETH_BROADCASTFRAMESRECEPTION_ENABLE;
macinit.DestinationAddrFilter = ETH_DESTINATIONADDRFILTER_NORMAL;
macinit.PromiscuousMode = ETH_PROMISCUOUS_MODE_DISABLE;
macinit.MulticastFramesFilter = ETH_MULTICASTFRAMESFILTER_PERFECT;
macinit.UnicastFramesFilter = ETH_UNICASTFRAMESFILTER_PERFECT;
 
/*----------------------- ETHERNET MACFFR Configuration --------------------*/ 
  /* Set the RA bit according to ETH ReceiveAll value */
  /* Set the SAF and SAIF bits according to ETH SourceAddrFilter value */
  /* Set the PCF bit according to ETH PassControlFrames value */
  /* Set the DBF bit according to ETH BroadcastFramesReception value */
  /* Set the DAIF bit according to ETH DestinationAddrFilter value */
  /* Set the PR bit according to ETH PromiscuousMode value */
  /* Set the PM, HMC and HPF bits according to ETH MulticastFramesFilter value */
  /* Set the HUC and HPF bits according to ETH UnicastFramesFilter value */
  /* Write to ETHERNET MACFFR */  
  (heth->Instance)->MACFFR = (uint32_t)(macinit.ReceiveAll | 
                                        macinit.SourceAddrFilter |
                                        macinit.PassControlFrames |
                                        macinit.BroadcastFramesReception | 
                                        macinit.DestinationAddrFilter |
                                        macinit.PromiscuousMode |
                                        macinit.MulticastFramesFilter |
                                        macinit.UnicastFramesFilter);

4 REPLIES 4

> And the filtering doesn't work. I am not receiving any multicast packets. Any idea, what is wrong?

No, and I'm also not going to delve deeper into this, but to remove one degree of uncertainty (i.e. bugs in Cube/HAL), read out and post the relevant ETH registers content.

JW

@Piranha​ , as the local ETH expert, can you please have a look?

Piranha
Chief II

Honestly, I haven't used filtering, but the problem in this case is simple. Multicast filtering is done on destination (group) MAC address, not source address. And, if we think more about it, listening to a group but then filtering on a single source address actually doesn't make sense.

Also this could be relevant, if IP layer multicasting is used:

https://en.wikipedia.org/wiki/IP_multicast#Layer_2_delivery

Pilous Droip
Senior

@Piranha​ . Thank you for showing the way to the goal. I am currently studying it. If I get the right result, I'll show the source codes to others as well. 👍

Pilous Droip
Senior

Here is a very useful calculator:http://www.dqnetworks.ie/toolsinfo.d/multicastaddressing.html

And here is more information: https://networklessons.com/multicast/multicast-ip-address-to-mac-address-mapping

When I set these 2 registers (MACA0LR and MACA0HR) correctly everything works. Thank you for your help @Piranha​