Address hashing in FEC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Address hashing in FEC

Jump to solution
1,815 Views
ynaught
Contributor III
I'm now initializing the FEC in my MCF5270 and am a bit puzzled by the Hash tables' configuration.
 
I think the explanation is clear enough, but am I correct in assuming that the table of MAC addresses and their coresponding hashes (Table 19-36, p. 19-43, MCF5271RM) is totally without value to me, except perhaps for validating my own algorithm?
 
As I read it, the only way to correctly configure this table is to write my own CRC32 algorithm, just to generate the 6-bit hash.  Is there some way I can leverage the hardware CRC generator for this?
 
TIA
 
Labels (1)
0 Kudos
1 Solution
456 Views
mnorman
NXP Employee
NXP Employee
You do have to calculate the hash value in software.  Here is a routine to do it:
 
/********************************************************************/
/*
 * Generate the hash table settings for the given address
 *
 * Parameters:
 *  addr    48-bit (6 byte) Address to generate the hash for
 *
 * Return Value:
 *  The 6 most significant bits of the 32-bit CRC result
 */
uint8
fec_hash_address(const uint8* addr)
{
    uint32 crc;
    uint8 byte;
    int i, j;
    crc = 0xFFFFFFFF;
    for(i=0; i<6; ++i)
    {
        byte = addr[i];
        for(j=0; j<8; ++j)
        {
            if((byte & 0x01)^(crc & 0x01))
            {
                crc >>= 1;
                crc = crc ^ 0xEDB88320;
            }
            else
                crc >>= 1;
            byte >>= 1;
        }
    }
    return (uint8)(crc >> 26);
}
/********************************************************************/

-mnorman


View solution in original post

0 Kudos
2 Replies
457 Views
mnorman
NXP Employee
NXP Employee
You do have to calculate the hash value in software.  Here is a routine to do it:
 
/********************************************************************/
/*
 * Generate the hash table settings for the given address
 *
 * Parameters:
 *  addr    48-bit (6 byte) Address to generate the hash for
 *
 * Return Value:
 *  The 6 most significant bits of the 32-bit CRC result
 */
uint8
fec_hash_address(const uint8* addr)
{
    uint32 crc;
    uint8 byte;
    int i, j;
    crc = 0xFFFFFFFF;
    for(i=0; i<6; ++i)
    {
        byte = addr[i];
        for(j=0; j<8; ++j)
        {
            if((byte & 0x01)^(crc & 0x01))
            {
                crc >>= 1;
                crc = crc ^ 0xEDB88320;
            }
            else
                crc >>= 1;
            byte >>= 1;
        }
    }
    return (uint8)(crc >> 26);
}
/********************************************************************/

-mnorman


0 Kudos
456 Views
ynaught
Contributor III
That one works, when none of the others I tried did.  All the algorithms I'd found used 0x04C11DB7, but I guess that'd be the MSB-first version...
 
Thank you!
 
0 Kudos