IMXRT CRC32 for multicast address filter

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

IMXRT CRC32 for multicast address filter

985 次查看
jakechoy
Contributor I
I'm trying to use the imxrt enet hardware to filter multicast IP addresses.
From the reference manual.
The user must initialize the hash table registers. Use this CRC32 polynomial to compute the hash:
• FCS(x) = x32+ x26+ x23+ x22+ x16+ x12+ x11+ x10+ x8+ x7+ x5+ x4+ x2+ x1+ 1
I am using the crc function below but I'm not able to produce the same crc output as the imrxt hardware crc32 generator.
static uint32_t imxrt_calcethcrc(const uint8_t *data, size_t length)
{
  uint32_t crc = 0xffffffff;
  size_t i;
  int j;
  for (i = 0; i < length; i++)
    {
      for (j = 0; j < 8; j++)
        {
          if (((crc >> 31) ^ (data[i] >> j)) & 0x01)
            {
              /* x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1 */
              crc = (crc << 1) ^ 0x04c11db7;
            }
          else
            {
              crc = crc << 1;
            }
        }
    }
  return ~crc;
}
The 48-bit destination address is mapped into one of 64 bits, represented by 64 bits in
ENETn_GAUR/GALR (group address hash match) or ENETn_IAUR/IALR
(individual address hash match).
• This mapping is performed by passing the 48-bit address through the on-chip 32-bit
CRC generator and selecting the six most significant bits of the CRC-encoded result
to generate a number between 0 and 63.
The IP I'm using is "239.255.0.1" which is 0x0100ffef. This will map to a MAC of 0x01005E7F0001 from the IETF IN RFC 1700.
The calculated crc32 is 0xc9579861 which produces a hashindex of 8. This will set the 8th bit in register IMXRT_ENET_GALR.
But this filter does not let the above IP through. I found the first bit of IMXRT_ENET_GAUR needs to be set for the IP to go through.
This means the crc calculation does not match the hardware crc generator. 
Does anyone have any insight into what the problem is or know an equivalent algorithm to the hardware CRC32 generator?
Jake
0 项奖励
回复
2 回复数

830 次查看
jakechoy
Contributor I

Thanks for your response Carlos. The correct crc32 algorithm can be found in this post:

https://community.nxp.com/thread/445605

0 项奖励
回复

830 次查看
CarlosCasillas
NXP Employee
NXP Employee

Hi Jake,

Have you verified data sizes of the used variables for software CRC calculations, in order to avoid overflows?

You could also take a look at the following link:

https://community.nxp.com/message/957904


Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复