AnsweredAssumed Answered

Calculating Ethernet Multicast filter HASH value (?)

Question asked by mjbcswitzerland on May 23, 2014
Latest reply on May 24, 2014 by mjbcswitzerland
Hi All

It is strange but I can't find any code example of how to set up the Ethernet HASH filter for multicast reception. There was a question in 2011 in this forum as to the same but it was not answered - so I will try again.

At the moment I am working with the ALL MULTICAST bit set so that all multicast frames are received - the reason being that the HASH calculation is presently making no sense.

An example - I join a multicast group and would like to set a multicast filter on the corresponding MAC address 01 00 5e 00 00 21
The CRC-32 calculation of this is 0xe2dae536 - taking the 6 MS bits it gives the hash 0x38 so the 24th bit in the high hash register is set.
The result is however no reception on the address. Playing around with the bits in the HASH registers it is found, by trial-and-error, that reception works when the 5th bit in that register is set instead (hash value 0x24)

OK - I thought - there must be a mis-understanding in the calculation so I studied the user's manual again and looked at two examples that are given there:
- 1f52 419c b6af   should give 0x2c (bit 12 to be set in the high register)
- a00a 9800 0045 should give 0x07 (7th bit in the low register)

When I put these through a CRC-32 IEEE calculation with CRC primed with 0xffffffff I get
0xdd39bb32 and 0x63d32b47 respectively, meaning that they would give HASH values of 0x37 and 0x18 respectively, not as the user's manual suggests and presumably also giving incorrect filtering results.

The CRC32 IEEE calculation I use is used in other projects and also matches with a HW CRC-32 IEEE result, confirmed by calculating Ethernet frame content too. It also works as expected when used to calculate HASH values for other Ethernet multicasting applications with other devices using the same technique, and having essentially identical instructions in their user manuals.

So the questions are:
- What is the calculation to be used to get the HASH setting correct?
- Is there any code that uses this? (I find plenty of multi-casting code in examples but with nothing more than a note to say  that the filter could be set up if required - is this because no code has successfully been able to do it??)