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;
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;
crc = crc << 1;
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 "18.104.22.168" 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?